Skip to contentSkip to conversation

i2c: replace i2c_new_probed_device with an ERR_PTR variant

RFC PATCH Applied Wolfram Sang 8 participants 32 messages Nov 6, 2019 – Nov 28, 2019

Subsystems (13)
lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.20.1
#1 lore raw

RFC PATCH 1/12 i2c: replace i2c_new_probed_device with an ERR_PTR variant

In the general move to have i2c_new_*_device functions which return ERR_PTR instead of NULL, this patch converts i2c_new_probed_device().

There are only few users, so this patch converts the I2C core and all users in one go. The function gets renamed to i2c_new_scanned_device() so out-of-tree users will get a build failure to understand they need to adapt their error checking code.

---
 Documentation/i2c/instantiating-devices.rst | 10 ++++-----
 Documentation/i2c/writing-clients.rst       |  8 +++----
 drivers/i2c/i2c-core-base.c                 | 25 ++++++++++++++++-----
 include/linux/i2c.h                         | 12 +++++++---
 4 files changed, 37 insertions(+), 18 deletions(-)
Documentation/i2c/instantiating-devices.rst +5 -5
index 1238f1fa3382..875ebe9e78e3 100644
@@ -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_probed_device() instead of i2c_new_device().
+i2c_new_scanned_device() instead of i2c_new_device().
 
 Example (from the nxp OHCI driver)::
 
@@ -139,8 +139,8 @@ Example (from the nxp OHCI driver)::
 	i2c_adap = i2c_get_adapter(2);
 	memset(&i2c_info, 0, sizeof(struct i2c_board_info));
 	strscpy(i2c_info.type, "isp1301_nxp", sizeof(i2c_info.type));
-	isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info,
-						   normal_i2c, NULL);
+	isp1301_i2c_client = i2c_new_scanned_device(i2c_adap, &i2c_info,
+						    normal_i2c, NULL);
 	i2c_put_adapter(i2c_adap);
 	(...)
   }
@@ -153,14 +153,14 @@ 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
-i2c_new_probed_device().
+i2c_new_scanned_device().
 
 
 Method 3: Probe an I2C bus for certain devices
 ----------------------------------------------
 
 Sometimes you do not have enough information about an I2C device, not even
-to call i2c_new_probed_device(). The typical case is hardware monitoring
+to call i2c_new_scanned_device(). The typical case is hardware monitoring
 chips on PC mainboards. There are several dozen models, which can live
 at 25 different addresses. Given the huge number of mainboards out there,
 it is next to impossible to build an exhaustive list of the hardware
Documentation/i2c/writing-clients.rst +4 -4
index dddf0a14ab7c..ced309b5e0cc 100644
@@ -185,14 +185,14 @@ Sometimes you know that a device is connected to a given I2C bus, but you
 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_probed_device() variant, which is
+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
 responsive address in the list.  If you expect more than one device to be
-present in the address range, simply call i2c_new_probed_device() that
+present in the address range, simply call i2c_new_scanned_device() that
 many times.
 
-The call to i2c_new_device() or i2c_new_probed_device() typically happens
+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
 reference for later use.
 
@@ -237,7 +237,7 @@ Device Deletion
 ---------------
 
 Each I2C device which has been created using i2c_new_device() or
-i2c_new_probed_device() can be unregistered by calling
+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.
drivers/i2c/i2c-core-base.c +19 -6
index 6a5183cffdfc..380bde2dc23e 100644
@@ -2277,10 +2277,10 @@ int i2c_probe_func_quick_read(struct i2c_adapter *adap, unsigned short addr)
 EXPORT_SYMBOL_GPL(i2c_probe_func_quick_read);
 
 struct i2c_client *
