Bladeren bron

Merge tag 'gpio-v4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio

Pull GPIO fixes from Linus Walleij:
 "Some GPIO fixes for the v4.4 series.  Most prominent: I revert the
  error propagation from the .get() function until we can fix up all the
  drivers properly for v4.5.

   - Revert the error number propagation from the .get() vtable entry
     temporarily, until we make the proper fixes to all drivers.
   - Fix the clamping behaviour in the generic GPIO driver.
   - Driver fix for the ath79 driver"

* tag 'gpio-v4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
  gpio: revert get() to non-errorprogating behaviour
  gpio: generic: clamp values from bgpio_get_set()
  gpio: ath79: Fix the logic to clear offset bit of AR71XX_GPIO_REG_OE register
Linus Torvalds 9 jaren geleden
bovenliggende
commit
d525c13e9e
3 gewijzigde bestanden met toevoegingen van 10 en 4 verwijderingen
  1. 1 1
      drivers/gpio/gpio-ath79.c
  2. 2 2
      drivers/gpio/gpio-generic.c
  3. 7 1
      drivers/gpio/gpiolib.c

+ 1 - 1
drivers/gpio/gpio-ath79.c

@@ -113,7 +113,7 @@ static int ar934x_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
 		__raw_writel(BIT(offset), ctrl->base + AR71XX_GPIO_REG_CLEAR);
 		__raw_writel(BIT(offset), ctrl->base + AR71XX_GPIO_REG_CLEAR);
 
 
 	__raw_writel(
 	__raw_writel(
-		__raw_readl(ctrl->base + AR71XX_GPIO_REG_OE) & BIT(offset),
+		__raw_readl(ctrl->base + AR71XX_GPIO_REG_OE) & ~BIT(offset),
 		ctrl->base + AR71XX_GPIO_REG_OE);
 		ctrl->base + AR71XX_GPIO_REG_OE);
 
 
 	spin_unlock_irqrestore(&ctrl->lock, flags);
 	spin_unlock_irqrestore(&ctrl->lock, flags);

+ 2 - 2
drivers/gpio/gpio-generic.c

@@ -141,9 +141,9 @@ static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio)
 	unsigned long pinmask = bgc->pin2mask(bgc, gpio);
 	unsigned long pinmask = bgc->pin2mask(bgc, gpio);
 
 
 	if (bgc->dir & pinmask)
 	if (bgc->dir & pinmask)
-		return bgc->read_reg(bgc->reg_set) & pinmask;
+		return !!(bgc->read_reg(bgc->reg_set) & pinmask);
 	else
 	else
-		return bgc->read_reg(bgc->reg_dat) & pinmask;
+		return !!(bgc->read_reg(bgc->reg_dat) & pinmask);
 }
 }
 
 
 static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
 static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)

+ 7 - 1
drivers/gpio/gpiolib.c

@@ -1279,7 +1279,13 @@ static int _gpiod_get_raw_value(const struct gpio_desc *desc)
 	chip = desc->chip;
 	chip = desc->chip;
 	offset = gpio_chip_hwgpio(desc);
 	offset = gpio_chip_hwgpio(desc);
 	value = chip->get ? chip->get(chip, offset) : -EIO;
 	value = chip->get ? chip->get(chip, offset) : -EIO;
-	value = value < 0 ? value : !!value;
+	/*
+	 * FIXME: fix all drivers to clamp to [0,1] or return negative,
+	 * then change this to:
+	 * value = value < 0 ? value : !!value;
+	 * so we can properly propagate error codes.
+	 */
+	value = !!value;
 	trace_gpio_value(desc_to_gpio(desc), 1, value);
 	trace_gpio_value(desc_to_gpio(desc), 1, value);
 	return value;
 	return value;
 }
 }