2020-01-07 17:49:25

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 00/12] i2c: convert subsystem to use i2c_new_client_device()

This patch series converts the I2C subsystem to use the new API. Drivers
have been build tested. There is one user left in the SMBus part of the
core which will need a seperate series because all users of this
function need to be checked/converted, too.

Except for documentation patches, the conversion has been done with a
coccinelle script and further simplification have been applied when
proofreading the patches.

A branch is here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/i2c/new_client_device

Looking forward to comments...

Wolfram Sang (12):
i2c: cht-wc: convert to use i2c_new_client_device()
i2c: i801: convert to use i2c_new_client_device()
i2c: nvidia-gpu: convert to use i2c_new_client_device()
i2c: ocores: convert to use i2c_new_client_device()
i2c: powermac: convert to use i2c_new_client_device()
i2c: taos-evm: convert to use i2c_new_client_device()
i2c: xiic: convert to use i2c_new_client_device()
i2c: i2c-core-acpi: convert to use i2c_new_client_device()
i2c: i2c-core-base: convert to use i2c_new_client_device()
i2c: i2c-core-of: convert to use i2c_new_client_device()
docs: i2c: use the new API in 'instantiating-devices.rst'
docs: i2c: use the new API in 'writing-clients'

Documentation/i2c/instantiating-devices.rst | 8 ++++----
Documentation/i2c/writing-clients.rst | 20 ++++++++++----------
drivers/i2c/busses/i2c-cht-wc.c | 6 +++---
drivers/i2c/busses/i2c-i801.c | 6 +++---
drivers/i2c/busses/i2c-nvidia-gpu.c | 6 +++---
drivers/i2c/busses/i2c-ocores.c | 2 +-
drivers/i2c/busses/i2c-powermac.c | 8 ++++----
drivers/i2c/busses/i2c-taos-evm.c | 4 ++--
drivers/i2c/busses/i2c-xiic.c | 2 +-
drivers/i2c/i2c-core-acpi.c | 12 ++++--------
drivers/i2c/i2c-core-base.c | 13 ++++++-------
drivers/i2c/i2c-core-of.c | 7 +++----
12 files changed, 44 insertions(+), 50 deletions(-)

--
2.20.1


2020-01-07 17:49:30

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 11/12] docs: i2c: use the new API in 'instantiating-devices.rst'

i2c_new_device is deprecated, use i2c_new_client_device.

Signed-off-by: Wolfram Sang <[email protected]>
---
Documentation/i2c/instantiating-devices.rst | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/i2c/instantiating-devices.rst b/Documentation/i2c/instantiating-devices.rst
index 875ebe9e78e3..b7b90b1b82f9 100644
--- a/Documentation/i2c/instantiating-devices.rst
+++ b/Documentation/i2c/instantiating-devices.rst
@@ -98,7 +98,7 @@ tuner, a video decoder, an audio decoder, etc. usually connected to the
main chip by the means of an I2C bus. You won't know the number of the I2C
bus in advance, so the method 1 described above can't be used. Instead,
you can instantiate your I2C devices explicitly. This is done by filling
-a struct i2c_board_info and calling i2c_new_device().
+a struct i2c_board_info and calling i2c_new_client_device().

Example (from the sfe4001 network driver)::

@@ -110,7 +110,7 @@ Example (from the sfe4001 network driver)::
{
(...)
efx->board_info.hwmon_client =
- i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info);
+ i2c_new_client_device(&efx->i2c_adap, &sfe4001_hwmon_info);

(...)
}
@@ -123,7 +123,7 @@ present or not (for example for an optional feature which is not present
on cheap variants of a board but you have no way to tell them apart), or
it may have different addresses from one board to the next (manufacturer
changing its design without notice). In this case, you can call
-i2c_new_scanned_device() instead of i2c_new_device().
+i2c_new_scanned_device() instead of i2c_new_client_device().

Example (from the nxp OHCI driver)::

@@ -152,7 +152,7 @@ simply gives up.

The driver which instantiated the I2C device is responsible for destroying
it on cleanup. This is done by calling i2c_unregister_device() on the
-pointer that was earlier returned by i2c_new_device() or
+pointer that was earlier returned by i2c_new_client_device() or
i2c_new_scanned_device().


--
2.20.1

