Skip to contentSkip to conversation

gpio: pch: Optimize pch_gpio_get()

PATCH In review Jean Delvare 2 participants 2 messages Jan 5, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: pch: Optimize pch_gpio_get()

The double negation is costly and can be avoided by shifting the register value before masking the requested bit.

---
 drivers/gpio/gpio-pch.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pch.c +1 -1
@@ -127,7 +127,7 @@ static int pch_gpio_get(struct gpio_chip
 {
 	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,
Signature · 2 lines
Jean Delvare
SUSE L3 Support