diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-17 12:32:01 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-17 12:32:01 -0800 |
commit | 58cf279acac3080ce03eeea5ca268210b3165fe1 (patch) | |
tree | 54997706fbfea2cd9fd4c4044edbd8ecdc154dfb /drivers/gpio/gpio-dln2.c | |
parent | 6606b342febfd470b4a33acb73e360eeaca1d9bb (diff) | |
parent | c474e348778bdf5b453a2cdff4b2b1f9e000f343 (diff) | |
download | linux-58cf279acac3080ce03eeea5ca268210b3165fe1.tar.bz2 |
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/gpio/gpio-dln2.c')
-rw-r--r-- | drivers/gpio/gpio-dln2.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c index 6685712c15cf..e11a7d126e74 100644 --- a/drivers/gpio/gpio-dln2.c +++ b/drivers/gpio/gpio-dln2.c @@ -153,7 +153,7 @@ static int dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2, static int dln2_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); struct dln2_gpio_pin req = { .pin = cpu_to_le16(offset), }; @@ -194,14 +194,14 @@ out_disable: static void dln2_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); dln2_gpio_pin_cmd(dln2, DLN2_GPIO_PIN_DISABLE, offset); } static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); if (test_bit(offset, dln2->output_enabled)) return GPIOF_DIR_OUT; @@ -211,7 +211,7 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); int dir; dir = dln2_gpio_get_direction(chip, offset); @@ -226,7 +226,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset) static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); dln2_gpio_pin_set_out_val(dln2, offset, value); } @@ -234,7 +234,7 @@ static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int dln2_gpio_set_direction(struct gpio_chip *chip, unsigned offset, unsigned dir) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); struct dln2_gpio_pin_val req = { .pin = cpu_to_le16(offset), .value = dir, @@ -262,7 +262,7 @@ static int dln2_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); int ret; ret = dln2_gpio_pin_set_out_val(dln2, offset, value); @@ -275,7 +275,7 @@ static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset, static int dln2_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, unsigned debounce) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); __le32 duration = cpu_to_le32(debounce); return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_SET_DEBOUNCE, @@ -302,7 +302,7 @@ static int dln2_gpio_set_event_cfg(struct dln2_gpio *dln2, unsigned pin, static void dln2_irq_unmask(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); set_bit(pin, dln2->unmasked_irqs); @@ -311,7 +311,7 @@ static void dln2_irq_unmask(struct irq_data *irqd) static void dln2_irq_mask(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); clear_bit(pin, dln2->unmasked_irqs); @@ -320,7 +320,7 @@ static void dln2_irq_mask(struct irq_data *irqd) static int dln2_irq_set_type(struct irq_data *irqd, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); switch (type) { @@ -349,7 +349,7 @@ static int dln2_irq_set_type(struct irq_data *irqd, unsigned type) static void dln2_irq_bus_lock(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); mutex_lock(&dln2->irq_lock); } @@ -357,7 +357,7 @@ static void dln2_irq_bus_lock(struct irq_data *irqd) static void dln2_irq_bus_unlock(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); int enabled, unmasked; unsigned type; @@ -377,7 +377,7 @@ static void dln2_irq_bus_unlock(struct irq_data *irqd) ret = dln2_gpio_set_event_cfg(dln2, pin, type, 0); if (ret) - dev_err(dln2->gpio.dev, "failed to set event\n"); + dev_err(dln2->gpio.parent, "failed to set event\n"); } mutex_unlock(&dln2->irq_lock); @@ -406,19 +406,19 @@ static void dln2_gpio_event(struct platform_device *pdev, u16 echo, struct dln2_gpio *dln2 = platform_get_drvdata(pdev); if (len < sizeof(*event)) { - dev_err(dln2->gpio.dev, "short event message\n"); + dev_err(dln2->gpio.parent, "short event message\n"); return; } pin = le16_to_cpu(event->pin); if (pin >= dln2->gpio.ngpio) { - dev_err(dln2->gpio.dev, "out of bounds pin %d\n", pin); + dev_err(dln2->gpio.parent, "out of bounds pin %d\n", pin); return; } irq = irq_find_mapping(dln2->gpio.irqdomain, pin); if (!irq) { - dev_err(dln2->gpio.dev, "pin %d not mapped to IRQ\n", pin); + dev_err(dln2->gpio.parent, "pin %d not mapped to IRQ\n", pin); return; } @@ -462,7 +462,7 @@ static int dln2_gpio_probe(struct platform_device *pdev) dln2->pdev = pdev; dln2->gpio.label = "dln2"; - dln2->gpio.dev = dev; + dln2->gpio.parent = dev; dln2->gpio.owner = THIS_MODULE; dln2->gpio.base = -1; dln2->gpio.ngpio = pins; @@ -479,7 +479,7 @@ static int dln2_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dln2); - ret = gpiochip_add(&dln2->gpio); + ret = gpiochip_add_data(&dln2->gpio, dln2); if (ret < 0) { dev_err(dev, "failed to add gpio chip: %d\n", ret); goto out; |