From 62ea22c4954f5b147488eefa644d668e843be6f7 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Thu, 19 Apr 2018 22:00:08 +0200 Subject: i2c: mux: gpio: move header to platform_data This header only contains platform_data. Move it to the proper directory. Signed-off-by: Wolfram Sang Acked-by: Peter Korsgaard --- drivers/i2c/muxes/i2c-mux-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/i2c/muxes') diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index 1a9973ede443..15a7cc0459fb 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include -- cgit v1.2.3 From f56f316dcfd7d66406303acf6e51711c071b3c63 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Tue, 17 Apr 2018 16:32:30 +0200 Subject: i2c: mux: ltc4306: switch to using .probe_new Use the new probe style for i2c drivers. Acked-by: Michael Hennerich Signed-off-by: Peter Rosin --- drivers/i2c/muxes/i2c-mux-ltc4306.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/i2c/muxes') diff --git a/drivers/i2c/muxes/i2c-mux-ltc4306.c b/drivers/i2c/muxes/i2c-mux-ltc4306.c index 311b1cced0c0..a9af93259b19 100644 --- a/drivers/i2c/muxes/i2c-mux-ltc4306.c +++ b/drivers/i2c/muxes/i2c-mux-ltc4306.c @@ -206,8 +206,7 @@ static const struct of_device_id ltc4306_of_match[] = { }; MODULE_DEVICE_TABLE(of, ltc4306_of_match); -static int ltc4306_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int ltc4306_probe(struct i2c_client *client) { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); const struct chip_desc *chip; @@ -221,7 +220,7 @@ static int ltc4306_probe(struct i2c_client *client, chip = of_device_get_match_data(&client->dev); if (!chip) - chip = &chips[id->driver_data]; + chip = &chips[i2c_match_id(ltc4306_id, client)->driver_data]; idle_disc = device_property_read_bool(&client->dev, "i2c-mux-idle-disconnect"); @@ -310,7 +309,7 @@ static struct i2c_driver ltc4306_driver = { .name = "ltc4306", .of_match_table = of_match_ptr(ltc4306_of_match), }, - .probe = ltc4306_probe, + .probe_new = ltc4306_probe, .remove = ltc4306_remove, .id_table = ltc4306_id, }; -- cgit v1.2.3 From fca700d6d2190292f34282d50b613a9efb100f70 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Mon, 30 Apr 2018 14:08:42 +0200 Subject: i2c: mux: demux-pinctrl: disable PM user interface The demux device is only a logical device with no children. So, no RuntimePM is needed, let's disable the sysfs interface for it. Signed-off-by: Wolfram Sang Signed-off-by: Peter Rosin --- drivers/i2c/muxes/i2c-demux-pinctrl.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/i2c/muxes') diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c index 33ce032cb701..428de4c97fb2 100644 --- a/drivers/i2c/muxes/i2c-demux-pinctrl.c +++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -254,6 +255,8 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); + pm_runtime_no_callbacks(&pdev->dev); + /* switch to first parent as active master */ i2c_demux_activate_master(priv, 0); -- cgit v1.2.3 From a2f8445d4ca2796283c07d4ba8e78718071de863 Mon Sep 17 00:00:00 2001 From: Mike Looijmans Date: Tue, 1 May 2018 13:42:12 +0200 Subject: i2c: mux: pca954x: force reset on probe if available Instead of just hogging the reset GPIO into deactivated state, activate and then de-activate the reset. This allows for better recovery if the CPU was reset halfway through an I2C transaction for example. Signed-off-by: Mike Looijmans Signed-off-by: Peter Rosin --- drivers/i2c/muxes/i2c-mux-pca954x.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers/i2c/muxes') diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 09bafd3e68fa..fe20b8ec5247 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -36,6 +36,7 @@ */ #include +#include #include #include #include @@ -389,10 +390,16 @@ static int pca954x_probe(struct i2c_client *client, i2c_set_clientdata(client, muxc); data->client = client; - /* Get the mux out of reset if a reset GPIO is specified. */ - gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW); + /* Reset the mux if a reset GPIO is specified. */ + gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(gpio)) return PTR_ERR(gpio); + if (gpio) { + udelay(1); + gpiod_set_value_cansleep(gpio, 0); + /* Give the chip some time to recover. */ + udelay(1); + } match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev); if (match) -- cgit v1.2.3 From b30c08a24caa89b28c84f09f0d1de94e9017cc36 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 1 Feb 2018 17:17:19 +0100 Subject: i2c: mux: reg: failed memory allocation is logged elsewhere Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Reviewed-by: Alexander Sverdlin Signed-off-by: Peter Rosin --- drivers/i2c/muxes/i2c-mux-reg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/i2c/muxes') diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c index c948e5a4cb04..f624ed64a47b 100644 --- a/drivers/i2c/muxes/i2c-mux-reg.c +++ b/drivers/i2c/muxes/i2c-mux-reg.c @@ -127,10 +127,8 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux, values = devm_kzalloc(&pdev->dev, sizeof(*mux->data.values) * mux->data.n_values, GFP_KERNEL); - if (!values) { - dev_err(&pdev->dev, "Cannot allocate values array"); + if (!values) return -ENOMEM; - } for_each_child_of_node(np, child) { of_property_read_u32(child, "reg", values + i); -- cgit v1.2.3 From 5a9dcd81908bb2bc6d8ed22bc4b7eec191024557 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Mon, 21 May 2018 09:29:38 +0200 Subject: i2c: mux: demux-pinctrl: use proper parent device for demux adapter Due to a typo, the wrong parent device was assigned to the newly created demuxing adapter device. It got connected to the demuxing platform device but not to the selected parent I2C adapter device. Fix it to get a proper parent-child relationship of the demuxed busses. Signed-off-by: Wolfram Sang Reviewed-by: Simon Horman Signed-off-by: Peter Rosin --- drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/i2c/muxes') diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c index 428de4c97fb2..035032e20327 100644 --- a/drivers/i2c/muxes/i2c-demux-pinctrl.c +++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c @@ -106,7 +106,7 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne priv->cur_adap.owner = THIS_MODULE; priv->cur_adap.algo = &priv->algo; priv->cur_adap.algo_data = priv; - priv->cur_adap.dev.parent = priv->dev; + priv->cur_adap.dev.parent = &adap->dev; priv->cur_adap.class = adap->class; priv->cur_adap.retries = adap->retries; priv->cur_adap.timeout = adap->timeout; -- cgit v1.2.3 From b10d7a1fd6fcb16f242ffbd87bf0466b337708d6 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 21 May 2018 11:49:08 +0200 Subject: i2c: mux: pca954x: merge calls to of_match_device and of_device_get_match_data Drop call to of_match_device, which is subsumed by the subsequent call to of_device_get_match_data. The code becomes simpler, and a temporary variable can be dropped. The semantic match that makes this change is as follows: (http://coccinelle.lip6.fr/) // @r@ local idexpression match; identifier i; expression x, dev, e, e1; @@ - match@i = of_match_device(x, dev); - if (match) e = of_device_get_match_data(dev); - else e = e1; + e = of_device_get_match_data(dev); + if (!e) e = e1; @@ identifier r.i; @@ - const struct of_device_id *i; ... when != i // Signed-off-by: Julia Lawall Signed-off-by: Peter Rosin --- drivers/i2c/muxes/i2c-mux-pca954x.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/i2c/muxes') diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index fe20b8ec5247..fbc748027087 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -374,7 +374,6 @@ static int pca954x_probe(struct i2c_client *client, int num, force, class; struct i2c_mux_core *muxc; struct pca954x *data; - const struct of_device_id *match; int ret; if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) @@ -401,10 +400,8 @@ static int pca954x_probe(struct i2c_client *client, udelay(1); } - match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev); - if (match) - data->chip = of_device_get_match_data(&client->dev); - else + data->chip = of_device_get_match_data(&client->dev); + if (!data->chip) data->chip = &chips[id->driver_data]; if (data->chip->id.manufacturer_id != I2C_DEVICE_ID_NONE) { -- cgit v1.2.3