summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-cougar.c
diff options
context:
space:
mode:
authorCai Huoqing <caihuoqing@baidu.com>2021-09-22 15:59:31 +0300
committerJiri Kosina <jkosina@suse.cz>2021-10-07 14:37:25 +0300
commit8e3cd9221c66b97c31964c013499e6c8d0f49440 (patch)
tree9637be79c3d77c2cefca1e382574f0ea9757cd37 /drivers/hid/hid-cougar.c
parenta68f3bd13994b315f47ec7e4da8d1c39ba0a2bb4 (diff)
downloadlinux-8e3cd9221c66b97c31964c013499e6c8d0f49440.tar.xz
HID: cougar: Make use of the helper function 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> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-cougar.c')
-rw-r--r--drivers/hid/hid-cougar.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/hid/hid-cougar.c b/drivers/hid/hid-cougar.c
index 28d671c5e0ca..cb8bd8aae15b 100644
--- a/drivers/hid/hid-cougar.c
+++ b/drivers/hid/hid-cougar.c
@@ -179,10 +179,9 @@ static int cougar_bind_shared_data(struct hid_device *hdev,
cougar->shared = shared;
- error = devm_add_action(&hdev->dev, cougar_remove_shared_data, cougar);
+ error = devm_add_action_or_reset(&hdev->dev, cougar_remove_shared_data, cougar);
if (error) {
mutex_unlock(&cougar_udev_list_lock);
- cougar_remove_shared_data(cougar);
return error;
}