Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

backlight: Use backlight_get_brightness() throughout

Introduce the backlight_get_brightness() helper in all
video/backlight/* drivers. This simplifies the code and align the
implementation of the update_status() operation across the different
backlight drivers.

Some of the drivers gains a little extra functionality by the change
as they now respect the fb_blank() ioctl.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Sam Ravnborg and committed by
Lee Jones
51d53e5b a00a5feb

+19 -150
+1 -12
drivers/video/backlight/88pm860x_bl.c
··· 121 121 122 122 static int pm860x_backlight_update_status(struct backlight_device *bl) 123 123 { 124 - int brightness = bl->props.brightness; 125 - 126 - if (bl->props.power != FB_BLANK_UNBLANK) 127 - brightness = 0; 128 - 129 - if (bl->props.fb_blank != FB_BLANK_UNBLANK) 130 - brightness = 0; 131 - 132 - if (bl->props.state & BL_CORE_SUSPENDED) 133 - brightness = 0; 134 - 135 - return pm860x_backlight_set(bl, brightness); 124 + return pm860x_backlight_set(bl, backlight_get_brightness(bl)); 136 125 } 137 126 138 127 static int pm860x_backlight_get_brightness(struct backlight_device *bl)
+1 -9
drivers/video/backlight/adp5520_bl.c
··· 65 65 66 66 static int adp5520_bl_update_status(struct backlight_device *bl) 67 67 { 68 - int brightness = bl->props.brightness; 69 - 70 - if (bl->props.power != FB_BLANK_UNBLANK) 71 - brightness = 0; 72 - 73 - if (bl->props.fb_blank != FB_BLANK_UNBLANK) 74 - brightness = 0; 75 - 76 - return adp5520_bl_set(bl, brightness); 68 + return adp5520_bl_set(bl, backlight_get_brightness(bl)); 77 69 } 78 70 79 71 static int adp5520_bl_get_brightness(struct backlight_device *bl)
+1 -9
drivers/video/backlight/adp8860_bl.c
··· 361 361 362 362 static int adp8860_bl_update_status(struct backlight_device *bl) 363 363 { 364 - int brightness = bl->props.brightness; 365 - 366 - if (bl->props.power != FB_BLANK_UNBLANK) 367 - brightness = 0; 368 - 369 - if (bl->props.fb_blank != FB_BLANK_UNBLANK) 370 - brightness = 0; 371 - 372 - return adp8860_bl_set(bl, brightness); 364 + return adp8860_bl_set(bl, backlight_get_brightness(bl)); 373 365 } 374 366 375 367 static int adp8860_bl_get_brightness(struct backlight_device *bl)
+1 -9
drivers/video/backlight/adp8870_bl.c
··· 399 399 400 400 static int adp8870_bl_update_status(struct backlight_device *bl) 401 401 { 402 - int brightness = bl->props.brightness; 403 - 404 - if (bl->props.power != FB_BLANK_UNBLANK) 405 - brightness = 0; 406 - 407 - if (bl->props.fb_blank != FB_BLANK_UNBLANK) 408 - brightness = 0; 409 - 410 - return adp8870_bl_set(bl, brightness); 402 + return adp8870_bl_set(bl, backlight_get_brightness(bl)); 411 403 } 412 404 413 405 static int adp8870_bl_get_brightness(struct backlight_device *bl)
+1 -6
drivers/video/backlight/bd6107.c
··· 82 82 static int bd6107_backlight_update_status(struct backlight_device *backlight) 83 83 { 84 84 struct bd6107 *bd = bl_get_data(backlight); 85 - int brightness = backlight->props.brightness; 86 - 87 - if (backlight->props.power != FB_BLANK_UNBLANK || 88 - backlight->props.fb_blank != FB_BLANK_UNBLANK || 89 - backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) 90 - brightness = 0; 85 + int brightness = backlight_get_brightness(backlight); 91 86 92 87 if (brightness) { 93 88 bd6107_write(bd, BD6107_PORTSEL, BD6107_PORTSEL_LEDM(2) |
+1 -7
drivers/video/backlight/corgi_lcd.c
··· 420 420 static int corgi_bl_update_status(struct backlight_device *bd) 421 421 { 422 422 struct corgi_lcd *lcd = bl_get_data(bd); 423 - int intensity = bd->props.brightness; 424 - 425 - if (bd->props.power != FB_BLANK_UNBLANK) 426 - intensity = 0; 427 - 428 - if (bd->props.fb_blank != FB_BLANK_UNBLANK) 429 - intensity = 0; 423 + int intensity = backlight_get_brightness(bd); 430 424 431 425 if (corgibl_flags & CORGIBL_SUSPENDED) 432 426 intensity = 0;
+1 -12
drivers/video/backlight/da903x_bl.c
··· 77 77 78 78 static int da903x_backlight_update_status(struct backlight_device *bl) 79 79 { 80 - int brightness = bl->props.brightness; 81 - 82 - if (bl->props.power != FB_BLANK_UNBLANK) 83 - brightness = 0; 84 - 85 - if (bl->props.fb_blank != FB_BLANK_UNBLANK) 86 - brightness = 0; 87 - 88 - if (bl->props.state & BL_CORE_SUSPENDED) 89 - brightness = 0; 90 - 91 - return da903x_backlight_set(bl, brightness); 80 + return da903x_backlight_set(bl, backlight_get_brightness(bl)); 92 81 } 93 82 94 83 static int da903x_backlight_get_brightness(struct backlight_device *bl)
+1 -7
drivers/video/backlight/ep93xx_bl.c
··· 36 36 37 37 static int ep93xxbl_update_status(struct backlight_device *bl) 38 38 { 39 - int brightness = bl->props.brightness; 40 - 41 - if (bl->props.power != FB_BLANK_UNBLANK || 42 - bl->props.fb_blank != FB_BLANK_UNBLANK) 43 - brightness = 0; 44 - 45 - return ep93xxbl_set(bl, brightness); 39 + return ep93xxbl_set(bl, backlight_get_brightness(bl)); 46 40 } 47 41 48 42 static int ep93xxbl_get_brightness(struct backlight_device *bl)
+1 -5
drivers/video/backlight/hp680_bl.c
··· 33 33 { 34 34 unsigned long flags; 35 35 u16 v; 36 - int intensity = bd->props.brightness; 36 + int intensity = backlight_get_brightness(bd); 37 37 38 - if (bd->props.power != FB_BLANK_UNBLANK) 39 - intensity = 0; 40 - if (bd->props.fb_blank != FB_BLANK_UNBLANK) 41 - intensity = 0; 42 38 if (hp680bl_suspended) 43 39 intensity = 0; 44 40
+1 -5
drivers/video/backlight/kb3886_bl.c
··· 87 87 88 88 static int kb3886bl_send_intensity(struct backlight_device *bd) 89 89 { 90 - int intensity = bd->props.brightness; 90 + int intensity = backlight_get_brightness(bd); 91 91 92 - if (bd->props.power != FB_BLANK_UNBLANK) 93 - intensity = 0; 94 - if (bd->props.fb_blank != FB_BLANK_UNBLANK) 95 - intensity = 0; 96 92 if (kb3886bl_flags & KB3886BL_SUSPENDED) 97 93 intensity = 0; 98 94
+1 -6
drivers/video/backlight/led_bl.c
··· 54 54 static int led_bl_update_status(struct backlight_device *bl) 55 55 { 56 56 struct led_bl_data *priv = bl_get_data(bl); 57 - int brightness = bl->props.brightness; 58 - 59 - if (bl->props.power != FB_BLANK_UNBLANK || 60 - bl->props.fb_blank != FB_BLANK_UNBLANK || 61 - bl->props.state & BL_CORE_FBBLANK) 62 - brightness = 0; 57 + int brightness = backlight_get_brightness(bl); 63 58 64 59 if (brightness > 0) 65 60 led_bl_set_brightness(priv, brightness);
+1 -7
drivers/video/backlight/lm3533_bl.c
··· 39 39 static int lm3533_bl_update_status(struct backlight_device *bd) 40 40 { 41 41 struct lm3533_bl *bl = bl_get_data(bd); 42 - int brightness = bd->props.brightness; 43 42 44 - if (bd->props.power != FB_BLANK_UNBLANK) 45 - brightness = 0; 46 - if (bd->props.fb_blank != FB_BLANK_UNBLANK) 47 - brightness = 0; 48 - 49 - return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness); 43 + return lm3533_ctrlbank_set_brightness(&bl->cb, backlight_get_brightness(bd)); 50 44 } 51 45 52 46 static int lm3533_bl_get_brightness(struct backlight_device *bd)
+1 -5
drivers/video/backlight/locomolcd.c
··· 111 111 112 112 static int locomolcd_set_intensity(struct backlight_device *bd) 113 113 { 114 - int intensity = bd->props.brightness; 114 + int intensity = backlight_get_brightness(bd); 115 115 116 - if (bd->props.power != FB_BLANK_UNBLANK) 117 - intensity = 0; 118 - if (bd->props.fb_blank != FB_BLANK_UNBLANK) 119 - intensity = 0; 120 116 if (locomolcd_flags & LOCOMOLCD_SUSPENDED) 121 117 intensity = 0; 122 118
+1 -6
drivers/video/backlight/lv5207lp.c
··· 46 46 static int lv5207lp_backlight_update_status(struct backlight_device *backlight) 47 47 { 48 48 struct lv5207lp *lv = bl_get_data(backlight); 49 - int brightness = backlight->props.brightness; 50 - 51 - if (backlight->props.power != FB_BLANK_UNBLANK || 52 - backlight->props.fb_blank != FB_BLANK_UNBLANK || 53 - backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) 54 - brightness = 0; 49 + int brightness = backlight_get_brightness(backlight); 55 50 56 51 if (brightness) { 57 52 lv5207lp_write(lv, LV5207LP_CTRL1,
+1 -12
drivers/video/backlight/max8925_bl.c
··· 64 64 65 65 static int max8925_backlight_update_status(struct backlight_device *bl) 66 66 { 67 - int brightness = bl->props.brightness; 68 - 69 - if (bl->props.power != FB_BLANK_UNBLANK) 70 - brightness = 0; 71 - 72 - if (bl->props.fb_blank != FB_BLANK_UNBLANK) 73 - brightness = 0; 74 - 75 - if (bl->props.state & BL_CORE_SUSPENDED) 76 - brightness = 0; 77 - 78 - return max8925_backlight_set(bl, brightness); 67 + return max8925_backlight_set(bl, backlight_get_brightness(bl)); 79 68 } 80 69 81 70 static int max8925_backlight_get_brightness(struct backlight_device *bl)
+1 -6
drivers/video/backlight/pwm_bl.c
··· 108 108 static int pwm_backlight_update_status(struct backlight_device *bl) 109 109 { 110 110 struct pwm_bl_data *pb = bl_get_data(bl); 111 - int brightness = bl->props.brightness; 111 + int brightness = backlight_get_brightness(bl); 112 112 struct pwm_state state; 113 - 114 - if (bl->props.power != FB_BLANK_UNBLANK || 115 - bl->props.fb_blank != FB_BLANK_UNBLANK || 116 - bl->props.state & BL_CORE_FBBLANK) 117 - brightness = 0; 118 113 119 114 if (pb->notify) 120 115 brightness = pb->notify(pb->dev, brightness);
+1 -6
drivers/video/backlight/qcom-wled.c
··· 433 433 static int wled_update_status(struct backlight_device *bl) 434 434 { 435 435 struct wled *wled = bl_get_data(bl); 436 - u16 brightness = bl->props.brightness; 436 + u16 brightness = backlight_get_brightness(bl); 437 437 int rc = 0; 438 - 439 - if (bl->props.power != FB_BLANK_UNBLANK || 440 - bl->props.fb_blank != FB_BLANK_UNBLANK || 441 - bl->props.state & BL_CORE_FBBLANK) 442 - brightness = 0; 443 438 444 439 mutex_lock(&wled->lock); 445 440 if (brightness) {
+1 -9
drivers/video/backlight/tps65217_bl.c
··· 77 77 { 78 78 struct tps65217_bl *tps65217_bl = bl_get_data(bl); 79 79 int rc; 80 - int brightness = bl->props.brightness; 81 - 82 - if (bl->props.state & BL_CORE_SUSPENDED) 83 - brightness = 0; 84 - 85 - if ((bl->props.power != FB_BLANK_UNBLANK) || 86 - (bl->props.fb_blank != FB_BLANK_UNBLANK)) 87 - /* framebuffer in low power mode or blanking active */ 88 - brightness = 0; 80 + int brightness = backlight_get_brightness(bl); 89 81 90 82 if (brightness > 0) { 91 83 rc = tps65217_reg_write(tps65217_bl->tps,
+1 -12
drivers/video/backlight/wm831x_bl.c
··· 91 91 92 92 static int wm831x_backlight_update_status(struct backlight_device *bl) 93 93 { 94 - int brightness = bl->props.brightness; 95 - 96 - if (bl->props.power != FB_BLANK_UNBLANK) 97 - brightness = 0; 98 - 99 - if (bl->props.fb_blank != FB_BLANK_UNBLANK) 100 - brightness = 0; 101 - 102 - if (bl->props.state & BL_CORE_SUSPENDED) 103 - brightness = 0; 104 - 105 - return wm831x_backlight_set(bl, brightness); 94 + return wm831x_backlight_set(bl, backlight_get_brightness(bl)); 106 95 } 107 96 108 97 static int wm831x_backlight_get_brightness(struct backlight_device *bl)