Skip to content

Commit 22380b5

Browse files
author
Jiri Kosina
committed
Merge branch 'for-6.13/core' into for-linus
- assorted cleanups and small code fixes (Dmitry Torokhov, Yan Zhen, Nathan Chancellor, Andy Shevchenko)
2 parents 359bfdc + 7b2daa6 commit 22380b5

11 files changed

Lines changed: 55 additions & 75 deletions

File tree

drivers/hid/hid-asus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ static const __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
11831183

11841184
if (drvdata->quirks & QUIRK_G752_KEYBOARD &&
11851185
*rsize == 75 && rdesc[61] == 0x15 && rdesc[62] == 0x00) {
1186-
/* report is missing usage mninum and maximum */
1186+
/* report is missing usage minimum and maximum */
11871187
__u8 *new_rdesc;
11881188
size_t new_size = *rsize + sizeof(asus_g752_fixed_rdesc);
11891189

drivers/hid/hid-core.c

Lines changed: 40 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,34 @@ static int hid_ignore_special_drivers = 0;
4545
module_param_named(ignore_special_drivers, hid_ignore_special_drivers, int, 0600);
4646
MODULE_PARM_DESC(ignore_special_drivers, "Ignore any special drivers and handle all devices by generic driver");
4747

48+
/*
49+
* Convert a signed n-bit integer to signed 32-bit integer.
50+
*/
51+
52+
static s32 snto32(__u32 value, unsigned int n)
53+
{
54+
if (!value || !n)
55+
return 0;
56+
57+
if (n > 32)
58+
n = 32;
59+
60+
return sign_extend32(value, n - 1);
61+
}
62+
63+
/*
64+
* Convert a signed 32-bit integer to a signed n-bit integer.
65+
*/
66+
67+
static u32 s32ton(__s32 value, unsigned int n)
68+
{
69+
s32 a = value >> (n - 1);
70+
71+
if (a && a != -1)
72+
return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
73+
return value & ((1 << n) - 1);
74+
}
75+
4876
/*
4977
* Register a new report for a device.
5078
*/
@@ -425,7 +453,7 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
425453
* both this and the standard encoding. */
426454
raw_value = item_sdata(item);
427455
if (!(raw_value & 0xfffffff0))
428-
parser->global.unit_exponent = hid_snto32(raw_value, 4);
456+
parser->global.unit_exponent = snto32(raw_value, 4);
429457
else
430458
parser->global.unit_exponent = raw_value;
431459
return 0;
@@ -754,35 +782,29 @@ static const u8 *fetch_item(const __u8 *start, const __u8 *end, struct hid_item
754782
}
755783

756784
item->format = HID_ITEM_FORMAT_SHORT;
757-
item->size = b & 3;
785+
item->size = BIT(b & 3) >> 1; /* 0, 1, 2, 3 -> 0, 1, 2, 4 */
786+
787+
if (end - start < item->size)
788+
return NULL;
758789

759790
switch (item->size) {
760791
case 0:
761-
return start;
792+
break;
762793

763794
case 1:
764-
if ((end - start) < 1)
765-
return NULL;
766-
item->data.u8 = *start++;
767-
return start;
795+
item->data.u8 = *start;
796+
break;
768797

769798
case 2:
770-
if ((end - start) < 2)
771-
return NULL;
772799
item->data.u16 = get_unaligned_le16(start);
773-
start = (__u8 *)((__le16 *)start + 1);
774-
return start;
800+
break;
775801

776-
case 3:
777-
item->size++;
778-
if ((end - start) < 4)
779-
return NULL;
802+
case 4:
780803
item->data.u32 = get_unaligned_le32(start);
781-
start = (__u8 *)((__le32 *)start + 1);
782-
return start;
804+
break;
783805
}
784806

785-
return NULL;
807+
return start + item->size;
786808
}
787809

788810
static void hid_scan_input_usage(struct hid_parser *parser, u32 usage)
@@ -1315,46 +1337,6 @@ int hid_open_report(struct hid_device *device)
13151337
}
13161338
EXPORT_SYMBOL_GPL(hid_open_report);
13171339

