tty: make tty_operations::write_room return uint

Line disciplines expect a positive value or zero returned from
tty->ops->write_room (invoked by tty_write_room). So make this
assumption explicit by using unsigned int as a return value. Both of
tty->ops->write_room and tty_write_room.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Acked-by: Alex Elder <elder@linaro.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com> # xtensa
Acked-by: David Sterba <dsterba@suse.com>
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Chris Zankel <chris@zankel.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Scott Branden <scott.branden@broadcom.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Link: https://lore.kernel.org/r/20210505091928.22010-23-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jiri Slaby 2021-05-05 11:19:15 +02:00 committed by Greg Kroah-Hartman
parent 0f29b503bd
commit 03b3b1a240
47 changed files with 71 additions and 71 deletions

View File

@ -142,7 +142,7 @@ srmcons_write(struct tty_struct *tty,
return count;
}
static int
static unsigned int
srmcons_write_room(struct tty_struct *tty)
{
return 512;

View File

@ -85,7 +85,7 @@ static int nfcon_tty_put_char(struct tty_struct *tty, unsigned char ch)
return 1;
}
static int nfcon_tty_write_room(struct tty_struct *tty)
static unsigned int nfcon_tty_write_room(struct tty_struct *tty)
{
return 64;
}

View File

@ -103,7 +103,7 @@ static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *bu
return count;
}
static int pdc_console_tty_write_room(struct tty_struct *tty)
static unsigned int pdc_console_tty_write_room(struct tty_struct *tty)
{
return 32768; /* no limit, no buffer used */
}

View File

