Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

video: fbdev: amba-clcd: Always use msleep() for waiting

The driver uses in_atomic() to distinguish between mdelay() and msleep().

The usage of in_interrupt() in drivers is phased out and Linus clearly
requested that code which changes behaviour depending on context should
either be separated or the context be conveyed in an argument passed by the
caller, which usually knows the context.

I traced the usage of in_interrupt() back to its initial merge:
bfe694f833643 ("[ARM] Add ARM AMBA CLCD framebuffer driver.")
https://git.kernel.org/history/history/c/bfe694f833643

The driver has been removed and added back in the meantime.
I've been looking for the IRQ context as described in the comment and
couldn't find it. The functions calling clcdfb_sleep() also call
conditionally backlight_update_status() which acquires a mutex. If it is
okay to acquire a mutex then it is okay to use msleep() since both
functions must be used in preemptible context.

Replace clcdfb_sleep() with msleep().

Cc: Peter Collingbourne <pcc@google.com>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210208223810.388502-4-bigeasy@linutronix.de

authored by

Sebastian Andrzej Siewior and committed by
Daniel Vetter
1b588c82 51be84fc

+2 -15
+2 -15
drivers/video/fbdev/amba-clcd.c
··· 35 35 /* This is limited to 16 characters when displayed by X startup */ 36 36 static const char *clcd_name = "CLCD FB"; 37 37 38 - /* 39 - * Unfortunately, the enable/disable functions may be called either from 40 - * process or IRQ context, and we _need_ to delay. This is _not_ good. 41 - */ 42 - static inline void clcdfb_sleep(unsigned int ms) 43 - { 44 - if (in_atomic()) { 45 - mdelay(ms); 46 - } else { 47 - msleep(ms); 48 - } 49 - } 50 - 51 38 static inline void clcdfb_set_start(struct clcd_fb *fb) 52 39 { 53 40 unsigned long ustart = fb->fb.fix.smem_start; ··· 64 77 val &= ~CNTL_LCDPWR; 65 78 writel(val, fb->regs + fb->off_cntl); 66 79 67 - clcdfb_sleep(20); 80 + msleep(20); 68 81 } 69 82 if (val & CNTL_LCDEN) { 70 83 val &= ~CNTL_LCDEN; ··· 96 109 cntl |= CNTL_LCDEN; 97 110 writel(cntl, fb->regs + fb->off_cntl); 98 111 99 - clcdfb_sleep(20); 112 + msleep(20); 100 113 101 114 /* 102 115 * and now apply power.