-i2c_new_probed_device(struct i2c_adapter *adap,
-		      struct i2c_board_info *info,
-		      unsigned short const *addr_list,
-		      int (*probe)(struct i2c_adapter *adap, unsigned short addr))
+i2c_new_scanned_device(struct i2c_adapter *adap,
+		       struct i2c_board_info *info,
+		       unsigned short const *addr_list,
+		       int (*probe)(struct i2c_adapter *adap, unsigned short addr))
 {
 	int i;
 
@@ -2310,11 +2310,24 @@ i2c_new_probed_device(struct i2c_adapter *adap,
 
 	if (addr_list[i] == I2C_CLIENT_END) {
 		dev_dbg(&adap->dev, "Probing failed, no device found\n");
-		return NULL;
+		return ERR_PTR(-ENODEV);
 	}
 
 	info->addr = addr_list[i];
-	return i2c_new_device(adap, info);
+	return i2c_new_client_device(adap, info);
+}
+EXPORT_SYMBOL_GPL(i2c_new_scanned_device);
+
+struct i2c_client *
+i2c_new_probed_device(struct i2c_adapter *adap,
+		      struct i2c_board_info *info,
+		      unsigned short const *addr_list,
+		      int (*probe)(struct i2c_adapter *adap, unsigned short addr))
+{
+	struct i2c_client *client;
+
+	client = i2c_new_scanned_device(adap, info, addr_list, probe);
+	return IS_ERR(client) ? NULL : client;
 }
 EXPORT_SYMBOL_GPL(i2c_new_probed_device);
 
include/linux/i2c.h +9 -3
index aaf57d9b41db..df3044513464 100644
@@ -452,10 +452,16 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
  * a default probing method is used.
  */
 extern struct i2c_client *
+i2c_new_scanned_device(struct i2c_adapter *adap,
+		       struct i2c_board_info *info,
+		       unsigned short const *addr_list,
+		       int (*probe)(struct i2c_adapter *adap, unsigned short addr));
+
+extern struct i2c_client *
 i2c_new_probed_device(struct i2c_adapter *adap,
-		      struct i2c_board_info *info,
-		      unsigned short const *addr_list,
-		      int (*probe)(struct i2c_adapter *adap, unsigned short addr));
+		       struct i2c_board_info *info,
+		       unsigned short const *addr_list,
+		       int (*probe)(struct i2c_adapter *adap, unsigned short addr));
 
 /* Common custom probe functions */
 extern int i2c_probe_func_quick_read(struct i2c_adapter *adap, unsigned short addr);
Signature · 1 line
2.20.1
maintainer
#2 lore raw

I'm not an I2C expert, but as far as I can see: This patch looks useful and well done to me. Thanks for moving forward on making the interfaces use ERR_PTR instead of NULL.

Max

#3 lore raw
In reply to Wolfram Sang

Hi Wolfram,

Quoted 139 lines · Wolfram Sang

In the general move to have i2c_new_*_device functions which return ERR_PTR instead of NULL, this patch converts i2c_new_probed_device().

There are only few users, so this patch converts the I2C core and all users in one go. The function gets renamed to i2c_new_scanned_device() so out-of-tree users will get a build failure to understand they need to adapt their error checking code.

---
 Documentation/i2c/instantiating-devices.rst | 10 ++++-----
 Documentation/i2c/writing-clients.rst       |  8 +++----
 drivers/i2c/i2c-core-base.c                 | 25 ++++++++++++++++-----
 include/linux/i2c.h                         | 12 +++++++---
 4 files changed, 37 insertions(+), 18 deletions(-)
Documentation/i2c/instantiating-devices.rst +5 -5
index 1238f1fa3382..875ebe9e78e3 100644
@@ -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_probed_device() instead of i2c_new_device().
+i2c_new_scanned_device() instead of i2c_new_device().
 
 Example (from the nxp OHCI driver)::
 
@@ -139,8 +139,8 @@ Example (from the nxp OHCI driver)::
 	i2c_adap = i2c_get_adapter(2);
 	memset(&i2c_info, 0, sizeof(struct i2c_board_info));
 	strscpy(i2c_info.type, "isp1301_nxp", sizeof(i2c_info.type));
-	isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info,
-						   normal_i2c, NULL);
+	isp1301_i2c_client = i2c_new_scanned_device(i2c_adap, &i2c_info,
+						    normal_i2c, NULL);
 	i2c_put_adapter(i2c_adap);
(...)
   }
@@ -153,14 +153,14 @@ 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
-i2c_new_probed_device().
+i2c_new_scanned_device().
 
 
 Method 3: Probe an I2C bus for certain devices
 ----------------------------------------------
 
 Sometimes you do not have enough information about an I2C device, not even
-to call i2c_new_probed_device(). The typical case is hardware monitoring
+to call i2c_new_scanned_device(). The typical case is hardware monitoring
 chips on PC mainboards. There are several dozen models, which can live
 at 25 different addresses. Given the huge number of mainboards out there,
 it is next to impossible to build an exhaustive list of the hardware
Documentation/i2c/writing-clients.rst +4 -4
index dddf0a14ab7c..ced309b5e0cc 100644
@@ -185,14 +185,14 @@ Sometimes you know that a device is connected to a given I2C bus, but you
 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_probed_device() variant, which is
+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
 responsive address in the list.  If you expect more than one device to be
