Linux console tools development discussion
 help / color / mirror / Atom feed
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
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


      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 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

Linux console tools development discussion

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/kbd/0 kbd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kbd kbd/ http://lore.altlinux.org/kbd \
		kbd@lists.altlinux.org kbd@lists.altlinux.ru kbd@lists.altlinux.com
	public-inbox-index kbd

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.kbd


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git