aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2011-01-10 16:11:23 -0500
committerJean Delvare <khali@endymion.delvare>2011-01-10 16:11:23 -0500
commit0cc43a1806f078f7fd414850d8f1f1761696e4af (patch)
tree2278fca3af95002a867fa72b34e4ca97ccf5489f
parentaf5a60baaee66e2f891dbb9a8519ca28ab7da7cd (diff)
i2c: Constify i2c_client where possible
Helper functions for I2C and SMBus transactions don't modify the i2c_client that is passed to them, so it can be marked const. Signed-off-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/i2c/i2c-core.c29
-rw-r--r--drivers/rtc/rtc-ds1307.c12
-rw-r--r--include/linux/i2c.h27
3 files changed, 37 insertions, 31 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 6b4cc567645b..c7db6980e3a3 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1362,7 +1362,7 @@ EXPORT_SYMBOL(i2c_transfer);
1362 * 1362 *
1363 * Returns negative errno, or else the number of bytes written. 1363 * Returns negative errno, or else the number of bytes written.
1364 */ 1364 */
1365int i2c_master_send(struct i2c_client *client, const char *buf, int count) 1365int i2c_master_send(const struct i2c_client *client, const char *buf, int count)
1366{ 1366{
1367 int ret; 1367 int ret;
1368 struct i2c_adapter *adap = client->adapter; 1368 struct i2c_adapter *adap = client->adapter;
@@ -1389,7 +1389,7 @@ EXPORT_SYMBOL(i2c_master_send);
1389 * 1389 *
1390 * Returns negative errno, or else the number of bytes read. 1390 * Returns negative errno, or else the number of bytes read.
1391 */ 1391 */
1392int i2c_master_recv(struct i2c_client *client, char *buf, int count) 1392int i2c_master_recv(const struct i2c_client *client, char *buf, int count)
1393{ 1393{
1394 struct i2c_adapter *adap = client->adapter; 1394 struct i2c_adapter *adap = client->adapter;
1395 struct i2c_msg msg; 1395 struct i2c_msg msg;
@@ -1679,7 +1679,7 @@ static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg)
1679 * This executes the SMBus "receive byte" protocol, returning negative errno 1679 * This executes the SMBus "receive byte" protocol, returning negative errno
1680 * else the byte received from the device. 1680 * else the byte received from the device.
1681 */ 1681 */
1682s32 i2c_smbus_read_byte(struct i2c_client *client) 1682s32 i2c_smbus_read_byte(const struct i2c_client *client)
1683{ 1683{
1684 union i2c_smbus_data data; 1684 union i2c_smbus_data data;
1685 int status; 1685 int status;
@@ -1699,7 +1699,7 @@ EXPORT_SYMBOL(i2c_smbus_read_byte);
1699 * This executes the SMBus "send byte" protocol, returning negative errno 1699 * This executes the SMBus "send byte" protocol, returning negative errno
1700 * else zero on success. 1700 * else zero on success.
1701 */ 1701 */
1702s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) 1702s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value)
1703{ 1703{
1704 return i2c_smbus_xfer(client->adapter, client->addr, client->flags, 1704 return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
1705 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); 1705 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
@@ -1714,7 +1714,7 @@ EXPORT_SYMBOL(i2c_smbus_write_byte);
1714 * This executes the SMBus "read byte" protocol, returning negative errno 1714 * This executes the SMBus "read byte" protocol, returning negative errno
1715 * else a data byte received from the device. 1715 * else a data byte received from the device.
1716 */ 1716 */
1717s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) 1717s32 i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command)
1718{ 1718{
1719 union i2c_smbus_data data; 1719 union i2c_smbus_data data;
1720 int status; 1720 int status;
@@ -1735,7 +1735,8 @@ EXPORT_SYMBOL(i2c_smbus_read_byte_data);
1735 * This executes the SMBus "write byte" protocol, returning negative errno 1735 * This executes the SMBus "write byte" protocol, returning negative errno
1736 * else zero on success. 1736 * else zero on success.
1737 */ 1737 */
1738s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) 1738s32 i2c_smbus_write_byte_data(const struct i2c_client *client, u8 command,
1739 u8 value)
1739{ 1740{
1740 union i2c_smbus_data data; 1741 union i2c_smbus_data data;
1741 data.byte = value; 1742 data.byte = value;
@@ -1753,7 +1754,7 @@ EXPORT_SYMBOL(i2c_smbus_write_byte_data);
1753 * This executes the SMBus "read word" protocol, returning negative errno 1754 * This executes the SMBus "read word" protocol, returning negative errno
1754 * else a 16-bit unsigned "word" received from the device. 1755 * else a 16-bit unsigned "word" received from the device.
1755 */ 1756 */
1756s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command) 1757s32 i2c_smbus_read_word_data(const struct i2c_client *client, u8 command)
1757{ 1758{
1758 union i2c_smbus_data data; 1759 union i2c_smbus_data data;
1759 int status; 1760 int status;
@@ -1774,7 +1775,8 @@ EXPORT_SYMBOL(i2c_smbus_read_word_data);
1774 * This executes the SMBus "write word" protocol, returning negative errno 1775 * This executes the SMBus "write word" protocol, returning negative errno
1775 * else zero on success. 1776 * else zero on success.
1776 */ 1777 */
1777s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) 1778s32 i2c_smbus_write_word_data(const struct i2c_client *client, u8 command,
1779 u16 value)
1778{ 1780{
1779 union i2c_smbus_data data; 1781 union i2c_smbus_data data;
1780 data.word = value; 1782 data.word = value;
@@ -1793,7 +1795,8 @@ EXPORT_SYMBOL(i2c_smbus_write_word_data);
1793 * This executes the SMBus "process call" protocol, returning negative errno 1795 * This executes the SMBus "process call" protocol, returning negative errno
1794 * else a 16-bit unsigned "word" received from the device. 1796 * else a 16-bit unsigned "word" received from the device.
1795 */ 1797 */
1796s32 i2c_smbus_process_call(struct i2c_client *client, u8 command, u16 value) 1798s32 i2c_smbus_process_call(const struct i2c_client *client, u8 command,
1799 u16 value)
1797{ 1800{
1798 union i2c_smbus_data data; 1801 union i2c_smbus_data data;
1799 int status; 1802 int status;
@@ -1821,7 +1824,7 @@ EXPORT_SYMBOL(i2c_smbus_process_call);
1821 * support this; its emulation through I2C messaging relies on a specific 1824 * support this; its emulation through I2C messaging relies on a specific
1822 * mechanism (I2C_M_RECV_LEN) which may not be implemented. 1825 * mechanism (I2C_M_RECV_LEN) which may not be implemented.
1823 */ 1826 */
1824s32 i2c_smbus_read_block_data(struct i2c_client *client, u8 command, 1827s32 i2c_smbus_read_block_data(const struct i2c_client *client, u8 command,
1825 u8 *values) 1828 u8 *values)
1826{ 1829{
1827 union i2c_smbus_data data; 1830 union i2c_smbus_data data;
@@ -1848,7 +1851,7 @@ EXPORT_SYMBOL(i2c_smbus_read_block_data);
1848 * This executes the SMBus "block write" protocol, returning negative errno 1851 * This executes the SMBus "block write" protocol, returning negative errno
1849 * else zero on success. 1852 * else zero on success.
1850 */ 1853 */
1851s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, 1854s32 i2c_smbus_write_block_data(const struct i2c_client *client, u8 command,
1852 u8 length, const u8 *values) 1855 u8 length, const u8 *values)
1853{ 1856{
1854 union i2c_smbus_data data; 1857 union i2c_smbus_data data;
@@ -1864,7 +1867,7 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
1864EXPORT_SYMBOL(i2c_smbus_write_block_data); 1867EXPORT_SYMBOL(i2c_smbus_write_block_data);
1865 1868
1866/* Returns the number of read bytes */ 1869/* Returns the number of read bytes */
1867s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, 1870s32 i2c_smbus_read_i2c_block_data(const struct i2c_client *client, u8 command,
1868 u8 length, u8 *values) 1871 u8 length, u8 *values)
1869{ 1872{
1870 union i2c_smbus_data data; 1873 union i2c_smbus_data data;
@@ -1884,7 +1887,7 @@ s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command,
1884} 1887}
1885EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data); 1888EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data);
1886 1889
1887s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, 1890s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client, u8 command,
1888 u8 length, const u8 *values) 1891 u8 length, const u8 *values)
1889{ 1892{
1890 union i2c_smbus_data data; 1893 union i2c_smbus_data data;
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index d827ce570a8c..0d559b6416dd 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -106,9 +106,9 @@ struct ds1307 {
106 struct i2c_client *client; 106 struct i2c_client *client;
107 struct rtc_device *rtc; 107 struct rtc_device *rtc;
108 struct work_struct work; 108 struct work_struct work;
109 s32 (*read_block_data)(struct i2c_client *client, u8 command, 109 s32 (*read_block_data)(const struct i2c_client *client, u8 command,
110 u8 length, u8 *values); 110 u8 length, u8 *values);
111 s32 (*write_block_data)(struct i2c_client *client, u8 command, 111 s32 (*write_block_data)(const struct i2c_client *client, u8 command,
112 u8 length, const u8 *values); 112 u8 length, const u8 *values);
113}; 113};
114 114
@@ -158,8 +158,8 @@ MODULE_DEVICE_TABLE(i2c, ds1307_id);
158 158
159#define BLOCK_DATA_MAX_TRIES 10 159#define BLOCK_DATA_MAX_TRIES 10
160 160
161static s32 ds1307_read_block_data_once(struct i2c_client *client, u8 command, 161static s32 ds1307_read_block_data_once(const struct i2c_client *client,
162 u8 length, u8 *values) 162 u8 command, u8 length, u8 *values)
163{ 163{
164 s32 i, data; 164 s32 i, data;
165 165
@@ -172,7 +172,7 @@ static s32 ds1307_read_block_data_once(struct i2c_client *client, u8 command,
172 return i; 172 return i;
173} 173}
174 174
175static s32 ds1307_read_block_data(struct i2c_client *client, u8 command, 175static s32 ds1307_read_block_data(const struct i2c_client *client, u8 command,
176 u8 length, u8 *values) 176 u8 length, u8 *values)
177{ 177{
178 u8 oldvalues[I2C_SMBUS_BLOCK_MAX]; 178 u8 oldvalues[I2C_SMBUS_BLOCK_MAX];
@@ -198,7 +198,7 @@ static s32 ds1307_read_block_data(struct i2c_client *client, u8 command,
198 return length; 198 return length;
199} 199}
200 200
201static s32 ds1307_write_block_data(struct i2c_client *client, u8 command, 201static s32 ds1307_write_block_data(const struct i2c_client *client, u8 command,
202 u8 length, const u8 *values) 202 u8 length, const u8 *values)
203{ 203{
204 u8 currvalues[I2C_SMBUS_BLOCK_MAX]; 204 u8 currvalues[I2C_SMBUS_BLOCK_MAX];
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 56cfe23ffb39..903576df88dc 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -57,9 +57,10 @@ struct i2c_board_info;
57 * transmit an arbitrary number of messages without interruption. 57 * transmit an arbitrary number of messages without interruption.
58 * @count must be be less than 64k since msg.len is u16. 58 * @count must be be less than 64k since msg.len is u16.
59 */ 59 */
60extern int i2c_master_send(struct i2c_client *client, const char *buf, 60extern int i2c_master_send(const struct i2c_client *client, const char *buf,
61 int count);
62extern int i2c_master_recv(const struct i2c_client *client, char *buf,
61 int count); 63 int count);
62extern int i2c_master_recv(struct i2c_client *client, char *buf, int count);
63 64
64/* Transfer num messages. 65/* Transfer num messages.
65 */ 66 */
@@ -78,23 +79,25 @@ extern s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
78/* Now follow the 'nice' access routines. These also document the calling 79/* Now follow the 'nice' access routines. These also document the calling
79 conventions of i2c_smbus_xfer. */ 80 conventions of i2c_smbus_xfer. */
80 81
81extern s32 i2c_smbus_read_byte(struct i2c_client *client); 82extern s32 i2c_smbus_read_byte(const struct i2c_client *client);
82extern s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value); 83extern s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value);
83extern s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command); 84extern s32 i2c_smbus_read_byte_data(const struct i2c_client *client,
84extern s32 i2c_smbus_write_byte_data(struct i2c_client *client, 85 u8 command);
86extern s32 i2c_smbus_write_byte_data(const struct i2c_client *client,
85 u8 command, u8 value); 87 u8 command, u8 value);
86extern s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command); 88extern s32 i2c_smbus_read_word_data(const struct i2c_client *client,
87extern s32 i2c_smbus_write_word_data(struct i2c_client *client, 89 u8 command);
90extern s32 i2c_smbus_write_word_data(const struct i2c_client *client,
88 u8 command, u16 value); 91 u8 command, u16 value);
89/* Returns the number of read bytes */ 92/* Returns the number of read bytes */
90extern s32 i2c_smbus_read_block_data(struct i2c_client *client, 93extern s32 i2c_smbus_read_block_data(const struct i2c_client *client,
91 u8 command, u8 *values); 94 u8 command, u8 *values);
92extern s32 i2c_smbus_write_block_data(struct i2c_client *client, 95extern s32 i2c_smbus_write_block_data(const struct i2c_client *client,
93 u8 command, u8 length, const u8 *values); 96 u8 command, u8 length, const u8 *values);
94/* Returns the number of read bytes */ 97/* Returns the number of read bytes */
95extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, 98extern s32 i2c_smbus_read_i2c_block_data(const struct i2c_client *client,
96 u8 command, u8 length, u8 *values); 99 u8 command, u8 length, u8 *values);
97extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, 100extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client,
98 u8 command, u8 length, 101 u8 command, u8 length,
99 const u8 *values); 102 const u8 *values);
100#endif /* I2C */ 103#endif /* I2C */