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

USB: serial: make usb_serial_driver::write_room return uint

Line disciplines expect a positive value or zero returned from
tty->ops->write_room (invoked by tty_write_room). Both of them are being
updated to return an unsigned int. Switch also
usb_serial_driver::write_room and all its users.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
[ johan: amend commit message, drop unrelated comment change ]
Signed-off-by: Johan Hovold <johan@kernel.org>

authored by

Jiri Slaby and committed by
Johan Hovold
94cc7aea d07f6ca9

+50 -50
+2 -2
drivers/usb/serial/cyberjack.c
··· 53 53 static void cyberjack_close(struct usb_serial_port *port); 54 54 static int cyberjack_write(struct tty_struct *tty, 55 55 struct usb_serial_port *port, const unsigned char *buf, int count); 56 - static int cyberjack_write_room(struct tty_struct *tty); 56 + static unsigned int cyberjack_write_room(struct tty_struct *tty); 57 57 static void cyberjack_read_int_callback(struct urb *urb); 58 58 static void cyberjack_read_bulk_callback(struct urb *urb); 59 59 static void cyberjack_write_bulk_callback(struct urb *urb); ··· 240 240 return count; 241 241 } 242 242 243 - static int cyberjack_write_room(struct tty_struct *tty) 243 + static unsigned int cyberjack_write_room(struct tty_struct *tty) 244 244 { 245 245 /* FIXME: .... */ 246 246 return CYBERJACK_LOCAL_BUF_SIZE;
+4 -4
drivers/usb/serial/cypress_m8.c
··· 122 122 static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, 123 123 const unsigned char *buf, int count); 124 124 static void cypress_send(struct usb_serial_port *port); 125 - static int cypress_write_room(struct tty_struct *tty); 125 + static unsigned int cypress_write_room(struct tty_struct *tty); 126 126 static void cypress_earthmate_init_termios(struct tty_struct *tty); 127 127 static void cypress_set_termios(struct tty_struct *tty, 128 128 struct usb_serial_port *port, struct ktermios *old); ··· 789 789 790 790 791 791 /* returns how much space is available in the soft buffer */ 792 - static int cypress_write_room(struct tty_struct *tty) 792 + static unsigned int cypress_write_room(struct tty_struct *tty) 793 793 { 794 794 struct usb_serial_port *port = tty->driver_data; 795 795 struct cypress_private *priv = usb_get_serial_port_data(port); 796 - int room = 0; 796 + unsigned int room; 797 797 unsigned long flags; 798 798 799 799 spin_lock_irqsave(&priv->lock, flags); 800 800 room = kfifo_avail(&priv->write_fifo); 801 801 spin_unlock_irqrestore(&priv->lock, flags); 802 802 803 - dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); 803 + dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); 804 804 return room; 805 805 } 806 806
+4 -4
drivers/usb/serial/digi_acceleport.c
··· 223 223 static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, 224 224 const unsigned char *buf, int count); 225 225 static void digi_write_bulk_callback(struct urb *urb); 226 - static int digi_write_room(struct tty_struct *tty); 226 + static unsigned int digi_write_room(struct tty_struct *tty); 227 227 static int digi_chars_in_buffer(struct tty_struct *tty); 228 228 static int digi_open(struct tty_struct *tty, struct usb_serial_port *port); 229 229 static void digi_close(struct usb_serial_port *port); ··· 1020 1020 tty_port_tty_wakeup(&port->port); 1021 1021 } 1022 1022 1023 - static int digi_write_room(struct tty_struct *tty) 1023 + static unsigned int digi_write_room(struct tty_struct *tty) 1024 1024 { 1025 1025 struct usb_serial_port *port = tty->driver_data; 1026 1026 struct digi_port *priv = usb_get_serial_port_data(port); 1027 - int room; 1027 + unsigned int room; 1028 1028 unsigned long flags = 0; 1029 1029 1030 1030 spin_lock_irqsave(&priv->dp_port_lock, flags); ··· 1035 1035 room = port->bulk_out_size - 2 - priv->dp_out_buf_len; 1036 1036 1037 1037 spin_unlock_irqrestore(&priv->dp_port_lock, flags); 1038 - dev_dbg(&port->dev, "digi_write_room: port=%d, room=%d\n", priv->dp_port_num, room); 1038 + dev_dbg(&port->dev, "digi_write_room: port=%d, room=%u\n", priv->dp_port_num, room); 1039 1039 return room; 1040 1040 1041 1041 }
+1 -1
drivers/usb/serial/garmin_gps.c
··· 1113 1113 } 1114 1114 1115 1115 1116 - static int garmin_write_room(struct tty_struct *tty) 1116 + static unsigned int garmin_write_room(struct tty_struct *tty) 1117 1117 { 1118 1118 struct usb_serial_port *port = tty->driver_data; 1119 1119 /*
+3 -3
drivers/usb/serial/generic.c
··· 230 230 } 231 231 EXPORT_SYMBOL_GPL(usb_serial_generic_write); 232 232 233 - int usb_serial_generic_write_room(struct tty_struct *tty) 233 + unsigned int usb_serial_generic_write_room(struct tty_struct *tty) 234 234 { 235 235 struct usb_serial_port *port = tty->driver_data; 236 236 unsigned long flags; 237 - int room; 237 + unsigned int room; 238 238 239 239 if (!port->bulk_out_size) 240 240 return 0; ··· 243 243 room = kfifo_avail(&port->write_fifo); 244 244 spin_unlock_irqrestore(&port->lock, flags); 245 245 246 - dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); 246 + dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); 247 247 return room; 248 248 } 249 249
+3 -3
drivers/usb/serial/io_edgeport.c
··· 1355 1355 * we return the amount of room that we have for this port (the txCredits) 1356 1356 * otherwise we return a negative error number. 1357 1357 *****************************************************************************/ 1358 - static int edge_write_room(struct tty_struct *tty) 1358 + static unsigned int edge_write_room(struct tty_struct *tty) 1359 1359 { 1360 1360 struct usb_serial_port *port = tty->driver_data; 1361 1361 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1362 - int room; 1362 + unsigned int room; 1363 1363 unsigned long flags; 1364 1364 1365 1365 if (edge_port == NULL) ··· 1377 1377 room = edge_port->txCredits - edge_port->txfifo.count; 1378 1378 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1379 1379 1380 - dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); 1380 + dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); 1381 1381 return room; 1382 1382 } 1383 1383
+3 -3
drivers/usb/serial/io_ti.c
··· 2067 2067 tty_wakeup(tty); 2068 2068 } 2069 2069 2070 - static int edge_write_room(struct tty_struct *tty) 2070 + static unsigned int edge_write_room(struct tty_struct *tty) 2071 2071 { 2072 2072 struct usb_serial_port *port = tty->driver_data; 2073 2073 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2074 - int room = 0; 2074 + unsigned int room; 2075 2075 unsigned long flags; 2076 2076 2077 2077 if (edge_port == NULL) ··· 2083 2083 room = kfifo_avail(&port->write_fifo); 2084 2084 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2085 2085 2086 - dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); 2086 + dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); 2087 2087 return room; 2088 2088 } 2089 2089
+3 -3
drivers/usb/serial/ir-usb.c
··· 47 47 static int ir_startup (struct usb_serial *serial); 48 48 static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, 49 49 const unsigned char *buf, int count); 50 - static int ir_write_room(struct tty_struct *tty); 50 + static unsigned int ir_write_room(struct tty_struct *tty); 51 51 static void ir_write_bulk_callback(struct urb *urb); 52 52 static void ir_process_read_urb(struct urb *urb); 53 53 static void ir_set_termios(struct tty_struct *tty, ··· 339 339 usb_serial_port_softint(port); 340 340 } 341 341 342 - static int ir_write_room(struct tty_struct *tty) 342 + static unsigned int ir_write_room(struct tty_struct *tty) 343 343 { 344 344 struct usb_serial_port *port = tty->driver_data; 345 - int count = 0; 345 + unsigned int count = 0; 346 346 347 347 if (port->bulk_out_size == 0) 348 348 return 0;
+2 -2
drivers/usb/serial/keyspan.c
··· 1453 1453 } 1454 1454 } 1455 1455 1456 - static int keyspan_write_room(struct tty_struct *tty) 1456 + static unsigned int keyspan_write_room(struct tty_struct *tty) 1457 1457 { 1458 1458 struct usb_serial_port *port = tty->driver_data; 1459 1459 struct keyspan_port_private *p_priv; 1460 1460 const struct keyspan_device_details *d_details; 1461 1461 int flip; 1462 - int data_len; 1462 + unsigned int data_len; 1463 1463 struct urb *this_urb; 1464 1464 1465 1465 p_priv = usb_get_serial_port_data(port);
+2 -2
drivers/usb/serial/kobil_sct.c
··· 53 53 static void kobil_close(struct usb_serial_port *port); 54 54 static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, 55 55 const unsigned char *buf, int count); 56 - static int kobil_write_room(struct tty_struct *tty); 56 + static unsigned int kobil_write_room(struct tty_struct *tty); 57 57 static int kobil_ioctl(struct tty_struct *tty, 58 58 unsigned int cmd, unsigned long arg); 59 59 static int kobil_tiocmget(struct tty_struct *tty); ··· 358 358 } 359 359 360 360 361 - static int kobil_write_room(struct tty_struct *tty) 361 + static unsigned int kobil_write_room(struct tty_struct *tty) 362 362 { 363 363 /* FIXME */ 364 364 return 8;
+3 -3
drivers/usb/serial/mos7720.c
··· 1033 1033 * If successful, we return the amount of room that we have for this port 1034 1034 * Otherwise we return a negative error number. 1035 1035 */ 1036 - static int mos7720_write_room(struct tty_struct *tty) 1036 + static unsigned int mos7720_write_room(struct tty_struct *tty) 1037 1037 { 1038 1038 struct usb_serial_port *port = tty->driver_data; 1039 1039 struct moschip_port *mos7720_port; 1040 - int room = 0; 1040 + unsigned int room = 0; 1041 1041 int i; 1042 1042 1043 1043 mos7720_port = usb_get_serial_port_data(port); ··· 1051 1051 room += URB_TRANSFER_BUFFER_SIZE; 1052 1052 } 1053 1053 1054 - dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); 1054 + dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); 1055 1055 return room; 1056 1056 } 1057 1057
+3 -3
drivers/usb/serial/mos7840.c
··· 818 818 * Otherwise we return a negative error number. 819 819 *****************************************************************************/ 820 820 821 - static int mos7840_write_room(struct tty_struct *tty) 821 + static unsigned int mos7840_write_room(struct tty_struct *tty) 822 822 { 823 823 struct usb_serial_port *port = tty->driver_data; 824 824 struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 825 825 int i; 826 - int room = 0; 826 + unsigned int room = 0; 827 827 unsigned long flags; 828 828 829 829 spin_lock_irqsave(&mos7840_port->pool_lock, flags); ··· 834 834 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 835 835 836 836 room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1; 837 - dev_dbg(&mos7840_port->port->dev, "%s - returns %d\n", __func__, room); 837 + dev_dbg(&mos7840_port->port->dev, "%s - returns %u\n", __func__, room); 838 838 return room; 839 839 840 840 }
+1 -1
drivers/usb/serial/opticon.c
··· 267 267 return ret; 268 268 } 269 269 270 - static int opticon_write_room(struct tty_struct *tty) 270 + static unsigned int opticon_write_room(struct tty_struct *tty) 271 271 { 272 272 struct usb_serial_port *port = tty->driver_data; 273 273 struct opticon_private *priv = usb_get_serial_port_data(port);
+3 -3
drivers/usb/serial/oti6858.c
··· 126 126 static void oti6858_write_bulk_callback(struct urb *urb); 127 127 static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, 128 128 const unsigned char *buf, int count); 129 - static int oti6858_write_room(struct tty_struct *tty); 129 + static unsigned int oti6858_write_room(struct tty_struct *tty); 130 130 static int oti6858_chars_in_buffer(struct tty_struct *tty); 131 131 static int oti6858_tiocmget(struct tty_struct *tty); 132 132 static int oti6858_tiocmset(struct tty_struct *tty, ··· 363 363 return count; 364 364 } 365 365 366 - static int oti6858_write_room(struct tty_struct *tty) 366 + static unsigned int oti6858_write_room(struct tty_struct *tty) 367 367 { 368 368 struct usb_serial_port *port = tty->driver_data; 369 - int room = 0; 369 + unsigned int room; 370 370 unsigned long flags; 371 371 372 372 spin_lock_irqsave(&port->lock, flags);
+2 -2
drivers/usb/serial/quatech2.c
··· 870 870 871 871 } 872 872 873 - static int qt2_write_room(struct tty_struct *tty) 873 + static unsigned int qt2_write_room(struct tty_struct *tty) 874 874 { 875 875 struct usb_serial_port *port = tty->driver_data; 876 876 struct qt2_port_private *port_priv; 877 877 unsigned long flags = 0; 878 - int r; 878 + unsigned int r; 879 879 880 880 port_priv = usb_get_serial_port_data(port); 881 881
+1 -1
drivers/usb/serial/sierra.c
··· 613 613 } 614 614 } 615 615 616 - static int sierra_write_room(struct tty_struct *tty) 616 + static unsigned int sierra_write_room(struct tty_struct *tty) 617 617 { 618 618 struct usb_serial_port *port = tty->driver_data; 619 619 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
+4 -4
drivers/usb/serial/ti_usb_3410_5052.c
··· 307 307 static void ti_close(struct usb_serial_port *port); 308 308 static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, 309 309 const unsigned char *data, int count); 310 - static int ti_write_room(struct tty_struct *tty); 310 + static unsigned int ti_write_room(struct tty_struct *tty); 311 311 static int ti_chars_in_buffer(struct tty_struct *tty); 312 312 static bool ti_tx_empty(struct usb_serial_port *port); 313 313 static void ti_throttle(struct tty_struct *tty); ··· 810 810 } 811 811 812 812 813 - static int ti_write_room(struct tty_struct *tty) 813 + static unsigned int ti_write_room(struct tty_struct *tty) 814 814 { 815 815 struct usb_serial_port *port = tty->driver_data; 816 816 struct ti_port *tport = usb_get_serial_port_data(port); 817 - int room = 0; 817 + unsigned int room; 818 818 unsigned long flags; 819 819 820 820 spin_lock_irqsave(&tport->tp_lock, flags); 821 821 room = kfifo_avail(&port->write_fifo); 822 822 spin_unlock_irqrestore(&tport->tp_lock, flags); 823 823 824 - dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); 824 + dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); 825 825 return room; 826 826 } 827 827
+1 -1
drivers/usb/serial/usb-wwan.h
··· 11 11 extern void usb_wwan_close(struct usb_serial_port *port); 12 12 extern int usb_wwan_port_probe(struct usb_serial_port *port); 13 13 extern void usb_wwan_port_remove(struct usb_serial_port *port); 14 - extern int usb_wwan_write_room(struct tty_struct *tty); 14 + extern unsigned int usb_wwan_write_room(struct tty_struct *tty); 15 15 extern int usb_wwan_tiocmget(struct tty_struct *tty); 16 16 extern int usb_wwan_tiocmset(struct tty_struct *tty, 17 17 unsigned int set, unsigned int clear);
+3 -3
drivers/usb/serial/usb_wwan.c
··· 278 278 } 279 279 } 280 280 281 - int usb_wwan_write_room(struct tty_struct *tty) 281 + unsigned int usb_wwan_write_room(struct tty_struct *tty) 282 282 { 283 283 struct usb_serial_port *port = tty->driver_data; 284 284 struct usb_wwan_port_private *portdata; 285 285 int i; 286 - int data_len = 0; 286 + unsigned int data_len = 0; 287 287 struct urb *this_urb; 288 288 289 289 portdata = usb_get_serial_port_data(port); ··· 294 294 data_len += OUT_BUFLEN; 295 295 } 296 296 297 - dev_dbg(&port->dev, "%s: %d\n", __func__, data_len); 297 + dev_dbg(&port->dev, "%s: %u\n", __func__, data_len); 298 298 return data_len; 299 299 } 300 300 EXPORT_SYMBOL(usb_wwan_write_room);
+2 -2
include/linux/usb/serial.h
··· 276 276 int (*write)(struct tty_struct *tty, struct usb_serial_port *port, 277 277 const unsigned char *buf, int count); 278 278 /* Called only by the tty layer */ 279 - int (*write_room)(struct tty_struct *tty); 279 + unsigned int (*write_room)(struct tty_struct *tty); 280 280 int (*ioctl)(struct tty_struct *tty, 281 281 unsigned int cmd, unsigned long arg); 282 282 void (*get_serial)(struct tty_struct *tty, struct serial_struct *ss); ··· 347 347 const unsigned char *buf, int count); 348 348 void usb_serial_generic_close(struct usb_serial_port *port); 349 349 int usb_serial_generic_resume(struct usb_serial *serial); 350 - int usb_serial_generic_write_room(struct tty_struct *tty); 350 + unsigned int usb_serial_generic_write_room(struct tty_struct *tty); 351 351 int usb_serial_generic_chars_in_buffer(struct tty_struct *tty); 352 352 void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout); 353 353 void usb_serial_generic_read_bulk_callback(struct urb *urb);