aboutsummaryrefslogtreecommitdiff
path: root/miscutils/i2c_tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils/i2c_tools.c')
-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);