From: Benjamin Wheeler <benjaminwheeler0510@gmail.com>
To: srimanachanta@gmail.com
Cc: bentiss@kernel.org, jikos@kernel.org,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] HID: steelseries: Clean up hid send_report functions
Date: Tue, 20 Jan 2026 15:02:00 -0500 [thread overview]
Message-ID: <20260120200202.1225216-2-benjaminwheeler0510@gmail.com> (raw)
In-Reply-To: <20260120200202.1225216-1-benjaminwheeler0510@gmail.com>
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@gmail.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@hadess.net>");
MODULE_AUTHOR("Simon Wood <simon@mungewell.org>");
MODULE_AUTHOR("Christian Mayer <git@mayer-bgk.de>");
MODULE_AUTHOR("Sriman Achanta <srimanachanta@gmail.com>");
+MODULE_AUTHOR("Benjamin Wheeler <benjaminwheeler0510@gmail.com>");
--
2.52.0
next prev parent reply other threads:[~2026-01-20 20:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 4:19 [PATCH v2 0/4] HID: steelseries: Add support for Arctis headset lineup Sriman Achanta
2026-01-12 4:19 ` [PATCH v2 1/4] HID: hid-ids: Add SteelSeries Arctis headset device IDs Sriman Achanta
2026-01-12 13:08 ` Bastien Nocera
2026-01-12 4:19 ` [PATCH v2 2/4] HID: quirks: Add INPUT_CONFIGURED quirk for SteelSeries Arctis headsets Sriman Achanta
2026-01-12 13:08 ` Bastien Nocera
2026-01-12 4:19 ` [PATCH v2 3/4] Documentation: ABI: Document SteelSeries headset sysfs attributes Sriman Achanta
2026-01-12 13:08 ` Bastien Nocera
2026-01-12 4:19 ` [PATCH v2 4/4] HID: steelseries: Add support for Arctis headset lineup Sriman Achanta
2026-01-12 13:09 ` Bastien Nocera
[not found] ` <CABMjph80yxmXnZjLgUrhFN7cKf2P=VjWF0rfWxG0rYOa42f5eQ@mail.gmail.com>
[not found] ` <e5b256fa8da7fe079f3e3b10a1b0b6a0faf8e913.camel@hadess.net>
[not found] ` <CABMjph9TzmCfks0OEtCx4gFFe0pKOccBwVutq6dVH2DhzSC5vA@mail.gmail.com>
2026-02-26 10:01 ` Bastien Nocera
2026-01-20 19:01 ` [PATCH v2 0/4] " Benjamin Wheeler
2026-01-20 20:01 ` [PATCH 0/3] HID: steelseries: clean up functions, move battery request data to structs Benjamin Wheeler
2026-01-20 20:02 ` Benjamin Wheeler [this message]
2026-01-20 20:02 ` [PATCH 2/3] HID: steelseries: Add battery request info (byte flags) to device info Benjamin Wheeler
2026-01-20 20:02 ` [PATCH 3/3] HID: steelseries: Use device data for battery requests Benjamin Wheeler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260120200202.1225216-2-benjaminwheeler0510@gmail.com \
--to=benjaminwheeler0510@gmail.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srimanachanta@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox