From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html