diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-17 23:32:01 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-17 23:32:01 +0300 |
commit | 58cf279acac3080ce03eeea5ca268210b3165fe1 (patch) | |
tree | 54997706fbfea2cd9fd4c4044edbd8ecdc154dfb /drivers/pinctrl/intel/pinctrl-baytrail.c | |
parent | 6606b342febfd470b4a33acb73e360eeaca1d9bb (diff) | |
parent | c474e348778bdf5b453a2cdff4b2b1f9e000f343 (diff) | |
download | linux-58cf279acac3080ce03eeea5ca268210b3165fe1.tar.xz |
Merge tag 'gpio-v4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij:
"Here is the bulk of GPIO changes for v4.5.
Notably there are big refactorings mostly by myself, aimed at getting
the gpio_chip into a shape that makes me believe I can proceed to
preserve state for a proper userspace ABI (character device) that has
already been proposed once, but resulted in the feedback that I need
to go back and restructure stuff. So I've been restructuring stuff.
On the way I ran into brokenness (return code from the get_value()
callback) and had to fix it. Also, refactored generic GPIO to be
simpler.
Some of that is still waiting to trickle down from the subsystems all
over the kernel that provide random gpio_chips, I've touched every
single GPIO driver in the kernel now, oh man I didn't know I was
responsible for so much...
Apart from that we're churning along as usual.
I took some effort to test and retest so it should merge nicely and we
shook out a couple of bugs in -next.
Infrastructural changes:
- In struct gpio_chip, rename the .dev node to .parent to better
reflect the fact that this is not the GPIO struct device
abstraction. We will add that soon so this would be totallt
confusing.
- It was noted that the driver .get_value() callbacks was sometimes
reporting negative -ERR values to the gpiolib core, expecting them
to be propagated to consumer gpiod_get_value() and gpio_get_value()
calls. This was not happening, so as there was a mess of drivers
returning negative errors and some returning "anything else than
zero" to indicate that a line was active. As some would have bit
31 set to indicate "line active" it clashed with negative error
codes. This is fixed by the largeish series clamping values in all
drivers with !!value to [0,1] and then augmenting the code to
propagate error codes to consumers. (Includes some ACKed patches
in other subsystems.)
- Add a void *data pointer to struct gpio_chip. The container_of()
design pattern is indeed very nice, but we want to reform the
struct gpio_chip to be a non-volative, stateless business, and keep
states internal to the gpiolib to be able to hold on to the state
when adding a proper userspace ABI (character device) further down
the road. To achieve this, drivers need a handle at the internal
state that is not dependent on their struct gpio_chip() so we add
gpiochip_add_data() and gpiochip_get_data() following the pattern
of many other subsystems. All the "use gpiochip data pointer"
patches transforms drivers to this scheme.
- The Generic GPIO chip header has been merged into the general
<linux/gpio/driver.h> header, and the custom header for that
removed. Instead of having a separate mm_gpio_chip struct for
these generic drivers, merge that into struct gpio_chip,
simplifying the code and removing the need for separate and
confusing includes.
Misc improvements:
- Stabilize the way GPIOs are looked up from the ACPI legacy
specification.
- Incremental driver features for PXA, PCA953X, Lantiq (patches from
the OpenWRT community), RCAR, Zynq, PL061, 104-idi-48
New drivers:
- Add a GPIO chip to the ALSA SoC AC97 driver.
- Add a new Broadcom NSP SoC driver (this lands in the pinctrl dir,
but the branch is merged here too to account for infrastructural
changes).
- The sx150x driver now supports the sx1502"
* tag 'gpio-v4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (220 commits)
gpio: generic: make bgpio_pdata always visible
gpiolib: fix chip order in gpio list
gpio: mpc8xxx: Do not use gpiochip_get_data() in mpc8xxx_gpio_save_regs()
gpio: mm-lantiq: Do not use gpiochip_get_data() in ltq_mm_save_regs()
gpio: brcmstb: Allow building driver for BMIPS_GENERIC
gpio: brcmstb: Set endian flags for big-endian MIPS
gpio: moxart: fix build regression
gpio: xilinx: Do not use gpiochip_get_data() in xgpio_save_regs()
leds: pca9532: use gpiochip data pointer
leds: tca6507: use gpiochip data pointer
hid: cp2112: use gpiochip data pointer
bcma: gpio: use gpiochip data pointer
avr32: gpio: use gpiochip data pointer
video: fbdev: via: use gpiochip data pointer
gpio: pch: Optimize pch_gpio_get()
Revert "pinctrl: lantiq: Implement gpio_chip.to_irq"
pinctrl: nsp-gpio: use gpiochip data pointer
pinctrl: vt8500-wmt: use gpiochip data pointer
pinctrl: exynos5440: use gpiochip data pointer
pinctrl: at91-pio4: use gpiochip data pointer
...
Diffstat (limited to 'drivers/pinctrl/intel/pinctrl-baytrail.c')
-rw-r--r-- | drivers/pinctrl/intel/pinctrl-baytrail.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index b59ce75b1947..21b79a446d5a 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c @@ -20,7 +20,7 @@ #include <linux/types.h> #include <linux/bitops.h> #include <linux/interrupt.h> -#include <linux/gpio.h> +#include <linux/gpio/driver.h> #include <linux/acpi.h> #include <linux/platform_device.h> #include <linux/seq_file.h> @@ -147,12 +147,10 @@ struct byt_gpio { struct byt_gpio_pin_context *saved_context; }; -#define to_byt_gpio(c) container_of(c, struct byt_gpio, chip) - static void __iomem *byt_gpio_reg(struct gpio_chip *chip, unsigned offset, int reg) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); u32 reg_offset; if (reg == BYT_INT_STAT_REG) @@ -193,7 +191,7 @@ static u32 byt_get_gpio_mux(struct byt_gpio *vg, unsigned offset) static int byt_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); void __iomem *reg = byt_gpio_reg(chip, offset, BYT_CONF0_REG); u32 value, gpio_mux; unsigned long flags; @@ -229,7 +227,7 @@ static int byt_gpio_request(struct gpio_chip *chip, unsigned offset) static void byt_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); byt_gpio_clear_triggering(vg, offset); pm_runtime_put(&vg->pdev->dev); @@ -237,7 +235,7 @@ static void byt_gpio_free(struct gpio_chip *chip, unsigned offset) static int byt_irq_type(struct irq_data *d, unsigned type) { - struct byt_gpio *vg = to_byt_gpio(irq_data_get_irq_chip_data(d)); + struct byt_gpio *vg = gpiochip_get_data(irq_data_get_irq_chip_data(d)); u32 offset = irqd_to_hwirq(d); u32 value; unsigned long flags; @@ -273,7 +271,7 @@ static int byt_irq_type(struct irq_data *d, unsigned type) static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) { void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -281,12 +279,12 @@ static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) val = readl(reg); raw_spin_unlock_irqrestore(&vg->lock, flags); - return val & BYT_LEVEL; + return !!(val & BYT_LEVEL); } static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); unsigned long flags; u32 old_val; @@ -305,7 +303,7 @@ static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); unsigned long flags; u32 value; @@ -324,7 +322,7 @@ static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int byt_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); void __iomem *conf_reg = byt_gpio_reg(chip, gpio, BYT_CONF0_REG); void __iomem *reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG); unsigned long flags; @@ -356,7 +354,7 @@ static int byt_gpio_direction_output(struct gpio_chip *chip, static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); int i; u32 conf0, val, offs; @@ -428,7 +426,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) static void byt_gpio_irq_handler(struct irq_desc *desc) { struct irq_data *data = irq_desc_get_irq_data(desc); - struct byt_gpio *vg = to_byt_gpio(irq_desc_get_handler_data(desc)); + struct byt_gpio *vg = gpiochip_get_data(irq_desc_get_handler_data(desc)); struct irq_chip *chip = irq_data_get_irq_chip(data); u32 base, pin; void __iomem *reg; @@ -450,7 +448,7 @@ static void byt_gpio_irq_handler(struct irq_desc *desc) static void byt_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct byt_gpio *vg = to_byt_gpio(gc); + struct byt_gpio *vg = gpiochip_get_data(gc); unsigned offset = irqd_to_hwirq(d); void __iomem *reg; @@ -463,7 +461,7 @@ static void byt_irq_ack(struct irq_data *d) static void byt_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct byt_gpio *vg = to_byt_gpio(gc); + struct byt_gpio *vg = gpiochip_get_data(gc); unsigned offset = irqd_to_hwirq(d); unsigned long flags; void __iomem *reg; @@ -498,7 +496,7 @@ static void byt_irq_unmask(struct irq_data *d) static void byt_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct byt_gpio *vg = to_byt_gpio(gc); + struct byt_gpio *vg = gpiochip_get_data(gc); byt_gpio_clear_triggering(vg, irqd_to_hwirq(d)); } @@ -598,14 +596,14 @@ static int byt_gpio_probe(struct platform_device *pdev) gc->dbg_show = byt_gpio_dbg_show; gc->base = -1; gc->can_sleep = false; - gc->dev = dev; + gc->parent = dev; #ifdef CONFIG_PM_SLEEP vg->saved_context = devm_kcalloc(&pdev->dev, gc->ngpio, sizeof(*vg->saved_context), GFP_KERNEL); #endif - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, vg); if (ret) { dev_err(&pdev->dev, "failed adding byt-gpio chip\n"); return ret; |