From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sa.int.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.2.5 From: Petr Tesarik Organization: SUSE LINUX, s.r.o. To: kbd@lists.altlinux.org Date: Fri, 27 Jul 2012 09:05:46 +0200 User-Agent: KMail/1.13.6 (Linux/2.6.37.6-0.19-default; KDE/4.6.0; i686; ; ) References: <201207262149.05758.ptesarik@suse.cz> In-Reply-To: <201207262149.05758.ptesarik@suse.cz> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201207270905.46719.ptesarik@suse.cz> Cc: Alexey Gladkov Subject: Re: [kbd] [PATCH] setleds: add option to reset state to the BIOS default X-BeenThere: kbd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Linux console tools development discussion List-Id: Linux console tools development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2012 07:05:51 -0000 Archived-At: List-Archive: Dne =C4=8Ct 26. =C4=8Dervence 2012 21:49:05 Petr Tesarik napsal(a): > Hello Alexey and everybody, >=20 > please consider the following patch for kbd. >[...] > + bios_state =3D map[BIOS_KBD_ADDR - mapoff]; > + *cur_leds =3D 0; > + if (bios_state & BIOS_LED_SCR) > + *cur_leds |=3D LED_SCR; > + if (bios_state & BIOS_LED_NUM) > + *cur_leds |=3D LED_NUM; > + if (bios_state & BIOS_LED_CAP) > + *cur_leds |=3D LED_CAP; I've just noticed that this produces crappy code, especially given that the= =20 BIOS bits are numerically equal to the kernel bits, so a simple bitwise AND= =20 would be sufficient. Rewriting the series of conditionals into one expressi= on=20 allows GCC to optimize it: *cur_leds =3D (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