summaryrefslogtreecommitdiff
path: root/drivers/i2c/muxes/i2c-mux-gpio.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2013-03-06 22:35:53 (GMT)
committerWolfram Sang <wsa@the-dreams.de>2013-03-27 07:55:13 (GMT)
commit7fafae669a623b003d9d40b75ab31bb9625d5c38 (patch)
treebf64062c90be60a81d06934d31dd15367286ca24 /drivers/i2c/muxes/i2c-mux-gpio.c
parent1b295c839b3931244f37cb52265017b298518f69 (diff)
downloadlinux-fsl-qoriq-7fafae669a623b003d9d40b75ab31bb9625d5c38.tar.xz
i2c: mux: gpio: Check gpio_direction_output return value
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@linux-fr.org> Acked-by: Peter Korsgaard <peter.korsgaard@barco.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/muxes/i2c-mux-gpio.c')
-rw-r--r--drivers/i2c/muxes/i2c-mux-gpio.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index abc2e55a..5a0ce00 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -201,10 +201,21 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev)
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++) {