Skip to contentSkip to conversation

auxdisplay: charlcd: delete mdelay in long_sleep

PATCH In review Jia-Ju Bai 3 participants 4 messages Jan 26, 2018 – Feb 12, 2018 Auxiliary display drivers

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH 1/1 auxdisplay: charlcd: delete mdelay in long_sleep

The function long_sleep() calls mdelay() when in an interrupt handler. But only charlcd_clear_display() and charlcd_init_display calls long_sleep(), and my tool finds that the two functions
are never called in an interrupt handler.
Thus mdelay() and in_interrupt() are not necessary.

This is found by a static analysis tool named DCNS written by myself.

---
 drivers/auxdisplay/charlcd.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/auxdisplay/charlcd.c +1 -4
index 642afd8..9e84795 100644
@@ -102,10 +102,7 @@ struct charlcd_priv {
 /* sleeps that many milliseconds with a reschedule */
 static void long_sleep(int ms)
 {
-	if (in_interrupt())
-		mdelay(ms);
-	else
-		schedule_timeout_interruptible(msecs_to_jiffies(ms));
+	schedule_timeout_interruptible(msecs_to_jiffies(ms));
 }
 
 /* turn the backlight on or off */
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 7 lines · Jia-Ju Bai

The function long_sleep() calls mdelay() when in an interrupt handler. But only charlcd_clear_display() and charlcd_init_display calls long_sleep(), and my tool finds that the two functions
are never called in an interrupt handler.
Thus mdelay() and in_interrupt() are not necessary.

This is found by a static analysis tool named DCNS written by myself.

Looks good. This code is extremely old (started in 2.2) so I'm not surprised at all that after many changes such parts are not used anymore.

Willy

#2 lore raw
Quoted 9 lines · Willy Tarreau

Hi,

Quoted 6 lines · Jia-Ju Bai

The function long_sleep() calls mdelay() when in an interrupt handler. But only charlcd_clear_display() and charlcd_init_display calls long_sleep(), and my tool finds that the two functions
are never called in an interrupt handler.
Thus mdelay() and in_interrupt() are not necessary.

Quoted 7 lines
Quoted 1 line

This is found by a static analysis tool named DCNS written by myself.

Looks good. This code is extremely old (started in 2.2) so I'm not surprised at all that after many changes such parts are not used anymore.

Thanks for the patch and the ack, putting it in the queue.

Miguel

Quoted 2 lines

Willy

#3 lore raw
In reply to Willy Tarreau
Quoted 9 lines · Willy Tarreau

Hi,

Quoted 6 lines · Jia-Ju Bai

The function long_sleep() calls mdelay() when in an interrupt handler. But only charlcd_clear_display() and charlcd_init_display calls long_sleep(), and my tool finds that the two functions
are never called in an interrupt handler.
Thus mdelay() and in_interrupt() are not necessary.

Quoted 5 lines
Quoted 1 line

This is found by a static analysis tool named DCNS written by myself.

Looks good. This code is extremely old (started in 2.2) so I'm not surprised at all that after many changes such parts are not used anymore.

By the way, maybe msleep_interruptible() should be used instead? (since I guess you want a minimum time here, no?). It would also take care of the jiffies to ms conversion, so the whole long_jump could be removed.

Quoted 4 lines

Willy