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

Input: cyapa - switch to using devm_add_action_or_reset()

devm_add_action_or_reset() is introduced as a helper function which
internally calls devm_add_action(). If devm_add_action() fails
then it will execute the action mentioned and return the error code.
This reduce source code size (avoid writing the action twice)
and reduce the likelyhood of bugs.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Link: https://lore.kernel.org/linux-input/20190708123323.11943-1-huangfq.daxian@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Fuqian Huang and committed by
Dmitry Torokhov
8edcd98b 3d82a4d7

+4 -6
+4 -6
drivers/input/mouse/cyapa.c
··· 840 840 return error; 841 841 } 842 842 843 - error = devm_add_action(dev, 843 + error = devm_add_action_or_reset(dev, 844 844 cyapa_remove_power_wakeup_group, cyapa); 845 845 if (error) { 846 - cyapa_remove_power_wakeup_group(cyapa); 847 846 dev_err(dev, "failed to add power cleanup action: %d\n", 848 847 error); 849 848 return error; ··· 956 957 return error; 957 958 } 958 959 959 - error = devm_add_action(dev, cyapa_remove_power_runtime_group, cyapa); 960 + error = devm_add_action_or_reset(dev, cyapa_remove_power_runtime_group, 961 + cyapa); 960 962 if (error) { 961 - cyapa_remove_power_runtime_group(cyapa); 962 963 dev_err(dev, 963 964 "failed to add power runtime cleanup action: %d\n", 964 965 error); ··· 1290 1291 return error; 1291 1292 } 1292 1293 1293 - error = devm_add_action(dev, cyapa_disable_regulator, cyapa); 1294 + error = devm_add_action_or_reset(dev, cyapa_disable_regulator, cyapa); 1294 1295 if (error) { 1295 - cyapa_disable_regulator(cyapa); 1296 1296 dev_err(dev, "failed to add disable regulator action: %d\n", 1297 1297 error); 1298 1298 return error;