1318-
/*
1319-
* Convert a signed n-bit integer to signed 32-bit integer. Common
1320-
* cases are done through the compiler, the screwed things has to be
1321-
* done by hand.
1322-
*/
1323-
1324-
static s32 snto32(__u32 value, unsigned n)
1325-
{
1326-
if (!value || !n)
1327-
return 0;
1328-
1329-
if (n > 32)
1330-
n = 32;
1331-
1332-
switch (n) {
1333-
case 8: return ((__s8)value);
1334-
case 16: return ((__s16)value);
1335-
case 32: return ((__s32)value);
1336-
}
1337-
return value & (1 << (n - 1)) ? value | (~0U << n) : value;
1338-
}
1339-
1340-
s32 hid_snto32(__u32 value, unsigned n)
1341-
{
1342-
return snto32(value, n);
1343-
}
1344-
EXPORT_SYMBOL_GPL(hid_snto32);
1345-
1346-
/*
1347-
* Convert a signed 32-bit integer to a signed n-bit integer.
1348-
*/
1349-
1350-
static u32 s32ton(__s32 value, unsigned n)
1351-
{
1352-
s32 a = value >> (n - 1);
1353-
if (a && a != -1)
1354-
return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
1355-
return value & ((1 << n) - 1);
1356-
}
1357-
13581340
/*
13591341
* Extract/implement a data field from/to a little endian report (bit array).
13601342
*

drivers/hid/hid-debug.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,9 +3309,9 @@ static const char *keys[KEY_MAX + 1] = {
33093309
[KEY_EPG] = "EPG", [KEY_PVR] = "PVR",
33103310
[KEY_MHP] = "MHP", [KEY_LANGUAGE] = "Language",
33113311
[KEY_TITLE] = "Title", [KEY_SUBTITLE] = "Subtitle",
3312-
[KEY_ANGLE] = "Angle", [KEY_ZOOM] = "Zoom",
3312+
[KEY_ANGLE] = "Angle",
33133313
[KEY_MODE] = "Mode", [KEY_KEYBOARD] = "Keyboard",
3314-
[KEY_SCREEN] = "Screen", [KEY_PC] = "PC",
3314+
[KEY_PC] = "PC",
33153315
[KEY_TV] = "TV", [KEY_TV2] = "TV2",
33163316
[KEY_VCR] = "VCR", [KEY_VCR2] = "VCR2",
33173317
[KEY_SAT] = "Sat", [KEY_SAT2] = "Sat2",
@@ -3409,8 +3409,7 @@ static const char *keys[KEY_MAX + 1] = {
34093409
[BTN_TRIGGER_HAPPY35] = "TriggerHappy35", [BTN_TRIGGER_HAPPY36] = "TriggerHappy36",
34103410
[BTN_TRIGGER_HAPPY37] = "TriggerHappy37", [BTN_TRIGGER_HAPPY38] = "TriggerHappy38",
34113411
[BTN_TRIGGER_HAPPY39] = "TriggerHappy39", [BTN_TRIGGER_HAPPY40] = "TriggerHappy40",
3412-
[BTN_DIGI] = "Digi", [BTN_STYLUS3] = "Stylus3",
3413-
[BTN_TOOL_QUINTTAP] = "ToolQuintTap", [BTN_WHEEL] = "Wheel",
3412+
[BTN_STYLUS3] = "Stylus3", [BTN_TOOL_QUINTTAP] = "ToolQuintTap",
34143413
[KEY_10CHANNELSDOWN] = "10ChannelsDown",
34153414
[KEY_10CHANNELSUP] = "10ChannelsUp",
34163415
[KEY_3D_MODE] = "3DMode", [KEY_ADDRESSBOOK] = "Addressbook",
@@ -3440,7 +3439,7 @@ static const char *keys[KEY_MAX + 1] = {
34403439
[KEY_FN_RIGHT_SHIFT] = "FnRightShift", [KEY_FRAMEBACK] = "FrameBack",
34413440
[KEY_FRAMEFORWARD] = "FrameForward", [KEY_FULL_SCREEN] = "FullScreen",
34423441
[KEY_GAMES] = "Games", [KEY_GRAPHICSEDITOR] = "GraphicsEditor",
3443-
[KEY_HANGEUL] = "HanGeul", [KEY_HANGUP_PHONE] = "HangUpPhone",
3442+
[KEY_HANGUP_PHONE] = "HangUpPhone",
34443443
[KEY_IMAGES] = "Images", [KEY_KBD_LCD_MENU1] = "KbdLcdMenu1",
34453444
[KEY_KBD_LCD_MENU2] = "KbdLcdMenu2", [KEY_KBD_LCD_MENU3] = "KbdLcdMenu3",
34463445
[KEY_KBD_LCD_MENU4] = "KbdLcdMenu4", [KEY_KBD_LCD_MENU5] = "KbdLcdMenu5",

drivers/hid/hid-logitech-hidpp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,7 +2498,7 @@ static void hidpp_ff_work_handler(struct work_struct *w)
24982498
/* regular effect destroyed */
24992499
data->effect_ids[wd->params[0]-1] = -1;
25002500
else if (wd->effect_id >= HIDPP_FF_EFFECTID_AUTOCENTER)
2501-
/* autocenter spring destoyed */
2501+
/* autocenter spring destroyed */
25022502
data->slot_autocenter = 0;
25032503
break;
25042504
case HIDPP_FF_SET_GLOBAL_GAINS:
@@ -3271,13 +3271,13 @@ static int m560_raw_event(struct hid_device *hdev, u8 *data, int size)
32713271
120);
32723272
}
32733273

