Fix some issues reported by checkpatch.pl. All of them are coding style issues, no function changes.
Differences from v2 to v3: - Fix the misunderstanding of 'period' for the patch 04/10.
Differences from v1 to v2: - Remove one redundant tab for the patch 02/10. - Add some expression optimization for some sentenses following - Jiri's advice for the patch 04/10.
Xiaofei Tan (10): tty/sysrq: Add a blank line after declarations tty/sysrq: Fix issues of code indent should use tabs tty: tty_jobctrl: Add a blank line after declarations tty: tty_jobctrl: Fix coding style issues of block comments tty: tty_jobctrl: Remove spaces before tabs tty: tty_ldisc: Fix an issue of code indent should use tabs tty: tty_ldisc: Add a blank line after declarations tty: tty_ldisc: Fix coding style issues of block comments tty: tty_ldisc: Do not use assignment in if condition tty: tty_ldisc: Remove the repeated word 'the'
drivers/tty/sysrq.c | 35 ++++++++++++++++++----------------- drivers/tty/tty_jobctrl.c | 29 +++++++++++++++++++---------- drivers/tty/tty_ldisc.c | 41 ++++++++++++++++++++++++++--------------- 3 files changed, 63 insertions(+), 42 deletions(-)
Add a blank line after declarations, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/sysrq.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 959f9e1..0372ed7 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -118,6 +118,7 @@ static const struct sysrq_key_op sysrq_loglevel_op = { static void sysrq_handle_SAK(int key) { struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work; + schedule_work(SAK_work); } static const struct sysrq_key_op sysrq_SAK_op = {
Fix issues of code indent should use tabs, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/sysrq.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 0372ed7..6628792 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -548,22 +548,22 @@ static int sysrq_key_table_key2index(int key) */ static const struct sysrq_key_op *__sysrq_get_key_op(int key) { - const struct sysrq_key_op *op_p = NULL; - int i; + const struct sysrq_key_op *op_p = NULL; + int i;
i = sysrq_key_table_key2index(key); if (i != -1) - op_p = sysrq_key_table[i]; + op_p = sysrq_key_table[i];
- return op_p; + return op_p; }
static void __sysrq_put_key_op(int key, const struct sysrq_key_op *op_p) { - int i = sysrq_key_table_key2index(key); + int i = sysrq_key_table_key2index(key);
- if (i != -1) - sysrq_key_table[i] = op_p; + if (i != -1) + sysrq_key_table[i] = op_p; }
void __handle_sysrq(int key, bool check_mask) @@ -587,8 +587,8 @@ void __handle_sysrq(int key, bool check_mask) orig_log_level = console_loglevel; console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
- op_p = __sysrq_get_key_op(key); - if (op_p) { + op_p = __sysrq_get_key_op(key); + if (op_p) { /* * Should we check for enabled operations (/proc/sysrq-trigger * should not) and is the invoked operation enabled? @@ -637,13 +637,13 @@ static int sysrq_reset_downtime_ms;
/* Simple translation table for the SysRq keys */ static const unsigned char sysrq_xlate[KEY_CNT] = - "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */ - "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */ - "dfghjkl;'`\000\zxcv" /* 0x20 - 0x2f */ - "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */ - "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */ - "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */ - "\r\000/"; /* 0x60 - 0x6f */ + "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */ + "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */ + "dfghjkl;'`\000\zxcv" /* 0x20 - 0x2f */ + "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */ + "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */ + "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */ + "\r\000/"; /* 0x60 - 0x6f */
struct sysrq_state { struct input_handle handle; @@ -1108,7 +1108,7 @@ int sysrq_toggle_support(int enable_mask) EXPORT_SYMBOL_GPL(sysrq_toggle_support);
static int __sysrq_swap_key_ops(int key, const struct sysrq_key_op *insert_op_p, - const struct sysrq_key_op *remove_op_p) + const struct sysrq_key_op *remove_op_p) { int retval;
Add a blank line after declarations, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_jobctrl.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c index 4b751b9..86070f7 100644 --- a/drivers/tty/tty_jobctrl.c +++ b/drivers/tty/tty_jobctrl.c @@ -75,6 +75,7 @@ void proc_clear_tty(struct task_struct *p) { unsigned long flags; struct tty_struct *tty; + spin_lock_irqsave(&p->sighand->siglock, flags); tty = p->signal->tty; p->signal->tty = NULL; @@ -173,6 +174,7 @@ EXPORT_SYMBOL_GPL(get_current_tty); void session_clear_tty(struct pid *session) { struct task_struct *p; + do_each_pid_task(session, PIDTYPE_SID, p) { proc_clear_tty(p); } while_each_pid_task(session, PIDTYPE_SID, p); @@ -269,6 +271,7 @@ void disassociate_ctty(int on_exit) tty_vhangup_session(tty); } else { struct pid *tty_pgrp = tty_get_pgrp(tty); + if (tty_pgrp) { kill_pgrp(tty_pgrp, SIGHUP, on_exit); if (!on_exit) @@ -280,6 +283,7 @@ void disassociate_ctty(int on_exit)
} else if (on_exit) { struct pid *old_pgrp; + spin_lock_irq(¤t->sighand->siglock); old_pgrp = current->signal->tty_old_pgrp; current->signal->tty_old_pgrp = NULL; @@ -328,6 +332,7 @@ void no_tty(void) between a new association and proc_clear_tty but possible we need to protect against this anyway */ struct task_struct *tsk = current; + disassociate_ctty(0); proc_clear_tty(tsk); }
Fix coding style issues of block comments, reported by checkpatch.pl. Besides, do some expression optimization for the sentenses.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_jobctrl.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c index 86070f7..5b4ab16 100644 --- a/drivers/tty/tty_jobctrl.c +++ b/drivers/tty/tty_jobctrl.c @@ -204,8 +204,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int exit_session) spin_lock_irq(&p->sighand->siglock); if (p->signal->tty == tty) { p->signal->tty = NULL; - /* We defer the dereferences outside fo - the tasklist lock */ + /* + * We defer the dereferences outside of + * the tasklist lock. + */ refs++; } if (!p->signal->leader) { @@ -328,9 +330,11 @@ void disassociate_ctty(int on_exit) */ void no_tty(void) { - /* FIXME: Review locking here. The tty_lock never covered any race - between a new association and proc_clear_tty but possible we need - to protect against this anyway */ + /* + * FIXME: Review locking here. The tty_lock never covered any race + * between a new association and proc_clear_tty but possibly we need + * to protect against this anyway. + */ struct task_struct *tsk = current;
disassociate_ctty(0); @@ -536,7 +540,7 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _ /* * (tty == real_tty) is a cheap way of * testing if the tty is NOT a master pty. - */ + */ if (tty == real_tty && current->signal->tty != real_tty) return -ENOTTY;
Remove spaces before tabs following the advice of checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_jobctrl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c index 5b4ab16..72df97b 100644 --- a/drivers/tty/tty_jobctrl.c +++ b/drivers/tty/tty_jobctrl.c @@ -244,10 +244,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int exit_session) * it wants to disassociate itself from its controlling tty. * * It performs the following functions: - * (1) Sends a SIGHUP and SIGCONT to the foreground process group - * (2) Clears the tty from being controlling the session - * (3) Clears the controlling tty for all processes in the - * session group. + * (1) Sends a SIGHUP and SIGCONT to the foreground process group + * (2) Clears the tty from being controlling the session + * (3) Clears the controlling tty for all processes in the + * session group. * * The argument on_exit is set to 1 if called when a process is * exiting; it is 0 if called by the ioctl TIOCNOTTY.
Fix an issue of code indent should use tabs, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_ldisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index 1ba74d6..2992319 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -459,7 +459,7 @@ static int tty_ldisc_open(struct tty_struct *tty, struct tty_ldisc *ld) WARN_ON(test_and_set_bit(TTY_LDISC_OPEN, &tty->flags)); if (ld->ops->open) { int ret; - /* BTM here locks versus a hangup event */ + /* BTM here locks versus a hangup event */ ret = ld->ops->open(tty); if (ret) clear_bit(TTY_LDISC_OPEN, &tty->flags);
Add a blank line after declarations, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_ldisc.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index 2992319..df0b589 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -771,6 +771,7 @@ void tty_ldisc_hangup(struct tty_struct *tty, bool reinit) int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty) { int retval = tty_ldisc_open(tty, tty->ldisc); + if (retval) return retval;
@@ -829,6 +830,7 @@ EXPORT_SYMBOL_GPL(tty_ldisc_release); int tty_ldisc_init(struct tty_struct *tty) { struct tty_ldisc *ld = tty_ldisc_get(tty, N_TTY); + if (IS_ERR(ld)) return PTR_ERR(ld); tty->ldisc = ld;
Fix coding style issues of block comments, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_ldisc.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index df0b589..874d238 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -529,9 +529,11 @@ static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) const char *name = tty_name(tty);
pr_warn("Falling back ldisc for %s.\n", name); - /* The traditional behaviour is to fall back to N_TTY, we - want to avoid falling back to N_NULL unless we have no - choice to avoid the risk of breaking anything */ + /* + * The traditional behaviour is to fall back to N_TTY, we + * want to avoid falling back to N_NULL unless we have no + * choice to avoid the risk of breaking anything + */ if (tty_ldisc_failto(tty, N_TTY) < 0 && tty_ldisc_failto(tty, N_NULL) < 0) panic("Couldn't open N_NULL ldisc for %s.", name); @@ -600,17 +602,21 @@ int tty_set_ldisc(struct tty_struct *tty, int disc) up_read(&tty->termios_rwsem); }
- /* At this point we hold a reference to the new ldisc and a - reference to the old ldisc, or we hold two references to - the old ldisc (if it was restored as part of error cleanup - above). In either case, releasing a single reference from - the old ldisc is correct. */ + /* + * At this point we hold a reference to the new ldisc and a + * reference to the old ldisc, or we hold two references to + * the old ldisc (if it was restored as part of error cleanup + * above). In either case, releasing a single reference from + * the old ldisc is correct. + */ new_ldisc = old_ldisc; out: tty_ldisc_unlock(tty);
- /* Restart the work queue in case no characters kick it off. Safe if - already running */ + /* + * Restart the work queue in case no characters kick it off. Safe if + * already running + */ tty_buffer_restart_work(tty->port); err: tty_ldisc_put(new_ldisc); /* drop the extra reference */ @@ -812,8 +818,10 @@ void tty_ldisc_release(struct tty_struct *tty) tty_ldisc_kill(o_tty); tty_ldisc_unlock_pair(tty, o_tty);
- /* And the memory resources remaining (buffers, termios) will be - disposed of when the kref hits zero */ + /* + * And the memory resources remaining (buffers, termios) will be + * disposed of when the kref hits zero + */
tty_ldisc_debug(tty, "released\n"); }
Do not use assignment in if condition following the advice of checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_ldisc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index 874d238..56e67f7 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -508,7 +508,8 @@ static int tty_ldisc_failto(struct tty_struct *tty, int ld) return PTR_ERR(disc); tty->ldisc = disc; tty_set_termios_ldisc(tty, ld); - if ((r = tty_ldisc_open(tty, disc)) < 0) + r = tty_ldisc_open(tty, disc); + if (r < 0) tty_ldisc_put(disc); return r; }
Remove the repeated word 'the' following advice of checkpatch.pl
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_ldisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index 56e67f7..fdc4fa3 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -147,7 +147,7 @@ static int tty_ldisc_autoload = IS_BUILTIN(CONFIG_LDISC_AUTOLOAD); * Returns: -EINVAL if the discipline index is not [N_TTY..NR_LDISCS] or * if the discipline is not registered * -EAGAIN if request_module() failed to load or register the - * the discipline + * discipline * -ENOMEM if allocation failure * * Otherwise, returns a pointer to the discipline and bumps the