2019-11-06 09:55:01

by Wolfram Sang

[permalink] [raw]
Subject: [RFC PATCH 00/12] i2c: replace i2c_new_probed_device with an ERR_PTR variant

From: Wolfram Sang <[email protected]>

In the on-going mission to let i2c_new_* calls return an ERR_PTR instead
of NULL, here is a series converting i2c_new_probed_device(). A new
function called i2c_new_scanned_device() is introduced with the new
retval, but for now, a compatibility helper is provided until all users
are converted. The rest of the patches convert all current in-tree
users.

Note that these patches are RFC because I want feedback on the approach
and hopefully collect acks on the driver conversions. If all goes well,
I'll apply the first two patches for the next merge window. Then, once
this dependency is upstream, I'll resend this series with all issues
fixed and acks collected.

Core changes tested on a Renesas Salvator-XS board (R-Car M3-N), driver
patches build tested by me and buildbot.

Wolfram Sang (12):
i2c: replace i2c_new_probed_device with an ERR_PTR variant
i2c: icy: convert to i2c_new_scanned_device
macintosh: convert to i2c_new_scanned_device
platform: chrome: convert to i2c_new_scanned_device
video: fbdev: matrox: convert to i2c_new_scanned_device
input: mouse: convert to i2c_new_scanned_device
media: pci: cx23885: convert to i2c_new_scanned_device
media: pci: cx88: convert to i2c_new_scanned_device
media: pci: bt8xx: convert to i2c_new_scanned_device
media: pci: cx18: convert to i2c_new_scanned_device
media: pci: ivtv: convert to i2c_new_scanned_device
media: v4l2-core: convert to i2c_new_scanned_device

Documentation/i2c/instantiating-devices.rst | 10 ++++-----
Documentation/i2c/writing-clients.rst | 8 +++----
drivers/i2c/busses/i2c-icy.c | 8 +++----
drivers/i2c/i2c-core-base.c | 25 ++++++++++++++++-----
drivers/input/mouse/psmouse-smbus.c | 8 ++++---
drivers/macintosh/therm_windtunnel.c | 4 ++--
drivers/media/pci/bt8xx/bttv-input.c | 6 ++---
drivers/media/pci/cx18/cx18-i2c.c | 2 +-
drivers/media/pci/cx23885/cx23885-i2c.c | 4 ++--
drivers/media/pci/cx88/cx88-input.c | 2 +-
drivers/media/pci/ivtv/ivtv-i2c.c | 6 ++---
drivers/media/pci/ivtv/ivtv-i2c.h | 2 +-
drivers/media/v4l2-core/v4l2-i2c.c | 10 ++++-----
drivers/platform/chrome/chromeos_laptop.c | 18 ++++++++-------
drivers/video/fbdev/matrox/i2c-matroxfb.c | 4 ++--
include/linux/i2c.h | 12 +++++++---
16 files changed, 76 insertions(+), 53 deletions(-)

--
2.20.1


2019-11-06 09:55:07

by Wolfram Sang

[permalink] [raw]
Subject: [RFC PATCH 04/12] platform: chrome: convert to i2c_new_scanned_device

Move from the deprecated i2c_new_probed_device() to the new
i2c_new_scanned_device(). Make use of the new ERRPTR if suitable.

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

Build tested only. RFC, please comment and/or ack, but don't apply yet.