2020-01-07 17:49:35

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 08/12] i2c: i2c-core-acpi: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/i2c-core-acpi.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 62a1c92ab803..8f3dbc97a057 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -225,7 +225,7 @@ static void i2c_acpi_register_device(struct i2c_adapter *adapter,
adev->power.flags.ignore_parent = true;
acpi_device_set_enumerated(adev);

- if (!i2c_new_device(adapter, info)) {
+ if (IS_ERR(i2c_new_client_device(adapter, info))) {
adev->power.flags.ignore_parent = false;
dev_err(&adapter->dev,
"failed to add I2C device %s from ACPI\n",
@@ -451,7 +451,8 @@ struct notifier_block i2c_acpi_notifier = {
* resources, in that case this function can be used to create an i2c-client
* for other I2cSerialBus resources in the Current Resource Settings table.
*
- * Also see i2c_new_device, which this function calls to create the i2c-client.
+ * Also see i2c_new_client_device, which this function calls to create the
+ * i2c-client.
*
* Returns a pointer to the new i2c-client, or error pointer in case of failure.
* Specifically, -EPROBE_DEFER is returned if the adapter is not found.
@@ -461,7 +462,6 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
{
struct i2c_acpi_lookup lookup;
struct i2c_adapter *adapter;
- struct i2c_client *client;
struct acpi_device *adev;
LIST_HEAD(resource_list);
int ret;
@@ -489,11 +489,7 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
if (!adapter)
return ERR_PTR(-EPROBE_DEFER);

- client = i2c_new_device(adapter, info);
- if (!client)
- return ERR_PTR(-ENODEV);
-
- return client;
+ return i2c_new_client_device(adapter, info);
}
EXPORT_SYMBOL_GPL(i2c_acpi_new_device);

--
2.20.1

2020-01-07 17:49:42

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 03/12] i2c: nvidia-gpu: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/busses/i2c-nvidia-gpu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-nvidia-gpu.c
index 5a1235fd86bb..62e18b4db0ed 100644
--- a/drivers/i2c/busses/i2c-nvidia-gpu.c
+++ b/drivers/i2c/busses/i2c-nvidia-gpu.c
@@ -280,9 +280,9 @@ static int gpu_populate_client(struct gpu_i2c_dev *i2cd, int irq)
i2cd->gpu_ccgx_ucsi->addr = 0x8;
i2cd->gpu_ccgx_ucsi->irq = irq;
i2cd->gpu_ccgx_ucsi->properties = ccgx_props;
- i2cd->ccgx_client = i2c_new_device(&i2cd->adapter, i2cd->gpu_ccgx_ucsi);
- if (!i2cd->ccgx_client)
- return -ENODEV;
+ i2cd->ccgx_client = i2c_new_client_device(&i2cd->adapter, i2cd->gpu_ccgx_ucsi);
+ if (IS_ERR(i2cd->ccgx_client))
+ return PTR_ERR(i2cd->ccgx_client);

return 0;
}
--
2.20.1

2020-01-07 17:49:43

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 12/12] docs: i2c: use the new API in 'writing-clients'

i2c_new_device is deprecated, use i2c_new_client_device. Also, align a
paragraph while here.

Signed-off-by: Wolfram Sang <[email protected]>
---
Documentation/i2c/writing-clients.rst | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/Documentation/i2c/writing-clients.rst b/Documentation/i2c/writing-clients.rst
index ced309b5e0cc..0336909ca01b 100644
--- a/Documentation/i2c/writing-clients.rst
+++ b/Documentation/i2c/writing-clients.rst
@@ -175,8 +175,8 @@ Device Creation
If you know for a fact that an I2C device is connected to a given I2C bus,
you can instantiate that device by simply filling an i2c_board_info
structure with the device address and driver name, and calling
-i2c_new_device(). This will create the device, then the driver core will
-take care of finding the right driver and will call its probe() method.
+i2c_new_client_device(). This will create the device, then the driver core
+will take care of finding the right driver and will call its probe() method.
If a driver supports different device types, you can specify the type you
want using the type field. You can also specify an IRQ and platform data
if needed.
@@ -186,14 +186,14 @@ don't know the exact address it uses. This happens on TV adapters for
example, where the same driver supports dozens of slightly different
models, and I2C device addresses change from one model to the next. In
that case, you can use the i2c_new_scanned_device() variant, which is
-similar to i2c_new_device(), except that it takes an additional list of
-possible I2C addresses to probe. A device is created for the first
+similar to i2c_new_client_device(), except that it takes an additional list
+of possible I2C addresses to probe. A device is created for the first
responsive address in the list. If you expect more than one device to be
present in the address range, simply call i2c_new_scanned_device() that
many times.

-The call to i2c_new_device() or i2c_new_scanned_device() typically happens
-in the I2C bus driver. You may want to save the returned i2c_client
+The call to i2c_new_client_device() or i2c_new_scanned_device() typically
+happens in the I2C bus driver. You may want to save the returned i2c_client
reference for later use.


@@ -236,11 +236,11 @@ possible.
Device Deletion
---------------

-Each I2C device which has been created using i2c_new_device() or
-i2c_new_scanned_device() can be unregistered by calling
+Each I2C device which has been created using i2c_new_client_device()
+or i2c_new_scanned_device() can be unregistered by calling
i2c_unregister_device(). If you don't call it explicitly, it will be
-called automatically before the underlying I2C bus itself is removed, as a
-device can't survive its parent in the device driver model.
+called automatically before the underlying I2C bus itself is removed,
+as a device can't survive its parent in the device driver model.


Initializing the driver
--
2.20.1

2020-01-07 17:49:49

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 04/12] i2c: ocores: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/busses/i2c-ocores.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index ca8b3ecfa93d..f5fc75b65a19 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -731,7 +731,7 @@ static int ocores_i2c_probe(struct platform_device *pdev)
/* add in known devices to the bus */
if (pdata) {
for (i = 0; i < pdata->num_devices; i++)
- i2c_new_device(&i2c->adap, pdata->devices + i);
+ i2c_new_client_device(&i2c->adap, pdata->devices + i);
}

return 0;
--
2.20.1

2020-01-07 17:49:53

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 10/12] i2c: i2c-core-of: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/i2c-core-of.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
index e4d296b40baa..6787c1f71483 100644
--- a/drivers/i2c/i2c-core-of.c
+++ b/drivers/i2c/i2c-core-of.c
@@ -75,11 +75,10 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
if (ret)
return ERR_PTR(ret);

