public inbox for linux-leds@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] leds: ns2: Remove work queue
@ 2021-12-10 13:52 Dan Carpenter
  2021-12-15 20:39 ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2021-12-10 13:52 UTC (permalink / raw)
  To: linux-leds; +Cc: j.anaszewski

Hello LED devs,

The patch c29e650b3af2: "leds: ns2: Remove work queue" from Nov 20,
2015, leads to the following Smatch static checker warning:

	drivers/leds/leds-ns2.c:96 ns2_led_set_mode()
	warn: sleeping in atomic context

drivers/leds/leds-ns2.c
    76 static void ns2_led_set_mode(struct ns2_led *led, enum ns2_led_modes mode)
    77 {
    78         int i;
    79         unsigned long flags;
    80 
    81         for (i = 0; i < led->num_modes; i++)
    82                 if (mode == led->modval[i].mode)
    83                         break;
    84 
    85         if (i == led->num_modes)
    86                 return;
    87 
    88         write_lock_irqsave(&led->rw_lock, flags);
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Holding a write lock (spin lock).

    89 
    90         if (!led->can_sleep) {
                    ^^^^^^^^^^^^^^^
Even if the led->can_sleep flag is set, we are not actually allowed to
sleep when the preempt count is non-zero.  Presumably we should make
this unconditional.

    91                 gpiod_set_value(led->cmd, led->modval[i].cmd_level);
    92                 gpiod_set_value(led->slow, led->modval[i].slow_level);
    93                 goto exit_unlock;
    94         }
    95 
--> 96         gpiod_set_value_cansleep(led->cmd, led->modval[i].cmd_level);
    97         gpiod_set_value_cansleep(led->slow, led->modval[i].slow_level);
               ^^^^^^^^^^^^^^^^^^^^^^^^^
These functions can sleep.

    98 
    99 exit_unlock:
    100         write_unlock_irqrestore(&led->rw_lock, flags);
    101 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-20 17:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-10 13:52 [bug report] leds: ns2: Remove work queue Dan Carpenter
2021-12-15 20:39 ` Pavel Machek
2021-12-15 21:04   ` Marek Behún
2021-12-16 10:30     ` Simon Guinot
2021-12-20 17:00     ` Ian Pilcher
2021-12-16 10:28   ` Simon Guinot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox