Skip to content

Commit 9037968

Browse files
author
Jiri Kosina
committed
Merge branch 'for-6.13/bpf' into for-linus
- improvement of the way hid-bpf coexists with specific drivers (others than hid-generic) that are already bound to devices (Benjamin Tissoires)
2 parents ffca1be + b6d8c47 commit 9037968

17 files changed

Lines changed: 709 additions & 202 deletions

drivers/hid/bpf/hid_bpf_dispatch.c

Lines changed: 6 additions & 3 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, const u8 *rdesc, unsigned int *size)
151+
const 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 = {
@@ -183,7 +183,7 @@ u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, const u8 *rdesc, unsigned
183183

184184
ignore_bpf:
185185
kfree(ctx_kern.data);
186-
return kmemdup(rdesc, *size, GFP_KERNEL);
186+
return rdesc;
187187
}
188188
EXPORT_SYMBOL_GPL(call_hid_bpf_rdesc_fixup);
189189

@@ -260,8 +260,11 @@ int hid_bpf_allocate_event_data(struct hid_device *hdev)
260260

261261
int hid_bpf_reconnect(struct hid_device *hdev)
262262
{
263-
if (!test_and_set_bit(ffs(HID_STAT_REPROBED), &hdev->status))
263+
if (!test_and_set_bit(ffs(HID_STAT_REPROBED), &hdev->status)) {
264+
/* trigger call to call_hid_bpf_rdesc_fixup() during the next probe */
265+
hdev->bpf_rsize = 0;
264266
return device_reprobe(&hdev->dev);
267+
}
265268

266269
return 0;
267270
}

drivers/hid/bpf/hid_bpf_struct_ops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ static int hid_bpf_ops_btf_struct_access(struct bpf_verifier_log *log,
7979
WRITE_RANGE(hid_device, name, true),
8080
WRITE_RANGE(hid_device, uniq, true),
8181
WRITE_RANGE(hid_device, phys, true),
82+
WRITE_RANGE(hid_device, quirks, false),
8283
};
8384
#undef WRITE_RANGE
8485
const struct btf_type *state = NULL;