-present in the address range, simply call i2c_new_probed_device() that
+present in the address range, simply call i2c_new_scanned_device() that
 many times.
 
-The call to i2c_new_device() or i2c_new_probed_device() typically happens
+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
 reference for later use.
 
@@ -237,7 +237,7 @@ Device Deletion
 ---------------
 
 Each I2C device which has been created using i2c_new_device() or
-i2c_new_probed_device() can be unregistered by calling
+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.
drivers/i2c/i2c-core-base.c +19 -6
index 6a5183cffdfc..380bde2dc23e 100644
@@ -2277,10 +2277,10 @@ int i2c_probe_func_quick_read(struct i2c_adapter *adap, unsigned short addr)
 EXPORT_SYMBOL_GPL(i2c_probe_func_quick_read);
 
 struct i2c_client *
-i2c_new_probed_device(struct i2c_adapter *adap,
-		      struct i2c_board_info *info,
-		      unsigned short const *addr_list,
-		      int (*probe)(struct i2c_adapter *adap, unsigned short addr))
+i2c_new_scanned_device(struct i2c_adapter *adap,
+		       struct i2c_board_info *info,
+		       unsigned short const *addr_list,
+		       int (*probe)(struct i2c_adapter *adap, unsigned short addr))
 {
 	int i;
 
@@ -2310,11 +2310,24 @@ i2c_new_probed_device(struct i2c_adapter *adap,
 
 	if (addr_list[i] == I2C_CLIENT_END) {
 		dev_dbg(&adap->dev, "Probing failed, no device found\n");
-		return NULL;
+		return ERR_PTR(-ENODEV);
 	}
 
 	info->addr = addr_list[i];
-	return i2c_new_device(adap, info);
+	return i2c_new_client_device(adap, info);
+}
+EXPORT_SYMBOL_GPL(i2c_new_scanned_device);
+
+struct i2c_client *
+i2c_new_probed_device(struct i2c_adapter *adap,
+		      struct i2c_board_info *info,
+		      unsigned short const *addr_list,
+		      int (*probe)(struct i2c_adapter *adap, unsigned short addr))
+{
+	struct i2c_client *client;
+
+	client = i2c_new_scanned_device(adap, info, addr_list, probe);
+	return IS_ERR(client) ? NULL : client;
 }
 EXPORT_SYMBOL_GPL(i2c_new_probed_device);
 
include/linux/i2c.h +0 -0
index aaf57d9b41db..df3044513464 100644

include/linux/i2c.h i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf · line 460

Quoted 9 lines
include/linux/i2c.h +6 -0
@@ -452,10 +452,16 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
  * a default probing method is used.
  */
 extern struct i2c_client *
+i2c_new_scanned_device(struct i2c_adapter *adap,
+		       struct i2c_board_info *info,
+		       unsigned short const *addr_list,
+		       int (*probe)(struct i2c_adapter *adap, unsigned short addr));
+
+extern struct i2c_client *

I beg your pardon for the newbie question, perhaps a stupid one, kind of nitpicking, and not even strictly related to this patch, but what's the reason for these functions being declared extern?

For the rest LGTM, I did some grep checks before/after the patchset, ran some build tests, and everything looks fine.

Signature · 1 line
Luca
#4 lore raw

Hi Luca,

Quoted 3 lines

I beg your pardon for the newbie question, perhaps a stupid one, kind of nitpicking, and not even strictly related to this patch, but what's the reason for these functions being declared extern?

I did this for consistency reasons. I agree that the 'extern' keyword could need some second thought, yet I think that should be a seperate patchset. And that does not have priority for me, so if someone is interested... :)

Quoted 2 lines

For the rest LGTM, I did some grep checks before/after the patchset, ran some build tests, and everything looks fine.

Cool, thanks for your review!

All the best,

Wolfram

Reviewed-by
#5 lore raw

Hi Wolfram,

Quoted 10 lines · Wolfram Sang

Hi Luca,

Quoted 3 lines

I beg your pardon for the newbie question, perhaps a stupid one, kind of nitpicking, and not even strictly related to this patch, but what's the reason for these functions being declared extern?

I did this for consistency reasons. I agree that the 'extern' keyword could need some second thought, yet I think that should be a seperate patchset. And that does not have priority for me, so if someone is interested... :)

Ok, got it!

And then:

Bye,

Signature · 1 line
Luca
Applied
#6 lore raw
In reply to Wolfram Sang
Quoted 9 lines · Wolfram Sang

