summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Scheller <d.scheller@gmx.net>2018-02-08 22:53:15 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2018-03-06 16:48:59 +0300
commitd19e3a72a6cec187a35aed9abf03fc4730eded76 (patch)
tree72feba78a5eb56ea51d25b98320d9f6af8d0a14f
parent81a705914b77e700ce142892c1f839488200099d (diff)
downloadlinux-d19e3a72a6cec187a35aed9abf03fc4730eded76.tar.xz
media: ngene: adapt cxd2099 attach to the new i2c_client way
Change the way the cxd2099 hardware is being attached to the new I2C client interface way. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Jasmin Jessich <jasmin@anw.at> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/pci/ngene/ngene-core.c41
-rw-r--r--drivers/media/pci/ngene/ngene.h1
2 files changed, 38 insertions, 4 deletions
diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c
index 8c92cb7f7e72..80db777cb7ec 100644
--- a/drivers/media/pci/ngene/ngene-core.c
+++ b/drivers/media/pci/ngene/ngene-core.c
@@ -1562,9 +1562,8 @@ static int init_channels(struct ngene *dev)
return 0;
}
-static struct cxd2099_cfg cxd_cfg = {
+static const struct cxd2099_cfg cxd_cfgtmpl = {
.bitrate = 62000,
- .adr = 0x40,
.polarity = 0,
.clock_mode = 0,
};
@@ -1572,18 +1571,52 @@ static struct cxd2099_cfg cxd_cfg = {
static void cxd_attach(struct ngene *dev)
{
struct ngene_ci *ci = &dev->ci;
+ 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.en = &ci->en;
+
+ request_module(board_info.type);
+
+ client = i2c_new_device(&dev->channel[0].i2c_adapter, &board_info);
+ if (!client || !client->dev.driver)
+ goto err_ret;
+
+ if (!try_module_get(client->dev.driver->owner))
+ goto err_i2c;
+
+ if (!ci->en)
+ goto err_i2c;
- ci->en = cxd2099_attach(&cxd_cfg, dev, &dev->channel[0].i2c_adapter);
ci->dev = dev;
+ dev->channel[0].i2c_client[0] = client;
+ return;
+
+err_i2c:
+ i2c_unregister_device(client);
+err_ret:
+ printk(KERN_ERR DEVICE_NAME ": CXD2099AR attach failed\n");
return;
}
static void cxd_detach(struct ngene *dev)
{
struct ngene_ci *ci = &dev->ci;
+ struct i2c_client *client;
dvb_ca_en50221_release(ci->en);
- kfree(ci->en);
+
+ client = dev->channel[0].i2c_client[0];
+ if (client) {
+ module_put(client->dev.driver->owner);
+ i2c_unregister_device(client);
+ }
+
ci->en = NULL;
}
diff --git a/drivers/media/pci/ngene/ngene.h b/drivers/media/pci/ngene/ngene.h
index 02dbd18f92d0..caf8602c7459 100644
--- a/drivers/media/pci/ngene/ngene.h
+++ b/drivers/media/pci/ngene/ngene.h
@@ -630,6 +630,7 @@ struct ngene_vopen {
struct ngene_channel {
struct device device;
struct i2c_adapter i2c_adapter;
+ struct i2c_client *i2c_client[1];
struct ngene *dev;
int number;