- client = i2c_new_device(adap, &info);
- if (!client) {
+ client = i2c_new_client_device(adap, &info);
+ if (IS_ERR(client))
dev_err(&adap->dev, "of_i2c: Failure registering %pOF\n", node);
- return ERR_PTR(-EINVAL);
- }
+
return client;
}

--
2.20.1

2020-01-07 17:50:09

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 09/12] i2c: i2c-core-base: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/i2c-core-base.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 9f8dcd3f8385..6c2007a015f2 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -824,8 +824,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)
@@ -1171,9 +1171,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);
@@ -2160,8 +2159,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",
--
2.20.1

2020-01-07 17:50:17

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 07/12] i2c: xiic: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/busses/i2c-xiic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index d8d49f1814c7..61e081b186cc 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -806,7 +806,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
if (pdata) {
/* add in known devices to the bus */
for (i = 0; i < pdata->num_devices; i++)
- i2c_new_device(&i2c->adap, pdata->devices + i);
+ i2c_new_client_device(&i2c->adap, pdata->devices + i);
}

return 0;
--
2.20.1

2020-01-07 17:50:19

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 02/12] i2c: i801: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/busses/i2c-i801.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index f5e69fe56532..44db3a91d32d 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -1142,7 +1142,7 @@ static void dmi_check_onboard_device(u8 type, const char *name,
memset(&info, 0, sizeof(struct i2c_board_info));
info.addr = dmi_devices[i].i2c_addr;
strlcpy(info.type, dmi_devices[i].i2c_type, I2C_NAME_SIZE);
- i2c_new_device(adap, &info);
+ i2c_new_client_device(adap, &info);
break;
}
}
@@ -1296,7 +1296,7 @@ static void register_dell_lis3lv02d_i2c_device(struct i801_priv *priv)
memset(&info, 0, sizeof(struct i2c_board_info));
info.addr = dell_lis3lv02d_devices[i].i2c_addr;
strlcpy(info.type, "lis3lv02d", I2C_NAME_SIZE);
- i2c_new_device(&priv->adapter, &info);
+ i2c_new_client_device(&priv->adapter, &info);
}

/* Register optional slaves */
@@ -1312,7 +1312,7 @@ static void i801_probe_optional_slaves(struct i801_priv *priv)
memset(&info, 0, sizeof(struct i2c_board_info));
info.addr = apanel_addr;
strlcpy(info.type, "fujitsu_apanel", I2C_NAME_SIZE);
- i2c_new_device(&priv->adapter, &info);
+ i2c_new_client_device(&priv->adapter, &info);
}

