aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpio
AgeCommit message (Collapse)AuthorFilesLines
2016-12-19Merge tag 'mfd-for-linus-4.10' of ↵Linus Torvalds1-1/+2
git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd Pull MFD updates from Lee Jones: "New Device Support - Add support for Ricoh RC5T619 PMIC to rn5t618 - Add support for PM8821 PMIC to qcom-pm8xxx New Functionality: - Add support for GPIO to lpc_ich - Add support for GPADC to sun4i - Add ability for rk808 to shutdown Fix-ups: - Simplify/strip unnecessary code; tps65218, palmas, tps65217 - Device Tree binding updates; tps65218, altera-a10sr - Provide/export device ID info; tps65218, axp20x-i2c, hi655x-pmic, fsl-imx25-tsadc, intel_soc_pmic_bxtwc - Use MFD API instead of of_platform_populate(); tps65218 - Generalise name-space; pm8xxx - Supply/edit regmap configuration; axp20x, cs47l24-tables, axp20x - Enable compile testing; max77620, max77686, exynos-lpass, abx500-core - Coding style issues; wm8994-core, wm5102-tables - Supply endian support; syscon - Remove module support; ab3100-core, ab8500-debugfs, ab8500-gpadc, abx500-core Bug Fixes: - Fix ordering issues; wm8994 - Fix dependencies (build-time/run-time); exynos_lpass, sun4i-gpadc - Fix compiler warnings; sun4i-gpadc - Fix leaks; mfd-core - Fix page fault during module unload; tps65217" * tag 'mfd-for-linus-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (49 commits) mfd: tps65217: Support an interrupt pin as the system wakeup mfd: tps65217: Make an interrupt handler simpler mfd: tps65217: Update register interrupt mask bits instead of writing operation mfd: tps65217: Specify the IRQ name mfd: tps65217: Fix page fault on unloading modules mfd: palmas: Remove redundant check in palmas_power_off mfd: arizona: Disable IRQs during driver remove mfd: pm8xxx: add support to pm8821 mfd: intel-lpss: Try to enable Memory-Write-Invalidate mfd: rn5t618: Add Ricoh RC5T619 PMIC support mfd: axp20x: Add address extension registers for AXP806 regmap mfd: intel_soc_pmic_bxtwc: Fix a typo in MODULE_DEVICE_TABLE() mfd: core: Fix device reference leak in mfd_clone_cell mfd: bcm590xx: Simplify a test mfd: sun4i-gpadc: Select regmap-irq mfd: abx500-core: drop unused MODULE_ tags from non-modular code mfd: ab8500: make sysctrl explicitly non-modular mfd: ab8500-gpadc: Make it explicitly non-modular mfd: ab8500-debugfs: Make it explicitly non-modular mfd: ab8500-core: Make it explicitly non-modular ...
2016-12-13Merge tag 'gpio-v4.10-1' of ↵Linus Torvalds31-1152/+670
git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio Pull GPIO updates from Luinus Walleij: "Bulk GPIO changes for the v4.10 kernel cycle: Core changes: - Simplify threaded interrupt handling: instead of passing numbed parameters to gpiochip_irqchip_add_chained() we create a new call: gpiochip_irqchip_add_nested() so the two types are clearly semantically different. Also make sure that all nested chips call gpiochip_set_nested_irqchip() which is necessary for IRQ resend to work properly if it happens. - Return error on seek operations for the chardev. - Clamp values set as part of gpio[d]_direction_output() so that anything != 0 will be send down to the driver as "1" not the value passed in. - ACPI can now support naming of GPIO lines, hogs and holes in the GPIO lists. New drivers: - The SX150x driver was deemed unfit for the GPIO subsystem and was moved over to a combined GPIO+pinctrl driver in the pinctrl subsystem. New features: - Various cleanups to various drivers" * tag 'gpio-v4.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (49 commits) gpio: merrifield: Implement gpio_get_direction callback gpio: merrifield: Add support for hardware debouncer gpio: chardev: Return error for seek operations gpio: arizona: Tidy up probe error path gpio: arizona: Remove pointless set of platform drvdata gpio: pl061: delete platform data handling gpio: pl061: move platform data into driver gpio: pl061: rename variable from chip to pl061 gpio: pl061: rename state container struct gpio: pl061: use local state for parent IRQ storage gpio: set explicit nesting on drivers gpio: simplify adding threaded interrupts gpio: vf610: use builtin_platform_driver gpio: axp209: use correct register for GPIO input status gpio: stmpe: fix interrupt handling bug gpio: em: depnd on ARCH_SHMOBILE gpio: zx: depend on ARCH_ZX gpio: x86: update config dependencies for x86 specific hardware gpio: mb86s7x: use builtin_platform_driver gpio: etraxfs: use builtin_platform_driver ...
2016-12-07Merge branch 'thread-irq-simpler' into develLinus Walleij11-72/+117
2016-12-07Merge branch 'pl061' into develLinus Walleij1-114/+94
2016-12-07gpio: merrifield: Implement gpio_get_direction callbackAndy Shevchenko1-0/+9
Implement gpio_get_direction() callback for Intel Merrifield GPIO. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-12-07gpio: merrifield: Add support for hardware debouncerAndy Shevchenko1-0/+22
By default all pins are configured to use a glitch filter. Writing 1 to the certain bit of the specific register might be useful in case someone needs to bypass the glitch filter completely for a given GPIO pin. This patch adds support for that in the Intel Merrifield GPIO driver. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-12-07gpio: chardev: Return error for seek operationsLars-Peter Clausen1-2/+3
The GPIO chardev is used for management tasks (allocating line and event handles) and does neither support read() nor write() operations. Hence it does not make much sense to allow seek operations. Currently the chardev uses noop_llseek() for its seek implementation. This function does not move the pointer and simply returns the current position (always 0 for the GPIO chardev). noop_llseek() is primarily meant for devices that can not support seek, but where there might be a user that depends on the seek() operation succeeding. For newly added devices that can not support seek operations it is recommended to use no_llseek(), which will return an error. For more information see commit 6038f373a3dc ("llseek: automatically add .llseek fop"). Unfortunately this was overlooked when the GPIO chardev ABI was introduced. But it is highly unlikely that since then userspace applications have appeared that rely on being able to perform non-failing seek operations on a GPIO chardev file descriptor. So it should be safe to change from noop_llseel() to no_seek(). Also use nonseekable_open() in the chardev open() callback to clear the FMODE_SEEK, FMODE_PREAD and FMODE_PWRITE flags from the file. Neither of these should be set on a file that does not support seek operations. Cc: [email protected] Fixes: 3c702e9987e2 ("gpio: add a userspace chardev ABI for GPIOs") Signed-off-by: Lars-Peter Clausen <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-12-07gpio: arizona: Tidy up probe error pathCharles Keepax1-5/+2
There is some unnecessary complexity in the error path which now things are converted to devm is actually very simple. This patch simplifies things. Signed-off-by: Charles Keepax <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-12-07gpio: arizona: Remove pointless set of platform drvdataCharles Keepax1-2/+0
We use the gpio chip private data in all the callbacks so remove this redundant line of code. Signed-off-by: Charles Keepax <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-12-07gpio: pl061: delete platform data handlingLinus Walleij1-38/+3
Platform data is a remnant of board files and all boards using the PL061 have been migrated to use device tree or ACPI instead. The custom mechanism to set line by default as inputs/outputs has been superceded by the GPIO-internal hogging mechanism. Signed-off-by: Linus Walleij <[email protected]>
2016-12-07gpio: pl061: move platform data into driverLinus Walleij1-1/+13
No boardfile defines any PL061 platform data anymore: the Integrator IM/PD-1 includes the file but is not making use of the struct. Let's delete the include and all references, then move the platform data into the driver for later consolidation into the driver state container. The only resource defined by the IM/PD-1 is the IRQ which is passed through the AMBA PrimeCell bus abstraction struct amba_device. Cc: [email protected] Cc: [email protected] Cc: Russell King <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-12-07gpio: pl061: rename variable from chip to pl061Linus Walleij1-93/+93
Rename the local variable "chip" referring to the struct pl061 state container to "pl061": we already have gpio_chip and irq_chip in the driver, we are needlessly adding yet another "chip" to the confusion. Signed-off-by: Linus Walleij <[email protected]>
2016-12-07gpio: pl061: rename state container structLinus Walleij1-15/+15
The PL061 state container is named "pl061_gpio", let's rename it to simply pl061. Less is more. Signed-off-by: Linus Walleij <[email protected]>
2016-12-07gpio: pl061: use local state for parent IRQ storageLinus Walleij1-1/+4
The driver is poking around in the struct gpio_chip internals, which is a no-no. Use a variable in the local state container. Signed-off-by: Linus Walleij <[email protected]>
2016-11-25gpio: set explicit nesting on driversLinus Walleij3-0/+6
The ADNP, CrystalCove and WhiskeyCove are all nested GPIO irqchips, but were avoiding to connect the parent IRQ to the gpiochip. This works, but is kind of sloppy as the child IRQs are not marked as having the parent IRQ as parent. Cc: Mika Westerberg <[email protected]> Cc: Ajay Thomas <[email protected]> Cc: Bin Gao <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-25gpio: simplify adding threaded interruptsLinus Walleij11-72/+111
This tries to simplify the use of CONFIG_GPIOLIB_IRQCHIP when using threaded interrupts: add a new call gpiochip_irqchip_add_nested() to indicate that we're dealing with a nested rather than a chained irqchip, then create a separate gpiochip_set_nested_irqchip() to mirror the gpiochip_set_chained_irqchip() call to connect the parent and child interrupts. In the nested case gpiochip_set_nested_irqchip() does nothing more than call irq_set_parent() on each valid child interrupt, which has little semantic effect in the kernel, but this is probably still formally correct. Update all drivers using nested interrupts to use gpiochip_irqchip_add_nested() so we can now see clearly which these users are. The DLN2 driver can drop its specific hack with .irq_not_threaded as we now recognize whether a chip is threaded or not from its use of gpiochip_irqchip_add_nested() signature rather than from inspecting .can_sleep. We rename the .irq_parent to .irq_chained_parent since this parent IRQ is only really kept around for the chained interrupt handlers. Cc: Lars Poeschel <[email protected]> Cc: Octavian Purdila <[email protected]> Cc: Daniel Baluta <[email protected]> Cc: Bin Gao <[email protected]> Cc: Mika Westerberg <[email protected]> Cc: Ajay Thomas <[email protected]> Cc: Semen Protsenko <[email protected]> Cc: Alexander Stein <[email protected]> Cc: Phil Reid <[email protected]> Cc: Bartosz Golaszewski <[email protected]> Cc: Patrice Chotard <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-24gpio: vf610: use builtin_platform_driverGeliang Tang1-5/+1
Use builtin_platform_driver() helper to simplify the code. Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-24gpio: axp209: use correct register for GPIO input statusQuentin Schulz1-6/+2
The GPIO input status was read from control register (AXP20X_GPIO[210]_CTRL) instead of status register (AXP20X_GPIO20_SS). Signed-off-by: Quentin Schulz <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-24gpio: stmpe: fix interrupt handling bugLinus Walleij1-1/+1
commit 43db289d00c6 ("gpio: stmpe: Rework registers access") reworked the STMPE register access so as to use [STMPE_IDX_*_LSB + i] to access the 8bit register for a certain bank, assuming the CSB and MSB will follow after the enumerator. For this to work the index needs to go from (size-1) to 0 not 0 to (size-1). However for the GPIO IRQ handler, the status registers we read register MSB + 3 bytes ahead for the 24 bit GPIOs and index registers from MSB upwards and run an index i over the registers UNLESS we are STMPE1600. This is not working when we get to clearing the interrupt EDGE status register STMPE_IDX_GPEDR_[LCM]SB: it is indexed like all other registers [STMPE_IDX_*_LSB + i] but in this loop we index from 0 to get the right bank index for the calculations, and we need to just add i to the MSB. Before this, interrupts on the STMPE2401 were broken, this patch fixes it so it works again. Cc: [email protected] Cc: Patrice Chotard <[email protected]> Fixes: 43db289d00c6 ("gpio: stmpe: Rework registers access") Signed-off-by: Linus Walleij <[email protected]>
2016-11-24gpio: em: depnd on ARCH_SHMOBILEPeter Robinson1-1/+1
The GPIO_EM is part of the Renesas SoCs so depend on the arch. Signed-off-by: Peter Robinson <[email protected]> [Changed to depend on ARCH_EMEV2] Signed-off-by: Linus Walleij <[email protected]>
2016-11-22gpio: zx: depend on ARCH_ZXPeter Robinson1-0/+1
Set GPIO_ZX to depend on ARCH_ZX as it's SOC specific. Signed-off-by: Peter Robinson <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-22gpio: x86: update config dependencies for x86 specific hardwarePeter Robinson1-5/+8
The devices here are specific to x86 so lets depend on x86. Signed-off-by: Peter Robinson <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-22gpio: mb86s7x: use builtin_platform_driverGeliang Tang1-5/+1
Use builtin_platform_driver() helper to simplify the code. Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-22gpio: etraxfs: use builtin_platform_driverGeliang Tang1-6/+1
Use builtin_platform_driver() helper to simplify the code. Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-16gpio: max77620: add compatible string to device id listVenkat Reddy Talla1-0/+1
Adding max20024 compatible string to the device id list to support both max77620 and max20024 devices. Signed-off-by: Venkat Reddy Talla <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-16gpio: Remove GPIO_DEVRES optionKeno Fischer2-5/+1
This option was added in 6a89a314ab107a12af08c71420c19a37a30fc2d3 to allow use of the devm_gpio_* functions without CONFIG_GPIOLIB. However, only a few months later in b69ac52449c658b7ac40034dc3c5f5f4a71a723d, CONFIG_GPIOLIB was added as a dependency, defeating the original purpose of this option. Instead of that patch, the original commit could have just been reverted (and in fact was partially so in 403c1d0be5ccbd750d25c59d8358843a81e52e3b). Further, since this option has a dependency on HAS_IOMEM, even though it does not require it, it causes build failures when !HAS_IOMEM (e.g. in a uml build). Fix that by completely removing the option, in essence completing the reversion of the original commit. Signed-off-by: Keno Fischer <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-15gpio: intel-mid: use builtin_pci_driverGeliang Tang1-6/+1
Use builtin_pci_driver() helper to simplify the code. Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-15gpio: tc3589x: fix up .get_direction()Linus Walleij1-1/+1
The bit in the TC3589x direction register is 0 for input and 1 for output, but the gpiolib expects the reverse. Fix up the logic. Cc: [email protected] Fixes: 14063d71e5e6 ("gpio: tc3589x: add .get_direction() and small cleanup") Signed-off-by: Linus Walleij <[email protected]>
2016-11-15gpio: tag line labels used for interruptsLinus Walleij1-2/+18
When a GPIO line is marked as used for an interrupt, it is helpful to set the label to "interrupt" so we know what is going on when inspecting the lines. If a GPIO is already properly named by gpiod_get*() we don't need to do this. It only happens when a line is used from the irqchip side of a GPIO driver without communicating with the GPIO side, such as when gpiochip is used as interrupt provider in the device tree. If the line is still marked as used by "interrupt" when we unmark it as used by an interrupt, also remove this label from the descriptor. Also shape up the code around unmarking IRQ lines. Signed-off-by: Linus Walleij <[email protected]>
2016-11-15gpio: clamp values on gpio[d]_direction_output()Linus Walleij1-5/+8
I saw weird values != [0,1] being passed down to drivers in their .set_direction_output() callbacks. Go over the gpiolib and make sure to hammer it to [0,1] before hitting the driver to avoid undesired side effects. Signed-off-by: Linus Walleij <[email protected]>
2016-11-15gpio: do not double-check direction on sleeping chipsLinus Walleij1-2/+5
When locking a GPIO line as IRQ, we go to lengths to double-check that the line is really set as input before marking it as used for IRQ. This is not good on GPIO chips that can sleep, because this function is called in IRQ-safe context. Just skip this if it can't be checked quickly. Currently this happens on sleeping expanders such as STMPE or TC3589x: BUG: scheduling while atomic: swapper/1/0x00000002 Modules linked in: CPU: 0 PID: 1 Comm: swapper Not tainted 4.9.0-rc1+ #38 Hardware name: Nomadik STn8815 [<c000f2e0>] (unwind_backtrace) from [<c000d244>] (show_stack+0x10/0x14) [<c000d244>] (show_stack) from [<c0037b78>] (__schedule_bug+0x54/0x80) [<c0037b78>] (__schedule_bug) from [<c042df14>] (__schedule+0x3a0/0x460) [<c042df14>] (__schedule) from [<c042e028>] (schedule+0x54/0xb8) (...) This patch fixes that problem and relies on the direction read from the chip when it was added. Cc: [email protected] Fixes: 9c10280d85c1 ("gpio: flush direction status in gpiochip_lock_as_irq()") Cc: Patrice Chotard <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-13gpio: htc-egpio: read output value from cacheLinus Walleij1-4/+8
When the hardware is in output mode, reading the value from the hardware is not giving the correct value back. Instead read the value from the cache so we get the right value. Suggested-by: Russell King <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-12gpio: htc-egpio: add .get_direction() supportLinus Walleij1-0/+10
This makes is possible to read out the current direction of a GPIO line on the HTC CPLD GPIO expander. Suggested-by: Russell King <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-09ACPI / gpio: avoid warning for gpio hogging codeArnd Bergmann1-4/+4
The newly added acpi_gpiochip_scan_gpios function produces a few harmless warnings: drivers/gpio/gpiolib-acpi.c: In function ‘acpi_gpiochip_add’: drivers/gpio/gpiolib-acpi.c:925:7: error: ‘dflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/gpio/gpiolib-acpi.c:925:9: error: ‘lflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized] The problem is that he compiler cannot know that a negative return value from fwnode_property_read_u32_array() or acpi_gpiochip_pin_to_gpio_offset() implies that the IS_ERR(gpio_desc) is true, as the value could in theory be below -MAX_ERRNO. The function already initializes its output values to zero, and moving that intialization a little higher up ensures that we can never have uninitialized data in the caller. Fixes: c80f1ba75df2 ("ACPI / gpio: Add hogging support") Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Mika Westerberg <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-09gpio: davinci: Use unique labels for each gpio chipAxel Haslam1-1/+6
The gpiod framework uses the chip label to match a specific chip. The davinci gpio driver, creates several chips using always the same label, which is not compatible with gpiod. To allow platform data to declare gpio lookup tables, and for drivers to use the gpiod framework, allocate unique label per registered chip. Signed-off-by: Axel Haslam <[email protected]> Reviewed-by: Sekhar Nori <[email protected]> Acked-by: Kevin Hilman <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-08gpio: pca953x: Move memcpy into mutex lock for set multiplePhil Reid1-2/+1
Need to ensure that reg_output is not updated while setting multiple bits. This makes the mutex locking behaviour for the set_multiple call consistent with that of the set_value call. Cc: [email protected] Fixes: b4818afeacbd ("gpio: pca953x: Add set_multiple to allow multiple") Signed-off-by: Phil Reid <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-08gpio: pca953x: Fix corruption of other gpios in set_multiple.Phil Reid1-0/+1
gpiod_set_array_value_complex does not clear the bits field. Therefore when the drivers set_multiple funciton is called bits outside the mask are undefined and can be either set or not. So bank_val needs to be masked with bank_mask before or with the reg_val cache. Cc: [email protected] Fixes: b4818afeacbd ("gpio: pca953x: Add set_multiple to allow multiple") Signed-off-by: Phil Reid <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-04gpio: htc-egpio: Make it explicitly non-modularPaul Gortmaker1-30/+2
The Kconfig currently controlling compilation of this code is: drivers/gpio/Kconfig:config HTC_EGPIO drivers/gpio/Kconfig: bool "HTC EGPIO support" ...meaning that it currently is not being built as a module by anyone. Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only. We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers. Since module_init was not in use by this code, the init ordering remains unchanged with this commit. We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments. Cc: Linus Walleij <[email protected]> Cc: Alexandre Courbot <[email protected]> Cc: Kevin O'Connor <[email protected]> Cc: [email protected] Signed-off-by: Paul Gortmaker <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-11-01gpio/mvebu: Use irq_domain_add_linearJason Gunthorpe1-49/+43
This fixes the irq allocation in this driver to not print: irq: Cannot allocate irq_descs @ IRQ34, assuming pre-allocated irq: Cannot allocate irq_descs @ IRQ66, assuming pre-allocated Which happens because the driver already called irq_alloc_descs() and so the change to use irq_domain_add_simple resulted in calling irq_alloc_descs() twice. Modernize the irq allocation in this driver to use the irq_domain_add_linear flow directly and eliminate the use of irq_domain_add_simple/legacy Fixes: ce931f571b6d ("gpio/mvebu: convert to use irq_domain_add_simple()") Signed-off-by: Jason Gunthorpe <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-10-31gpio: of: fix GPIO drivers with multiple gpio_chip for a single nodeMasahiro Yamada1-5/+9
Sylvain Lemieux reports the LPC32xx GPIO driver is broken since commit 762c2e46c059 ("gpio: of: remove of_gpiochip_and_xlate() and struct gg_data"). Probably, gpio-etraxfs.c and gpio-davinci.c are broken too. Those drivers register multiple gpio_chip that are associated to a single OF node, and their own .of_xlate() checks if the passed gpio_chip is valid. Now, the problem is of_find_gpiochip_by_node() returns the first gpio_chip found to match the given node. So, .of_xlate() fails, except for the first GPIO bank. Reverting the commit could be a solution, but I do not want to go back to the mess of struct gg_data. Another solution here is to take the match by a node pointer and the success of .of_xlate(). It is a bit clumsy to call .of_xlate twice; for gpio_chip matching and for really getting the gpio_desc index. Perhaps, our long-term goal might be to convert the drivers to single chip registration, but this commit will solve the problem until then. Fixes: 762c2e46c059 ("gpio: of: remove of_gpiochip_and_xlate() and struct gg_data") Signed-off-by: Masahiro Yamada <[email protected]> Reported-by: Sylvain Lemieux <[email protected]> Tested-by: David Lechner <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-10-31gpio: GPIO_GET_LINE{HANDLE,EVENT}_IOCTL: Fix file descriptor leakLars-Peter Clausen1-12/+45
When allocating a new line handle or event a file is allocated that it is associated to. The file is attached to a file descriptor of the current process and the file descriptor is returned to userspace using copy_to_user(). If this copy operation fails the line handle or event allocation is aborted, all acquired resources are freed and an error is returned. But the file struct is not freed and left attached to the userspace application and even though the file descriptor number was not copied it is trivial to guess. If a userspace application performs a IOCTL on such a left over file descriptor it will trigger a use-after-free and if the file descriptor is closed (latest when the application exits) a double-free is triggered. anon_inode_getfd() performs 3 tasks, allocate a file struct, allocate a file descriptor for the current process and install the file struct in the file descriptor. As soon as the file struct is installed in the file descriptor it is accessible by userspace (even if the IOCTL itself hasn't completed yet), this means uninstalling the fd on the error path is not an option, since userspace might already got a reference to the file. Instead anon_inode_getfd() needs to be broken into its individual steps. The allocation of the file struct and file descriptor is done first, then the copy_to_user() is executed and only if it succeeds the file is installed. Since the file struct is reference counted it can not be just freed, but its reference needs to be dropped, which will also call the release() callback, which will free the state attached to the file. So in this case the normal error cleanup path should not be taken. Cc: [email protected] Fixes: d932cd49182f ("gpio: free handles in fringe cases") Signed-off-by: Lars-Peter Clausen <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-10-31gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios()Wei Yongjun1-1/+3
When terminating for_each_available_child_of_node() iteration with break or return, of_node_put() should be used to prevent stale device node references from being left behind. This is detected by Coccinelle semantic patch. Signed-off-by: Wei Yongjun <[email protected]> Reviewed-by: Vladimir Zapolskiy <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-10-31ACPI / gpio: make acpi_gpiochip_parse_own_gpio staticWei Yongjun1-3/+3
Fixes the following sparse warning: drivers/gpio/gpiolib-acpi.c:863:18: warning: symbol 'acpi_gpiochip_parse_own_gpio' was not declared. Should it be static? Signed-off-by: Wei Yongjun <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-10-31ACPI / gpio: add missing fwnode_handle_put() in acpi_gpiochip_scan_gpios()Wei Yongjun1-0/+1
fwnode_handle_put() should be used when terminating device_for_each_child_node() iteration with break or return to prevent stale device node references from being left behind. This is detected by Coccinelle semantic patch. Signed-off-by: Wei Yongjun <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-10-26mfd: tps65218: Remove redundant read wrapperKeerthy1-1/+2
Currently read directly calls the repmap read function. Hence remove the redundant wrapper and use regmap read wherever needed. Signed-off-by: Keerthy <[email protected]> Signed-off-by: Lee Jones <[email protected]>
2016-10-25gpio: gpiolib-devprop: Check chip->parent pointer before dereferencingThor Thayer1-0/+5
Confirm the chip->parent is valid before dereferencing because the parent parameter is optional. Signed-off-by: Thor Thayer <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-10-25gpio: altera-a10sr: Drop unnecessary gpiochip_removeWei Yongjun1-10/+0
It's not necessary to unregister gpio_chip which registered with devm_gpiochip_add_data(). Also get rid of useless altr_a10sr_gpio_remove(). Signed-off-by: Wei Yongjun <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-10-24Merge branch 'ib-sx150x' of /home/linus/linux-pinctrl into develLinus Walleij3-801/+5
2016-10-24gpio: mxs: fix duplicate level interruptsSascha Hauer1-9/+29
According to the reference manual level interrupts can't be acked using the IRQSTAT registers. The effect is that when a level interrupt triggers the following ack is a no-op and the same interrupt triggers again right after it has been unmasked after running the interrupt handler. The reference manual says: Status bits for pins configured as level sensitive interrupts cannot be cleared unless either the actual pin is in the non-interrupting state, or the pin has been disabled as an interrupt source by clearing its bit in HW_PINCTRL_PIN2IRQ. To work around the duplicated interrupts we can use the PIN2IRQ rather than the IRQEN registers to mask the interrupts. This probably does not work for the edge interrupts, so we have to split up the irq chip into two chip types, one for the level interrupts and one for the edge interrupts. We now make use of two different enable registers, so we have to take care to always enable the right one, especially during switching of the interrupt type. An easy way to accomplish this is to use the IRQCHIP_SET_TYPE_MASKED which makes sure that set_irq_type is called with masked interrupts. With this the flow to change the irq type is like: - core masks interrupt (using the current chip type) - mxs_gpio_set_irq_type() changes chip type if necessary - mxs_gpio_set_irq_type() unconditionally sets the enable bit in the now unused enable register - core eventually unmasks the interrupt (using the new chip type) Signed-off-by: Sascha Hauer <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-10-24gpio: mxs: use enable/disable regs to (un)mask irqsSascha Hauer1-3/+4
The mxs gpio controller does not only have a mask register to mask interrupts, but also enable/disable registers. Use the enable/disable registers rather than the mask register. This does not have any advantage for now, but makes the next patch simpler. Signed-off-by: Sascha Hauer <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Signed-off-by: Linus Walleij <[email protected]>