1
- /* $OpenBSD: ihidev.c,v 1.39 2025/01/13 15:33:34 kirill Exp $ */
1
+ /* $OpenBSD: ihidev.c,v 1.40 2025/06/20 22:00:49 kettenis Exp $ */
2
2
/*
3
3
* HID-over-i2c driver
4
4
*
@@ -367,8 +367,7 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg)
367
367
int cmdlen = 7 ;
368
368
int dataoff = 4 ;
369
369
int report_id = rreq -> id ;
370
- int report_id_len = 1 ;
371
- int report_len = rreq -> len + 2 ;
370
+ int report_len = rreq -> len + 2 + 1 ;
372
371
int d ;
373
372
uint8_t * tmprep ;
374
373
@@ -386,7 +385,6 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg)
386
385
if (report_id >= 15 ) {
387
386
cmd [dataoff ++ ] = report_id ;
388
387
report_id = 15 ;
389
- report_id_len = 2 ;
390
388
} else
391
389
cmdlen -- ;
392
390
@@ -396,13 +394,12 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg)
396
394
cmd [dataoff ] = sc -> hid_desc .wDataRegister >> 8 ;
397
395
398
396
/*
399
- * 7.2.2.2 - Response will be a 2-byte length value, the report
400
- * id with length determined above , and then the report.
401
- * Allocate rreq->len + 2 + 2 bytes, read into that temporary
397
+ * 7.2.2.2 - Response will be a 2-byte length value,
398
+ * the report id , and then the report.
399
+ * Allocate rreq->len + 2 + 1 bytes, read into that temporary
402
400
* buffer, and then copy only the report back out to
403
401
* rreq->data.
404
402
*/
405
- report_len += report_id_len ;
406
403
tmprep = malloc (report_len , M_DEVBUF , M_WAITOK | M_ZERO );
407
404
408
405
/* type 3 id 8: 22 00 38 02 23 00 */
@@ -414,11 +411,7 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg)
414
411
DPRINTF (("%s: response size %d != expected length %d\n" ,
415
412
sc -> sc_dev .dv_xname , d , report_len ));
416
413
417
- if (report_id_len == 2 )
418
- d = tmprep [2 ] | tmprep [3 ] << 8 ;
419
- else
420
- d = tmprep [2 ];
421
-
414
+ d = tmprep [2 ];
422
415
if (d != rreq -> id ) {
423
416
DPRINTF (("%s: response report id %d != %d\n" ,
424
417
sc -> sc_dev .dv_xname , d , rreq -> id ));
@@ -432,7 +425,7 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg)
432
425
DPRINTF ((" %.2x" , tmprep [i ]));
433
426
DPRINTF (("\n" ));
434
427
435
- memcpy (rreq -> data , tmprep + 2 + report_id_len , rreq -> len );
428
+ memcpy (rreq -> data , tmprep + 2 + 1 , rreq -> len );
436
429
free (tmprep , M_DEVBUF , report_len );
437
430
438
431
break ;
0 commit comments