if (dmi_name_in_vendors("FUJITSU"))
--
2.20.1

2020-01-07 17:50:22

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 05/12] i2c: powermac: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/busses/i2c-powermac.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index 504f5bf0e625..973e5339033c 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -240,8 +240,8 @@ static void i2c_powermac_create_one(struct i2c_adapter *adap,

strncpy(info.type, type, sizeof(info.type));
info.addr = addr;
- newdev = i2c_new_device(adap, &info);
- if (!newdev)
+ newdev = i2c_new_client_device(adap, &info);
+ if (IS_ERR(newdev))
dev_err(&adap->dev,
"i2c-powermac: Failure to register missing %s\n",
type);
@@ -359,8 +359,8 @@ static void i2c_powermac_register_devices(struct i2c_adapter *adap,
info.irq = irq_of_parse_and_map(node, 0);
info.of_node = of_node_get(node);

- newdev = i2c_new_device(adap, &info);
- if (!newdev) {
+ newdev = i2c_new_client_device(adap, &info);
+ if (IS_ERR(newdev)) {
dev_err(&adap->dev, "i2c-powermac: Failure to register"
" %pOF\n", node);
of_node_put(node);
--
2.20.1

2020-01-07 17:50:25

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 01/12] i2c: cht-wc: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/busses/i2c-cht-wc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c
index b8fde61bb5d8..35e55feda763 100644
--- a/drivers/i2c/busses/i2c-cht-wc.c
+++ b/drivers/i2c/busses/i2c-cht-wc.c
@@ -388,9 +388,9 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
*/
if (acpi_dev_present("INT33FE", NULL, -1)) {
board_info.irq = adap->client_irq;
- adap->client = i2c_new_device(&adap->adapter, &board_info);
- if (!adap->client) {
- ret = -ENOMEM;
+ adap->client = i2c_new_client_device(&adap->adapter, &board_info);
+ if (IS_ERR(adap->client)) {
+ ret = PTR_ERR(adap->client);
goto del_adapter;
}
}
--
2.20.1

2020-01-07 17:51:04

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 06/12] i2c: taos-evm: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <[email protected]>
---
Build tested only.

drivers/i2c/busses/i2c-taos-evm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
index 0bff3f3a8779..b4050f5b6746 100644
--- a/drivers/i2c/busses/i2c-taos-evm.c
+++ b/drivers/i2c/busses/i2c-taos-evm.c
@@ -49,10 +49,10 @@ static struct i2c_client *taos_instantiate_device(struct i2c_adapter *adapter)
if (!strncmp(adapter->name, "TAOS TSL2550 EVM", 16)) {
dev_info(&adapter->dev, "Instantiating device %s at 0x%02x\n",
tsl2550_info.type, tsl2550_info.addr);
- return i2c_new_device(adapter, &tsl2550_info);
+ return i2c_new_client_device(adapter, &tsl2550_info);
}

- return NULL;
+ return ERR_PTR(-ENODEV);
}

static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
--
2.20.1

2020-01-07 18:33:56

by Peter Korsgaard

[permalink] [raw]
Subject: Re: [PATCH 04/12] i2c: ocores: convert to use i2c_new_client_device()

>>>>> "Wolfram" == Wolfram Sang <[email protected]> writes:

> Move away from the deprecated API and return the shiny new ERRPTR where
> useful.

> Signed-off-by: Wolfram Sang <[email protected]>

I didn't follow the discussion, but I don't see any returns anywhere?

> ---
> Build tested only.

> drivers/i2c/busses/i2c-ocores.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
> index ca8b3ecfa93d..f5fc75b65a19 100644
> --- a/drivers/i2c/busses/i2c-ocores.c
> +++ b/drivers/i2c/busses/i2c-ocores.c
> @@ -731,7 +731,7 @@ static int ocores_i2c_probe(struct platform_device *pdev)
> /* add in known devices to the bus */
> if (pdata) {
> for (i = 0; i < pdata->num_devices; i++)
> - i2c_new_device(&i2c->adap, pdata->devices + i);
> + i2c_new_client_device(&i2c->adap, pdata->devices + i);
> }

> return 0;
> --
> 2.20.1


--
Bye, Peter Korsgaard

2020-01-07 19:32:44

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH 04/12] i2c: ocores: convert to use i2c_new_client_device()

Hi Peter,

a happy new year to you!

> > Move away from the deprecated API and return the shiny new ERRPTR where
> > useful.
>
> > Signed-off-by: Wolfram Sang <[email protected]>
>
> I didn't follow the discussion, but I don't see any returns anywhere?

Yeah, an ERRPTR is not "useful" here. However, the old API is going to
be removed, so your driver is converted, too.

Happy hacking,

Wolfram


Attachments:
(No filename) (438.00 B)
signature.asc (849.00 B)
Download all attachments

2020-01-07 19:38:17

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH 04/12] i2c: ocores: convert to use i2c_new_client_device()

