[PATCH 2/2] regulator: 88pm800: Remove NULL test for regulator_unregister()

Axel Lin
2013-06-28T13:34:21Z

It's safe to call regulator_unregister with NULL.
In additional, having NULL check in the for loop is wrong because
the for loop exits if pm800_data->regulators[i] is NULL.
So we have have some regulators remains registered.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/88pm800.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c
index afa3762..1fc1899 100644
--- a/drivers/regulator/88pm800.c
+++ b/drivers/regulator/88pm800.c
@@ -405,7 +405,7 @@ static int pm800_regulator_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Failed to register %s\n",
info->desc.name);

- while (--i >= 0 && pm800_data->regulators[i])
+ while (--i >= 0)
regulator_unregister(pm800_data->regulators[i]);

return ret;
@@ -420,7 +420,7 @@ static int pm800_regulator_remove(struct platform_device *pdev)
struct pm800_regulators *pm800_data = platform_get_drvdata(pdev);
int i;

- for (i = 0; pm800_data->regulators[i] && i < PM800_ID_RG_MAX; i++)
+ for (i = 0; i < PM800_ID_RG_MAX; i++)
regulator_unregister(pm800_data->regulators[i]);

return 0;
--
1.8.1.2