mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drivers/sbus/char: Micro-optimization in display7seg.c
@ 2014-06-19 12:31 Rasmus Villemoes
  2014-07-22  4:38 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Villemoes @ 2014-06-19 12:31 UTC (permalink / raw)
  To: David S. Miller, Paul Gortmaker
  Cc: sparclinux, linux-kernel, Rasmus Villemoes

Flipping a bit doesn't need four lines of code; and gcc seems to
actually generate two branches.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/sbus/char/display7seg.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
index 7c71e7b..3221dff 100644
--- a/drivers/sbus/char/display7seg.c
+++ b/drivers/sbus/char/display7seg.c
@@ -143,10 +143,7 @@ static long d7s_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	case D7SIOCTM:
 		/* toggle device mode-- flip display orientation */
-		if (regs & D7S_FLIP)
-			regs &= ~D7S_FLIP;
-		else
-			regs |= D7S_FLIP;
+		regs ^= D7S_FLIP;
 		writeb(regs, p->regs);
 		break;
 	}
-- 
1.9.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drivers/sbus/char: Micro-optimization in display7seg.c
  2014-06-19 12:31 [PATCH] drivers/sbus/char: Micro-optimization in display7seg.c Rasmus Villemoes
@ 2014-07-22  4:38 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-07-22  4:38 UTC (permalink / raw)
  To: linux; +Cc: paul.gortmaker, sparclinux, linux-kernel

From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Date: Thu, 19 Jun 2014 14:31:52 +0200

> Flipping a bit doesn't need four lines of code; and gcc seems to
> actually generate two branches.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Applied to sparc-next

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-22  4:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-19 12:31 [PATCH] drivers/sbus/char: Micro-optimization in display7seg.c Rasmus Villemoes
2014-07-22  4:38 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®