* [PATCH] gpio: pch: Optimize pch_gpio_get()
@ 2016-01-05 13:23 Jean Delvare
2016-01-05 14:47 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Jean Delvare @ 2016-01-05 13:23 UTC (permalink / raw)
To: linux-gpio; +Cc: Linus Walleij
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>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: pch: Optimize pch_gpio_get()
2016-01-05 13:23 [PATCH] gpio: pch: Optimize pch_gpio_get() Jean Delvare
@ 2016-01-05 14:47 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2016-01-05 14:47 UTC (permalink / raw)
To: Jean Delvare; +Cc: linux-gpio@vger.kernel.org
On Tue, Jan 5, 2016 at 2:23 PM, Jean Delvare <jdelvare@suse.de> wrote:
> 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>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-05 14:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-05 13:23 [PATCH] gpio: pch: Optimize pch_gpio_get() Jean Delvare
2016-01-05 14:47 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).