Skip to content

Commit 701454b

Browse files
Sebastian Andrzej Siewiorojeda
authored andcommitted
auxdisplay: Remove in_interrupt() usage.
charlcd_write() is invoked as a VFS->write() callback and as such it is always invoked from preemptible context and may sleep. charlcd_puts() is invoked from register/unregister callback which is preemptible. The reboot notifier callback is also invoked from preemptible context. Therefore there is no need to use in_interrupt() to figure out if it is safe to sleep because it always is. in_interrupt() and related context checks are being removed from non-core code. Using schedule() to schedule (and be friendly to others) is discouraged and cond_resched() should be used instead. Remove in_interrupt() and use cond_resched() to schedule every 32 iterations if needed. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Sebastian Andrzej Siewior <[email protected]> [mo: fixed a couple typos in comment and commit message] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 1e28eed commit 701454b

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

drivers/auxdisplay/charlcd.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,14 @@ static ssize_t charlcd_write(struct file *file, const char __user *buf,
470470
char c;
471471

472472
for (; count-- > 0; (*ppos)++, tmp++) {
473-
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
473+
if (((count + 1) & 0x1f) == 0) {
474474
/*
475-
* let's be a little nice with other processes
476-
* that need some CPU
475+
* charlcd_write() is invoked as a VFS->write() callback
476+
* and as such it is always invoked from preemptible
477+
* context and may sleep.
477478
*/
478-
schedule();
479+
cond_resched();
480+
}
479481

480482
if (get_user(c, tmp))
481483
return -EFAULT;
@@ -537,12 +539,8 @@ static void charlcd_puts(struct charlcd *lcd, const char *s)
537539
int count = strlen(s);
538540

539541
for (; count-- > 0; tmp++) {
540-
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
541-
/*
542-
* let's be a little nice with other processes
543-
* that need some CPU
544-
*/
545-
schedule();
542+
if (((count + 1) & 0x1f) == 0)
543+
cond_resched();
546544

547545
charlcd_write_char(lcd, *tmp);
548546
}

0 commit comments

Comments
 (0)