wiringPi: Move moduleLoaded function to export
Change-Id: Ie74b852ebdd596bb3dfd7ec6ec37c7f050948195
This commit is contained in:
@@ -161,38 +161,6 @@ static void changeOwner (char *cmd, char *file)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* moduleLoaded:
|
||||
* Return true/false if the supplied module is loaded
|
||||
*********************************************************************************
|
||||
*/
|
||||
static int moduleLoaded (char *modName)
|
||||
{
|
||||
int len = strlen (modName) ;
|
||||
int found = FALSE ;
|
||||
FILE *fd = fopen ("/proc/modules", "r") ;
|
||||
char line [80] ;
|
||||
|
||||
if (fd == NULL) {
|
||||
fprintf (stderr, "gpio: Unable to check /proc/modules: %s\n",
|
||||
strerror (errno)) ;
|
||||
exit (1) ;
|
||||
}
|
||||
|
||||
while (fgets (line, 80, fd) != NULL) {
|
||||
if (strncmp (line, modName, len) != 0)
|
||||
continue ;
|
||||
|
||||
found = TRUE ;
|
||||
break ;
|
||||
}
|
||||
fclose (fd) ;
|
||||
|
||||
return found ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doLoad:
|
||||
* Load either the spi or i2c modules and change device ownerships, etc.
|
||||
|
||||
@@ -115,6 +115,36 @@ int wiringPiReturnCodes = FALSE ;
|
||||
// ODROID Wiring Library
|
||||
struct libodroid libwiring;
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
//
|
||||
// Return true/false if the supplied module is loaded
|
||||
//
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int moduleLoaded (char *modName)
|
||||
{
|
||||
int len = strlen (modName) ;
|
||||
int found = FALSE ;
|
||||
FILE *fd = fopen ("/proc/modules", "r") ;
|
||||
char line [80] ;
|
||||
|
||||
if (fd == NULL) {
|
||||
fprintf (stderr, "gpio: Unable to check /proc/modules: %s\n",
|
||||
strerror (errno)) ;
|
||||
exit (1) ;
|
||||
}
|
||||
|
||||
while (fgets (line, 80, fd) != NULL) {
|
||||
if (strncmp (line, modName, len) != 0)
|
||||
continue ;
|
||||
|
||||
found = TRUE ;
|
||||
break ;
|
||||
}
|
||||
fclose (fd) ;
|
||||
|
||||
return found ;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
//
|
||||
// ODROID System Message function
|
||||
|
||||
@@ -89,6 +89,7 @@ extern "C" {
|
||||
// Export function define
|
||||
/*----------------------------------------------------------------------------*/
|
||||
extern int msg (int type, const char *message, ...);
|
||||
extern int moduleLoaded(char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user