Changeset 5202
- Timestamp:
- 04/24/08 14:22:59 (7 months ago)
- Files:
-
- i2c-tools/trunk/tools/i2cbusses.c (modified) (4 diffs)
- i2c-tools/trunk/tools/i2cbusses.h (modified) (1 diff)
- i2c-tools/trunk/tools/i2cdetect.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
i2c-tools/trunk/tools/i2cbusses.c
r5200 r5202 56 56 }; 57 57 58 struct i2c_adap {59 int nr;60 char *name;61 const char *funcs;62 const char *algo;63 };64 65 58 static enum adt i2c_get_funcs(int i2cbus) 66 59 { … … 100 93 } 101 94 102 staticvoid free_adapters(struct i2c_adap *adapters)95 void free_adapters(struct i2c_adap *adapters) 103 96 { 104 97 int i; … … 129 122 } 130 123 131 st atic struct i2c_adap *gather_i2c_busses(void)124 struct i2c_adap *gather_i2c_busses(void) 132 125 { 133 126 char s[120]; … … 295 288 } 296 289 297 /*298 * Print the installed i2c busses. The format is those of Linux 2.4's299 * /proc/bus/i2c for historical compatibility reasons.300 */301 void print_i2c_busses(void)302 {303 struct i2c_adap *adapters;304 int count;305 306 adapters = gather_i2c_busses();307 if (adapters == NULL) {308 fprintf(stderr, "Error: Out of memory!\n");309 return;310 }311 312 for (count = 0; adapters[count].name; count++) {313 printf("i2c-%d\t%-10s\t%-32s\t%s\n",314 adapters[count].nr, adapters[count].funcs,315 adapters[count].name, adapters[count].algo);316 }317 318 free_adapters(adapters);319 }320 321 290 static int lookup_i2c_bus_by_name(const char *bus_name) 322 291 { i2c-tools/trunk/tools/i2cbusses.h
r5200 r5202 23 23 #define _I2CBUSSES_H 24 24 25 void print_i2c_busses(void); 25 struct i2c_adap { 26 int nr; 27 char *name; 28 const char *funcs; 29 const char *algo; 30 }; 31 32 struct i2c_adap *gather_i2c_busses(void); 33 void free_adapters(struct i2c_adap *adapters); 26 34 27 35 int lookup_i2c_bus(const char *i2cbus_arg); i2c-tools/trunk/tools/i2cdetect.c
r5201 r5202 159 159 } 160 160 161 /* 162 * Print the installed i2c busses. The format is those of Linux 2.4's 163 * /proc/bus/i2c for historical compatibility reasons. 164 */ 165 static void print_i2c_busses(void) 166 { 167 struct i2c_adap *adapters; 168 int count; 169 170 adapters = gather_i2c_busses(); 171 if (adapters == NULL) { 172 fprintf(stderr, "Error: Out of memory!\n"); 173 return; 174 } 175 176 for (count = 0; adapters[count].name; count++) { 177 printf("i2c-%d\t%-10s\t%-32s\t%s\n", 178 adapters[count].nr, adapters[count].funcs, 179 adapters[count].name, adapters[count].algo); 180 } 181 182 free_adapters(adapters); 183 } 184 161 185 int main(int argc, char *argv[]) 162 186 {
