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

tty: hvc: convert to u8 and size_t

Switch character types to u8 and sizes to size_t. To conform to
characters/sizes in the rest of the tty layer.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Amit Shah <amit@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: virtualization@lists.linux.dev
Cc: linux-riscv@lists.infradead.org
Link: https://lore.kernel.org/r/20231206073712.17776-13-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
f32fcbed f3fb7367

+107 -92
+2 -2
arch/powerpc/include/asm/hvconsole.h
··· 21 21 * Vio firmware always attempts to fetch MAX_VIO_GET_CHARS chars. The 'count' 22 22 * parm is included to conform to put_chars() function pointer template 23 23 */ 24 - extern int hvc_get_chars(uint32_t vtermno, char *buf, int count); 25 - extern int hvc_put_chars(uint32_t vtermno, const char *buf, int count); 24 + extern ssize_t hvc_get_chars(uint32_t vtermno, u8 *buf, size_t count); 25 + extern ssize_t hvc_put_chars(uint32_t vtermno, const u8 *buf, size_t count); 26 26 27 27 /* Provided by HVC VIO */ 28 28 void hvc_vio_init_early(void);
+10 -8
arch/powerpc/include/asm/hvsi.h
··· 64 64 unsigned int inbuf_len; /* data in input buffer */ 65 65 unsigned char inbuf[HVSI_INBUF_SIZE]; 66 66 unsigned int inbuf_cur; /* Cursor in input buffer */ 67 - unsigned int inbuf_pktlen; /* packet length from cursor */ 67 + size_t inbuf_pktlen; /* packet length from cursor */ 68 68 atomic_t seqno; /* packet sequence number */ 69 69 unsigned int opened:1; /* driver opened */ 70 70 unsigned int established:1; /* protocol established */ ··· 72 72 unsigned int mctrl_update:1; /* modem control updated */ 73 73 unsigned short mctrl; /* modem control */ 74 74 struct tty_struct *tty; /* tty structure */ 75 - int (*get_chars)(uint32_t termno, char *buf, int count); 76 - int (*put_chars)(uint32_t termno, const char *buf, int count); 75 + ssize_t (*get_chars)(uint32_t termno, u8 *buf, size_t count); 76 + ssize_t (*put_chars)(uint32_t termno, const u8 *buf, size_t count); 77 77 uint32_t termno; 78 78 }; 79 79 80 80 /* hvsi lib functions */ 81 81 struct hvc_struct; 82 82 extern void hvsilib_init(struct hvsi_priv *pv, 83 - int (*get_chars)(uint32_t termno, char *buf, int count), 84 - int (*put_chars)(uint32_t termno, const char *buf, 85 - int count), 83 + ssize_t (*get_chars)(uint32_t termno, u8 *buf, 84 + size_t count), 85 + ssize_t (*put_chars)(uint32_t termno, const u8 *buf, 86 + size_t count), 86 87 int termno, int is_console); 87 88 extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp); 88 89 extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp); 89 90 extern int hvsilib_read_mctrl(struct hvsi_priv *pv); 90 91 extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr); 91 92 extern void hvsilib_establish(struct hvsi_priv *pv); 92 - extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count); 93 - extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count); 93 + extern ssize_t hvsilib_get_chars(struct hvsi_priv *pv, u8 *buf, size_t count); 94 + extern ssize_t hvsilib_put_chars(struct hvsi_priv *pv, const u8 *buf, 95 + size_t count); 94 96 95 97 #endif /* _HVSI_H */
+5 -3
arch/powerpc/include/asm/opal.h
··· 313 313 const char *uname, int depth, void *data); 314 314 void __init opal_configure_cores(void); 315 315 316 - extern int opal_get_chars(uint32_t vtermno, char *buf, int count); 317 - extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len); 318 - extern int opal_put_chars_atomic(uint32_t vtermno, const char *buf, int total_len); 316 + extern ssize_t opal_get_chars(uint32_t vtermno, u8 *buf, size_t count); 317 + extern ssize_t opal_put_chars(uint32_t vtermno, const u8 *buf, 318 + size_t total_len); 319 + extern ssize_t opal_put_chars_atomic(uint32_t vtermno, const u8 *buf, 320 + size_t total_len); 319 321 extern int opal_flush_chars(uint32_t vtermno, bool wait); 320 322 extern int opal_flush_console(uint32_t vtermno); 321 323
+8 -6
arch/powerpc/platforms/powernv/opal.c
··· 424 424 return 0; 425 425 } 426 426 427 - int opal_get_chars(uint32_t vtermno, char *buf, int count) 427 + ssize_t opal_get_chars(uint32_t vtermno, u8 *buf, size_t count) 428 428 { 429 429 s64 rc; 430 430 __be64 evt, len; ··· 441 441 return 0; 442 442 } 443 443 444 - static int __opal_put_chars(uint32_t vtermno, const char *data, int total_len, bool atomic) 444 + static ssize_t __opal_put_chars(uint32_t vtermno, const u8 *data, 445 + size_t total_len, bool atomic) 445 446 { 446 447 unsigned long flags = 0 /* shut up gcc */; 447 - int written; 448 + ssize_t written; 448 449 __be64 olen; 449 450 s64 rc; 450 451 ··· 485 484 if (atomic) { 486 485 /* Should not happen */ 487 486 pr_warn("atomic console write returned partial " 488 - "len=%d written=%d\n", total_len, written); 487 + "len=%zu written=%zd\n", total_len, written); 489 488 } 490 489 if (!written) 491 490 written = -EAGAIN; ··· 498 497 return written; 499 498 } 500 499 501 - int opal_put_chars(uint32_t vtermno, const char *data, int total_len) 500 + ssize_t opal_put_chars(uint32_t vtermno, const u8 *data, size_t total_len) 502 501 { 503 502 return __opal_put_chars(vtermno, data, total_len, false); 504 503 } ··· 509 508 * true at the moment because console space can race with OPAL's console 510 509 * writes. 511 510 */ 512 - int opal_put_chars_atomic(uint32_t vtermno, const char *data, int total_len) 511 + ssize_t opal_put_chars_atomic(uint32_t vtermno, const u8 *data, 512 + size_t total_len) 513 513 { 514 514 return __opal_put_chars(vtermno, data, total_len, true); 515 515 }
+2 -2
arch/powerpc/platforms/pseries/hvconsole.c
··· 25 25 * firmware. 26 26 * @count: not used? 27 27 */ 28 - int hvc_get_chars(uint32_t vtermno, char *buf, int count) 28 + ssize_t hvc_get_chars(uint32_t vtermno, u8 *buf, size_t count) 29 29 { 30 30 long ret; 31 31 unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; ··· 52 52 * firmware. Must be at least 16 bytes, even if count is less than 16. 53 53 * @count: Send this number of characters. 54 54 */ 55 - int hvc_put_chars(uint32_t vtermno, const char *buf, int count) 55 + ssize_t hvc_put_chars(uint32_t vtermno, const u8 *buf, size_t count) 56 56 { 57 57 unsigned long *lbuf = (unsigned long *) buf; 58 58 long ret;
+5 -5
drivers/char/virtio_console.c
··· 650 650 * Give out the data that's requested from the buffer that we have 651 651 * queued up. 652 652 */ 653 - static ssize_t fill_readbuf(struct port *port, char __user *out_buf, 653 + static ssize_t fill_readbuf(struct port *port, u8 __user *out_buf, 654 654 size_t out_count, bool to_user) 655 655 { 656 656 struct port_buffer *buf; ··· 669 669 if (ret) 670 670 return -EFAULT; 671 671 } else { 672 - memcpy((__force char *)out_buf, buf->buf + buf->offset, 672 + memcpy((__force u8 *)out_buf, buf->buf + buf->offset, 673 673 out_count); 674 674 } 675 675 ··· 1104 1104 * it to finish: inefficient in theory, but in practice 1105 1105 * implementations will do it immediately. 1106 1106 */ 1107 - static int put_chars(u32 vtermno, const char *buf, int count) 1107 + static ssize_t put_chars(u32 vtermno, const u8 *buf, size_t count) 1108 1108 { 1109 1109 struct port *port; 1110 1110 struct scatterlist sg[1]; ··· 1132 1132 * We call out to fill_readbuf that gets us the required data from the 1133 1133 * buffers that are queued up. 1134 1134 */ 1135 - static int get_chars(u32 vtermno, char *buf, int count) 1135 + static ssize_t get_chars(u32 vtermno, u8 *buf, size_t count) 1136 1136 { 1137 1137 struct port *port; 1138 1138 ··· 1143 1143 /* If we don't have an input queue yet, we can't get input. */ 1144 1144 BUG_ON(!port->in_vq); 1145 1145 1146 - return fill_readbuf(port, (__force char __user *)buf, count, false); 1146 + return fill_readbuf(port, (__force u8 __user *)buf, count, false); 1147 1147 } 1148 1148 1149 1149 static void resize_console(struct port *port)
+2 -2
drivers/tty/hvc/hvc_console.h
··· 52 52 53 53 /* implemented by a low level driver */ 54 54 struct hv_ops { 55 - int (*get_chars)(uint32_t vtermno, char *buf, int count); 56 - int (*put_chars)(uint32_t vtermno, const char *buf, int count); 55 + ssize_t (*get_chars)(uint32_t vtermno, u8 *buf, size_t count); 56 + ssize_t (*put_chars)(uint32_t vtermno, const u8 *buf, size_t count); 57 57 int (*flush)(uint32_t vtermno, bool wait); 58 58 59 59 /* Callbacks for notification. Called in open, close and hangup */
+12 -12
drivers/tty/hvc/hvc_dcc.c
··· 26 26 /* Lock to serialize access to DCC fifo */ 27 27 static DEFINE_SPINLOCK(dcc_lock); 28 28 29 - static DEFINE_KFIFO(inbuf, unsigned char, DCC_INBUF_SIZE); 30 - static DEFINE_KFIFO(outbuf, unsigned char, DCC_OUTBUF_SIZE); 29 + static DEFINE_KFIFO(inbuf, u8, DCC_INBUF_SIZE); 30 + static DEFINE_KFIFO(outbuf, u8, DCC_OUTBUF_SIZE); 31 31 32 - static void dcc_uart_console_putchar(struct uart_port *port, unsigned char ch) 32 + static void dcc_uart_console_putchar(struct uart_port *port, u8 ch) 33 33 { 34 34 while (__dcc_getstatus() & DCC_STATUS_TX) 35 35 cpu_relax(); ··· 62 62 63 63 EARLYCON_DECLARE(dcc, dcc_early_console_setup); 64 64 65 - static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count) 65 + static ssize_t hvc_dcc_put_chars(uint32_t vt, const u8 *buf, size_t count) 66 66 { 67 - int i; 67 + size_t i; 68 68 69 69 for (i = 0; i < count; i++) { 70 70 while (__dcc_getstatus() & DCC_STATUS_TX) ··· 76 76 return count; 77 77 } 78 78 79 - static int hvc_dcc_get_chars(uint32_t vt, char *buf, int count) 79 + static ssize_t hvc_dcc_get_chars(uint32_t vt, u8 *buf, size_t count) 80 80 { 81 - int i; 81 + size_t i; 82 82 83 83 for (i = 0; i < count; ++i) 84 84 if (__dcc_getstatus() & DCC_STATUS_RX) ··· 157 157 */ 158 158 static void dcc_get_work(struct work_struct *work) 159 159 { 160 - unsigned char ch; 161 160 unsigned long irqflags; 161 + u8 ch; 162 162 163 163 /* 164 164 * Read characters from DCC and put them into the input FIFO, as ··· 180 180 * Write characters directly to the DCC if we're on core 0 and the FIFO 181 181 * is empty, or write them to the FIFO if we're not. 182 182 */ 183 - static int hvc_dcc0_put_chars(u32 vt, const char *buf, int count) 183 + static ssize_t hvc_dcc0_put_chars(u32 vt, const u8 *buf, size_t count) 184 184 { 185 - int len; 186 185 unsigned long irqflags; 186 + ssize_t len; 187 187 188 188 if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP)) 189 189 return hvc_dcc_put_chars(vt, buf, count); ··· 219 219 * Read characters directly from the DCC if we're on core 0 and the FIFO 220 220 * is empty, or read them from the FIFO if we're not. 221 221 */ 222 - static int hvc_dcc0_get_chars(u32 vt, char *buf, int count) 222 + static ssize_t hvc_dcc0_get_chars(u32 vt, u8 *buf, size_t count) 223 223 { 224 - int len; 225 224 unsigned long irqflags; 225 + ssize_t len; 226 226 227 227 if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP)) 228 228 return hvc_dcc_get_chars(vt, buf, count);
+9 -9
drivers/tty/hvc/hvc_iucv.c
··· 215 215 * If the IUCV path has been severed, then -EPIPE is returned to cause a 216 216 * hang up (that is issued by the HVC layer). 217 217 */ 218 - static int hvc_iucv_write(struct hvc_iucv_private *priv, 219 - char *buf, int count, int *has_more_data) 218 + static ssize_t hvc_iucv_write(struct hvc_iucv_private *priv, 219 + u8 *buf, size_t count, int *has_more_data) 220 220 { 221 221 struct iucv_tty_buffer *rb; 222 - int written; 222 + ssize_t written; 223 223 int rc; 224 224 225 225 /* immediately return if there is no IUCV connection */ ··· 312 312 * the routine locks the struct hvc_iucv_private->lock to call 313 313 * helper functions. 314 314 */ 315 - static int hvc_iucv_get_chars(uint32_t vtermno, char *buf, int count) 315 + static ssize_t hvc_iucv_get_chars(uint32_t vtermno, u8 *buf, size_t count) 316 316 { 317 317 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); 318 - int written; 318 + ssize_t written; 319 319 int has_more_data; 320 320 321 321 if (count <= 0) ··· 352 352 * If an existing IUCV communicaton path has been severed, -EPIPE is returned 353 353 * (that can be passed to HVC layer to cause a tty hangup). 354 354 */ 355 - static int hvc_iucv_queue(struct hvc_iucv_private *priv, const char *buf, 356 - int count) 355 + static ssize_t hvc_iucv_queue(struct hvc_iucv_private *priv, const u8 *buf, 356 + size_t count) 357 357 { 358 358 size_t len; 359 359 ··· 455 455 * Locking: The method gets called under an irqsave() spinlock; and 456 456 * locks struct hvc_iucv_private->lock. 457 457 */ 458 - static int hvc_iucv_put_chars(uint32_t vtermno, const char *buf, int count) 458 + static ssize_t hvc_iucv_put_chars(uint32_t vtermno, const u8 *buf, size_t count) 459 459 { 460 460 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); 461 461 int queued; 462 462 463 - if (count <= 0) 463 + if (!count) 464 464 return 0; 465 465 466 466 if (!priv)
+3 -2
drivers/tty/hvc/hvc_opal.c
··· 58 58 .notifier_hangup = notifier_hangup_irq, 59 59 }; 60 60 61 - static int hvc_opal_hvsi_get_chars(uint32_t vtermno, char *buf, int count) 61 + static ssize_t hvc_opal_hvsi_get_chars(uint32_t vtermno, u8 *buf, size_t count) 62 62 { 63 63 struct hvc_opal_priv *pv = hvc_opal_privs[vtermno]; 64 64 ··· 68 68 return hvsilib_get_chars(&pv->hvsi, buf, count); 69 69 } 70 70 71 - static int hvc_opal_hvsi_put_chars(uint32_t vtermno, const char *buf, int count) 71 + static ssize_t hvc_opal_hvsi_put_chars(uint32_t vtermno, const u8 *buf, 72 + size_t count) 72 73 { 73 74 struct hvc_opal_priv *pv = hvc_opal_privs[vtermno]; 74 75
+5 -4
drivers/tty/hvc/hvc_riscv_sbi.c
··· 15 15 16 16 #include "hvc_console.h" 17 17 18 - static int hvc_sbi_tty_put(uint32_t vtermno, const char *buf, int count) 18 + static ssize_t hvc_sbi_tty_put(uint32_t vtermno, const u8 *buf, size_t count) 19 19 { 20 - int i; 20 + size_t i; 21 21 22 22 for (i = 0; i < count; i++) 23 23 sbi_console_putchar(buf[i]); ··· 25 25 return i; 26 26 } 27 27 28 - static int hvc_sbi_tty_get(uint32_t vtermno, char *buf, int count) 28 + static ssize_t hvc_sbi_tty_get(uint32_t vtermno, u8 *buf, size_t count) 29 29 { 30 - int i, c; 30 + size_t i; 31 + int c; 31 32 32 33 for (i = 0; i < count; i++) { 33 34 c = sbi_console_getchar();
+6 -5
drivers/tty/hvc/hvc_rtas.c
··· 31 31 static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE; 32 32 static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE; 33 33 34 - static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, 35 - int count) 34 + static ssize_t hvc_rtas_write_console(uint32_t vtermno, const u8 *buf, 35 + size_t count) 36 36 { 37 - int i; 37 + size_t i; 38 38 39 39 for (i = 0; i < count; i++) { 40 40 if (rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[i])) ··· 44 44 return i; 45 45 } 46 46 47 - static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count) 47 + static ssize_t hvc_rtas_read_console(uint32_t vtermno, u8 *buf, size_t count) 48 48 { 49 - int i, c; 49 + size_t i; 50 + int c; 50 51 51 52 for (i = 0; i < count; i++) { 52 53 if (rtas_call(rtascons_get_char_token, 0, 2, &c))
+5 -4
drivers/tty/hvc/hvc_udbg.c
··· 19 19 20 20 static struct hvc_struct *hvc_udbg_dev; 21 21 22 - static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count) 22 + static ssize_t hvc_udbg_put(uint32_t vtermno, const u8 *buf, size_t count) 23 23 { 24 - int i; 24 + size_t i; 25 25 26 26 for (i = 0; i < count && udbg_putc; i++) 27 27 udbg_putc(buf[i]); ··· 29 29 return i; 30 30 } 31 31 32 - static int hvc_udbg_get(uint32_t vtermno, char *buf, int count) 32 + static ssize_t hvc_udbg_get(uint32_t vtermno, u8 *buf, size_t count) 33 33 { 34 - int i, c; 34 + size_t i; 35 + int c; 35 36 36 37 if (!udbg_getc_poll) 37 38 return 0;
+10 -8
drivers/tty/hvc/hvc_vio.c
··· 58 58 hv_protocol_t proto; /* Raw data or HVSI packets */ 59 59 struct hvsi_priv hvsi; /* HVSI specific data */ 60 60 spinlock_t buf_lock; 61 - char buf[SIZE_VIO_GET_CHARS]; 62 - int left; 63 - int offset; 61 + u8 buf[SIZE_VIO_GET_CHARS]; 62 + size_t left; 63 + size_t offset; 64 64 }; 65 65 static struct hvterm_priv *hvterm_privs[MAX_NR_HVC_CONSOLES]; 66 66 /* For early boot console */ 67 67 static struct hvterm_priv hvterm_priv0; 68 68 69 - static int hvterm_raw_get_chars(uint32_t vtermno, char *buf, int count) 69 + static ssize_t hvterm_raw_get_chars(uint32_t vtermno, u8 *buf, size_t count) 70 70 { 71 71 struct hvterm_priv *pv = hvterm_privs[vtermno]; 72 72 unsigned long i; 73 73 unsigned long flags; 74 - int got; 74 + size_t got; 75 75 76 76 if (WARN_ON(!pv)) 77 77 return 0; ··· 115 115 * you are sending fewer chars. 116 116 * @count: number of chars to send. 117 117 */ 118 - static int hvterm_raw_put_chars(uint32_t vtermno, const char *buf, int count) 118 + static ssize_t hvterm_raw_put_chars(uint32_t vtermno, const u8 *buf, 119 + size_t count) 119 120 { 120 121 struct hvterm_priv *pv = hvterm_privs[vtermno]; 121 122 ··· 134 133 .notifier_hangup = notifier_hangup_irq, 135 134 }; 136 135 137 - static int hvterm_hvsi_get_chars(uint32_t vtermno, char *buf, int count) 136 + static ssize_t hvterm_hvsi_get_chars(uint32_t vtermno, u8 *buf, size_t count) 138 137 { 139 138 struct hvterm_priv *pv = hvterm_privs[vtermno]; 140 139 ··· 144 143 return hvsilib_get_chars(&pv->hvsi, buf, count); 145 144 } 146 145 147 - static int hvterm_hvsi_put_chars(uint32_t vtermno, const char *buf, int count) 146 + static ssize_t hvterm_hvsi_put_chars(uint32_t vtermno, const u8 *buf, 147 + size_t count) 148 148 { 149 149 struct hvterm_priv *pv = hvterm_privs[vtermno]; 150 150
+12 -11
drivers/tty/hvc/hvc_xen.c
··· 84 84 notify_remote_via_evtchn(cons->evtchn); 85 85 } 86 86 87 - static int __write_console(struct xencons_info *xencons, 88 - const char *data, int len) 87 + static ssize_t __write_console(struct xencons_info *xencons, 88 + const u8 *data, size_t len) 89 89 { 90 90 XENCONS_RING_IDX cons, prod; 91 91 struct xencons_interface *intf = xencons->intf; 92 - int sent = 0; 93 92 unsigned long flags; 93 + size_t sent = 0; 94 94 95 95 spin_lock_irqsave(&xencons->ring_lock, flags); 96 96 cons = intf->out_cons; ··· 115 115 return sent; 116 116 } 117 117 118 - static int domU_write_console(uint32_t vtermno, const char *data, int len) 118 + static ssize_t domU_write_console(uint32_t vtermno, const u8 *data, size_t len) 119 119 { 120 - int ret = len; 121 120 struct xencons_info *cons = vtermno_to_xencons(vtermno); 121 + size_t ret = len; 122 + 122 123 if (cons == NULL) 123 124 return -EINVAL; 124 125 ··· 130 129 * kernel is crippled. 131 130 */ 132 131 while (len) { 133 - int sent = __write_console(cons, data, len); 132 + ssize_t sent = __write_console(cons, data, len); 134 133 135 134 if (sent < 0) 136 135 return sent; ··· 145 144 return ret; 146 145 } 147 146 148 - static int domU_read_console(uint32_t vtermno, char *buf, int len) 147 + static ssize_t domU_read_console(uint32_t vtermno, u8 *buf, size_t len) 149 148 { 150 149 struct xencons_interface *intf; 151 150 XENCONS_RING_IDX cons, prod; 152 - int recv = 0; 153 151 struct xencons_info *xencons = vtermno_to_xencons(vtermno); 154 152 unsigned int eoiflag = 0; 155 153 unsigned long flags; 154 + size_t recv = 0; 156 155 157 156 if (xencons == NULL) 158 157 return -EINVAL; ··· 210 209 .notifier_hangup = notifier_hangup_irq, 211 210 }; 212 211 213 - static int dom0_read_console(uint32_t vtermno, char *buf, int len) 212 + static ssize_t dom0_read_console(uint32_t vtermno, u8 *buf, size_t len) 214 213 { 215 214 return HYPERVISOR_console_io(CONSOLEIO_read, len, buf); 216 215 } ··· 219 218 * Either for a dom0 to write to the system console, or a domU with a 220 219 * debug version of Xen 221 220 */ 222 - static int dom0_write_console(uint32_t vtermno, const char *str, int len) 221 + static ssize_t dom0_write_console(uint32_t vtermno, const u8 *str, size_t len) 223 222 { 224 - int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str); 223 + int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (u8 *)str); 225 224 if (rc < 0) 226 225 return rc; 227 226
+11 -9
drivers/tty/hvc/hvsi_lib.c
··· 12 12 packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno)); 13 13 14 14 /* Assumes that always succeeds, works in practice */ 15 - return pv->put_chars(pv->termno, (char *)packet, packet->len); 15 + return pv->put_chars(pv->termno, (u8 *)packet, packet->len); 16 16 } 17 17 18 18 static void hvsi_start_handshake(struct hvsi_priv *pv) ··· 178 178 return 0; 179 179 } 180 180 181 - int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count) 181 + ssize_t hvsilib_get_chars(struct hvsi_priv *pv, u8 *buf, size_t count) 182 182 { 183 - unsigned int tries, read = 0; 183 + unsigned int tries; 184 + size_t read = 0; 184 185 185 186 if (WARN_ON(!pv)) 186 187 return -ENXIO; ··· 200 199 for (tries = 1; count && tries < 2; tries++) { 201 200 /* Consume existing data packet */ 202 201 if (pv->inbuf_pktlen) { 203 - unsigned int l = min(count, (int)pv->inbuf_pktlen); 202 + size_t l = min(count, pv->inbuf_pktlen); 204 203 memcpy(&buf[read], &pv->inbuf[pv->inbuf_cur], l); 205 204 pv->inbuf_cur += l; 206 205 pv->inbuf_pktlen -= l; ··· 229 228 return read; 230 229 } 231 230 232 - int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count) 231 + ssize_t hvsilib_put_chars(struct hvsi_priv *pv, const u8 *buf, size_t count) 233 232 { 234 233 struct hvsi_data dp; 235 - int rc, adjcount = min(count, HVSI_MAX_OUTGOING_DATA); 234 + size_t adjcount = min_t(size_t, count, HVSI_MAX_OUTGOING_DATA); 235 + int rc; 236 236 237 237 if (WARN_ON(!pv)) 238 238 return -ENODEV; ··· 413 411 } 414 412 415 413 void hvsilib_init(struct hvsi_priv *pv, 416 - int (*get_chars)(uint32_t termno, char *buf, int count), 417 - int (*put_chars)(uint32_t termno, const char *buf, 418 - int count), 414 + ssize_t (*get_chars)(uint32_t termno, u8 *buf, size_t count), 415 + ssize_t (*put_chars)(uint32_t termno, const u8 *buf, 416 + size_t count), 419 417 int termno, int is_console) 420 418 { 421 419 memset(pv, 0, sizeof(*pv));