Message ID | 20130307093553.4bc1595f@endymion.delvare |
---|---|
State | Accepted |
Headers | show |
>>>>> "JD" == Jean Delvare <khali@linux-fr.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@linux-fr.org> JD> Cc: Peter Korsgaard <peter.korsgaard@barco.com> JD> Cc: Wolfram Sang <wsa@the-dreams.de> Acked-by: Peter Korsgaard <peter.korsgaard@barco.com>
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@linux-fr.org> Applied to for-next, thanks! -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
--- 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++) {
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> Cc: Peter Korsgaard <peter.korsgaard@barco.com> Cc: Wolfram Sang <wsa@the-dreams.de> --- 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(-)