Skip to content

Commit 7d8fe4c

Browse files
committed
Merge branch 'for-6.1/core' into for-linus
- move from strlcpy with unused retval to strscpy (Wolfram Sang) - Kconfig fixes (Randy Dunlap) - HID-BPF preparatory patches, convert blank defines as enums (Benjamin Tissoires)
2 parents bfdc750 + 735e1bb commit 7d8fe4c

File tree

10 files changed

+58
-117
lines changed

10 files changed

+58
-117
lines changed

drivers/hid/Kconfig

Lines changed: 1 addition & 72 deletions
Large diffs are not rendered by default.

drivers/hid/hid-core.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(ignore_special_drivers, "Ignore any special drivers and handle
5555
*/
5656

5757
struct hid_report *hid_register_report(struct hid_device *device,
58-
unsigned int type, unsigned int id,
58+
enum hid_report_type type, unsigned int id,
5959
unsigned int application)
6060
{
6161
struct hid_report_enum *report_enum = device->report_enum + type;
@@ -967,7 +967,7 @@ static const char * const hid_report_names[] = {
967967
* parsing.
968968
*/
969969
struct hid_report *hid_validate_values(struct hid_device *hid,
970-
unsigned int type, unsigned int id,
970+
enum hid_report_type type, unsigned int id,
971971
unsigned int field_index,
972972
unsigned int report_counts)
973973
{
@@ -1921,7 +1921,7 @@ static struct hid_report *hid_get_report(struct hid_report_enum *report_enum,
19211921
* DO NOT USE in hid drivers directly, but through hid_hw_request instead.
19221922
*/
19231923
int __hid_request(struct hid_device *hid, struct hid_report *report,
1924-
int reqtype)
1924+
enum hid_class_request reqtype)
19251925
{
19261926
char *buf;
19271927
int ret;
@@ -1954,8 +1954,8 @@ int __hid_request(struct hid_device *hid, struct hid_report *report,
19541954
}
19551955
EXPORT_SYMBOL_GPL(__hid_request);
19561956

1957-
int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size,
1958-
int interrupt)
1957+
int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *data, u32 size,
1958+
int interrupt)
19591959
{
19601960
struct hid_report_enum *report_enum = hid->report_enum + type;
19611961
struct hid_report *report;
@@ -2019,7 +2019,8 @@ EXPORT_SYMBOL_GPL(hid_report_raw_event);
20192019
*
20202020
* This is data entry for lower layers.
20212021
*/
2022-
int hid_input_report(struct hid_device *hid, int type, u8 *data, u32 size, int interrupt)
2022+
int hid_input_report(struct hid_device *hid, enum hid_report_type type, u8 *data, u32 size,
2023+
int interrupt)
20232024
{
20242025
struct hid_report_enum *report_enum;
20252026
struct hid_driver *hdrv;
@@ -2352,7 +2353,7 @@ EXPORT_SYMBOL_GPL(hid_hw_close);
23522353
* @reqtype: hid request type
23532354
*/
23542355
void hid_hw_request(struct hid_device *hdev,
2355-
struct hid_report *report, int reqtype)
2356+
struct hid_report *report, enum hid_class_request reqtype)
23562357
{
23572358
if (hdev->ll_driver->request)
23582359
return hdev->ll_driver->request(hdev, report, reqtype);
@@ -2377,7 +2378,7 @@ EXPORT_SYMBOL_GPL(hid_hw_request);
23772378
*/
23782379
int hid_hw_raw_request(struct hid_device *hdev,
23792380
unsigned char reportnum, __u8 *buf,
2380-
size_t len, unsigned char rtype, int reqtype)
2381+
size_t len, enum hid_report_type rtype, enum hid_class_request reqtype)
23812382
{
23822383
if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
23832384
return -EINVAL;
@@ -2739,10 +2740,12 @@ int hid_add_device(struct hid_device *hdev)
27392740
hid_warn(hdev, "bad device descriptor (%d)\n", ret);
27402741
}
27412742

2743+
hdev->id = atomic_inc_return(&id);
2744+
27422745
/* XXX hack, any other cleaner solution after the driver core
27432746
* is converted to allow more than 20 bytes as the device name? */
27442747
dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
2745-
hdev->vendor, hdev->product, atomic_inc_return(&id));
2748+
hdev->vendor, hdev->product, hdev->id);
27462749

27472750
hid_debug_register(hdev, dev_name(&hdev->dev));
27482751
ret = device_add(&hdev->dev);

drivers/hid/hid-steam.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static int steam_get_serial(struct steam_device *steam)
256256
if (reply[0] != 0xae || reply[1] != 0x15 || reply[2] != 0x01)
257257
return -EIO;
258258
reply[3 + STEAM_SERIAL_LEN] = 0;
259-
strlcpy(steam->serial_no, reply + 3, sizeof(steam->serial_no));
259+
strscpy(steam->serial_no, reply + 3, sizeof(steam->serial_no));
260260
return 0;
261261
}
262262

@@ -524,7 +524,7 @@ static int steam_register(struct steam_device *steam)
524524
*/
525525
mutex_lock(&steam->mutex);
526526
if (steam_get_serial(steam) < 0)
527-
strlcpy(steam->serial_no, "XXXXXXXXXX",
527+
strscpy(steam->serial_no, "XXXXXXXXXX",
528528
sizeof(steam->serial_no));
529529
mutex_unlock(&steam->mutex);
530530

@@ -699,9 +699,9 @@ static struct hid_device *steam_create_client_hid(struct hid_device *hdev)
699699
client_hdev->version = hdev->version;
700700
client_hdev->type = hdev->type;
701701
client_hdev->country = hdev->country;
702-
strlcpy(client_hdev->name, hdev->name,
702+
strscpy(client_hdev->name, hdev->name,
703703
sizeof(client_hdev->name));
704-
strlcpy(client_hdev->phys, hdev->phys,
704+
strscpy(client_hdev->phys, hdev->phys,
705705
sizeof(client_hdev->phys));
706706
/*
707707
* Since we use the same device info than the real interface to

drivers/hid/i2c-hid/i2c-hid-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
10361036

10371037
snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
10381038
client->name, (u16)hid->vendor, (u16)hid->product);
1039-
strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
1039+
strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
10401040

10411041
ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product);
10421042

drivers/hid/usbhid/hid-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
13811381
hid->type = HID_TYPE_USBNONE;
13821382

13831383
if (dev->manufacturer)
1384-
strlcpy(hid->name, dev->manufacturer, sizeof(hid->name));
1384+
strscpy(hid->name, dev->manufacturer, sizeof(hid->name));
13851385

13861386
if (dev->product) {
13871387
if (dev->manufacturer)

drivers/hid/usbhid/usbkbd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
294294
spin_lock_init(&kbd->leds_lock);
295295

296296
if (dev->manufacturer)
297-
strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name));
297+
strscpy(kbd->name, dev->manufacturer, sizeof(kbd->name));
298298

299299
if (dev->product) {
300300
if (dev->manufacturer)

drivers/hid/usbhid/usbmouse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
142142
mouse->dev = input_dev;
143143

144144
if (dev->manufacturer)
145-
strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name));
145+
strscpy(mouse->name, dev->manufacturer, sizeof(mouse->name));
146146

147147
if (dev->product) {
148148
if (dev->manufacturer)

drivers/hid/wacom_sys.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,7 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix)
22262226
} else if (strstr(product_name, "Wacom") ||
22272227
strstr(product_name, "wacom") ||
22282228
strstr(product_name, "WACOM")) {
2229-
strlcpy(name, product_name, sizeof(name));
2229+
strscpy(name, product_name, sizeof(name));
22302230
} else {
22312231
snprintf(name, sizeof(name), "Wacom %s", product_name);
22322232
}
@@ -2244,7 +2244,7 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix)
22442244
if (name[strlen(name)-1] == ' ')
22452245
name[strlen(name)-1] = '\0';
22462246
} else {
2247-
strlcpy(name, features->name, sizeof(name));
2247+
strscpy(name, features->name, sizeof(name));
22482248
}
22492249

22502250
snprintf(wacom_wac->name, sizeof(wacom_wac->name), "%s%s",
@@ -2509,7 +2509,7 @@ static void wacom_wireless_work(struct work_struct *work)
25092509
goto fail;
25102510
}
25112511

2512-
strlcpy(wacom_wac->name, wacom_wac1->name,
2512+
strscpy(wacom_wac->name, wacom_wac1->name,
25132513
sizeof(wacom_wac->name));
25142514
error = wacom_initialize_battery(wacom);
25152515
if (error)

include/linux/hid.h

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,6 @@ struct hid_item {
314314
#define HID_BAT_ABSOLUTESTATEOFCHARGE 0x00850065
315315

316316
#define HID_VD_ASUS_CUSTOM_MEDIA_KEYS 0xff310076
317-
/*
318-
* HID report types --- Ouch! HID spec says 1 2 3!
319-
*/
320-
321-
#define HID_INPUT_REPORT 0
322-
#define HID_OUTPUT_REPORT 1
323-
#define HID_FEATURE_REPORT 2
324-
325-
#define HID_REPORT_TYPES 3
326317

327318
/*
328319
* HID connect requests
@@ -509,7 +500,7 @@ struct hid_report {
509500
struct list_head hidinput_list;
510501
struct list_head field_entry_list; /* ordered list of input fields */
511502
unsigned int id; /* id of this report */
512-
unsigned int type; /* report type */
503+
enum hid_report_type type; /* report type */
513504
unsigned int application; /* application usage for this report */
514505
struct hid_field *field[HID_MAX_FIELDS]; /* fields of the report */
515506
struct hid_field_entry *field_entries; /* allocated memory of input field_entry */
@@ -658,6 +649,8 @@ struct hid_device { /* device report descriptor */
658649
struct list_head debug_list;
659650
spinlock_t debug_list_lock;
660651
wait_queue_head_t debug_wait;
652+
653+
unsigned int id; /* system unique id */
661654
};
662655

663656
#define to_hid_device(pdev) \
@@ -924,20 +917,21 @@ extern int hidinput_connect(struct hid_device *hid, unsigned int force);
924917
extern void hidinput_disconnect(struct hid_device *);
925918

926919
int hid_set_field(struct hid_field *, unsigned, __s32);
927-
int hid_input_report(struct hid_device *, int type, u8 *, u32, int);
920+
int hid_input_report(struct hid_device *hid, enum hid_report_type type, u8 *data, u32 size,
921+
int interrupt);
928922
struct hid_field *hidinput_get_led_field(struct hid_device *hid);
929923
unsigned int hidinput_count_leds(struct hid_device *hid);
930924
__s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code);
931925
void hid_output_report(struct hid_report *report, __u8 *data);
932-
int __hid_request(struct hid_device *hid, struct hid_report *rep, int reqtype);
926+
int __hid_request(struct hid_device *hid, struct hid_report *rep, enum hid_class_request reqtype);
933927
u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags);
934928
struct hid_device *hid_allocate_device(void);
935929
struct hid_report *hid_register_report(struct hid_device *device,
936-
unsigned int type, unsigned int id,
930+
enum hid_report_type type, unsigned int id,
937931
unsigned int application);
938932
int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
939933
struct hid_report *hid_validate_values(struct hid_device *hid,
940-
unsigned int type, unsigned int id,
934+
enum hid_report_type type, unsigned int id,
941935
unsigned int field_index,
942936
unsigned int report_counts);
943937

@@ -1106,10 +1100,11 @@ void hid_hw_stop(struct hid_device *hdev);
11061100
int __must_check hid_hw_open(struct hid_device *hdev);
11071101
void hid_hw_close(struct hid_device *hdev);
11081102
void hid_hw_request(struct hid_device *hdev,
1109-
struct hid_report *report, int reqtype);
1103+
struct hid_report *report, enum hid_class_request reqtype);
11101104
int hid_hw_raw_request(struct hid_device *hdev,
11111105
unsigned char reportnum, __u8 *buf,
1112-
size_t len, unsigned char rtype, int reqtype);
1106+
size_t len, enum hid_report_type rtype,
1107+
enum hid_class_request reqtype);
11131108
int hid_hw_output_report(struct hid_device *hdev, __u8 *buf, size_t len);
11141109

11151110
/**
@@ -1137,7 +1132,7 @@ static inline int hid_hw_power(struct hid_device *hdev, int level)
11371132
* @reqtype: hid request type
11381133
*/
11391134
static inline int hid_hw_idle(struct hid_device *hdev, int report, int idle,
1140-
int reqtype)
1135+
enum hid_class_request reqtype)
11411136
{
11421137
if (hdev->ll_driver->idle)
11431138
return hdev->ll_driver->idle(hdev, report, idle, reqtype);
@@ -1182,8 +1177,8 @@ static inline u32 hid_report_len(struct hid_report *report)
11821177
return DIV_ROUND_UP(report->size, 8) + (report->id > 0);
11831178
}
11841179

1185-
int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size,
1186-
int interrupt);
1180+
int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *data, u32 size,
1181+
int interrupt);
11871182

11881183
/* HID quirks API */
11891184
unsigned long hid_lookup_quirk(const struct hid_device *hdev);

include/uapi/linux/hid.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,30 @@
4242
#define USB_INTERFACE_PROTOCOL_KEYBOARD 1
4343
#define USB_INTERFACE_PROTOCOL_MOUSE 2
4444

45+
/*
46+
* HID report types --- Ouch! HID spec says 1 2 3!
47+
*/
48+
49+
enum hid_report_type {
50+
HID_INPUT_REPORT = 0,
51+
HID_OUTPUT_REPORT = 1,
52+
HID_FEATURE_REPORT = 2,
53+
54+
HID_REPORT_TYPES,
55+
};
56+
4557
/*
4658
* HID class requests
4759
*/
4860

49-
#define HID_REQ_GET_REPORT 0x01
50-
#define HID_REQ_GET_IDLE 0x02
51-
#define HID_REQ_GET_PROTOCOL 0x03
52-
#define HID_REQ_SET_REPORT 0x09
53-
#define HID_REQ_SET_IDLE 0x0A
54-
#define HID_REQ_SET_PROTOCOL 0x0B
61+
enum hid_class_request {
62+
HID_REQ_GET_REPORT = 0x01,
63+
HID_REQ_GET_IDLE = 0x02,
64+
HID_REQ_GET_PROTOCOL = 0x03,
65+
HID_REQ_SET_REPORT = 0x09,
66+
HID_REQ_SET_IDLE = 0x0A,
67+
HID_REQ_SET_PROTOCOL = 0x0B,
68+
};
5569

5670
/*
5771
* HID class descriptor types

0 commit comments

Comments
 (0)