]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
gpio/pinctrl: sunxi: stop poking around in private vars
authorLinus Walleij <linus.walleij@linaro.org>
Wed, 26 Oct 2016 07:18:33 +0000 (15:18 +0800)
committerLuis Henriques <luis.henriques@canonical.com>
Tue, 8 Nov 2016 16:46:36 +0000 (16:46 +0000)
BugLink: http://bugs.launchpad.net/bugs/1632527
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>
(backported from commit 6cee3821e4e4bd6e6cdf0870b6c72d455460bd39)
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/gpio/gpiolib.c
drivers/pinctrl/sunxi/pinctrl-sunxi.c
include/linux/gpio/driver.h

index bee796343cc32301b8cdf5f521ed02f5c94d17f5..a40d825901b95b6f90de3617d20638b6ada2a14e 100644 (file)
@@ -1701,6 +1701,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->desc[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 a4a5b504c532a2b898cc98df06c42677ba2b79a1..3a6cdbb0d5a0e09487b9d08d3905609ff56426d2 100644 (file)
@@ -457,8 +457,8 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
        struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
        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 e3701c8e8dfbe689154c1f1ad235e03084120591..4e598d82c21938ea2504ef7149950f99d75bb848 100644 (file)
@@ -180,6 +180,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);
 
 struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);