Commit 7fafae66 authored by Jean Delvare's avatar Jean Delvare Committed by Wolfram Sang

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: default avatarJean Delvare <khali@linux-fr.org>
Acked-by: default avatarPeter Korsgaard <peter.korsgaard@barco.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 1b295c83
...@@ -201,10 +201,21 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) ...@@ -201,10 +201,21 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev)
for (i = 0; i < mux->data.n_gpios; i++) { for (i = 0; i < mux->data.n_gpios; i++) {
ret = gpio_request(gpio_base + mux->data.gpios[i], "i2c-mux-gpio"); 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; goto err_request_gpio;
gpio_direction_output(gpio_base + mux->data.gpios[i], }
ret = gpio_direction_output(gpio_base + mux->data.gpios[i],
initial_state & (1 << 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++) { for (i = 0; i < mux->data.n_values; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment