Commit f32fcbed authored by Jiri Slaby (SUSE)'s avatar Jiri Slaby (SUSE) Committed by Greg Kroah-Hartman

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: default avatar"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.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f3fb7367
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
* Vio firmware always attempts to fetch MAX_VIO_GET_CHARS chars. The 'count' * Vio firmware always attempts to fetch MAX_VIO_GET_CHARS chars. The 'count'
* parm is included to conform to put_chars() function pointer template * parm is included to conform to put_chars() function pointer template
*/ */
extern int hvc_get_chars(uint32_t vtermno, char *buf, int count); extern ssize_t hvc_get_chars(uint32_t vtermno, u8 *buf, size_t count);
extern int hvc_put_chars(uint32_t vtermno, const char *buf, int count); extern ssize_t hvc_put_chars(uint32_t vtermno, const u8 *buf, size_t count);
/* Provided by HVC VIO */ /* Provided by HVC VIO */
void hvc_vio_init_early(void); void hvc_vio_init_early(void);
......
...@@ -64,7 +64,7 @@ struct hvsi_priv { ...@@ -64,7 +64,7 @@ struct hvsi_priv {
unsigned int inbuf_len; /* data in input buffer */ unsigned int inbuf_len; /* data in input buffer */
unsigned char inbuf[HVSI_INBUF_SIZE]; unsigned char inbuf[HVSI_INBUF_SIZE];
unsigned int inbuf_cur; /* Cursor in input buffer */ unsigned int inbuf_cur; /* Cursor in input buffer */
unsigned int inbuf_pktlen; /* packet length from cursor */ size_t inbuf_pktlen; /* packet length from cursor */
atomic_t seqno; /* packet sequence number */ atomic_t seqno; /* packet sequence number */
unsigned int opened:1; /* driver opened */ unsigned int opened:1; /* driver opened */
unsigned int established:1; /* protocol established */ unsigned int established:1; /* protocol established */
...@@ -72,24 +72,26 @@ struct hvsi_priv { ...@@ -72,24 +72,26 @@ struct hvsi_priv {
unsigned int mctrl_update:1; /* modem control updated */ unsigned int mctrl_update:1; /* modem control updated */
unsigned short mctrl; /* modem control */ unsigned short mctrl; /* modem control */
struct tty_struct *tty; /* tty structure */ struct tty_struct *tty; /* tty structure */
int (*get_chars)(uint32_t termno, char *buf, int count); ssize_t (*get_chars)(uint32_t termno, u8 *buf, size_t count);
int (*put_chars)(uint32_t termno, const char *buf, int count); ssize_t (*put_chars)(uint32_t termno, const u8 *buf, size_t count);
uint32_t termno; uint32_t termno;
}; };
/* hvsi lib functions */ /* hvsi lib functions */
struct hvc_struct; struct hvc_struct;
extern void hvsilib_init(struct hvsi_priv *pv, extern void hvsilib_init(struct hvsi_priv *pv,
int (*get_chars)(uint32_t termno, char *buf, int count), ssize_t (*get_chars)(uint32_t termno, u8 *buf,
int (*put_chars)(uint32_t termno, const char *buf, size_t count),
int count), ssize_t (*put_chars)(uint32_t termno, const u8 *buf,
size_t count),
int termno, int is_console); int termno, int is_console);
extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp); extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp);
extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp); extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp);
extern int hvsilib_read_mctrl(struct hvsi_priv *pv); extern int hvsilib_read_mctrl(struct hvsi_priv *pv);
extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr); extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr);
extern void hvsilib_establish(struct hvsi_priv *pv); extern void hvsilib_establish(struct hvsi_priv *pv);
extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count); extern ssize_t hvsilib_get_chars(struct hvsi_priv *pv, u8 *buf, size_t count);
extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count); extern ssize_t hvsilib_put_chars(struct hvsi_priv *pv, const u8 *buf,
size_t count);
#endif /* _HVSI_H */ #endif /* _HVSI_H */
...@@ -313,9 +313,11 @@ extern int early_init_dt_scan_recoverable_ranges(unsigned long node, ...@@ -313,9 +313,11 @@ extern int early_init_dt_scan_recoverable_ranges(unsigned long node,
const char *uname, int depth, void *data); const char *uname, int depth, void *data);
void __init opal_configure_cores(void); void __init opal_configure_cores(void);
extern int opal_get_chars(uint32_t vtermno, char *buf, int count); extern ssize_t opal_get_chars(uint32_t vtermno, u8 *buf, size_t count);
extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len); extern ssize_t opal_put_chars(uint32_t vtermno, const u8 *buf,
extern int opal_put_chars_atomic(uint32_t vtermno, const char *buf, int total_len); size_t total_len);
extern ssize_t opal_put_chars_atomic(uint32_t vtermno, const u8 *buf,
size_t total_len);
extern int opal_flush_chars(uint32_t vtermno, bool wait); extern int opal_flush_chars(uint32_t vtermno, bool wait);
extern int opal_flush_console(uint32_t vtermno); extern int opal_flush_console(uint32_t vtermno);
......
...@@ -424,7 +424,7 @@ static int __init opal_message_init(struct device_node *opal_node) ...@@ -424,7 +424,7 @@ static int __init opal_message_init(struct device_node *opal_node)
return 0; return 0;
} }
int opal_get_chars(uint32_t vtermno, char *buf, int count) ssize_t opal_get_chars(uint32_t vtermno, u8 *buf, size_t count)
{ {
s64 rc; s64 rc;
__be64 evt, len; __be64 evt, len;
...@@ -441,10 +441,11 @@ int opal_get_chars(uint32_t vtermno, char *buf, int count) ...@@ -441,10 +441,11 @@ int opal_get_chars(uint32_t vtermno, char *buf, int count)
return 0; return 0;
} }
static int __opal_put_chars(uint32_t vtermno, const char *data, int total_len, bool atomic) static ssize_t __opal_put_chars(uint32_t vtermno, const u8 *data,
size_t total_len, bool atomic)
{ {
unsigned long flags = 0 /* shut up gcc */; unsigned long flags = 0 /* shut up gcc */;
int written; ssize_t written;
__be64 olen; __be64 olen;
s64 rc; s64 rc;
...@@ -484,7 +485,7 @@ static int __opal_put_chars(uint32_t vtermno, const char *data, int total_len, b ...@@ -484,7 +485,7 @@ static int __opal_put_chars(uint32_t vtermno, const char *data, int total_len, b
if (atomic) { if (atomic) {
/* Should not happen */ /* Should not happen */
pr_warn("atomic console write returned partial " pr_warn("atomic console write returned partial "
"len=%d written=%d\n", total_len, written); "len=%zu written=%zd\n", total_len, written);
} }
if (!written) if (!written)
written = -EAGAIN; written = -EAGAIN;
...@@ -497,7 +498,7 @@ static int __opal_put_chars(uint32_t vtermno, const char *data, int total_len, b ...@@ -497,7 +498,7 @@ static int __opal_put_chars(uint32_t vtermno, const char *data, int total_len, b
return written; return written;
} }
int opal_put_chars(uint32_t vtermno, const char *data, int total_len) ssize_t opal_put_chars(uint32_t vtermno, const u8 *data, size_t total_len)
{ {
return __opal_put_chars(vtermno, data, total_len, false); return __opal_put_chars(vtermno, data, total_len, false);
} }
...@@ -508,7 +509,8 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len) ...@@ -508,7 +509,8 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
* true at the moment because console space can race with OPAL's console * true at the moment because console space can race with OPAL's console
* writes. * writes.
*/ */
int opal_put_chars_atomic(uint32_t vtermno, const char *data, int total_len) ssize_t opal_put_chars_atomic(uint32_t vtermno, const u8 *data,
size_t total_len)
{ {
return __opal_put_chars(vtermno, data, total_len, true); return __opal_put_chars(vtermno, data, total_len, true);
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* firmware. * firmware.
* @count: not used? * @count: not used?
*/ */
int hvc_get_chars(uint32_t vtermno, char *buf, int count) ssize_t hvc_get_chars(uint32_t vtermno, u8 *buf, size_t count)
{ {
long ret; long ret;
unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
...@@ -52,7 +52,7 @@ EXPORT_SYMBOL(hvc_get_chars); ...@@ -52,7 +52,7 @@ EXPORT_SYMBOL(hvc_get_chars);
* firmware. Must be at least 16 bytes, even if count is less than 16. * firmware. Must be at least 16 bytes, even if count is less than 16.
* @count: Send this number of characters. * @count: Send this number of characters.
*/ */
int hvc_put_chars(uint32_t vtermno, const char *buf, int count) ssize_t hvc_put_chars(uint32_t vtermno, const u8 *buf, size_t count)
{ {
unsigned long *lbuf = (unsigned long *) buf; unsigned long *lbuf = (unsigned long *) buf;
long ret; long ret;
......
...@@ -650,7 +650,7 @@ static ssize_t __send_to_port(struct port *port, struct scatterlist *sg, ...@@ -650,7 +650,7 @@ static ssize_t __send_to_port(struct port *port, struct scatterlist *sg,
* Give out the data that's requested from the buffer that we have * Give out the data that's requested from the buffer that we have
* queued up. * queued up.
*/ */
static ssize_t fill_readbuf(struct port *port, char __user *out_buf, static ssize_t fill_readbuf(struct port *port, u8 __user *out_buf,
size_t out_count, bool to_user) size_t out_count, bool to_user)
{ {
struct port_buffer *buf; struct port_buffer *buf;
...@@ -669,7 +669,7 @@ static ssize_t fill_readbuf(struct port *port, char __user *out_buf, ...@@ -669,7 +669,7 @@ static ssize_t fill_readbuf(struct port *port, char __user *out_buf,
if (ret) if (ret)
return -EFAULT; return -EFAULT;
} else { } else {
memcpy((__force char *)out_buf, buf->buf + buf->offset, memcpy((__force u8 *)out_buf, buf->buf + buf->offset,
out_count); out_count);
} }
...@@ -1104,7 +1104,7 @@ static const struct file_operations port_fops = { ...@@ -1104,7 +1104,7 @@ static const struct file_operations port_fops = {
* it to finish: inefficient in theory, but in practice * it to finish: inefficient in theory, but in practice
* implementations will do it immediately. * implementations will do it immediately.
*/ */
static int put_chars(u32 vtermno, const char *buf, int count) static ssize_t put_chars(u32 vtermno, const u8 *buf, size_t count)
{ {
struct port *port; struct port *port;
struct scatterlist sg[1]; struct scatterlist sg[1];
...@@ -1132,7 +1132,7 @@ static int put_chars(u32 vtermno, const char *buf, int count) ...@@ -1132,7 +1132,7 @@ static int put_chars(u32 vtermno, const char *buf, int count)
* We call out to fill_readbuf that gets us the required data from the * We call out to fill_readbuf that gets us the required data from the
* buffers that are queued up. * buffers that are queued up.
*/ */
static int get_chars(u32 vtermno, char *buf, int count) static ssize_t get_chars(u32 vtermno, u8 *buf, size_t count)
{ {
struct port *port; struct port *port;
...@@ -1143,7 +1143,7 @@ static int get_chars(u32 vtermno, char *buf, int count) ...@@ -1143,7 +1143,7 @@ static int get_chars(u32 vtermno, char *buf, int count)
/* If we don't have an input queue yet, we can't get input. */ /* If we don't have an input queue yet, we can't get input. */
BUG_ON(!port->in_vq); BUG_ON(!port->in_vq);
return fill_readbuf(port, (__force char __user *)buf, count, false); return fill_readbuf(port, (__force u8 __user *)buf, count, false);
} }
static void resize_console(struct port *port) static void resize_console(struct port *port)
......
...@@ -52,8 +52,8 @@ struct hvc_struct { ...@@ -52,8 +52,8 @@ struct hvc_struct {
/* implemented by a low level driver */ /* implemented by a low level driver */
struct hv_ops { struct hv_ops {
int (*get_chars)(uint32_t vtermno, char *buf, int count); ssize_t (*get_chars)(uint32_t vtermno, u8 *buf, size_t count);
int (*put_chars)(uint32_t vtermno, const char *buf, int count); ssize_t (*put_chars)(uint32_t vtermno, const u8 *buf, size_t count);
int (*flush)(uint32_t vtermno, bool wait); int (*flush)(uint32_t vtermno, bool wait);
/* Callbacks for notification. Called in open, close and hangup */ /* Callbacks for notification. Called in open, close and hangup */
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
/* Lock to serialize access to DCC fifo */ /* Lock to serialize access to DCC fifo */
static DEFINE_SPINLOCK(dcc_lock); static DEFINE_SPINLOCK(dcc_lock);
static DEFINE_KFIFO(inbuf, unsigned char, DCC_INBUF_SIZE); static DEFINE_KFIFO(inbuf, u8, DCC_INBUF_SIZE);
static DEFINE_KFIFO(outbuf, unsigned char, DCC_OUTBUF_SIZE); static DEFINE_KFIFO(outbuf, u8, DCC_OUTBUF_SIZE);
static void dcc_uart_console_putchar(struct uart_port *port, unsigned char ch) static void dcc_uart_console_putchar(struct uart_port *port, u8 ch)
{ {
while (__dcc_getstatus() & DCC_STATUS_TX) while (__dcc_getstatus() & DCC_STATUS_TX)
cpu_relax(); cpu_relax();
...@@ -62,9 +62,9 @@ static int __init dcc_early_console_setup(struct earlycon_device *device, ...@@ -62,9 +62,9 @@ static int __init dcc_early_console_setup(struct earlycon_device *device,
EARLYCON_DECLARE(dcc, dcc_early_console_setup); EARLYCON_DECLARE(dcc, dcc_early_console_setup);
static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count) static ssize_t hvc_dcc_put_chars(uint32_t vt, const u8 *buf, size_t count)
{ {
int i; size_t i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
while (__dcc_getstatus() & DCC_STATUS_TX) while (__dcc_getstatus() & DCC_STATUS_TX)
...@@ -76,9 +76,9 @@ static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count) ...@@ -76,9 +76,9 @@ static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count)
return count; return count;
} }
static int hvc_dcc_get_chars(uint32_t vt, char *buf, int count) static ssize_t hvc_dcc_get_chars(uint32_t vt, u8 *buf, size_t count)
{ {
int i; size_t i;
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
if (__dcc_getstatus() & DCC_STATUS_RX) if (__dcc_getstatus() & DCC_STATUS_RX)
...@@ -157,8 +157,8 @@ static DECLARE_WORK(dcc_pwork, dcc_put_work); ...@@ -157,8 +157,8 @@ static DECLARE_WORK(dcc_pwork, dcc_put_work);
*/ */
static void dcc_get_work(struct work_struct *work) static void dcc_get_work(struct work_struct *work)
{ {
unsigned char ch;
unsigned long irqflags; unsigned long irqflags;
u8 ch;
/* /*
* Read characters from DCC and put them into the input FIFO, as * Read characters from DCC and put them into the input FIFO, as
...@@ -180,10 +180,10 @@ static DECLARE_WORK(dcc_gwork, dcc_get_work); ...@@ -180,10 +180,10 @@ static DECLARE_WORK(dcc_gwork, dcc_get_work);
* Write characters directly to the DCC if we're on core 0 and the FIFO * Write characters directly to the DCC if we're on core 0 and the FIFO
* is empty, or write them to the FIFO if we're not. * is empty, or write them to the FIFO if we're not.
*/ */
static int hvc_dcc0_put_chars(u32 vt, const char *buf, int count) static ssize_t hvc_dcc0_put_chars(u32 vt, const u8 *buf, size_t count)
{ {
int len;
unsigned long irqflags; unsigned long irqflags;
ssize_t len;
if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP)) if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP))
return hvc_dcc_put_chars(vt, buf, count); return hvc_dcc_put_chars(vt, buf, count);
...@@ -219,10 +219,10 @@ static int hvc_dcc0_put_chars(u32 vt, const char *buf, int count) ...@@ -219,10 +219,10 @@ static int hvc_dcc0_put_chars(u32 vt, const char *buf, int count)
* Read characters directly from the DCC if we're on core 0 and the FIFO * Read characters directly from the DCC if we're on core 0 and the FIFO
* is empty, or read them from the FIFO if we're not. * is empty, or read them from the FIFO if we're not.
*/ */
static int hvc_dcc0_get_chars(u32 vt, char *buf, int count) static ssize_t hvc_dcc0_get_chars(u32 vt, u8 *buf, size_t count)
{ {
int len;
unsigned long irqflags; unsigned long irqflags;
ssize_t len;
if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP)) if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP))
return hvc_dcc_get_chars(vt, buf, count); return hvc_dcc_get_chars(vt, buf, count);
......
...@@ -215,11 +215,11 @@ static void destroy_tty_buffer_list(struct list_head *list) ...@@ -215,11 +215,11 @@ static void destroy_tty_buffer_list(struct list_head *list)
* If the IUCV path has been severed, then -EPIPE is returned to cause a * If the IUCV path has been severed, then -EPIPE is returned to cause a
* hang up (that is issued by the HVC layer). * hang up (that is issued by the HVC layer).
*/ */
static int hvc_iucv_write(struct hvc_iucv_private *priv, static ssize_t hvc_iucv_write(struct hvc_iucv_private *priv,
char *buf, int count, int *has_more_data) u8 *buf, size_t count, int *has_more_data)
{ {
struct iucv_tty_buffer *rb; struct iucv_tty_buffer *rb;
int written; ssize_t written;
int rc; int rc;
/* immediately return if there is no IUCV connection */ /* immediately return if there is no IUCV connection */
...@@ -312,10 +312,10 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv, ...@@ -312,10 +312,10 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv,
* the routine locks the struct hvc_iucv_private->lock to call * the routine locks the struct hvc_iucv_private->lock to call
* helper functions. * helper functions.
*/ */
static int hvc_iucv_get_chars(uint32_t vtermno, char *buf, int count) static ssize_t hvc_iucv_get_chars(uint32_t vtermno, u8 *buf, size_t count)
{ {
struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno);
int written; ssize_t written;
int has_more_data; int has_more_data;
if (count <= 0) if (count <= 0)
...@@ -352,8 +352,8 @@ static int hvc_iucv_get_chars(uint32_t vtermno, char *buf, int count) ...@@ -352,8 +352,8 @@ static int hvc_iucv_get_chars(uint32_t vtermno, char *buf, int count)
* If an existing IUCV communicaton path has been severed, -EPIPE is returned * If an existing IUCV communicaton path has been severed, -EPIPE is returned
* (that can be passed to HVC layer to cause a tty hangup). * (that can be passed to HVC layer to cause a tty hangup).
*/ */
static int hvc_iucv_queue(struct hvc_iucv_private *priv, const char *buf, static ssize_t hvc_iucv_queue(struct hvc_iucv_private *priv, const u8 *buf,
int count) size_t count)
{ {
size_t len; size_t len;
...@@ -455,12 +455,12 @@ static void hvc_iucv_sndbuf_work(struct work_struct *work) ...@@ -455,12 +455,12 @@ static void hvc_iucv_sndbuf_work(struct work_struct *work)
* Locking: The method gets called under an irqsave() spinlock; and * Locking: The method gets called under an irqsave() spinlock; and
* locks struct hvc_iucv_private->lock. * locks struct hvc_iucv_private->lock.
*/ */
static int hvc_iucv_put_chars(uint32_t vtermno, const char *buf, int count) static ssize_t hvc_iucv_put_chars(uint32_t vtermno, const u8 *buf, size_t count)
{ {
struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno);
int queued; int queued;
if (count <= 0) if (!count)
return 0; return 0;
if (!priv) if (!priv)
......
...@@ -58,7 +58,7 @@ static const struct hv_ops hvc_opal_raw_ops = { ...@@ -58,7 +58,7 @@ static const struct hv_ops hvc_opal_raw_ops = {
.notifier_hangup = notifier_hangup_irq, .notifier_hangup = notifier_hangup_irq,
}; };
static int hvc_opal_hvsi_get_chars(uint32_t vtermno, char *buf, int count) static ssize_t hvc_opal_hvsi_get_chars(uint32_t vtermno, u8 *buf, size_t count)
{ {
struct hvc_opal_priv *pv = hvc_opal_privs[vtermno]; struct hvc_opal_priv *pv = hvc_opal_privs[vtermno];
...@@ -68,7 +68,8 @@ static int hvc_opal_hvsi_get_chars(uint32_t vtermno, char *buf, int count) ...@@ -68,7 +68,8 @@ static int hvc_opal_hvsi_get_chars(uint32_t vtermno, char *buf, int count)
return hvsilib_get_chars(&pv->hvsi, buf, count); return hvsilib_get_chars(&pv->hvsi, buf, count);
} }
static int hvc_opal_hvsi_put_chars(uint32_t vtermno, const char *buf, int count) static ssize_t hvc_opal_hvsi_put_chars(uint32_t vtermno, const u8 *buf,
size_t count)
{ {
struct hvc_opal_priv *pv = hvc_opal_privs[vtermno]; struct hvc_opal_priv *pv = hvc_opal_privs[vtermno];
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
#include "hvc_console.h" #include "hvc_console.h"
static int hvc_sbi_tty_put(uint32_t vtermno, const char *buf, int count) static ssize_t hvc_sbi_tty_put(uint32_t vtermno, const u8 *buf, size_t count)
{ {
int i; size_t i;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
sbi_console_putchar(buf[i]); sbi_console_putchar(buf[i]);
...@@ -25,9 +25,10 @@ static int hvc_sbi_tty_put(uint32_t vtermno, const char *buf, int count) ...@@ -25,9 +25,10 @@ static int hvc_sbi_tty_put(uint32_t vtermno, const char *buf, int count)
return i; return i;
} }
static int hvc_sbi_tty_get(uint32_t vtermno, char *buf, int count) static ssize_t hvc_sbi_tty_get(uint32_t vtermno, u8 *buf, size_t count)
{ {
int i, c; size_t i;
int c;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
c = sbi_console_getchar(); c = sbi_console_getchar();
......
...@@ -31,10 +31,10 @@ static struct hvc_struct *hvc_rtas_dev; ...@@ -31,10 +31,10 @@ static struct hvc_struct *hvc_rtas_dev;
static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE; static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE;
static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE; static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE;
static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, static ssize_t hvc_rtas_write_console(uint32_t vtermno, const u8 *buf,
int count) size_t count)
{ {
int i; size_t i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[i])) if (rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[i]))
...@@ -44,9 +44,10 @@ static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, ...@@ -44,9 +44,10 @@ static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf,
return i; return i;
} }
static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count) static ssize_t hvc_rtas_read_console(uint32_t vtermno, u8 *buf, size_t count)
{ {
int i, c; size_t i;
int c;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (rtas_call(rtascons_get_char_token, 0, 2, &c)) if (rtas_call(rtascons_get_char_token, 0, 2, &c))
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
static struct hvc_struct *hvc_udbg_dev; static struct hvc_struct *hvc_udbg_dev;
static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count) static ssize_t hvc_udbg_put(uint32_t vtermno, const u8 *buf, size_t count)
{ {
int i; size_t i;
for (i = 0; i < count && udbg_putc; i++) for (i = 0; i < count && udbg_putc; i++)
udbg_putc(buf[i]); udbg_putc(buf[i]);
...@@ -29,9 +29,10 @@ static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count) ...@@ -29,9 +29,10 @@ static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count)
return i; return i;
} }
static int hvc_udbg_get(uint32_t vtermno, char *buf, int count) static ssize_t hvc_udbg_get(uint32_t vtermno, u8 *buf, size_t count)
{ {
int i, c; size_t i;
int c;
if (!udbg_getc_poll) if (!udbg_getc_poll)
return 0; return 0;
......
...@@ -58,20 +58,20 @@ struct hvterm_priv { ...@@ -58,20 +58,20 @@ struct hvterm_priv {
hv_protocol_t proto; /* Raw data or HVSI packets */ hv_protocol_t proto; /* Raw data or HVSI packets */
struct hvsi_priv hvsi; /* HVSI specific data */ struct hvsi_priv hvsi; /* HVSI specific data */
spinlock_t buf_lock; spinlock_t buf_lock;
char buf[SIZE_VIO_GET_CHARS]; u8 buf[SIZE_VIO_GET_CHARS];
int left; size_t left;
int offset; size_t offset;
}; };
static struct hvterm_priv *hvterm_privs[MAX_NR_HVC_CONSOLES]; static struct hvterm_priv *hvterm_privs[MAX_NR_HVC_CONSOLES];
/* For early boot console */ /* For early boot console */
static struct hvterm_priv hvterm_priv0; static struct hvterm_priv hvterm_priv0;
static int hvterm_raw_get_chars(uint32_t vtermno, char *buf, int count) static ssize_t hvterm_raw_get_chars(uint32_t vtermno, u8 *buf, size_t count)
{ {
struct hvterm_priv *pv = hvterm_privs[vtermno]; struct hvterm_priv *pv = hvterm_privs[vtermno];
unsigned long i; unsigned long i;
unsigned long flags; unsigned long flags;
int got; size_t got;
if (WARN_ON(!pv)) if (WARN_ON(!pv))
return 0; return 0;
...@@ -115,7 +115,8 @@ static int hvterm_raw_get_chars(uint32_t vtermno, char *buf, int count) ...@@ -115,7 +115,8 @@ static int hvterm_raw_get_chars(uint32_t vtermno, char *buf, int count)
* you are sending fewer chars. * you are sending fewer chars.
* @count: number of chars to send. * @count: number of chars to send.
*/ */
static int hvterm_raw_put_chars(uint32_t vtermno, const char *buf, int count) static ssize_t hvterm_raw_put_chars(uint32_t vtermno, const u8 *buf,
size_t count)
{ {
struct hvterm_priv *pv = hvterm_privs[vtermno]; struct hvterm_priv *pv = hvterm_privs[vtermno];
...@@ -133,7 +134,7 @@ static const struct hv_ops hvterm_raw_ops = { ...@@ -133,7 +134,7 @@ static const struct hv_ops hvterm_raw_ops = {
.notifier_hangup = notifier_hangup_irq, .notifier_hangup = notifier_hangup_irq,
}; };
static int hvterm_hvsi_get_chars(uint32_t vtermno, char *buf, int count) static ssize_t hvterm_hvsi_get_chars(uint32_t vtermno, u8 *buf, size_t count)
{ {
struct hvterm_priv *pv = hvterm_privs[vtermno]; struct hvterm_priv *pv = hvterm_privs[vtermno];
...@@ -143,7 +144,8 @@ static int hvterm_hvsi_get_chars(uint32_t vtermno, char *buf, int count) ...@@ -143,7 +144,8 @@ static int hvterm_hvsi_get_chars(uint32_t vtermno, char *buf, int count)
return hvsilib_get_chars(&pv->hvsi, buf, count); return hvsilib_get_chars(&pv->hvsi, buf, count);
} }
static int hvterm_hvsi_put_chars(uint32_t vtermno, const char *buf, int count) static ssize_t hvterm_hvsi_put_chars(uint32_t vtermno, const u8 *buf,
size_t count)
{ {
struct hvterm_priv *pv = hvterm_privs[vtermno]; struct hvterm_priv *pv = hvterm_privs[vtermno];
......
...@@ -84,13 +84,13 @@ static inline void notify_daemon(struct xencons_info *cons) ...@@ -84,13 +84,13 @@ static inline void notify_daemon(struct xencons_info *cons)
notify_remote_via_evtchn(cons->evtchn); notify_remote_via_evtchn(cons->evtchn);
} }
static int __write_console(struct xencons_info *xencons, static ssize_t __write_console(struct xencons_info *xencons,
const char *data, int len) const u8 *data, size_t len)
{ {
XENCONS_RING_IDX cons, prod; XENCONS_RING_IDX cons, prod;
struct xencons_interface *intf = xencons->intf; struct xencons_interface *intf = xencons->intf;
int sent = 0;
unsigned long flags; unsigned long flags;
size_t sent = 0;
spin_lock_irqsave(&xencons->ring_lock, flags); spin_lock_irqsave(&xencons->ring_lock, flags);
cons = intf->out_cons; cons = intf->out_cons;
...@@ -115,10 +115,11 @@ static int __write_console(struct xencons_info *xencons, ...@@ -115,10 +115,11 @@ static int __write_console(struct xencons_info *xencons,
return sent; return sent;
} }
static int domU_write_console(uint32_t vtermno, const char *data, int len) static ssize_t domU_write_console(uint32_t vtermno, const u8 *data, size_t len)
{ {
int ret = len;
struct xencons_info *cons = vtermno_to_xencons(vtermno); struct xencons_info *cons = vtermno_to_xencons(vtermno);
size_t ret = len;
if (cons == NULL) if (cons == NULL)
return -EINVAL; return -EINVAL;
...@@ -129,7 +130,7 @@ static int domU_write_console(uint32_t vtermno, const char *data, int len) ...@@ -129,7 +130,7 @@ static int domU_write_console(uint32_t vtermno, const char *data, int len)
* kernel is crippled. * kernel is crippled.
*/ */
while (len) { while (len) {
int sent = __write_console(cons, data, len); ssize_t sent = __write_console(cons, data, len);
if (sent < 0) if (sent < 0)
return sent; return sent;
...@@ -144,14 +145,14 @@ static int domU_write_console(uint32_t vtermno, const char *data, int len) ...@@ -144,14 +145,14 @@ static int domU_write_console(uint32_t vtermno, const char *data, int len)
return ret; return ret;
} }
static int domU_read_console(uint32_t vtermno, char *buf, int len) static ssize_t domU_read_console(uint32_t vtermno, u8 *buf, size_t len)
{ {
struct xencons_interface *intf; struct xencons_interface *intf;
XENCONS_RING_IDX cons, prod; XENCONS_RING_IDX cons, prod;
int recv = 0;
struct xencons_info *xencons = vtermno_to_xencons(vtermno); struct xencons_info *xencons = vtermno_to_xencons(vtermno);
unsigned int eoiflag = 0; unsigned int eoiflag = 0;
unsigned long flags; unsigned long flags;
size_t recv = 0;
if (xencons == NULL) if (xencons == NULL)
return -EINVAL; return -EINVAL;
...@@ -209,7 +210,7 @@ static const struct hv_ops domU_hvc_ops = { ...@@ -209,7 +210,7 @@ static const struct hv_ops domU_hvc_ops = {
.notifier_hangup = notifier_hangup_irq, .notifier_hangup = notifier_hangup_irq,
}; };
static int dom0_read_console(uint32_t vtermno, char *buf, int len) static ssize_t dom0_read_console(uint32_t vtermno, u8 *buf, size_t len)
{ {
return HYPERVISOR_console_io(CONSOLEIO_read, len, buf); return HYPERVISOR_console_io(CONSOLEIO_read, len, buf);
} }
...@@ -218,9 +219,9 @@ static int dom0_read_console(uint32_t vtermno, char *buf, int len) ...@@ -218,9 +219,9 @@ static int dom0_read_console(uint32_t vtermno, char *buf, int len)
* Either for a dom0 to write to the system console, or a domU with a * Either for a dom0 to write to the system console, or a domU with a
* debug version of Xen * debug version of Xen
*/ */
static int dom0_write_console(uint32_t vtermno, const char *str, int len) static ssize_t dom0_write_console(uint32_t vtermno, const u8 *str, size_t len)
{ {
int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str); int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (u8 *)str);
if (rc < 0) if (rc < 0)
return rc; return rc;
......
...@@ -12,7 +12,7 @@ static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet) ...@@ -12,7 +12,7 @@ static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno)); packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno));
/* Assumes that always succeeds, works in practice */ /* Assumes that always succeeds, works in practice */
return pv->put_chars(pv->termno, (char *)packet, packet->len); return pv->put_chars(pv->termno, (u8 *)packet, packet->len);
} }
static void hvsi_start_handshake(struct hvsi_priv *pv) static void hvsi_start_handshake(struct hvsi_priv *pv)
...@@ -178,9 +178,10 @@ static int hvsi_get_packet(struct hvsi_priv *pv) ...@@ -178,9 +178,10 @@ static int hvsi_get_packet(struct hvsi_priv *pv)
return 0; return 0;
} }
int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count) ssize_t hvsilib_get_chars(struct hvsi_priv *pv, u8 *buf, size_t count)
{ {
unsigned int tries, read = 0; unsigned int tries;
size_t read = 0;
if (WARN_ON(!pv)) if (WARN_ON(!pv))
return -ENXIO; return -ENXIO;
...@@ -199,7 +200,7 @@ int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count) ...@@ -199,7 +200,7 @@ int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count)
for (tries = 1; count && tries < 2; tries++) { for (tries = 1; count && tries < 2; tries++) {
/* Consume existing data packet */ /* Consume existing data packet */
if (pv->inbuf_pktlen) { if (pv->inbuf_pktlen) {
unsigned int l = min(count, (int)pv->inbuf_pktlen); size_t l = min(count, pv->inbuf_pktlen);
memcpy(&buf[read], &pv->inbuf[pv->inbuf_cur], l); memcpy(&buf[read], &pv->inbuf[pv->inbuf_cur], l);
pv->inbuf_cur += l; pv->inbuf_cur += l;
pv->inbuf_pktlen -= l; pv->inbuf_pktlen -= l;
...@@ -228,10 +229,11 @@ int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count) ...@@ -228,10 +229,11 @@ int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count)
return read; return read;
} }
int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count) ssize_t hvsilib_put_chars(struct hvsi_priv *pv, const u8 *buf, size_t count)
{ {
struct hvsi_data dp; struct hvsi_data dp;
int rc, adjcount = min(count, HVSI_MAX_OUTGOING_DATA); size_t adjcount = min_t(size_t, count, HVSI_MAX_OUTGOING_DATA);
int rc;
if (WARN_ON(!pv)) if (WARN_ON(!pv))
return -ENODEV; return -ENODEV;
...@@ -411,9 +413,9 @@ void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp) ...@@ -411,9 +413,9 @@ void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp)
} }
void hvsilib_init(struct hvsi_priv *pv, void hvsilib_init(struct hvsi_priv *pv,
int (*get_chars)(uint32_t termno, char *buf, int count), ssize_t (*get_chars)(uint32_t termno, u8 *buf, size_t count),
int (*put_chars)(uint32_t termno, const char *buf, ssize_t (*put_chars)(uint32_t termno, const u8 *buf,
int count), size_t count),
int termno, int is_console) int termno, int is_console)
{ {
memset(pv, 0, sizeof(*pv)); memset(pv, 0, sizeof(*pv));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment