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


Groups > linux.kernel > #1349633

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

From Peter Rosin <peda@lysator.liu.se>
Newsgroups linux.kernel
Subject [PATCH v4 12/18] [media] si2168: convert to use an explicit i2c mux core
Date 2016-03-03 23:30 +0100
Message-ID <r8JUS-5sH-15@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/si2168.c      | 22 ++++++++++++----------
 drivers/media/dvb-frontends/si2168_priv.h |  2 +-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 821a8f481507..ca455d01c71d 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -615,9 +615,9 @@ static int si2168_get_tune_settings(struct dvb_frontend *fe,
  * We must use unlocked I2C I/O because I2C adapter lock is already taken
  * by the caller (usually tuner driver).
  */
-static int si2168_select(struct i2c_adapter *adap, void *mux_priv, u32 chan)
+static int si2168_select(struct i2c_mux_core *muxc, u32 chan)
 {
-	struct i2c_client *client = mux_priv;
+	struct i2c_client *client = i2c_mux_priv(muxc);
 	int ret;
 	struct si2168_cmd cmd;
 
@@ -635,9 +635,9 @@ err:
 	return ret;
 }
 
-static int si2168_deselect(struct i2c_adapter *adap, void *mux_priv, u32 chan)
+static int si2168_deselect(struct i2c_mux_core *muxc, u32 chan)
 {
-	struct i2c_client *client = mux_priv;
+	struct i2c_client *client = i2c_mux_priv(muxc);
 	int ret;
 	struct si2168_cmd cmd;
 
@@ -709,17 +709,19 @@ static int si2168_probe(struct i2c_client *client,
 	}
 
 	/* create mux i2c adapter for tuner */
-	dev->adapter = i2c_add_mux_adapter(client->adapter, &client->dev,
-			client, 0, 0, 0, si2168_select, si2168_deselect);
-	if (dev->adapter == NULL) {
-		ret = -ENODEV;
+	dev->muxc = i2c_mux_one_adapter(client->adapter, &client->dev, 0, 0,
+					0, 0, 0,
+					si2168_select, si2168_deselect);
+	if (IS_ERR(dev->muxc)) {
+		ret = PTR_ERR(dev->muxc);
 		goto err_kfree;
 	}
+	dev->muxc->priv = client;
 
 	/* create dvb_frontend */
 	memcpy(&dev->fe.ops, &si2168_ops, sizeof(struct dvb_frontend_ops));
 	dev->fe.demodulator_priv = client;
-	*config->i2c_adapter = dev->adapter;
+	*config->i2c_adapter = dev->muxc->adapter[0];
 	*config->fe = &dev->fe;
 	dev->ts_mode = config->ts_mode;
 	dev->ts_clock_inv = config->ts_clock_inv;
@@ -743,7 +745,7 @@ static int si2168_remove(struct i2c_client *client)
 
 	dev_dbg(&client->dev, "\n");
 
-	i2c_del_mux_adapter(dev->adapter);
+	i2c_mux_del_adapters(dev->muxc);
 
 	dev->fe.ops.release = NULL;
 	dev->fe.demodulator_priv = NULL;
diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h
index c07e6fe2cb10..165bf1412063 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -29,7 +29,7 @@
 
 /* state struct */
 struct si2168_dev {
-	struct i2c_adapter *adapter;
+	struct i2c_mux_core *muxc;
 	struct dvb_frontend fe;
 	enum fe_delivery_system delivery_system;
 	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