leds: ktd2692: Fix an error handling path
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 21 May 2021 11:21:01 +0000 (13:21 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:56:48 +0000 (16:56 +0200)
commit57e49a0bc4b3887d1e3db2d3073f2a6934f87e16
tree2add50a57c63acd1b28a9c6b7d3fd7dfef8d33ea
parent53cb671592efe10c993674bc7657e19192471679
leds: ktd2692: Fix an error handling path

[ Upstream commit ee78b9360e14c276f5ceaa4a0d06f790f04ccdad ]

In 'ktd2692_parse_dt()', if an error occurs after a successful
'regulator_enable()' call, we should call 'regulator_enable()'.

This is the same in 'ktd2692_probe()', if an error occurs after a
successful 'ktd2692_parse_dt()' call.

Instead of adding 'regulator_enable()' in several places, implement a
resource managed solution and simplify the remove function accordingly.

Fixes: b7da8c5c725c ("leds: Add ktd2692 flash LED driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/leds/leds-ktd2692.c