Skip to content

Commit 6cee382

Browse files
committed
gpio/pinctrl: sunxi: stop poking around in private vars
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>
1 parent 1c3cdb1 commit 6cee382

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

drivers/gpio/gpiolib.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,15 @@ void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset)
18571857
}
18581858
EXPORT_SYMBOL_GPL(gpiochip_unlock_as_irq);
18591859

1860+
bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset)
1861+
{
1862+
if (offset >= chip->ngpio)
1863+
return false;
1864+
1865+
return test_bit(FLAG_USED_AS_IRQ, &chip->gpiodev->descs[offset].flags);
1866+
}
1867+
EXPORT_SYMBOL_GPL(gpiochip_line_is_irq);
1868+
18601869
/**
18611870
* gpiod_get_raw_value_cansleep() - return a gpio's raw value
18621871
* @desc: gpio whose value will be returned

drivers/pinctrl/sunxi/pinctrl-sunxi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
457457
struct sunxi_pinctrl *pctl = gpiochip_get_data(chip);
458458
u32 reg = sunxi_data_reg(offset);
459459
u8 index = sunxi_data_offset(offset);
460-
u32 set_mux = pctl->desc->irq_read_needs_mux &&
461-
test_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags);
460+
bool set_mux = pctl->desc->irq_read_needs_mux &&
461+
gpiochip_line_is_irq(chip, offset);
462462
u32 val;
463463

464464
if (set_mux)

include/linux/gpio/driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ extern struct gpio_chip *gpiochip_find(void *data,
208208
/* lock/unlock as IRQ */
209209
int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
210210
void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
211+
bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset);
211212

212213
/* get driver data */
213214
static inline void *gpiochip_get_data(struct gpio_chip *chip)

0 commit comments

Comments
 (0)