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

backlight: omap1: Replace FB_BLANK_ states with simple on/off

The backlight is on for fb_blank eq FB_BLANK_UNBLANK, or off for
any other value in fb_blank. But the field fb_blank in struct
backlight_properties is deprecated and should not be used any
longer.

Replace the test for fb_blank in omap's backlight code with a
simple boolean parameter and push the test into the update_status
helper. Instead of reading fb_blank directly, decode the backlight
device's status with backlight_is_blank().

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20240319093915.31778-4-tzimmermann@suse.de
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Thomas Zimmermann and committed by
Lee Jones
bf8c9550 b7ad4c67

+18 -25
+18 -25
drivers/video/backlight/omap1_bl.c
··· 9 9 #include <linux/kernel.h> 10 10 #include <linux/init.h> 11 11 #include <linux/platform_device.h> 12 - #include <linux/fb.h> 13 12 #include <linux/backlight.h> 14 13 #include <linux/slab.h> 15 14 #include <linux/platform_data/omap1_bl.h> ··· 19 20 #define OMAPBL_MAX_INTENSITY 0xff 20 21 21 22 struct omap_backlight { 22 - int powermode; 23 + bool enabled; 23 24 int current_intensity; 24 25 25 26 struct device *dev; ··· 36 37 omap_writeb(enable, OMAP_PWL_CLK_ENABLE); 37 38 } 38 39 39 - static void omapbl_blank(struct omap_backlight *bl, int mode) 40 + static void omapbl_enable(struct omap_backlight *bl, bool enable) 40 41 { 41 - switch (mode) { 42 - case FB_BLANK_NORMAL: 43 - case FB_BLANK_VSYNC_SUSPEND: 44 - case FB_BLANK_HSYNC_SUSPEND: 45 - case FB_BLANK_POWERDOWN: 46 - omapbl_send_intensity(0); 47 - omapbl_send_enable(0); 48 - break; 49 - 50 - case FB_BLANK_UNBLANK: 42 + if (enable) { 51 43 omapbl_send_intensity(bl->current_intensity); 52 44 omapbl_send_enable(1); 53 - break; 45 + } else { 46 + omapbl_send_intensity(0); 47 + omapbl_send_enable(0); 54 48 } 55 49 } 56 50 ··· 53 61 struct backlight_device *bl_dev = dev_get_drvdata(dev); 54 62 struct omap_backlight *bl = bl_get_data(bl_dev); 55 63 56 - omapbl_blank(bl, FB_BLANK_POWERDOWN); 64 + omapbl_enable(bl, false); 57 65 return 0; 58 66 } 59 67 ··· 62 70 struct backlight_device *bl_dev = dev_get_drvdata(dev); 63 71 struct omap_backlight *bl = bl_get_data(bl_dev); 64 72 65 - omapbl_blank(bl, bl->powermode); 73 + omapbl_enable(bl, bl->enabled); 66 74 return 0; 67 75 } 68 76 #endif 69 77 70 - static int omapbl_set_power(struct backlight_device *dev, int state) 78 + static void omapbl_set_enabled(struct backlight_device *dev, bool enable) 71 79 { 72 80 struct omap_backlight *bl = bl_get_data(dev); 73 81 74 - omapbl_blank(bl, state); 75 - bl->powermode = state; 76 - 77 - return 0; 82 + omapbl_enable(bl, enable); 83 + bl->enabled = enable; 78 84 } 79 85 80 86 static int omapbl_update_status(struct backlight_device *dev) 81 87 { 82 88 struct omap_backlight *bl = bl_get_data(dev); 89 + bool enable; 83 90 84 91 if (bl->current_intensity != dev->props.brightness) { 85 - if (bl->powermode == FB_BLANK_UNBLANK) 92 + if (bl->enabled) 86 93 omapbl_send_intensity(dev->props.brightness); 87 94 bl->current_intensity = dev->props.brightness; 88 95 } 89 96 90 - if (dev->props.fb_blank != bl->powermode) 91 - omapbl_set_power(dev, dev->props.fb_blank); 97 + enable = !backlight_is_blank(dev); 98 + 99 + if (enable != bl->enabled) 100 + omapbl_set_enabled(dev, enable); 92 101 93 102 return 0; 94 103 } ··· 129 136 if (IS_ERR(dev)) 130 137 return PTR_ERR(dev); 131 138 132 - bl->powermode = FB_BLANK_POWERDOWN; 139 + bl->enabled = false; 133 140 bl->current_intensity = 0; 134 141 135 142 bl->pdata = pdata;