Skip to content

Commit 023a883

Browse files
tititiou36Lee Jones
authored andcommitted
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 <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Signed-off-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/f998a4291d865273afa0d1f85764a9ac7fbc1b64.1644738084.git.christophe.jaillet@wanadoo.fr
1 parent d4294e4 commit 023a883

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/video/backlight/backlight.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,7 @@ static void devm_backlight_release(void *data)
710710
{
711711
struct backlight_device *bd = data;
712712

713-
if (bd)
714-
put_device(&bd->dev);
713+
put_device(&bd->dev);
715714
}
716715

717716
/**
@@ -737,11 +736,10 @@ struct backlight_device *devm_of_find_backlight(struct device *dev)
737736
bd = of_find_backlight(dev);
738737
if (IS_ERR_OR_NULL(bd))
739738
return bd;
740-
ret = devm_add_action(dev, devm_backlight_release, bd);
741-
if (ret) {
742-
put_device(&bd->dev);
739+
ret = devm_add_action_or_reset(dev, devm_backlight_release, bd);
740+
if (ret)
743741
return ERR_PTR(ret);
744-
}
742+
745743
return bd;
746744
}
747745
EXPORT_SYMBOL(devm_of_find_backlight);

0 commit comments

Comments
 (0)