* [PATCH v3] i2c-mux-gpio: Check gpio_direction_output return value
@ 2013-03-07 8:35 Jean Delvare
[not found] ` <20130307093553.4bc1595f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Jean Delvare @ 2013-03-07 8:35 UTC (permalink / raw)
To: Peter Korsgaard; +Cc: Wolfram Sang, Linux I2C
gpio_direction_output() may fail, check for that and deal with it
appropriately. Also log an error message if gpio_request() fails.
Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Peter Korsgaard <peter.korsgaard-ob4gmnvZ1/cAvxtiuMwx3w@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
---
Changes since v2:
* Refreshed so that it applies on top of the most recent version of
the driver.
drivers/i2c/muxes/i2c-mux-gpio.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
--- linux-3.8.orig/drivers/i2c/muxes/i2c-mux-gpio.c 2013-03-07 09:06:31.431159507 +0100
+++ linux-3.8/drivers/i2c/muxes/i2c-mux-gpio.c 2013-03-07 09:07:02.739878467 +0100
@@ -201,10 +201,21 @@ static int i2c_mux_gpio_probe(struct pla
for (i = 0; i < mux->data.n_gpios; i++) {
ret = gpio_request(gpio_base + mux->data.gpios[i], "i2c-mux-gpio");
- if (ret)
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to request GPIO %d\n",
+ mux->data.gpios[i]);
goto err_request_gpio;
- gpio_direction_output(gpio_base + mux->data.gpios[i],
- initial_state & (1 << i));
+ }
+
+ ret = gpio_direction_output(gpio_base + mux->data.gpios[i],
+ initial_state & (1 << i));
+ if (ret) {
+ dev_err(&pdev->dev,
+ "Failed to set direction of GPIO %d to output\n",
+ mux->data.gpios[i]);
+ i++; /* gpio_request above succeeded, so must free */
+ goto err_request_gpio;
+ }
}
for (i = 0; i < mux->data.n_values; i++) {
--
Jean Delvare
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] i2c-mux-gpio: Check gpio_direction_output return value
[not found] ` <20130307093553.4bc1595f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2013-03-07 8:45 ` Peter Korsgaard
2013-03-27 8:22 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2013-03-07 8:45 UTC (permalink / raw)
To: Jean Delvare; +Cc: Wolfram Sang, Linux I2C
>>>>> "JD" == Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> writes:
JD> gpio_direction_output() may fail, check for that and deal with it
JD> appropriately. Also log an error message if gpio_request() fails.
JD> Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
JD> Cc: Peter Korsgaard <peter.korsgaard-ob4gmnvZ1/cAvxtiuMwx3w@public.gmane.org>
JD> Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
Acked-by: Peter Korsgaard <peter.korsgaard-ob4gmnvZ1/cAvxtiuMwx3w@public.gmane.org>
--
Sorry about disclaimer - It's out of my control.
Bye, Peter Korsgaard
DISCLAIMER:
Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] i2c-mux-gpio: Check gpio_direction_output return value
[not found] ` <20130307093553.4bc1595f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-03-07 8:45 ` Peter Korsgaard
@ 2013-03-27 8:22 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2013-03-27 8:22 UTC (permalink / raw)
To: Jean Delvare; +Cc: Peter Korsgaard, Linux I2C
On Thu, Mar 07, 2013 at 09:35:53AM +0100, Jean Delvare wrote:
> gpio_direction_output() may fail, check for that and deal with it
> appropriately. Also log an error message if gpio_request() fails.
>
> Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Applied to for-next, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-27 8:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-07 8:35 [PATCH v3] i2c-mux-gpio: Check gpio_direction_output return value Jean Delvare
[not found] ` <20130307093553.4bc1595f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-03-07 8:45 ` Peter Korsgaard
2013-03-27 8:22 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox