Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: elants_i2c - make use of devm_add_action_or_reset()

The helper function devm_add_action_or_reset() will internally
call devm_add_action(), and if devm_add_action() fails then it will
execute the action mentioned and return the error code. So
use devm_add_action_or_reset() instead of devm_add_action()
to simplify the error handling, reduce the code.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210922125212.95-2-caihuoqing@baidu.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Cai Huoqing and committed by
Dmitry Torokhov
b083704f 09182ed2

+2 -2
+2 -2
drivers/input/touchscreen/elants_i2c.c
··· 1440 1440 if (error) 1441 1441 return error; 1442 1442 1443 - error = devm_add_action(&client->dev, elants_i2c_power_off, ts); 1443 + error = devm_add_action_or_reset(&client->dev, 1444 + elants_i2c_power_off, ts); 1444 1445 if (error) { 1445 1446 dev_err(&client->dev, 1446 1447 "failed to install power off action: %d\n", error); 1447 - elants_i2c_power_off(ts); 1448 1448 return error; 1449 1449 } 1450 1450