Re: [PATCH v18] tty: Fix the keyboard led light display problem

From: Dmitry Torokhov
Date: Mon Nov 29 2021 - 02:19:14 EST


Hi,

On Mon, Nov 29, 2021 at 12:04:45PM +0800, lianzhi chang wrote:
> + /*
> + * When switching VT, according to the value of kb->kbdmode,
> + * judge whether it is necessary to force the keyboard light
> + * state to be issued.
> + */
> + kb = kbd_table + fg_console;
> + if (kb->kbdmode != VC_RAW ||
> + kb->kbdmode != VC_MEDIUMRAW ||
> + kb->kbdmode != VC_OFF) {

Please do not do that. Even if kbdmode is one of those states if might
be set up to show LED pattern set by ioctls (KDSETLED), so you still
want to restore LEDs.

Also, you are trying optimize something that happens pretty infrequently
and it is really easy to get it wrong. It is much safer to let the
kernel [re]set LEDs regardless of kbdmode and then let X do its own
thing.

Thanks.

--
Dmitry