]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: asus: simplify and improve asus_kbd_set_report()
authorDenis Benato <denis.benato@linux.dev>
Sat, 28 Feb 2026 19:10:08 +0000 (20:10 +0100)
committerJiri Kosina <jkosina@suse.com>
Tue, 10 Mar 2026 17:01:19 +0000 (18:01 +0100)
Make the function shorter and easier to read using __free, and also fix a
misaligned comment closing tag.

The __free macro from cleanup.h is already used in the driver, but its
include is missing: add it.

Signed-off-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/hid-asus.c

index 7513a0b3e155a38c10cf90ed106e0d079c028378..fa9a24f279f492df5610127a9ad3ca537499f51d 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/cleanup.h>
 #include <linux/dmi.h>
 #include <linux/hid.h>
 #include <linux/module.h>
@@ -464,23 +465,16 @@ static int asus_raw_event(struct hid_device *hdev,
 
 static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t buf_size)
 {
-       unsigned char *dmabuf;
-       int ret;
-
-       dmabuf = kmemdup(buf, buf_size, GFP_KERNEL);
+       u8 *dmabuf __free(kfree) = kmemdup(buf, buf_size, GFP_KERNEL);
        if (!dmabuf)
                return -ENOMEM;
 
        /*
         * The report ID should be set from the incoming buffer due to LED and key
         * interfaces having different pages
-       */
-       ret = hid_hw_raw_request(hdev, buf[0], dmabuf,
-                                buf_size, HID_FEATURE_REPORT,
-                                HID_REQ_SET_REPORT);
-       kfree(dmabuf);
-
-       return ret;
+        */
+       return hid_hw_raw_request(hdev, buf[0], dmabuf, buf_size, HID_FEATURE_REPORT,
+                                 HID_REQ_SET_REPORT);
 }
 
 static int asus_kbd_init(struct hid_device *hdev, u8 report_id)