@ -32,7 +32,7 @@ static irqreturn_t line_interrupt(int irq, void *data)
*
* Should be called while holding line->lock (this does not modify data).
*/
static int write_room(struct line *line)
static unsigned int write_room(struct line *line)
{
int n;
@ -47,11 +47,11 @@ static int write_room(struct line *line)
return n - 1;
}
int line_write_room(struct tty_struct *tty)
unsigned int line_write_room(struct tty_struct *tty)
{
struct line *line = tty->driver_data;
unsigned long flags;
int room;
unsigned int room;
spin_lock_irqsave(&line->lock, flags);
room = write_room(line);

View File

@ -70,7 +70,7 @@ extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
extern int line_chars_in_buffer(struct tty_struct *tty);
extern void line_flush_buffer(struct tty_struct *tty);
extern void line_flush_chars(struct tty_struct *tty);
extern int line_write_room(struct tty_struct *tty);
extern unsigned int line_write_room(struct tty_struct *tty);
extern void line_throttle(struct tty_struct *tty);
extern void line_unthrottle(struct tty_struct *tty);

View File

@ -100,7 +100,7 @@ static void rs_flush_chars(struct tty_struct *tty)
{
}
static int rs_write_room(struct tty_struct *tty)
static unsigned int rs_write_room(struct tty_struct *tty)
{
/* Let's say iss can always accept 2K characters.. */
return 2 * 1024;

View File

@ -1609,7 +1609,7 @@ cleanup:
/* Return the count of free bytes in transmit buffer
*/
static int mgslpc_write_room(struct tty_struct *tty)
static unsigned int mgslpc_write_room(struct tty_struct *tty)
{
MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
int ret;

View File

@ -132,7 +132,7 @@ static int tpk_write(struct tty_struct *tty,
/*
* TTY operations write_room function.
*/
static int tpk_write_room(struct tty_struct *tty)
static unsigned int tpk_write_room(struct tty_struct *tty)
{
return TPK_MAX_ROOM;
}

View File

@ -460,7 +460,7 @@ static int ipoctal_write_tty(struct tty_struct *tty,
return char_copied;
}
static int ipoctal_write_room(struct tty_struct *tty)
static unsigned int ipoctal_write_room(struct tty_struct *tty)
{
struct ipoctal_channel *channel = tty->driver_data;

View File

@ -1175,14 +1175,14 @@ static void capinc_tty_flush_chars(struct tty_struct *tty)
handle_minor_recv(mp);
}
static int capinc_tty_write_room(struct tty_struct *tty)
static unsigned int capinc_tty_write_room(struct tty_struct *tty)
{
struct capiminor *mp = tty->driver_data;
int room;
unsigned int room;
room = CAPINC_MAX_SENDQUEUE-skb_queue_len(&mp->outqueue);
room *= CAPI_MAX_BLKSIZE;
pr_debug("capinc_tty_write_room = %d\n", room);
pr_debug("capinc_tty_write_room = %u\n", room);
return room;
}

View File

@ -214,7 +214,7 @@ static int bcm_vk_tty_write(struct tty_struct *tty,
return count;
}
static int bcm_vk_tty_write_room(struct tty_struct *tty)
static unsigned int bcm_vk_tty_write_room(struct tty_struct *tty)
{
struct bcm_vk *vk = dev_get_drvdata(tty->dev);

View File

@ -797,7 +797,7 @@ static int sdio_uart_write(struct tty_struct *tty, const unsigned char *buf,
return ret;
}
static int sdio_uart_write_room(struct tty_struct *tty)
static unsigned int sdio_uart_write_room(struct tty_struct *tty)
{
struct sdio_uart_port *port = tty->driver_data;
return FIFO_SIZE - kfifo_len(&port->xmit_fifo);

View File

@ -1357,10 +1357,10 @@ out:
}
/* how much room is there for writing */
static int hso_serial_write_room(struct tty_struct *tty)
static unsigned int hso_serial_write_room(struct tty_struct *tty)
{
struct hso_serial *serial = tty->driver_data;
int room;
unsigned int room;
unsigned long flags;
spin_lock_irqsave(&serial->serial_lock, flags);

View File

@ -924,7 +924,7 @@ static void tty3215_close(struct tty_struct *tty, struct file * filp)
/*
* Returns the amount of free space in the output buffer.
*/
static int tty3215_write_room(struct tty_struct *tty)
static unsigned int tty3215_write_room(struct tty_struct *tty)
{
struct raw3215_info *raw = tty->driver_data;

View File

@ -86,12 +86,12 @@ sclp_tty_close(struct tty_struct *tty, struct file *filp)
* a string of newlines. Every newline creates a new message which
* needs 82 bytes.
*/
static int
static unsigned int
sclp_tty_write_room (struct tty_struct *tty)
{
unsigned long flags;
struct list_head *l;
int count;
unsigned int count;
spin_lock_irqsave(&sclp_tty_lock, flags);
count = 0;

View File

@ -609,12 +609,12 @@ sclp_vt220_flush_chars(struct tty_struct *tty)
* to change as output buffers get emptied, or if the output flow
* control is acted.
*/
static int
static unsigned int
sclp_vt220_write_room(struct tty_struct *tty)
{
unsigned long flags;
struct list_head *l;
int count;
unsigned int count;
spin_lock_irqsave(&sclp_vt220_lock, flags);
count = 0;

View File

@ -1071,7 +1071,7 @@ static void tty3270_cleanup(struct tty_struct *tty)
/*
* We always have room.
*/
static int
static unsigned int
tty3270_write_room(struct tty_struct *tty)
{
return INT_MAX;

View File

@ -1113,16 +1113,16 @@ static int fwtty_write(struct tty_struct *tty, const unsigned char *buf, int c)
return (n < 0) ? 0 : n;
}
static int fwtty_write_room(struct tty_struct *tty)
static unsigned int fwtty_write_room(struct tty_struct *tty)
{
struct fwtty_port *port = tty->driver_data;
int n;
unsigned int n;
spin_lock_bh(&port->lock);
n = dma_fifo_avail(&port->tx_fifo);
spin_unlock_bh(&port->lock);
fwtty_dbg(port, "%d\n", n);
fwtty_dbg(port, "%u\n", n);
return n;
}

View File

@ -183,7 +183,7 @@ static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf,
return len;
}
static int gdm_tty_write_room(struct tty_struct *tty)
static unsigned int gdm_tty_write_room(struct tty_struct *tty)
{
struct gdm *gdm = tty->driver_data;

View File

@ -440,7 +440,7 @@ static int gb_tty_write(struct tty_struct *tty, const unsigned char *buf,
return count;
}
static int gb_tty_write_room(struct tty_struct *tty)
static unsigned int gb_tty_write_room(struct tty_struct *tty)
{
struct gb_tty *gb_tty = tty->driver_data;
unsigned long flags;

View File

@ -827,7 +827,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count
return ret;
}
static int rs_write_room(struct tty_struct *tty)
static unsigned int rs_write_room(struct tty_struct *tty)
{
struct serial_state *info = tty->driver_data;

View File

@ -536,11 +536,11 @@ static void ehv_bc_tty_close(struct tty_struct *ttys, struct file *filp)
* how much write room the driver can guarantee will be sent OR BUFFERED. This
* driver MUST honor the return value.
*/
static int ehv_bc_tty_write_room(struct tty_struct *ttys)
static unsigned int ehv_bc_tty_write_room(struct tty_struct *ttys)
{
struct ehv_bc_data *bc = ttys->driver_data;
unsigned long flags;
int count;
unsigned int count;
spin_lock_irqsave(&bc->lock, flags);
count = CIRC_SPACE(bc->head, bc->tail, BUF_SIZE);

View File

@ -193,7 +193,7 @@ static int goldfish_tty_write(struct tty_struct *tty, const unsigned char *buf,
return count;
}
static int goldfish_tty_write_room(struct tty_struct *tty)
static unsigned int goldfish_tty_write_room(struct tty_struct *tty)
{
return 0x10000;
}

View File

@ -586,7 +586,7 @@ static void hvc_set_winsz(struct work_struct *work)
* how much write room the driver can guarantee will be sent OR BUFFERED. This
* driver MUST honor the return value.
*/
static int hvc_write_room(struct tty_struct *tty)
static unsigned int hvc_write_room(struct tty_struct *tty)
{
struct hvc_struct *hp = tty->driver_data;

View File

@ -1376,7 +1376,7 @@ static int hvcs_write(struct tty_struct *tty,
* absolutely WILL BUFFER if we can't send it. This driver MUST honor the
* return value, hence the reason for hvcs_struct buffering.
*/
static int hvcs_write_room(struct tty_struct *tty)
static unsigned int hvcs_write_room(struct tty_struct *tty)
{
struct hvcs_struct *hvcsd = tty->driver_data;

View File

@ -890,7 +890,7 @@ out:
spin_unlock_irqrestore(&hp->lock, flags);
}
static int hvsi_write_room(struct tty_struct *tty)
static unsigned int hvsi_write_room(struct tty_struct *tty)
{
struct hvsi_struct *hp = tty->driver_data;
@ -929,7 +929,7 @@ static int hvsi_write(struct tty_struct *tty,
* will see there is no room in outbuf and return.
*/
while ((count > 0) && (hvsi_write_room(tty) > 0)) {
int chunksize = min(count, hvsi_write_room(tty));
int chunksize = min_t(int, count, hvsi_write_room(tty));
BUG_ON(hp->n_outbuf < 0);
memcpy(hp->outbuf + hp->n_outbuf, source, chunksize);

View File

@ -228,7 +228,7 @@ static int ipw_write(struct tty_struct *linux_tty,
return count;
}
static int ipw_write_room(struct tty_struct *linux_tty)
static unsigned int ipw_write_room(struct tty_struct *linux_tty)
{
struct ipw_tty *tty = linux_tty->driver_data;
int room;

View File

@ -840,11 +840,11 @@ static int mips_ejtag_fdc_tty_write(struct tty_struct *tty,
return total;
}
static int mips_ejtag_fdc_tty_write_room(struct tty_struct *tty)
static unsigned int mips_ejtag_fdc_tty_write_room(struct tty_struct *tty)
{
struct mips_ejtag_fdc_tty_port *dport = tty->driver_data;
struct mips_ejtag_fdc_tty *priv = dport->driver;
int room;
unsigned int room;
/* Report the space in the xmit buffer */
spin_lock(&dport->xmit_lock);

View File

@ -188,7 +188,7 @@ module_param(ttymajor, int, 0);
static int moxa_open(struct tty_struct *, struct file *);
static void moxa_close(struct tty_struct *, struct file *);
static int moxa_write(struct tty_struct *, const unsigned char *, int);
static int moxa_write_room(struct tty_struct *);
static unsigned int moxa_write_room(struct tty_struct *);
static void moxa_flush_buffer(struct tty_struct *);
static int moxa_chars_in_buffer(struct tty_struct *);
static void moxa_set_termios(struct tty_struct *, struct ktermios *);
@ -218,7 +218,7 @@ static int MoxaPortWriteData(struct tty_struct *, const unsigned char *, int);
static int MoxaPortReadData(struct moxa_port *);
static int MoxaPortTxQueue(struct moxa_port *);
static int MoxaPortRxQueue(struct moxa_port *);
static int MoxaPortTxFree(struct moxa_port *);
static unsigned int MoxaPortTxFree(struct moxa_port *);
static void MoxaPortTxDisable(struct moxa_port *);
static void MoxaPortTxEnable(struct moxa_port *);
static int moxa_get_serial_info(struct tty_struct *, struct serial_struct *);
@ -1217,7 +1217,7 @@ static int moxa_write(struct tty_struct *tty,
return len;
}
static int moxa_write_room(struct tty_struct *tty)
static unsigned int moxa_write_room(struct tty_struct *tty)
{
struct moxa_port *ch;
@ -1992,7 +1992,7 @@ static int MoxaPortTxQueue(struct moxa_port *port)
return (wptr - rptr) & mask;
}
static int MoxaPortTxFree(struct moxa_port *port)
static unsigned int MoxaPortTxFree(struct moxa_port *port)
{
void __iomem *ofsAddr = port->tableAddr;
u16 rptr, wptr, mask;

View File

@ -1183,7 +1183,7 @@ static void mxser_flush_chars(struct tty_struct *tty)
spin_unlock_irqrestore(&info->slock, flags);
}
static int mxser_write_room(struct tty_struct *tty)
static unsigned int mxser_write_room(struct tty_struct *tty)
{
struct mxser_port *info = tty->driver_data;
int ret;

View File

@ -3056,7 +3056,7 @@ static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf,
return sent;
}
static int gsmtty_write_room(struct tty_struct *tty)
static unsigned int gsmtty_write_room(struct tty_struct *tty)
{
struct gsm_dlci *dlci = tty->driver_data;
if (dlci->state == DLCI_CLOSED)

View File

@ -1636,10 +1636,10 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
* If the port is unplugged report lots of room and let the bits
* dribble away so we don't block anything.
*/
static int ntty_write_room(struct tty_struct *tty)
static unsigned int ntty_write_room(struct tty_struct *tty)
{
struct port *port = tty->driver_data;
int room = 4096;
unsigned int room = 4096;
const struct nozomi *dc = get_dc_by_tty(tty);
if (dc)

View File

@ -136,7 +136,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
* the other device.
*/
static int pty_write_room(struct tty_struct *tty)
static unsigned int pty_write_room(struct tty_struct *tty)
{
if (tty->flow.stopped)
return 0;

View File

@ -298,7 +298,7 @@ static void kgdb_nmi_tty_hangup(struct tty_struct *tty)
tty_port_hangup(&priv->port);
}
static int kgdb_nmi_tty_write_room(struct tty_struct *tty)
static unsigned int kgdb_nmi_tty_write_room(struct tty_struct *tty)
{
/* Actually, we can handle any amount as we use polled writes. */
return 2048;

View File

@ -616,12 +616,12 @@ static int uart_write(struct tty_struct *tty,
return ret;
}
static int uart_write_room(struct tty_struct *tty)
static unsigned int uart_write_room(struct tty_struct *tty)
{
struct uart_state *state = tty->driver_data;
struct uart_port *port;
unsigned long flags;
int ret;
unsigned int ret;
port = uart_port_lock(state, flags);
ret = uart_circ_chars_free(&state->xmit);

View File

@ -868,15 +868,15 @@ exit:
DBGINFO(("%s wait_until_sent exit\n", info->device_name));
}
static int write_room(struct tty_struct *tty)
static unsigned int write_room(struct tty_struct *tty)
{
struct slgt_info *info = tty->driver_data;
int ret;
unsigned int ret;
if (sanity_check(info, tty->name, "write_room"))
return 0;
ret = (info->tx_active) ? 0 : HDLC_MAX_FRAME_SIZE;
DBGINFO(("%s write_room=%d\n", info->device_name, ret));
DBGINFO(("%s write_room=%u\n", info->device_name, ret));
return ret;
}

View File

@ -73,7 +73,7 @@ EXPORT_SYMBOL(tty_chars_in_buffer);
* returned and data may be lost as there will be no flow control.
*/
int tty_write_room(struct tty_struct *tty)
unsigned int tty_write_room(struct tty_struct *tty)
{
if (tty->ops->write_room)
return tty->ops->write_room(tty);

View File

@ -35,7 +35,7 @@ static int ttynull_write(struct tty_struct *tty, const unsigned char *buf,
return count;
}
static int ttynull_write_room(struct tty_struct *tty)
static unsigned int ttynull_write_room(struct tty_struct *tty)
{
return 65536;
}

View File

@ -870,10 +870,10 @@ static int vcc_write(struct tty_struct *tty, const unsigned char *buf,
return total_sent ? total_sent : rv;
}
static int vcc_write_room(struct tty_struct *tty)
static unsigned int vcc_write_room(struct tty_struct *tty)
{
struct vcc_port *port;
u64 num;
unsigned int num;
port = vcc_get_ne(tty->index);
if (unlikely(!port)) {

View File

@ -3263,7 +3263,7 @@ static int con_put_char(struct tty_struct *tty, unsigned char ch)
return do_con_write(tty, &ch, 1);
}
static int con_write_room(struct tty_struct *tty)
static unsigned int con_write_room(struct tty_struct *tty)
{
if (tty->flow.stopped)
return 0;

View File

@ -838,7 +838,7 @@ static int acm_tty_write(struct tty_struct *tty,
return count;
}
static int acm_tty_write_room(struct tty_struct *tty)
static unsigned int acm_tty_write_room(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
/*

View File

@ -774,18 +774,18 @@ static void gs_flush_chars(struct tty_struct *tty)
spin_unlock_irqrestore(&port->port_lock, flags);
}
static int gs_write_room(struct tty_struct *tty)
static unsigned int gs_write_room(struct tty_struct *tty)
{
struct gs_port *port = tty->driver_data;
unsigned long flags;
int room = 0;
unsigned int room = 0;
spin_lock_irqsave(&port->port_lock, flags);
if (port->port_usb)
room = kfifo_avail(&port->port_write_buf);
spin_unlock_irqrestore(&port->port_lock, flags);
pr_vdebug("gs_write_room: (%d,%p) room=%d\n",
pr_vdebug("gs_write_room: (%d,%p) room=%u\n",
port->port_num, tty, room);
return room;

View File

@ -240,11 +240,11 @@ static void dbc_tty_flush_chars(struct tty_struct *tty)
spin_unlock_irqrestore(&port->port_lock, flags);
}
static int dbc_tty_write_room(struct tty_struct *tty)
static unsigned int dbc_tty_write_room(struct tty_struct *tty)
{
struct dbc_port *port = tty->driver_data;
unsigned long flags;
int room = 0;
unsigned int room;
spin_lock_irqsave(&port->port_lock, flags);
room = kfifo_avail(&port->write_fifo);

View File

@ -376,7 +376,7 @@ exit:
return retval;
}
static int serial_write_room(struct tty_struct *tty)
static unsigned int serial_write_room(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;

View File

@ -459,7 +459,7 @@ extern void tty_write_message(struct tty_struct *tty, char *msg);
extern int tty_send_xchar(struct tty_struct *tty, char ch);
extern int tty_put_char(struct tty_struct *tty, unsigned char c);
extern int tty_chars_in_buffer(struct tty_struct *tty);
extern int tty_write_room(struct tty_struct *tty);
extern unsigned int tty_write_room(struct tty_struct *tty);
extern void tty_driver_flush_buffer(struct tty_struct *tty);
extern void tty_throttle(struct tty_struct *tty);
extern void tty_unthrottle(struct tty_struct *tty);

View File

@ -89,7 +89,7 @@
*
* Note: Do not call this function directly, call tty_driver_flush_chars
*
* int (*write_room)(struct tty_struct *tty);
* unsigned int (*write_room)(struct tty_struct *tty);
*
* This routine returns the numbers of characters the tty driver
* will accept for queuing to be written. This number is subject
@ -256,7 +256,7 @@ struct tty_operations {
const unsigned char *buf, int count);
int (*put_char)(struct tty_struct *tty, unsigned char ch);
void (*flush_chars)(struct tty_struct *tty);
int (*write_room)(struct tty_struct *tty);
unsigned int (*write_room)(struct tty_struct *tty);
int (*chars_in_buffer)(struct tty_struct *tty);
int (*ioctl)(struct tty_struct *tty,
unsigned int cmd, unsigned long arg);

View File

@ -807,7 +807,7 @@ static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, in
return sent;
}
static int rfcomm_tty_write_room(struct tty_struct *tty)
static unsigned int rfcomm_tty_write_room(struct tty_struct *tty)
{
struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
int room = 0;