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(-)
Remove unnecessary tab and spaces in comment sentence, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_baudrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c index 48b5de6..b3f5ba9 100644 --- a/drivers/tty/tty_baudrate.c +++ b/drivers/tty/tty_baudrate.c @@ -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;
Fix coding style issues of block comments, reported by checkpatch.pl. Besides, add a period at the end of comment sentenses.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_baudrate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c index b3f5ba9..426b125 100644 --- a/drivers/tty/tty_baudrate.c +++ b/drivers/tty/tty_baudrate.c @@ -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
Add a blank line after declarations, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_buffer.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 9733469..5509b5d 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -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);
Remove the repeated word 'the' following advice of checkpatch.pl Besides, add a period at the end of comment sentence.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 5509b5d..721491df 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -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)
Fix coding style issues of block comments, reported by checkpatch.pl. Besides, add a period at the end of the sentenses.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_buffer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 721491df..e9ff5dd 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -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; }
Remove spaces before tabs following the advice of checkpatch.pl.
Signed-off-by: Xiaofei Tan tanxiaofei@huawei.com --- drivers/tty/tty_io.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 5b5e996..c5b0e49 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -33,7 +33,7 @@ * -- Nick Holloway alfie@dcs.warwick.ac.uk, 27th May 1993. * * Rewrote canonical mode and added more termios flags. - * -- julian@uhunix.uhcc.hawaii.edu (J. Cowley), 13Jan94 + * -- julian@uhunix.uhcc.hawaii.edu (J. Cowley), 13Jan94 * * Reorganized FASYNC support so mouse code can share it. * -- ctm@ardi.com, 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: ??