From 66663ae72a2b40b009108ce4582be075e536f09c Mon Sep 17 00:00:00 2001 From: Joshua Yang Date: Thu, 10 May 2018 13:43:52 +0900 Subject: [PATCH] wiringPi: Move moduleLoaded function to export Change-Id: Ie74b852ebdd596bb3dfd7ec6ec37c7f050948195 --- gpio/gpio_odroid.c | 32 -------------------------------- wiringPi/wiringOdroid.c | 30 ++++++++++++++++++++++++++++++ wiringPi/wiringOdroid.h | 1 + 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/gpio/gpio_odroid.c b/gpio/gpio_odroid.c index 4616f80..8973bb6 100755 --- a/gpio/gpio_odroid.c +++ b/gpio/gpio_odroid.c @@ -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. diff --git a/wiringPi/wiringOdroid.c b/wiringPi/wiringOdroid.c index 7b2955f..738479c 100755 --- a/wiringPi/wiringOdroid.c +++ b/wiringPi/wiringOdroid.c @@ -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 diff --git a/wiringPi/wiringOdroid.h b/wiringPi/wiringOdroid.h index ef1ca09..d6df8d1 100755 --- a/wiringPi/wiringOdroid.h +++ b/wiringPi/wiringOdroid.h @@ -89,6 +89,7 @@ extern "C" { // Export function define /*----------------------------------------------------------------------------*/ extern int msg (int type, const char *message, ...); +extern int moduleLoaded(char *); #ifdef __cplusplus }