leds: gpio: Refactor code to use devm_gpiod_get_index_optional()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 16 Oct 2023 16:10:02 +0000 (19:10 +0300)
committerLee Jones <lee@kernel.org>
Wed, 1 Nov 2023 11:29:21 +0000 (11:29 +0000)
commit5ac50ec712921f6250188732387bf5dac33736ae
tree065ef980f7cd2b7c55ed4c3c4eab60047454c7f7
parentf5ad594e389c57dfe19059ce868392809f9b1a71
leds: gpio: Refactor code to use devm_gpiod_get_index_optional()

Instead of checking for the specific error codes, replace
devm_gpiod_get_index() with devm_gpiod_get_index_optional().
In this case we just return all errors to the caller and
simply check for NULL in case if legacy GPIO is being used.
As the result the code is easier to read and maintain.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231016161005.1471768-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-gpio.c