In the general move to have i2c_new_*_device functions which return ERR_PTR instead of NULL, this patch converts i2c_new_probed_device().

There are only few users, so this patch converts the I2C core and all users in one go. The function gets renamed to i2c_new_scanned_device() so out-of-tree users will get a build failure to understand they need to adapt their error checking code.

Eeks, this nearly slipped through the cracks because I marked it as RFC in patchwork...

Applied to for-next, thanks!

#7 lore raw

RFC PATCH 2/12 i2c: icy: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---
 drivers/i2c/busses/i2c-icy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-icy.c +4 -4
index 8382eb64b424..07baa4d8de39 100644
@@ -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;
Signature · 1 line
2.20.1
maintainer Acked-by on v1 2/12
#8 lore raw

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

Quoted 14 lines · Wolfram Sang

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

---
 drivers/i2c/busses/i2c-icy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-icy.c +0 -0
index 8382eb64b424..07baa4d8de39 100644
@@ -188,10 +188,10 @@ static int icy_probe(struct zorro_dev *z,
 		ltc2990_info.fwnode = new_fwnode;

drivers/i2c/busses/i2c-icy.c static int icy_probe(struct zorro_dev *z, · line 194

Quoted 10 lines
drivers/i2c/busses/i2c-icy.c +4 -4
 
 		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.

#10 lore raw

RFC PATCH 3/12 macintosh: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---

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

 drivers/macintosh/therm_windtunnel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/macintosh/therm_windtunnel.c +2 -2
index 8c744578122a..f15fec5e1cb6 100644
@@ -321,10 +321,10 @@ do_attach( struct i2c_adapter *adapter )
 
 		memset(&info, 0, sizeof(struct i2c_board_info));
 		strlcpy(info.type, "therm_ds1775", I2C_NAME_SIZE);
-		i2c_new_probed_device(adapter, &info, scan_ds1775, NULL);
+		i2c_new_scanned_device(adapter, &info, scan_ds1775, NULL);
 
 		strlcpy(info.type, "therm_adm1030", I2C_NAME_SIZE);
-		i2c_new_probed_device(adapter, &info, scan_adm1030, NULL);
+		i2c_new_scanned_device(adapter, &info, scan_adm1030, NULL);
 
 		if( x.thermostat && x.fan ) {
 			x.running = 1;
Signature · 1 line
2.20.1
#11 lore raw

RFC PATCH 4/12 platform: chrome: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---

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(-)
drivers/platform/chrome/chromeos_laptop.c +10 -8
index 8723bcf10c93..4f3651fcd9fe 100644
@@ -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;
 }
Signature · 1 line
2.20.1
#12 lore raw

RFC PATCH 5/12 video: fbdev: matrox: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---

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

 drivers/video/fbdev/matrox/i2c-matroxfb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/matrox/i2c-matroxfb.c +2 -2
index 34e2659c3189..e2e4705e3fe0 100644
@@ -191,8 +191,8 @@ static void* i2c_matroxfb_probe(struct matrox_fb_info* minfo) {
 				0x1b, I2C_CLIENT_END
 			};
 
-			i2c_new_probed_device(&m2info->maven.adapter,
-					      &maven_info, addr_list, NULL);
+			i2c_new_scanned_device(&m2info->maven.adapter,
+					       &maven_info, addr_list, NULL);
 		}
 	}
 	return m2info;
Signature · 1 line
2.20.1
#13 lore raw

Re: [RFC PATCH 05/12] video: fbdev: matrox: convert to i2c_new_scanned_device

Quoted 4 lines · Wolfram Sang

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

Ack for merging through whatever tree you think this should best land through.
-Daniel

Quoted 29 lines

---

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

 drivers/video/fbdev/matrox/i2c-matroxfb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/matrox/i2c-matroxfb.c +2 -2
index 34e2659c3189..e2e4705e3fe0 100644
@@ -191,8 +191,8 @@ static void* i2c_matroxfb_probe(struct matrox_fb_info* minfo) {
 				0x1b, I2C_CLIENT_END
 			};
 
-			i2c_new_probed_device(&m2info->maven.adapter,
-					      &maven_info, addr_list, NULL);
+			i2c_new_scanned_device(&m2info->maven.adapter,
+					       &maven_info, addr_list, NULL);
 		}
 	}
 	return m2info;
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#14 lore raw

Re: [RFC PATCH 05/12] video: fbdev: matrox: convert to i2c_new_scanned_device

Quoted 8 lines · Daniel Vetter
Quoted 4 lines · Wolfram Sang

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

Ack for merging through whatever tree you think this should best land through.