On Tue, Jan 07, 2020 at 07:32:50PM +0100, Peter Korsgaard wrote:
> >>>>> "Wolfram" == Wolfram Sang <[email protected]> writes:
>
> > Move away from the deprecated API and return the shiny new ERRPTR where
> > useful.
>
> > Signed-off-by: Wolfram Sang <[email protected]>
>
> I didn't follow the discussion, but I don't see any returns anywhere?

Hi Peter

I have also not been following the discussion. But i2c_new_device()
seems to of always returned a NULL pointer on error, and the code has
been ignoring it. The 'where useful' comment suggests the return value
maybe checked, but it is optional to check it. So this patch seems
O.K.

I suppose the commit message could be extended with:

In this case, the shiny new stuff is not useful, so ignore it.

But:

Reviewed-by: Andrew Lunn <[email protected]>

Andrew

2020-01-07 20:00:04

by Peter Korsgaard

[permalink] [raw]
Subject: Re: [PATCH 04/12] i2c: ocores: convert to use i2c_new_client_device()

>>>>> "Wolfram" == Wolfram Sang <[email protected]> writes:

> Hi Peter,
> a happy new year to you!

thanks, You too!

>> > Move away from the deprecated API and return the shiny new ERRPTR where
>> > useful.
>>
>> > Signed-off-by: Wolfram Sang <[email protected]>
>>
>> I didn't follow the discussion, but I don't see any returns anywhere?

> Yeah, an ERRPTR is not "useful" here. However, the old API is going to
> be removed, so your driver is converted, too.

Ok, great.

Reviewed-by: Peter Korsgaard <[email protected]>

--
Bye, Peter Korsgaard

2020-01-08 11:20:39

by Jean Delvare

[permalink] [raw]
Subject: Re: [PATCH 06/12] i2c: taos-evm: convert to use i2c_new_client_device()

Hi Wolfram,

On Tue, 7 Jan 2020 18:47:40 +0100, Wolfram Sang wrote:
> Move away from the deprecated API and return the shiny new ERRPTR where
> useful.
>
> Signed-off-by: Wolfram Sang <[email protected]>
> ---
> Build tested only.
>
> drivers/i2c/busses/i2c-taos-evm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
> index 0bff3f3a8779..b4050f5b6746 100644
> --- a/drivers/i2c/busses/i2c-taos-evm.c
> +++ b/drivers/i2c/busses/i2c-taos-evm.c
> @@ -49,10 +49,10 @@ static struct i2c_client *taos_instantiate_device(struct i2c_adapter *adapter)
> if (!strncmp(adapter->name, "TAOS TSL2550 EVM", 16)) {
> dev_info(&adapter->dev, "Instantiating device %s at 0x%02x\n",
> tsl2550_info.type, tsl2550_info.addr);
> - return i2c_new_device(adapter, &tsl2550_info);
> + return i2c_new_client_device(adapter, &tsl2550_info);
> }
>
> - return NULL;
> + return ERR_PTR(-ENODEV);
> }
>
> static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,

Looks good to me, although ideally the caller should handle the error
instead of ignoring it. But that's out of scope for this conversion
patch, I'll look into submitting an update on top.

So:

Reviewed-by: Jean Delvare <[email protected]>

I'll also try to revive my evaluation module to give it some testing.

Thanks,
--
Jean Delvare
SUSE L3 Support

2020-01-08 12:52:30

by Mika Westerberg

[permalink] [raw]
Subject: Re: [PATCH 08/12] i2c: i2c-core-acpi: convert to use i2c_new_client_device()

On Tue, Jan 07, 2020 at 06:47:42PM +0100, Wolfram Sang wrote:
> Move away from the deprecated API and return the shiny new ERRPTR where
> useful.
>
> Signed-off-by: Wolfram Sang <[email protected]>

