Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b63739e authored by Linus Walleij's avatar Linus Walleij
Browse files

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: default avatarDavid Binderman <dcb314@hotmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 13e676be
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ o ` ~~~~\___/~~~~ ` controller in FPGA is ,.`
#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/platform_device.h>
#include <linux/mod_devicetable.h>
#include <linux/basic_mmio_gpio.h>
@@ -126,13 +127,13 @@ static unsigned long bgpio_read32be(void __iomem *reg)

static unsigned long bgpio_pin2mask(struct bgpio_chip *bgc, unsigned int pin)
{
	return 1 << pin;
	return BIT(pin);
}

static unsigned long bgpio_pin2mask_be(struct bgpio_chip *bgc,
				       unsigned int pin)
{
	return 1 << (bgc->bits - 1 - pin);
	return BIT(bgc->bits - 1 - pin);
}

static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio)