public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexey Gladkov <legion@kernel.org>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-serial@vger.kernel.org
Subject: Re: [PATCH v1 1/2] tty/vt: Use KVAL instead of use bit operation
Date: Wed, 19 Feb 2025 12:53:39 +0100	[thread overview]
Message-ID: <Z7XGQ6muZoXmhJeD@example.org> (raw)
In-Reply-To: <8b2200ea-425d-477d-8463-d49eb1c7a66a@kernel.org>

On Wed, Feb 19, 2025 at 10:33:38AM +0100, Jiri Slaby wrote:
> On 19. 02. 25, 10:23, Alexey Gladkov wrote:
> > On Wed, Feb 19, 2025 at 07:24:52AM +0100, Jiri Slaby wrote:
> >> On 18. 02. 25, 13:29, Alexey Gladkov wrote:
> >>> The K_HANDLERS always gets KVAL as an argument. It is better to use the
> >>> KVAL macro itself instead of bit operation.
> >>>
> >>> Signed-off-by: Alexey Gladkov <legion@kernel.org>
> >>> ---
> >>>    drivers/tty/vt/keyboard.c | 4 ++--
> >>>    1 file changed, 2 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
> >>> index 804355da46f5..7df041ac4d5c 100644
> >>> --- a/drivers/tty/vt/keyboard.c
> >>> +++ b/drivers/tty/vt/keyboard.c
> >>> @@ -885,7 +885,7 @@ static void k_shift(struct vc_data *vc, unsigned char value, char up_flag)
> >>>    		if (kbd->kbdmode == VC_UNICODE)
> >>>    			to_utf8(vc, npadch_value);
> >>>    		else
> >>> -			put_queue(vc, npadch_value & 0xff);
> >>> +			put_queue(vc, KVAL(npadch_value));
> >>
> >> While the mask is the same, this is not a kval, right?
> > 
> > I'm pretty sure it's KVAL, but to be honest I don't understand why it is
> > not done for to_utf8() as well. All values passed to to_utf8() must be
> > kval.
> 
> Not at all, it handles multibyte chars.
> 
> > We call to_utf8() in k_unicode, fn_enter (through k_spec), handle_diacr
> > (through k_deadunicode or k_unicode). All K_HANDLERS take KVAL as value.
> 
> Yes, but pass unicode multibyte to to_utf8().
> 
> > If I understand this code correctly, it is more correct to write it like
> > this:
> > 
> > --- a/drivers/tty/vt/keyboard.c
> > +++ b/drivers/tty/vt/keyboard.c
> > @@ -882,10 +882,11 @@ static void k_shift(struct vc_data *vc, unsigned char value, char up_flag)
> > 
> >          /* kludge */
> >          if (up_flag && shift_state != old_state && npadch_active) {
> > +               u32 kval = KVAL(npadch_value);
> >                  if (kbd->kbdmode == VC_UNICODE)
> > -                       to_utf8(vc, npadch_value);
> > +                       to_utf8(vc, kval);
> 
> Definitely not, as you want to pass that multibyte char in.

Ok. So I misunderstood this code. I will remove this change from the next
version.

-- 
Rgrds, legion


  reply	other threads:[~2025-02-19 11:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18 12:29 [PATCH v1 0/2] tty/vt: Cleanups for keyboard driver Alexey Gladkov
2025-02-18 12:29 ` [PATCH v1 1/2] tty/vt: Use KVAL instead of use bit operation Alexey Gladkov
2025-02-19  6:24   ` Jiri Slaby
2025-02-19  9:23     ` Alexey Gladkov
2025-02-19  9:33       ` Jiri Slaby
2025-02-19 11:53         ` Alexey Gladkov [this message]
2025-02-18 12:29 ` [PATCH v1 2/2] tty/vt: Gather the code that outputs char with utf8 in mind Alexey Gladkov
2025-02-19  6:26   ` Jiri Slaby
2025-02-21 12:43 ` [PATCH v2 0/2] tty/vt: Cleanups for keyboard driver Alexey Gladkov
2025-02-21 12:43   ` [PATCH v2 1/2] tty/vt: Use KVAL instead of use bit operation Alexey Gladkov
2025-02-21 12:43   ` [PATCH v2 2/2] tty/vt: Gather the code that outputs char with utf8 in mind Alexey Gladkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z7XGQ6muZoXmhJeD@example.org \
    --to=legion@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox