From: Jean Delvare <jdelvare@suse.de>
To: linux-gpio@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH] gpio: pch: Optimize pch_gpio_get()
Date: Tue, 5 Jan 2016 14:23:47 +0100 [thread overview]
Message-ID: <20160105142347.72fff8f1@endymion.delvare> (raw)
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
next reply other threads:[~2016-01-05 13:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-05 13:23 Jean Delvare [this message]
2016-01-05 14:47 ` [PATCH] gpio: pch: Optimize pch_gpio_get() Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160105142347.72fff8f1@endymion.delvare \
--to=jdelvare@suse.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox