summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib-cdev.c
AgeCommit message (Collapse)AuthorFilesLines
2020-07-12gpiolib: cdev: refactor lineevent cleanup into lineevent_freeKent Gibson1-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>
2020-07-12gpiolib: cdev: refactor linehandle cleanup into linehandle_freeKent Gibson1-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>
2020-07-12gpiolib: cdev: remove recalculation of offsetKent Gibson1-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>
2020-07-12gpiolib: cdev: fix minor race in GET_LINEINFO_WATCHKent Gibson1-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>
2020-07-12gpiolib: cdev: rename priv to cdevKent Gibson1-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>
2020-07-12gpiolib: cdev: use blocking notifier call chain instead of atomicKent Gibson1-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>
2020-07-12gpiolib: cdev: remove pointless decrement of iKent Gibson1-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>
2020-07-12gpiolib: cdev: rename numdescs to num_descsKent Gibson1-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>
2020-07-12gpiolib: cdev: rename 'filep' and 'filp' to 'file' to be consistent with ↵Kent Gibson1-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>
2020-07-12gpiolib: cdev: refactor gpiohandle_flags_to_desc_flagsKent Gibson1-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>
2020-07-12gpiolib: cdev: minor indentation fixesKent Gibson1-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>
2020-07-12gpiolib: cdev: sort includesKent Gibson1-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>
2020-06-20gpiolib: split character device into gpiolib-cdevKent Gibson1-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>