[PATCH 10/36] tty: make counts in tty_port_client_operations hooks size_t

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The counts in tty_port_client_operations hooks' are currently
represented by all 'int', 'unsigned int', and 'size_t'. Unify them all
to unsigned 'size_t' for clarity. Note that size_t is used already in
tty_buffer.c. So, eventually, it is spread for counts everywhere and
this is the beginning.

So the two changes namely:
* ::receive_buf() is called from tty_ldisc_receive_buf(). And that
  expects values ">= 0" from ::receive_buf(), so switch its rettype to
  size_t is fine. tty_ldisc_receive_buf() types will be changed
  separately.
* ::lookahead_buf()'s count comes from lookahead_bufs() and is already
  'unsigned int'.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@xxxxxxxxxx>
Cc: Rob Herring <robh@xxxxxxxxxx>
---
 drivers/tty/serdev/serdev-ttyport.c |  4 ++--
 drivers/tty/tty_port.c              | 11 +++++------
 include/linux/tty_port.h            |  6 +++---
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index f69ae27838e3..e3856814ce77 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -22,8 +22,8 @@ struct serport {
  * Callback functions from the tty port.
  */
 
-static int ttyport_receive_buf(struct tty_port *port, const u8 *cp,
-				const u8 *fp, size_t count)
+static size_t ttyport_receive_buf(struct tty_port *port, const u8 *cp,
+				  const u8 *fp, size_t count)
 {
 	struct serdev_controller *ctrl = port->client_data;
 	struct serport *serport = serdev_controller_get_drvdata(ctrl);
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 6bf58980c81d..7fd171b7c844 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -20,10 +20,9 @@
 #include <linux/serdev.h>
 #include "tty.h"
 
-static int tty_port_default_receive_buf(struct tty_port *port, const u8 *p,
-					const u8 *f, size_t count)
+static size_t tty_port_default_receive_buf(struct tty_port *port, const u8 *p,
+					   const u8 *f, size_t count)
 {
-	int ret;
 	struct tty_struct *tty;
 	struct tty_ldisc *ld;
 
@@ -35,15 +34,15 @@ static int tty_port_default_receive_buf(struct tty_port *port, const u8 *p,
 	if (!ld)
 		return 0;
 
-	ret = tty_ldisc_receive_buf(ld, p, (char *)f, count);
+	count = tty_ldisc_receive_buf(ld, p, (char *)f, count);
 
 	tty_ldisc_deref(ld);
 
-	return ret;
+	return count;
 }
 
 static void tty_port_default_lookahead_buf(struct tty_port *port, const u8 *p,
-					   const u8 *f, unsigned int count)
+					   const u8 *f, size_t count)
 {
 	struct tty_struct *tty;
 	struct tty_ldisc *ld;
diff --git a/include/linux/tty_port.h b/include/linux/tty_port.h
index 726575743367..6b367eb17979 100644
--- a/include/linux/tty_port.h
+++ b/include/linux/tty_port.h
@@ -39,10 +39,10 @@ struct tty_port_operations {
 };
 
 struct tty_port_client_operations {
-	int (*receive_buf)(struct tty_port *port, const u8 *cp, const u8 *fp,
-			   size_t count);
+	size_t (*receive_buf)(struct tty_port *port, const u8 *cp, const u8 *fp,
+			      size_t count);
 	void (*lookahead_buf)(struct tty_port *port, const u8 *cp,
-			      const u8 *fp, unsigned int count);
+			      const u8 *fp, size_t count);
 	void (*write_wakeup)(struct tty_port *port);
 };
 
-- 
2.41.0




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux