summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-01-05 05:13:28 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-01-05 05:13:28 -0500
commit4b63739efabc93d67d2b6812dd0cd41358fadf29 (patch)
tree980fce8217893a92b5f276e7b088915378d822cb
parent13e676be085341c1161c3daf535e98ec6d5d6e3c (diff)
gpio: generic: fix signedness bug found by cppcheck
cppcheck reports this: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. This can be fixed with (1UL << pin) but that is the same as using <linux/bitops.h> that already use 1UL so take this approach. Reported-by: David Binderman <dcb314@hotmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpio-generic.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index ea581dc23d44..053a7f0a83e6 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -58,6 +58,7 @@ o ` ~~~~\___/~~~~ ` controller in FPGA is ,.`
58#include <linux/io.h> 58#include <linux/io.h>
59#include <linux/gpio.h> 59#include <linux/gpio.h>
60#include <linux/slab.h> 60#include <linux/slab.h>
61#include <linux/bitops.h>
61#include <linux/platform_device.h> 62#include <linux/platform_device.h>
62#include <linux/mod_devicetable.h> 63#include <linux/mod_devicetable.h>
63#include <linux/basic_mmio_gpio.h> 64#include <linux/basic_mmio_gpio.h>
@@ -126,13 +127,13 @@ static unsigned long bgpio_read32be(void __iomem *reg)
126 127
127static unsigned long bgpio_pin2mask(struct bgpio_chip *bgc, unsigned int pin) 128static unsigned long bgpio_pin2mask(struct bgpio_chip *bgc, unsigned int pin)
128{ 129{
129 return 1 << pin; 130 return BIT(pin);
130} 131}
131 132
132static unsigned long bgpio_pin2mask_be(struct bgpio_chip *bgc, 133static unsigned long bgpio_pin2mask_be(struct bgpio_chip *bgc,
133 unsigned int pin) 134 unsigned int pin)
134{ 135{
135 return 1 << (bgc->bits - 1 - pin); 136 return BIT(bgc->bits - 1 - pin);
136} 137}
137 138
138static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio) 139static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio)