[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YXglWDgtWZdZhhUe@kroah.com>
Date: Tue, 26 Oct 2021 17:57:12 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: 常廉志 <changlianzhi@...ontech.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
linux-kernel <linux-kernel@...r.kernel.org>,
"dmitry.torokhov" <dmitry.torokhov@...il.com>,
jirislaby <jirislaby@...nel.org>, 282827961 <282827961@...com>
Subject: Re: [PATCH v7] tty: Fix the keyboard led light display problem
On Tue, Oct 26, 2021 at 11:41:17PM +0800, 常廉志 wrote:
> On Tue, Oct 26, 2021 at 05:23:35PM +0300, Andy Shevchenko wrote:
> > On Tue, Oct 26, 2021 at 10:40:32AM +0800, lianzhi chang wrote:
> > > Switching from the desktop environment to the tty environment,
> > > the state of the keyboard led lights and the state of the keyboard
> > > lock are inconsistent. This is because the attribute kb->kbdmode
> > > of the tty bound in the desktop environment (xorg) is set to
> >
> > Xorg
> >
> > I think I already pointed that out.
> >
> > > VC_OFF, which causes the ledstate and kb->ledflagstate
> > > values of the bound tty to always be 0, which causes the switch
> > > from the desktop When to the tty environment, the LED light
> > > status is inconsistent with the keyboard lock status.
> >
> > ...
> >
> > > +static void kbd_update_ledstate(struct input_dev *dev)
> > > +{
> > > + if (!!test_bit(LED_NUML, dev->led) !=
> > > + !!(ledstate & BIT(VC_NUMLOCK)))
> > > + ledstate ^= BIT(VC_NUMLOCK);
> > > + if (!!test_bit(LED_CAPSL, dev->led) !=
> > > + !!(ledstate & BIT(VC_CAPSLOCK)))
> > > + ledstate ^= BIT(VC_CAPSLOCK);
> > > + if (!!test_bit(LED_SCROLLL, dev->led) !=
> > > + !!(ledstate & BIT(VC_SCROLLOCK)))
> > > + ledstate ^= BIT(VC_SCROLLOCK);
> >
> > This looks ugly.
>
> I think it can be done like this:
> static void kbd_update_ledstate(struct input_dev *dev)
> {
> ledstate = (test_bit(LED_SCROLL,dev->led) ?1 :0)
> | (test_bit(LED_NUML,dev->led) ?2 :0)
> | (test_bit(LED_CAPSL,dev->led) ?3 :0)
> }
Please write code for developers to read first, and compilers second.
That ? : stuff is a mess, do not do that.
thanks,
greg k-h
Powered by blists - more mailing lists