drivers/sbus/char: Micro-optimization in display7seg.c
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Thu, 19 Jun 2014 12:31:52 +0000 (14:31 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 22 Jul 2014 04:37:05 +0000 (21:37 -0700)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/sbus/char/display7seg.c

index b48899c..2b0ce7c 100644 (file)
@@ -144,10 +144,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;
        }