Skip to content

Commit 054e0bd

Browse files
author
Benjamin Tissoires
committed
Merge branch 'for-6.12/constify-rdesc' into for-linus
- Constification of report descriptors so drivers can use read-only memory when declaring report descriptors fixups (Thomas Weißschuh)
2 parents 37c25a5 + 9f5305e commit 054e0bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+167
-171
lines changed

drivers/hid/bpf/hid_bpf_dispatch.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int dispatch_hid_bpf_output_report(struct hid_device *hdev,
148148
}
149149
EXPORT_SYMBOL_GPL(dispatch_hid_bpf_output_report);
150150

151-
u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size)
151+
u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, const u8 *rdesc, unsigned int *size)
152152
{
153153
int ret;
154154
struct hid_bpf_ctx_kern ctx_kern = {
@@ -179,9 +179,7 @@ u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *s
179179
*size = ret;
180180
}
181181

182-
rdesc = krealloc(ctx_kern.data, *size, GFP_KERNEL);
183-
184-
return rdesc;
182+
return krealloc(ctx_kern.data, *size, GFP_KERNEL);
185183

186184
ignore_bpf:
187185
kfree(ctx_kern.data);

drivers/hid/hid-apple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ static void apple_battery_timer_tick(struct timer_list *t)
620620
* MacBook JIS keyboard has wrong logical maximum
621621
* Magic Keyboard JIS has wrong logical maximum
622622
*/
623-
static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
623+
static const __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
624624
unsigned int *rsize)
625625
{
626626
struct apple_sc *asc = hid_get_drvdata(hdev);

drivers/hid/hid-asus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ static const __u8 asus_g752_fixed_rdesc[] = {
11191119
0x2A, 0xFF, 0x00, /* Usage Maximum (0xFF) */
11201120
};
11211121

1122-
static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
1122+
static const __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
11231123
unsigned int *rsize)
11241124
{
11251125
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);

drivers/hid/hid-aureal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "hid-ids.h"
2020

21-
static __u8 *aureal_report_fixup(struct hid_device *hdev, __u8 *rdesc,
21+
static const __u8 *aureal_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2222
unsigned int *rsize)
2323
{
2424
if (*rsize >= 54 && rdesc[52] == 0x25 && rdesc[53] == 0x01) {

drivers/hid/hid-bigbenff.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
* - map previously unused analog trigger data to Z/RZ
100100
* - simplify feature and output descriptor
101101
*/
102-
static __u8 pid0902_rdesc_fixed[] = {
102+
static const __u8 pid0902_rdesc_fixed[] = {
103103
0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
104104
0x09, 0x05, /* Usage (Game Pad) */
105105
0xA1, 0x01, /* Collection (Application) */
@@ -464,12 +464,12 @@ static int bigben_probe(struct hid_device *hid,
464464
return error;
465465
}
466466

467-
static __u8 *bigben_report_fixup(struct hid_device *hid, __u8 *rdesc,
467+
static const __u8 *bigben_report_fixup(struct hid_device *hid, __u8 *rdesc,
468468
unsigned int *rsize)
469469
{
470470
if (*rsize == PID0902_RDESC_ORIG_SIZE) {
471-
rdesc = pid0902_rdesc_fixed;
472471
*rsize = sizeof(pid0902_rdesc_fixed);
472+
return pid0902_rdesc_fixed;
473473
} else
474474
hid_warn(hid, "unexpected rdesc, please submit for review\n");
475475
return rdesc;

drivers/hid/hid-cherry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Cherry Cymotion keyboard have an invalid HID report descriptor,
2323
* that needs fixing before we can parse it.
2424
*/
25-
static __u8 *ch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
25+
static const __u8 *ch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2626
unsigned int *rsize)
2727
{
2828
if (*rsize >= 18 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {

drivers/hid/hid-chicony.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
8888
return 1;
8989
}
9090

91-
static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc,
92-
unsigned int *rsize)
91+
static const __u8 *ch_switch12_report_fixup(struct hid_device *hdev,
92+
__u8 *rdesc, unsigned int *rsize)
9393
{
9494
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
9595

drivers/hid/hid-cmedia.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MODULE_LICENSE("GPL");
2626
/* Fixed report descriptor of HS-100B audio chip
2727
* Bit 4 is an abolute Microphone mute usage instead of being unassigned.
2828
*/
29-
static __u8 hs100b_rdesc_fixed[] = {
29+
static const __u8 hs100b_rdesc_fixed[] = {
3030
0x05, 0x0C, /* Usage Page (Consumer), */
3131
0x09, 0x01, /* Usage (Consumer Control), */
3232
0xA1, 0x01, /* Collection (Application), */
@@ -199,13 +199,13 @@ static struct hid_driver cmhid_driver = {
199199
.input_mapping = cmhid_input_mapping,
200200
};
201201

202-
static __u8 *cmhid_hs100b_report_fixup(struct hid_device *hid, __u8 *rdesc,
202+
static const __u8 *cmhid_hs100b_report_fixup(struct hid_device *hid, __u8 *rdesc,
203203
unsigned int *rsize)
204204
{
205205
if (*rsize == HS100B_RDESC_ORIG_SIZE) {
206206
hid_info(hid, "Fixing CMedia HS-100B report descriptor\n");
207-
rdesc = hs100b_rdesc_fixed;
208207
*rsize = sizeof(hs100b_rdesc_fixed);
208+
return hs100b_rdesc_fixed;
209209
}
210210
return rdesc;
211211
}

drivers/hid/hid-core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ static void hid_device_release(struct device *dev)
723723
* items, though they are not used yet.
724724
*/
725725

726-
static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
726+
static const u8 *fetch_item(const __u8 *start, const __u8 *end, struct hid_item *item)
727727
{
728728
u8 b;
729729

@@ -880,8 +880,8 @@ static int hid_scan_report(struct hid_device *hid)
880880
{
881881
struct hid_parser *parser;
882882
struct hid_item item;
883-
__u8 *start = hid->dev_rdesc;
884-
__u8 *end = start + hid->dev_rsize;
883+
const __u8 *start = hid->dev_rdesc;
884+
const __u8 *end = start + hid->dev_rsize;
885885
static int (*dispatch_type[])(struct hid_parser *parser,
886886
struct hid_item *item) = {
887887
hid_scan_main,
@@ -946,7 +946,7 @@ static int hid_scan_report(struct hid_device *hid)
946946
* Allocate the device report as read by the bus driver. This function should
947947
* only be called from parse() in ll drivers.
948948
*/
949-
int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size)
949+
int hid_parse_report(struct hid_device *hid, const __u8 *start, unsigned size)
950950
{
951951
hid->dev_rdesc = kmemdup(start, size, GFP_KERNEL);
952952
if (!hid->dev_rdesc)
@@ -1204,10 +1204,10 @@ int hid_open_report(struct hid_device *device)
12041204
struct hid_parser *parser;
12051205
struct hid_item item;
12061206
unsigned int size;
1207-
__u8 *start;
1207+
const __u8 *start;
12081208
__u8 *buf;
1209-
__u8 *end;
1210-
__u8 *next;
1209+
const __u8 *end;
1210+
const __u8 *next;
12111211
int ret;
12121212
int i;
12131213
static int (*dispatch_type[])(struct hid_parser *parser,

drivers/hid/hid-corsair.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ static int corsair_input_mapping(struct hid_device *dev,
690690
* - USB ID 1b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse
691691
*/
692692

693-
static __u8 *corsair_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
694-
unsigned int *rsize)
693+
static const __u8 *corsair_mouse_report_fixup(struct hid_device *hdev,
694+
__u8 *rdesc, unsigned int *rsize)
695695
{
696696
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
697697

0 commit comments

Comments
 (0)