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

Configure Feed

Select the types of activity you want to include in your feed.

backlight: Move blank-state handling into helper

Move the handling of blank-state updates into a separate helper,
so that is can be called without the fbdev event. No functional
changes.

As a minor improvement over the original code, the update replaces
manual locking with a guard.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: "Daniel Thompson (RISCstar)" <danielt@kernel.org>
Acked-by: Simona Vetter <simona.vetter@ffwll.ch>
Link: https://lore.kernel.org/r/20250321095517.313713-6-tzimmermann@suse.de
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Thomas Zimmermann and committed by
Lee Jones
4bfb77f3 726491f2

+27 -19
+27 -19
drivers/video/backlight/backlight.c
··· 80 80 81 81 #if defined(CONFIG_FB_CORE) || (defined(CONFIG_FB_CORE_MODULE) && \ 82 82 defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)) 83 + static void backlight_notify_blank(struct backlight_device *bd, 84 + struct device *display_dev, 85 + bool fb_on, bool prev_fb_on) 86 + { 87 + guard(mutex)(&bd->ops_lock); 88 + 89 + if (!bd->ops) 90 + return; 91 + if (bd->ops->controls_device && !bd->ops->controls_device(bd, display_dev)) 92 + return; 93 + 94 + if (fb_on && (!prev_fb_on || !bd->use_count)) { 95 + if (!bd->use_count++) { 96 + bd->props.state &= ~BL_CORE_FBBLANK; 97 + backlight_update_status(bd); 98 + } 99 + } else if (!fb_on && prev_fb_on && bd->use_count) { 100 + if (!(--bd->use_count)) { 101 + bd->props.state |= BL_CORE_FBBLANK; 102 + backlight_update_status(bd); 103 + } 104 + } 105 + } 106 + 83 107 /* 84 108 * fb_notifier_callback 85 109 * ··· 131 107 return 0; 132 108 133 109 bd = container_of(self, struct backlight_device, fb_notif); 134 - mutex_lock(&bd->ops_lock); 135 110 136 - if (!bd->ops) 137 - goto out; 138 - if (bd->ops->controls_device && !bd->ops->controls_device(bd, info->device)) 139 - goto out; 140 111 if (fb_bd && fb_bd != bd) 141 - goto out; 112 + return 0; 142 113 143 114 fb_on = fb_blank[0] == FB_BLANK_UNBLANK; 144 115 prev_fb_on = fb_blank[1] == FB_BLANK_UNBLANK; 145 116 146 - if (fb_on && (!prev_fb_on || !bd->use_count)) { 147 - if (!bd->use_count++) { 148 - bd->props.state &= ~BL_CORE_FBBLANK; 149 - backlight_update_status(bd); 150 - } 151 - } else if (!fb_on && prev_fb_on && bd->use_count) { 152 - if (!(--bd->use_count)) { 153 - bd->props.state |= BL_CORE_FBBLANK; 154 - backlight_update_status(bd); 155 - } 156 - } 157 - out: 158 - mutex_unlock(&bd->ops_lock); 117 + backlight_notify_blank(bd, info->device, fb_on, prev_fb_on); 118 + 159 119 return 0; 160 120 } 161 121