tty: Fix some coding style issues
cover tty: Fix some coding style issues
Fix some issues reported by checkpatch.pl. All of them are coding style issues, no function changes.
Xiaofei Tan (17):
tty: tty_baudrate: Remove unnecessary tab and spaces in comment
sentence
tty: tty_baudrate: Fix coding style issues of block comments
tty: tty_buffer: Add a blank line after declarations
tty: tty_buffer: Remove the repeated word 'the'
tty: tty_buffer: Fix coding style issues of block comments
tty: tty_io: Remove spaces before tabs
tty: tty_io: Add a blank line after declarations
tty: tty_io: Fix spaces required around that ':'
tty: tty_io: Fix trailing whitespace issues
tty: tty_io: Fix coding style issues of block comments
tty: tty_io: Remove the repeated word 'can'
tty: tty_io: Fix an issue of code indent for conditional statements
tty: tty_io: Delete a blank line before EXPORT_SYMBOL(foo)
tty: tty_io: Remove return in void function
tty: tty_port: Delete a blank line before EXPORT_SYMBOL(foo)
tty: tty_port: Add a blank line after declarations
tty: tty_port: Fix coding style issues of block comments
drivers/tty/tty_baudrate.c | 13 ++++++---- drivers/tty/tty_buffer.c | 20 +++++++++++---- drivers/tty/tty_io.c | 61 ++++++++++++++++++++++++++-------------------- drivers/tty/tty_port.c | 16 +++++++----- 4 files changed, 67 insertions(+), 43 deletions(-)
Signature · 1 line
2.8.1
PATCH 1/17 tty: tty_baudrate: Remove unnecessary tab and spaces in comment sentence
Remove unnecessary tab and spaces in comment sentence, reported by checkpatch.pl.
--- drivers/tty/tty_baudrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_baudrate.c +1 -1
@@ -147,7 +147,7 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,int iclose = ibaud/50 , oclose = obaud/50 ;int ibinput =0 ; -if (obaud ==0 )/* CD dropped */ +if (obaud ==0 )/* CD dropped */ ibaud =0 ;/* Clear ibaud to be sure */ termios->c_ispeed = ibaud;
Signature · 1 line
2.8.1
PATCH 2/17 tty: tty_baudrate: Fix coding style issues of block comments
In reply to Xiaofei TanFix coding style issues of block comments, reported by checkpatch.pl. Besides, add a period at the end of comment sentenses.
--- drivers/tty/tty_baudrate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/tty/tty_baudrate.c +7 -4
@@ -159,8 +159,9 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,#endif #ifdef BOTHER /* If the user asked for a precise weird speed give a precise weird -answer. If they asked for a Bfoo speed they may have problems -digesting non-exact replies so fuzz a bit */ +* answer. If they asked for a Bfoo speed they may have problems +* digesting non-exact replies so fuzz a bit. +*/ if ((termios->c_cflag &CBAUD ) ==BOTHER ) { oclose =0 ;
@@ -191,7 +192,8 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,if (ibaud - iclose <= baud_table[i] && ibaud + iclose >= baud_table[i]) {/* For the case input == output don't set IBAUD bits -if the user didn't do so */ +* if the user didn't do so. +*/ if (ofound == i && !ibinput) ifound = i;#ifdef IBSHIFT
@@ -211,7 +213,8 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,if (ofound ==-1 ) termios->c_cflag |=BOTHER ;/* Set exact input bits only if the input and output differ or the -user already did */ +* user already did. +*/ if (ifound ==-1 && (ibaud != obaud || ibinput)) termios->c_cflag |= (BOTHER <<IBSHIFT );#else
Signature · 1 line
2.8.1
PATCH 3/17 tty: tty_buffer: Add a blank line after declarations
In reply to Xiaofei TanAdd a blank line after declarations, reported by checkpatch.pl.
--- drivers/tty/tty_buffer.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/tty/tty_buffer.c +7 -0
@@ -91,6 +91,7 @@ EXPORT_SYMBOL_GPL(tty_buffer_unlock_exclusive);int tty_buffer_space_avail (struct tty_port *port) {int space = port->buf.mem_limit -atomic_read (&port->buf.mem_used); +return max (space,0 ); }EXPORT_SYMBOL_GPL (tty_buffer_space_avail);
@@ -312,11 +313,13 @@ int tty_insert_flip_string_fixed_flag(struct tty_port *port, const unsigned char *chars, char flag, size_t size) { int copied = 0; + do { int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0; int space = __tty_buffer_request_room(port, goal, flags); struct tty_buffer *tb = port->buf.tail; + if (unlikely(space == 0)) break; memcpy(char_buf_ptr(tb, tb->used), chars, space);
@@ -348,10 +351,12 @@ int tty_insert_flip_string_flags(struct tty_port *port, const unsigned char *chars, const char *flags, size_t size) { int copied = 0; + do { int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); int space = tty_buffer_request_room(port, goal); struct tty_buffer *tb = port->buf.tail; + if (unlikely(space == 0)) break; memcpy(char_buf_ptr(tb, tb->used), chars, space);
@@ -431,8 +436,10 @@ int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars, size_t size) {int space =__tty_buffer_request_room (port, size,TTYB_NORMAL ); +if (likely (space)) {struct tty_buffer *tb = port->buf.tail; + *chars =char_buf_ptr (tb, tb->used);if (~tb->flags &TTYB_NORMAL )memset (flag_buf_ptr (tb, tb->used),TTY_NORMAL , space);
Signature · 1 line
2.8.1
PATCH 4/17 tty: tty_buffer: Remove the repeated word 'the'
In reply to Xiaofei TanRemove the repeated word 'the' following advice of checkpatch.pl Besides, add a period at the end of comment sentence.
--- drivers/tty/tty_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/tty_buffer.c +2 -2
@@ -32,8 +32,8 @@* We default to dicing tty buffer allocations to this many characters * in order to avoid multiple page allocations. We know the size of * tty_buffer itself but it must also be taken into account that the -* the buffer is 256 byte aligned. See tty_buffer_find for the allocation -* logic this must match +* buffer is 256 byte aligned. See tty_buffer_find for the allocation +* logic this must match. */ #define TTY_BUFFER_PAGE (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF)
Signature · 1 line
2.8.1
PATCH 5/17 tty: tty_buffer: Fix coding style issues of block comments
In reply to Xiaofei TanFix coding style issues of block comments, reported by checkpatch.pl. Besides, add a period at the end of the sentenses.
--- drivers/tty/tty_buffer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/tty/tty_buffer.c +6 -3
@@ -170,7 +170,8 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size) }/* Should possibly check if this fails for the largest buffer we -have queued and recycle that ? */ +* have queued and recycle that ? +*/ if (atomic_read (&port->buf.mem_used) > port->buf.mem_limit)return NULL ; p =kmalloc (sizeof (struct tty_buffer ) +2 * size,GFP_ATOMIC );
@@ -329,7 +330,8 @@ int tty_insert_flip_string_fixed_flag(struct tty_port *port, copied += space; chars += space;/* There is a small chance that we need to split the data over -several buffers. If this is the case we must loop */ +* several buffers. If this is the case we must loop. +*/ }while (unlikely (size > copied));return copied; }
@@ -366,7 +368,8 @@ int tty_insert_flip_string_flags(struct tty_port *port, chars += space; flags += space;/* There is a small chance that we need to split the data over -several buffers. If this is the case we must loop */ +* several buffers. If this is the case we must loop. +*/ }while (unlikely (size > copied));return copied; }
Signature · 1 line
2.8.1
PATCH 6/17 tty: tty_io: Remove spaces before tabs
In reply to Xiaofei TanRemove spaces before tabs following the advice of checkpatch.pl.
--- drivers/tty/tty_io.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/tty/tty_io.c +8 -8
@@ -33,7 +33,7 @@* -- Nick Holloway <[email protected]>, 27th May 1993. * * Rewrote canonical mode and added more termios flags. -* -- [email protected] (J. Cowley), 13Jan94 +* -- [email protected] (J. Cowley), 13Jan94 * * Reorganized FASYNC support so mouse code can share it. * -- [email protected], 9Sep95
@@ -1114,7 +1114,7 @@ void tty_write_message(struct tty_struct *tty, char *msg)static ssize_t file_tty_write (struct file *file,struct kiocb *iocb,struct iov_iter *from) {struct tty_struct *tty =file_tty (file); -struct tty_ldisc *ld; +struct tty_ldisc *ld;ssize_t ret;if (tty_paranoia_check (tty,file_inode (file),"tty_write" ))
@@ -1928,8 +1928,8 @@ static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp)* @index: index for the device in the @return driver * @return: driver for this inode (with increased refcount) * -* If @return is not erroneous, the caller is responsible to decrement the -* refcount by tty_driver_kref_put. +* If @return is not erroneous, the caller is responsible to decrement the +* refcount by tty_driver_kref_put. * * Locking: tty_mutex protects get_tty_driver */
@@ -3317,11 +3317,11 @@ struct device *tty_register_device_attr(struct tty_driver *driver,EXPORT_SYMBOL_GPL (tty_register_device_attr);/** -* tty_unregister_device - unregister a tty device -* @driver: the tty driver that describes the tty device -* @index: the index in the tty driver for this tty device +* tty_unregister_device - unregister a tty device +* @driver: the tty driver that describes the tty device +* @index: the index in the tty driver for this tty device * -* If a tty device is registered with a call to tty_register_device() then +* If a tty device is registered with a call to tty_register_device() then * this function must be called when the tty device is gone. * * Locking: ??
Signature · 1 line
2.8.1
PATCH 7/17 tty: tty_io: Add a blank line after declarations
In reply to Xiaofei TanAdd a blank line after declarations, reported by checkpatch.pl.
--- drivers/tty/tty_io.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/tty/tty_io.c +10 -0
@@ -320,6 +320,7 @@ static struct tty_driver *get_tty_driver(dev_t device, int *index)list_for_each_entry (p, &tty_drivers, tty_drivers) {dev_t base =MKDEV (p->major, p->minor_start); +if (device < base || device >= base + p->num)continue ; *index = device - base;
@@ -1033,6 +1034,7 @@ static inline ssize_t do_tty_write(/* Do the write .. */ for (;;) {size_t size = count; +if (size > chunk) size = chunk;
@@ -1155,6 +1157,7 @@ ssize_t redirected_tty_write(struct kiocb *iocb, struct iov_iter *iter)*/ if (p) {ssize_t res; + res =file_tty_write (p, iocb, iter);fput (p);return res;
@@ -1942,6 +1945,7 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp,#ifdef CONFIG_VT case MKDEV (TTY_MAJOR ,0 ): {extern struct tty_driver *console_driver; + driver =tty_driver_kref_get (console_driver); *index = fg_console;break ;
@@ -1949,6 +1953,7 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp,#endif case MKDEV (TTYAUX_MAJOR ,1 ): {struct tty_driver *console_driver =console_device (index); +if (console_driver) { driver =tty_driver_kref_get (console_driver);if (driver && filp) {
@@ -2388,6 +2393,7 @@ EXPORT_SYMBOL(tty_do_resize);static int tiocswinsz (struct tty_struct *tty,struct winsize __user *arg) {struct winsize tmp_ws; +if (copy_from_user (&tmp_ws, arg,sizeof (*arg)))return -EFAULT ;
@@ -2412,6 +2418,7 @@ static int tioccons(struct file *file)return -EPERM ;if (file->f_op->write_iter == redirected_tty_write) {struct file *f; +spin_lock (&redirect_lock); f = redirect; redirect =NULL ;
@@ -2734,6 +2741,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case TIOCGEXCL : {int excl =test_bit (TTY_EXCLUSIVE , &tty->flags); +return put_user (excl, (int __user *)p); }case TIOCGETD :
@@ -2748,6 +2756,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case TIOCGDEV : {unsigned int ret =new_encode_dev (tty_devnum (real_tty)); +return put_user (ret, (unsigned int __user *)p); }/*
@@ -3103,6 +3112,7 @@ EXPORT_SYMBOL(do_SAK);static struct device *tty_get_device (struct tty_struct *tty) {dev_t devt =tty_devnum (tty); +return class_find_device_by_devt (tty_class, devt); }
Signature · 1 line
2.8.1
PATCH 8/17 tty: tty_io: Fix spaces required around that ':'
In reply to Xiaofei TanFix spaces required around that ':', reported by checkpatch.pl.
--- drivers/tty/tty_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_io.c +1 -1
@@ -2341,7 +2341,7 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) err =copy_to_user (arg, &tty->winsize,sizeof (*arg));mutex_unlock (&tty->winsize_mutex); -return err ? -EFAULT :0 ; +return err ? -EFAULT :0 ; }/**
Signature · 1 line
2.8.1
PATCH 9/17 tty: tty_io: Fix trailing whitespace issues
In reply to Xiaofei TanFix trailing whitespace issues, reported by checkpatch.pl.
--- drivers/tty/tty_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_io.c +1 -1
@@ -3015,7 +3015,7 @@ static int this_tty(const void *t, struct file *file, unsigned fd)return 0 ;return file_tty (file) != t ?0 : fd +1 ; } - +/* * This implements the "Secure Attention Key" --- the idea is to * prevent trojan horses by killing all processes associated with this
Signature · 1 line
2.8.1
PATCH 10/17 tty: tty_io: Fix coding style issues of block comments
In reply to Xiaofei TanFix coding style issues of block comments, reported by checkpatch.pl. Besides, add a period at the end of the sentenses.
--- drivers/tty/tty_io.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/tty/tty_io.c +12 -7
@@ -135,8 +135,9 @@ struct ktermios tty_std_termios = { /* for the benefit of tty drivers */EXPORT_SYMBOL (tty_std_termios);/* This list gets poked at by procfs and various bits of boot up code. This -could do with some rationalisation such as pulling the tty proc function -into this file */ +* could do with some rationalisation such as pulling the tty proc function +* into this file. +*/ LIST_HEAD (tty_drivers);/* linked list of tty drivers */
@@ -614,8 +615,9 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)set_bit (TTY_HUPPING , &tty->flags);/* inuse_filps is protected by the single tty lock, -this really needs to change if we want to flush the -workqueue with the lock held */ +* this really needs to change if we want to flush the +* workqueue with the lock held. +*/ check_tty_count (tty,"tty_hangup" );spin_lock (&tty->files_lock);
@@ -942,7 +944,8 @@ static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to)return -EIO ;/* We want to wait for the line discipline to sort out in this -situation */ +* situation. +*/ ld =tty_ldisc_ref_wait (tty);if (!ld)return hung_up_tty_read (iocb, to);
@@ -1572,7 +1575,8 @@ static void queue_release_one_tty(struct kref *kref) struct tty_struct *tty = container_of(kref, struct tty_struct, kref);/* The hangup queue is now free so we can reuse it rather than -waste a chunk of memory for each port */ +* waste a chunk of memory for each port. +*/ INIT_WORK (&tty->hangup_work, release_one_tty);schedule_work (&tty->hangup_work); }
@@ -1877,7 +1881,8 @@ int tty_release(struct inode *inode, struct file *filp)tty_unlock (tty);/* At this point, the tty->count == 0 should ensure a dead tty -cannot be re-opened by a racing opener */ +* cannot be re-opened by a racing opener. +*/ if (!final)return 0 ;
Signature · 1 line
2.8.1
PATCH 11/17 tty: tty_io: Remove the repeated word 'can'
In reply to Xiaofei TanRemove the repeated word 'can' following advice of checkpatch.pl
--- drivers/tty/tty_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_io.c +1 -1
@@ -1155,7 +1155,7 @@ ssize_t redirected_tty_write(struct kiocb *iocb, struct iov_iter *iter)spin_unlock (&redirect_lock);/* -* We know the redirected tty is just another tty, we can can +* We know the redirected tty is just another tty, we can * call file_tty_write() directly with that file pointer. */ if (p) {
Signature · 1 line
2.8.1
PATCH 12/17 tty: tty_io: Fix an issue of code indent for conditional statements
In reply to Xiaofei TanFix an issue of code indent for conditional statements,reported by checkpatch.pl.
--- drivers/tty/tty_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_io.c +1 -1
@@ -1125,7 +1125,7 @@ static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_if (tty_paranoia_check (tty,file_inode (file),"tty_write" ))return -EIO ;if (!tty || !tty->ops->write ||tty_io_error (tty)) -return -EIO ; +return -EIO ;/* Short term debug to catch buggy drivers */ if (tty->ops->write_room ==NULL )tty_err (tty,"missing write_room method\n" );
Signature · 1 line
2.8.1
PATCH 13/17 tty: tty_io: Delete a blank line before EXPORT_SYMBOL(foo)
In reply to Xiaofei TanDelete a blank line before EXPORT_SYMBOL(foo) so that EXPORT_SYMBOL(foo) immediately follow its function/variable, reported by checkpatch.pl.
--- drivers/tty/tty_io.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/tty/tty_io.c +0 -7
@@ -131,7 +131,6 @@ struct ktermios tty_std_termios = { /* for the benefit of tty drivers */ .c_ospeed = 38400,/* .c_line = N_TTY, */ }; -EXPORT_SYMBOL (tty_std_termios);/* This list gets poked at by procfs and various bits of boot up code. This
@@ -249,7 +248,6 @@ const char *tty_name(const struct tty_struct *tty)return "NULL tty" ;return tty->name; } -EXPORT_SYMBOL (tty_name);const char *tty_driver_name (const struct tty_struct *tty)
@@ -539,7 +537,6 @@ void tty_wakeup(struct tty_struct *tty) }wake_up_interruptible_poll (&tty->write_wait,EPOLLOUT ); } -EXPORT_SYMBOL_GPL (tty_wakeup);/**
@@ -697,7 +694,6 @@ void tty_hangup(struct tty_struct *tty)tty_debug_hangup (tty,"hangup\n" );schedule_work (&tty->hangup_work); } -EXPORT_SYMBOL (tty_hangup);/**
@@ -714,7 +710,6 @@ void tty_vhangup(struct tty_struct *tty)tty_debug_hangup (tty,"vhangup\n" );__tty_hangup (tty,0 ); } -EXPORT_SYMBOL (tty_vhangup);
@@ -764,7 +759,6 @@ int tty_hung_up_p(struct file *filp) {return (filp && filp->f_op == &hung_up_tty_fops); } -EXPORT_SYMBOL (tty_hung_up_p);/**
@@ -3110,7 +3104,6 @@ void do_SAK(struct tty_struct *tty)return ;schedule_work (&tty->SAK_work); } -EXPORT_SYMBOL (do_SAK);/* Must put_device() after it's unused! */
Signature · 1 line
2.8.1
PATCH 14/17 tty: tty_io: Remove return in void function
In reply to Xiaofei TanRemove return in void function, reported by checkpatch.pl.
--- drivers/tty/tty_io.c | 1 - 1 file changed, 1 deletion(-)
drivers/tty/tty_io.c +0 -1
@@ -1090,7 +1090,6 @@ void tty_write_message(struct tty_struct *tty, char *msg)tty_unlock (tty);tty_write_unlock (tty); } -return ; }
Signature · 1 line
2.8.1
PATCH 15/17 tty: tty_port: Delete a blank line before EXPORT_SYMBOL(foo)
In reply to Xiaofei TanDelete a blank line before EXPORT_SYMBOL(foo) so that EXPORT_SYMBOL(foo) immediately follow its function/variable, reported by checkpatch.pl.
--- drivers/tty/tty_port.c | 1 - 1 file changed, 1 deletion(-)
drivers/tty/tty_port.c +0 -1
@@ -698,5 +698,4 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,mutex_unlock (&port->mutex);return tty_port_block_til_ready (port, tty, filp); } -EXPORT_SYMBOL (tty_port_open);
Signature · 1 line
2.8.1
PATCH 16/17 tty: tty_port: Add a blank line after declarations
In reply to Xiaofei TanAdd a blank line after declarations, reported by checkpatch.pl.
--- drivers/tty/tty_port.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/tty_port.c +1 -0
@@ -688,6 +688,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,clear_bit (TTY_IO_ERROR , &tty->flags);if (port->ops->activate) {int retval = port->ops->activate (port, tty); +if (retval) {mutex_unlock (&port->mutex);return retval;
Signature · 1 line
2.8.1
PATCH 17/17 tty: tty_port: Fix coding style issues of block comments
In reply to Xiaofei TanFix coding style issues of block comments, reported by checkpatch.pl. Besides, add a period at the end of the sentenses.
--- drivers/tty/tty_port.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/tty/tty_port.c +9 -5
@@ -468,7 +468,8 @@ int tty_port_block_til_ready(struct tty_port *port,DEFINE_WAIT (wait);/* if non-blocking mode is set we can pass directly to open unless -the port has just hung up or is in another error state */ +* the port has just hung up or is in another error state. +*/ if (tty_io_error (tty)) {tty_port_set_active (port,1 );return 0 ;
@@ -485,8 +486,9 @@ int tty_port_block_til_ready(struct tty_port *port, do_clocal =1 ;/* Block waiting until we can proceed. We may need to wait for the -carrier, but we must also wait for any close that is in progress -before the next open may complete */ +* carrier, but we must also wait for any close that is in progress +* before the next open may complete. +*/ retval =0 ;
@@ -503,7 +505,8 @@ int tty_port_block_til_ready(struct tty_port *port,prepare_to_wait (&port->open_wait, &wait,TASK_INTERRUPTIBLE );/* Check for a hangup or uninitialised port. -Return accordingly */ +* Return accordingly. +*/ if (tty_hung_up_p (filp) || !tty_port_initialized (port)) {if (port->flags &ASYNC_HUP_NOTIFY ) retval = -EAGAIN ;
@@ -530,7 +533,8 @@ int tty_port_block_til_ready(struct tty_port *port,finish_wait (&port->open_wait, &wait);/* Update counts. A parallel hangup will have set count to zero and -we must not mess that up further */ +* we must not mess that up further. +*/ spin_lock_irqsave (&port->lock, flags);if (!tty_hung_up_p (filp)) port->count++;
Signature · 1 line
2.8.1