gpiolib: cdev: reduce locking in gpio_desc_to_lineinfo()
authorKent Gibson <warthog618@gmail.com>
Tue, 19 Dec 2023 00:41:56 +0000 (08:41 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 19 Dec 2023 09:32:52 +0000 (10:32 +0100)
commit1cdc605c7d70a390ff75a814a26c6f45d75778be
treea69663f1a8cd4550c168c71c378cab8d531a86d9
parent193b6b0902bf57ff13bbadaa037a288c73c9d126
gpiolib: cdev: reduce locking in gpio_desc_to_lineinfo()

Reduce the time holding the gpio_lock by snapshotting the desc flags,
rather than testing them individually while holding the lock.

Accept that the calculation of the used field is inherently racy, and
only check the availability of the line from pinctrl if other checks
pass, so avoiding the check for lines that are otherwise in use.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpiolib-cdev.c