Skip to content

Commit 1685192

Browse files
committed
hkbd: remove erorr detection in KDSKBSTATE ioctl
The KDSKBSTATE ioctl brings the LED up. However, some keyboards (like qemu keyboard) may not have LED or failed to set the LED due to unexpected reason. Therefore, removing the error check as ukbd(4) does allow the keyboard works correctly with kbdcontrol(4). Also move hw.hid.hkbd.no_leds sysctl out of HID_BUG thus users can disable setting LEDs PR: 288968 Reviewed by: wulf Tested by: trashcan@ellael.org, marklmi26-fbsd@yahoo.com, trkellers@gmail.coom Approved by: lwsu (mentor), markj (mentor) MFC after 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52101 mvalsmva
1 parent 649e8a3 commit 1685192

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

sys/dev/hid/hkbd.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,16 @@
9595

9696
#ifdef HID_DEBUG
9797
static int hkbd_debug = 0;
98+
#endif
9899
static int hkbd_no_leds = 0;
99100

100101
static SYSCTL_NODE(_hw_hid, OID_AUTO, hkbd, CTLFLAG_RW, 0, "USB keyboard");
102+
#ifdef HID_DEBUG
101103
SYSCTL_INT(_hw_hid_hkbd, OID_AUTO, debug, CTLFLAG_RWTUN,
102104
&hkbd_debug, 0, "Debug level");
105+
#endif
103106
SYSCTL_INT(_hw_hid_hkbd, OID_AUTO, no_leds, CTLFLAG_RWTUN,
104107
&hkbd_no_leds, 0, "Disables setting of keyboard leds");
105-
#endif
106108

107109
#define INPUT_EPOCH global_epoch_preempt
108110

@@ -1596,8 +1598,16 @@ hkbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
15961598
sc->sc_state &= ~LOCK_MASK;
15971599
sc->sc_state |= *(int *)arg;
15981600

1599-
/* set LEDs and quit */
1600-
return (hkbd_ioctl_locked(kbd, KDSETLED, arg));
1601+
/*
1602+
* Attempt to set the keyboard LEDs; ignore the return value
1603+
* intentionally. Note: Some hypervisors/emulators (e.g., QEMU,
1604+
* Parallels—at least as of the time of writing) may fail when
1605+
* setting LEDs. This can prevent kbdmux from attaching the
1606+
* keyboard, which in turn may block the console from accessing
1607+
* it.
1608+
*/
1609+
(void)hkbd_ioctl_locked(kbd, KDSETLED, arg);
1610+
return (0);
16011611

16021612
case KDSETREPEAT: /* set keyboard repeat rate (new
16031613
* interface) */
@@ -1766,10 +1776,8 @@ hkbd_set_leds(struct hkbd_softc *sc, uint8_t leds)
17661776
SYSCONS_LOCK_ASSERT();
17671777
DPRINTF("leds=0x%02x\n", leds);
17681778

1769-
#ifdef HID_DEBUG
17701779
if (hkbd_no_leds)
17711780
return (0);
1772-
#endif
17731781

17741782
memset(sc->sc_buffer, 0, HKBD_BUFFER_SIZE);
17751783

@@ -1820,6 +1828,7 @@ hkbd_set_leds(struct hkbd_softc *sc, uint8_t leds)
18201828
SYSCONS_UNLOCK();
18211829
error = hid_write(sc->sc_dev, buf, len);
18221830
SYSCONS_LOCK();
1831+
DPRINTF(("error %d", error));
18231832

18241833
return (error);
18251834
}

0 commit comments

Comments
 (0)