From patchwork Thu Feb 6 15:30:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 863669 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D286F233153; Thu, 6 Feb 2025 15:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738856452; cv=none; b=TwlAdylVHvmoxAaN3gbxGYh+Hoew63WoT7nQIyv8XzbryRXHO6h3AJeQdDXKdyAS00Ph3Ahw38EXGZ0lQLJlVyiHKHWulZHycHOeCCi1mDZtS8bnpPyubmO3o9zTSa7tIx611csKwTd2mFOcA2QYWSgrZg3Xo/I3HZkRTtmiaGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738856452; c=relaxed/simple; bh=lz7I91W2cfM3234Y7dwhDeYlhnpEVRpwP8ihLa2kFNY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pgySMXx1PCRUUQ7ZIiGHE8A41CIG1LarFFwKw63udDq+LP2H6iaP1H48a9FAIe2PcXO3oh5iXQ45XsLAizDwrNCsAC78wwpxoqSsENUZaRVPWdaVKKbIFn2KPJaYp2Fpf4kgwkXVRj5gmNjd9SNs0OLYtEpKUJd+U00g9Q7wMTU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 57A261F453; Thu, 6 Feb 2025 15:40:47 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 108F913AC0; Thu, 6 Feb 2025 15:40:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id kLW3Av/XpGf4PAAAD6G6ig (envelope-from ); Thu, 06 Feb 2025 15:40:47 +0000 From: Thomas Zimmermann 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 Subject: [PATCH 11/13] leds: backlight trigger: Move blank-state handling into helper Date: Thu, 6 Feb 2025 16:30:30 +0100 Message-ID: <20250206154033.697495-12-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206154033.697495-1-tzimmermann@suse.de> References: <20250206154033.697495-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU] X-Spam-Flag: NO X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 57A261F453 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: 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 --- 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; }