1. 12 9月, 2016 1 次提交
  2. 25 2月, 2016 1 次提交
  3. 12 2月, 2016 3 次提交
    • L
      gpio: reflect base and ngpio into gpio_device · fdeb8e15
      Linus Walleij 提交于
      Some information about the GPIO chip need to stay around also
      after the gpio_chip has been removed and only the gpio_device
      persist. The base and ngpio are such things, for example we
      don't want a new chip arriving to overlap the number space
      of a dangling gpio_device, and the chardev may still query
      the device for the number of lines etc.
      
      Note that the code that assigns base and insert gpio_device
      into the global list no longer check for a missing gpio_chip:
      we respect the number space allocated by any other gpio_device.
      
      As a consequence of the gdev being referenced directly from
      the gpio_desc, we need to verify it differently from all
      in-kernel API calls that fall through to direct queries to
      the gpio_chip vtable: we first check that desc is !NULL, then
      that desc->gdev is !NULL, then, if desc->gdev->chip is NULL,
      we *BAIL OUT* without any error, so as to manage the case
      where operations are requested on a device that is gone.
      
      These checks were non-uniform and partly missing in the past:
      so to simplify: create the macros VALIDATE_DESC() that will
      return -EINVAL if the desc or desc->gdev is missing and just
      0 if the chip is gone, and conversely VALIDATE_DESC_VOID()
      for the case where the function does not return an error.
      By using these macros, we get warning messages about missing
      gdev with reference to the right function in the kernel log.
      
      Despite the macro business this simplifies the code and make
      it more readable than if we copy/paste the same descriptor
      checking code into all code ABI call sites (IMHO).
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      fdeb8e15
    • L
      gpio: move descriptors into gpio_device · 1c3cdb18
      Linus Walleij 提交于
      We need gpio_device to hold the descriptors so that they can
      be lifecycled with the struct gpio_device held from userspace.
      Move the descriptor array into gpio_device. Also rename it from
      "desc" (singularis) to "descs" (pluralis) to reflect the fact
      that it is an array.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      1c3cdb18
    • L
      gpio: move sysfs mock device to the gpio_device · afbc4f31
      Linus Walleij 提交于
      Since gpio_device is the struct that survives if the backing
      gpio_chip is removed, move the sysfs mock device to this state
      container so it becomes part of the dangling state of the
      GPIO device on removal.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      afbc4f31
  4. 09 2月, 2016 1 次提交
    • L
      gpio: make the gpiochip a real device · ff2b1359
      Linus Walleij 提交于
      GPIO chips have been around for years, but were never real devices,
      instead they were piggy-backing on a parent device (such as a
      platform_device or amba_device) but this was always optional.
      GPIO chips could also exist without any device at all, with its
      struct device *parent (ex *dev) pointer being set to null.
      
      When sysfs was in use, a mock device would be created, with the
      optional parent assigned, or just floating orphaned with NULL
      as parent.
      
      If sysfs is active, it will use this device as parent.
      
      We now create a gpio_device struct containing a real
      struct device and move the subsystem over to using that. The
      list of struct gpio_chip:s is augmented to hold struct
      gpio_device:s and we find gpio_chips:s by first looking up
      the struct gpio_device.
      
      The struct gpio_device is designed to stay around even if the
      gpio_chip is removed, so as to satisfy users in userspace
      that need a backing data structure to hold the state of the
      session initiated with e.g. a character device even if there is
      no physical chip anymore.
      
      From this point on, gpiochips are devices.
      
      Cc: Johan Hovold <johan@kernel.org>
      Cc: Michael Welling <mwelling@ieee.org>
      Cc: Markus Pargmann <mpa@pengutronix.de>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      ff2b1359
  5. 19 11月, 2015 1 次提交
    • L
      gpio: change member .dev to .parent · 58383c78
      Linus Walleij 提交于
      The name .dev in a struct is normally reserved for a struct device
      that is let us say a superclass to the thing described by the struct.
      struct gpio_chip stands out by confusingly using a struct device *dev
      to point to the parent device (such as a platform_device) that
      represents the hardware. As we want to give gpio_chip:s real devices,
      this is not working. We need to rename this member to parent.
      
      This was done by two coccinelle scripts, I guess it is possible to
      combine them into one, but I don't know such stuff. They look like
      this:
      
      @@
      struct gpio_chip *var;
      @@
      -var->dev
      +var->parent
      
      and:
      
      @@
      struct gpio_chip var;
      @@
      -var.dev
      +var.parent
      
      and:
      
      @@
      struct bgpio_chip *var;
      @@
      -var->gc.dev
      +var->gc.parent
      
      Plus a few instances of bgpio that I couldn't figure out how
      to teach Coccinelle to rewrite.
      
      This patch hits all over the place, but I *strongly* prefer this
      solution to any piecemal approaches that just exercise patch
      mechanics all over the place. It mainly hits drivers/gpio and
      drivers/pinctrl which is my own backyard anyway.
      
      Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
      Cc: Rafał Miłecki <zajec5@gmail.com>
      Cc: Richard Purdie <rpurdie@rpsys.net>
      Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
      Cc: Alek Du <alek.du@intel.com>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: Takashi Iwai <tiwai@suse.com>
      Acked-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NLee Jones <lee.jones@linaro.org>
      Acked-by: NJiri Kosina <jkosina@suse.cz>
      Acked-by: NHans-Christian Egtvedt <egtvedt@samfundet.no>
      Acked-by: NJacek Anaszewski <j.anaszewski@samsung.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      58383c78
  6. 05 10月, 2015 1 次提交
  7. 25 9月, 2015 1 次提交
  8. 12 5月, 2015 21 次提交
  9. 30 4月, 2015 1 次提交
    • J
      gpio: sysfs: fix memory leaks and device hotplug · 483d8211
      Johan Hovold 提交于
      Unregister GPIOs requested through sysfs at chip remove to avoid leaking
      the associated memory and sysfs entries.
      
      The stale sysfs entries prevented the gpio numbers from being exported
      when the gpio range was later reused (e.g. at device reconnect).
      
      This also fixes the related module-reference leak.
      
      Note that kernfs makes sure that any on-going sysfs operations finish
      before the class devices are unregistered and that further accesses
      fail.
      
      The chip exported flag is used to prevent gpiod exports during removal.
      This also makes it harder to trigger, but does not fix, the related race
      between gpiochip_remove and export_store, which is really a race with
      gpiod_request that needs to be addressed separately.
      
      Also note that this would prevent the crashes (e.g. NULL-dereferences)
      at reconnect that affects pre-3.18 kernels, as well as use-after-free on
      operations on open attribute files on pre-3.14 kernels (prior to
      kernfs).
      
      Fixes: d8f388d8 ("gpio: sysfs interface")
      Cc: stable <stable@vger.kernel.org>	# v2.6.27: 01cca93aSigned-off-by: NJohan Hovold <johan@kernel.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      483d8211
  10. 30 1月, 2015 2 次提交
  11. 16 1月, 2015 3 次提交
  12. 28 11月, 2014 1 次提交
  13. 29 10月, 2014 1 次提交
  14. 24 7月, 2014 1 次提交
  15. 23 7月, 2014 1 次提交