]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
[media] rtl2830: convert to use an explicit i2c mux core
authorPeter Rosin <peda@axentia.se>
Wed, 20 Apr 2016 06:41:13 +0000 (08:41 +0200)
committerWolfram Sang <wsa@the-dreams.de>
Fri, 22 Apr 2016 13:00:14 +0000 (15:00 +0200)
Allocate an explicit i2c mux core to handle parent and child adapters
etc. Update the select op to be in terms of the i2c mux core instead
of the child adapter.

Tested-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/media/dvb-frontends/rtl2830.c
drivers/media/dvb-frontends/rtl2830_priv.h

index 3f96429af0e59e0de58805754fa59dca27b062a2..d25d1e0cd4ca6459c5190e6b2902dd13335b2b0d 100644 (file)
@@ -677,9 +677,9 @@ err:
  * adapter lock is already taken by tuner driver.
  * Gate is closed automatically after single I2C transfer.
  */
-static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id)
+static int rtl2830_select(struct i2c_mux_core *muxc, u32 chan_id)
 {
-       struct i2c_client *client = mux_priv;
+       struct i2c_client *client = i2c_mux_priv(muxc);
        struct rtl2830_dev *dev = i2c_get_clientdata(client);
        int ret;
 
@@ -712,7 +712,7 @@ static struct i2c_adapter *rtl2830_get_i2c_adapter(struct i2c_client *client)
 
        dev_dbg(&client->dev, "\n");
 
-       return dev->adapter;
+       return dev->muxc->adapter[0];
 }
 
 /*
@@ -865,12 +865,16 @@ static int rtl2830_probe(struct i2c_client *client,
                goto err_regmap_exit;
 
        /* create muxed i2c adapter for tuner */
-       dev->adapter = i2c_add_mux_adapter(client->adapter, &client->dev,
-                       client, 0, 0, 0, rtl2830_select, NULL);
-       if (dev->adapter == NULL) {
-               ret = -ENODEV;
+       dev->muxc = i2c_mux_alloc(client->adapter, &client->dev, 1, 0, 0,
+                                 rtl2830_select, NULL);
+       if (!dev->muxc) {
+               ret = -ENOMEM;
                goto err_regmap_exit;
        }
+       dev->muxc->priv = client;
+       ret = i2c_mux_add_adapter(dev->muxc, 0, 0, 0);
+       if (ret)
+               goto err_regmap_exit;
 
        /* create dvb frontend */
        memcpy(&dev->fe.ops, &rtl2830_ops, sizeof(dev->fe.ops));
@@ -903,7 +907,7 @@ static int rtl2830_remove(struct i2c_client *client)
        /* stop statistics polling */
        cancel_delayed_work_sync(&dev->stat_work);
 
-       i2c_del_mux_adapter(dev->adapter);
+       i2c_mux_del_adapters(dev->muxc);
        regmap_exit(dev->regmap);
        kfree(dev);
 
index cf793f39a09b3980c4acceb5fa61b1a54d8a9975..da4909543da2a25038efedd4a6805a98d15b1ef3 100644 (file)
@@ -29,7 +29,7 @@ struct rtl2830_dev {
        struct rtl2830_platform_data *pdata;
        struct i2c_client *client;
        struct regmap *regmap;
-       struct i2c_adapter *adapter;
+       struct i2c_mux_core *muxc;
        struct dvb_frontend fe;
        bool sleeping;
        unsigned long filters;