Commit 023a8830 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Lee Jones
Browse files

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/f998a4291d865273afa0d1f85764a9ac7fbc1b64.1644738084.git.christophe.jaillet@wanadoo.fr
parent d4294e4f
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -710,7 +710,6 @@ static void devm_backlight_release(void *data)
{
	struct backlight_device *bd = data;

	if (bd)
	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);