i2c-mux-gpio: Check gpio_direction_output return value
PATCH v3 1/1 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.
---
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(-)
drivers/i2c/muxes/i2c-mux-gpio.c +14 -3
@@ -201,10 +201,21 @@ static int i2c_mux_gpio_probe(struct plafor (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++) {
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
Peter Korsgaard
Acked-byQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"JD" == Jean Delvare <[email protected]> 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 <[email protected]> JD> Cc: Peter Korsgaard <peter.korsgaard-ob4gmnvZ1/[email protected]> JD> Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/[email protected]>
Signature · 6 lines
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.
Wolfram Sang
AppliedQuoted 4 lines · Jean Delvare
gpio_direction_output()may fail, check for that and deal with it appropriately. Also log an error message ifgpio_request()fails.Signed-off-by Jean Delvare <[email protected]>
Applied to for-next, thanks!