]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
gpio/pinctrl: sunxi: stop poking around in private vars
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 11 Feb 2016 19:16:45 +0000 (20:16 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 11 Feb 2016 19:29:45 +0000 (20:29 +0100)
This kind of hacks disturbs the refactoring of the gpiolib.

The descriptor table belongs to the gpiolib, if we want to know
something about something in it, use or define the proper accessor
functions. Let's add this gpiochip_lins_is_irq() to do what the
sunxi driver is trying at so we can privatize the descriptors
properly.

Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c
drivers/pinctrl/sunxi/pinctrl-sunxi.c
include/linux/gpio/driver.h

index f3fcd415a77b7ed4a358271c6995510b8fbc05d9..ff8d55ad790c32464966b9f9c79271bfc23fe210 100644 (file)
@@ -1857,6 +1857,15 @@ void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset)
 }
 EXPORT_SYMBOL_GPL(gpiochip_unlock_as_irq);
 
+bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset)
+{
+       if (offset >= chip->ngpio)
+               return false;
+
+       return test_bit(FLAG_USED_AS_IRQ, &chip->gpiodev->descs[offset].flags);
+}
+EXPORT_SYMBOL_GPL(gpiochip_line_is_irq);
+
 /**
  * gpiod_get_raw_value_cansleep() - return a gpio's raw value
  * @desc: gpio whose value will be returned
index 7a2465f5e71e67c7e06f78dac19f850e2c01ba1f..3e95bfe66a061db634f9af9be7fab337025ba118 100644 (file)
@@ -457,8 +457,8 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
        struct sunxi_pinctrl *pctl = gpiochip_get_data(chip);
        u32 reg = sunxi_data_reg(offset);
        u8 index = sunxi_data_offset(offset);
-       u32 set_mux = pctl->desc->irq_read_needs_mux &&
-                       test_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags);
+       bool set_mux = pctl->desc->irq_read_needs_mux &&
+               gpiochip_line_is_irq(chip, offset);
        u32 val;
 
        if (set_mux)
index bfc842c2fc574d9b3fcf041f08797f3a91fb03f6..41c6144c473b1c8d2abd7be7b617044bedab4cc1 100644 (file)
@@ -208,6 +208,7 @@ extern struct gpio_chip *gpiochip_find(void *data,
 /* lock/unlock as IRQ */
 int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
 void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
+bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset);
 
 /* get driver data */
 static inline void *gpiochip_get_data(struct gpio_chip *chip)