OSDN Git Service

i2c: i2c-core-base: convert to use i2c_new_client_device()
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Tue, 7 Jan 2020 17:47:43 +0000 (18:47 +0100)
committerWolfram Sang <wsa@the-dreams.de>
Wed, 15 Jan 2020 19:40:08 +0000 (20:40 +0100)
Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/i2c-core-base.c

index 19d9299..cefad08 100644 (file)
@@ -831,8 +831,8 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
 
 
 /**
- * i2c_unregister_device - reverse effect of i2c_new_device()
- * @client: value returned from i2c_new_device()
+ * i2c_unregister_device - reverse effect of i2c_new_*_device()
+ * @client: value returned from i2c_new_*_device()
  * Context: can sleep
  */
 void i2c_unregister_device(struct i2c_client *client)
@@ -1178,9 +1178,8 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
 
        down_read(&__i2c_board_lock);
        list_for_each_entry(devinfo, &__i2c_board_list, list) {
-               if (devinfo->busnum == adapter->nr
-                               && !i2c_new_device(adapter,
-                                               &devinfo->board_info))
+               if (devinfo->busnum == adapter->nr &&
+                   IS_ERR(i2c_new_client_device(adapter, &devinfo->board_info)))
                        dev_err(&adapter->dev,
                                "Can't create device at 0x%02x\n",
                                devinfo->board_info.addr);
@@ -2167,8 +2166,8 @@ static int i2c_detect_address(struct i2c_client *temp_client,
 
                dev_dbg(&adapter->dev, "Creating %s at 0x%02x\n",
                        info.type, info.addr);
-               client = i2c_new_device(adapter, &info);
-               if (client)
+               client = i2c_new_client_device(adapter, &info);
+               if (!IS_ERR(client))
                        list_add_tail(&client->detected, &driver->clients);
                else
                        dev_err(&adapter->dev, "Failed creating %s at 0x%02x\n",