linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: pavel@ucw.cz, lee@kernel.org, danielt@kernel.org,
	jingoohan1@gmail.com, deller@gmx.de, simona@ffwll.ch
Cc: linux-leds@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-fbdev@vger.kernel.org,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH 11/13] leds: backlight trigger: Move blank-state handling into helper
Date: Thu,  6 Feb 2025 16:30:30 +0100	[thread overview]
Message-ID: <20250206154033.697495-12-tzimmermann@suse.de> (raw)
In-Reply-To: <20250206154033.697495-1-tzimmermann@suse.de>

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

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/leds/trigger/ledtrig-backlight.c | 33 ++++++++++++++----------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/leds/trigger/ledtrig-backlight.c b/drivers/leds/trigger/ledtrig-backlight.c
index c1c1aa60cf07..f9317f93483b 100644
--- a/drivers/leds/trigger/ledtrig-backlight.c
+++ b/drivers/leds/trigger/ledtrig-backlight.c
@@ -30,34 +30,39 @@ struct bl_trig_notifier {
 static struct list_head ledtrig_backlight_list;
 static struct mutex ledtrig_backlight_list_mutex;
 
+static void ledtrig_backlight_blank(struct bl_trig_notifier *n, bool on)
+{
+	struct led_classdev *led = n->led;
+	int new_status = !on ? BLANK : UNBLANK;
+
+	if (new_status == n->old_status)
+		return;
+
+	if ((n->old_status == UNBLANK) ^ n->invert) {
+		n->brightness = led->brightness;
+		led_set_brightness_nosleep(led, LED_OFF);
+	} else {
+		led_set_brightness_nosleep(led, n->brightness);
+	}
+
+	n->old_status = new_status;
+}
+
 static int fb_notifier_callback(struct notifier_block *p,
 				unsigned long event, void *data)
 {
 	struct bl_trig_notifier *n = container_of(p,
 					struct bl_trig_notifier, notifier);
-	struct led_classdev *led = n->led;
 	struct fb_event *fb_event = data;
 	int *blank;
-	int new_status;
 
 	/* If we aren't interested in this event, skip it immediately ... */
 	if (event != FB_EVENT_BLANK)
 		return 0;
 
 	blank = fb_event->data;
-	new_status = *blank ? BLANK : UNBLANK;
 
-	if (new_status == n->old_status)
-		return 0;
-
-	if ((n->old_status == UNBLANK) ^ n->invert) {
-		n->brightness = led->brightness;
-		led_set_brightness_nosleep(led, LED_OFF);
-	} else {
-		led_set_brightness_nosleep(led, n->brightness);
-	}
-
-	n->old_status = new_status;
+	ledtrig_backlight_blank(n, !blank[0]);
 
 	return 0;
 }
-- 
2.48.1


  parent reply	other threads:[~2025-02-06 15:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-06 15:30 [RFC PATCH 00/13] backlight, lcd, led: Remove fbdev dependencies Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 01/13] fbdev: Rework fb_blank() Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 02/13] fbdev: Track display blanking state Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 03/13] fbdev: Send old blank state in FB_EVENT_BLANK Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 04/13] backlight: Implement fbdev tracking with blank state from event Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 05/13] backlight: Move blank-state handling into helper Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 06/13] backlight: Replace fb events with a dedicated function call Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 07/13] backlight: lcd: Maintain global list of lcd devices Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 08/13] backlight: lcd: Move event handling into helpers Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 09/13] backlight: lcd: Replace fb events with a dedicated function call Thomas Zimmermann
2025-02-06 15:30 ` [PATCH 10/13] leds: backlight trigger: Maintain global list of led backlight triggers Thomas Zimmermann
2025-02-11 14:00   ` Lee Jones
2025-02-13 14:23     ` Thomas Zimmermann
2025-02-06 15:30 ` Thomas Zimmermann [this message]
2025-02-06 15:30 ` [PATCH 12/13] leds: backlight trigger: Replace fb events with a dedicated function call Thomas Zimmermann
2025-02-11 13:57   ` Lee Jones
2025-02-13 14:34     ` Thomas Zimmermann
2025-02-20 15:00       ` Lee Jones
2025-02-06 15:30 ` [PATCH 13/13] fbdev: Remove constants of unused events Thomas Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250206154033.697495-12-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=danielt@kernel.org \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).