Skip to content

Commit 8e3cd92

Browse files
caihuoqing1990Jiri Kosina
authored andcommitted
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent a68f3bd commit 8e3cd92

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/hid/hid-cougar.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,9 @@ static int cougar_bind_shared_data(struct hid_device *hdev,
179179

180180
cougar->shared = shared;
181181

182-
error = devm_add_action(&hdev->dev, cougar_remove_shared_data, cougar);
182+
error = devm_add_action_or_reset(&hdev->dev, cougar_remove_shared_data, cougar);
183183
if (error) {
184184
mutex_unlock(&cougar_udev_list_lock);
185-
cougar_remove_shared_data(cougar);
186185
return error;
187186
}
188187

0 commit comments

Comments
 (0)