Ok, because it is a single and simple patch, I'll apply it simply via I2C. Thanks!

#16 lore raw

RFC PATCH 6/12 input: mouse: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---

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

 drivers/input/mouse/psmouse-smbus.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/input/mouse/psmouse-smbus.c +5 -3
index 027efdd2b2ad..35bf50a871d2 100644
@@ -198,10 +198,12 @@ static int psmouse_smbus_create_companion(struct device *dev, void *data)
 	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HOST_NOTIFY))
 		return 0;
 
-	smbdev->client = i2c_new_probed_device(adapter, &smbdev->board,
-					       addr_list, NULL);
-	if (!smbdev->client)
+	smbdev->client = i2c_new_scanned_device(adapter, &smbdev->board,
+					        addr_list, NULL);
+	if (IS_ERR(smbdev->client)) {
+		smbdev->client = NULL;
 		return 0;
+	}
 
 	/* We have our(?) device, stop iterating i2c bus. */
 	return 1;
Signature · 1 line
2.20.1
maintainer
#17 lore raw

Re: [RFC PATCH 06/12] input: mouse: convert to i2c_new_scanned_device

Quoted 21 lines · Wolfram Sang

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

---

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

 drivers/input/mouse/psmouse-smbus.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/input/mouse/psmouse-smbus.c +0 -2
index 027efdd2b2ad..35bf50a871d2 100644
@@ -198,10 +198,12 @@ static int psmouse_smbus_create_companion(struct device *dev, void *data)
 	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HOST_NOTIFY))
 		return 0;
 
-	smbdev->client = i2c_new_probed_device(adapter, &smbdev->board,
-					       addr_list, NULL);

drivers/input/mouse/psmouse-smbus.c static int psmouse_smbus_create_companion(struct device *dev, void *data) · line 209

Quoted 10 lines
drivers/input/mouse/psmouse-smbus.c +5 -1
-	if (!smbdev->client)
+	smbdev->client = i2c_new_scanned_device(adapter, &smbdev->board,
+					        addr_list, NULL);
+	if (IS_ERR(smbdev->client)) {
+		smbdev->client = NULL;
 		return 0;
+	}
 
 	/* We have our(?) device, stop iterating i2c bus. */
 	return 1;

I'd prefer postponing assignment until after we get valid value. I.e.

	client = i2c_new_probed_device(...);
	if (IS_ERR(client))
		return 0;

	/* We have our(?) device, stop iterating i2c bus. */
	smbdev->client = client;
	return 1;

Thanks.

Signature · 1 line
Dmitry
#18 lore raw

RFC PATCH 7/12 media: pci: cx23885: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---

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

 drivers/media/pci/cx23885/cx23885-i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/pci/cx23885/cx23885-i2c.c +2 -2
index 4f327ee9659e..f51fad33dc04 100644
@@ -337,8 +337,8 @@ int cx23885_i2c_register(struct cx23885_i2c *bus)
 		strscpy(info.type, "ir_video", I2C_NAME_SIZE);
 		/* Use quick read command for probe, some IR chips don't
 		 * support writes */
-		i2c_new_probed_device(&bus->i2c_adap, &info, addr_list,
-				      i2c_probe_func_quick_read);
+		i2c_new_scanned_device(&bus->i2c_adap, &info, addr_list,
+				       i2c_probe_func_quick_read);
 	}
 
 	return bus->i2c_rc;
Signature · 1 line
2.20.1
Acked-by on v1 7/12
#19 lore raw

Re: [RFC PATCH 07/12] media: pci: cx23885: convert to i2c_new_scanned_device

Quoted 4 lines · Wolfram Sang

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

Regards,

Hans

Quoted 23 lines

---

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

 drivers/media/pci/cx23885/cx23885-i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/pci/cx23885/cx23885-i2c.c +2 -2
index 4f327ee9659e..f51fad33dc04 100644
@@ -337,8 +337,8 @@ int cx23885_i2c_register(struct cx23885_i2c *bus)
 		strscpy(info.type, "ir_video", I2C_NAME_SIZE);
 		/* Use quick read command for probe, some IR chips don't
 		 * support writes */
-		i2c_new_probed_device(&bus->i2c_adap, &info, addr_list,
-				      i2c_probe_func_quick_read);
+		i2c_new_scanned_device(&bus->i2c_adap, &info, addr_list,
+				       i2c_probe_func_quick_read);
 	}
 
 	return bus->i2c_rc;
#20 lore raw

