summaryrefslogtreecommitdiff
path: root/drivers/media/pci/ddbridge/ddbridge-ci.c
diff options
context:
space:
mode:
authorDaniel Scheller <d.scheller@gmx.net>2018-03-07 15:07:55 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2018-03-08 06:06:51 -0500
commitc966453b1386136e47f7c45a6d3b66f4013f974d (patch)
treebc29de5c5d0dbd836617d87d726d00c141bdb8ec /drivers/media/pci/ddbridge/ddbridge-ci.c
parenta31b86b17681fd2b888b11981222b472541d4a4d (diff)
media: ddbridge: use common DVB I2C client handling helpers
Instead of keeping duplicated I2C client handling construct, make use of the newly introduced dvb_module_*() helpers. This not only keeps things way cleaner and removes the need for duplicated I2C client attach code, but even allows to get rid of some variables that won't help in making things look cleaner anymore. The check on a valid ptr on port->en isn't really needed since the cxd2099 driver will set it at a time where it is going to return successfully from probing. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/pci/ddbridge/ddbridge-ci.c')
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-ci.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c b/drivers/media/pci/ddbridge/ddbridge-ci.c
index 6585ef54ac22..a9dbc4ebf94f 100644
--- a/drivers/media/pci/ddbridge/ddbridge-ci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-ci.c
@@ -324,34 +324,20 @@ static int ci_cxd2099_attach(struct ddb_port *port, u32 bitrate)
{
struct cxd2099_cfg cxd_cfg = cxd_cfgtmpl;
struct i2c_client *client;
- struct i2c_board_info board_info = {
- .type = "cxd2099",
- .addr = 0x40,
- .platform_data = &cxd_cfg,
- };
cxd_cfg.bitrate = bitrate;
cxd_cfg.en = &port->en;
- request_module(board_info.type);
-
- client = i2c_new_device(&port->i2c->adap, &board_info);
- if (!client || !client->dev.driver)
- goto err_ret;
-
- if (!try_module_get(client->dev.driver->owner))
- goto err_i2c;
-
- if (!port->en)
- goto err_i2c;
+ client = dvb_module_probe("cxd2099", NULL, &port->i2c->adap,
+ 0x40, &cxd_cfg);
+ if (!client)
+ goto err;
port->dvb[0].i2c_client[0] = client;
port->en_freedata = 0;
return 0;
-err_i2c:
- i2c_unregister_device(client);
-err_ret:
+err:
dev_err(port->dev->dev, "CXD2099AR attach failed\n");
return -ENODEV;
}
@@ -385,18 +371,13 @@ int ddb_ci_attach(struct ddb_port *port, u32 bitrate)
void ddb_ci_detach(struct ddb_port *port)
{
- struct i2c_client *client;
-
if (port->dvb[0].dev)
dvb_unregister_device(port->dvb[0].dev);
if (port->en) {
dvb_ca_en50221_release(port->en);
- client = port->dvb[0].i2c_client[0];
- if (client) {
- module_put(client->dev.driver->owner);
- i2c_unregister_device(client);
- }
+ dvb_module_release(port->dvb[0].i2c_client[0]);
+ port->dvb[0].i2c_client[0] = NULL;
/* free alloc'ed memory if needed */
if (port->en_freedata)