提交 166814d8 编写于 作者: J Jean Delvare 提交者: Linus Walleij

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.
Signed-off-by: NJean Delvare <jdelvare@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 446f59ac
...@@ -127,7 +127,7 @@ static int pch_gpio_get(struct gpio_chip *gpio, unsigned nr) ...@@ -127,7 +127,7 @@ static int pch_gpio_get(struct gpio_chip *gpio, unsigned nr)
{ {
struct pch_gpio *chip = gpiochip_get_data(gpio); 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, static int pch_gpio_direction_output(struct gpio_chip *gpio, unsigned nr,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册