From: Petr Tesarik <ptesarik@suse.cz>
To: kbd@lists.altlinux.org
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
Subject: Re: [kbd] [PATCH] setleds: add option to reset state to the BIOS default
Date: Fri, 27 Jul 2012 09:05:46 +0200 [thread overview]
Message-ID: <201207270905.46719.ptesarik@suse.cz> (raw)
In-Reply-To: <201207262149.05758.ptesarik@suse.cz>
Dne Čt 26. července 2012 21:49:05 Petr Tesarik napsal(a):
> Hello Alexey and everybody,
>
> please consider the following patch for kbd.
>[...]
> + bios_state = map[BIOS_KBD_ADDR - mapoff];
> + *cur_leds = 0;
> + if (bios_state & BIOS_LED_SCR)
> + *cur_leds |= LED_SCR;
> + if (bios_state & BIOS_LED_NUM)
> + *cur_leds |= LED_NUM;
> + if (bios_state & BIOS_LED_CAP)
> + *cur_leds |= LED_CAP;
I've just noticed that this produces crappy code, especially given that the
BIOS bits are numerically equal to the kernel bits, so a simple bitwise AND
would be sufficient. Rewriting the series of conditionals into one expression
allows GCC to optimize it:
*cur_leds =
(bios_state & BIOS_LED_SCR ? LED_SCR : 0) |
(bios_state & BIOS_LED_NUM ? LED_NUM : 0) |
(bios_state & BIOS_LED_CAP ? LED_CAP : 0);
Let me resend v2 of the patch,
Petr Tesarik
prev parent reply other threads:[~2012-07-27 7:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-26 19:49 [kbd] [PATCH] setleds: add option to reset state to the BIOS default Petr Tesarik
2012-07-27 7:05 ` Petr Tesarik [this message]
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=201207270905.46719.ptesarik@suse.cz \
--to=ptesarik@suse.cz \
--cc=gladkov.alexey@gmail.com \
--cc=kbd@lists.altlinux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.