ARM: davinci: dm646x-evm: Simplify error handling in 'evm_sw_setup()'

There is no need to call 'gpio_free(evm_sw_gpio[i])' for these error
handling cases, it is already done in the error handling path at label
'out_free'.

Simplify the code and axe a few LoC.

While at it, also explicitly return 0 in the normal path.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
This commit is contained in:
Christophe JAILLET 2020-03-21 09:58:36 +01:00 коммит произвёл Sekhar Nori
Родитель 66ed86d637
Коммит 951e395686
1 изменённых файлов: 4 добавлений и 9 удалений

Просмотреть файл

@ -267,20 +267,15 @@ static int evm_sw_setup(struct i2c_client *client, int gpio,
evm_sw_gpio[i] = gpio++;
status = gpio_direction_input(evm_sw_gpio[i]);
if (status) {
gpio_free(evm_sw_gpio[i]);
evm_sw_gpio[i] = -EINVAL;
if (status)
goto out_free;
}
status = gpio_export(evm_sw_gpio[i], 0);
if (status) {
gpio_free(evm_sw_gpio[i]);
evm_sw_gpio[i] = -EINVAL;
if (status)
goto out_free;
}
}
return status;
return 0;
out_free:
for (i = 0; i < 4; ++i) {
if (evm_sw_gpio[i] != -EINVAL) {