1. 21 10月, 2016 8 次提交
  2. 04 10月, 2016 1 次提交
    • L
      gpio: acpi: separation of concerns · 031ba28a
      Linus Walleij 提交于
      The generic GPIO library directly implement code for acpi_find_gpio()
      which is only used with CONFIG_ACPI. This was probably done because
      OF did the same thing, but I removed that so remove this too.
      
      Rename the internal acpi_find_gpio() in gpiolib-acpi.c to
      acpi_populate_gpio_lookup() which seems to be more appropriate anyway
      so as to avoid a namespace clash with the same function.
      
      Make the stub return -ENOENT rather than -ENOSYS (as that is for
      syscalls!).
      
      For some reason the sunxi pin control driver was including the private
      gpiolib header, it works just fine without it so remove that oneliner.
      
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      031ba28a
  3. 03 10月, 2016 1 次提交
    • L
      gpio: OF: separation of concerns · ea713bc4
      Linus Walleij 提交于
      The generic GPIO library directly implement code for of_find_gpio()
      which is only used with CONFIG_OF and causes compilation problems
      on archs that do not even have stubs for OF functions, especially
      on UM that does not implement any IO remap functions.
      
      Move the function to gpiolib-of.c, implement a static inline stub
      in gpiolib.h returning PTR_ERR(-ENOENT) if CONFIG_OF_GPIO is not
      set and be done with it.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      ea713bc4
  4. 23 9月, 2016 1 次提交
    • M
      gpiolib: Make it possible to exclude GPIOs from IRQ domain · 79b804cb
      Mika Westerberg 提交于
      When using GPIO irqchip helpers to setup irqchip for a gpiolib based
      driver, it is not possible to select which GPIOs to add to the IRQ domain.
      Instead it just adds all GPIOs which is not always desired. For example
      there might be GPIOs that for some reason cannot generated normal
      interrupts at all.
      
      To support this we add a flag irq_need_valid_mask to struct gpio_chip. When
      this flag is set the core allocates irq_valid_mask that holds one bit for
      each GPIO the chip has. By default all bits are set but drivers can
      manipulate this using set_bit() and clear_bit() accordingly.
      
      Then when gpiochip_irqchip_add() is called, this mask is checked and all
      GPIOs with bit is set are added to the IRQ domain created for the GPIO
      chip.
      Suggested-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      79b804cb
  5. 13 9月, 2016 1 次提交
  6. 12 9月, 2016 1 次提交
  7. 19 8月, 2016 1 次提交
  8. 22 7月, 2016 1 次提交
  9. 06 7月, 2016 3 次提交
    • L
      Revert "gpio: convince line to become input in irq helper" · 78456d6f
      Linus Walleij 提交于
      This reverts commit 7e7c059c.
      
      I was wrong about trying to do this, as it breaks the
      orthogonality between gpiochips and irqchips.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      78456d6f
    • L
      gpiolib: of_find_gpio(): Don't discard errors · da17f8a1
      Lars-Peter Clausen 提交于
      Since commit dd34c37a ("gpio: of: Allow -gpio suffix for property
      names") when requesting a GPIO from the devicetree gpiolib looks for
      properties with both the '-gpio' and the '-gpios' suffix. This was
      implemented by first searching for the property with the '-gpios' suffix
      and if that yields an error try the '-gpio' suffix. This approach has the
      issue that any error returned when looking for the '-gpios' suffix is
      silently discarded.
      
      Commit 06fc3b70 ("gpio: of: Fix handling for deferred probe for -gpio
      suffix") partially addressed the issue by treating the EPROBE_DEFER error
      as a special condition. This fixed the case when the property is specified,
      but the GPIO provider is not ready yet. But there are other cases in which
      of_get_named_gpiod_flags() returns an error even though the property is
      specified, e.g. if the specification is incorrect.
      
      of_find_gpio() should only try to look for the property with the '-gpio'
      suffix if no property with the '-gpios' suffix was found. If the property
      was not found of_get_named_gpiod_flags() will return -ENOENT, so update the
      condition to abort and propagate the error to the caller in all other
      cases.
      
      This is important for gpiod_get_optinal() and friends to behave correctly
      in case the specifier contains errors. Without this patch they'll return
      NULL if the property uses the '-gpios' suffix and the specifier contains
      errors, which falsely indicates to the caller that no GPIO was specified.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      da17f8a1
    • T
      gpio: of: Allow overriding the device node · acc6e331
      Thierry Reding 提交于
      When registering a GPIO chip, drivers can override the device tree node
      associated with the chip by setting the chip's ->of_node field. If set,
      this field is supposed to take precedence over the ->parent->of_node
      field, but the code doesn't actually do that.
      
      Commit 762c2e46 ("gpio: of: remove of_gpiochip_and_xlate() and
      struct gg_data") exposes this because it now no longer matches on the
      GPIO chip's ->of_node field, but the GPIO device's ->of_node field that
      is set using the procedure described above.
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Acked-by: NAlexandre Courbot <acourbot@nvidia.com>
      Reviewed-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      acc6e331
  10. 04 7月, 2016 2 次提交
    • L
      gpio: free handles in fringe cases · d932cd49
      Linus Walleij 提交于
      If we fail when copying the ioctl() struct to userspace we still
      need to clean up the cruft otherwise left behind or it will stay
      around until the issuing process terminates the file handle.
      Reported-by: NAlexander Stein <alexander.stein@systec-electronic.com>
      Acked-by: NAlexander Stein <alexander.stein@systec-electronic.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      d932cd49
    • J
      Revert "gpiolib: Split GPIO flags parsing and GPIO configuration" · 85b03b30
      Johan Hovold 提交于
      This reverts commit 923b93e4.
      
      Make sure consumers do not overwrite gpio flags for pins that have
      already been claimed.
      
      While adding support for gpio drivers to refuse a request using
      unsupported flags, the order of when the requested flag was checked and
      the new flags were applied was reversed to that consumers could
      overwrite flags for already requested gpios.
      
      This not only affects device-tree setups where two drivers could request
      the same gpio using conflicting configurations, but also allowed user
      space to clear gpio flags for already claimed pins simply by attempting
      to export them through the sysfs interface. By for example clearing the
      FLAG_ACTIVE_LOW flag this way, user space could effectively change the
      polarity of a signal.
      
      Reverting this change obviously prevents gpio drivers from doing sanity
      checks on the flags in their request callbacks. Fortunately only one
      recently added driver (gpio-tps65218 in v4.6) appears to do this, and a
      follow up patch could restore this functionality through a different
      interface.
      
      Cc: stable <stable@vger.kernel.org>	# 4.4
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      85b03b30
  11. 23 6月, 2016 3 次提交
  12. 18 6月, 2016 4 次提交
  13. 16 6月, 2016 1 次提交
    • A
      gpiolib: avoid uninitialized data in gpio kfifo · bc0207a5
      Arnd Bergmann 提交于
      gcc reports a theoretical case for returning uninitialized data in
      the kfifo when a GPIO interrupt happens and neither
      GPIOEVENT_REQUEST_RISING_EDGE nor GPIOEVENT_REQUEST_FALLING_EDGE
      are set:
      
      drivers/gpio/gpiolib.c: In function 'lineevent_irq_thread':
      drivers/gpio/gpiolib.c:683:87: error: 'ge.id' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      
      This case should not happen, but to be on the safe side, let's
      return from the irq handler without adding data to the FIFO
      to ensure we can never leak stack data to user space.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 61f922db ("gpio: userspace ABI for reading GPIO line events")
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      bc0207a5
  14. 15 6月, 2016 2 次提交
    • L
      gpio: userspace ABI for reading GPIO line events · 61f922db
      Linus Walleij 提交于
      This adds an ABI for listening to events on GPIO lines.
      The mechanism returns an anonymous file handle to a request
      to listen to a specific offset on a specific gpiochip.
      To fetch the stream of events from the file handle, userspace
      simply reads an event.
      
      - Events can be requested with the same flags as ordinary
        handles, i.e. open drain or open source. An ioctl() call
        GPIO_GET_LINEEVENT_IOCTL is issued indicating the desired
        line.
      
      - Events can be requested for falling edge events, rising
        edge events, or both.
      
      - All events are timestamped using the kernel real time
        nanosecond timestamp (the same as is used by IIO).
      
      - The supplied consumer label will appear in "lsgpio"
        listings of the lines, and in /proc/interrupts as the
        mechanism will request an interrupt from the gpio chip.
      
      - Events are not supported on gpiochips that do not serve
        interrupts (no legal .to_irq() call). The event interrupt
        is threaded to avoid any realtime problems.
      
      - It is possible to also directly read the current value
        of the registered GPIO line by issuing the same
        GPIOHANDLE_GET_LINE_VALUES_IOCTL as used by the
        line handles. Setting the value is not supported: we
        do not listen to events on output lines.
      
      This ABI is strongly influenced by Industrial I/O and surpasses
      the old sysfs ABI by providing proper precision timestamps,
      making it possible to set flags like open drain, and put
      consumer names on the GPIO lines.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      61f922db
    • L
      gpio: userspace ABI for reading/writing GPIO lines · d7c51b47
      Linus Walleij 提交于
      This adds a userspace ABI for reading and writing GPIO lines.
      The mechanism returns an anonymous file handle to a request
      to read/write n offsets from a gpiochip. This file handle
      in turn accepts two ioctl()s: one that reads and one that
      writes values to the selected lines.
      
      - Handles can be requested as input/output, active low,
        open drain, open source, however when you issue a request
        for n lines with GPIO_GET_LINEHANDLE_IOCTL, they must all
        have the same flags, i.e. all inputs or all outputs, all
        open drain etc. If a granular control of the flags for
        each line is desired, they need to be requested
        individually, not in a batch.
      
      - The GPIOHANDLE_GET_LINE_VALUES_IOCTL read ioctl() can be
        issued also to output lines to verify that the hardware
        is in the expected state.
      
      - It reads and writes up to GPIOHANDLES_MAX lines at once,
        utilizing the .set_multiple() call in the driver if
        possible, making the call efficient if several lines
        can be written with a single register update.
      
      The limitation of GPIOHANDLES_MAX to 64 lines is done under
      the assumption that we may expect hardware that can issue a
      transaction updating 64 bits at an instant but unlikely
      anything larger than that.
      
      ChangeLog v2->v3:
      - Use gpiod_get_value_cansleep() so we support also slowpath
        GPIO drivers.
      - Fix up the UAPI docs kerneldoc.
      - Allocate the anonymous fd last, so that the release
        function don't get called until that point of something
        fails. After this point, skip the errorpath.
      ChangeLog v1->v2:
      - Handle ioctl_compat() properly based on a similar patch
        to the other ioctl() handling code.
      - Use _IOWR() as we pass pointers both in and out of the
        ioctl()
      - Use kmalloc() and kfree() for the linehandled, do not
        try to be fancy with devm_* it doesn't work the way I
        thought.
      - Fix const-correctness on the linehandle name field.
      Acked-by: NMichael Welling <mwelling@ieee.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      d7c51b47
  15. 08 6月, 2016 2 次提交
    • R
      gpiolib: Fix unaligned used of reference counters · f4833b8c
      Ricardo Ribalda Delgado 提交于
      gpiolib relies on the reference counters to clean up the gpio_device
      structure.
      
      Although the number of get/put is properly aligned on gpiolib.c
      itself, it does not take into consideration how the referece counters
      are affected by other external functions such as cdev_add and device_add.
      
      Because of this, after the last call to put_device, the reference counter
      has a value of +3, therefore never calling gpiodevice_release.
      
      Due to the fact that some of the device  has already been cleaned on
      gpiochip_remove, the library will end up OOPsing the kernel (e.g. a call
      to of_gpiochip_find_and_xlate).
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      f4833b8c
    • R
      gpiolib: Fix NULL pointer deference · 11f33a6d
      Ricardo Ribalda Delgado 提交于
      Under some circumstances, a gpiochip might be half cleaned from the
      gpio_device list.
      
      This patch makes sure that the chip pointer is still valid, before
      calling the match function.
      
      [  104.088296] BUG: unable to handle kernel NULL pointer dereference at
      0000000000000090
      [  104.089772] IP: [<ffffffff813d2045>] of_gpiochip_find_and_xlate+0x15/0x80
      [  104.128273] Call Trace:
      [  104.129802]  [<ffffffff813d2030>] ? of_parse_own_gpio+0x1f0/0x1f0
      [  104.131353]  [<ffffffff813cd910>] gpiochip_find+0x60/0x90
      [  104.132868]  [<ffffffff813d21ba>] of_get_named_gpiod_flags+0x9a/0x120
      ...
      [  104.141586]  [<ffffffff8163d12b>] gpio_led_probe+0x11b/0x360
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      11f33a6d
  16. 30 5月, 2016 4 次提交
  17. 02 5月, 2016 1 次提交
  18. 30 4月, 2016 1 次提交
  19. 26 4月, 2016 1 次提交
  20. 14 4月, 2016 1 次提交