summaryrefslogtreecommitdiff
path: root/miscutils/i2c_tools.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2015-05-18 09:36:27 +0100
committerRon Yorston <rmy@pobox.com>2015-05-18 09:36:27 +0100
commit60063627a6d540871061854a362047e6517f821c (patch)
tree0de228630450c64e085f2e3f5141b5ba17eccab3 /miscutils/i2c_tools.c
parentec39cb770ddd5c0e085d5c4ee10be65bab5e7a44 (diff)
parent9a595bb36ded308e6d4336aef2c1cd3ac738a398 (diff)
downloadbusybox-w32-FRP.tar.gz
busybox-w32-FRP.tar.bz2
busybox-w32-FRP.zip
Merge branch 'busybox' into mergeFRP
Diffstat (limited to '')
-rw-r--r--miscutils/i2c_tools.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index 03bb03974..7034dc9a8 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -379,8 +379,12 @@ static int i2c_dev_open(int i2cbus)
379 sprintf(filename, "/dev/i2c-%d", i2cbus); 379 sprintf(filename, "/dev/i2c-%d", i2cbus);
380 fd = open(filename, O_RDWR); 380 fd = open(filename, O_RDWR);
381 if (fd < 0) { 381 if (fd < 0) {
382 filename[8] = '/'; /* change to "/dev/i2c/%d" */ 382 if (errno == ENOENT) {
383 fd = xopen(filename, O_RDWR); 383 filename[8] = '/'; /* change to "/dev/i2c/%d" */
384 fd = xopen(filename, O_RDWR);
385 } else {
386 bb_perror_msg_and_die("can't open '%s'", filename);
387 }
384 } 388 }
385 389
386 return fd; 390 return fd;
@@ -1284,13 +1288,16 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
1284 unsigned opts; 1288 unsigned opts;
1285 1289
1286 opt_complementary = "q--r:r--q:" /* mutually exclusive */ 1290 opt_complementary = "q--r:r--q:" /* mutually exclusive */
1287 "-1:?3"; /* from 1 to 3 args */ 1291 "?3"; /* up to 3 args */
1288 opts = getopt32(argv, optstr); 1292 opts = getopt32(argv, optstr);
1289 argv += optind; 1293 argv += optind;
1290 1294
1291 if (opts & opt_l) 1295 if (opts & opt_l)
1292 list_i2c_busses_and_exit(); 1296 list_i2c_busses_and_exit();
1293 1297
1298 if (!argv[0])
1299 bb_show_usage();
1300
1294 bus_num = i2c_bus_lookup(argv[0]); 1301 bus_num = i2c_bus_lookup(argv[0]);
1295 fd = i2c_dev_open(bus_num); 1302 fd = i2c_dev_open(bus_num);
1296 get_funcs_matrix(fd, &funcs); 1303 get_funcs_matrix(fd, &funcs);