@@ -399,46 +399,60 @@ static unsigned int atkbd_compat_scancode(struct atkbd *atkbd, unsigned int code
399
399
}
400
400
401
401
/*
402
- * atkbd_interrupt(). Here takes place processing of data received from
403
- * the keyboard into events.
402
+ * Tries to handle frame or parity error by requesting the keyboard controller
403
+ * to resend the last byte. This historically not done on x86 as controllers
404
+ * there typically do not implement this command.
404
405
*/
405
-
406
- static irqreturn_t atkbd_interrupt (struct serio * serio , unsigned char data ,
407
- unsigned int flags )
406
+ static bool __maybe_unused atkbd_handle_frame_error (struct ps2dev * ps2dev ,
407
+ u8 data , unsigned int flags )
408
408
{
409
- struct atkbd * atkbd = atkbd_from_serio (serio );
410
- struct input_dev * dev = atkbd -> dev ;
411
- unsigned int code = data ;
412
- int scroll = 0 , hscroll = 0 , click = -1 ;
413
- int value ;
414
- unsigned short keycode ;
409
+ struct atkbd * atkbd = container_of (ps2dev , struct atkbd , ps2dev );
410
+ struct serio * serio = ps2dev -> serio ;
415
411
416
- dev_dbg (& serio -> dev , "Received %02x flags %02x\n" , data , flags );
417
-
418
- #if !defined(__i386__ ) && !defined (__x86_64__ )
419
- if ((flags & (SERIO_FRAME | SERIO_PARITY )) && (~flags & SERIO_TIMEOUT ) && !atkbd -> resend && atkbd -> write ) {
412
+ if ((flags & (SERIO_FRAME | SERIO_PARITY )) &&
413
+ (~flags & SERIO_TIMEOUT ) &&
414
+ !atkbd -> resend && atkbd -> write ) {
420
415
dev_warn (& serio -> dev , "Frame/parity error: %02x\n" , flags );
421
416
serio_write (serio , ATKBD_CMD_RESEND );
422
417
atkbd -> resend = true;
423
- goto out ;
418
+ return true ;
424
419
}
425
420
426
421
if (!flags && data == ATKBD_RET_ACK )
427
422
atkbd -> resend = false;
423
+
424
+ return false;
425
+ }
426
+
427
+ static enum ps2_disposition atkbd_pre_receive_byte (struct ps2dev * ps2dev ,
428
+ u8 data , unsigned int flags )
429
+ {
430
+ struct serio * serio = ps2dev -> serio ;
431
+
432
+ dev_dbg (& serio -> dev , "Received %02x flags %02x\n" , data , flags );
433
+
434
+ #if !defined(__i386__ ) && !defined (__x86_64__ )
435
+ if (atkbd_handle_frame_error (ps2dev , data , flags ))
436
+ return PS2_IGNORE ;
428
437
#endif
429
438
430
- if (unlikely (atkbd -> ps2dev .flags & PS2_FLAG_ACK ))
431
- if (ps2_handle_ack (& atkbd -> ps2dev , data ))
432
- goto out ;
439
+ return PS2_PROCESS ;
440
+ }
433
441
434
- if (unlikely (atkbd -> ps2dev .flags & PS2_FLAG_CMD ))
435
- if (ps2_handle_response (& atkbd -> ps2dev , data ))
436
- goto out ;
442
+ static void atkbd_receive_byte (struct ps2dev * ps2dev , u8 data )
443
+ {
444
+ struct serio * serio = ps2dev -> serio ;
445
+ struct atkbd * atkbd = container_of (ps2dev , struct atkbd , ps2dev );
446
+ struct input_dev * dev = atkbd -> dev ;
447
+ unsigned int code = data ;
448
+ int scroll = 0 , hscroll = 0 , click = -1 ;
449
+ int value ;
450
+ unsigned short keycode ;
437
451
438
452
pm_wakeup_event (& serio -> dev , 0 );
439
453
440
454
if (!atkbd -> enabled )
441
- goto out ;
455
+ return ;
442
456
443
457
input_event (dev , EV_MSC , MSC_RAW , code );
444
458
@@ -460,35 +474,35 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
460
474
case ATKBD_RET_BAT :
461
475
atkbd -> enabled = false;
462
476
serio_reconnect (atkbd -> ps2dev .serio );
463
- goto out ;
477
+ return ;
464
478
case ATKBD_RET_EMUL0 :
465
479
atkbd -> emul = 1 ;
466
- goto out ;
480
+ return ;
467
481
case ATKBD_RET_EMUL1 :
468
482
atkbd -> emul = 2 ;
469
- goto out ;
483
+ return ;
470
484
case ATKBD_RET_RELEASE :
471
485
atkbd -> release = true;
472
- goto out ;
486
+ return ;
473
487
case ATKBD_RET_ACK :
474
488
case ATKBD_RET_NAK :
475
489
if (printk_ratelimit ())
476
490
dev_warn (& serio -> dev ,
477
491
"Spurious %s on %s. "
478
492
"Some program might be trying to access hardware directly.\n" ,
479
493
data == ATKBD_RET_ACK ? "ACK" : "NAK" , serio -> phys );
480
- goto out ;
494
+ return ;
481
495
case ATKBD_RET_ERR :
482
496
atkbd -> err_count ++ ;
483
497
dev_dbg (& serio -> dev , "Keyboard on %s reports too many keys pressed.\n" ,
484
498
serio -> phys );
485
- goto out ;
499
+ return ;
486
500
}
487
501
488
502
code = atkbd_compat_scancode (atkbd , code );
489
503
490
504
if (atkbd -> emul && -- atkbd -> emul )
491
- goto out ;
505
+ return ;
492
506
493
507
keycode = atkbd -> keycode [code ];
494
508
@@ -564,8 +578,6 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
564
578
}
565
579
566
580
atkbd -> release = false;
567
- out :
568
- return IRQ_HANDLED ;
569
581
}
570
582
571
583
static int atkbd_set_repeat_rate (struct atkbd * atkbd )
@@ -1229,7 +1241,8 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
1229
1241
goto fail1 ;
1230
1242
1231
1243
atkbd -> dev = dev ;
1232
- ps2_init (& atkbd -> ps2dev , serio );
1244
+ ps2_init (& atkbd -> ps2dev , serio ,
1245
+ atkbd_pre_receive_byte , atkbd_receive_byte );
1233
1246
INIT_DELAYED_WORK (& atkbd -> event_work , atkbd_event_work );
1234
1247
mutex_init (& atkbd -> mutex );
1235
1248
@@ -1385,7 +1398,7 @@ static struct serio_driver atkbd_drv = {
1385
1398
},
1386
1399
.description = DRIVER_DESC ,
1387
1400
.id_table = atkbd_serio_ids ,
1388
- .interrupt = atkbd_interrupt ,
1401
+ .interrupt = ps2_interrupt ,
1389
1402
.connect = atkbd_connect ,
1390
1403
.reconnect = atkbd_reconnect ,
1391
1404
.disconnect = atkbd_disconnect ,
0 commit comments