[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260120200202.1225216-2-benjaminwheeler0510@gmail.com>
Date: Tue, 20 Jan 2026 15:02:00 -0500
From: Benjamin Wheeler <benjaminwheeler0510@...il.com>
To: srimanachanta@...il.com
Cc: bentiss@...nel.org,
jikos@...nel.org,
linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] HID: steelseries: Clean up hid send_report functions
These functions do the same thing, so combine them into one with a
parameter.
Use helper functions to keep callsites the same.
Signed-off-by: Benjamin Wheeler <benjaminwheeler0510@...il.com>
---
drivers/hid/hid-steelseries.c | 45 ++++++++++++++++-------------------
1 file changed, 21 insertions(+), 24 deletions(-)
diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c
index a0046fbc830b..63b086fa6df0 100644
--- a/drivers/hid/hid-steelseries.c
+++ b/drivers/hid/hid-steelseries.c
@@ -829,9 +829,13 @@ static int steelseries_battery_register(struct steelseries_device *sd)
return 0;
}
-/* Helper function to send feature reports */
-static int steelseries_send_feature_report(struct hid_device *hdev,
- const u8 *data, size_t len)
+/**
+ * Send an hid report to the device.
+ * Supported types are output reports and feature reports.
+ */
+static int __steelseries_send_report(struct hid_device *const hdev,
+ const u8 *const data, const size_t len,
+ const enum hid_report_type type)
{
u8 *buf;
int ret;
@@ -840,8 +844,9 @@ static int steelseries_send_feature_report(struct hid_device *hdev,
if (!buf)
return -ENOMEM;
- ret = hid_hw_raw_request(hdev, data[0], buf, len, HID_FEATURE_REPORT,
+ ret = hid_hw_raw_request(hdev, data[0], buf, len, type,
HID_REQ_SET_REPORT);
+
kfree(buf);
if (ret < 0)
@@ -852,28 +857,19 @@ static int steelseries_send_feature_report(struct hid_device *hdev,
return 0;
}
-/* Helper function to send output reports */
-static int steelseries_send_output_report(struct hid_device *hdev,
- const u8 *data, size_t len)
+static inline int steelseries_send_feature_report(struct hid_device *const hdev,
+ const u8 *const data,
+ const size_t len)
{
- u8 *buf;
- int ret;
-
- buf = kmemdup(data, len, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- /* Use raw_request with OUTPUT_REPORT type for devices without Interrupt OUT */
- ret = hid_hw_raw_request(hdev, data[0], buf, len, HID_OUTPUT_REPORT,
- HID_REQ_SET_REPORT);
- kfree(buf);
-
- if (ret < 0)
- return ret;
- if (ret < len)
- return -EIO;
+ return __steelseries_send_report(hdev, data, len, HID_FEATURE_REPORT);
+}
- return 0;
+static inline int steelseries_send_output_report(struct hid_device *const hdev,
+ const u8 *const data,
+ const size_t len)
+{
+ // NOTE: Output report (HID_OUTPUT_REPORT) is for devices without Interrupt OUT
+ return __steelseries_send_report(hdev, data, len, HID_OUTPUT_REPORT);
}
/* Sidetone level attribute */
@@ -2170,3 +2166,4 @@ MODULE_AUTHOR("Bastien Nocera <hadess@...ess.net>");
MODULE_AUTHOR("Simon Wood <simon@...gewell.org>");
MODULE_AUTHOR("Christian Mayer <git@...er-bgk.de>");
MODULE_AUTHOR("Sriman Achanta <srimanachanta@...il.com>");
+MODULE_AUTHOR("Benjamin Wheeler <benjaminwheeler0510@...il.com>");
--
2.52.0
Powered by blists - more mailing lists