summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib-cdev.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* gpiolib: cdev: refactor lineevent cleanup into lineevent_freeKent Gibson2020-07-121-23/+21
| | | | | | | | | Consolidate the cleanup of lineevents, currently duplicated in lineevent_create and lineevent_release, into a helper function lineevent_free. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: refactor linehandle cleanup into linehandle_freeKent Gibson2020-07-121-20/+19
| | | | | | | | | Consolidate the cleanup of linehandles, currently duplicated in linehandle_create and linehandle_release, into a helper function linehandle_free. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: remove recalculation of offsetKent Gibson2020-07-121-13/+7
| | | | | | | | | | | | | | Remove recalculation of offset from desc, where desc itself was calculated from offset. There is no benefit from the desc -> hwgpio conversion in this context. The only implicit benefit of the offset -> desc -> hwgpio is the range check in the offset -> desc, but where desc is required you still get that, and where desc isn't required it is simpler to perform the range check directly. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: fix minor race in GET_LINEINFO_WATCHKent Gibson2020-07-121-5/+5
| | | | | | | | | | | | | Merge separate usage of test_bit/set_bit into test_and_set_bit to remove the possibility of a race between the test and set. Similarly test_bit and clear_bit. In the existing code it is possible for two threads to race past the test_bit and then set or clear the watch bit, and neither return EBUSY. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: rename priv to cdevKent Gibson2020-07-121-45/+45
| | | | | | | | | | | | Rename priv to cdev to improve readability. The name "priv" indicates that the object is pointed to by file->private_data, not what the object is actually is. As it is always used to point to a struct gpio_chardev_data, renaming it to cdev is more appropriate. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: use blocking notifier call chain instead of atomicKent Gibson2020-07-121-12/+12
| | | | | | | | | | | | | Replace usage of atomic_notifier_call_chain with blocking_notifier_call_chain as the notifier function, lineinfo_changed_notify, calls gpio_desc_to_lineinfo, which calls pinctrl_gpio_can_use_line, which can sleep. The chain isn't being called from an atomic context so the the blocking notifier is a suitable substitute. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: remove pointless decrement of iKent Gibson2020-07-121-2/+0
| | | | | | | | | | Remove pointless decrement of variable, and associated comment. While i is used subsequently, it is re-initialized so this decrement serves no purpose. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: rename numdescs to num_descsKent Gibson2020-07-121-10/+10
| | | | | | | | Rename numdescs to num_descs to be more consistent with the naming of other counters and improve readability. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: rename 'filep' and 'filp' to 'file' to be consistent with ↵Kent Gibson2020-07-121-35/+35
| | | | | | | | | | other use Rename 'filep' and 'filp' to 'file' to be consistent with other use and improve readability. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: refactor gpiohandle_flags_to_desc_flagsKent Gibson2020-07-121-41/+19
| | | | | | | | | | | | | Refactor the mapping from handle flags to desc flags into a helper function. The assign_bit is overkill where it is replacing the set_bit cases, as is rechecking bits known to be clear in some circumstances, but the DRY simplification more than makes up for any performance degradation, especially as this is not a hot path. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: minor indentation fixesKent Gibson2020-07-121-14/+14
| | | | | | | Make indentation consistent with other use to improve readability. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: cdev: sort includesKent Gibson2020-07-121-11/+11
| | | | | | | | Sort the includes of gpiolib-cdev.c to make it easier to identify if a module is included and to avoid duplication. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
* gpiolib: split character device into gpiolib-cdevKent Gibson2020-06-201-0/+1154
Split the cdev specific functionality out of gpiolib.c and into gpiolib-cdev.c. This improves the readability and maintainability of both the cdev and core gpiolib code. Suggested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Kent Gibson <warthog618@gmail.com> Link: https://lore.kernel.org/r/20200616093615.5167-1-warthog618@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>