1. 17 11月, 2016 1 次提交
    • K
      gpio: Remove GPIO_DEVRES option · f9c22ec6
      Keno Fischer 提交于
      This option was added in 6a89a314 to
      allow use of the devm_gpio_* functions without CONFIG_GPIOLIB.
      
      However, only a few months later in
      b69ac524, 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
      403c1d0b). 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: NKeno Fischer <keno@juliacomputing.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      f9c22ec6
  2. 15 11月, 2016 2 次提交
    • L
      gpio: tc3589x: fix up .get_direction() · 220a04f0
      Linus Walleij 提交于
      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: stable@vger.kernel.org
      Fixes: 14063d71 ("gpio: tc3589x: add .get_direction() and small cleanup")
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      220a04f0
    • L
      gpio: do not double-check direction on sleeping chips · 60f8339e
      Linus Walleij 提交于
      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: stable@vger.kernel.org
      Fixes: 9c10280d ("gpio: flush direction status in gpiochip_lock_as_irq()")
      Cc: Patrice Chotard <patrice.chotard@st.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      60f8339e
  3. 08 11月, 2016 2 次提交
  4. 02 11月, 2016 1 次提交
    • J
      gpio/mvebu: Use irq_domain_add_linear · 812d4788
      Jason Gunthorpe 提交于
      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: ce931f57 ("gpio/mvebu: convert to use irq_domain_add_simple()")
      Signed-off-by: NJason Gunthorpe <jgunthorpe@obsidianresearch.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      812d4788
  5. 01 11月, 2016 2 次提交
    • M
      gpio: of: fix GPIO drivers with multiple gpio_chip for a single node · c7e9d398
      Masahiro Yamada 提交于
      Sylvain Lemieux reports the LPC32xx GPIO driver is broken since
      commit 762c2e46 ("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: 762c2e46 ("gpio: of: remove of_gpiochip_and_xlate() and struct gg_data")
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reported-by: NSylvain Lemieux <slemieux.tyco@gmail.com>
      Tested-by: NDavid Lechner <david@lechnology.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      c7e9d398
    • L
      gpio: GPIO_GET_LINE{HANDLE,EVENT}_IOCTL: Fix file descriptor leak · 953b956a
      Lars-Peter Clausen 提交于
      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: stable@vger.kernel.org
      Fixes: d932cd49 ("gpio: free handles in fringe cases")
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      953b956a
  6. 24 10月, 2016 2 次提交
    • L
      gpio: mpc8xxx: Correct irq handler function · d71cf15b
      Liu Gang 提交于
      From the beginning of the gpio-mpc8xxx.c, the "handle_level_irq"
      has being used to handle GPIO interrupts in the PowerPC/Layerscape
      platforms. But actually, almost all PowerPC/Layerscape platforms
      assert an interrupt request upon either a high-to-low change or
      any change on the state of the signal.
      
      So the "handle_level_irq" is not reasonable for PowerPC/Layerscape
      GPIO interrupt, it should be "handle_edge_irq". Otherwise the system
      may lost some interrupts from the PIN's state changes.
      Signed-off-by: NLiu Gang <Gang.Liu@nxp.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      d71cf15b
    • J
      gpio: ath79: Fix module autoload · 6d8d271e
      Javier Martinez Canillas 提交于
      If the driver is built as a module, autoload won't work because the module
      alias information is not filled. So user-space can't match the registered
      device with the corresponding module.
      
      Export the module alias information using the MODULE_DEVICE_TABLE() macro.
      
      Before this patch:
      
      $ modinfo drivers/gpio/gpio-ath79.ko | grep alias
      $
      
      After this patch:
      
      $ modinfo drivers/gpio/gpio-ath79.ko | grep alias
      alias:          of:N*T*Cqca,ar9340-gpioC*
      alias:          of:N*T*Cqca,ar9340-gpio
      alias:          of:N*T*Cqca,ar7100-gpioC*
      alias:          of:N*T*Cqca,ar7100-gpio
      Signed-off-by: NJavier Martinez Canillas <javier@osg.samsung.com>
      Acked-by: NAban Bedel <albeu@free.fr>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      6d8d271e
  7. 21 10月, 2016 9 次提交
  8. 20 10月, 2016 4 次提交
  9. 12 10月, 2016 1 次提交
  10. 04 10月, 2016 3 次提交
  11. 03 10月, 2016 2 次提交
    • 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
    • L
      gpio: make memory-mapped drivers depend on HAS_IOMEM · 3085a4a4
      Linus Walleij 提交于
      This one is pretty obvious: on UM Linux compilation of things
      like allmodconfig and allyesconfig will fail due to the
      absence of IO memory. Simply make these drivers depend on
      HAS_IOMEM, it has been implicitly assumed all the time, so
      just make it explicit.
      
      The generic MMIO library also assumes that IOMEM is present
      so make also this depend on HAS_IOMEM.
      Reported-by: Nkbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      3085a4a4
  12. 01 10月, 2016 2 次提交
  13. 29 9月, 2016 1 次提交
  14. 27 9月, 2016 1 次提交
  15. 24 9月, 2016 2 次提交
    • W
      gpio: pca953x: variable 'id' was used twice · 6212e1d6
      Wolfram Sang 提交于
      sparse  rightfully said:
      
      drivers/gpio/gpio-pca953x.c:771:45: warning: symbol 'id' shadows an earlier one
      drivers/gpio/gpio-pca953x.c:742:36: originally declared here
      
      So, name them explicitly 'i2c_id' and 'acpi_id' to avoid any confusion.
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      6212e1d6
    • B
      gpio: pca953x: fix an incorrect lockdep warning · 559b4699
      Bartosz Golaszewski 提交于
      If an I2C GPIO multiplexer is driven by a GPIO provided by an expander
      when there's a second expander using the same device driver on one of
      the I2C bus segments, lockdep prints a deadlock warning when trying to
      set the direction or the value of the GPIOs provided by the second
      expander.
      
      The below diagram presents the setup:
      
                                                     - - - - -
       -------             ---------  Bus segment 1 |         |
      |       |           |         |---------------  Devices
      |       | SCL/SDA   |         |               |         |
      | Linux |-----------| I2C MUX |                - - - - -
      |       |    |      |         | Bus segment 2
      |       |    |      |         |-------------------
       -------     |       ---------                    |
                   |           |                    - - - - -
              ------------     | MUX GPIO          |         |
             |            |    |                     Devices
             |    GPIO    |    |                   |         |
             | Expander 1 |----                     - - - - -
             |            |                             |
              ------------                              | SCL/SDA
                                                        |
                                                   ------------
                                                  |            |
                                                  |    GPIO    |
                                                  | Expander 2 |
                                                  |            |
                                                   ------------
      
      The reason for lockdep warning is that we take the chip->i2c_lock in
      pca953x_gpio_set_value() or pca953x_gpio_direction_output() and then
      come right back to pca953x_gpio_set_value() when the GPIO mux kicks
      in. The locks actually protect different expanders, but for lockdep
      both are of the same class, so it says:
      
        Possible unsafe locking scenario:
      
              CPU0
              ----
         lock(&chip->i2c_lock);
         lock(&chip->i2c_lock);
      
        *** DEADLOCK ***
      
        May be due to missing lock nesting notation
      
      In order to get rid of the warning, retrieve the adapter nesting depth
      and use it as lockdep subclass for chip->i2c_lock.
      Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
      Acked-by: NPeter Rosin <peda@axentia.se>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      559b4699
  16. 23 9月, 2016 5 次提交