linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/17] media: use new API for creating client devices
@ 2019-11-06 21:21 Wolfram Sang
  2019-11-06 21:21 ` [PATCH 01/17] i2c: add helper to check if a client has a driver attached Wolfram Sang
                   ` (16 more replies)
  0 siblings, 17 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, linux-arm-kernel, linux-kernel

These media drivers create a new I2C client device with the deprecated
i2c_new_device() and check afterwards if the client exists and if a
driver is bound to it.

These series changes the drivers to use the now suggested
i2c_new_client_device() call and introduces a helper to check if the
driver is bound. This helper supports (for now) the old and the new API
and is also more readable.

The drivers were converted with the following coccinelle script:

@@
expression client;
statement S;
@@
	client =
-		i2c_new_device
+		i2c_new_client_device
			(...);
	... when != client
	if (
-		\( !client \| client == NULL \) || \( !client->dev.driver \| client->dev.driver == NULL \)
+		!i2c_client_has_driver(client)
			) {
			S
		}

The helper has been tested on a Renesas Salvator-XS board (R-Car M3-N).
The rest was build tested by me. buildbot has this still queued.

Although the first patch is in the I2C realm, I suggest that all patches
go through the media tree to avoid the dependency. There are no merge
conflicts with I2C currently and I don't see any coming (famous last
words).

This series is based on linux-next as of today. It does not depend on
the i2c_new_probed_device() conversion I sent out earlier today. This
series can be applied as is.

Looking forward to comments.

Thanks and happy hacking,

   Wolfram


Wolfram Sang (17):
  i2c: add helper to check if a client has a driver attached
  media: dvb-core: dvbdev: convert to use i2c_new_client_device()
  media: dvb-frontends: cxd2820r_core: convert to use
    i2c_new_client_device()
  media: dvb-frontends: lgdt330x: convert to use i2c_new_client_device()
  media: dvb-frontends: m88ds3103: convert to use
    i2c_new_client_device()
  media: dvb-frontends: ts2020: convert to use i2c_new_client_device()
  media: pci: cx23885: cx23885-dvb: convert to use
    i2c_new_client_device()
  media: pci: saa7164: saa7164-dvb: convert to use
    i2c_new_client_device()
  media: pci: smipcie: smipcie-main: convert to use
    i2c_new_client_device()
  media: platform: sti: c8sectpfe: c8sectpfe-dvb: convert to use
    i2c_new_client_device()
  media: usb: dvb-usb-v2: af9035: convert to use i2c_new_client_device()
  media: usb: dvb-usb-v2: anysee: convert to use i2c_new_client_device()
  media: usb: dvb-usb-v2: rtl28xxu: convert to use
    i2c_new_client_device()
  media: usb: dvb-usb-v2: zd1301: convert to use i2c_new_client_device()
  media: usb: dvb-usb: dib0700_devices: convert to use
    i2c_new_client_device()
  media: usb: dvb-usb: dw2102: convert to use i2c_new_client_device()
  media: v4l2-core: v4l2-i2c: convert to use i2c_new_client_device()

 drivers/media/dvb-core/dvbdev.c               |   4 +-
 drivers/media/dvb-frontends/cxd2820r_core.c   |   4 +-
 drivers/media/dvb-frontends/lgdt330x.c        |   4 +-
 drivers/media/dvb-frontends/m88ds3103.c       |   4 +-
 drivers/media/dvb-frontends/ts2020.c          |   4 +-
 drivers/media/pci/cx23885/cx23885-dvb.c       | 114 +++++++++---------
 drivers/media/pci/saa7164/saa7164-dvb.c       |  20 +--
 drivers/media/pci/smipcie/smipcie-main.c      |   4 +-
 .../platform/sti/c8sectpfe/c8sectpfe-dvb.c    |   4 +-
 drivers/media/usb/dvb-usb-v2/af9035.c         |   4 +-
 drivers/media/usb/dvb-usb-v2/anysee.c         |   4 +-
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c       |  36 +++---
 drivers/media/usb/dvb-usb-v2/zd1301.c         |   4 +-
 drivers/media/usb/dvb-usb/dib0700_devices.c   |   8 +-
 drivers/media/usb/dvb-usb/dw2102.c            |   8 +-
 drivers/media/v4l2-core/v4l2-i2c.c            |   2 +-
 include/linux/i2c.h                           |   5 +
 17 files changed, 116 insertions(+), 117 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 01/17] i2c: add helper to check if a client has a driver attached
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-12-11  7:59   ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 02/17] media: dvb-core: dvbdev: convert to use i2c_new_client_device() Wolfram Sang
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Wolfram Sang, linux-kernel

Factoring out something used in the media subsystem. As an improvement,
it bails out on both, NULL and ERRPTR.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 include/linux/i2c.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index aaf57d9b41db..93b315c9a062 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -850,6 +850,11 @@ extern void i2c_del_driver(struct i2c_driver *driver);
 #define i2c_add_driver(driver) \
 	i2c_register_driver(THIS_MODULE, driver)
 
