2022-06-08 05:36:38

by Stephen Kitt

[permalink] [raw]
Subject: [PATCH 4/4] backlight: tosa: Use backlight helper

Instead of retrieving the backlight brightness in struct
backlight_properties manually, and then checking whether the backlight
should be on at all, use backlight_get_brightness() which does all
this and insulates this from future changes.

Signed-off-by: Stephen Kitt <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: Daniel Thompson <[email protected]>
Cc: Jingoo Han <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/video/backlight/tosa_bl.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c
index 6df6fcd132e3..5bbb769f9746 100644
--- a/drivers/video/backlight/tosa_bl.c
+++ b/drivers/video/backlight/tosa_bl.c
@@ -50,13 +50,8 @@ static void tosa_bl_set_backlight(struct tosa_bl_data *data, int brightness)

static int tosa_bl_update_status(struct backlight_device *dev)
{
- struct backlight_properties *props = &dev->props;
struct tosa_bl_data *data = bl_get_data(dev);
- int power = max(props->power, props->fb_blank);
- int brightness = props->brightness;
-
- if (power)
- brightness = 0;
+ int brightness = backlight_get_brightness(dev);

tosa_bl_set_backlight(data, brightness);

--
2.30.2


2022-06-08 15:05:56

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH 4/4] backlight: tosa: Use backlight helper

On Tue, Jun 07, 2022 at 09:09:25PM +0200, Stephen Kitt wrote:
> Instead of retrieving the backlight brightness in struct
> backlight_properties manually, and then checking whether the backlight
> should be on at all, use backlight_get_brightness() which does all
> this and insulates this from future changes.
>
> Signed-off-by: Stephen Kitt <[email protected]>
> Cc: Lee Jones <[email protected]>
> Cc: Daniel Thompson <[email protected]>
> Cc: Jingoo Han <[email protected]>
> Cc: Helge Deller <[email protected]>
> Cc: [email protected]
> Cc: [email protected]

Reviewed-by: Daniel Thompson <[email protected]>

... and, wowzer, the code before your change wasn't much fun to read!


> static int tosa_bl_update_status(struct backlight_device *dev)
> {
> - struct backlight_properties *props = &dev->props;
> struct tosa_bl_data *data = bl_get_data(dev);
> - int power = max(props->power, props->fb_blank);
> - int brightness = props->brightness;
> -
> - if (power)
> - brightness = 0;
> + int brightness = backlight_get_brightness(dev);
>
> tosa_bl_set_backlight(data, brightness);


Daniel.