Acked-by: Mika Westerberg <[email protected]>

2020-01-08 13:44:41

by Michal Simek

[permalink] [raw]
Subject: Re: [PATCH 07/12] i2c: xiic: convert to use i2c_new_client_device()

On 07. 01. 20 18:47, Wolfram Sang wrote:
> Move away from the deprecated API and return the shiny new ERRPTR where
> useful.
>
> Signed-off-by: Wolfram Sang <[email protected]>
> ---
> Build tested only.
>
> drivers/i2c/busses/i2c-xiic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
> index d8d49f1814c7..61e081b186cc 100644
> --- a/drivers/i2c/busses/i2c-xiic.c
> +++ b/drivers/i2c/busses/i2c-xiic.c
> @@ -806,7 +806,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
> if (pdata) {
> /* add in known devices to the bus */
> for (i = 0; i < pdata->num_devices; i++)
> - i2c_new_device(&i2c->adap, pdata->devices + i);
> + i2c_new_client_device(&i2c->adap, pdata->devices + i);
> }
>
> return 0;
>

Acked-by: Michal Simek <[email protected]>

Shubhrajyoti: Can you please retest?

Thanks,
Michal

2020-01-09 09:59:48

by Jean Delvare

[permalink] [raw]
Subject: Re: [PATCH 06/12] i2c: taos-evm: convert to use i2c_new_client_device()

Hi again Wolfram,

On Wed, 8 Jan 2020 11:58:22 +0100, Jean Delvare wrote:
> On Tue, 7 Jan 2020 18:47:40 +0100, Wolfram Sang wrote:
> > Move away from the deprecated API and return the shiny new ERRPTR where
> > useful.
> >
> > Signed-off-by: Wolfram Sang <[email protected]>
> > ---
> > Build tested only.
> >
> > drivers/i2c/busses/i2c-taos-evm.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
> > index 0bff3f3a8779..b4050f5b6746 100644
> > --- a/drivers/i2c/busses/i2c-taos-evm.c
> > +++ b/drivers/i2c/busses/i2c-taos-evm.c
> > @@ -49,10 +49,10 @@ static struct i2c_client *taos_instantiate_device(struct i2c_adapter *adapter)
> > if (!strncmp(adapter->name, "TAOS TSL2550 EVM", 16)) {
> > dev_info(&adapter->dev, "Instantiating device %s at 0x%02x\n",
> > tsl2550_info.type, tsl2550_info.addr);
> > - return i2c_new_device(adapter, &tsl2550_info);
> > + return i2c_new_client_device(adapter, &tsl2550_info);
> > }
> >
> > - return NULL;
> > + return ERR_PTR(-ENODEV);
> > }
> >
> > static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
>
> Looks good to me, although ideally the caller should handle the error
> instead of ignoring it. But that's out of scope for this conversion
> patch, I'll look into submitting an update on top.

I take that back. taos_instantiate_device() is instantiating an
optional slave device on the bus. If that fails, the bus is still
usable, therefore failing the whole registration would be inappropriate.

Makes me wonder if return ERR_PTR(-ENODEV) is the right thing to do in
the fallback case. The i2c-taos-evm driver was designed to support
multiple TAOS evaluation module types, even though the only one fully
supported right now is the only one I own (TSL2550). The driver can
still be used with other modules, just no slave device will be
instantiated. It can still be done later from user-space.

In my opinion -ENODEV should only be used for "I expected a device but
could not find it". For the case where we simply don't know what slave
device to instantiate, NULL seems more appropriate, as it's not an
error.

What do you think? Either way I agree it doesn't make much practical
difference in the end as i2c_unregister_device() will deal gracefully
with both.

> So:
>
> Reviewed-by: Jean Delvare <[email protected]>
>
> I'll also try to revive my evaluation module to give it some testing.

That I did, and it works fine, as expected :-)

Tested-by: Jean Delvare <[email protected]>

--
Jean Delvare
SUSE L3 Support

2020-01-09 10:16:33

by Jean Delvare

[permalink] [raw]
Subject: Re: [PATCH 02/12] i2c: i801: convert to use i2c_new_client_device()

