Commit cddcc40b authored by Peter Rosin's avatar Peter Rosin Committed by Wolfram Sang

[media] rtl2832: convert to use an explicit i2c mux core

Allocate an explicit i2c mux core to handle parent and child adapters
etc. Update the select/deselect ops to be in terms of the i2c mux core
instead of the child adapter.
Tested-by: default avatarAntti Palosaari <crope@iki.fi>
Reviewed-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent a0119159
...@@ -847,9 +847,9 @@ static void rtl2832_i2c_gate_work(struct work_struct *work) ...@@ -847,9 +847,9 @@ static void rtl2832_i2c_gate_work(struct work_struct *work)
dev_dbg(&client->dev, "failed=%d\n", ret); dev_dbg(&client->dev, "failed=%d\n", ret);
} }
static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) static int rtl2832_select(struct i2c_mux_core *muxc, u32 chan_id)
{ {
struct rtl2832_dev *dev = mux_priv; struct rtl2832_dev *dev = i2c_mux_priv(muxc);
struct i2c_client *client = dev->client; struct i2c_client *client = dev->client;
int ret; int ret;
...@@ -870,10 +870,9 @@ static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) ...@@ -870,10 +870,9 @@ static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id)
return ret; return ret;
} }
static int rtl2832_deselect(struct i2c_adapter *adap, void *mux_priv, static int rtl2832_deselect(struct i2c_mux_core *muxc, u32 chan_id)
u32 chan_id)
{ {
struct rtl2832_dev *dev = mux_priv; struct rtl2832_dev *dev = i2c_mux_priv(muxc);
schedule_delayed_work(&dev->i2c_gate_work, usecs_to_jiffies(100)); schedule_delayed_work(&dev->i2c_gate_work, usecs_to_jiffies(100));
return 0; return 0;
...@@ -1059,7 +1058,7 @@ static struct i2c_adapter *rtl2832_get_i2c_adapter(struct i2c_client *client) ...@@ -1059,7 +1058,7 @@ static struct i2c_adapter *rtl2832_get_i2c_adapter(struct i2c_client *client)
struct rtl2832_dev *dev = i2c_get_clientdata(client); struct rtl2832_dev *dev = i2c_get_clientdata(client);
dev_dbg(&client->dev, "\n"); dev_dbg(&client->dev, "\n");
return dev->i2c_adapter_tuner; return dev->muxc->adapter[0];
} }
static int rtl2832_slave_ts_ctrl(struct i2c_client *client, bool enable) static int rtl2832_slave_ts_ctrl(struct i2c_client *client, bool enable)
...@@ -1242,12 +1241,16 @@ static int rtl2832_probe(struct i2c_client *client, ...@@ -1242,12 +1241,16 @@ static int rtl2832_probe(struct i2c_client *client,
goto err_regmap_exit; goto err_regmap_exit;
/* create muxed i2c adapter for demod tuner bus */ /* create muxed i2c adapter for demod tuner bus */
dev->i2c_adapter_tuner = i2c_add_mux_adapter(i2c, &i2c->dev, dev, dev->muxc = i2c_mux_alloc(i2c, &i2c->dev, 1, 0, 0,
0, 0, 0, rtl2832_select, rtl2832_deselect); rtl2832_select, rtl2832_deselect);
if (dev->i2c_adapter_tuner == NULL) { if (!dev->muxc) {
ret = -ENODEV; ret = -ENOMEM;
goto err_regmap_exit; goto err_regmap_exit;
} }
dev->muxc->priv = dev;
ret = i2c_mux_add_adapter(dev->muxc, 0, 0, 0);
if (ret)
goto err_regmap_exit;
/* create dvb_frontend */ /* create dvb_frontend */
memcpy(&dev->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops)); memcpy(&dev->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops));
...@@ -1282,7 +1285,7 @@ static int rtl2832_remove(struct i2c_client *client) ...@@ -1282,7 +1285,7 @@ static int rtl2832_remove(struct i2c_client *client)
cancel_delayed_work_sync(&dev->i2c_gate_work); cancel_delayed_work_sync(&dev->i2c_gate_work);
i2c_del_mux_adapter(dev->i2c_adapter_tuner); i2c_mux_del_adapters(dev->muxc);
regmap_exit(dev->regmap); regmap_exit(dev->regmap);
......
...@@ -36,7 +36,7 @@ struct rtl2832_dev { ...@@ -36,7 +36,7 @@ struct rtl2832_dev {
struct mutex regmap_mutex; struct mutex regmap_mutex;
struct regmap_config regmap_config; struct regmap_config regmap_config;
struct regmap *regmap; struct regmap *regmap;
struct i2c_adapter *i2c_adapter_tuner; struct i2c_mux_core *muxc;
struct dvb_frontend fe; struct dvb_frontend fe;
enum fe_status fe_status; enum fe_status fe_status;
u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */ u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment