All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Derek J. Clark" <derekjohn.clark@gmail.com>
To: jikos@kernel.org, bentiss@kernel.org
Cc: linux-input@vger.kernel.org,
	kernel@lists.opengamingcollective.org,
	gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	pgriffais@valvesoftware.com, derekjohn.clark@gmail.com
Subject: [PATCH 7/8] HID: hid-msi: Switch the RGB LED to brightness_set_blocking
Date: Thu,  3 Dec 2026 16:18:45 -0800	[thread overview]
Message-ID: <20261204001846.3801336-8-derekjohn.clark@gmail.com> (raw)
In-Reply-To: <20261204001846.3801336-1-derekjohn.clark@gmail.com>

brightness_set must not sleep, so led-core may call it from the blink
timer or a trigger's hardirq. The work this handler queues is an HID
transaction, so register brightness_set_blocking instead, like
hid-playstation does for the DualSense lightbar.

No path that led-core uses to reach this handler sleeps, so this is an
interface correction rather than a bug fix.

Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
---
 drivers/hid/hid-msi.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-msi.c b/drivers/hid/hid-msi.c
index d2cd0d7397aa..f4b592c7d297 100644
--- a/drivers/hid/hid-msi.c
+++ b/drivers/hid/hid-msi.c
@@ -1716,8 +1716,8 @@ static ssize_t speed_range_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(speed_range);
 
-static void claw_led_brightness_set(struct led_classdev *led_cdev,
-				    enum led_brightness _brightness)
+static int claw_led_brightness_set_blocking(struct led_classdev *led_cdev,
+					    enum led_brightness brightness)
 {
 	struct led_classdev_mc *led_mc = container_of(led_cdev, struct led_classdev_mc, led_cdev);
 	struct claw_drvdata *drvdata = container_of(led_mc, struct claw_drvdata, led_mc);
@@ -1725,10 +1725,16 @@ static void claw_led_brightness_set(struct led_classdev *led_cdev,
 	scoped_guard(spinlock_irqsave, &drvdata->registration_lock) {
 		/* Pairs with smp_store_release from cfg_setup_fn in system_percpu_wq context */
 		if (!smp_load_acquire(&drvdata->rgb_registered))
-			return;
+			return 0;
 	}
 
+	scoped_guard(spinlock_irqsave, &drvdata->frame_lock)
+		led_cdev->brightness = min_t(unsigned int, brightness,
+					     led_cdev->max_brightness);
+
 	claw_rgb_schedule(drvdata);
+
+	return 0;
 }
 
 static struct attribute *claw_rgb_attrs[] = {
@@ -1946,7 +1952,7 @@ static int claw_probe(struct hid_device *hdev, u8 ep)
 	drvdata->led_mc.led_cdev.brightness = 0x50;
 	drvdata->led_mc.led_cdev.max_brightness = 0x64;
 	drvdata->led_mc.led_cdev.color = LED_COLOR_ID_RGB;
-	drvdata->led_mc.led_cdev.brightness_set = claw_led_brightness_set;
+	drvdata->led_mc.led_cdev.brightness_set_blocking = claw_led_brightness_set_blocking;
 	drvdata->led_mc.num_colors = 3;
 	drvdata->led_mc.subled_info = devm_kmemdup(&hdev->dev, claw_rgb_subled_info,
 						   sizeof(claw_rgb_subled_info), GFP_KERNEL);
-- 
2.56.0


  parent reply	other threads:[~2026-12-04  0:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  0:18 [PATCH 0/8] MSI Claw suspend, resume and ROM commit fixes Derek J. Clark
2026-12-04  0:18 ` [PATCH 1/8] HID: hid-msi: Queue the RGB work item on system_dfl_wq Derek J. Clark
2026-12-04  0:18 ` [PATCH 2/8] HID: hid-msi: Move the ROM commit to an explicit apply attribute Derek J. Clark
2026-12-04  0:35   ` sashiko-bot
2026-12-04  0:18 ` [PATCH 3/8] HID: hid-msi: Protect the RGB state with frame_lock Derek J. Clark
2026-12-04  0:18 ` [PATCH 4/8] HID: hid-msi: Re-init on reset during resume Derek J. Clark
2026-12-04  0:37   ` sashiko-bot
2026-12-04  0:18 ` [PATCH 5/8] HID: hid-msi: Drain in-flight MCU traffic before suspend Derek J. Clark
2026-12-04  0:38   ` sashiko-bot
2026-12-04  0:18 ` [PATCH 6/8] HID: hid-msi: Defer RGB updates while the MCU is suspended Derek J. Clark
2026-12-04  0:32   ` sashiko-bot
2026-12-04  0:18 ` Derek J. Clark [this message]
2026-12-04  0:39   ` [PATCH 7/8] HID: hid-msi: Switch the RGB LED to brightness_set_blocking sashiko-bot
2026-12-04  0:18 ` [PATCH 8/8] USB: core: quirks: Add RESET_RESUME quirk for MSI Claw Derek J. Clark
2026-12-04  0:39 ` [PATCH 0/8] MSI Claw suspend, resume and ROM commit fixes sashiko-bot

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=20261204001846.3801336-8-derekjohn.clark@gmail.com \
    --to=derekjohn.clark@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jikos@kernel.org \
    --cc=kernel@lists.opengamingcollective.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pgriffais@valvesoftware.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.