Commit b37cc220 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Miguel Ojeda

auxdisplay: ht16k33: Extract ht16k33_brightness_set()

Extract brightness handling into a helper function, so it can be called
from multiple places.
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: default avatarRobin van der Gracht <robin@protonic.nl>
Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent 85d93b16
......@@ -113,6 +113,22 @@ static int ht16k33_display_off(struct ht16k33_priv *priv)
return i2c_smbus_write_byte(priv->client, REG_DISPLAY_SETUP);
}
static int ht16k33_brightness_set(struct ht16k33_priv *priv,
unsigned int brightness)
{
int err;
if (brightness == 0)
return ht16k33_display_off(priv);
err = ht16k33_display_on(priv);
if (err)
return err;
return i2c_smbus_write_byte(priv->client,
REG_BRIGHTNESS | (brightness - 1));
}
static void ht16k33_fb_queue(struct ht16k33_priv *priv)
{
struct ht16k33_fbdev *fbdev = &priv->fbdev;
......@@ -197,13 +213,10 @@ static int ht16k33_bl_update_status(struct backlight_device *bl)
if (bl->props.power != FB_BLANK_UNBLANK ||
bl->props.fb_blank != FB_BLANK_UNBLANK ||
bl->props.state & BL_CORE_FBBLANK || brightness == 0) {
return ht16k33_display_off(priv);
}
bl->props.state & BL_CORE_FBBLANK)
brightness = 0;
ht16k33_display_on(priv);
return i2c_smbus_write_byte(priv->client,
REG_BRIGHTNESS | (brightness - 1));
return ht16k33_brightness_set(priv, brightness);
}
static int ht16k33_bl_check_fb(struct backlight_device *bl, struct fb_info *fi)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment