[PATCH v2 5/5] HID: hidraw: Make hidraw.h private to HID subsystem
From: Dmitry Torokhov
Date: Fri Oct 16 2026 - 18:45:18 EST
With all external consumers converted to use the hidraw instance helper,
hidraw.h no longer needs to be exposed in include/linux.
Move the header into drivers/hid, keep private buffer and list
structures internal to hidraw.c, and drop unneeded symbol exports
since hidraw and hid-core are built into the same module.
Assisted-by: LLM
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/hid/hid-core.c | 2 +-
drivers/hid/hid-cp2112.c | 2 +-
drivers/hid/hid-led.c | 2 +-
drivers/hid/hid-u2fzero.c | 2 +-
drivers/hid/hidraw.c | 33 +++++++++++++++++++++++++++++----
{include/linux => drivers/hid}/hidraw.h | 29 +----------------------------
6 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 85433f64bda1..8ee3be98811a 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -31,10 +31,10 @@
#include <linux/hid.h>
#include <linux/hiddev.h>
#include <linux/hid-debug.h>
-#include <linux/hidraw.h>
#include "hid-core.h"
#include "hid-ids.h"
+#include "hidraw.h"
/*
* Version Information
diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 148946b04bff..0f65ce44e677 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -20,7 +20,6 @@
#include <linux/cleanup.h>
#include <linux/gpio/driver.h>
#include <linux/hid.h>
-#include <linux/hidraw.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mutex.h>
@@ -28,6 +27,7 @@
#include <linux/string_choices.h>
#include <linux/usb/ch9.h>
#include "hid-ids.h"
+#include "hidraw.h"
/**
* enum cp2112_child_acpi_cell_addrs - Child ACPI addresses for CP2112 sub-functions
diff --git a/drivers/hid/hid-led.c b/drivers/hid/hid-led.c
index 63fd723d9e69..f5a798c7979e 100644
--- a/drivers/hid/hid-led.c
+++ b/drivers/hid/hid-led.c
@@ -8,12 +8,12 @@
*/
#include <linux/hid.h>
-#include <linux/hidraw.h>
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include "hid-ids.h"
+#include "hidraw.h"
enum hidled_report_type {
RAW_REQUEST,
diff --git a/drivers/hid/hid-u2fzero.c b/drivers/hid/hid-u2fzero.c
index 83e223c12cd6..4b9271b4e45e 100644
--- a/drivers/hid/hid-u2fzero.c
+++ b/drivers/hid/hid-u2fzero.c
@@ -12,7 +12,6 @@
*/
#include <linux/hid.h>
-#include <linux/hidraw.h>
#include <linux/hw_random.h>
#include <linux/leds.h>
#include <linux/module.h>
@@ -21,6 +20,7 @@
#include "usbhid/usbhid.h"
#include "hid-ids.h"
+#include "hidraw.h"
#define DRIVER_SHORT "u2fzero"
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 949e7546339f..9d0df711ed5d 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -27,8 +27,36 @@
#include <linux/mutex.h>
#include <linux/sched/signal.h>
#include <linux/string.h>
+#include <uapi/linux/hidraw.h>
+
+#include "hidraw.h"
+
+struct hidraw {
+ unsigned int minor;
+ int exist;
+ int open;
+ wait_queue_head_t wait;
+ struct hid_device *hid;
+ struct device *dev;
+ spinlock_t list_lock;
+ struct list_head list;
+};
+
+struct hidraw_report {
+ __u8 *value;
+ int len;
+};
-#include <linux/hidraw.h>
+struct hidraw_list {
+ struct hidraw_report buffer[HIDRAW_BUFFER_SIZE];
+ int head;
+ int tail;
+ struct fasync_struct *fasync;
+ struct hidraw *hidraw;
+ struct list_head node;
+ struct mutex read_mutex;
+ bool revoked;
+};
static int hidraw_major;
static struct cdev hidraw_cdev;
@@ -594,7 +622,6 @@ int hidraw_report_event(struct hid_device *hid, u8 *data, int len)
wake_up_interruptible(&dev->wait);
return ret;
}
-EXPORT_SYMBOL_GPL(hidraw_report_event);
int hidraw_connect(struct hid_device *hid)
{
@@ -651,7 +678,6 @@ int hidraw_connect(struct hid_device *hid)
return result;
}
-EXPORT_SYMBOL_GPL(hidraw_connect);
void hidraw_disconnect(struct hid_device *hid)
{
@@ -663,7 +689,6 @@ void hidraw_disconnect(struct hid_device *hid)
up_write(&minors_rwsem);
}
-EXPORT_SYMBOL_GPL(hidraw_disconnect);
/**
* hidraw_instance - get hidraw instance minor number for a HID device
diff --git a/include/linux/hidraw.h b/drivers/hid/hidraw.h
similarity index 63%
rename from include/linux/hidraw.h
rename to drivers/hid/hidraw.h
index 3021454ba513..a822007ce5f8 100644
--- a/include/linux/hidraw.h
+++ b/drivers/hid/hidraw.h
@@ -6,35 +6,8 @@
#define _HIDRAW_H
#include <linux/errno.h>
-#include <uapi/linux/hidraw.h>
-
-struct hidraw {
- unsigned int minor;
- int exist;
- int open;
- wait_queue_head_t wait;
- struct hid_device *hid;
- struct device *dev;
- spinlock_t list_lock;
- struct list_head list;
-};
-
-struct hidraw_report {
- __u8 *value;
- int len;
-};
-
-struct hidraw_list {
- struct hidraw_report buffer[HIDRAW_BUFFER_SIZE];
- int head;
- int tail;
- struct fasync_struct *fasync;
- struct hidraw *hidraw;
- struct list_head node;
- struct mutex read_mutex;
- bool revoked;
-};
+struct hid_device;
#ifdef CONFIG_HIDRAW
int hidraw_init(void);
--
2.56.0.176.g3575e65682-goog