i2c: guarantee that I2C_M_RD will be 0x0001 forever
authorWolfram Sang <wsa@the-dreams.de>
Sun, 3 Apr 2016 18:44:44 +0000 (20:44 +0200)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 11 Apr 2016 16:54:59 +0000 (18:54 +0200)
There is code out there in user space and kernel space which relies on
I2C_M_RD being bit 0 to simplify their bit operations. Add a comment to
make sure this will never break. Do proper sorting of the defines while
we are here.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
include/uapi/linux/i2c.h

index b0a7dd61eb353a273e3009a01e0682495064e643..adcbef4bff610af948ab40cfd3d63b6d167abaa8 100644 (file)
 struct i2c_msg {
        __u16 addr;     /* slave address                        */
        __u16 flags;
-#define I2C_M_TEN              0x0010  /* this is a ten bit chip address */
 #define I2C_M_RD               0x0001  /* read data, from slave to master */
-#define I2C_M_STOP             0x8000  /* if I2C_FUNC_PROTOCOL_MANGLING */
-#define I2C_M_NOSTART          0x4000  /* if I2C_FUNC_NOSTART */
-#define I2C_M_REV_DIR_ADDR     0x2000  /* if I2C_FUNC_PROTOCOL_MANGLING */
-#define I2C_M_IGNORE_NAK       0x1000  /* if I2C_FUNC_PROTOCOL_MANGLING */
-#define I2C_M_NO_RD_ACK                0x0800  /* if I2C_FUNC_PROTOCOL_MANGLING */
+                                       /* I2C_M_RD is guaranteed to be 0x0001! */
+#define I2C_M_TEN              0x0010  /* this is a ten bit chip address */
 #define I2C_M_RECV_LEN         0x0400  /* length will be first received byte */
+#define I2C_M_NO_RD_ACK                0x0800  /* if I2C_FUNC_PROTOCOL_MANGLING */
+#define I2C_M_IGNORE_NAK       0x1000  /* if I2C_FUNC_PROTOCOL_MANGLING */
+#define I2C_M_REV_DIR_ADDR     0x2000  /* if I2C_FUNC_PROTOCOL_MANGLING */
+#define I2C_M_NOSTART          0x4000  /* if I2C_FUNC_NOSTART */
+#define I2C_M_STOP             0x8000  /* if I2C_FUNC_PROTOCOL_MANGLING */
        __u16 len;              /* msg length                           */
        __u8 *buf;              /* pointer to msg data                  */
 };