+static inline bool i2c_client_has_driver(struct i2c_client *client)
+{
+	return !IS_ERR_OR_NULL(client) && client->dev.driver;
+}
+
 extern struct i2c_client *i2c_use_client(struct i2c_client *client);
 extern void i2c_release_client(struct i2c_client *client);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 02/17] media: dvb-core: dvbdev: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
  2019-11-06 21:21 ` [PATCH 01/17] i2c: add helper to check if a client has a driver attached Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 03/17] media: dvb-frontends: cxd2820r_core: " Wolfram Sang
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Mauro Carvalho Chehab, linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/dvb-core/dvbdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 917fe034af37..80b6a71aa33e 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -983,8 +983,8 @@ struct i2c_client *dvb_module_probe(const char *module_name,
 	board_info->addr = addr;
 	board_info->platform_data = platform_data;
 	request_module(module_name);
-	client = i2c_new_device(adap, board_info);
-	if (client == NULL || client->dev.driver == NULL) {
+	client = i2c_new_client_device(adap, board_info);
+	if (!i2c_client_has_driver(client)) {
 		kfree(board_info);
 		return NULL;
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 03/17] media: dvb-frontends: cxd2820r_core: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
  2019-11-06 21:21 ` [PATCH 01/17] i2c: add helper to check if a client has a driver attached Wolfram Sang
  2019-11-06 21:21 ` [PATCH 02/17] media: dvb-core: dvbdev: convert to use i2c_new_client_device() Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 04/17] media: dvb-frontends: lgdt330x: " Wolfram Sang
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media
  Cc: linux-i2c, Wolfram Sang, Antti Palosaari, Mauro Carvalho Chehab,
	linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/dvb-frontends/cxd2820r_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/cxd2820r_core.c b/drivers/media/dvb-frontends/cxd2820r_core.c
index d137199e13e6..b1618339eec0 100644
--- a/drivers/media/dvb-frontends/cxd2820r_core.c
+++ b/drivers/media/dvb-frontends/cxd2820r_core.c
@@ -530,8 +530,8 @@ struct dvb_frontend *cxd2820r_attach(const struct cxd2820r_config *config,
 	strscpy(board_info.type, "cxd2820r", I2C_NAME_SIZE);
 	board_info.addr = config->i2c_address;
 	board_info.platform_data = &pdata;
-	client = i2c_new_device(adapter, &board_info);
-	if (!client || !client->dev.driver)
+	client = i2c_new_client_device(adapter, &board_info);
+	if (!i2c_client_has_driver(client))
 		return NULL;
 
 	return pdata.get_dvb_frontend(client);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 04/17] media: dvb-frontends: lgdt330x: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (2 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 03/17] media: dvb-frontends: cxd2820r_core: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 05/17] media: dvb-frontends: m88ds3103: " Wolfram Sang
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Mauro Carvalho Chehab, linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/dvb-frontends/lgdt330x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/lgdt330x.c b/drivers/media/dvb-frontends/lgdt330x.c
index 651c8aa75e17..da3a8c5e18d8 100644
--- a/drivers/media/dvb-frontends/lgdt330x.c
+++ b/drivers/media/dvb-frontends/lgdt330x.c
@@ -922,8 +922,8 @@ struct dvb_frontend *lgdt330x_attach(const struct lgdt330x_config *_config,
 	strscpy(board_info.type, "lgdt330x", sizeof(board_info.type));
 	board_info.addr = demod_address;
 	board_info.platform_data = &config;
-	client = i2c_new_device(i2c, &board_info);
-	if (!client || !client->dev.driver)
+	client = i2c_new_client_device(i2c, &board_info);
+	if (!i2c_client_has_driver(client))
 		return NULL;
 
 	return lgdt330x_get_dvb_frontend(client);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 05/17] media: dvb-frontends: m88ds3103: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (3 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 04/17] media: dvb-frontends: lgdt330x: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 06/17] media: dvb-frontends: ts2020: " Wolfram Sang
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media
  Cc: linux-i2c, Wolfram Sang, Antti Palosaari, Mauro Carvalho Chehab,
	linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/dvb-frontends/m88ds3103.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index 3a367a585084..c96f05ff5f2f 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -1277,8 +1277,8 @@ struct dvb_frontend *m88ds3103_attach(const struct m88ds3103_config *cfg,
 	strscpy(board_info.type, "m88ds3103", I2C_NAME_SIZE);
 	board_info.addr = cfg->i2c_addr;
 	board_info.platform_data = &pdata;
-	client = i2c_new_device(i2c, &board_info);
-	if (!client || !client->dev.driver)
+	client = i2c_new_client_device(i2c, &board_info);
+	if (!i2c_client_has_driver(client))
 		return NULL;
 
 	*tuner_i2c_adapter = pdata.get_i2c_adapter(client);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 06/17] media: dvb-frontends: ts2020: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (4 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 05/17] media: dvb-frontends: m88ds3103: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 07/17] media: pci: cx23885: cx23885-dvb: " Wolfram Sang
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Mauro Carvalho Chehab, linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/dvb-frontends/ts2020.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/ts2020.c b/drivers/media/dvb-frontends/ts2020.c
index 6c24d6d0d4c9..234607b02edb 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -519,8 +519,8 @@ struct dvb_frontend *ts2020_attach(struct dvb_frontend *fe,
 	strscpy(board_info.type, "ts2020", I2C_NAME_SIZE);
 	board_info.addr = config->tuner_address;
 	board_info.platform_data = &pdata;
-	client = i2c_new_device(i2c, &board_info);
-	if (!client || !client->dev.driver)
+	client = i2c_new_client_device(i2c, &board_info);
+	if (!i2c_client_has_driver(client))
 		return NULL;
 
 	return fe;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 07/17] media: pci: cx23885: cx23885-dvb: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (5 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 06/17] media: dvb-frontends: ts2020: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 08/17] media: pci: saa7164: saa7164-dvb: " Wolfram Sang
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Mauro Carvalho Chehab, linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 114 +++++++++++-------------
 1 file changed, 54 insertions(+), 60 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 4f386db33a11..494751a067a3 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1159,8 +1159,8 @@ static int dvb_register_ci_mac(struct cx23885_tsport *port)
 		info.addr = 0x40;
 		info.platform_data = &sp2_config;
 		request_module(info.type);
-		client_ci = i2c_new_device(&i2c_bus->i2c_adap, &info);
-		if (client_ci == NULL || client_ci->dev.driver == NULL)
+		client_ci = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+		if (!i2c_client_has_driver(client_ci))
 			return -ENODEV;
 		if (!try_module_get(client_ci->dev.driver->owner)) {
 			i2c_unregister_device(client_ci);
@@ -1826,8 +1826,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x05;
 			info.platform_data = &tda10071_pdata;
 			request_module("tda10071");
-			client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
-			if (!client_demod || !client_demod->dev.driver)
+			client_demod = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+			if (!i2c_client_has_driver(client_demod))
 				goto frontend_detach;
 			if (!try_module_get(client_demod->dev.driver->owner)) {
 				i2c_unregister_device(client_demod);
@@ -1843,8 +1843,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x0b;
 			info.platform_data = &a8293_pdata;
 			request_module("a8293");
-			client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
-			if (!client_sec || !client_sec->dev.driver)
+			client_sec = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+			if (!i2c_client_has_driver(client_sec))
 				goto frontend_detach;
 			if (!try_module_get(client_sec->dev.driver->owner)) {
 				i2c_unregister_device(client_sec);
@@ -1864,9 +1864,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x64;
 			info.platform_data = &si2165_pdata;
 			request_module(info.type);
-			client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
-			if (client_demod == NULL ||
-					client_demod->dev.driver == NULL)
+			client_demod = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+			if (!i2c_client_has_driver(client_demod))
 				goto frontend_detach;
 			if (!try_module_get(client_demod->dev.driver->owner)) {
 				i2c_unregister_device(client_demod);
@@ -1898,8 +1897,8 @@ static int dvb_register(struct cx23885_tsport *port)
 		info.addr = 0x05;
 		info.platform_data = &tda10071_pdata;
 		request_module("tda10071");
-		client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
-		if (!client_demod || !client_demod->dev.driver)
+		client_demod = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+		if (!i2c_client_has_driver(client_demod))
 			goto frontend_detach;
 		if (!try_module_get(client_demod->dev.driver->owner)) {
 			i2c_unregister_device(client_demod);
@@ -1915,8 +1914,8 @@ static int dvb_register(struct cx23885_tsport *port)
 		info.addr = 0x0b;
 		info.platform_data = &a8293_pdata;
 		request_module("a8293");
-		client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
-		if (!client_sec || !client_sec->dev.driver)
+		client_sec = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+		if (!i2c_client_has_driver(client_sec))
 			goto frontend_detach;
 		if (!try_module_get(client_sec->dev.driver->owner)) {
 			i2c_unregister_device(client_sec);
@@ -1948,9 +1947,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x60;
 			info.platform_data = &ts2020_config;
 			request_module(info.type);
-			client_tuner = i2c_new_device(adapter, &info);
-			if (client_tuner == NULL ||
-					client_tuner->dev.driver == NULL)
+			client_tuner = i2c_new_client_device(adapter, &info);
+			if (!i2c_client_has_driver(client_tuner))
 				goto frontend_detach;
 			if (!try_module_get(client_tuner->dev.driver->owner)) {
 				i2c_unregister_device(client_tuner);
@@ -1985,9 +1983,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x64;
 			info.platform_data = &si2168_config;
 			request_module(info.type);
-			client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
-			if (client_demod == NULL ||
-					client_demod->dev.driver == NULL)
+			client_demod = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+			if (!i2c_client_has_driver(client_demod))
 				goto frontend_detach;
 			if (!try_module_get(client_demod->dev.driver->owner)) {
 				i2c_unregister_device(client_demod);
@@ -2004,9 +2001,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x60;
 			info.platform_data = &si2157_config;
 			request_module(info.type);
-			client_tuner = i2c_new_device(adapter, &info);
-			if (client_tuner == NULL ||
-					client_tuner->dev.driver == NULL)
+			client_tuner = i2c_new_client_device(adapter, &info);
+			if (!i2c_client_has_driver(client_tuner))
 				goto frontend_detach;
 
 			if (!try_module_get(client_tuner->dev.driver->owner)) {
@@ -2032,8 +2028,8 @@ static int dvb_register(struct cx23885_tsport *port)
 		info.addr = 0x64;
 		info.platform_data = &si2168_config;
 		request_module(info.type);
-		client_demod = i2c_new_device(&i2c_bus2->i2c_adap, &info);
-		if (client_demod == NULL || client_demod->dev.driver == NULL)
+		client_demod = i2c_new_client_device(&i2c_bus2->i2c_adap, &info);
+		if (!i2c_client_has_driver(client_demod))
 			goto frontend_detach;
 		if (!try_module_get(client_demod->dev.driver->owner)) {
 			i2c_unregister_device(client_demod);
@@ -2050,9 +2046,8 @@ static int dvb_register(struct cx23885_tsport *port)
 		info.addr = 0x60;
 		info.platform_data = &si2157_config;
 		request_module(info.type);
-		client_tuner = i2c_new_device(adapter, &info);
-		if (client_tuner == NULL ||
-				client_tuner->dev.driver == NULL)
+		client_tuner = i2c_new_client_device(adapter, &info);
+		if (!i2c_client_has_driver(client_tuner))
 			goto frontend_detach;
 		if (!try_module_get(client_tuner->dev.driver->owner)) {
 			i2c_unregister_device(client_tuner);
@@ -2080,8 +2075,8 @@ static int dvb_register(struct cx23885_tsport *port)
 		info.addr = 0x60;
 		info.platform_data = &ts2020_config;
 		request_module(info.type);
-		client_tuner = i2c_new_device(adapter, &info);
-		if (client_tuner == NULL || client_tuner->dev.driver == NULL)
+		client_tuner = i2c_new_client_device(adapter, &info);
+		if (!i2c_client_has_driver(client_tuner))
 			goto frontend_detach;
 		if (!try_module_get(client_tuner->dev.driver->owner)) {
 			i2c_unregister_device(client_tuner);
@@ -2129,8 +2124,8 @@ static int dvb_register(struct cx23885_tsport *port)
 		info.addr = 0x68;
 		info.platform_data = &m88ds3103_pdata;
 		request_module(info.type);
-		client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
-		if (client_demod == NULL || client_demod->dev.driver == NULL)
+		client_demod = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+		if (!i2c_client_has_driver(client_demod))
 			goto frontend_detach;
 		if (!try_module_get(client_demod->dev.driver->owner)) {
 			i2c_unregister_device(client_demod);
@@ -2149,8 +2144,8 @@ static int dvb_register(struct cx23885_tsport *port)
 		info.addr = 0x60;
 		info.platform_data = &ts2020_config;
 		request_module(info.type);
-		client_tuner = i2c_new_device(adapter, &info);
-		if (client_tuner == NULL || client_tuner->dev.driver == NULL)
+		client_tuner = i2c_new_client_device(adapter, &info);
+		if (!i2c_client_has_driver(client_tuner))
 			goto frontend_detach;
 		if (!try_module_get(client_tuner->dev.driver->owner)) {
 			i2c_unregister_device(client_tuner);
@@ -2194,8 +2189,8 @@ static int dvb_register(struct cx23885_tsport *port)
 		info.addr = 0x64;
 		info.platform_data = &si2168_config;
 		request_module(info.type);
-		client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
-		if (client_demod == NULL || client_demod->dev.driver == NULL)
+		client_demod = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+		if (!i2c_client_has_driver(client_demod))
 			goto frontend_detach;
 		if (!try_module_get(client_demod->dev.driver->owner)) {
 			i2c_unregister_device(client_demod);
@@ -2212,9 +2207,8 @@ static int dvb_register(struct cx23885_tsport *port)
 		info.addr = 0x60;
 		info.platform_data = &si2157_config;
 		request_module(info.type);
-		client_tuner = i2c_new_device(adapter, &info);
-		if (client_tuner == NULL ||
-				client_tuner->dev.driver == NULL)
+		client_tuner = i2c_new_client_device(adapter, &info);
+		if (!i2c_client_has_driver(client_tuner))
 			goto frontend_detach;
 		if (!try_module_get(client_tuner->dev.driver->owner)) {
 			i2c_unregister_device(client_tuner);
@@ -2245,8 +2239,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x0b;
 			info.platform_data = &a8293_pdata;
 			request_module("a8293");
-			client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
-			if (!client_sec || !client_sec->dev.driver)
+			client_sec = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+			if (!i2c_client_has_driver(client_sec))
 				goto frontend_detach;
 			if (!try_module_get(client_sec->dev.driver->owner)) {
 				i2c_unregister_device(client_sec);
@@ -2262,8 +2256,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x21;
 			info.platform_data = &m88rs6000t_config;
 			request_module("%s", info.type);
-			client_tuner = i2c_new_device(adapter, &info);
-			if (!client_tuner || !client_tuner->dev.driver)
+			client_tuner = i2c_new_client_device(adapter, &info);
+			if (!i2c_client_has_driver(client_tuner))
 				goto frontend_detach;
 			if (!try_module_get(client_tuner->dev.driver->owner)) {
 				i2c_unregister_device(client_tuner);
@@ -2287,8 +2281,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x64;
 			info.platform_data = &si2168_config;
 			request_module("%s", info.type);
-			client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
-			if (!client_demod || !client_demod->dev.driver)
+			client_demod = i2c_new_client_device(&i2c_bus->i2c_adap, &info);
+			if (!i2c_client_has_driver(client_demod))
 				goto frontend_detach;
 			if (!try_module_get(client_demod->dev.driver->owner)) {
 				i2c_unregister_device(client_demod);
@@ -2305,8 +2299,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x60;
 			info.platform_data = &si2157_config;
 			request_module("%s", info.type);
-			client_tuner = i2c_new_device(&i2c_bus2->i2c_adap, &info);
-			if (!client_tuner || !client_tuner->dev.driver) {
+			client_tuner = i2c_new_client_device(&i2c_bus2->i2c_adap, &info);
+			if (!i2c_client_has_driver(client_tuner)) {
 				module_put(client_demod->dev.driver->owner);
 				i2c_unregister_device(client_demod);
 				port->i2c_client_demod = NULL;
@@ -2340,8 +2334,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x64;
 			info.platform_data = &si2168_config;
 			request_module("%s", info.type);
-			client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
-			if (!client_demod || !client_demod->dev.driver)
+			client_demod = i2c_new_client_device(&dev->i2c_bus[0].i2c_adap, &info);
+			if (!i2c_client_has_driver(client_demod))
 				goto frontend_detach;
 			if (!try_module_get(client_demod->dev.driver->owner)) {
 				i2c_unregister_device(client_demod);
@@ -2358,8 +2352,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x60;
 			info.platform_data = &si2157_config;
 			request_module("%s", info.type);
-			client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
-			if (!client_tuner || !client_tuner->dev.driver) {
+			client_tuner = i2c_new_client_device(&dev->i2c_bus[1].i2c_adap, &info);
+			if (!i2c_client_has_driver(client_tuner)) {
 				module_put(client_demod->dev.driver->owner);
 				i2c_unregister_device(client_demod);
 				port->i2c_client_demod = NULL;
@@ -2387,8 +2381,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x66;
 			info.platform_data = &si2168_config;
 			request_module("%s", info.type);
-			client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
-			if (!client_demod || !client_demod->dev.driver)
+			client_demod = i2c_new_client_device(&dev->i2c_bus[0].i2c_adap, &info);
+			if (!i2c_client_has_driver(client_demod))
 				goto frontend_detach;
 			if (!try_module_get(client_demod->dev.driver->owner)) {
 				i2c_unregister_device(client_demod);
@@ -2405,8 +2399,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x62;
 			info.platform_data = &si2157_config;
 			request_module("%s", info.type);
-			client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
-			if (!client_tuner || !client_tuner->dev.driver) {
+			client_tuner = i2c_new_client_device(&dev->i2c_bus[1].i2c_adap, &info);
+			if (!i2c_client_has_driver(client_tuner)) {
 				module_put(client_demod->dev.driver->owner);
 				i2c_unregister_device(client_demod);
 				port->i2c_client_demod = NULL;
@@ -2447,8 +2441,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x60;
 			info.platform_data = &si2157_config;
 			request_module("%s", info.type);
-			client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
-			if (!client_tuner || !client_tuner->dev.driver) {
+			client_tuner = i2c_new_client_device(&dev->i2c_bus[1].i2c_adap, &info);
+			if (!i2c_client_has_driver(client_tuner)) {
 				module_put(client_demod->dev.driver->owner);
 				i2c_unregister_device(client_demod);
 				port->i2c_client_demod = NULL;
@@ -2483,8 +2477,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x62;
 			info.platform_data = &si2157_config;
 			request_module("%s", info.type);
-			client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
-			if (!client_tuner || !client_tuner->dev.driver) {
+			client_tuner = i2c_new_client_device(&dev->i2c_bus[1].i2c_adap, &info);
+			if (!i2c_client_has_driver(client_tuner)) {
 				module_put(client_demod->dev.driver->owner);
 				i2c_unregister_device(client_demod);
 				port->i2c_client_demod = NULL;
@@ -2523,8 +2517,8 @@ static int dvb_register(struct cx23885_tsport *port)
 			info.addr = 0x60;
 			info.platform_data = &si2157_config;
 			request_module("%s", info.type);
-			client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
-			if (!client_tuner || !client_tuner->dev.driver)
+			client_tuner = i2c_new_client_device(&dev->i2c_bus[1].i2c_adap, &info);
+			if (!i2c_client_has_driver(client_tuner))
 				goto frontend_detach;
 
 			if (!try_module_get(client_tuner->dev.driver->owner)) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 08/17] media: pci: saa7164: saa7164-dvb: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (6 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 07/17] media: pci: cx23885: cx23885-dvb: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 09/17] media: pci: smipcie: smipcie-main: " Wolfram Sang
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Mauro Carvalho Chehab, linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/pci/saa7164/saa7164-dvb.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/media/pci/saa7164/saa7164-dvb.c b/drivers/media/pci/saa7164/saa7164-dvb.c
index 05ab4734ea67..6a527dbc1daf 100644
--- a/drivers/media/pci/saa7164/saa7164-dvb.c
+++ b/drivers/media/pci/saa7164/saa7164-dvb.c
@@ -116,8 +116,8 @@ static int si2157_attach(struct saa7164_port *port, struct i2c_adapter *adapter,
 
 	request_module(bi.type);
 
-	tuner = i2c_new_device(adapter, &bi);
-	if (tuner == NULL || tuner->dev.driver == NULL)
+	tuner = i2c_new_client_device(adapter, &bi);
+	if (!i2c_client_has_driver(tuner))
 		return -ENODEV;
 
 	if (!try_module_get(tuner->dev.driver->owner)) {
@@ -637,9 +637,9 @@ int saa7164_dvb_register(struct saa7164_port *port)
 			info.addr = 0xc8 >> 1;
 			info.platform_data = &si2168_config;
 			request_module(info.type);
-			client_demod = i2c_new_device(&dev->i2c_bus[2].i2c_adap,
+			client_demod = i2c_new_client_device(&dev->i2c_bus[2].i2c_adap,
 						      &info);
-			if (!client_demod || !client_demod->dev.driver)
+			if (!i2c_client_has_driver(client_demod))
 				goto frontend_detach;
 
 			if (!try_module_get(client_demod->dev.driver->owner)) {
@@ -657,9 +657,9 @@ int saa7164_dvb_register(struct saa7164_port *port)
 			info.addr = 0xc0 >> 1;
 			info.platform_data = &si2157_config;
 			request_module(info.type);
-			client_tuner = i2c_new_device(&dev->i2c_bus[0].i2c_adap,
+			client_tuner = i2c_new_client_device(&dev->i2c_bus[0].i2c_adap,
 						      &info);
-			if (!client_tuner || !client_tuner->dev.driver) {
+			if (!i2c_client_has_driver(client_tuner)) {
 				module_put(client_demod->dev.driver->owner);
 				i2c_unregister_device(client_demod);
 				goto frontend_detach;
@@ -682,9 +682,9 @@ int saa7164_dvb_register(struct saa7164_port *port)
 			info.addr = 0xcc >> 1;
 			info.platform_data = &si2168_config;
 			request_module(info.type);
-			client_demod = i2c_new_device(&dev->i2c_bus[2].i2c_adap,
+			client_demod = i2c_new_client_device(&dev->i2c_bus[2].i2c_adap,
 						      &info);
-			if (!client_demod || !client_demod->dev.driver)
+			if (!i2c_client_has_driver(client_demod))
 				goto frontend_detach;
 
 			if (!try_module_get(client_demod->dev.driver->owner)) {
@@ -702,9 +702,9 @@ int saa7164_dvb_register(struct saa7164_port *port)
 			info.addr = 0xc0 >> 1;
 			info.platform_data = &si2157_config;
 			request_module(info.type);
-			client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap,
+			client_tuner = i2c_new_client_device(&dev->i2c_bus[1].i2c_adap,
 						      &info);
-			if (!client_tuner || !client_tuner->dev.driver) {
+			if (!i2c_client_has_driver(client_tuner)) {
 				module_put(client_demod->dev.driver->owner);
 				i2c_unregister_device(client_demod);
 				goto frontend_detach;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 09/17] media: pci: smipcie: smipcie-main: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (7 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 08/17] media: pci: saa7164: saa7164-dvb: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 10/17] media: platform: sti: c8sectpfe: c8sectpfe-dvb: " Wolfram Sang
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Mauro Carvalho Chehab, linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/pci/smipcie/smipcie-main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/smipcie/smipcie-main.c b/drivers/media/pci/smipcie/smipcie-main.c
index 1fb78462e081..9ca0fc3e6f80 100644
--- a/drivers/media/pci/smipcie/smipcie-main.c
+++ b/drivers/media/pci/smipcie/smipcie-main.c
@@ -484,8 +484,8 @@ static struct i2c_client *smi_add_i2c_client(struct i2c_adapter *adapter,
 	struct i2c_client *client;
 
 	request_module(info->type);
-	client = i2c_new_device(adapter, info);
-	if (client == NULL || client->dev.driver == NULL)
+	client = i2c_new_client_device(adapter, info);
+	if (!i2c_client_has_driver(client))
 		goto err_add_i2c_client;
 
 	if (!try_module_get(client->dev.driver->owner)) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 10/17] media: platform: sti: c8sectpfe: c8sectpfe-dvb: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (8 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 09/17] media: pci: smipcie: smipcie-main: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-07  9:59   ` Patrice CHOTARD
  2019-11-06 21:21 ` [PATCH 11/17] media: usb: dvb-usb-v2: af9035: " Wolfram Sang
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media
  Cc: linux-i2c, Wolfram Sang, Patrice Chotard, Mauro Carvalho Chehab,
	linux-arm-kernel, linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
index a79250a7f812..103872266565 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
@@ -170,8 +170,8 @@ int c8sectpfe_frontend_attach(struct dvb_frontend **fe,
 
 		/* attach tuner */
 		request_module("tda18212");
-		client = i2c_new_device(tsin->i2c_adapter, &tda18212_info);
-		if (!client || !client->dev.driver) {
+		client = i2c_new_client_device(tsin->i2c_adapter, &tda18212_info);
+		if (!i2c_client_has_driver(client)) {
 			dvb_frontend_detach(*fe);
 			return -ENODEV;
 		}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 11/17] media: usb: dvb-usb-v2: af9035: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (9 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 10/17] media: platform: sti: c8sectpfe: c8sectpfe-dvb: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 12/17] media: usb: dvb-usb-v2: anysee: " Wolfram Sang
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media
  Cc: linux-i2c, Wolfram Sang, Antti Palosaari, Mauro Carvalho Chehab,
	linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 792667ee5ebc..2db286d88fa5 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -208,8 +208,8 @@ static int af9035_add_i2c_dev(struct dvb_usb_device *d, const char *type,
 	request_module("%s", board_info.type);
 
 	/* register I2C device */
-	client = i2c_new_device(adapter, &board_info);
-	if (client == NULL || client->dev.driver == NULL) {
+	client = i2c_new_client_device(adapter, &board_info);
+	if (!i2c_client_has_driver(client)) {
 		ret = -ENODEV;
 		goto err;
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 12/17] media: usb: dvb-usb-v2: anysee: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (10 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 11/17] media: usb: dvb-usb-v2: af9035: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 13/17] media: usb: dvb-usb-v2: rtl28xxu: " Wolfram Sang
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media
  Cc: linux-i2c, Wolfram Sang, Antti Palosaari, Mauro Carvalho Chehab,
	linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/usb/dvb-usb-v2/anysee.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c b/drivers/media/usb/dvb-usb-v2/anysee.c
index fb6d99dea31a..0514e87405b6 100644
--- a/drivers/media/usb/dvb-usb-v2/anysee.c
+++ b/drivers/media/usb/dvb-usb-v2/anysee.c
@@ -649,8 +649,8 @@ static int anysee_add_i2c_dev(struct dvb_usb_device *d, const char *type,
 	request_module("%s", board_info.type);
 
 	/* register I2C device */
-	client = i2c_new_device(adapter, &board_info);
-	if (client == NULL || client->dev.driver == NULL) {
+	client = i2c_new_client_device(adapter, &board_info);
+	if (!i2c_client_has_driver(client)) {
 		ret = -ENODEV;
 		goto err;
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 13/17] media: usb: dvb-usb-v2: rtl28xxu: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (11 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 12/17] media: usb: dvb-usb-v2: anysee: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 14/17] media: usb: dvb-usb-v2: zd1301: " Wolfram Sang
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media
  Cc: linux-i2c, Wolfram Sang, Antti Palosaari, Mauro Carvalho Chehab,
	linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 36 ++++++++++++-------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 5016ede7b35f..3a4eb992024a 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -697,8 +697,8 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap)
 	board_info.addr = 0x10;
 	board_info.platform_data = pdata;
 	request_module("%s", board_info.type);
-	client = i2c_new_device(&d->i2c_adap, &board_info);
-	if (client == NULL || client->dev.driver == NULL) {
+	client = i2c_new_client_device(&d->i2c_adap, &board_info);
+	if (!i2c_client_has_driver(client)) {
 		ret = -ENODEV;
 		goto err;
 	}
@@ -918,8 +918,8 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 	board_info.addr = 0x10;
 	board_info.platform_data = pdata;
 	request_module("%s", board_info.type);
-	client = i2c_new_device(&d->i2c_adap, &board_info);
-	if (client == NULL || client->dev.driver == NULL) {
+	client = i2c_new_client_device(&d->i2c_adap, &board_info);
+	if (!i2c_client_has_driver(client)) {
 		ret = -ENODEV;
 		goto err;
 	}
@@ -960,8 +960,8 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			info.addr = 0x18;
 			info.platform_data = &mn88472_config;
 			request_module(info.type);
-			client = i2c_new_device(&d->i2c_adap, &info);
-			if (client == NULL || client->dev.driver == NULL) {
+			client = i2c_new_client_device(&d->i2c_adap, &info);
+			if (!i2c_client_has_driver(client)) {
 				dev->slave_demod = SLAVE_DEMOD_NONE;
 				goto err_slave_demod_failed;
 			}
@@ -982,8 +982,8 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			info.addr = 0x18;
 			info.platform_data = &mn88473_config;
 			request_module(info.type);
-			client = i2c_new_device(&d->i2c_adap, &info);
-			if (client == NULL || client->dev.driver == NULL) {
+			client = i2c_new_client_device(&d->i2c_adap, &info);
+			if (!i2c_client_has_driver(client)) {
 				dev->slave_demod = SLAVE_DEMOD_NONE;
 				goto err_slave_demod_failed;
 			}
@@ -1025,8 +1025,8 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			info.addr = 0x64;
 			info.platform_data = &si2168_config;
 			request_module(info.type);
-			client = i2c_new_device(&d->i2c_adap, &info);
-			if (client == NULL || client->dev.driver == NULL) {
+			client = i2c_new_client_device(&d->i2c_adap, &info);
+			if (!i2c_client_has_driver(client)) {
 				dev->slave_demod = SLAVE_DEMOD_NONE;
 				goto err_slave_demod_failed;
 			}
@@ -1217,8 +1217,8 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 			info.platform_data = &e4000_config;
 
 			request_module(info.type);
-			client = i2c_new_device(dev->demod_i2c_adapter, &info);
-			if (client == NULL || client->dev.driver == NULL)
+			client = i2c_new_client_device(dev->demod_i2c_adapter, &info);
+			if (!i2c_client_has_driver(client))
 				break;
 
 			if (!try_module_get(client->dev.driver->owner)) {
@@ -1240,9 +1240,9 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 			board_info.addr = 0x56;
 			board_info.platform_data = &fc2580_pdata;
 			request_module("fc2580");
-			client = i2c_new_device(dev->demod_i2c_adapter,
+			client = i2c_new_client_device(dev->demod_i2c_adapter,
 						&board_info);
-			if (client == NULL || client->dev.driver == NULL)
+			if (!i2c_client_has_driver(client))
 				break;
 			if (!try_module_get(client->dev.driver->owner)) {
 				i2c_unregister_device(client);
@@ -1271,8 +1271,8 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 		board_info.addr = 0x60;
 		board_info.platform_data = &tua9001_pdata;
 		request_module("tua9001");
-		client = i2c_new_device(dev->demod_i2c_adapter, &board_info);
-		if (client == NULL || client->dev.driver == NULL)
+		client = i2c_new_client_device(dev->demod_i2c_adapter, &board_info);
+		if (!i2c_client_has_driver(client))
 			break;
 		if (!try_module_get(client->dev.driver->owner)) {
 			i2c_unregister_device(client);
@@ -1316,8 +1316,8 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 			info.addr = 0x60;
 			info.platform_data = &si2157_config;
 			request_module(info.type);
-			client = i2c_new_device(&d->i2c_adap, &info);
-			if (client == NULL || client->dev.driver == NULL)
+			client = i2c_new_client_device(&d->i2c_adap, &info);
+			if (!i2c_client_has_driver(client))
 				break;
 
 			if (!try_module_get(client->dev.driver->owner)) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 14/17] media: usb: dvb-usb-v2: zd1301: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (12 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 13/17] media: usb: dvb-usb-v2: rtl28xxu: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 15/17] media: usb: dvb-usb: dib0700_devices: " Wolfram Sang
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media
  Cc: linux-i2c, Wolfram Sang, Antti Palosaari, Mauro Carvalho Chehab,
	linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/usb/dvb-usb-v2/zd1301.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/zd1301.c b/drivers/media/usb/dvb-usb-v2/zd1301.c
index 63b66b207b64..ba2c1b0d3989 100644
--- a/drivers/media/usb/dvb-usb-v2/zd1301.c
+++ b/drivers/media/usb/dvb-usb-v2/zd1301.c
@@ -172,8 +172,8 @@ static int zd1301_frontend_attach(struct dvb_usb_adapter *adap)
 	board_info.addr = 0x60;
 	board_info.platform_data = &dev->mt2060_pdata;
 	request_module("%s", "mt2060");
-	client = i2c_new_device(adapter, &board_info);
-	if (!client || !client->dev.driver) {
+	client = i2c_new_client_device(adapter, &board_info);
+	if (!i2c_client_has_driver(client)) {
 		ret = -ENODEV;
 		goto err_module_put_demod;
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 15/17] media: usb: dvb-usb: dib0700_devices: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (13 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 14/17] media: usb: dvb-usb-v2: zd1301: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 16/17] media: usb: dvb-usb: dw2102: " Wolfram Sang
  2019-11-06 21:21 ` [PATCH 17/17] media: v4l2-core: v4l2-i2c: " Wolfram Sang
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Mauro Carvalho Chehab, linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/usb/dvb-usb/dib0700_devices.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index ab7a100ec84f..4ef3fa98d20f 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -3772,8 +3772,8 @@ static int xbox_one_attach(struct dvb_usb_adapter *adap)
 	info.addr = 0x18;
 	info.platform_data = &mn88472_config;
 	request_module(info.type);
