Skip to content

Commit

Permalink
tty: make tty_operations::write_room return uint
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Laurentiu Tudor <[email protected]>
Acked-by: Alex Elder <[email protected]>
Acked-by: Max Filippov <[email protected]> # xtensa
Acked-by: David Sterba <[email protected]>
Acked-By: Anton Ivanov <[email protected]>
Acked-by: Geert Uytterhoeven <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Samuel Iglesias Gonsalvez <[email protected]>
Cc: Jens Taprogge <[email protected]>
Cc: Karsten Keil <[email protected]>
Cc: Scott Branden <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: David Lin <[email protected]>
Cc: Johan Hovold <[email protected]>
Cc: Jiri Kosina <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Oliver Neukum <[email protected]>
Cc: Felipe Balbi <[email protected]>
Cc: Mathias Nyman <[email protected]>
Cc: Marcel Holtmann <[email protected]>
Cc: Johan Hedberg <[email protected]>
Cc: Luiz Augusto von Dentz <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Jiri Slaby authored and gregkh committed May 13, 2021
1 parent 0f29b50 commit 03b3b1a
Show file tree
Hide file tree
Showing 47 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion arch/alpha/kernel/srmcons.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/emu/nfcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/parisc/kernel/pdc_cons.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand Down
6 changes: 3 additions & 3 deletions arch/um/drivers/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion arch/um/drivers/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/platforms/iss/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/pcmcia/synclink_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ static int mgslpc_write(struct tty_struct * tty,

/* 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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ttyprintk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/ipack/devices/ipoctal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions drivers/isdn/capi/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/bcm-vk/bcm_vk_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/core/sdio_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/usb/hso.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,10 +1357,10 @@ static int hso_serial_write(struct tty_struct *tty, const unsigned char *buf,
}

/* 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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/char/con3215.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions drivers/s390/char/sclp_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/s390/char/sclp_vt220.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/char/tty3270.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/fwserial/fwserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/gdm724x/gdm_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/greybus/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/amiserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions drivers/tty/ehv_bytechan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/goldfish.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/hvc/hvc_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/hvc/hvcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions drivers/tty/hvc/hvsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ static void hvsi_write_worker(struct work_struct *work)
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;

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/ipwireless/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/tty/mips_ejtag_fdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions drivers/tty/moxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down Expand Up @@ -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 *);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/mxser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/n_gsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions drivers/tty/nozomi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 03b3b1a

Please sign in to comment.