drivers/platform/chrome/chromeos_laptop.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
index 8723bcf10c93..4f3651fcd9fe 100644
--- a/drivers/platform/chrome/chromeos_laptop.c
+++ b/drivers/platform/chrome/chromeos_laptop.c
@@ -63,7 +63,7 @@ struct acpi_peripheral {
struct chromeos_laptop {
/*
* Note that we can't mark this pointer as const because
- * i2c_new_probed_device() changes passed in I2C board info, so.
+ * i2c_new_scanned_device() changes passed in I2C board info, so.
*/
struct i2c_peripheral *i2c_peripherals;
unsigned int num_i2c_peripherals;
@@ -87,8 +87,8 @@ chromes_laptop_instantiate_i2c_device(struct i2c_adapter *adapter,
* address we scan secondary addresses. In any case the client
* structure gets assigned primary address.
*/
- client = i2c_new_probed_device(adapter, info, addr_list, NULL);
- if (!client && alt_addr) {
+ client = i2c_new_scanned_device(adapter, info, addr_list, NULL);
+ if (IS_ERR(client) && alt_addr) {
struct i2c_board_info dummy_info = {
I2C_BOARD_INFO("dummy", info->addr),
};
@@ -97,9 +97,9 @@ chromes_laptop_instantiate_i2c_device(struct i2c_adapter *adapter,
};
struct i2c_client *dummy;

- dummy = i2c_new_probed_device(adapter, &dummy_info,
- alt_addr_list, NULL);
- if (dummy) {
+ dummy = i2c_new_scanned_device(adapter, &dummy_info,
+ alt_addr_list, NULL);
+ if (!IS_ERR(dummy)) {
pr_debug("%d-%02x is probed at %02x\n",
adapter->nr, info->addr, dummy->addr);
i2c_unregister_device(dummy);
@@ -107,12 +107,14 @@ chromes_laptop_instantiate_i2c_device(struct i2c_adapter *adapter,
}
}

- if (!client)
+ if (IS_ERR(client)) {
+ client = NULL;
pr_debug("failed to register device %d-%02x\n",
adapter->nr, info->addr);
- else
+ } else {
pr_debug("added i2c device %d-%02x\n",
adapter->nr, info->addr);
+ }

return client;
}
--
2.20.1

2019-11-06 09:55:39

by Wolfram Sang

[permalink] [raw]
Subject: [RFC PATCH 02/12] i2c: icy: convert to i2c_new_scanned_device

Move from the deprecated i2c_new_probed_device() to the new
i2c_new_scanned_device(). Make use of the new ERRPTR if suitable.

Signed-off-by: Wolfram Sang <[email protected]>
---
drivers/i2c/busses/i2c-icy.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-icy.c b/drivers/i2c/busses/i2c-icy.c
index 8382eb64b424..07baa4d8de39 100644
--- a/drivers/i2c/busses/i2c-icy.c
+++ b/drivers/i2c/busses/i2c-icy.c
@@ -188,10 +188,10 @@ static int icy_probe(struct zorro_dev *z,
ltc2990_info.fwnode = new_fwnode;

i2c->ltc2990_client =
- i2c_new_probed_device(&i2c->adapter,
- &ltc2990_info,
- icy_ltc2990_addresses,
- NULL);
+ i2c_new_scanned_device(&i2c->adapter,
+ &ltc2990_info,
+ icy_ltc2990_addresses,
+ NULL);
}

return 0;
--
2.20.1

2019-11-06 10:08:07

by Sean Young

[permalink] [raw]
Subject: Re: [RFC PATCH 00/12] i2c: replace i2c_new_probed_device with an ERR_PTR variant

On Wed, Nov 06, 2019 at 10:50:18AM +0100, Wolfram Sang wrote:
> From: Wolfram Sang <[email protected]>
>
> In the on-going mission to let i2c_new_* calls return an ERR_PTR instead
> of NULL, here is a series converting i2c_new_probed_device(). A new
> function called i2c_new_scanned_device() is introduced with the new
> retval, but for now, a compatibility helper is provided until all users
> are converted. The rest of the patches convert all current in-tree
> users.
>
> Note that these patches are RFC because I want feedback on the approach
> and hopefully collect acks on the driver conversions. If all goes well,
> I'll apply the first two patches for the next merge window. Then, once
> this dependency is upstream, I'll resend this series with all issues
> fixed and acks collected.

The patches to drivers/media/pci/* are all IR related which have touched
on/read over the years. So, for those:

Acked-by: Sean Young <[email protected]>

>
> Core changes tested on a Renesas Salvator-XS board (R-Car M3-N), driver
> patches build tested by me and buildbot.
>
> Wolfram Sang (12):
> i2c: replace i2c_new_probed_device with an ERR_PTR variant
> i2c: icy: convert to i2c_new_scanned_device
> macintosh: convert to i2c_new_scanned_device
> platform: chrome: convert to i2c_new_scanned_device
> video: fbdev: matrox: convert to i2c_new_scanned_device
> input: mouse: convert to i2c_new_scanned_device
> media: pci: cx23885: convert to i2c_new_scanned_device
> media: pci: cx88: convert to i2c_new_scanned_device
> media: pci: bt8xx: convert to i2c_new_scanned_device
> media: pci: cx18: convert to i2c_new_scanned_device
> media: pci: ivtv: convert to i2c_new_scanned_device
> media: v4l2-core: convert to i2c_new_scanned_device
>
> Documentation/i2c/instantiating-devices.rst | 10 ++++-----
> Documentation/i2c/writing-clients.rst | 8 +++----
> drivers/i2c/busses/i2c-icy.c | 8 +++----
> drivers/i2c/i2c-core-base.c | 25 ++++++++++++++++-----
> drivers/input/mouse/psmouse-smbus.c | 8 ++++---
> drivers/macintosh/therm_windtunnel.c | 4 ++--
> drivers/media/pci/bt8xx/bttv-input.c | 6 ++---
> drivers/media/pci/cx18/cx18-i2c.c | 2 +-
> drivers/media/pci/cx23885/cx23885-i2c.c | 4 ++--
> drivers/media/pci/cx88/cx88-input.c | 2 +-
> drivers/media/pci/ivtv/ivtv-i2c.c | 6 ++---
> drivers/media/pci/ivtv/ivtv-i2c.h | 2 +-
> drivers/media/v4l2-core/v4l2-i2c.c | 10 ++++-----
> drivers/platform/chrome/chromeos_laptop.c | 18 ++++++++-------
> drivers/video/fbdev/matrox/i2c-matroxfb.c | 4 ++--
> include/linux/i2c.h | 12 +++++++---
> 16 files changed, 76 insertions(+), 53 deletions(-)
>
> --
> 2.20.1

2019-11-06 11:36:56

by Max Staudt

[permalink] [raw]
Subject: Re: [RFC PATCH 02/12] i2c: icy: convert to i2c_new_scanned_device

On 11/06/2019 10:50 AM, Wolfram Sang wrote:
> Move from the deprecated i2c_new_probed_device() to the new
> i2c_new_scanned_device(). Make use of the new ERRPTR if suitable.
>
> Signed-off-by: Wolfram Sang <[email protected]>
> ---
> drivers/i2c/busses/i2c-icy.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-icy.c b/drivers/i2c/busses/i2c-icy.c
> index 8382eb64b424..07baa4d8de39 100644
> --- a/drivers/i2c/busses/i2c-icy.c
> +++ b/drivers/i2c/busses/i2c-icy.c
> @@ -188,10 +188,10 @@ static int icy_probe(struct zorro_dev *z,
> ltc2990_info.fwnode = new_fwnode;
>
> i2c->ltc2990_client =
> - i2c_new_probed_device(&i2c->adapter,
> - &ltc2990_info,
> - icy_ltc2990_addresses,
> - NULL);
> + i2c_new_scanned_device(&i2c->adapter,
> + &ltc2990_info,
> + icy_ltc2990_addresses,
> + NULL);

Looks good, thank you for patching this!

i2c_unregister_device() checks the pointer using IS_ERR_OR_NULL(), so the simple logic in i2c-icy (where the pointer is not checked on i2c_new_scanned_device()) still works.


Acked-by: Max Staudt <[email protected]>

2019-11-28 16:20:11

by Wolfram Sang

[permalink] [raw]
Subject: Re: [RFC PATCH 02/12] i2c: icy: convert to i2c_new_scanned_device

On Wed, Nov 06, 2019 at 10:50:20AM +0100, Wolfram Sang wrote:
> Move from the deprecated i2c_new_probed_device() to the new
> i2c_new_scanned_device(). Make use of the new ERRPTR if suitable.
>
> Signed-off-by: Wolfram Sang <[email protected]>

Applied to for-next, thanks!


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