drivers/hid/bpf/progs/Huion__Dial-2.bpf.c

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ static const __u8 fixed_rdesc_pad[] = {
214214
CollectionApplication(
215215
// -- Byte 0 in report
216216
ReportId(PAD_REPORT_ID)
217-
LogicalRange_i8(0, 1)
217+
LogicalMaximum_i8(0)
218+
LogicalMaximum_i8(1)
218219
UsagePage_Digitizers
219220
Usage_Dig_TabletFunctionKeys
220221
CollectionPhysical(
@@ -234,14 +235,17 @@ static const __u8 fixed_rdesc_pad[] = {
234235
Input(Var|Abs)
235236
// Byte 4 in report is the dial
236237
Usage_GD_Wheel
237-
LogicalRange_i8(-1, 1)
238+
LogicalMinimum_i8(-1)
239+
LogicalMaximum_i8(1)
238240
ReportCount(1)
239241
ReportSize(8)
240242
Input(Var|Rel)
241243
// Byte 5 is the button state
242244
UsagePage_Button
243-
UsageRange_i8(0x01, 0x8)
244-
LogicalRange_i8(0x0, 0x1)
245+
UsageMinimum_i8(0x01)
246+
UsageMaximum_i8(0x08)
247+
LogicalMinimum_i8(0x0)
248+
LogicalMaximum_i8(0x1)
245249
ReportCount(7)
246250
ReportSize(1)
247251
Input(Var|Abs)
@@ -265,7 +269,8 @@ static const __u8 fixed_rdesc_pen[] = {
265269
Usage_Dig_TipSwitch
266270
Usage_Dig_BarrelSwitch
267271
Usage_Dig_SecondaryBarrelSwitch // maps eraser to BTN_STYLUS2
268-
LogicalRange_i8(0, 1)
272+
LogicalMinimum_i8(0)
273+
LogicalMaximum_i8(1)
269274
ReportSize(1)
270275
ReportCount(3)
271276
Input(Var|Abs)
@@ -280,22 +285,28 @@ static const __u8 fixed_rdesc_pen[] = {
280285
UsagePage_GenericDesktop
281286
Unit(cm)
282287
UnitExponent(-1)
283-
PhysicalRange_i16(0, 266)
284-
LogicalRange_i16(0, 32767)
288+
PhysicalMinimum_i16(0)
289+
PhysicalMaximum_i16(266)
290+
LogicalMinimum_i16(0)
291+
LogicalMaximum_i16(32767)
285292
Usage_GD_X
286293
Input(Var|Abs) // Bytes 2+3
287-
PhysicalRange_i16(0, 166)
288-
LogicalRange_i16(0, 32767)
294+
PhysicalMinimum_i16(0)
295+
PhysicalMaximum_i16(166)
296+
LogicalMinimum_i16(0)
297+
LogicalMaximum_i16(32767)
289298
Usage_GD_Y
290299
Input(Var|Abs) // Bytes 4+5
291300
)
292301
UsagePage_Digitizers
293302
Usage_Dig_TipPressure
294-
LogicalRange_i16(0, 8191)
303+
LogicalMinimum_i16(0)
304+
LogicalMaximum_i16(8191)
295305
Input(Var|Abs) // Byte 6+7
296306
ReportSize(8)
297307
ReportCount(2)
298-
LogicalRange_i8(-60, 60)
308+
LogicalMinimum_i8(-60)
309+
LogicalMaximum_i8(60)
299310
Usage_Dig_XTilt
300311
Usage_Dig_YTilt
301312
Input(Var|Abs) // Byte 8+9
@@ -313,7 +324,8 @@ static const __u8 fixed_rdesc_vendor[] = {
313324
Usage_Dig_Pen
314325
CollectionPhysical(
315326
// Byte 1 are the buttons
316-
LogicalRange_i8(0, 1)
327+
LogicalMinimum_i8(0)
328+
LogicalMaximum_i8(1)
317329
ReportSize(1)
318330
Usage_Dig_TipSwitch
319331
Usage_Dig_BarrelSwitch
@@ -333,25 +345,31 @@ static const __u8 fixed_rdesc_vendor[] = {
333345
UnitExponent(-1)
334346
// Note: reported logical range differs
335347
// from the pen report ID for x and y
336-
LogicalRange_i16(0, 53340)
337-
PhysicalRange_i16(0, 266)
348+
LogicalMinimum_i16(0)
349+
LogicalMaximum_i16(53340)
350+
PhysicalMinimum_i16(0)
351+
PhysicalMaximum_i16(266)
338352
// Bytes 2/3 in report
339353
Usage_GD_X
340354
Input(Var|Abs)
341-
LogicalRange_i16(0, 33340)
342-
PhysicalRange_i16(0, 166)
355+
LogicalMinimum_i16(0)
356+
LogicalMaximum_i16(33340)
357+
PhysicalMinimum_i16(0)
358+
PhysicalMaximum_i16(166)
343359
// Bytes 4/5 in report
344360
Usage_GD_Y
345361
Input(Var|Abs)
346362
)
347363
// Bytes 6/7 in report
348-
LogicalRange_i16(0, 8191)
364+
LogicalMinimum_i16(0)
365+
LogicalMaximum_i16(8191)
349366
Usage_Dig_TipPressure
350367
Input(Var|Abs)
351368
// Bytes 8/9 in report
352369
ReportCount(1) // Padding
353370
Input(Const)
354-
LogicalRange_i8(-60, 60)
371+
LogicalMinimum_i8(-60)
372+
LogicalMaximum_i8(60)
355373
// Byte 10 in report
356374
Usage_Dig_XTilt
357375
// Byte 11 in report
@@ -366,7 +384,8 @@ static const __u8 fixed_rdesc_vendor[] = {
366384
CollectionApplication(
367385
// Byte 0
368386
ReportId(PAD_REPORT_ID)
369-
LogicalRange_i8(0, 1)
387+
LogicalMinimum_i8(0)
388+
LogicalMaximum_i8(1)
370389
UsagePage_Digitizers
371390
Usage_Dig_TabletFunctionKeys
372391
CollectionPhysical(
@@ -386,15 +405,18 @@ static const __u8 fixed_rdesc_vendor[] = {
386405
Input(Var|Abs)
387406
// Byte 4 is the button state
388407
UsagePage_Button
389-
UsageRange_i8(0x01, 0x8)
390-
LogicalRange_i8(0x0, 0x1)
408+
UsageMinimum_i8(0x1)
409+
UsageMaximum_i8(0x8)
410+
LogicalMinimum_i8(0x0)
411+
LogicalMaximum_i8(0x1)
391412
ReportCount(8)
392413
ReportSize(1)
393414
Input(Var|Abs)
394415
// Byte 5 is the top dial
395416
UsagePage_GenericDesktop
396417
Usage_GD_Wheel
397-
LogicalRange_i8(-1, 1)
418+
LogicalMinimum_i8(-1)
419+
LogicalMaximum_i8(1)
398420
ReportCount(1)
399421
ReportSize(8)
400422
Input(Var|Rel)

drivers/hid/bpf/progs/Huion__Inspiroy-2-S.bpf.c

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ static const __u8 fixed_rdesc_pad[] = {
170170
CollectionApplication(
171171
// -- Byte 0 in report
172172
ReportId(PAD_REPORT_ID)
173-
LogicalRange_i8(0, 1)
173+
LogicalMinimum_i8(0)
174+
LogicalMaximum_i8(1)
174175
UsagePage_Digitizers
175176
Usage_Dig_TabletFunctionKeys
176177
CollectionPhysical(
@@ -190,14 +191,17 @@ static const __u8 fixed_rdesc_pad[] = {
190191
Input(Var|Abs)
191192
// Byte 4 in report is the wheel
192193
Usage_GD_Wheel
193-
LogicalRange_i8(-1, 1)
194+
LogicalMinimum_i8(-1)
195+
LogicalMaximum_i8(1)
194196
ReportCount(1)
195197
ReportSize(8)
196198
Input(Var|Rel)
197199
// Byte 5 is the button state
198200
UsagePage_Button
199-
UsageRange_i8(0x01, 0x6)
200-
LogicalRange_i8(0x01, 0x6)
201+
UsageMinimum_i8(0x1)
202+
UsageMaximum_i8(0x6)
203+
LogicalMinimum_i8(0x1)
204+
LogicalMaximum_i8(0x6)
201205
ReportCount(1)
202206
ReportSize(8)
203207
Input(Arr|Abs)
@@ -219,7 +223,8 @@ static const __u8 fixed_rdesc_pen[] = {
219223
Usage_Dig_TipSwitch
220224
Usage_Dig_BarrelSwitch
221225
Usage_Dig_SecondaryBarrelSwitch // maps eraser to BTN_STYLUS2
222-
LogicalRange_i8(0, 1)
226+
LogicalMinimum_i8(0)
227+
LogicalMaximum_i8(1)
223228
ReportSize(1)
224229
ReportCount(3)
225230
Input(Var|Abs)
@@ -234,18 +239,23 @@ static const __u8 fixed_rdesc_pen[] = {
234239
UsagePage_GenericDesktop
235240
Unit(cm)
236241
UnitExponent(-1)
237-
PhysicalRange_i16(0, 160)
238-
LogicalRange_i16(0, 32767)
242+
PhysicalMinimum_i16(0)
243+
PhysicalMaximum_i16(160)
244+
LogicalMinimum_i16(0)
245+
LogicalMaximum_i16(32767)
239246
Usage_GD_X
240247
Input(Var|Abs) // Bytes 2+3
241-
PhysicalRange_i16(0, 100)
242-
LogicalRange_i16(0, 32767)
248+
PhysicalMinimum_i16(0)
249+
PhysicalMaximum_i16(100)
250+
LogicalMinimum_i16(0)
251+
LogicalMaximum_i16(32767)
243252
Usage_GD_Y
244253
Input(Var|Abs) // Bytes 4+5
245254
)
246255
UsagePage_Digitizers
247256
Usage_Dig_TipPressure
248-
LogicalRange_i16(0, 8191)
257+
LogicalMinimum_i16(0)
258+
LogicalMaximum_i16(8191)
249259
Input(Var|Abs) // Byte 6+7
250260
// Two bytes padding so we don't need to change the report at all
251261
ReportSize(8)
@@ -265,7 +275,8 @@ static const __u8 fixed_rdesc_vendor[] = {
265275
Usage_Dig_Pen
266276
CollectionPhysical(
267277
// Byte 1 are the buttons
268-
LogicalRange_i8(0, 1)
278+
LogicalMinimum_i8(0)
279+
LogicalMaximum_i8(1)
269280
ReportSize(1)
270281
Usage_Dig_TipSwitch
271282
Usage_Dig_BarrelSwitch
@@ -285,19 +296,24 @@ static const __u8 fixed_rdesc_vendor[] = {
285296
UnitExponent(-1)
286297
// Note: reported logical range differs
287298
// from the pen report ID for x and y
288-
LogicalRange_i16(0, 32000)
289-
PhysicalRange_i16(0, 160)
299+
LogicalMinimum_i16(0)
300+
LogicalMaximum_i16(32000)
301+
PhysicalMinimum_i16(0)
302+
PhysicalMaximum_i16(160)
290303
// Bytes 2/3 in report
291304
Usage_GD_X
292305
Input(Var|Abs)
293-
LogicalRange_i16(0, 20000)
294-
PhysicalRange_i16(0, 100)
306+
LogicalMinimum_i16(0)
307+
LogicalMaximum_i16(20000)
308+
PhysicalMinimum_i16(0)
309+
PhysicalMaximum_i16(100)
295310
// Bytes 4/5 in report
296311
Usage_GD_Y
297312
Input(Var|Abs)
298313
)
299314
// Bytes 6/7 in report
300-
LogicalRange_i16(0, 8192)
315+
LogicalMinimum_i16(0)
316+
LogicalMaximum_i16(8192)
301317
Usage_Dig_TipPressure
302318
Input(Var|Abs)
303319
)
@@ -307,7 +323,8 @@ static const __u8 fixed_rdesc_vendor[] = {
307323
CollectionApplication(
308324
// Byte 0
309325
ReportId(PAD_REPORT_ID)
310-
LogicalRange_i8(0, 1)
326+
LogicalMinimum_i8(0)
327+
LogicalMaximum_i8(1)
311328
UsagePage_Digitizers
312329
Usage_Dig_TabletFunctionKeys
313330
CollectionPhysical(
@@ -327,8 +344,10 @@ static const __u8 fixed_rdesc_vendor[] = {
327344
Input(Var|Abs)
328345
// Byte 4 is the button state
329346
UsagePage_Button
330-
UsageRange_i8(0x01, 0x6)
331-
LogicalRange_i8(0x0, 0x1)
347+
UsageMinimum_i8(0x1)
348+
UsageMaximum_i8(0x6)
349+
LogicalMinimum_i8(0x0)
350+
LogicalMaximum_i8(0x1)
332351
ReportCount(6)
333352
ReportSize(1)
334353
Input(Var|Abs)
@@ -337,7 +356,8 @@ static const __u8 fixed_rdesc_vendor[] = {
337356
// Byte 5 is the wheel
338357
UsagePage_GenericDesktop
339358
Usage_GD_Wheel
340-
LogicalRange_i8(-1, 1)
359+
LogicalMinimum_i8(-1)
360+
LogicalMaximum_i8(1)
341361
ReportCount(1)
342362
ReportSize(8)
343363
Input(Var|Rel)

0 commit comments

Comments
 (0)