Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1349638

[PATCH v4 11/18] [media] rtl2832: convert to use an explicit i2c mux core

From Peter Rosin <peda@lysator.liu.se>
Newsgroups linux.kernel
Subject [PATCH v4 11/18] [media] rtl2832: convert to use an explicit i2c mux core
Date 2016-03-03 23:30 +0100
Message-ID <r8JUT-5sH-27@gated-at.bofh.it> (permalink)
References <r8JUS-5sH-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Peter Rosin <peda@axentia.se>

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.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/media/dvb-frontends/rtl2832.c      | 22 +++++++++++-----------
 drivers/media/dvb-frontends/rtl2832_priv.h |  2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 10f2119935da..775444898599 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -866,9 +866,9 @@ err:
 	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;
 	int ret;
 
@@ -889,10 +889,9 @@ err:
 	return ret;
 }
 
-static int rtl2832_deselect(struct i2c_adapter *adap, void *mux_priv,
-			    u32 chan_id)
+static int rtl2832_deselect(struct i2c_mux_core *muxc, 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));
 	return 0;
@@ -1078,7 +1077,7 @@ static struct i2c_adapter *rtl2832_get_i2c_adapter(struct i2c_client *client)
 	struct rtl2832_dev *dev = i2c_get_clientdata(client);
 
 	dev_dbg(&client->dev, "\n");
-	return dev->i2c_adapter_tuner;
+	return dev->muxc->adapter[0];
 }
 
 static int rtl2832_enable_slave_ts(struct i2c_client *client)
@@ -1253,12 +1252,13 @@ static int rtl2832_probe(struct i2c_client *client,
 		goto err_regmap_exit;
 
 	/* create muxed i2c adapter for demod tuner bus */
-	dev->i2c_adapter_tuner = i2c_add_mux_adapter(i2c, &i2c->dev, dev,
-			0, 0, 0, rtl2832_select, rtl2832_deselect);
-	if (dev->i2c_adapter_tuner == NULL) {
-		ret = -ENODEV;
+	dev->muxc = i2c_mux_one_adapter(i2c, &i2c->dev, 0, 0, 0, 0, 0,
+					rtl2832_select, rtl2832_deselect);
+	if (IS_ERR(dev->muxc)) {
+		ret = PTR_ERR(dev->muxc);
 		goto err_regmap_exit;
 	}
+	dev->muxc->priv = dev;
 
 	/* create dvb_frontend */
 	memcpy(&dev->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops));
@@ -1293,7 +1293,7 @@ static int rtl2832_remove(struct i2c_client *client)
 
 	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);
 
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h b/drivers/media/dvb-frontends/rtl2832_priv.h
index 5dcd3a41d23f..6b3cd23a2c26 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -36,7 +36,7 @@ struct rtl2832_dev {
 	struct mutex regmap_mutex;
 	struct regmap_config regmap_config;
 	struct regmap *regmap;
-	struct i2c_adapter *i2c_adapter_tuner;
+	struct i2c_mux_core *muxc;
 	struct dvb_frontend fe;
 	struct delayed_work stat_work;
 	enum fe_status fe_status;
-- 
2.1.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 00/18] i2c mux cleanup and locking update Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:30 +0100
  [PATCH v4 10/18] [media] rtl2830: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:30 +0100
  [PATCH v4 12/18] [media] si2168: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:30 +0100
  [PATCH v4 05/18] i2c: i2c-mux-pca9541: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:30 +0100
  [PATCH v4 06/18] i2c: i2c-mux-pca954x: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:30 +0100
  [PATCH v4 11/18] [media] rtl2832: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:30 +0100
  [PATCH v4 04/18] i2c: i2c-arb-gpio-challenge: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:30 +0100
  [PATCH v4 02/18] i2c: i2c-mux-gpio: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:30 +0100
  [PATCH v4 03/18] i2c: i2c-mux-pinctrl: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:30 +0100
  [PATCH v4 18/18] i2c-mux: relax locking of the top i2c adapter during i2c controlled muxing Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:40 +0100
    Re: [PATCH v4 18/18] i2c-mux: relax locking of the top i2c adapter  during i2c controlled muxing kbuild test robot <lkp@intel.com> - 2016-03-04 06:30 +0100
    Re: [PATCH v4 18/18] i2c-mux: relax locking of the top i2c adapter  during i2c controlled muxing Peter Rosin <peda@lysator.liu.se> - 2016-03-04 08:20 +0100
  [PATCH v4 15/18] i2c-mux: drop old unused i2c-mux api Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:40 +0100
  [PATCH v4 13/18] [media] cx231xx: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:40 +0100
  [PATCH v4 09/18] [media] m88ds3103: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:40 +0100
  [PATCH v4 16/18] i2c: allow adapter drivers to override the adapter locking Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:40 +0100
    Re: [PATCH v4 16/18] i2c: allow adapter drivers to override the  adapter locking kbuild test robot <lkp@intel.com> - 2016-03-04 07:00 +0100
    Re: [PATCH v4 16/18] i2c: allow adapter drivers to override the adapter  locking Peter Rosin <peda@lysator.liu.se> - 2016-03-04 10:40 +0100
  [PATCH v4 17/18] i2c: muxes always lock the parent adapter Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:40 +0100
  [PATCH v4 14/18] of/unittest: convert to use an explicit i2c mux core Peter Rosin <peda@lysator.liu.se> - 2016-03-03 23:40 +0100
  Re: [PATCH v4 00/18] i2c mux cleanup and locking update Peter Rosin <peda@lysator.liu.se> - 2016-03-04 12:10 +0100
    Re: [PATCH v4 00/18] i2c mux cleanup and locking update Peter Rosin <peda@lysator.liu.se> - 2016-03-04 15:50 +0100
  Re: [PATCH v4 00/18] i2c mux cleanup and locking update Peter Rosin <peda@lysator.liu.se> - 2016-03-15 15:20 +0100
    Re: [PATCH v4 00/18] i2c mux cleanup and locking update Antti Palosaari <crope@iki.fi> - 2016-03-15 18:10 +0100

csiph-web