Commit 43b3d1a9 authored by Denis Benato's avatar Denis Benato Committed by Jiri Kosina
Browse files

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: default avatarDenis Benato <denis.benato@linux.dev>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
parent 51d33b42
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -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,10 +465,7 @@ 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;

@@ -475,12 +473,8 @@ static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t bu
	 * 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,
	return hid_hw_raw_request(hdev, buf[0], dmabuf, buf_size, HID_FEATURE_REPORT,
				  HID_REQ_SET_REPORT);
	kfree(dmabuf);

	return ret;
}

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