Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: make tty_operations::write()'s count size_t

Unify with the rest of the code. Use size_t for counts and ssize_t for
retval.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230810091510.13006-30-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
95713967 dcaafbe6

+82 -61
+2 -2
arch/alpha/kernel/srmcons.c
··· 129 129 return count; 130 130 } 131 131 132 - static int 133 - srmcons_write(struct tty_struct *tty, const u8 *buf, int count) 132 + static ssize_t 133 + srmcons_write(struct tty_struct *tty, const u8 *buf, size_t count) 134 134 { 135 135 unsigned long flags; 136 136
+2 -1
arch/m68k/emu/nfcon.c
··· 70 70 { 71 71 } 72 72 73 - static int nfcon_tty_write(struct tty_struct *tty, const u8 *buf, int count) 73 + static ssize_t nfcon_tty_write(struct tty_struct *tty, const u8 *buf, 74 + size_t count) 74 75 { 75 76 nfputs(buf, count); 76 77 return count;
+1 -1
arch/um/drivers/line.c
··· 184 184 line_flush_buffer(tty); 185 185 } 186 186 187 - int line_write(struct tty_struct *tty, const u8 *buf, int len) 187 + ssize_t line_write(struct tty_struct *tty, const u8 *buf, size_t len) 188 188 { 189 189 struct line *line = tty->driver_data; 190 190 unsigned long flags;
+1 -1
arch/um/drivers/line.h
··· 64 64 extern void line_hangup(struct tty_struct *tty); 65 65 extern int line_setup(char **conf, unsigned nlines, char **def, 66 66 char *init, char *name); 67 - extern int line_write(struct tty_struct *tty, const u8 *buf, int len); 67 + extern ssize_t line_write(struct tty_struct *tty, const u8 *buf, size_t len); 68 68 extern unsigned int line_chars_in_buffer(struct tty_struct *tty); 69 69 extern void line_flush_buffer(struct tty_struct *tty); 70 70 extern void line_flush_chars(struct tty_struct *tty);
+1 -1
arch/xtensa/platforms/iss/console.c
··· 52 52 } 53 53 54 54 55 - static int rs_write(struct tty_struct * tty, const u8 *buf, int count) 55 + static ssize_t rs_write(struct tty_struct * tty, const u8 *buf, size_t count) 56 56 { 57 57 /* see drivers/char/serialX.c to reference original version */ 58 58
+1 -1
drivers/char/ttyprintk.c
··· 103 103 /* 104 104 * TTY operations write function. 105 105 */ 106 - static int tpk_write(struct tty_struct *tty, const u8 *buf, int count) 106 + static ssize_t tpk_write(struct tty_struct *tty, const u8 *buf, size_t count) 107 107 { 108 108 struct ttyprintk_port *tpkp = tty->driver_data; 109 109 unsigned long flags;
+2 -1
drivers/ipack/devices/ipoctal.c
··· 458 458 return i; 459 459 } 460 460 461 - static int ipoctal_write_tty(struct tty_struct *tty, const u8 *buf, int count) 461 + static ssize_t ipoctal_write_tty(struct tty_struct *tty, const u8 *buf, 462 + size_t count) 462 463 { 463 464 struct ipoctal_channel *channel = tty->driver_data; 464 465 unsigned int char_copied;
+3 -2
drivers/isdn/capi/capi.c
··· 1077 1077 tty_port_close(&mp->port, tty, filp); 1078 1078 } 1079 1079 1080 - static int capinc_tty_write(struct tty_struct *tty, const u8 *buf, int count) 1080 + static ssize_t capinc_tty_write(struct tty_struct *tty, const u8 *buf, 1081 + size_t count) 1081 1082 { 1082 1083 struct capiminor *mp = tty->driver_data; 1083 1084 struct sk_buff *skb; 1084 1085 1085 - pr_debug("capinc_tty_write(count=%d)\n", count); 1086 + pr_debug("capinc_tty_write(count=%zu)\n", count); 1086 1087 1087 1088 spin_lock_bh(&mp->outlock); 1088 1089 skb = mp->outskb;
+2 -1
drivers/misc/bcm-vk/bcm_vk_tty.c
··· 186 186 VK_BAR0_REGSEG_DB_BASE + VK_BAR0_REGSEG_TTY_DB_OFFSET); 187 187 } 188 188 189 - static int bcm_vk_tty_write(struct tty_struct *tty, const u8 *buffer, int count) 189 + static ssize_t bcm_vk_tty_write(struct tty_struct *tty, const u8 *buffer, 190 + size_t count) 190 191 { 191 192 int index; 192 193 struct bcm_vk *vk;
+2 -1
drivers/mmc/core/sdio_uart.c
··· 760 760 tty_port_hangup(&port->port); 761 761 } 762 762 763 - static int sdio_uart_write(struct tty_struct *tty, const u8 *buf, int count) 763 + static ssize_t sdio_uart_write(struct tty_struct *tty, const u8 *buf, 764 + size_t count) 764 765 { 765 766 struct sdio_uart_port *port = tty->driver_data; 766 767 int ret;
+2 -1
drivers/net/usb/hso.c
··· 1322 1322 } 1323 1323 1324 1324 /* close the requested serial port */ 1325 - static int hso_serial_write(struct tty_struct *tty, const u8 *buf, int count) 1325 + static ssize_t hso_serial_write(struct tty_struct *tty, const u8 *buf, 1326 + size_t count) 1326 1327 { 1327 1328 struct hso_serial *serial = tty->driver_data; 1328 1329 int space, tx_bytes;
+2 -1
drivers/s390/char/con3215.c
··· 1021 1021 /* 1022 1022 * String write routine for 3215 ttys 1023 1023 */ 1024 - static int tty3215_write(struct tty_struct *tty, const u8 *buf, int count) 1024 + static ssize_t tty3215_write(struct tty_struct *tty, const u8 *buf, 1025 + size_t count) 1025 1026 { 1026 1027 handle_write(tty->driver_data, buf, count); 1027 1028 return count;
+2 -1
drivers/s390/char/con3270.c
··· 1803 1803 /* 1804 1804 * String write routine for 3270 ttys 1805 1805 */ 1806 - static int tty3270_write(struct tty_struct *tty, const u8 *buf, int count) 1806 + static ssize_t tty3270_write(struct tty_struct *tty, const u8 *buf, 1807 + size_t count) 1807 1808 { 1808 1809 struct tty3270 *tp; 1809 1810
+2 -2
drivers/s390/char/sclp_tty.c
··· 229 229 * tty device. The characters may come from user space or kernel space. This 230 230 * routine will return the number of characters actually accepted for writing. 231 231 */ 232 - static int 233 - sclp_tty_write(struct tty_struct *tty, const u8 *buf, int count) 232 + static ssize_t 233 + sclp_tty_write(struct tty_struct *tty, const u8 *buf, size_t count) 234 234 { 235 235 if (sclp_tty_chars_count > 0) { 236 236 sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count, 0);
+2 -2
drivers/s390/char/sclp_vt220.c
··· 462 462 * user space or kernel space. This routine will return the 463 463 * number of characters actually accepted for writing. 464 464 */ 465 - static int 466 - sclp_vt220_write(struct tty_struct *tty, const u8 *buf, int count) 465 + static ssize_t 466 + sclp_vt220_write(struct tty_struct *tty, const u8 *buf, size_t count) 467 467 { 468 468 return __sclp_vt220_write(buf, count, 1, 0, 1); 469 469 }
+1 -1
drivers/staging/gdm724x/gdm_tty.c
··· 149 149 tty_port_tty_wakeup(&gdm->port); 150 150 } 151 151 152 - static int gdm_tty_write(struct tty_struct *tty, const u8 *buf, int len) 152 + static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len) 153 153 { 154 154 struct gdm *gdm = tty->driver_data; 155 155 int remain = len;
+1 -1
drivers/staging/greybus/uart.c
··· 427 427 tty_port_hangup(&gb_tty->port); 428 428 } 429 429 430 - static int gb_tty_write(struct tty_struct *tty, const u8 *buf, int count) 430 + static ssize_t gb_tty_write(struct tty_struct *tty, const u8 *buf, size_t count) 431 431 { 432 432 struct gb_tty *gb_tty = tty->driver_data; 433 433
+1 -1
drivers/tty/amiserial.c
··· 741 741 local_irq_restore(flags); 742 742 } 743 743 744 - static int rs_write(struct tty_struct * tty, const u8 *buf, int count) 744 + static ssize_t rs_write(struct tty_struct * tty, const u8 *buf, size_t count) 745 745 { 746 746 int c, ret = 0; 747 747 struct serial_state *info = tty->driver_data;
+2 -1
drivers/tty/ehv_bytechan.c
··· 466 466 * ehv_bc_tty_write_room() will never lie, so the tty layer will never send us 467 467 * too much data. 468 468 */ 469 - static int ehv_bc_tty_write(struct tty_struct *ttys, const u8 *s, int count) 469 + static ssize_t ehv_bc_tty_write(struct tty_struct *ttys, const u8 *s, 470 + size_t count) 470 471 { 471 472 struct ehv_bc_data *bc = ttys->driver_data; 472 473 unsigned long flags;
+2 -1
drivers/tty/goldfish.c
··· 185 185 tty_port_hangup(tty->port); 186 186 } 187 187 188 - static int goldfish_tty_write(struct tty_struct *tty, const u8 *buf, int count) 188 + static ssize_t goldfish_tty_write(struct tty_struct *tty, const u8 *buf, 189 + size_t count) 189 190 { 190 191 goldfish_tty_do_write(tty->index, buf, count); 191 192 return count;
+1 -1
drivers/tty/hvc/hvc_console.c
··· 496 496 return n; 497 497 } 498 498 499 - static int hvc_write(struct tty_struct *tty, const u8 *buf, int count) 499 + static ssize_t hvc_write(struct tty_struct *tty, const u8 *buf, size_t count) 500 500 { 501 501 struct hvc_struct *hp = tty->driver_data; 502 502 unsigned long flags;
+3 -2
drivers/tty/hvc/hvcs.c
··· 1257 1257 * tty_hangup will allow hvcs_write time to complete execution before it 1258 1258 * terminates our device. 1259 1259 */ 1260 - static int hvcs_write(struct tty_struct *tty, const u8 *buf, int count) 1260 + static ssize_t hvcs_write(struct tty_struct *tty, const u8 *buf, size_t count) 1261 1261 { 1262 1262 struct hvcs_struct *hvcsd = tty->driver_data; 1263 1263 unsigned int unit_address; ··· 1299 1299 unit_address = hvcsd->vdev->unit_address; 1300 1300 1301 1301 while (count > 0) { 1302 - tosend = min(count, (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); 1302 + tosend = min_t(unsigned, count, 1303 + (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); 1303 1304 /* 1304 1305 * No more space, this probably means that the last call to 1305 1306 * hvcs_write() didn't succeed and the buffer was filled up.
+2 -1
drivers/tty/hvc/hvsi.c
··· 904 904 return hp->n_outbuf; 905 905 } 906 906 907 - static int hvsi_write(struct tty_struct *tty, const u8 *source, int count) 907 + static ssize_t hvsi_write(struct tty_struct *tty, const u8 *source, 908 + size_t count) 908 909 { 909 910 struct hvsi_struct *hp = tty->driver_data; 910 911 unsigned long flags;
+2 -1
drivers/tty/ipwireless/tty.c
··· 186 186 tty->tx_bytes_queued -= packet_length; 187 187 } 188 188 189 - static int ipw_write(struct tty_struct *linux_tty, const u8 *buf, int count) 189 + static ssize_t ipw_write(struct tty_struct *linux_tty, const u8 *buf, 190 + size_t count) 190 191 { 191 192 struct ipw_tty *tty = linux_tty->driver_data; 192 193 int room, ret;
+3 -3
drivers/tty/mips_ejtag_fdc.c
··· 796 796 tty_port_hangup(tty->port); 797 797 } 798 798 799 - static int mips_ejtag_fdc_tty_write(struct tty_struct *tty, const u8 *buf, 800 - int total) 799 + static ssize_t mips_ejtag_fdc_tty_write(struct tty_struct *tty, const u8 *buf, 800 + size_t total) 801 801 { 802 802 int count, block; 803 803 struct mips_ejtag_fdc_tty_port *dport = tty->driver_data; ··· 816 816 */ 817 817 spin_lock(&dport->xmit_lock); 818 818 /* Work out how many bytes we can write to the xmit buffer */ 819 - total = min(total, (int)(priv->xmit_size - dport->xmit_cnt)); 819 + total = min_t(size_t, total, priv->xmit_size - dport->xmit_cnt); 820 820 atomic_add(total, &priv->xmit_total); 821 821 dport->xmit_cnt += total; 822 822 /* Write the actual bytes (may need splitting if it wraps) */
+2 -2
drivers/tty/moxa.c
··· 487 487 */ 488 488 static int moxa_open(struct tty_struct *, struct file *); 489 489 static void moxa_close(struct tty_struct *, struct file *); 490 - static int moxa_write(struct tty_struct *, const u8 *, int); 490 + static ssize_t moxa_write(struct tty_struct *, const u8 *, size_t); 491 491 static unsigned int moxa_write_room(struct tty_struct *); 492 492 static void moxa_flush_buffer(struct tty_struct *); 493 493 static unsigned int moxa_chars_in_buffer(struct tty_struct *); ··· 1499 1499 tty_port_close(&ch->port, tty, filp); 1500 1500 } 1501 1501 1502 - static int moxa_write(struct tty_struct *tty, const u8 *buf, int count) 1502 + static ssize_t moxa_write(struct tty_struct *tty, const u8 *buf, size_t count) 1503 1503 { 1504 1504 struct moxa_port *ch = tty->driver_data; 1505 1505 unsigned long flags;
+1 -1
drivers/tty/mxser.c
··· 901 901 tty_port_close(tty->port, tty, filp); 902 902 } 903 903 904 - static int mxser_write(struct tty_struct *tty, const u8 *buf, int count) 904 + static ssize_t mxser_write(struct tty_struct *tty, const u8 *buf, size_t count) 905 905 { 906 906 struct mxser_port *info = tty->driver_data; 907 907 unsigned long flags;
+1 -1
drivers/tty/n_gsm.c
··· 4256 4256 gsm_dlci_begin_close(dlci); 4257 4257 } 4258 4258 4259 - static int gsmtty_write(struct tty_struct *tty, const u8 *buf, int len) 4259 + static ssize_t gsmtty_write(struct tty_struct *tty, const u8 *buf, size_t len) 4260 4260 { 4261 4261 int sent; 4262 4262 struct gsm_dlci *dlci = tty->driver_data;
+2 -1
drivers/tty/nozomi.c
··· 1599 1599 * called when the userspace process writes to the tty (/dev/noz*). 1600 1600 * Data is inserted into a fifo, which is then read and transferred to the modem. 1601 1601 */ 1602 - static int ntty_write(struct tty_struct *tty, const u8 *buffer, int count) 1602 + static ssize_t ntty_write(struct tty_struct *tty, const u8 *buffer, 1603 + size_t count) 1603 1604 { 1604 1605 int rval = -EINVAL; 1605 1606 struct nozomi *dc = get_dc_by_tty(tty);
+1 -1
drivers/tty/pty.c
··· 108 108 * the other side of the pty/tty pair. 109 109 */ 110 110 111 - static int pty_write(struct tty_struct *tty, const u8 *buf, int c) 111 + static ssize_t pty_write(struct tty_struct *tty, const u8 *buf, size_t c) 112 112 { 113 113 struct tty_struct *to = tty->link; 114 114
+3 -2
drivers/tty/rpmsg_tty.c
··· 73 73 return tty_port_close(tty->port, tty, filp); 74 74 } 75 75 76 - static int rpmsg_tty_write(struct tty_struct *tty, const u8 *buf, int len) 76 + static ssize_t rpmsg_tty_write(struct tty_struct *tty, const u8 *buf, 77 + size_t len) 77 78 { 78 79 struct rpmsg_tty_port *cport = tty->driver_data; 79 80 struct rpmsg_device *rpdev; ··· 87 86 if (msg_max_size < 0) 88 87 return msg_max_size; 89 88 90 - msg_size = min(len, msg_max_size); 89 + msg_size = min_t(unsigned int, len, msg_max_size); 91 90 92 91 /* 93 92 * Use rpmsg_trysend instead of rpmsg_send to send the message so the caller is not
+2 -1
drivers/tty/serial/kgdb_nmi.c
··· 304 304 return 2048; 305 305 } 306 306 307 - static int kgdb_nmi_tty_write(struct tty_struct *tty, const u8 *buf, int c) 307 + static ssize_t kgdb_nmi_tty_write(struct tty_struct *tty, const u8 *buf, 308 + size_t c) 308 309 { 309 310 int i; 310 311
+1 -1
drivers/tty/serial/serial_core.c
··· 580 580 uart_start(tty); 581 581 } 582 582 583 - static int uart_write(struct tty_struct *tty, const u8 *buf, int count) 583 + static ssize_t uart_write(struct tty_struct *tty, const u8 *buf, size_t count) 584 584 { 585 585 struct uart_state *state = tty->driver_data; 586 586 struct uart_port *port;
+2 -1
drivers/tty/ttynull.c
··· 29 29 tty_port_hangup(&ttynull_port); 30 30 } 31 31 32 - static int ttynull_write(struct tty_struct *tty, const u8 *buf, int count) 32 + static ssize_t ttynull_write(struct tty_struct *tty, const u8 *buf, 33 + size_t count) 33 34 { 34 35 return count; 35 36 }
+3 -2
drivers/tty/vcc.c
··· 804 804 tty_port_hangup(tty->port); 805 805 } 806 806 807 - static int vcc_write(struct tty_struct *tty, const u8 *buf, int count) 807 + static ssize_t vcc_write(struct tty_struct *tty, const u8 *buf, size_t count) 808 808 { 809 809 struct vcc_port *port; 810 810 struct vio_vcc *pkt; ··· 826 826 827 827 while (count > 0) { 828 828 /* Minimum of data to write and space available */ 829 - tosend = min(count, (VCC_BUFF_LEN - port->chars_in_buffer)); 829 + tosend = min_t(size_t, count, 830 + (VCC_BUFF_LEN - port->chars_in_buffer)); 830 831 831 832 if (!tosend) 832 833 break;
+1 -1
drivers/tty/vt/vt.c
··· 3238 3238 * /dev/ttyN handling 3239 3239 */ 3240 3240 3241 - static int con_write(struct tty_struct *tty, const u8 *buf, int count) 3241 + static ssize_t con_write(struct tty_struct *tty, const u8 *buf, size_t count) 3242 3242 { 3243 3243 int retval; 3244 3244
+4 -3
drivers/usb/class/cdc-acm.c
··· 789 789 tty_port_close(&acm->port, tty, filp); 790 790 } 791 791 792 - static int acm_tty_write(struct tty_struct *tty, const u8 *buf, int count) 792 + static ssize_t acm_tty_write(struct tty_struct *tty, const u8 *buf, 793 + size_t count) 793 794 { 794 795 struct acm *acm = tty->driver_data; 795 796 int stat; ··· 801 800 if (!count) 802 801 return 0; 803 802 804 - dev_vdbg(&acm->data->dev, "%d bytes from tty layer\n", count); 803 + dev_vdbg(&acm->data->dev, "%zu bytes from tty layer\n", count); 805 804 806 805 spin_lock_irqsave(&acm->write_lock, flags); 807 806 wbn = acm_wb_alloc(acm); ··· 818 817 } 819 818 820 819 count = (count > acm->writesize) ? acm->writesize : count; 821 - dev_vdbg(&acm->data->dev, "writing %d bytes\n", count); 820 + dev_vdbg(&acm->data->dev, "writing %zu bytes\n", count); 822 821 memcpy(wb->buf, buf, count); 823 822 wb->len = count; 824 823
+2 -2
drivers/usb/gadget/function/u_serial.c
··· 734 734 spin_unlock_irq(&port->port_lock); 735 735 } 736 736 737 - static int gs_write(struct tty_struct *tty, const u8 *buf, int count) 737 + static ssize_t gs_write(struct tty_struct *tty, const u8 *buf, size_t count) 738 738 { 739 739 struct gs_port *port = tty->driver_data; 740 740 unsigned long flags; 741 741 742 - pr_vdebug("gs_write: ttyGS%d (%p) writing %d bytes\n", 742 + pr_vdebug("gs_write: ttyGS%d (%p) writing %zu bytes\n", 743 743 port->port_num, tty, count); 744 744 745 745 spin_lock_irqsave(&port->port_lock, flags);
+2 -1
drivers/usb/host/xhci-dbgtty.c
··· 208 208 tty_port_close(&port->port, tty, file); 209 209 } 210 210 211 - static int dbc_tty_write(struct tty_struct *tty, const u8 *buf, int count) 211 + static ssize_t dbc_tty_write(struct tty_struct *tty, const u8 *buf, 212 + size_t count) 212 213 { 213 214 struct dbc_port *port = tty->driver_data; 214 215 unsigned long flags;
+2 -2
drivers/usb/serial/usb-serial.c
··· 361 361 module_put(owner); 362 362 } 363 363 364 - static int serial_write(struct tty_struct *tty, const u8 *buf, int count) 364 + static ssize_t serial_write(struct tty_struct *tty, const u8 *buf, size_t count) 365 365 { 366 366 struct usb_serial_port *port = tty->driver_data; 367 367 int retval = -ENODEV; ··· 369 369 if (port->serial->dev->state == USB_STATE_NOTATTACHED) 370 370 goto exit; 371 371 372 - dev_dbg(&port->dev, "%s - %d byte(s)\n", __func__, count); 372 + dev_dbg(&port->dev, "%s - %zu byte(s)\n", __func__, count); 373 373 374 374 retval = port->serial->type->write(tty, port, buf, count); 375 375 if (retval < 0)
+3 -3
include/linux/tty_driver.h
··· 72 72 * is closed for the last time freeing up the resources. This is 73 73 * actually the second part of shutdown for routines that might sleep. 74 74 * 75 - * @write: ``int ()(struct tty_struct *tty, const unsigned char *buf, 76 - * int count)`` 75 + * @write: ``ssize_t ()(struct tty_struct *tty, const unsigned char *buf, 76 + * size_t count)`` 77 77 * 78 78 * This routine is called by the kernel to write a series (@count) of 79 79 * characters (@buf) to the @tty device. The characters may come from ··· 356 356 void (*close)(struct tty_struct * tty, struct file * filp); 357 357 void (*shutdown)(struct tty_struct *tty); 358 358 void (*cleanup)(struct tty_struct *tty); 359 - int (*write)(struct tty_struct *tty, const u8 *buf, int count); 359 + ssize_t (*write)(struct tty_struct *tty, const u8 *buf, size_t count); 360 360 int (*put_char)(struct tty_struct *tty, u8 ch); 361 361 void (*flush_chars)(struct tty_struct *tty); 362 362 unsigned int (*write_room)(struct tty_struct *tty);
+3 -2
net/bluetooth/rfcomm/tty.c
··· 779 779 tty_port_close(&dev->port, tty, filp); 780 780 } 781 781 782 - static int rfcomm_tty_write(struct tty_struct *tty, const u8 *buf, int count) 782 + static ssize_t rfcomm_tty_write(struct tty_struct *tty, const u8 *buf, 783 + size_t count) 783 784 { 784 785 struct rfcomm_dev *dev = tty->driver_data; 785 786 struct rfcomm_dlc *dlc = dev->dlc; 786 787 struct sk_buff *skb; 787 788 int sent = 0, size; 788 789 789 - BT_DBG("tty %p count %d", tty, count); 790 + BT_DBG("tty %p count %zu", tty, count); 790 791 791 792 while (count) { 792 793 size = min_t(uint, count, dlc->mtu);