[PATCH] power: generic-adc-battery: Delete unnecessary checks before the function call "iio_channel_release"

SF Markus Elfring
2016-07-23T13:02:23Z

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Jul 2016 14:50:47 +0200

The iio_channel_release() function tests whether its argument is NULL
and then returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/power/generic-adc-battery.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/power/generic-adc-battery.c b/drivers/power/generic-adc-battery.c
index edb36bf..8f7f24c 100644
--- a/drivers/power/generic-adc-battery.c
+++ b/drivers/power/generic-adc-battery.c
@@ -350,10 +350,8 @@ err_gpio:
gpio_req_fail:
power_supply_unregister(adc_bat->psy);
err_reg_fail:
- for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++) {
- if (adc_bat->channel[chan])
- iio_channel_release(adc_bat->channel[chan]);
- }
+ for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++)
+ iio_channel_release(adc_bat->channel[chan]);
second_mem_fail:
kfree(psy_desc->properties);
first_mem_fail:
@@ -373,11 +371,8 @@ static int gab_remove(struct platform_device *pdev)
gpio_free(pdata->gpio_charge_finished);
}

- for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++) {
- if (adc_bat->channel[chan])
- iio_channel_release(adc_bat->channel[chan]);
- }
-
+ for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++)
+ iio_channel_release(adc_bat->channel[chan]);
kfree(adc_bat->psy_desc.properties);
cancel_delayed_work(&adc_bat->bat_work);
return 0;
--
2.9.2