-	client_demod = i2c_new_device(&d->i2c_adap, &info);
-	if (client_demod == NULL || client_demod->dev.driver == NULL)
+	client_demod = i2c_new_client_device(&d->i2c_adap, &info);
+	if (!i2c_client_has_driver(client_demod))
 		goto fail_demod_device;
 	if (!try_module_get(client_demod->dev.driver->owner))
 		goto fail_demod_module;
@@ -3800,8 +3800,8 @@ static int xbox_one_attach(struct dvb_usb_adapter *adap)
 	info.platform_data = &tda18250_config;
 
 	request_module(info.type);
-	client_tuner = i2c_new_device(&adap->dev->i2c_adap, &info);
-	if (client_tuner == NULL || client_tuner->dev.driver == NULL)
+	client_tuner = i2c_new_client_device(&adap->dev->i2c_adap, &info);
+	if (!i2c_client_has_driver(client_tuner))
 		goto fail_tuner_device;
 	if (!try_module_get(client_tuner->dev.driver->owner))
 		goto fail_tuner_module;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 16/17] media: usb: dvb-usb: dw2102: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (14 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 15/17] media: usb: dvb-usb: dib0700_devices: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  2019-11-06 21:21 ` [PATCH 17/17] media: v4l2-core: v4l2-i2c: " Wolfram Sang
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Mauro Carvalho Chehab, linux-kernel

Use the newer API returning an ERRPTR and use the new helper to bail
out.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/usb/dvb-usb/dw2102.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
index b960abd00d48..8b584507dd59 100644
--- a/drivers/media/usb/dvb-usb/dw2102.c
+++ b/drivers/media/usb/dvb-usb/dw2102.c
@@ -1590,8 +1590,8 @@ static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap)
 	board_info.addr = 0x68;
 	board_info.platform_data = &m88ds3103_pdata;
 	request_module("m88ds3103");
-	client = i2c_new_device(&d->i2c_adap, &board_info);
-	if (client == NULL || client->dev.driver == NULL)
+	client = i2c_new_client_device(&d->i2c_adap, &board_info);
+	if (!i2c_client_has_driver(client))
 		return -ENODEV;
 	if (!try_module_get(client->dev.driver->owner)) {
 		i2c_unregister_device(client);
@@ -1609,9 +1609,9 @@ static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap)
 	board_info.addr = 0x60;
 	board_info.platform_data = &ts2020_config;
 	request_module("ts2020");
-	client = i2c_new_device(i2c_adapter, &board_info);
+	client = i2c_new_client_device(i2c_adapter, &board_info);
 
-	if (client == NULL || client->dev.driver == NULL) {
+	if (!i2c_client_has_driver(client)) {
 		dvb_frontend_detach(adap->fe_adap[0].fe);
 		return -ENODEV;
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 17/17] media: v4l2-core: v4l2-i2c: convert to use i2c_new_client_device()
  2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
                   ` (15 preceding siblings ...)
  2019-11-06 21:21 ` [PATCH 16/17] media: usb: dvb-usb: dw2102: " Wolfram Sang
@ 2019-11-06 21:21 ` Wolfram Sang
  16 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-11-06 21:21 UTC (permalink / raw)
  To: linux-media; +Cc: linux-i2c, Wolfram Sang, Mauro Carvalho Chehab, linux-kernel

Use the new helper to bail out. It is more readable and in preparation
for another conversion.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/v4l2-core/v4l2-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-i2c.c b/drivers/media/v4l2-core/v4l2-i2c.c
index 5bf99e7c0c09..d85f5b1f5509 100644
--- a/drivers/media/v4l2-core/v4l2-i2c.c
+++ b/drivers/media/v4l2-core/v4l2-i2c.c
@@ -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 (!i2c_client_has_driver(client))
 		goto error;
 
 	/* Lock the module so we can safely get the v4l2_subdev pointer */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 10/17] media: platform: sti: c8sectpfe: c8sectpfe-dvb: convert to use i2c_new_client_device()
  2019-11-06 21:21 ` [PATCH 10/17] media: platform: sti: c8sectpfe: c8sectpfe-dvb: " Wolfram Sang
@ 2019-11-07  9:59   ` Patrice CHOTARD
  0 siblings, 0 replies; 20+ messages in thread
From: Patrice CHOTARD @ 2019-11-07  9:59 UTC (permalink / raw)
  To: Wolfram Sang, linux-media
  Cc: linux-i2c, Mauro Carvalho Chehab, linux-arm-kernel, linux-kernel

Hi

On 11/6/19 10:21 PM, Wolfram Sang wrote:
> Use the newer API returning an ERRPTR and use the new helper to bail
> out.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
> index a79250a7f812..103872266565 100644
> --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
> +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
> @@ -170,8 +170,8 @@ int c8sectpfe_frontend_attach(struct dvb_frontend **fe,
>  
>  		/* attach tuner */
>  		request_module("tda18212");
> -		client = i2c_new_device(tsin->i2c_adapter, &tda18212_info);
> -		if (!client || !client->dev.driver) {
> +		client = i2c_new_client_device(tsin->i2c_adapter, &tda18212_info);
> +		if (!i2c_client_has_driver(client)) {
>  			dvb_frontend_detach(*fe);
>  			return -ENODEV;
>  		}

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>


Thanks

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 01/17] i2c: add helper to check if a client has a driver attached
  2019-11-06 21:21 ` [PATCH 01/17] i2c: add helper to check if a client has a driver attached Wolfram Sang
@ 2019-12-11  7:59   ` Wolfram Sang
  0 siblings, 0 replies; 20+ messages in thread
From: Wolfram Sang @ 2019-12-11  7:59 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-media, linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

On Wed, Nov 06, 2019 at 10:21:01PM +0100, Wolfram Sang wrote:
> Factoring out something used in the media subsystem. As an improvement,
> it bails out on both, NULL and ERRPTR.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

I picked it up myself now, so we can start using it right away.

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-12-11  7:59 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 21:21 [PATCH 00/17] media: use new API for creating client devices Wolfram Sang
2019-11-06 21:21 ` [PATCH 01/17] i2c: add helper to check if a client has a driver attached Wolfram Sang
2019-12-11  7:59   ` Wolfram Sang
2019-11-06 21:21 ` [PATCH 02/17] media: dvb-core: dvbdev: convert to use i2c_new_client_device() Wolfram Sang
2019-11-06 21:21 ` [PATCH 03/17] media: dvb-frontends: cxd2820r_core: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 04/17] media: dvb-frontends: lgdt330x: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 05/17] media: dvb-frontends: m88ds3103: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 06/17] media: dvb-frontends: ts2020: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 07/17] media: pci: cx23885: cx23885-dvb: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 08/17] media: pci: saa7164: saa7164-dvb: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 09/17] media: pci: smipcie: smipcie-main: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 10/17] media: platform: sti: c8sectpfe: c8sectpfe-dvb: " Wolfram Sang
2019-11-07  9:59   ` Patrice CHOTARD
2019-11-06 21:21 ` [PATCH 11/17] media: usb: dvb-usb-v2: af9035: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 12/17] media: usb: dvb-usb-v2: anysee: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 13/17] media: usb: dvb-usb-v2: rtl28xxu: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 14/17] media: usb: dvb-usb-v2: zd1301: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 15/17] media: usb: dvb-usb: dib0700_devices: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 16/17] media: usb: dvb-usb: dw2102: " Wolfram Sang
2019-11-06 21:21 ` [PATCH 17/17] media: v4l2-core: v4l2-i2c: " Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).