mirror of https://gitee.com/openkylin/linux.git
regulator: s5m8767: Properly handle gpio_request failure
Convert to devm_gpio_request to save a few error handling code. This patch properly handle the gpio_request failure, we should return error when gpio_request fails rather than just show warning. I think one of the reason we got -EBUSY is because current code does not free gpios in s5m8767_pmic_remove(). So it got -EBUSY when reload the module. Yest another reason is in current code if gpio_request() returns error, the rest of the code still calls gpio_direction_output to config buck_gpios and buck_ds gpios. This looks wrong to me. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
8fa25eda86
commit
5febb3c9d5
|
@ -620,20 +620,21 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
|
||||||
if (gpio_is_valid(pdata->buck_gpios[0]) &&
|
if (gpio_is_valid(pdata->buck_gpios[0]) &&
|
||||||
gpio_is_valid(pdata->buck_gpios[1]) &&
|
gpio_is_valid(pdata->buck_gpios[1]) &&
|
||||||
gpio_is_valid(pdata->buck_gpios[2])) {
|
gpio_is_valid(pdata->buck_gpios[2])) {
|
||||||
ret = gpio_request(pdata->buck_gpios[0], "S5M8767 SET1");
|
ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[0],
|
||||||
if (ret == -EBUSY)
|
"S5M8767 SET1");
|
||||||
dev_warn(&pdev->dev, "Duplicated gpio request"
|
if (ret)
|
||||||
" for SET1\n");
|
return ret;
|
||||||
|
|
||||||
ret = gpio_request(pdata->buck_gpios[1], "S5M8767 SET2");
|
ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[1],
|
||||||
if (ret == -EBUSY)
|
"S5M8767 SET2");
|
||||||
dev_warn(&pdev->dev, "Duplicated gpio request"
|
if (ret)
|
||||||
" for SET2\n");
|
return ret;
|
||||||
|
|
||||||
|
ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[2],
|
||||||
|
"S5M8767 SET3");
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
ret = gpio_request(pdata->buck_gpios[2], "S5M8767 SET3");
|
|
||||||
if (ret == -EBUSY)
|
|
||||||
dev_warn(&pdev->dev, "Duplicated gpio request"
|
|
||||||
" for SET3\n");
|
|
||||||
/* SET1 GPIO */
|
/* SET1 GPIO */
|
||||||
gpio_direction_output(pdata->buck_gpios[0],
|
gpio_direction_output(pdata->buck_gpios[0],
|
||||||
(s5m8767->buck_gpioindex >> 2) & 0x1);
|
(s5m8767->buck_gpioindex >> 2) & 0x1);
|
||||||
|
@ -643,25 +644,23 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
|
||||||
/* SET3 GPIO */
|
/* SET3 GPIO */
|
||||||
gpio_direction_output(pdata->buck_gpios[2],
|
gpio_direction_output(pdata->buck_gpios[2],
|
||||||
(s5m8767->buck_gpioindex >> 0) & 0x1);
|
(s5m8767->buck_gpioindex >> 0) & 0x1);
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dev_err(&pdev->dev, "GPIO NOT VALID\n");
|
dev_err(&pdev->dev, "GPIO NOT VALID\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gpio_request(pdata->buck_ds[0], "S5M8767 DS2");
|
ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[0], "S5M8767 DS2");
|
||||||
if (ret == -EBUSY)
|
if (ret)
|
||||||
dev_warn(&pdev->dev, "Duplicated gpio request for DS2\n");
|
return ret;
|
||||||
|
|
||||||
ret = gpio_request(pdata->buck_ds[1], "S5M8767 DS3");
|
ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[1], "S5M8767 DS3");
|
||||||
if (ret == -EBUSY)
|
if (ret)
|
||||||
dev_warn(&pdev->dev, "Duplicated gpio request for DS3\n");
|
return ret;
|
||||||
|
|
||||||
ret = gpio_request(pdata->buck_ds[2], "S5M8767 DS4");
|
ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[2], "S5M8767 DS4");
|
||||||
if (ret == -EBUSY)
|
if (ret)
|
||||||
dev_warn(&pdev->dev, "Duplicated gpio request for DS4\n");
|
return ret;
|
||||||
|
|
||||||
/* DS2 GPIO */
|
/* DS2 GPIO */
|
||||||
gpio_direction_output(pdata->buck_ds[0], 0x0);
|
gpio_direction_output(pdata->buck_ds[0], 0x0);
|
||||||
|
|
Loading…
Reference in New Issue