3274-
v = hid_snto32(hid_field_extract(hdev, data+3, 0, 12), 12);
3274+
v = sign_extend32(hid_field_extract(hdev, data + 3, 0, 12), 11);
32753275
input_report_rel(hidpp->input, REL_X, v);
32763276

3277-
v = hid_snto32(hid_field_extract(hdev, data+3, 12, 12), 12);
3277+
v = sign_extend32(hid_field_extract(hdev, data + 3, 12, 12), 11);
32783278
input_report_rel(hidpp->input, REL_Y, v);
32793279

3280-
v = hid_snto32(data[6], 8);
3280+
v = sign_extend32(data[6], 7);
32813281
if (v != 0)
32823282
hidpp_scroll_counter_handle_scroll(hidpp->input,
32833283
&hidpp->vertical_wheel_counter, v);

drivers/hid/hid-picolcd_fb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static void picolcd_fb_destroy(struct fb_info *info)
296296
/* make sure no work is deferred */
297297
fb_deferred_io_cleanup(info);
298298

299-
/* No thridparty should ever unregister our framebuffer! */
299+
/* No thirdparty should ever unregister our framebuffer! */
300300
WARN_ON(fbdata->picolcd != NULL);
301301

302302
vfree((u8 *)info->fix.smem_start);

drivers/hid/hid-sensor-custom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ hid_sensor_register_platform_device(struct platform_device *pdev,
946946

947947
memcpy(real_usage, match->luid, 4);
948948

949-
/* usage id are all lowcase */
949+
/* usage id are all lowercase */
950950
for (c = real_usage; *c != '\0'; c++)
951951
*c = tolower(*c);
952952

drivers/hid/hid-steam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ enum
253253
ID_CONTROLLER_DECK_STATE = 9
254254
};
255255

256-
/* String attribute idenitifiers */
256+
/* String attribute identifiers */
257257
enum {
258258
ATTRIB_STR_BOARD_SERIAL,
259259
ATTRIB_STR_UNIT_SERIAL,

drivers/hid/intel-ish-hid/ishtp-fw-loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static int load_fw_from_host(struct ishtp_cl_data *client_data)
793793
if (rv < 0)
794794
goto end_err_fw_release;
795795

796-
/* Step 3: Start ISH main firmware exeuction */
796+
/* Step 3: Start ISH main firmware execution */
797797

798798
rv = ish_fw_start(client_data);
799799
if (rv < 0)

drivers/hid/intel-ish-hid/ishtp/client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ static void ipc_tx_send(void *prm)
863863
/* Send ipc fragment */
864864
ishtp_hdr.length = dev->mtu;
865865
ishtp_hdr.msg_complete = 0;
866-
/* All fregments submitted to IPC queue with no callback */
866+
/* All fragments submitted to IPC queue with no callback */
867867
ishtp_write_message(dev, &ishtp_hdr, pmsg);
868868
cl->tx_offs += dev->mtu;
869869
rem = cl_msg->send_buf.size - cl->tx_offs;

drivers/hid/usbhid/hid-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ static int usbhid_start(struct hid_device *hid)
11001100

11011101
interval = endpoint->bInterval;
11021102

1103-
/* Some vendors give fullspeed interval on highspeed devides */
1103+
/* Some vendors give fullspeed interval on highspeed devices */
11041104
if (hid->quirks & HID_QUIRK_FULLSPEED_INTERVAL &&
11051105
dev->speed == USB_SPEED_HIGH) {
11061106
interval = fls(endpoint->bInterval*8);

0 commit comments

Comments
 (0)