RFC PATCH 8/12 media: pci: cx88: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---

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

 drivers/media/pci/cx88/cx88-input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/cx88/cx88-input.c +1 -1
index 589f52d961eb..c7c2acd55266 100644
@@ -613,7 +613,7 @@ void cx88_i2c_init_ir(struct cx88_core *core)
 	}
 
 	/*
-	 * We can't call i2c_new_probed_device() because it uses
+	 * We can't call i2c_new_scanned_device() because it uses
 	 * quick writes for probing and at least some RC receiver
 	 * devices only reply to reads.
 	 * Also, Hauppauge XVR needs to be specified, as address 0x71
Signature · 1 line
2.20.1
#21 lore raw

Re: [RFC PATCH 08/12] media: pci: cx88: convert to i2c_new_scanned_device

Quoted 2 lines · Wolfram Sang

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

This commit text is a bit out-of-sync with the actual patch.

This should be improved for the next version. Looks good otherwise.

Regards,

Hans

Quoted 23 lines

---

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

 drivers/media/pci/cx88/cx88-input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/cx88/cx88-input.c +1 -1
index 589f52d961eb..c7c2acd55266 100644
@@ -613,7 +613,7 @@ void cx88_i2c_init_ir(struct cx88_core *core)
 	}
 
 	/*
-	 * We can't call i2c_new_probed_device() because it uses
+	 * We can't call i2c_new_scanned_device() because it uses
 	 * quick writes for probing and at least some RC receiver
 	 * devices only reply to reads.
 	 * Also, Hauppauge XVR needs to be specified, as address 0x71
#22 lore raw

Re: [RFC PATCH 08/12] media: pci: cx88: convert to i2c_new_scanned_device

Quoted 5 lines · Hans Verkuil
Quoted 2 lines · Wolfram Sang

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

This commit text is a bit out-of-sync with the actual patch.

Ha, true :) Thanks for pointing out (and the other reviews, too, of course!)

#23 lore raw

RFC PATCH 9/12 media: pci: bt8xx: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---

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

 drivers/media/pci/bt8xx/bttv-input.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/pci/bt8xx/bttv-input.c +3 -3
index 492bc85c2700..41226f1d0e5b 100644
@@ -386,7 +386,7 @@ void init_bttv_i2c_ir(struct bttv *btv)
 
 	if (btv->init_data.name) {
 		info.platform_data = &btv->init_data;
-		i2c_dev = i2c_new_device(&btv->c.i2c_adap, &info);
+		i2c_dev = i2c_new_client_device(&btv->c.i2c_adap, &info);
 	} else {
 		/*
 		 * The external IR receiver is at i2c address 0x34 (0x35 for
@@ -396,9 +396,9 @@ void init_bttv_i2c_ir(struct bttv *btv)
 		 * internal.
 		 * That's why we probe 0x1a (~0x34) first. CB
 		 */
-		i2c_dev = i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL);
+		i2c_dev = i2c_new_scanned_device(&btv->c.i2c_adap, &info, addr_list, NULL);
 	}
-	if (NULL == i2c_dev)
+	if (IS_ERR(i2c_dev))
 		return;
 
 #if defined(CONFIG_MODULES) && defined(MODULE)
Signature · 1 line
2.20.1
Acked-by on v1 9/12
#24 lore raw

Re: [RFC PATCH 09/12] media: pci: bt8xx: convert to i2c_new_scanned_device

Quoted 4 lines · Wolfram Sang

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

Regards,

Hans

Quoted 33 lines

---

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

 drivers/media/pci/bt8xx/bttv-input.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/pci/bt8xx/bttv-input.c +3 -3
index 492bc85c2700..41226f1d0e5b 100644
@@ -386,7 +386,7 @@ void init_bttv_i2c_ir(struct bttv *btv)
 
 	if (btv->init_data.name) {
 		info.platform_data = &btv->init_data;
-		i2c_dev = i2c_new_device(&btv->c.i2c_adap, &info);
+		i2c_dev = i2c_new_client_device(&btv->c.i2c_adap, &info);
 	} else {
 		/*
 		 * The external IR receiver is at i2c address 0x34 (0x35 for
@@ -396,9 +396,9 @@ void init_bttv_i2c_ir(struct bttv *btv)
 		 * internal.
 		 * That's why we probe 0x1a (~0x34) first. CB
 		 */
-		i2c_dev = i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL);
+		i2c_dev = i2c_new_scanned_device(&btv->c.i2c_adap, &info, addr_list, NULL);
 	}