On Tue, 7 Jan 2020 18:47:36 +0100, Wolfram Sang wrote:
> Move away from the deprecated API and return the shiny new ERRPTR where
> useful.
>
> Signed-off-by: Wolfram Sang <[email protected]>
> ---
> Build tested only.
>
> drivers/i2c/busses/i2c-i801.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index f5e69fe56532..44db3a91d32d 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -1142,7 +1142,7 @@ static void dmi_check_onboard_device(u8 type, const char *name,
> memset(&info, 0, sizeof(struct i2c_board_info));
> info.addr = dmi_devices[i].i2c_addr;
> strlcpy(info.type, dmi_devices[i].i2c_type, I2C_NAME_SIZE);
> - i2c_new_device(adap, &info);
> + i2c_new_client_device(adap, &info);
> break;
> }
> }
> @@ -1296,7 +1296,7 @@ static void register_dell_lis3lv02d_i2c_device(struct i801_priv *priv)
> memset(&info, 0, sizeof(struct i2c_board_info));
> info.addr = dell_lis3lv02d_devices[i].i2c_addr;
> strlcpy(info.type, "lis3lv02d", I2C_NAME_SIZE);
> - i2c_new_device(&priv->adapter, &info);
> + i2c_new_client_device(&priv->adapter, &info);
> }
>
> /* Register optional slaves */
> @@ -1312,7 +1312,7 @@ static void i801_probe_optional_slaves(struct i801_priv *priv)
> memset(&info, 0, sizeof(struct i2c_board_info));
> info.addr = apanel_addr;
> strlcpy(info.type, "fujitsu_apanel", I2C_NAME_SIZE);
> - i2c_new_device(&priv->adapter, &info);
> + i2c_new_client_device(&priv->adapter, &info);
> }
>
> if (dmi_name_in_vendors("FUJITSU"))

Reviewed-by: Jean Delvare <[email protected]>

Thanks,
--
Jean Delvare
SUSE L3 Support

2020-01-09 23:07:14

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH 01/12] i2c: cht-wc: convert to use i2c_new_client_device()

Hi,

On 07-01-2020 18:47, Wolfram Sang wrote:
> Move away from the deprecated API and return the shiny new ERRPTR where
> useful.
>
> Signed-off-by: Wolfram Sang <[email protected]> > ---
> Build tested only.

I've given this a quick test spin on hw which uses this drivers,
I've not noticed any regressions:

Tested-by: Hans de Goede <[email protected]>

Also the changes look good to me:

Reviewed-by: Hans de Goede <[email protected]>

Regards,

Hans


>
> drivers/i2c/busses/i2c-cht-wc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c
> index b8fde61bb5d8..35e55feda763 100644
> --- a/drivers/i2c/busses/i2c-cht-wc.c
> +++ b/drivers/i2c/busses/i2c-cht-wc.c
> @@ -388,9 +388,9 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
> */
> if (acpi_dev_present("INT33FE", NULL, -1)) {
> board_info.irq = adap->client_irq;
> - adap->client = i2c_new_device(&adap->adapter, &board_info);
> - if (!adap->client) {
> - ret = -ENOMEM;
> + adap->client = i2c_new_client_device(&adap->adapter, &board_info);
> + if (IS_ERR(adap->client)) {
> + ret = PTR_ERR(adap->client);
> goto del_adapter;
> }
> }
>

2020-01-15 19:59:48

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH 00/12] i2c: convert subsystem to use i2c_new_client_device()

On Tue, Jan 07, 2020 at 06:47:34PM +0100, Wolfram Sang wrote:
> This patch series converts the I2C subsystem to use the new API. Drivers
> have been build tested. There is one user left in the SMBus part of the
> core which will need a seperate series because all users of this
> function need to be checked/converted, too.
>
> Except for documentation patches, the conversion has been done with a
> coccinelle script and further simplification have been applied when
> proofreading the patches.
>
> A branch is here:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/i2c/new_client_device
>
> Looking forward to comments...

Thanks for all the quick reviews and tests \o/

Series applied to for-next, thanks!


Attachments:
(No filename) (757.00 B)
signature.asc (849.00 B)
Download all attachments

2020-01-15 21:08:14

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH 06/12] i2c: taos-evm: convert to use i2c_new_client_device()


> In my opinion -ENODEV should only be used for "I expected a device but
> could not find it". For the case where we simply don't know what slave
> device to instantiate, NULL seems more appropriate, as it's not an
> error.

Well, I copied the behaviour from driver core here. -ENODEV is the one
errno where no messages will be displayed when returned from probe. So,
I think we can keep it as is.


Attachments:
(No filename) (410.00 B)
signature.asc (849.00 B)
Download all attachments