aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartekgola@gmail.com>2015-09-04 10:35:22 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-09-21 13:15:00 +0200
commitd9892fa0c3abf28b71996e5bc7c133f29f987a7b (patch)
tree49f13b7de5f863ff69ab62cc340a2735087e098c
parent8aa7cf305ba5133721aa9852b398cbf1867fc857 (diff)
downloadbusybox-w32-d9892fa0c3abf28b71996e5bc7c133f29f987a7b.tar.gz
busybox-w32-d9892fa0c3abf28b71996e5bc7c133f29f987a7b.tar.bz2
busybox-w32-d9892fa0c3abf28b71996e5bc7c133f29f987a7b.zip
i2c-tools: remove duplicate definitions
Most applets include linux' user API headers instead of duplicating the definitions. Make it the case for i2c-tools as well. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/i2c_tools.c102
1 files changed, 2 insertions, 100 deletions
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index 38d90ff10..b78860277 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -61,113 +61,15 @@
61 61
62#include "libbb.h" 62#include "libbb.h"
63 63
64/* 64#include <linux/i2c.h>
65 * /dev/i2c-X ioctl commands. The ioctl's parameter is always an unsigned long, 65#include <linux/i2c-dev.h>
66 * except for:
67 * - I2C_FUNCS, takes pointer to an unsigned long
68 * - I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data
69 * - I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data
70 */
71
72/*
73 * NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
74 * are not supported due to code brokenness.
75 */
76
77/* Use this slave address. */
78#define I2C_SLAVE 0x0703
79/* Use this slave address, even if it is already in use by a driver. */
80#define I2C_SLAVE_FORCE 0x0706
81/* 0 for 7 bit addrs, != 0 for 10 bit. */
82#define I2C_TENBIT 0x0704
83/* Get the adapter functionality mask. */
84#define I2C_FUNCS 0x0705
85/* Combined R/W transfer (one STOP only). */
86#define I2C_RDWR 0x0707
87/* != 0 to use PEC with SMBus. */
88#define I2C_PEC 0x0708
89/* SMBus transfer. */
90#define I2C_SMBUS 0x0720
91
92/* Structure used in the I2C_SMBUS ioctl call. */
93struct i2c_smbus_ioctl_data {
94 uint8_t read_write;
95 uint8_t command;
96 uint32_t size;
97 union i2c_smbus_data *data;
98};
99 66
100/* Structure used in the I2C_RDWR ioctl call. */
101struct i2c_rdwr_ioctl_data {
102 struct i2c_msg *msgs; /* Pointers to i2c_msgs. */
103 uint32_t nmsgs; /* Number of i2c_msgs. */
104};
105
106/* As specified in SMBus standard. */
107#define I2C_SMBUS_BLOCK_MAX 32
108/* Not specified but we use same structure. */
109#define I2C_SMBUS_I2C_BLOCK_MAX 32
110
111/* Data for SMBus Messages. */
112union i2c_smbus_data {
113 uint8_t byte;
114 uint16_t word;
115 /* block[0] is used for length and one more for PEC */
116 uint8_t block[I2C_SMBUS_BLOCK_MAX + 2];
117};
118
119#define I2C_RDRW_IOCTL_MAX_MSGS 42
120#define I2C_MAX_REGS 256 67#define I2C_MAX_REGS 256
121 68
122/* Smbus_access read or write markers. */
123#define I2C_SMBUS_READ 1
124#define I2C_SMBUS_WRITE 0
125
126/* SMBus transaction types (size parameter in the below functions). */
127#define I2C_SMBUS_QUICK 0
128#define I2C_SMBUS_BYTE 1
129#define I2C_SMBUS_BYTE_DATA 2
130#define I2C_SMBUS_WORD_DATA 3
131#define I2C_SMBUS_PROC_CALL 4
132#define I2C_SMBUS_BLOCK_DATA 5
133#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
134#define I2C_SMBUS_BLOCK_PROC_CALL 7
135#define I2C_SMBUS_I2C_BLOCK_DATA 8
136
137#define DETECT_MODE_AUTO 0 69#define DETECT_MODE_AUTO 0
138#define DETECT_MODE_QUICK 1 70#define DETECT_MODE_QUICK 1
139#define DETECT_MODE_READ 2 71#define DETECT_MODE_READ 2
140 72
141/* Defines to determine what functionality is present. */
142#define I2C_FUNC_I2C 0x00000001
143#define I2C_FUNC_10BIT_ADDR 0x00000002
144#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004
145#define I2C_FUNC_SMBUS_PEC 0x00000008
146#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000
147#define I2C_FUNC_SMBUS_QUICK 0x00010000
148#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
149#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
150#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
151#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
152#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
153#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
154#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
155#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
156#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
157#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000
158#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000
159
160#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
161 I2C_FUNC_SMBUS_WRITE_BYTE)
162#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
163 I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
164#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
165 I2C_FUNC_SMBUS_WRITE_WORD_DATA)
166#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
167 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
168#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
169 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
170
171/* 73/*
172 * This is needed for ioctl_or_perror_and_die() since it only accepts pointers. 74 * This is needed for ioctl_or_perror_and_die() since it only accepts pointers.
173 */ 75 */