[PATCH 11/12] HID: rmi: remove dead code and reorder report write helper
From: Dmitry Torokhov
Date: Sat Nov 14 2026 - 01:01:40 EST
Leftover unused definitions, unreachable control flow, and an
unnecessary forward declaration clutter the driver.
Drop the dead code, remove the redundant pointer cast, and move the
report write helper ahead of its callers to eliminate its forward
declaration.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/hid/hid-rmi.c | 67 +++++++++++++++++++++------------------------------
1 file changed, 28 insertions(+), 39 deletions(-)
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index ec0d18cb06f6..d5961d408e72 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -39,13 +39,6 @@
#define RMI_DEVICE_HAS_PHYS_BUTTONS BIT(1)
#define RMI_DEVICE_OUTPUT_SET_REPORT BIT(2)
-/*
- * retrieve the ctrl registers
- * the ctrl register has a size of 20 but a fw bug split it into 16 + 4,
- * and there is no way to know if the first 20 bytes are here or not.
- * We use only the first 12 bytes, so get only them.
- */
-#define RMI_F11_CTRL_REG_COUNT 12
enum rmi_mode_type {
RMI_MODE_OFF = 0,
@@ -104,7 +97,34 @@ struct rmi_data {
#define RMI_PAGE(addr) (((addr) >> 8) & 0xff)
-static int rmi_write_report(struct hid_device *hdev, u8 *report, int len);
+static int rmi_write_report(struct hid_device *hdev, u8 *report, int len)
+{
+ struct rmi_data *data = hid_get_drvdata(hdev);
+ int ret;
+
+ if (data->device_flags & RMI_DEVICE_OUTPUT_SET_REPORT) {
+ /*
+ * Talk to device by using SET_REPORT requests instead.
+ */
+ ret = hid_hw_raw_request(hdev, report[0], report,
+ len, HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
+ } else {
+ ret = hid_hw_output_report(hdev, report, len);
+ }
+
+ if (ret < 0) {
+ dev_err(&hdev->dev, "failed to write hid report (%d)\n", ret);
+ return ret;
+ }
+
+ if (ret != len) {
+ dev_err(&hdev->dev, "short write to hid device (%d < %d)\n",
+ ret, len);
+ return -EIO;
+ }
+
+ return 0;
+}
/**
* rmi_set_page - Set RMI page
@@ -162,35 +182,6 @@ static int rmi_set_mode(struct hid_device *hdev, u8 mode)
return 0;
}
-static int rmi_write_report(struct hid_device *hdev, u8 *report, int len)
-{
- struct rmi_data *data = hid_get_drvdata(hdev);
- int ret;
-
- if (data->device_flags & RMI_DEVICE_OUTPUT_SET_REPORT) {
- /*
- * Talk to device by using SET_REPORT requests instead.
- */
- ret = hid_hw_raw_request(hdev, report[0], report,
- len, HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
- } else {
- ret = hid_hw_output_report(hdev, (void *)report, len);
- }
-
- if (ret < 0) {
- dev_err(&hdev->dev, "failed to write hid report (%d)\n", ret);
- return ret;
- }
-
- if (ret != len) {
- dev_err(&hdev->dev, "short write to hid device (%d < %d)\n",
- ret, len);
- return -EIO;
- }
-
- return 0;
-}
-
static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr,
void *buf, size_t len)
{
@@ -412,8 +403,6 @@ static int rmi_raw_event(struct hid_device *hdev,
default:
return 1;
}
-
- return 0;
}
static int rmi_event(struct hid_device *hdev, struct hid_field *field,
--
2.56.0.679.gc527c65306-goog