diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2022-02-13 10:41:39 +0300 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2022-03-08 13:47:28 +0300 |
commit | 023a8830a62846e1cecc8da07e00c801dd0d7598 (patch) | |
tree | 10570c0db6d006dadb71fef1208062756efac7a8 | |
parent | d4294e4fc7f0feeb877ae0aa58cea4f4328f8974 (diff) | |
download | linux-023a8830a62846e1cecc8da07e00c801dd0d7598.tar.xz |
backlight: backlight: Slighly simplify devm_of_find_backlight()
Use devm_add_action_or_reset() instead of devm_add_action()+hand writing
what is done in the release function, should an error occur.
This is more straightforward and saves a few lines of code.
While at it, remove a useless test in devm_backlight_release(). 'data' is
known to be not NULL when this function is called.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/f998a4291d865273afa0d1f85764a9ac7fbc1b64.1644738084.git.christophe.jaillet@wanadoo.fr
-rw-r--r-- | drivers/video/backlight/backlight.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 4ae6fae94ac2..b788ff3d0f45 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -710,8 +710,7 @@ static void devm_backlight_release(void *data) { struct backlight_device *bd = data; - if (bd) - put_device(&bd->dev); + put_device(&bd->dev); } /** @@ -737,11 +736,10 @@ struct backlight_device *devm_of_find_backlight(struct device *dev) bd = of_find_backlight(dev); if (IS_ERR_OR_NULL(bd)) return bd; - ret = devm_add_action(dev, devm_backlight_release, bd); - if (ret) { - put_device(&bd->dev); + ret = devm_add_action_or_reset(dev, devm_backlight_release, bd); + if (ret) return ERR_PTR(ret); - } + return bd; } EXPORT_SYMBOL(devm_of_find_backlight); |