[PATCH v2 5/7] HID: asus: simplify and improve asus_kbd_set_report()
From: Denis Benato
Date: Sat Feb 28 2026 - 16:37:18 EST
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@xxxxxxxxx>
---
drivers/hid/hid-asus.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 48731b48523d..4fa8e72c6855 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -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)
--
2.53.0