@@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.fb_blank != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.state & BL_CORE_SUSPENDED)
+ if (backlight_is_blank(bl))
brightness = 0;
return pm860x_backlight_set(bl, brightness);
@@ -67,10 +67,7 @@ static int adp5520_bl_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.fb_blank != FB_BLANK_UNBLANK)
+ if (backlight_is_blank(bl))
brightness = 0;
return adp5520_bl_set(bl, brightness);
@@ -363,10 +363,7 @@ static int adp8860_bl_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.fb_blank != FB_BLANK_UNBLANK)
+ if (backlight_is_blank(bl))
brightness = 0;
return adp8860_bl_set(bl, brightness);
@@ -401,10 +401,7 @@ static int adp8870_bl_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.fb_blank != FB_BLANK_UNBLANK)
+ if (backlight_is_blank(bl))
brightness = 0;
return adp8870_bl_set(bl, brightness);
@@ -107,13 +107,11 @@ static int as3711_bl_update_status(struct backlight_device *bl)
int brightness = bl->props.brightness;
int ret = 0;
- dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n",
+ dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, state %x\n",
__func__, bl->props.brightness, bl->props.power,
- bl->props.fb_blank, bl->props.state);
+ bl->props.state);
- if (bl->props.power != FB_BLANK_UNBLANK ||
- bl->props.fb_blank != FB_BLANK_UNBLANK ||
- bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+ if (backlight_is_blank(bl))
brightness = 0;
if (data->type == AS3711_BL_SU1) {
@@ -84,9 +84,7 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)
struct bd6107 *bd = bl_get_data(backlight);
int brightness = backlight->props.brightness;
- if (backlight->props.power != FB_BLANK_UNBLANK ||
- backlight->props.fb_blank != FB_BLANK_UNBLANK ||
- backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+ if (backlight_is_blank(backlight))
brightness = 0;
if (brightness) {
@@ -422,10 +422,7 @@ static int corgi_bl_update_status(struct backlight_device *bd)
struct corgi_lcd *lcd = bl_get_data(bd);
int intensity = bd->props.brightness;
- if (bd->props.power != FB_BLANK_UNBLANK)
- intensity = 0;
-
- if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+ if (backlight_is_blank(bd))
intensity = 0;
if (corgibl_flags & CORGIBL_SUSPENDED)
@@ -59,26 +59,18 @@ struct cr_panel {
static int cr_backlight_set_intensity(struct backlight_device *bd)
{
- int intensity = bd->props.brightness;
u32 addr = gpio_bar + CRVML_PANEL_PORT;
u32 cur = inl(addr);
- if (bd->props.power == FB_BLANK_UNBLANK)
- intensity = FB_BLANK_UNBLANK;
- if (bd->props.fb_blank == FB_BLANK_UNBLANK)
- intensity = FB_BLANK_UNBLANK;
- if (bd->props.power == FB_BLANK_POWERDOWN)
- intensity = FB_BLANK_POWERDOWN;
- if (bd->props.fb_blank == FB_BLANK_POWERDOWN)
- intensity = FB_BLANK_POWERDOWN;
-
- if (intensity == FB_BLANK_UNBLANK) { /* FULL ON */
- cur &= ~CRVML_BACKLIGHT_OFF;
- outl(cur, addr);
- } else if (intensity == FB_BLANK_POWERDOWN) { /* OFF */
+ if (backlight_is_blank(bd)) {
+ /* OFF */
cur |= CRVML_BACKLIGHT_OFF;
outl(cur, addr);
- } /* anything else, don't bother */
+ } else {
+ /* FULL ON */
+ cur &= ~CRVML_BACKLIGHT_OFF;
+ outl(cur, addr);
+ }
return 0;
}
@@ -79,13 +79,7 @@ static int da903x_backlight_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.fb_blank != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.state & BL_CORE_SUSPENDED)
+ if (backlight_is_blank(bl))
brightness = 0;
return da903x_backlight_set(bl, brightness);
@@ -38,8 +38,7 @@ static int ep93xxbl_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK ||
- bl->props.fb_blank != FB_BLANK_UNBLANK)
+ if (backlight_is_blank(bl))
brightness = 0;
return ep93xxbl_set(bl, brightness);
@@ -25,9 +25,7 @@ static int gpio_backlight_get_next_brightness(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK ||
- bl->props.fb_blank != FB_BLANK_UNBLANK ||
- bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+ if (backlight_is_blank(bl))
brightness = 0;
return brightness;
@@ -35,9 +35,7 @@ static void hp680bl_send_intensity(struct backlight_device *bd)
u16 v;
int intensity = bd->props.brightness;
- if (bd->props.power != FB_BLANK_UNBLANK)
- intensity = 0;
- if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+ if (backlight_is_blank(bd))
intensity = 0;
if (hp680bl_suspended)
intensity = 0;
@@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)
jornada_ssp_start();
/* If backlight is off then really turn it off */
- if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
+ if (backlight_is_blank(bd)) {
ret = jornada_ssp_byte(BRIGHTNESSOFF);
if (ret != TXDUMMY) {
dev_info(&bd->dev, "brightness off timeout\n");
@@ -89,9 +89,7 @@ static int kb3886bl_send_intensity(struct backlight_device *bd)
{
int intensity = bd->props.brightness;
- if (bd->props.power != FB_BLANK_UNBLANK)
- intensity = 0;
- if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+ if (backlight_is_blank(bd))
intensity = 0;
if (kb3886bl_flags & KB3886BL_SUSPENDED)
intensity = 0;
@@ -56,9 +56,7 @@ static int led_bl_update_status(struct backlight_device *bl)
struct led_bl_data *priv = bl_get_data(bl);
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK ||
- bl->props.fb_blank != FB_BLANK_UNBLANK ||
- bl->props.state & BL_CORE_FBBLANK)
+ if (backlight_is_blank(bl))
brightness = 0;
if (brightness > 0)
@@ -41,9 +41,7 @@ static int lm3533_bl_update_status(struct backlight_device *bd)
struct lm3533_bl *bl = bl_get_data(bd);
int brightness = bd->props.brightness;
- if (bd->props.power != FB_BLANK_UNBLANK)
- brightness = 0;
- if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+ if (backlight_is_blank(bd))
brightness = 0;
return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness);
@@ -113,9 +113,7 @@ static int locomolcd_set_intensity(struct backlight_device *bd)
{
int intensity = bd->props.brightness;
- if (bd->props.power != FB_BLANK_UNBLANK)
- intensity = 0;
- if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+ if (backlight_is_blank(bd))
intensity = 0;
if (locomolcd_flags & LOCOMOLCD_SUSPENDED)
intensity = 0;
@@ -48,9 +48,7 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)
struct lv5207lp *lv = bl_get_data(backlight);
int brightness = backlight->props.brightness;
- if (backlight->props.power != FB_BLANK_UNBLANK ||
- backlight->props.fb_blank != FB_BLANK_UNBLANK ||
- backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+ if (backlight_is_blank(backlight))
brightness = 0;
if (brightness) {
@@ -66,13 +66,7 @@ static int max8925_backlight_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.fb_blank != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.state & BL_CORE_SUSPENDED)
+ if (backlight_is_blank(bl))
brightness = 0;
return max8925_backlight_set(bl, brightness);
@@ -111,9 +111,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
int brightness = bl->props.brightness;
struct pwm_state state;
- if (bl->props.power != FB_BLANK_UNBLANK ||
- bl->props.fb_blank != FB_BLANK_UNBLANK ||
- bl->props.state & BL_CORE_FBBLANK)
+ if (backlight_is_blank(bl))
brightness = 0;
if (pb->notify)
@@ -261,9 +261,7 @@ static int wled_update_status(struct backlight_device *bl)
u16 brightness = bl->props.brightness;
int rc = 0;
- if (bl->props.power != FB_BLANK_UNBLANK ||
- bl->props.fb_blank != FB_BLANK_UNBLANK ||
- bl->props.state & BL_CORE_FBBLANK)
+ if (backlight_is_blank(bl))
brightness = 0;
mutex_lock(&wled->lock);
@@ -82,9 +82,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl)
if (bl->props.state & BL_CORE_SUSPENDED)
brightness = 0;
- if ((bl->props.power != FB_BLANK_UNBLANK) ||
- (bl->props.fb_blank != FB_BLANK_UNBLANK))
- /* framebuffer in low power mode or blanking active */
+ if (backlight_is_blank(bl))
brightness = 0;
if (brightness > 0) {
@@ -93,13 +93,7 @@ static int wm831x_backlight_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
- if (bl->props.power != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.fb_blank != FB_BLANK_UNBLANK)
- brightness = 0;
-
- if (bl->props.state & BL_CORE_SUSPENDED)
+ if (backlight_is_blank(bl))
brightness = 0;
return wm831x_backlight_set(bl, brightness);
Replaces the open-coded checks if the state etc., with the backlight_is_blank() helper. This increases readability of the code and aling the functionality. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Cc: Lee Jones <lee.jones@linaro.org> Cc: Daniel Thompson <daniel.thompson@linaro.org> Cc: Jingoo Han <jingoohan1@gmail.com> Cc: Michael Hennerich <michael.hennerich@analog.com> Cc: Support Opensource <support.opensource@diasemi.com> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de> Cc: Andy Gross <agross@kernel.org> Cc: Bjorn Andersson <bjorn.andersson@linaro.org> Cc: linux-pwm@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org Cc: patches@opensource.cirrus.com --- drivers/video/backlight/88pm860x_bl.c | 8 +------- drivers/video/backlight/adp5520_bl.c | 5 +---- drivers/video/backlight/adp8860_bl.c | 5 +---- drivers/video/backlight/adp8870_bl.c | 5 +---- drivers/video/backlight/as3711_bl.c | 8 +++----- drivers/video/backlight/bd6107.c | 4 +--- drivers/video/backlight/corgi_lcd.c | 5 +---- drivers/video/backlight/cr_bllcd.c | 22 +++++++--------------- drivers/video/backlight/da903x_bl.c | 8 +------- drivers/video/backlight/ep93xx_bl.c | 3 +-- drivers/video/backlight/gpio_backlight.c | 4 +--- drivers/video/backlight/hp680_bl.c | 4 +--- drivers/video/backlight/jornada720_bl.c | 2 +- drivers/video/backlight/kb3886_bl.c | 4 +--- drivers/video/backlight/led_bl.c | 4 +--- drivers/video/backlight/lm3533_bl.c | 4 +--- drivers/video/backlight/locomolcd.c | 4 +--- drivers/video/backlight/lv5207lp.c | 4 +--- drivers/video/backlight/max8925_bl.c | 8 +------- drivers/video/backlight/pwm_bl.c | 4 +--- drivers/video/backlight/qcom-wled.c | 4 +--- drivers/video/backlight/tps65217_bl.c | 4 +--- drivers/video/backlight/wm831x_bl.c | 8 +------- 23 files changed, 31 insertions(+), 100 deletions(-)