aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c210
1 files changed, 116 insertions, 94 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index bea4c5021d26..9a58994ff7ea 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -196,88 +196,60 @@ static int i2c_device_pm_suspend(struct device *dev)
196{ 196{
197 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 197 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
198 198
199 if (pm) { 199 if (pm)
200 if (pm_runtime_suspended(dev)) 200 return pm_generic_suspend(dev);
201 return 0; 201 else
202 else 202 return i2c_legacy_suspend(dev, PMSG_SUSPEND);
203 return pm->suspend ? pm->suspend(dev) : 0;
204 }
205
206 return i2c_legacy_suspend(dev, PMSG_SUSPEND);
207} 203}
208 204
209static int i2c_device_pm_resume(struct device *dev) 205static int i2c_device_pm_resume(struct device *dev)
210{ 206{
211 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 207 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
212 int ret;
213 208
214 if (pm) 209 if (pm)
215 ret = pm->resume ? pm->resume(dev) : 0; 210 return pm_generic_resume(dev);
216 else 211 else
217 ret = i2c_legacy_resume(dev); 212 return i2c_legacy_resume(dev);
218
219 return ret;
220} 213}
221 214
222static int i2c_device_pm_freeze(struct device *dev) 215static int i2c_device_pm_freeze(struct device *dev)
223{ 216{
224 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 217 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
225 218
226 if (pm) { 219 if (pm)
227 if (pm_runtime_suspended(dev)) 220 return pm_generic_freeze(dev);
228 return 0; 221 else
229 else 222 return i2c_legacy_suspend(dev, PMSG_FREEZE);
230 return pm->freeze ? pm->freeze(dev) : 0;
231 }
232
233 return i2c_legacy_suspend(dev, PMSG_FREEZE);
234} 223}
235 224
236static int i2c_device_pm_thaw(struct device *dev) 225static int i2c_device_pm_thaw(struct device *dev)
237{ 226{
238 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 227 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
239 228
240 if (pm) { 229 if (pm)
241 if (pm_runtime_suspended(dev)) 230 return pm_generic_thaw(dev);
242 return 0; 231 else
243 else 232 return i2c_legacy_resume(dev);
244 return pm->thaw ? pm->thaw(dev) : 0;
245 }
246
247 return i2c_legacy_resume(dev);
248} 233}
249 234
250static int i2c_device_pm_poweroff(struct device *dev) 235static int i2c_device_pm_poweroff(struct device *dev)
251{ 236{
252 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 237 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
253 238
254 if (pm) { 239 if (pm)
255 if (pm_runtime_suspended(dev)) 240 return pm_generic_poweroff(dev);
256 return 0; 241 else
257 else 242 return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
258 return pm->poweroff ? pm->poweroff(dev) : 0;
259 }
260
261 return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
262} 243}
263 244
264static int i2c_device_pm_restore(struct device *dev) 245static int i2c_device_pm_restore(struct device *dev)
265{ 246{
266 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 247 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
267 int ret;
268 248
269 if (pm) 249 if (pm)
270 ret = pm->restore ? pm->restore(dev) : 0; 250 return pm_generic_restore(dev);
271 else 251 else
272 ret = i2c_legacy_resume(dev); 252 return i2c_legacy_resume(dev);
273
274 if (!ret) {
275 pm_runtime_disable(dev);
276 pm_runtime_set_active(dev);
277 pm_runtime_enable(dev);
278 }
279
280 return ret;
281} 253}
282#else /* !CONFIG_PM_SLEEP */ 254#else /* !CONFIG_PM_SLEEP */
283#define i2c_device_pm_suspend NULL 255#define i2c_device_pm_suspend NULL
@@ -376,7 +348,7 @@ EXPORT_SYMBOL(i2c_verify_client);
376 348
377 349
378/* This is a permissive address validity check, I2C address map constraints 350/* This is a permissive address validity check, I2C address map constraints
379 * are purposedly not enforced, except for the general call address. */ 351 * are purposely not enforced, except for the general call address. */
380static int i2c_check_client_addr_validity(const struct i2c_client *client) 352static int i2c_check_client_addr_validity(const struct i2c_client *client)
381{ 353{
382 if (client->flags & I2C_CLIENT_TEN) { 354 if (client->flags & I2C_CLIENT_TEN) {
@@ -425,14 +397,14 @@ static int __i2c_check_addr_busy(struct device *dev, void *addrp)
425/* walk up mux tree */ 397/* walk up mux tree */
426static int i2c_check_mux_parents(struct i2c_adapter *adapter, int addr) 398static int i2c_check_mux_parents(struct i2c_adapter *adapter, int addr)
427{ 399{
400 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
428 int result; 401 int result;
429 402
430 result = device_for_each_child(&adapter->dev, &addr, 403 result = device_for_each_child(&adapter->dev, &addr,
431 __i2c_check_addr_busy); 404 __i2c_check_addr_busy);
432 405
433 if (!result && i2c_parent_is_i2c_adapter(adapter)) 406 if (!result && parent)
434 result = i2c_check_mux_parents( 407 result = i2c_check_mux_parents(parent, addr);
435 to_i2c_adapter(adapter->dev.parent), addr);
436 408
437 return result; 409 return result;
438} 410}
@@ -453,11 +425,11 @@ static int i2c_check_mux_children(struct device *dev, void *addrp)
453 425
454static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr) 426static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr)
455{ 427{
428 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
456 int result = 0; 429 int result = 0;
457 430
458 if (i2c_parent_is_i2c_adapter(adapter)) 431 if (parent)
459 result = i2c_check_mux_parents( 432 result = i2c_check_mux_parents(parent, addr);
460 to_i2c_adapter(adapter->dev.parent), addr);
461 433
462 if (!result) 434 if (!result)
463 result = device_for_each_child(&adapter->dev, &addr, 435 result = device_for_each_child(&adapter->dev, &addr,
@@ -472,8 +444,10 @@ static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr)
472 */ 444 */
473void i2c_lock_adapter(struct i2c_adapter *adapter) 445void i2c_lock_adapter(struct i2c_adapter *adapter)
474{ 446{
475 if (i2c_parent_is_i2c_adapter(adapter)) 447 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
476 i2c_lock_adapter(to_i2c_adapter(adapter->dev.parent)); 448
449 if (parent)
450 i2c_lock_adapter(parent);
477 else 451 else
478 rt_mutex_lock(&adapter->bus_lock); 452 rt_mutex_lock(&adapter->bus_lock);
479} 453}
@@ -485,8 +459,10 @@ EXPORT_SYMBOL_GPL(i2c_lock_adapter);
485 */ 459 */
486static int i2c_trylock_adapter(struct i2c_adapter *adapter) 460static int i2c_trylock_adapter(struct i2c_adapter *adapter)
487{ 461{
488 if (i2c_parent_is_i2c_adapter(adapter)) 462 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
489 return i2c_trylock_adapter(to_i2c_adapter(adapter->dev.parent)); 463
464 if (parent)
465 return i2c_trylock_adapter(parent);
490 else 466 else
491 return rt_mutex_trylock(&adapter->bus_lock); 467 return rt_mutex_trylock(&adapter->bus_lock);
492} 468}
@@ -497,8 +473,10 @@ static int i2c_trylock_adapter(struct i2c_adapter *adapter)
497 */ 473 */
498void i2c_unlock_adapter(struct i2c_adapter *adapter) 474void i2c_unlock_adapter(struct i2c_adapter *adapter)
499{ 475{
500 if (i2c_parent_is_i2c_adapter(adapter)) 476 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
501 i2c_unlock_adapter(to_i2c_adapter(adapter->dev.parent)); 477
478 if (parent)
479 i2c_unlock_adapter(parent);
502 else 480 else
503 rt_mutex_unlock(&adapter->bus_lock); 481 rt_mutex_unlock(&adapter->bus_lock);
504} 482}
@@ -559,9 +537,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
559 client->dev.parent = &client->adapter->dev; 537 client->dev.parent = &client->adapter->dev;
560 client->dev.bus = &i2c_bus_type; 538 client->dev.bus = &i2c_bus_type;
561 client->dev.type = &i2c_client_type; 539 client->dev.type = &i2c_client_type;
562#ifdef CONFIG_OF
563 client->dev.of_node = info->of_node; 540 client->dev.of_node = info->of_node;
564#endif
565 541
566 dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), 542 dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap),
567 client->addr); 543 client->addr);
@@ -677,8 +653,6 @@ i2c_sysfs_new_device(struct device *dev, struct device_attribute *attr,
677 char *blank, end; 653 char *blank, end;
678 int res; 654 int res;
679 655
680 dev_warn(dev, "The new_device interface is still experimental "
681 "and may change in a near future\n");
682 memset(&info, 0, sizeof(struct i2c_board_info)); 656 memset(&info, 0, sizeof(struct i2c_board_info));
683 657
684 blank = strchr(buf, ' '); 658 blank = strchr(buf, ' ');
@@ -823,6 +797,10 @@ static int i2c_do_add_adapter(struct i2c_driver *driver,
823 797
824 /* Let legacy drivers scan this bus for matching devices */ 798 /* Let legacy drivers scan this bus for matching devices */
825 if (driver->attach_adapter) { 799 if (driver->attach_adapter) {
800 dev_warn(&adap->dev, "%s: attach_adapter method is deprecated\n",
801 driver->driver.name);
802 dev_warn(&adap->dev, "Please use another way to instantiate "
803 "your i2c_client\n");
826 /* We ignore the return code; if it fails, too bad */ 804 /* We ignore the return code; if it fails, too bad */
827 driver->attach_adapter(adap); 805 driver->attach_adapter(adap);
828 } 806 }
@@ -844,6 +822,18 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
844 goto out_list; 822 goto out_list;
845 } 823 }
846 824
825 /* Sanity checks */
826 if (unlikely(adap->name[0] == '\0')) {
827 pr_err("i2c-core: Attempt to register an adapter with "
828 "no name!\n");
829 return -EINVAL;
830 }
831 if (unlikely(!adap->algo)) {
832 pr_err("i2c-core: Attempt to register adapter '%s' with "
833 "no algo!\n", adap->name);
834 return -EINVAL;
835 }
836
847 rt_mutex_init(&adap->bus_lock); 837 rt_mutex_init(&adap->bus_lock);
848 mutex_init(&adap->userspace_clients_lock); 838 mutex_init(&adap->userspace_clients_lock);
849 INIT_LIST_HEAD(&adap->userspace_clients); 839 INIT_LIST_HEAD(&adap->userspace_clients);
@@ -995,6 +985,8 @@ static int i2c_do_del_adapter(struct i2c_driver *driver,
995 985
996 if (!driver->detach_adapter) 986 if (!driver->detach_adapter)
997 return 0; 987 return 0;
988 dev_warn(&adapter->dev, "%s: detach_adapter method is deprecated\n",
989 driver->driver.name);
998 res = driver->detach_adapter(adapter); 990 res = driver->detach_adapter(adapter);
999 if (res) 991 if (res)
1000 dev_err(&adapter->dev, "detach_adapter failed (%d) " 992 dev_err(&adapter->dev, "detach_adapter failed (%d) "
@@ -1005,6 +997,14 @@ static int i2c_do_del_adapter(struct i2c_driver *driver,
1005static int __unregister_client(struct device *dev, void *dummy) 997static int __unregister_client(struct device *dev, void *dummy)
1006{ 998{
1007 struct i2c_client *client = i2c_verify_client(dev); 999 struct i2c_client *client = i2c_verify_client(dev);
1000 if (client && strcmp(client->name, "dummy"))
1001 i2c_unregister_device(client);
1002 return 0;
1003}
1004
1005static int __unregister_dummy(struct device *dev, void *dummy)
1006{
1007 struct i2c_client *client = i2c_verify_client(dev);
1008 if (client) 1008 if (client)
1009 i2c_unregister_device(client); 1009 i2c_unregister_device(client);
1010 return 0; 1010 return 0;
@@ -1059,8 +1059,12 @@ int i2c_del_adapter(struct i2c_adapter *adap)
1059 mutex_unlock(&adap->userspace_clients_lock); 1059 mutex_unlock(&adap->userspace_clients_lock);
1060 1060
1061 /* Detach any active clients. This can't fail, thus we do not 1061 /* Detach any active clients. This can't fail, thus we do not
1062 checking the returned value. */ 1062 * check the returned value. This is a two-pass process, because
1063 * we can't remove the dummy devices during the first pass: they
1064 * could have been instantiated by real devices wishing to clean
1065 * them up properly, so we give them a chance to do that first. */
1063 res = device_for_each_child(&adap->dev, NULL, __unregister_client); 1066 res = device_for_each_child(&adap->dev, NULL, __unregister_client);
1067 res = device_for_each_child(&adap->dev, NULL, __unregister_dummy);
1064 1068
1065#ifdef CONFIG_I2C_COMPAT 1069#ifdef CONFIG_I2C_COMPAT
1066 class_compat_remove_link(i2c_adapter_compat_class, &adap->dev, 1070 class_compat_remove_link(i2c_adapter_compat_class, &adap->dev,
@@ -1093,6 +1097,18 @@ EXPORT_SYMBOL(i2c_del_adapter);
1093 1097
1094/* ------------------------------------------------------------------------- */ 1098/* ------------------------------------------------------------------------- */
1095 1099
1100int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *))
1101{
1102 int res;
1103
1104 mutex_lock(&core_lock);
1105 res = bus_for_each_dev(&i2c_bus_type, NULL, data, fn);
1106 mutex_unlock(&core_lock);
1107
1108 return res;
1109}
1110EXPORT_SYMBOL_GPL(i2c_for_each_dev);
1111
1096static int __process_new_driver(struct device *dev, void *data) 1112static int __process_new_driver(struct device *dev, void *data)
1097{ 1113{
1098 if (dev->type != &i2c_adapter_type) 1114 if (dev->type != &i2c_adapter_type)
@@ -1124,13 +1140,19 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
1124 if (res) 1140 if (res)
1125 return res; 1141 return res;
1126 1142
1143 /* Drivers should switch to dev_pm_ops instead. */
1144 if (driver->suspend)
1145 pr_warn("i2c-core: driver [%s] using legacy suspend method\n",
1146 driver->driver.name);
1147 if (driver->resume)
1148 pr_warn("i2c-core: driver [%s] using legacy resume method\n",
1149 driver->driver.name);
1150
1127 pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); 1151 pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);
1128 1152
1129 INIT_LIST_HEAD(&driver->clients); 1153 INIT_LIST_HEAD(&driver->clients);
1130 /* Walk the adapters that are already present */ 1154 /* Walk the adapters that are already present */
1131 mutex_lock(&core_lock); 1155 i2c_for_each_dev(driver, __process_new_driver);
1132 bus_for_each_dev(&i2c_bus_type, NULL, driver, __process_new_driver);
1133 mutex_unlock(&core_lock);
1134 1156
1135 return 0; 1157 return 0;
1136} 1158}
@@ -1150,9 +1172,7 @@ static int __process_removed_driver(struct device *dev, void *data)
1150 */ 1172 */
1151void i2c_del_driver(struct i2c_driver *driver) 1173void i2c_del_driver(struct i2c_driver *driver)
1152{ 1174{
1153 mutex_lock(&core_lock); 1175 i2c_for_each_dev(driver, __process_removed_driver);
1154 bus_for_each_dev(&i2c_bus_type, NULL, driver, __process_removed_driver);
1155 mutex_unlock(&core_lock);
1156 1176
1157 driver_unregister(&driver->driver); 1177 driver_unregister(&driver->driver);
1158 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); 1178 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
@@ -1346,7 +1366,7 @@ EXPORT_SYMBOL(i2c_transfer);
1346 * 1366 *
1347 * Returns negative errno, or else the number of bytes written. 1367 * Returns negative errno, or else the number of bytes written.
1348 */ 1368 */
1349int i2c_master_send(struct i2c_client *client, const char *buf, int count) 1369int i2c_master_send(const struct i2c_client *client, const char *buf, int count)
1350{ 1370{
1351 int ret; 1371 int ret;
1352 struct i2c_adapter *adap = client->adapter; 1372 struct i2c_adapter *adap = client->adapter;
@@ -1373,7 +1393,7 @@ EXPORT_SYMBOL(i2c_master_send);
1373 * 1393 *
1374 * Returns negative errno, or else the number of bytes read. 1394 * Returns negative errno, or else the number of bytes read.
1375 */ 1395 */
1376int i2c_master_recv(struct i2c_client *client, char *buf, int count) 1396int i2c_master_recv(const struct i2c_client *client, char *buf, int count)
1377{ 1397{
1378 struct i2c_adapter *adap = client->adapter; 1398 struct i2c_adapter *adap = client->adapter;
1379 struct i2c_msg msg; 1399 struct i2c_msg msg;
@@ -1504,26 +1524,25 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
1504 if (!driver->detect || !address_list) 1524 if (!driver->detect || !address_list)
1505 return 0; 1525 return 0;
1506 1526
1527 /* Stop here if the classes do not match */
1528 if (!(adapter->class & driver->class))
1529 return 0;
1530
1507 /* Set up a temporary client to help detect callback */ 1531 /* Set up a temporary client to help detect callback */
1508 temp_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 1532 temp_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
1509 if (!temp_client) 1533 if (!temp_client)
1510 return -ENOMEM; 1534 return -ENOMEM;
1511 temp_client->adapter = adapter; 1535 temp_client->adapter = adapter;
1512 1536
1513 /* Stop here if the classes do not match */
1514 if (!(adapter->class & driver->class))
1515 goto exit_free;
1516
1517 for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) { 1537 for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) {
1518 dev_dbg(&adapter->dev, "found normal entry for adapter %d, " 1538 dev_dbg(&adapter->dev, "found normal entry for adapter %d, "
1519 "addr 0x%02x\n", adap_id, address_list[i]); 1539 "addr 0x%02x\n", adap_id, address_list[i]);
1520 temp_client->addr = address_list[i]; 1540 temp_client->addr = address_list[i];
1521 err = i2c_detect_address(temp_client, driver); 1541 err = i2c_detect_address(temp_client, driver);
1522 if (err) 1542 if (unlikely(err))
1523 goto exit_free; 1543 break;
1524 } 1544 }
1525 1545
1526 exit_free:
1527 kfree(temp_client); 1546 kfree(temp_client);
1528 return err; 1547 return err;
1529} 1548}
@@ -1576,12 +1595,12 @@ i2c_new_probed_device(struct i2c_adapter *adap,
1576} 1595}
1577EXPORT_SYMBOL_GPL(i2c_new_probed_device); 1596EXPORT_SYMBOL_GPL(i2c_new_probed_device);
1578 1597
1579struct i2c_adapter *i2c_get_adapter(int id) 1598struct i2c_adapter *i2c_get_adapter(int nr)
1580{ 1599{
1581 struct i2c_adapter *adapter; 1600 struct i2c_adapter *adapter;
1582 1601
1583 mutex_lock(&core_lock); 1602 mutex_lock(&core_lock);
1584 adapter = idr_find(&i2c_adapter_idr, id); 1603 adapter = idr_find(&i2c_adapter_idr, nr);
1585 if (adapter && !try_module_get(adapter->owner)) 1604 if (adapter && !try_module_get(adapter->owner))
1586 adapter = NULL; 1605 adapter = NULL;
1587 1606
@@ -1664,7 +1683,7 @@ static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg)
1664 * This executes the SMBus "receive byte" protocol, returning negative errno 1683 * This executes the SMBus "receive byte" protocol, returning negative errno
1665 * else the byte received from the device. 1684 * else the byte received from the device.
1666 */ 1685 */
1667s32 i2c_smbus_read_byte(struct i2c_client *client) 1686s32 i2c_smbus_read_byte(const struct i2c_client *client)
1668{ 1687{
1669 union i2c_smbus_data data; 1688 union i2c_smbus_data data;
1670 int status; 1689 int status;
@@ -1684,7 +1703,7 @@ EXPORT_SYMBOL(i2c_smbus_read_byte);
1684 * This executes the SMBus "send byte" protocol, returning negative errno 1703 * This executes the SMBus "send byte" protocol, returning negative errno
1685 * else zero on success. 1704 * else zero on success.
1686 */ 1705 */
1687s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) 1706s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value)
1688{ 1707{
1689 return i2c_smbus_xfer(client->adapter, client->addr, client->flags, 1708 return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
1690 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); 1709 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
@@ -1699,7 +1718,7 @@ EXPORT_SYMBOL(i2c_smbus_write_byte);
1699 * This executes the SMBus "read byte" protocol, returning negative errno 1718 * This executes the SMBus "read byte" protocol, returning negative errno
1700 * else a data byte received from the device. 1719 * else a data byte received from the device.
1701 */ 1720 */
1702s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) 1721s32 i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command)
1703{ 1722{
1704 union i2c_smbus_data data; 1723 union i2c_smbus_data data;
1705 int status; 1724 int status;
@@ -1720,7 +1739,8 @@ EXPORT_SYMBOL(i2c_smbus_read_byte_data);
1720 * This executes the SMBus "write byte" protocol, returning negative errno 1739 * This executes the SMBus "write byte" protocol, returning negative errno
1721 * else zero on success. 1740 * else zero on success.
1722 */ 1741 */
1723s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) 1742s32 i2c_smbus_write_byte_data(const struct i2c_client *client, u8 command,
1743 u8 value)
1724{ 1744{
1725 union i2c_smbus_data data; 1745 union i2c_smbus_data data;
1726 data.byte = value; 1746 data.byte = value;
@@ -1738,7 +1758,7 @@ EXPORT_SYMBOL(i2c_smbus_write_byte_data);
1738 * This executes the SMBus "read word" protocol, returning negative errno 1758 * This executes the SMBus "read word" protocol, returning negative errno
1739 * else a 16-bit unsigned "word" received from the device. 1759 * else a 16-bit unsigned "word" received from the device.
1740 */ 1760 */
1741s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command) 1761s32 i2c_smbus_read_word_data(const struct i2c_client *client, u8 command)
1742{ 1762{
1743 union i2c_smbus_data data; 1763 union i2c_smbus_data data;
1744 int status; 1764 int status;
@@ -1759,7 +1779,8 @@ EXPORT_SYMBOL(i2c_smbus_read_word_data);
1759 * This executes the SMBus "write word" protocol, returning negative errno 1779 * This executes the SMBus "write word" protocol, returning negative errno
1760 * else zero on success. 1780 * else zero on success.
1761 */ 1781 */
1762s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) 1782s32 i2c_smbus_write_word_data(const struct i2c_client *client, u8 command,
1783 u16 value)
1763{ 1784{
1764 union i2c_smbus_data data; 1785 union i2c_smbus_data data;
1765 data.word = value; 1786 data.word = value;
@@ -1778,7 +1799,8 @@ EXPORT_SYMBOL(i2c_smbus_write_word_data);
1778 * This executes the SMBus "process call" protocol, returning negative errno 1799 * This executes the SMBus "process call" protocol, returning negative errno
1779 * else a 16-bit unsigned "word" received from the device. 1800 * else a 16-bit unsigned "word" received from the device.
1780 */ 1801 */
1781s32 i2c_smbus_process_call(struct i2c_client *client, u8 command, u16 value) 1802s32 i2c_smbus_process_call(const struct i2c_client *client, u8 command,
1803 u16 value)
1782{ 1804{
1783 union i2c_smbus_data data; 1805 union i2c_smbus_data data;
1784 int status; 1806 int status;
@@ -1806,7 +1828,7 @@ EXPORT_SYMBOL(i2c_smbus_process_call);
1806 * support this; its emulation through I2C messaging relies on a specific 1828 * support this; its emulation through I2C messaging relies on a specific
1807 * mechanism (I2C_M_RECV_LEN) which may not be implemented. 1829 * mechanism (I2C_M_RECV_LEN) which may not be implemented.
1808 */ 1830 */
1809s32 i2c_smbus_read_block_data(struct i2c_client *client, u8 command, 1831s32 i2c_smbus_read_block_data(const struct i2c_client *client, u8 command,
1810 u8 *values) 1832 u8 *values)
1811{ 1833{
1812 union i2c_smbus_data data; 1834 union i2c_smbus_data data;
@@ -1833,7 +1855,7 @@ EXPORT_SYMBOL(i2c_smbus_read_block_data);
1833 * This executes the SMBus "block write" protocol, returning negative errno 1855 * This executes the SMBus "block write" protocol, returning negative errno
1834 * else zero on success. 1856 * else zero on success.
1835 */ 1857 */
1836s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, 1858s32 i2c_smbus_write_block_data(const struct i2c_client *client, u8 command,
1837 u8 length, const u8 *values) 1859 u8 length, const u8 *values)
1838{ 1860{
1839 union i2c_smbus_data data; 1861 union i2c_smbus_data data;
@@ -1849,7 +1871,7 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
1849EXPORT_SYMBOL(i2c_smbus_write_block_data); 1871EXPORT_SYMBOL(i2c_smbus_write_block_data);
1850 1872
1851/* Returns the number of read bytes */ 1873/* Returns the number of read bytes */
1852s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, 1874s32 i2c_smbus_read_i2c_block_data(const struct i2c_client *client, u8 command,
1853 u8 length, u8 *values) 1875 u8 length, u8 *values)
1854{ 1876{
1855 union i2c_smbus_data data; 1877 union i2c_smbus_data data;
@@ -1869,7 +1891,7 @@ s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command,
1869} 1891}
1870EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data); 1892EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data);
1871 1893
1872s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, 1894s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client, u8 command,
1873 u8 length, const u8 *values) 1895 u8 length, const u8 *values)
1874{ 1896{
1875 union i2c_smbus_data data; 1897 union i2c_smbus_data data;