Browse Source

Move print_i2c_busses from i2cbusses.c to i2cdetect.c, as it is

only used there.


git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5202 7894878c-1315-0410-8ee3-d5d059ff63e0
tags/v3.0.2
Jean Delvare 18 years ago
parent
commit
b331c042c8
  1. 35
      tools/i2cbusses.c
  2. 10
      tools/i2cbusses.h
  3. 24
      tools/i2cdetect.c

35
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;

10
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);

24
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;

Loading…
Cancel
Save