-	if (NULL == i2c_dev)
+	if (IS_ERR(i2c_dev))
 		return;
 
 #if defined(CONFIG_MODULES) && defined(MODULE)
#25 lore raw

RFC PATCH 10/12 media: pci: cx18: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---

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

 drivers/media/pci/cx18/cx18-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/cx18/cx18-i2c.c +1 -1
index 1ef7ccf4a722..a83435245251 100644
@@ -88,7 +88,7 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
 		break;
 	}
 
-	return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ?
+	return IS_ERR(i2c_new_scanned_device(adap, &info, addr_list, NULL)) ?
 	       -1 : 0;
 }
 
Signature · 1 line
2.20.1
Acked-by on v1 10/12
#26 lore raw

Re: [RFC PATCH 10/12] media: pci: cx18: convert to i2c_new_scanned_device

Quoted 4 lines · Wolfram Sang

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

Regards,

Hans

Quoted 21 lines

---

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

 drivers/media/pci/cx18/cx18-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/cx18/cx18-i2c.c +1 -1
index 1ef7ccf4a722..a83435245251 100644
@@ -88,7 +88,7 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
 		break;
 	}
 
-	return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ?
+	return IS_ERR(i2c_new_scanned_device(adap, &info, addr_list, NULL)) ?
 	       -1 : 0;
 }
 
#27 lore raw

RFC PATCH 11/12 media: pci: ivtv: convert to i2c_new_scanned_device

In reply to Wolfram Sang

Move from the deprecated i2c_new_probed_device() to the new i2c_new_scanned_device(). Make use of the new ERRPTR if suitable. Change the legacy function to simply return void because the retval was never used anywhere.

---

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

 drivers/media/pci/ivtv/ivtv-i2c.c | 6 +++---
 drivers/media/pci/ivtv/ivtv-i2c.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/media/pci/ivtv/ivtv-i2c.c +3 -3
index 0772d757a389..982045c4eea8 100644
@@ -208,12 +208,12 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
 	info.platform_data = init_data;
 	strscpy(info.type, type, I2C_NAME_SIZE);
 
-	return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ?
+	return IS_ERR(i2c_new_scanned_device(adap, &info, addr_list, NULL)) ?
 	       -1 : 0;
 }
 
 /* Instantiate the IR receiver device using probing -- undesirable */
-struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
+void ivtv_i2c_new_ir_legacy(struct ivtv *itv)
 {
 	struct i2c_board_info info;
 	/*
@@ -235,7 +235,7 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
 
 	memset(&info, 0, sizeof(struct i2c_board_info));
 	strscpy(info.type, "ir_video", I2C_NAME_SIZE);
-	return i2c_new_probed_device(&itv->i2c_adap, &info, addr_list, NULL);
+	i2c_new_scanned_device(&itv->i2c_adap, &info, addr_list, NULL);
 }
 
 int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
drivers/media/pci/ivtv/ivtv-i2c.h +1 -1
index 462f73449a6e..2d9cdaa682c5 100644
@@ -9,7 +9,7 @@
 #ifndef IVTV_I2C_H
 #define IVTV_I2C_H
 
-struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv);
+void ivtv_i2c_new_ir_legacy(struct ivtv *itv);
 int ivtv_i2c_register(struct ivtv *itv, unsigned idx);
 struct v4l2_subdev *ivtv_find_hw(struct ivtv *itv, u32 hw);
 
Signature · 1 line
2.20.1
Acked-by on v1 11/12
#28 lore raw

Re: [RFC PATCH 11/12] media: pci: ivtv: convert to i2c_new_scanned_device

Quoted 6 lines · Wolfram Sang

Move from the deprecated i2c_new_probed_device() to the new i2c_new_scanned_device(). Make use of the new ERRPTR if suitable. Change the legacy function to simply return void because the retval was never used anywhere.

Regards,

Hans

Quoted 50 lines

---

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

 drivers/media/pci/ivtv/ivtv-i2c.c | 6 +++---
 drivers/media/pci/ivtv/ivtv-i2c.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/media/pci/ivtv/ivtv-i2c.c +3 -3
index 0772d757a389..982045c4eea8 100644
@@ -208,12 +208,12 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
 	info.platform_data = init_data;
 	strscpy(info.type, type, I2C_NAME_SIZE);
 
-	return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ?
+	return IS_ERR(i2c_new_scanned_device(adap, &info, addr_list, NULL)) ?
 	       -1 : 0;
 }
 
 /* Instantiate the IR receiver device using probing -- undesirable */
-struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
+void ivtv_i2c_new_ir_legacy(struct ivtv *itv)
 {
 	struct i2c_board_info info;
 	/*
@@ -235,7 +235,7 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
 
 	memset(&info, 0, sizeof(struct i2c_board_info));
 	strscpy(info.type, "ir_video", I2C_NAME_SIZE);
-	return i2c_new_probed_device(&itv->i2c_adap, &info, addr_list, NULL);
+	i2c_new_scanned_device(&itv->i2c_adap, &info, addr_list, NULL);
 }
 
 int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
drivers/media/pci/ivtv/ivtv-i2c.h +1 -1
index 462f73449a6e..2d9cdaa682c5 100644
@@ -9,7 +9,7 @@
 #ifndef IVTV_I2C_H
 #define IVTV_I2C_H
 
-struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv);
+void ivtv_i2c_new_ir_legacy(struct ivtv *itv);
 int ivtv_i2c_register(struct ivtv *itv, unsigned idx);
 struct v4l2_subdev *ivtv_find_hw(struct ivtv *itv, u32 hw);
 
#29 lore raw

RFC PATCH 12/12 media: v4l2-core: convert to i2c_new_scanned_device

In reply to Wolfram Sang

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

---

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

 drivers/media/v4l2-core/v4l2-i2c.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/v4l2-core/v4l2-i2c.c +5 -5
index 5bf99e7c0c09..25ddda3b7ce6 100644
@@ -74,10 +74,10 @@ struct v4l2_subdev
 
 	/* Create the i2c client */
 	if (info->addr == 0 && probe_addrs)
-		client = i2c_new_probed_device(adapter, info, probe_addrs,
-					       NULL);
+		client = i2c_new_scanned_device(adapter, info, probe_addrs,
+					        NULL);
 	else
-		client = i2c_new_device(adapter, info);
+		client = i2c_new_client_device(adapter, info);
 
 	/*
 	 * Note: by loading the module first we are certain that c->driver
@@ -88,7 +88,7 @@ struct v4l2_subdev
 	 * want to use the i2c device, so explicitly loading the module
 	 * is the best alternative.
 	 */
-	if (!client || !client->dev.driver)
+	if (IS_ERR(client) || !client->dev.driver)
 		goto error;
 
 	/* Lock the module so we can safely get the v4l2_subdev pointer */
@@ -110,7 +110,7 @@ struct v4l2_subdev
 	 * If we have a client but no subdev, then something went wrong and
 	 * we must unregister the client.
 	 */
-	if (client && !sd)
+	if (!IS_ERR(client) && !sd)
 		i2c_unregister_device(client);
 	return sd;
 }
Signature · 1 line
2.20.1
Acked-by on v1 12/12
#30 lore raw

Re: [RFC PATCH 12/12] media: v4l2-core: convert to i2c_new_scanned_device

Quoted 4 lines · Wolfram Sang

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

Regards,

Hans

Quoted 44 lines

---

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

 drivers/media/v4l2-core/v4l2-i2c.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/v4l2-core/v4l2-i2c.c +5 -5
index 5bf99e7c0c09..25ddda3b7ce6 100644
@@ -74,10 +74,10 @@ struct v4l2_subdev
 
 	/* Create the i2c client */
 	if (info->addr == 0 && probe_addrs)
-		client = i2c_new_probed_device(adapter, info, probe_addrs,
-					       NULL);
+		client = i2c_new_scanned_device(adapter, info, probe_addrs,
+					        NULL);
 	else
-		client = i2c_new_device(adapter, info);
+		client = i2c_new_client_device(adapter, info);
 
 	/*
 	 * Note: by loading the module first we are certain that c->driver
@@ -88,7 +88,7 @@ struct v4l2_subdev
 	 * want to use the i2c device, so explicitly loading the module
 	 * is the best alternative.
 	 */
-	if (!client || !client->dev.driver)
+	if (IS_ERR(client) || !client->dev.driver)
 		goto error;
 
 	/* Lock the module so we can safely get the v4l2_subdev pointer */
@@ -110,7 +110,7 @@ struct v4l2_subdev
 	 * If we have a client but no subdev, then something went wrong and
 	 * we must unregister the client.
 	 */
-	if (client && !sd)
+	if (!IS_ERR(client) && !sd)
 		i2c_unregister_device(client);
 	return sd;
 }
Acked-by on the v1 series
#31 lore raw
In reply to Wolfram Sang
Quoted 9 lines · Wolfram Sang

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.

Quoted 5 lines

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:

Quoted 38 lines

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(-)
Signature · 1 line
2.20.1