backlight: l4f00242t03: fix error handling in l4f00242t03_probe
Error handling fixes: 1. In the case of kzalloc failure, simple return -ENOMEM instead of goto err. ( priv is NULL in this case ) 2. In the case of gpio_request fail for reset_gpio and data_enable_gpio, properly release resources by goto err and err2 respectively. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Alberto Panizzo <maramaopercheseimorto@gmail.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
parent
ee378a5c65
commit
beb0a43f39
1 changed files with 3 additions and 4 deletions
|
@ -125,8 +125,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
|
||||||
|
|
||||||
if (priv == NULL) {
|
if (priv == NULL) {
|
||||||
dev_err(&spi->dev, "No memory for this device.\n");
|
dev_err(&spi->dev, "No memory for this device.\n");
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_set_drvdata(&spi->dev, priv);
|
dev_set_drvdata(&spi->dev, priv);
|
||||||
|
@ -139,7 +138,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&spi->dev,
|
dev_err(&spi->dev,
|
||||||
"Unable to get the lcd l4f00242t03 reset gpio.\n");
|
"Unable to get the lcd l4f00242t03 reset gpio.\n");
|
||||||
return ret;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gpio_direction_output(pdata->reset_gpio, 1);
|
ret = gpio_direction_output(pdata->reset_gpio, 1);
|
||||||
|
@ -151,7 +150,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&spi->dev,
|
dev_err(&spi->dev,
|
||||||
"Unable to get the lcd l4f00242t03 data en gpio.\n");
|
"Unable to get the lcd l4f00242t03 data en gpio.\n");
|
||||||
return ret;
|
goto err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gpio_direction_output(pdata->data_enable_gpio, 0);
|
ret = gpio_direction_output(pdata->data_enable_gpio, 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue