tty: minor cleanups
Subsystems (13)
Jiri Slaby (SUSE)
maintainercover tty: minor cleanups
This is another round of minor cleanups in the tty/serial/related drivers.
Jiri Slaby (SUSE) (10):
serial: move WARN_ON() in uart_write() to the condition
Bluetooth: rfcomm: remove casts from tty->driver_data
tty: hvsi: remove an extra variable from hvsi_write()
input: serport: remove casts from tty->disc_data
can: slcan: remove casts from tty->disc_data
serial: altera_jtaguart: switch status to u32
speakup: switch to unsigned iterator in spk_ttyio_receive_buf2()
misc: ti-st: remove forward declarations and make st_int_recv() static
misc: ti-st: remove ptr from recv functions
misc: ti-st: don't check for tty data == NULL
drivers/accessibility/speakup/spk_ttyio.c | 2 +- drivers/input/serio/serport.c | 10 +++++----- drivers/misc/ti-st/st_core.c | 11 +++-------- drivers/misc/ti-st/st_kim.c | 9 +-------- drivers/net/can/slcan/slcan-core.c | 8 ++++---- drivers/tty/hvc/hvsi.c | 3 +-- drivers/tty/serial/altera_jtaguart.c | 2 +- drivers/tty/serial/serial_core.c | 8 ++------ net/bluetooth/rfcomm/tty.c | 22 +++++++++++----------- 9 files changed, 29 insertions(+), 46 deletions(-)
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 1/10 serial: move WARN_ON() in uart_write() to the condition
uart code currently does the following in uart_write() and uart_flush_buffer():
if (cond) {
WARN_ON(1);
return;}
It can be rewritten to more obvious and more readable:
if (WARN_ON(cond))
return;
Do so.
--- drivers/tty/serial/serial_core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/tty/serial/serial_core.c +2 -6
@@ -593,10 +593,8 @@ static int uart_write(struct tty_struct *tty,* This means you called this function _after_ the port was * closed. No cookie for you. */ -if (!state) { -WARN_ON (1 ); +if (WARN_ON (!state))return -EL3HLT ; - } port =uart_port_lock (state, flags); circ = &state->xmit;
@@ -659,10 +657,8 @@ static void uart_flush_buffer(struct tty_struct *tty)* This means you called this function _after_ the port was * closed. No cookie for you. */ -if (!state) { -WARN_ON (1 ); +if (WARN_ON (!state))return ; - }pr_debug ("uart_flush_buffer(%d) called\n" , tty->index);
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 2/10 Bluetooth: rfcomm: remove casts from tty->driver_data
In reply to Jiri Slaby (SUSE)tty->driver_data is 'void *', so there is no need to cast from that. Therefore remove the casts and assign the pointer directly.
--- net/bluetooth/rfcomm/tty.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
net/bluetooth/rfcomm/tty.c +11 -11
@@ -771,7 +771,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)static void rfcomm_tty_close (struct tty_struct *tty,struct file *filp) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;BT_DBG ("tty %p dev %p dlc %p opened %d" , tty, dev, dev->dlc, dev->port.count);
@@ -781,7 +781,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)static int rfcomm_tty_write (struct tty_struct *tty,const unsigned char *buf,int count) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;struct rfcomm_dlc *dlc = dev->dlc;struct sk_buff *skb;int sent =0 , size;
@@ -810,7 +810,7 @@ static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, instatic unsigned int rfcomm_tty_write_room (struct tty_struct *tty) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;int room =0 ;if (dev && dev->dlc)
@@ -864,7 +864,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty,u8 baud, data_bits, stop_bits, parity, x_on, x_off;u16 changes =0 ; -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;BT_DBG ("tty %p termios %p" , tty, old);
@@ -996,7 +996,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty,static void rfcomm_tty_throttle (struct tty_struct *tty) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;BT_DBG ("tty %p dev %p" , tty, dev);
@@ -1005,7 +1005,7 @@ static void rfcomm_tty_throttle(struct tty_struct *tty)static void rfcomm_tty_unthrottle (struct tty_struct *tty) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;BT_DBG ("tty %p dev %p" , tty, dev);
@@ -1014,7 +1014,7 @@ static void rfcomm_tty_unthrottle(struct tty_struct *tty)static unsigned int rfcomm_tty_chars_in_buffer (struct tty_struct *tty) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;BT_DBG ("tty %p dev %p" , tty, dev);
@@ -1029,7 +1029,7 @@ static unsigned int rfcomm_tty_chars_in_buffer(struct tty_struct *tty)static void rfcomm_tty_flush_buffer (struct tty_struct *tty) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;BT_DBG ("tty %p dev %p" , tty, dev);
@@ -1052,7 +1052,7 @@ static void rfcomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)static void rfcomm_tty_hangup (struct tty_struct *tty) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;BT_DBG ("tty %p dev %p" , tty, dev);
@@ -1061,7 +1061,7 @@ static void rfcomm_tty_hangup(struct tty_struct *tty)static int rfcomm_tty_tiocmget (struct tty_struct *tty) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;BT_DBG ("tty %p dev %p" , tty, dev);
@@ -1070,7 +1070,7 @@ static int rfcomm_tty_tiocmget(struct tty_struct *tty)static int rfcomm_tty_tiocmset (struct tty_struct *tty,unsigned int set,unsigned int clear) { -struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; +struct rfcomm_dev *dev = tty->driver_data;struct rfcomm_dlc *dlc = dev->dlc;u8 v24_sig;
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 3/10 tty: hvsi: remove an extra variable from hvsi_write()
In reply to Jiri Slaby (SUSE)'source' is the same as 'buf'. Rename the parameter ('buf') to 'source' and drop the local variable.
Likely, the two were introduced to have a different type. But 'char' and 'unsigned char' are the same in the kernel for a long time.
--- drivers/tty/hvc/hvsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/hvc/hvsi.c +1 -2
@@ -905,10 +905,9 @@ static unsigned int hvsi_chars_in_buffer(struct tty_struct *tty) }static int hvsi_write (struct tty_struct *tty, -const unsigned char *buf,int count) +const unsigned char *source,int count) {struct hvsi_struct *hp = tty->driver_data; -const char *source = buf;unsigned long flags;int total =0 ;int origcount = count;
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 4/10 input: serport: remove casts from tty->disc_data
In reply to Jiri Slaby (SUSE)tty->disc_data is 'void *', so there is no need to cast from that. Therefore remove the casts and assign the pointer directly.
--- drivers/input/serio/serport.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/input/serio/serport.c +5 -5
@@ -103,7 +103,7 @@ static int serport_ldisc_open(struct tty_struct *tty)static void serport_ldisc_close (struct tty_struct *tty) { -struct serport *serport = (struct serport *) tty->disc_data; +struct serport *serport = tty->disc_data;kfree (serport); }
@@ -117,7 +117,7 @@ static void serport_ldisc_close(struct tty_struct *tty)static void serport_ldisc_receive (struct tty_struct *tty,const unsigned char *cp,const char *fp,int count) { -struct serport *serport = (struct serport *) tty->disc_data; +struct serport *serport = tty->disc_data;unsigned long flags;unsigned int ch_flags =0 ;int i;
@@ -161,7 +161,7 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, unsigned char *kbuf, size_t nr, void **cookie, unsigned long offset) { - struct serport *serport = (struct serport*) tty->disc_data; + struct serport *serport = tty->disc_data;struct serio *serio;if (test_and_set_bit (SERPORT_BUSY , &serport->flags))
@@ -245,7 +245,7 @@ static int serport_ldisc_compat_ioctl(struct tty_struct *tty,static void serport_ldisc_hangup (struct tty_struct *tty) { -struct serport *serport = (struct serport *) tty->disc_data; +struct serport *serport = tty->disc_data;unsigned long flags;spin_lock_irqsave (&serport->lock, flags);
@@ -257,7 +257,7 @@ static void serport_ldisc_hangup(struct tty_struct *tty)static void serport_ldisc_write_wakeup (struct tty_struct * tty) { -struct serport *serport = (struct serport *) tty->disc_data; +struct serport *serport = tty->disc_data;unsigned long flags;spin_lock_irqsave (&serport->lock, flags);
Signature · 1 line
2.41.0
Re: [PATCH 04/10] input: serport: remove casts from tty->disc_data
Quoted 6 lines · Jiri Slaby (SUSE)
tty->disc_datais 'void *', so there is no need to cast from that. Therefore remove the casts and assign the pointer directly.Signed-off-by Jiri Slaby (SUSE) <[email protected]>Cc Dmitry Torokhov <[email protected]>
Thanks.
Signature · 1 line
Dmitry
Jiri Slaby (SUSE)
maintainerPATCH 5/10 can: slcan: remove casts from tty->disc_data
In reply to Jiri Slaby (SUSE)tty->disc_data is 'void *', so there is no need to cast from that. Therefore remove the casts and assign the pointer directly.
--- drivers/net/can/slcan/slcan-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/can/slcan/slcan-core.c +4 -4
@@ -583,7 +583,7 @@ static void slcan_transmit(struct work_struct *work)*/ static void slcan_write_wakeup (struct tty_struct *tty) { -struct slcan *sl = (struct slcan *)tty->disc_data; +struct slcan *sl = tty->disc_data;schedule_work (&sl->tx_work); }
@@ -778,7 +778,7 @@ static void slcan_receive_buf(struct tty_struct *tty, const unsigned char *cp, const char *fp, int count) { - struct slcan *sl = (struct slcan *)tty->disc_data; + struct slcan *sl = tty->disc_data;if (!netif_running (sl->dev))return ;
@@ -862,7 +862,7 @@ static int slcan_open(struct tty_struct *tty)*/ static void slcan_close (struct tty_struct *tty) { -struct slcan *sl = (struct slcan *)tty->disc_data; +struct slcan *sl = tty->disc_data;unregister_candev (sl->dev);
@@ -886,7 +886,7 @@ static void slcan_close(struct tty_struct *tty)static int slcan_ioctl (struct tty_struct *tty,unsigned int cmd,unsigned long arg) { -struct slcan *sl = (struct slcan *)tty->disc_data; +struct slcan *sl = tty->disc_data;unsigned int tmp;switch (cmd) {
Signature · 1 line
2.41.0
Re: [PATCH 05/10] can: slcan: remove casts from tty->disc_data
Quoted 13 lines · Jiri Slaby (SUSE)
tty->disc_datais 'void *', so there is no need to cast from that. Therefore remove the casts and assign the pointer directly.Signed-off-by Jiri Slaby (SUSE) <[email protected]>Cc Dario Binacchi <[email protected]>Cc Wolfgang Grandegger <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Jiri Slaby (SUSE)
maintainerPATCH 6/10 serial: altera_jtaguart: switch status to u32
In reply to Jiri Slaby (SUSE)'status' is assigned a result from readl(). There is no need for the variable to be 'unsigned long'. readl() returns 32bit values.
Provided, this is a Nios II driver (32-bit), there is no change in semantics. This only makes the type explicit.
--- drivers/tty/serial/altera_jtaguart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/altera_jtaguart.c +1 -1
@@ -110,7 +110,7 @@ static void altera_jtaguart_set_termios(struct uart_port *port,static void altera_jtaguart_rx_chars (struct uart_port *port) { -unsigned long status; +u32 status;u8 ch; while ((status = readl(port->membase + ALTERA_JTAGUART_DATA_REG)) &
Signature · 1 line
2.41.0
Re: [PATCH 06/10] serial: altera_jtaguart: switch status to u32
Quoted 8 lines · Jiri Slaby (SUSE)
'status' is assigned a result from
readl(). There is no need for the variable to be 'unsigned long'.readl()returns 32bit values.Provided, this is a Nios II driver (32-bit), there is no change in semantics. This only makes the type explicit.
Signed-off-by Jiri Slaby (SUSE) <[email protected]>Cc Tobias Klauser <[email protected]>
Jiri Slaby (SUSE)
maintainerPATCH 7/10 speakup: switch to unsigned iterator in spk_ttyio_receive_buf2()
In reply to Jiri Slaby (SUSE)Now, that spk_ttyio_receive_buf2() receives an unsigned count, the iterator can/should be unsigned too. Switch to that to be explicit.
--- drivers/accessibility/speakup/spk_ttyio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accessibility/speakup/spk_ttyio.c +1 -1
@@ -79,7 +79,7 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty,struct spk_synth *synth = ldisc_data->synth;if (synth->read_buff_add) { -int i; +unsigned int i;for (i =0 ; i < count; i++) synth->read_buff_add (cp[i]);
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 8/10 misc: ti-st: remove forward declarations and make st_int_recv() static
In reply to Jiri Slaby (SUSE)st_kim_recv() is already declared in linux/ti_wilink_st.h. Given that is already included in st_core.c, drop the re-declaration from there.
st_int_recv() is used only in st_core.c and the forward declaration is not needed. So drop the declaration and make the function static.
--- drivers/misc/ti-st/st_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/misc/ti-st/st_core.c +1 -3
@@ -16,8 +16,6 @@#include <linux/ti_wilink_st.h> -extern void st_kim_recv (void *,const unsigned char *,long ); -void st_int_recv (void *,const unsigned char *,long );/* * function pointer pointing to either, * st_kim_recv during registration to receive fw download responses
@@ -225,7 +223,7 @@ static inline void st_wakeup_ack(struct st_data_s *st_gdata,* HCI-Events, ACL, SCO, 4 types of HCI-LL PM packets * CH-8 packets from FM, CH-9 packets from GPS cores. */ -void st_int_recv (void *disc_data, +static void st_int_recv (void *disc_data,const unsigned char *data,long count) {char *ptr;
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 9/10 misc: ti-st: remove ptr from recv functions
In reply to Jiri Slaby (SUSE)ptr is the same as data, so use ptr directly as a parameter and drop the useless local variable.
Likely, the two were introduced to have a different type. But 'char' and 'unsigned char' are the same in the kernel for a long time.
--- drivers/misc/ti-st/st_core.c | 4 +--- drivers/misc/ti-st/st_kim.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/misc/ti-st/st_core.c +1 -3
@@ -224,9 +224,8 @@ static inline void st_wakeup_ack(struct st_data_s *st_gdata,* CH-8 packets from FM, CH-9 packets from GPS cores. */ static void st_int_recv (void *disc_data, -const unsigned char *data,long count) +const unsigned char *ptr,long count) { -char *ptr;struct st_proto_s *proto;unsigned short payload_len =0 ;int len =0 ;
@@ -235,7 +234,6 @@ static void st_int_recv(void *disc_data,struct st_data_s *st_gdata = (struct st_data_s *)disc_data;unsigned long flags; - ptr = (char *)data;/* tty_receive sent null ? */ if (unlikely (ptr ==NULL ) || (st_gdata ==NULL )) {pr_err (" received null from TTY " );
drivers/misc/ti-st/st_kim.c +1 -3
@@ -128,15 +128,13 @@ static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len)* tty_receive and hence the logic */ static void kim_int_recv (struct kim_data_s *kim_gdata, -const unsigned char *data,long count) +const unsigned char *ptr,long count) { -const unsigned char *ptr;int len =0 ;unsigned char *plen;pr_debug ("%s" , __func__);/* Decode received bytes here */ - ptr = data;if (unlikely (ptr ==NULL )) {pr_err (" received null from TTY " );return ;
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 10/10 misc: ti-st: don't check for tty data == NULL
In reply to Jiri Slaby (SUSE)tty data passed to tty_ldisc_ops::receive_buf() are never NULL. Remove this check.
--- drivers/misc/ti-st/st_core.c | 3 +-- drivers/misc/ti-st/st_kim.c | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/misc/ti-st/st_core.c +1 -2
@@ -234,8 +234,7 @@ static void st_int_recv(void *disc_data,struct st_data_s *st_gdata = (struct st_data_s *)disc_data;unsigned long flags; -/* tty_receive sent null ? */ -if (unlikely (ptr ==NULL ) || (st_gdata ==NULL )) { +if (st_gdata ==NULL ) {pr_err (" received null from TTY " );return ; }
drivers/misc/ti-st/st_kim.c +0 -5
@@ -135,11 +135,6 @@ static void kim_int_recv(struct kim_data_s *kim_gdata,pr_debug ("%s" , __func__);/* Decode received bytes here */ -if (unlikely (ptr ==NULL )) { -pr_err (" received null from TTY " ); -return ; - } -while (count) {if (kim_gdata->rx_count) { len = min_t(unsigned int, kim_gdata->rx_count, count);
Signature · 1 line
2.41.0
Marc Kleine-Budde
maintainerQuoted 1 line · Jiri Slaby (SUSE)
can: slcan: remove casts from
tty->disc_data
You can do the same for drivers/net/can/can327.c
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Jiri Slaby
maintainerQuoted 4 lines · Marc Kleine-Budde
Quoted 1 line · Jiri Slaby (SUSE)
can: slcan: remove casts from
tty->disc_dataYou can do the same for
drivers/net/can/can327.c
OK. And in net/nfc/nci/uart.c and that all should be it.
thanks,
Signature · 2 lines
js suse labs