diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c index d379247..434b8a3 100644 --- a/tools/i2cbusses.c +++ b/tools/i2cbusses.c @@ -55,13 +55,6 @@ static struct adap_type adap_types[5] = { .algo = "N/A", }, }; -struct i2c_adap { - int nr; - char *name; - const char *funcs; - const char *algo; -}; - static enum adt i2c_get_funcs(int i2cbus) { unsigned long funcs; @@ -99,7 +92,7 @@ static int rtrim(char *s) return i + 2; } -static void free_adapters(struct i2c_adap *adapters) +void free_adapters(struct i2c_adap *adapters) { int i; @@ -128,7 +121,7 @@ static struct i2c_adap *more_adapters(struct i2c_adap *adapters, int n) return new_adapters; } -static struct i2c_adap *gather_i2c_busses(void) +struct i2c_adap *gather_i2c_busses(void) { char s[120]; struct dirent *de, *dde; @@ -294,30 +287,6 @@ done: return adapters; } -/* - * Print the installed i2c busses. The format is those of Linux 2.4's - * /proc/bus/i2c for historical compatibility reasons. - */ -void print_i2c_busses(void) -{ - struct i2c_adap *adapters; - int count; - - adapters = gather_i2c_busses(); - if (adapters == NULL) { - fprintf(stderr, "Error: Out of memory!\n"); - return; - } - - for (count = 0; adapters[count].name; count++) { - printf("i2c-%d\t%-10s\t%-32s\t%s\n", - adapters[count].nr, adapters[count].funcs, - adapters[count].name, adapters[count].algo); - } - - free_adapters(adapters); -} - static int lookup_i2c_bus_by_name(const char *bus_name) { struct i2c_adap *adapters; diff --git a/tools/i2cbusses.h b/tools/i2cbusses.h index 464b1f2..a2f3476 100644 --- a/tools/i2cbusses.h +++ b/tools/i2cbusses.h @@ -22,7 +22,15 @@ #ifndef _I2CBUSSES_H #define _I2CBUSSES_H -void print_i2c_busses(void); +struct i2c_adap { + int nr; + char *name; + const char *funcs; + const char *algo; +}; + +struct i2c_adap *gather_i2c_busses(void); +void free_adapters(struct i2c_adap *adapters); int lookup_i2c_bus(const char *i2cbus_arg); int open_i2c_dev(const int i2cbus, char *filename, const int quiet); diff --git a/tools/i2cdetect.c b/tools/i2cdetect.c index 342e7d7..f2552f1 100644 --- a/tools/i2cdetect.c +++ b/tools/i2cdetect.c @@ -158,6 +158,30 @@ static void print_functionality(unsigned long funcs) } } +/* + * Print the installed i2c busses. The format is those of Linux 2.4's + * /proc/bus/i2c for historical compatibility reasons. + */ +static void print_i2c_busses(void) +{ + struct i2c_adap *adapters; + int count; + + adapters = gather_i2c_busses(); + if (adapters == NULL) { + fprintf(stderr, "Error: Out of memory!\n"); + return; + } + + for (count = 0; adapters[count].name; count++) { + printf("i2c-%d\t%-10s\t%-32s\t%s\n", + adapters[count].nr, adapters[count].funcs, + adapters[count].name, adapters[count].algo); + } + + free_adapters(adapters); +} + int main(int argc, char *argv[]) { char *end;