tty: random fixes and cleanups
Subsystems (8)
Jiri Slaby (SUSE)
maintainerv2 cover tty: random fixes and cleanups
Hi,
this is a series of locally accumulated patches over past months.
The series:
* makes mctp and 6pack use u8s,
* cleans up 6pack a bit,
* fixes two coverity reports,
* uses guard() to make some of the tty function easier to follow.
[v2]
* fixed "serial: use guards for simple mutex locks"
* added also previously missed xhci dbgtty patches
Jiri Slaby (SUSE) (11):
serial: use guards for simple mutex locks
mxser: remove stale comment
mxser: remove doubled sets of close times
xhci: dbgtty: remove kfifo_out() wrapper
xhci: dbgtty: use kfifo from tty_port struct
mctp: serial: propagage new tty types
6pack: remove sixpack::rbuff
6pack: drop sixpack::mtu
6pack: drop sixpack::buffsize
6pack: remove global strings
6pack: propagage new tty types
drivers/net/hamradio/6pack.c | 60 ++++++---------- drivers/net/mctp/mctp-serial.c | 23 ++++--- drivers/tty/mxser.c | 5 -- drivers/tty/serial/serial_core.c | 113 +++++++++++++------------------ drivers/usb/host/xhci-dbgcap.h | 1 - drivers/usb/host/xhci-dbgtty.c | 30 +++----- 6 files changed, 88 insertions(+), 144 deletions(-)
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 1/11 serial: use guards for simple mutex locks
Guards can help to make the code more readable. So use it wherever they do so.
On many places labels and 'ret' locals are eliminated completely.
---
[v2] change also the third goto in uart_suspend_port().
How could this only slip through?
--- drivers/tty/serial/serial_core.c | 113 +++++++++++++------------------ 1 file changed, 47 insertions(+), 66 deletions(-)
drivers/tty/serial/serial_core.c +47 -66
@@ -1104,21 +1104,19 @@ static int uart_tiocmget(struct tty_struct *tty)struct uart_state *state = tty->driver_data;struct tty_port *port = &state->port;struct uart_port *uport; -int result = -EIO ; +int result; + +guard (mutex)(&port->mutex); -mutex_lock (&port->mutex); uport =uart_port_check (state); -if (!uport) - goto out; +if (!uport ||tty_io_error (tty)) +return -EIO ; + +uart_port_lock_irq (uport); + result = uport->mctrl; + result |= uport->ops->get_mctrl (uport); +uart_port_unlock_irq (uport); -if (!tty_io_error (tty)) { -uart_port_lock_irq (uport); - result = uport->mctrl; - result |= uport->ops->get_mctrl (uport); -uart_port_unlock_irq (uport); - } -out: -mutex_unlock (&port->mutex);return result; }
@@ -1128,20 +1126,16 @@ uart_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear)struct uart_state *state = tty->driver_data;struct tty_port *port = &state->port;struct uart_port *uport; -int ret = -EIO ; -mutex_lock (&port->mutex); +guard (mutex)(&port->mutex); + uport =uart_port_check (state); -if (!uport) - goto out; +if (!uport ||tty_io_error (tty)) +return -EIO ; -if (!tty_io_error (tty)) { -uart_update_mctrl (uport, set, clear); - ret =0 ; - } -out: -mutex_unlock (&port->mutex); -return ret; +uart_update_mctrl (uport, set, clear); + +return 0 ; }static int uart_break_ctl (struct tty_struct *tty,int break_state)
@@ -1149,19 +1143,17 @@ static int uart_break_ctl(struct tty_struct *tty, int break_state)struct uart_state *state = tty->driver_data;struct tty_port *port = &state->port;struct uart_port *uport; -int ret = -EIO ; -mutex_lock (&port->mutex); +guard (mutex)(&port->mutex); + uport =uart_port_check (state);if (!uport) - goto out; +return -EIO ;if (uport->type !=PORT_UNKNOWN && uport->ops->break_ctl) uport->ops->break_ctl (uport, break_state); - ret =0 ; -out: -mutex_unlock (&port->mutex); -return ret; + +return 0 ; }static int uart_do_autoconfig (struct tty_struct *tty,struct uart_state *state)
@@ -1178,17 +1170,14 @@ static int uart_do_autoconfig(struct tty_struct *tty, struct uart_state *state)* changing, and hence any extra opens of the port while * we're auto-configuring. */ -if (mutex_lock_interruptible (&port->mutex)) -return -ERESTARTSYS ; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &port->mutex) { + uport =uart_port_check (state); +if (!uport) +return -EIO ; - uport =uart_port_check (state); -if (!uport) { - ret = -EIO ; - goto out; - } +if (tty_port_users (port) !=1 ) +return -EBUSY ; - ret = -EBUSY ; -if (tty_port_users (port) ==1 ) {uart_shutdown (tty, state);/*
@@ -1209,14 +1198,15 @@ static int uart_do_autoconfig(struct tty_struct *tty, struct uart_state *state) uport->ops->config_port (uport, flags); ret =uart_startup (tty, state, true); -if (ret ==0 ) -tty_port_set_initialized (port, true); +if (ret <0 ) +return ret;if (ret >0 ) - ret =0 ; +return 0 ; + +tty_port_set_initialized (port, true); } -out: -mutex_unlock (&port->mutex); -return ret; + +return 0 ; }static void uart_enable_ms (struct uart_port *uport)
@@ -1711,10 +1701,11 @@ static void uart_set_termios(struct tty_struct *tty,unsigned int iflag_mask =IGNBRK |BRKINT |IGNPAR |PARMRK |INPCK ;bool sw_changed = false; -mutex_lock (&state->port.mutex); +guard (mutex)(&state->port.mutex); + uport =uart_port_check (state);if (!uport) - goto out; +return ;/* * Drivers doing software flow control also need to know
@@ -1737,9 +1728,8 @@ static void uart_set_termios(struct tty_struct *tty, tty->termios.c_ospeed == old_termios->c_ospeed && tty->termios.c_ispeed == old_termios->c_ispeed && ((tty->termios.c_iflag ^ old_termios->c_iflag) & iflag_mask) ==0 && - !sw_changed) { - goto out; - } + !sw_changed) + return;uart_change_line_settings (tty, state, old_termios);/* reload cflag from termios; port driver may have overridden flags */
@@ -1756,8 +1746,6 @@ static void uart_set_termios(struct tty_struct *tty, mask |=TIOCM_RTS ;uart_set_mctrl (uport, mask); } -out: -mutex_unlock (&state->port.mutex); }/*
@@ -2051,10 +2039,11 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)unsigned int status;int mmio; -mutex_lock (&port->mutex); +guard (mutex)(&port->mutex); + uport =uart_port_check (state);if (!uport) - goto out; +return ; mmio = uport->iotype >=UPIO_MEM ; seq_printf(m, "%d: uart:%s %s%08llX irq:%d",
@@ -2066,7 +2055,7 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)if (uport->type ==PORT_UNKNOWN ) {seq_putc (m,'\n' ); - goto out; +return ; }if (capable (CAP_SYS_ADMIN )) {
@@ -2117,8 +2106,6 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)seq_putc (m,'\n' );#undef STATBIT#undef INFOBIT -out: -mutex_unlock (&port->mutex); }static int uart_proc_show (struct seq_file *m,void *v)
@@ -2395,13 +2382,12 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)struct device *tty_dev;struct uart_match match = {uport, drv}; -mutex_lock (&port->mutex); +guard (mutex)(&port->mutex); tty_dev =device_find_child (&uport->port_dev->dev, &match, serial_match_port);if (tty_dev &&device_may_wakeup (tty_dev)) {enable_irq_wake (uport->irq);put_device (tty_dev); -mutex_unlock (&port->mutex);return 0 ; }put_device (tty_dev);
@@ -2419,7 +2405,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)uart_port_unlock_irq (uport); }device_set_awake_path (uport->dev); - goto unlock; +return 0 ; } uport->suspended =1 ;
@@ -2462,8 +2448,6 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)console_stop (uport->cons);uart_change_pm (state,UART_PM_STATE_OFF ); -unlock: -mutex_unlock (&port->mutex);return 0 ; }
@@ -2477,14 +2461,13 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)struct uart_match match = {uport, drv};struct ktermios termios; -mutex_lock (&port->mutex); +guard (mutex)(&port->mutex); tty_dev =device_find_child (&uport->port_dev->dev, &match, serial_match_port);if (!uport->suspended &&device_may_wakeup (tty_dev)) {if (irqd_is_wakeup_set (irq_get_irq_data ((uport->irq))))disable_irq_wake (uport->irq);put_device (tty_dev); -mutex_unlock (&port->mutex);return 0 ; }put_device (tty_dev);
@@ -2557,8 +2540,6 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)tty_port_set_suspended (port, false); } -mutex_unlock (&port->mutex); -return 0 ; }EXPORT_SYMBOL (uart_resume_port);
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 2/11 mxser: remove stale comment
In reply to Jiri Slaby (SUSE)The comment mentions ISA removed long time ago. It also comments on .driver_data pointing to above structures. That is not true either. Remove that.
--- drivers/tty/mxser.c | 3 --- 1 file changed, 3 deletions(-)
drivers/tty/mxser.c +0 -3
@@ -208,9 +208,6 @@ static const struct { };#define UART_INFO_NUM ARRAY_SIZE(Gpci_uart_info) - -/* driver_data correspond to the lines in the structure above -see also ISA probe function before you change something */ static const struct pci_device_id mxser_pcibrds[] = { {PCI_DEVICE_DATA (MOXA ,C168 ,8 ) }, {PCI_DEVICE_DATA (MOXA ,C104 ,4 ) },
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 3/11 mxser: remove doubled sets of close times
In reply to Jiri Slaby (SUSE)tty_port::close_delay and ::closing_wait are set in tty_port_init() few lines above already, no need to reset them (to the same values).
--- drivers/tty/mxser.c | 2 -- 1 file changed, 2 deletions(-)
drivers/tty/mxser.c +0 -2
@@ -1770,8 +1770,6 @@ static void mxser_initbrd(struct mxser_board *brd, bool high_baud)mxser_process_txrx_fifo (info); - info->port.close_delay =5 *HZ /10 ; - info->port.closing_wait =30 *HZ ;spin_lock_init (&info->slock);/* before set INT ISR, disable all int */
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 4/11 xhci: dbgtty: remove kfifo_out() wrapper
In reply to Jiri Slaby (SUSE)There is no need to check against kfifo_len() before kfifo_out(). Just ask the latter for data and it tells how much it retrieved. Or returns 0 in case there are no more.
--- drivers/usb/host/xhci-dbgtty.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/usb/host/xhci-dbgtty.c +1 -14
@@ -24,19 +24,6 @@ static inline struct dbc_port *dbc_to_port(struct xhci_dbc *dbc)return dbc->priv; } -static unsigned int -dbc_send_packet (struct dbc_port *port,char *packet,unsigned int size) -{ -unsigned int len; - - len =kfifo_len (&port->write_fifo); -if (len < size) - size = len; -if (size !=0 ) - size =kfifo_out (&port->write_fifo, packet, size); -return size; -} - static int dbc_start_tx(struct dbc_port *port) __releases(&port->port_lock) __acquires(&port->port_lock)
@@ -49,7 +36,7 @@ static int dbc_start_tx(struct dbc_port *port)while (!list_empty (pool)) { req = list_entry(pool->next, struct dbc_request, list_pool); - len =dbc_send_packet (port, req->buf,DBC_MAX_PACKET ); + len =kfifo_out (&port->write_fifo, req->buf,DBC_MAX_PACKET );if (len ==0 )break ; do_tty_wake = true;
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 5/11 xhci: dbgtty: use kfifo from tty_port struct
In reply to Jiri Slaby (SUSE)There is no need to define one in a custom structure. The tty_port one is free to use.
--- drivers/usb/host/xhci-dbgcap.h | 1 - drivers/usb/host/xhci-dbgtty.c | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/usb/host/xhci-dbgcap.h +0 -1
@@ -110,7 +110,6 @@ struct dbc_port {struct tasklet_struct push;struct list_head write_pool; -struct kfifo write_fifo;bool registered; };
drivers/usb/host/xhci-dbgtty.c +9 -8
@@ -36,7 +36,7 @@ static int dbc_start_tx(struct dbc_port *port)while (!list_empty (pool)) { req = list_entry(pool->next, struct dbc_request, list_pool); - len =kfifo_out (&port->write_fifo, req->buf,DBC_MAX_PACKET ); + len =kfifo_out (&port->port.xmit_fifo, req->buf,DBC_MAX_PACKET );if (len ==0 )break ; do_tty_wake = true;
@@ -203,7 +203,7 @@ static ssize_t dbc_tty_write(struct tty_struct *tty, const u8 *buf,spin_lock_irqsave (&port->port_lock, flags);if (count) - count =kfifo_in (&port->write_fifo, buf, count); + count =kfifo_in (&port->port.xmit_fifo, buf, count);dbc_start_tx (port);spin_unlock_irqrestore (&port->port_lock, flags);
@@ -217,7 +217,7 @@ static int dbc_tty_put_char(struct tty_struct *tty, u8 ch)int status;spin_lock_irqsave (&port->port_lock, flags); - status =kfifo_put (&port->write_fifo, ch); + status =kfifo_put (&port->port.xmit_fifo, ch);spin_unlock_irqrestore (&port->port_lock, flags);return status;
@@ -240,7 +240,7 @@ static unsigned int dbc_tty_write_room(struct tty_struct *tty)unsigned int room;spin_lock_irqsave (&port->port_lock, flags); - room =kfifo_avail (&port->write_fifo); + room =kfifo_avail (&port->port.xmit_fifo);spin_unlock_irqrestore (&port->port_lock, flags);return room;
@@ -253,7 +253,7 @@ static unsigned int dbc_tty_chars_in_buffer(struct tty_struct *tty)unsigned int chars;spin_lock_irqsave (&port->port_lock, flags); - chars =kfifo_len (&port->write_fifo); + chars =kfifo_len (&port->port.xmit_fifo);spin_unlock_irqrestore (&port->port_lock, flags);return chars;
@@ -411,7 +411,8 @@ static int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) goto err_idr; } - ret =kfifo_alloc (&port->write_fifo,DBC_WRITE_BUF_SIZE ,GFP_KERNEL ); + ret =kfifo_alloc (&port->port.xmit_fifo,DBC_WRITE_BUF_SIZE , +GFP_KERNEL );if (ret) goto err_exit_port;
@@ -440,7 +441,7 @@ static int xhci_dbc_tty_register_device(struct xhci_dbc *dbc)xhci_dbc_free_requests (&port->read_pool);xhci_dbc_free_requests (&port->write_pool); err_free_fifo: -kfifo_free (&port->write_fifo); +kfifo_free (&port->port.xmit_fifo); err_exit_port:idr_remove (&dbc_tty_minors, port->minor); err_idr:
@@ -465,7 +466,7 @@ static void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc)idr_remove (&dbc_tty_minors, port->minor);mutex_unlock (&dbc_tty_minors_lock); -kfifo_free (&port->write_fifo); +kfifo_free (&port->port.xmit_fifo);xhci_dbc_free_requests (&port->read_pool);xhci_dbc_free_requests (&port->read_queue);xhci_dbc_free_requests (&port->write_pool);
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 6/11 mctp: serial: propagage new tty types
In reply to Jiri Slaby (SUSE)In tty, u8 is now used for data, ssize_t for sizes (with possible negative error codes). Propagate these types (and use unsigned in next_chunk_len()) to mctp.
--- drivers/net/mctp/mctp-serial.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/net/mctp/mctp-serial.c +12 -11
@@ -64,18 +64,18 @@ struct mctp_serial {u16 txfcs, rxfcs, rxfcs_rcvd;unsigned int txlen, rxlen;unsigned int txpos, rxpos; -unsigned char txbuf[BUFSIZE ], +u8 txbuf[BUFSIZE ], rxbuf[BUFSIZE ]; }; -static bool needs_escape (unsigned char c) +static bool needs_escape (u8 c) {return c ==BYTE_ESC || c ==BYTE_FRAME ; } -static int next_chunk_len (struct mctp_serial *dev) +static unsigned int next_chunk_len (struct mctp_serial *dev) { -int i; +unsigned int i;/* either we have no bytes to send ... */ if (dev->txpos == dev->txlen)
@@ -99,7 +99,7 @@ static int next_chunk_len(struct mctp_serial *dev)return i; } -static int write_chunk (struct mctp_serial *dev,unsigned char *buf,int len) +static ssize_t write_chunk (struct mctp_serial *dev,u8 *buf,size_t len) {return dev->tty->ops->write (dev->tty, buf, len); }
@@ -108,9 +108,10 @@ static void mctp_serial_tx_work(struct work_struct *work) { struct mctp_serial *dev = container_of(work, struct mctp_serial, tx_work); -unsigned char c, buf[3 ];unsigned long flags; -int len, txlen; +ssize_t txlen; +unsigned int len; +u8 c, buf[3 ];spin_lock_irqsave (&dev->lock, flags);
@@ -293,7 +294,7 @@ static void mctp_serial_rx(struct mctp_serial *dev) dev->netdev->stats.rx_bytes += dev->rxlen; } -static void mctp_serial_push_header (struct mctp_serial *dev,unsigned char c) +static void mctp_serial_push_header (struct mctp_serial *dev,u8 c) {switch (dev->rxpos) {case 0 :
@@ -323,7 +324,7 @@ static void mctp_serial_push_header(struct mctp_serial *dev, unsigned char c) } } -static void mctp_serial_push_trailer (struct mctp_serial *dev,unsigned char c) +static void mctp_serial_push_trailer (struct mctp_serial *dev,u8 c) {switch (dev->rxpos) {case 0 :
@@ -347,7 +348,7 @@ static void mctp_serial_push_trailer(struct mctp_serial *dev, unsigned char c) } } -static void mctp_serial_push (struct mctp_serial *dev,unsigned char c) +static void mctp_serial_push (struct mctp_serial *dev,u8 c) {switch (dev->rxstate) {case STATE_IDLE :
@@ -394,7 +395,7 @@ static void mctp_serial_tty_receive_buf(struct tty_struct *tty, const u8 *c, const u8 *f, size_t len) {struct mctp_serial *dev = tty->disc_data; -int i; +size_t i;if (!netif_running (dev->netdev))return ;
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 7/11 6pack: remove sixpack::rbuff
In reply to Jiri Slaby (SUSE)It's unused (except allocation and free).
--- drivers/net/hamradio/6pack.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/net/hamradio/6pack.c +2 -8
@@ -88,7 +88,6 @@ struct sixpack {struct net_device *dev;/* easy for intr handling */ /* These are pointers to the malloc()ed frame buffers. */ -unsigned char *rbuff;/* receiver buffer */ int rcount;/* received chars counter */ unsigned char *xbuff;/* transmitter buffer */ unsigned char *xhead;/* next byte to XMIT */
@@ -544,7 +543,7 @@ static inline int tnc_init(struct sixpack *sp)*/ static int sixpack_open (struct tty_struct *tty) { -char *rbuff =NULL , *xbuff =NULL ; +char *xbuff =NULL ;struct net_device *dev;struct sixpack *sp;unsigned long len;
@@ -574,10 +573,8 @@ static int sixpack_open(struct tty_struct *tty) len = dev->mtu *2 ; - rbuff =kmalloc (len +4 ,GFP_KERNEL ); xbuff =kmalloc (len +4 ,GFP_KERNEL ); - -if (rbuff ==NULL || xbuff ==NULL ) { +if (xbuff ==NULL ) { err = -ENOBUFS ; goto out_free; }
@@ -586,7 +583,6 @@ static int sixpack_open(struct tty_struct *tty) sp->tty = tty; - sp->rbuff = rbuff; sp->xbuff = xbuff; sp->mtu =AX25_MTU +73 ;
@@ -631,7 +627,6 @@ static int sixpack_open(struct tty_struct *tty) out_free:kfree (xbuff); -kfree (rbuff);free_netdev (dev);
@@ -676,7 +671,6 @@ static void sixpack_close(struct tty_struct *tty)del_timer_sync (&sp->resync_t);/* Free all 6pack frame buffers after unreg. */ -kfree (sp->rbuff);kfree (sp->xbuff);free_netdev (sp->dev);
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 8/11 6pack: drop sixpack::mtu
In reply to Jiri Slaby (SUSE)It holds a constant (AX25_MTU + 73), so use that constant in place of the single use directly.
And remove the stale comment.
--- drivers/net/hamradio/6pack.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/hamradio/6pack.c +1 -3
@@ -100,7 +100,6 @@ struct sixpack {unsigned int rx_count_cooked;spinlock_t rxlock; -int mtu;/* Our mtu (to spot changes!) */ int buffsize;/* Max buffers sizes */ unsigned long flags;/* Flag values/ mode etc */
@@ -166,7 +165,7 @@ static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len)unsigned char *msg, *p = icp;int actual, count; -if (len > sp->mtu) {/* sp->mtu = AX25_MTU = max. PACLEN = 256 */ +if (len >AX25_MTU +73 ) { msg ="oversized transmit packet!" ; goto out_drop; }
@@ -585,7 +584,6 @@ static int sixpack_open(struct tty_struct *tty) sp->xbuff = xbuff; - sp->mtu =AX25_MTU +73 ; sp->buffsize = len; sp->rcount =0 ; sp->rx_count =0 ;
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 9/11 6pack: drop sixpack::buffsize
In reply to Jiri Slaby (SUSE)It's never read.
--- drivers/net/hamradio/6pack.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/hamradio/6pack.c +0 -3
@@ -100,8 +100,6 @@ struct sixpack {unsigned int rx_count_cooked;spinlock_t rxlock; -int buffsize;/* Max buffers sizes */ -unsigned long flags;/* Flag values/ mode etc */ unsigned char mode;/* 6pack mode */
@@ -584,7 +582,6 @@ static int sixpack_open(struct tty_struct *tty) sp->xbuff = xbuff; - sp->buffsize = len; sp->rcount =0 ; sp->rx_count =0 ; sp->rx_count_cooked =0 ;
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 10/11 6pack: remove global strings
In reply to Jiri Slaby (SUSE)They are __init, so they are freed after init is done. But this obfuscates the code.
Provided these days, we usually don't print anything if everything has gone fine, drop the info print completely (along with now unused and always artificial SIXPACK_VERSION).
And move the other string into the printk proper (while converting from KERN_ERR to pr_err()).
--- drivers/net/hamradio/6pack.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/net/hamradio/6pack.c +1 -10
@@ -37,8 +37,6 @@#include <linux/semaphore.h> #include <linux/refcount.h> -#define SIXPACK_VERSION "Revision: 0.3.0" -/* sixpack priority commands */ #define SIXP_SEOF 0x40/* start and end of a 6pack frame */ #define SIXP_TX_URUN 0x48/* transmit overrun */
@@ -745,21 +743,14 @@ static struct tty_ldisc_ops sp_ldisc = {/* Initialize 6pack control device -- register 6pack line discipline */ -static const char msg_banner[] __initconst = KERN_INFO \ -"AX.25: 6pack driver, " SIXPACK_VERSION "\n" ; -static const char msg_regfail[] __initconst = KERN_ERR \ -"6pack: can't register line discipline (err = %d)\n" ; -static int __init sixpack_init_driver (void ) {int status; -printk (msg_banner); -/* Register the provided line protocol discipline */ status =tty_register_ldisc (&sp_ldisc);if (status) -printk (msg_regfail, status); +pr_err ("6pack: can't register line discipline (err = %d)\n" , status);return status; }
Signature · 1 line
2.46.0
Jiri Slaby (SUSE)
maintainerPATCH v2 11/11 6pack: propagage new tty types
In reply to Jiri Slaby (SUSE)In tty, u8 is now used for data, ssize_t for sizes (with possible negative error codes). Propagate these types to 6pack.
--- drivers/net/hamradio/6pack.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/net/hamradio/6pack.c +16 -16
@@ -91,8 +91,8 @@ struct sixpack {unsigned char *xhead;/* next byte to XMIT */ int xleft;/* bytes left in XMIT queue */ -unsigned char raw_buf[4 ]; -unsigned char cooked_buf[400 ]; +u8 raw_buf[4 ]; +u8 cooked_buf[400 ];unsigned int rx_count;unsigned int rx_count_cooked;
@@ -107,8 +107,8 @@ struct sixpack {unsigned char slottime;unsigned char duplex;unsigned char led_state; -unsigned char status; -unsigned char status1; +u8 status; +u8 status1;unsigned char status2;unsigned char tx_enable;unsigned char tnc_state;
@@ -122,7 +122,7 @@ struct sixpack {#define AX25_6PACK_HEADER_LEN 0 -static void sixpack_decode (struct sixpack *,const unsigned char [],int ); +static void sixpack_decode (struct sixpack *,const u8 *,size_t );static int encode_sixpack (unsigned char *,unsigned char *,int ,unsigned char );/*
@@ -327,7 +327,7 @@ static void sp_bump(struct sixpack *sp, char cmd) {struct sk_buff *skb;int count; -unsigned char *ptr; +u8 *ptr; count = sp->rcount +1 ;
@@ -425,7 +425,7 @@ static void sixpack_receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp, size_t count) {struct sixpack *sp; -int count1; +size_t count1;if (!count)return ;
@@ -800,9 +800,9 @@ static int encode_sixpack(unsigned char *tx_buf, unsigned char *tx_buf_raw,/* decode 4 sixpack-encoded bytes into 3 data bytes */ -static void decode_data (struct sixpack *sp,unsigned char inbyte) +static void decode_data (struct sixpack *sp,u8 inbyte) { -unsigned char *buf; +u8 *buf;if (sp->rx_count !=3 ) { sp->raw_buf[sp->rx_count++] = inbyte;
@@ -828,9 +828,9 @@ static void decode_data(struct sixpack *sp, unsigned char inbyte)/* identify and execute a 6pack priority command byte */ -static void decode_prio_command (struct sixpack *sp,unsigned char cmd) +static void decode_prio_command (struct sixpack *sp,u8 cmd) { -int actual; +ssize_t actual;if ((cmd &SIXP_PRIO_DATA_MASK ) !=0 ) {/* idle ? */
@@ -878,9 +878,9 @@ static void decode_prio_command(struct sixpack *sp, unsigned char cmd)/* identify and execute a standard 6pack command byte */ -static void decode_std_command (struct sixpack *sp,unsigned char cmd) +static void decode_std_command (struct sixpack *sp,u8 cmd) { -unsigned char checksum =0 , rest =0 ; +u8 checksum =0 , rest =0 ;short i;switch (cmd &SIXP_CMD_MASK ) {/* normal command */
@@ -928,10 +928,10 @@ static void decode_std_command(struct sixpack *sp, unsigned char cmd)/* decode a 6pack packet */ static void -sixpack_decode (struct sixpack *sp,const unsigned char *pre_rbuff,int count) +sixpack_decode (struct sixpack *sp,const u8 *pre_rbuff,size_t count) { -unsigned char inbyte; -int count1; +size_t count1; +u8 inbyte;for (count1 =0 ; count1 < count; count1++) { inbyte = pre_rbuff[count1];
Signature · 1 line
2.46.0