Linux LED subsystem development
 help / color / mirror / Atom feed
From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>,
	Andrew Lunn <andrew@lunn.ch>, Peng Fan <peng.fan@nxp.com>,
	"Mike Marciniszyn (Meta)" <mike.marciniszyn@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>, Kees Cook <kees@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org
Subject: [PATCH] leds: use assign_bit() where applicable
Date: Fri, 18 Sep 2026 22:17:23 +0800	[thread overview]
Message-ID: <20260918141728.3022983-1-peng.fan@oss.nxp.com> (raw)

From: Peng Fan <peng.fan@nxp.com>

Convert open-coded if/else with set_bit/clear_bit and their
non-atomic __set_bit/__clear_bit variants to the assign_bit/__assign_bit
API.

Done with Coccinelle semantic patch and manual fixups.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/leds/led-core.c               | 5 +----
 drivers/leds/leds-pca963x.c           | 5 +----
 drivers/leds/trigger/ledtrig-netdev.c | 5 +----
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 073c547068cc..80e281dce195 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -267,10 +267,7 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
 	set_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags);
 	clear_bit(LED_BLINK_ONESHOT_STOP, &led_cdev->work_flags);
 
-	if (invert)
-		set_bit(LED_BLINK_INVERT, &led_cdev->work_flags);
-	else
-		clear_bit(LED_BLINK_INVERT, &led_cdev->work_flags);
+	assign_bit(LED_BLINK_INVERT, &led_cdev->work_flags, invert);
 
 	led_blink_setup(led_cdev, delay_on, delay_off);
 }
diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index 605cf7497e4c..5363afbe93ea 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -208,10 +208,7 @@ static void pca963x_track_power_state(struct pca963x_led *led, unsigned int led_
 {
 	unsigned long *leds_on = &led->chip->leds_on;
 
-	if (brightness)
-		set_bit(led_num, leds_on);
-	else
-		clear_bit(led_num, leds_on);
+	assign_bit(led_num, leds_on, brightness);
 }
 
 static int pca963x_sync_power_state(struct pca963x_led *led, unsigned long cached_leds)
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index 5b4e92c14dbb..7e43fa30130c 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -414,10 +414,7 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
 		return -EINVAL;
 	}
 
-	if (state)
-		set_bit(bit, &mode);
-	else
-		clear_bit(bit, &mode);
+	assign_bit(bit, &mode, state);
 
 	if (test_bit(TRIGGER_NETDEV_LINK, &mode) &&
 	    (test_bit(TRIGGER_NETDEV_LINK_10, &mode) ||
-- 
2.51.0


             reply	other threads:[~2026-09-18 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 14:17 Peng Fan (OSS) [this message]
2026-09-18 14:26 ` [PATCH] leds: use assign_bit() where applicable sashiko-bot
2026-09-23 15:17 ` (subset) " Lee Jones

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=20260918141728.3022983-1-peng.fan@oss.nxp.com \
    --to=peng.fan@oss.nxp.com \
    --cc=andrew@lunn.ch \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mike.marciniszyn@gmail.com \
    --cc=pavel@kernel.org \
    --cc=peng.fan@nxp.com \
    /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