aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/i2c_tools.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index 03a09d519..52fc5ec6b 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -8,7 +8,6 @@
8 * 8 *
9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 */ 10 */
11
12//config:config I2CGET 11//config:config I2CGET
13//config: bool "i2cget (5.6 kb)" 12//config: bool "i2cget (5.6 kb)"
14//config: default y 13//config: default y
@@ -63,7 +62,6 @@
63#include "libbb.h" 62#include "libbb.h"
64 63
65#include <linux/i2c.h> 64#include <linux/i2c.h>
66#include <linux/i2c-dev.h>
67 65
68#define I2CDUMP_NUM_REGS 256 66#define I2CDUMP_NUM_REGS 256
69 67
@@ -71,6 +69,25 @@
71#define I2CDETECT_MODE_QUICK 1 69#define I2CDETECT_MODE_QUICK 1
72#define I2CDETECT_MODE_READ 2 70#define I2CDETECT_MODE_READ 2
73 71
72/* linux/i2c-dev.h from i2c-tools overwrites the one from linux uapi
73 * and defines symbols already defined by linux/i2c.h.
74 * Also, it defines a bunch of static inlines which we would rather NOT
75 * inline. What a mess.
76 * We need only these definitions from linux/i2c-dev.h:
77 */
78#define I2C_SLAVE 0x0703
79#define I2C_SLAVE_FORCE 0x0706
80#define I2C_FUNCS 0x0705
81#define I2C_PEC 0x0708
82#define I2C_SMBUS 0x0720
83struct i2c_smbus_ioctl_data {
84 __u8 read_write;
85 __u8 command;
86 __u32 size;
87 union i2c_smbus_data *data;
88};
89/* end linux/i2c-dev.h */
90
74/* 91/*
75 * This is needed for ioctl_or_perror_and_die() since it only accepts pointers. 92 * This is needed for ioctl_or_perror_and_die() since it only accepts pointers.
76 */ 93 */
@@ -1187,18 +1204,17 @@ static void will_skip(const char *cmd)
1187} 1204}
1188 1205
1189//usage:#define i2cdetect_trivial_usage 1206//usage:#define i2cdetect_trivial_usage
1190//usage: "[-F I2CBUS] [-l] [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]" 1207//usage: "-l | -F I2CBUS | [-ya] [-q|-r] I2CBUS [FIRST LAST]"
1191//usage:#define i2cdetect_full_usage "\n\n" 1208//usage:#define i2cdetect_full_usage "\n\n"
1192//usage: "Detect I2C chips.\n" 1209//usage: "Detect I2C chips"
1193//usage: "\n I2CBUS i2c bus number"
1194//usage: "\n FIRST and LAST limit the probing range"
1195//usage: "\n" 1210//usage: "\n"
1196//usage: "\n -l output list of installed busses" 1211//usage: "\n -l Print list of installed buses"
1197//usage: "\n -y disable interactive mode" 1212//usage: "\n -F BUS# Print list of functionalities on this bus"
1198//usage: "\n -a force scanning of non-regular addresses" 1213//usage: "\n -y Disable interactive mode"
1199//usage: "\n -q use smbus quick write commands for probing (default)" 1214//usage: "\n -a Force scanning of non-regular addresses"
1200//usage: "\n -r use smbus read byte commands for probing" 1215//usage: "\n -q Use smbus quick write commands for probing (default)"
1201//usage: "\n -F display list of functionalities" 1216//usage: "\n -r Use smbus read byte commands for probing"
1217//usage: "\n FIRST and LAST limit probing range"
1202int i2cdetect_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1218int i2cdetect_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
1203int i2cdetect_main(int argc UNUSED_PARAM, char **argv) 1219int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
1204{ 1220{
@@ -1213,7 +1229,8 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
1213 opts = getopt32(argv, "^" 1229 opts = getopt32(argv, "^"
1214 "yaqrFl" 1230 "yaqrFl"
1215 "\0" 1231 "\0"
1216 "q--r:r--q:"/*mutually exclusive*/ "?3"/*up to 3 args*/ 1232 "q--r:r--q:"/*mutually exclusive*/
1233 "?3"/*up to 3 args*/
1217 ); 1234 );
1218 argv += optind; 1235 argv += optind;
1219 1236