[PATCH] gpio: pch: Optimize pch_gpio_get()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
 drivers/gpio/gpio-pch.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-4.4-rc8.orig/drivers/gpio/gpio-pch.c	2016-01-05 14:18:55.444163876 +0100
+++ linux-4.4-rc8/drivers/gpio/gpio-pch.c	2016-01-05 14:19:02.014313389 +0100
@@ -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,


-- 
Jean Delvare
SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux