2013-10-08 13:20:37

by Ionut Nicu

[permalink] [raw]
Subject: [PATCH] i2c-mux-gpio: use deferred probing with the device tree

If the i2c-parent bus driver is not loaded, returning
-EINVAL will force people to unload and then reload the
module again to get it working.

Also of_get_named_gpio could return -E_PROBE_DEFER or
another error code. This error should be passed further
instead of being ignored.

Signed-off-by: Ionut Nicu <[email protected]>
---
drivers/i2c/muxes/i2c-mux-gpio.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index 5d4a99b..6370b47 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -66,7 +66,7 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
struct device_node *adapter_np, *child;
struct i2c_adapter *adapter;
unsigned *values, *gpios;
- int i = 0;
+ int i = 0, ret;

if (!np)
return -ENODEV;
@@ -79,7 +79,7 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
adapter = of_find_i2c_adapter_by_node(adapter_np);
if (!adapter) {
dev_err(&pdev->dev, "Cannot find parent bus\n");
- return -ENODEV;
+ return -EPROBE_DEFER;
}
mux->data.parent = i2c_adapter_id(adapter);
put_device(&adapter->dev);
@@ -116,8 +116,12 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
return -ENOMEM;
}

- for (i = 0; i < mux->data.n_gpios; i++)
- gpios[i] = of_get_named_gpio(np, "mux-gpios", i);
+ for (i = 0; i < mux->data.n_gpios; i++) {
+ ret = of_get_named_gpio(np, "mux-gpios", i);
+ if (ret < 0)
+ return ret;
+ gpios[i] = ret;
+ }

mux->data.gpios = gpios;

--
1.7.1


2013-10-08 13:35:06

by Ionut Nicu

[permalink] [raw]
Subject: Re: [PATCH] i2c-mux-gpio: use deferred probing with the device tree

On 08.10.2013 15:30, ext Peter Korsgaard wrote:
>>>>>> "IN" == Ionut Nicu <[email protected]> writes:
>
> IN> If the i2c-parent bus driver is not loaded, returning
> IN> -EINVAL will force people to unload and then reload the
> IN> module again to get it working.
>
> IN> Also of_get_named_gpio could return -E_PROBE_DEFER or
> IN> another error code. This error should be passed further
> IN> instead of being ignored.
>
> Two different fixes, so should be 2 separate patches. Other that that,
> it looks good.
>
> Acked-by: Peter Korsgaard <[email protected]>
>

Right, I will split it into two patches and re-submit.

Thanks!

2013-10-08 13:37:35

by Peter Korsgaard

[permalink] [raw]
Subject: Re: [PATCH] i2c-mux-gpio: use deferred probing with the device tree

>>>>> "IN" == Ionut Nicu <[email protected]> writes:

IN> If the i2c-parent bus driver is not loaded, returning
IN> -EINVAL will force people to unload and then reload the
IN> module again to get it working.

IN> Also of_get_named_gpio could return -E_PROBE_DEFER or
IN> another error code. This error should be passed further
IN> instead of being ignored.

Two different fixes, so should be 2 separate patches. Other that that,
it looks good.

Acked-by: Peter Korsgaard <[email protected]>

--
Sorry about disclaimer - It's out of my control.
Bye, Peter Korsgaard
This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>