gpio: pch: Optimize pch_gpio_get()
authorJean Delvare <jdelvare@suse.de>
Tue, 5 Jan 2016 13:23:47 +0000 (14:23 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 5 Jan 2016 14:46:34 +0000 (15:46 +0100)
The double negation is costly and can be avoided by shifting the
register value before masking the requested bit.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-pch.c

index 0475782..7c7135d 100644 (file)
@@ -127,7 +127,7 @@ static int pch_gpio_get(struct gpio_chip *gpio, unsigned nr)
 {
        struct pch_gpio *chip = gpiochip_get_data(gpio);
 
-       return !!(ioread32(&chip->reg->pi) & (1 << nr));
+       return (ioread32(&chip->reg->pi) >> nr) & 1;
 }
 
 static int pch_gpio_direction_output(struct gpio_chip *gpio, unsigned nr,