Skip to content

Commit 43b3d1a

Browse files
NeroReflexJiri Kosina
authored andcommitted
HID: asus: simplify and improve asus_kbd_set_report()
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>
1 parent 51d33b4 commit 43b3d1a

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

drivers/hid/hid-asus.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
#include <linux/acpi.h>
24+
#include <linux/cleanup.h>
2425
#include <linux/dmi.h>
2526
#include <linux/hid.h>
2627
#include <linux/module.h>
@@ -464,23 +465,16 @@ static int asus_raw_event(struct hid_device *hdev,
464465

465466
static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t buf_size)
466467
{
467-
unsigned char *dmabuf;
468-
int ret;
469-
470-
dmabuf = kmemdup(buf, buf_size, GFP_KERNEL);
468+
u8 *dmabuf __free(kfree) = kmemdup(buf, buf_size, GFP_KERNEL);
471469
if (!dmabuf)
472470
return -ENOMEM;
473471

474472
/*
475473
* The report ID should be set from the incoming buffer due to LED and key
476474
* interfaces having different pages
477-
*/
478-
ret = hid_hw_raw_request(hdev, buf[0], dmabuf,
479-
buf_size, HID_FEATURE_REPORT,
480-
HID_REQ_SET_REPORT);
481-
kfree(dmabuf);
482-
483-
return ret;
475+
*/
476+
return hid_hw_raw_request(hdev, buf[0], dmabuf, buf_size, HID_FEATURE_REPORT,
477+
HID_REQ_SET_REPORT);
484478
}
485479

486480
static int asus_kbd_init(struct hid_device *hdev, u8 report_id)

0 commit comments

Comments
 (0)