[08/10] tty/serial: Make ->dcd_change()+uart_handle_dcd_change() status bool

Message ID 20230104151531.73994-9-ilpo.jarvinen@linux.intel.com
State New
Headers
Series tty/serial: bool conversions and cleanups |

Commit Message

Ilpo Järvinen Jan. 4, 2023, 3:15 p.m. UTC
  Convert status parameter for ->dcd_change() and
uart_handle_dcd_change() to bool which matches to how the parameter is
used.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/pps/clients/pps-ldisc.c  | 2 +-
 drivers/tty/serial/serial_core.c | 4 ++--
 drivers/tty/serial/sunhv.c       | 8 ++++----
 drivers/usb/serial/generic.c     | 2 +-
 include/linux/serial_core.h      | 3 +--
 include/linux/tty_ldisc.h        | 4 ++--
 include/linux/usb/serial.h       | 2 +-
 7 files changed, 12 insertions(+), 13 deletions(-)
  

Comments

Jiri Slaby Jan. 5, 2023, 6:21 a.m. UTC | #1
On 04. 01. 23, 16:15, Ilpo Järvinen wrote:
> Convert status parameter for ->dcd_change() and
> uart_handle_dcd_change() to bool which matches to how the parameter is
> used.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -896,8 +896,7 @@ static inline bool uart_softcts_mode(struct uart_port *uport)
>    * The following are helper functions for the low level drivers.
>    */
>   
> -extern void uart_handle_dcd_change(struct uart_port *uport,
> -		unsigned int status);
> +extern void uart_handle_dcd_change(struct uart_port *uport, bool status);
>   extern void uart_handle_cts_change(struct uart_port *uport,
>   		unsigned int status);
Note to myself: huh, we still have some superfluous "extern"s in headers.

thanks,
  
Rodolfo Giometti Jan. 5, 2023, 9:11 a.m. UTC | #2
On 04/01/23 16:15, Ilpo Järvinen wrote:
> Convert status parameter for ->dcd_change() and
> uart_handle_dcd_change() to bool which matches to how the parameter is
> used.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>   drivers/pps/clients/pps-ldisc.c  | 2 +-

Acked-by: Rodolfo Giometti <giometti@enneenne.com>

>   drivers/tty/serial/serial_core.c | 4 ++--
>   drivers/tty/serial/sunhv.c       | 8 ++++----
>   drivers/usb/serial/generic.c     | 2 +-
>   include/linux/serial_core.h      | 3 +--
>   include/linux/tty_ldisc.h        | 4 ++--
>   include/linux/usb/serial.h       | 2 +-
>   7 files changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c
> index d73c4c2ed4e1..67aee758ac1d 100644
> --- a/drivers/pps/clients/pps-ldisc.c
> +++ b/drivers/pps/clients/pps-ldisc.c
> @@ -13,7 +13,7 @@
>   #include <linux/pps_kernel.h>
>   #include <linux/bug.h>
>   
> -static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status)
> +static void pps_tty_dcd_change(struct tty_struct *tty, bool status)
>   {
>   	struct pps_device *pps;
>   	struct pps_event_time ts;
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 07b4af10a7e9..76536c74e907 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -3250,11 +3250,11 @@ EXPORT_SYMBOL(uart_match_port);
>   /**
>    * uart_handle_dcd_change - handle a change of carrier detect state
>    * @uport: uart_port structure for the open port
> - * @status: new carrier detect status, nonzero if active
> + * @status: new carrier detect status, true if active
>    *
>    * Caller must hold uport->lock.
>    */
> -void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
> +void uart_handle_dcd_change(struct uart_port *uport, bool status)
>   {
>   	struct tty_port *port = &uport->state->port;
>   	struct tty_struct *tty = port->tty;
> diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c
> index 16c746a63258..7d38c33ef506 100644
> --- a/drivers/tty/serial/sunhv.c
> +++ b/drivers/tty/serial/sunhv.c
> @@ -87,10 +87,10 @@ static int receive_chars_getchar(struct uart_port *port)
>   
>   		if (c == CON_HUP) {
>   			hung_up = 1;
> -			uart_handle_dcd_change(port, 0);
> +			uart_handle_dcd_change(port, false);
>   		} else if (hung_up) {
>   			hung_up = 0;
> -			uart_handle_dcd_change(port, 1);
> +			uart_handle_dcd_change(port, true);
>   		}
>   
>   		if (port->state == NULL) {
> @@ -133,7 +133,7 @@ static int receive_chars_read(struct uart_port *port)
>   				bytes_read = 1;
>   			} else if (stat == CON_HUP) {
>   				hung_up = 1;
> -				uart_handle_dcd_change(port, 0);
> +				uart_handle_dcd_change(port, false);
>   				continue;
>   			} else {
>   				/* HV_EWOULDBLOCK, etc.  */
> @@ -143,7 +143,7 @@ static int receive_chars_read(struct uart_port *port)
>   
>   		if (hung_up) {
>   			hung_up = 0;
> -			uart_handle_dcd_change(port, 1);
> +			uart_handle_dcd_change(port, true);
>   		}
>   
>   		if (port->sysrq != 0 &&  *con_read_page) {
> diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
> index 15b6dee3a8e5..50016ee1026a 100644
> --- a/drivers/usb/serial/generic.c
> +++ b/drivers/usb/serial/generic.c
> @@ -608,7 +608,7 @@ EXPORT_SYMBOL_GPL(usb_serial_handle_break);
>    * @status: new carrier detect status, nonzero if active
>    */
>   void usb_serial_handle_dcd_change(struct usb_serial_port *port,
> -				struct tty_struct *tty, unsigned int status)
> +				struct tty_struct *tty, bool status)
>   {
>   	dev_dbg(&port->dev, "%s - status %d\n", __func__, status);
>   
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> index fd59f600094a..f1b69a36bb2b 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -896,8 +896,7 @@ static inline bool uart_softcts_mode(struct uart_port *uport)
>    * The following are helper functions for the low level drivers.
>    */
>   
> -extern void uart_handle_dcd_change(struct uart_port *uport,
> -		unsigned int status);
> +extern void uart_handle_dcd_change(struct uart_port *uport, bool status);
>   extern void uart_handle_cts_change(struct uart_port *uport,
>   		unsigned int status);
>   
> diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
> index dcb61ec11424..8f4a684973c9 100644
> --- a/include/linux/tty_ldisc.h
> +++ b/include/linux/tty_ldisc.h
> @@ -170,7 +170,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
>    *	send, please arise a tasklet or workqueue to do the real data transfer.
>    *	Do not send data in this hook, it may lead to a deadlock.
>    *
> - * @dcd_change: [DRV] ``void ()(struct tty_struct *tty, unsigned int status)``
> + * @dcd_change: [DRV] ``void ()(struct tty_struct *tty, bool status)``
>    *
>    *	Tells the discipline that the DCD pin has changed its status. Used
>    *	exclusively by the %N_PPS (Pulse-Per-Second) line discipline.
> @@ -238,7 +238,7 @@ struct tty_ldisc_ops {
>   	void	(*receive_buf)(struct tty_struct *tty, const unsigned char *cp,
>   			       const char *fp, int count);
>   	void	(*write_wakeup)(struct tty_struct *tty);
> -	void	(*dcd_change)(struct tty_struct *tty, unsigned int status);
> +	void	(*dcd_change)(struct tty_struct *tty, bool status);
>   	int	(*receive_buf2)(struct tty_struct *tty, const unsigned char *cp,
>   				const char *fp, int count);
>   	void	(*lookahead_buf)(struct tty_struct *tty, const unsigned char *cp,
> diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
> index c597357853d9..6fa608cb4d98 100644
> --- a/include/linux/usb/serial.h
> +++ b/include/linux/usb/serial.h
> @@ -372,7 +372,7 @@ static inline int usb_serial_handle_break(struct usb_serial_port *port)
>   #endif
>   
>   void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port,
> -		struct tty_struct *tty, unsigned int status);
> +				  struct tty_struct *tty, bool status);
>   
>   
>   int usb_serial_bus_register(struct usb_serial_driver *device);
  

Patch

diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c
index d73c4c2ed4e1..67aee758ac1d 100644
--- a/drivers/pps/clients/pps-ldisc.c
+++ b/drivers/pps/clients/pps-ldisc.c
@@ -13,7 +13,7 @@ 
 #include <linux/pps_kernel.h>
 #include <linux/bug.h>
 
-static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status)
+static void pps_tty_dcd_change(struct tty_struct *tty, bool status)
 {
 	struct pps_device *pps;
 	struct pps_event_time ts;
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 07b4af10a7e9..76536c74e907 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -3250,11 +3250,11 @@  EXPORT_SYMBOL(uart_match_port);
 /**
  * uart_handle_dcd_change - handle a change of carrier detect state
  * @uport: uart_port structure for the open port
- * @status: new carrier detect status, nonzero if active
+ * @status: new carrier detect status, true if active
  *
  * Caller must hold uport->lock.
  */
-void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
+void uart_handle_dcd_change(struct uart_port *uport, bool status)
 {
 	struct tty_port *port = &uport->state->port;
 	struct tty_struct *tty = port->tty;
diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c
index 16c746a63258..7d38c33ef506 100644
--- a/drivers/tty/serial/sunhv.c
+++ b/drivers/tty/serial/sunhv.c
@@ -87,10 +87,10 @@  static int receive_chars_getchar(struct uart_port *port)
 
 		if (c == CON_HUP) {
 			hung_up = 1;
-			uart_handle_dcd_change(port, 0);
+			uart_handle_dcd_change(port, false);
 		} else if (hung_up) {
 			hung_up = 0;
-			uart_handle_dcd_change(port, 1);
+			uart_handle_dcd_change(port, true);
 		}
 
 		if (port->state == NULL) {
@@ -133,7 +133,7 @@  static int receive_chars_read(struct uart_port *port)
 				bytes_read = 1;
 			} else if (stat == CON_HUP) {
 				hung_up = 1;
-				uart_handle_dcd_change(port, 0);
+				uart_handle_dcd_change(port, false);
 				continue;
 			} else {
 				/* HV_EWOULDBLOCK, etc.  */
@@ -143,7 +143,7 @@  static int receive_chars_read(struct uart_port *port)
 
 		if (hung_up) {
 			hung_up = 0;
-			uart_handle_dcd_change(port, 1);
+			uart_handle_dcd_change(port, true);
 		}
 
 		if (port->sysrq != 0 &&  *con_read_page) {
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 15b6dee3a8e5..50016ee1026a 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -608,7 +608,7 @@  EXPORT_SYMBOL_GPL(usb_serial_handle_break);
  * @status: new carrier detect status, nonzero if active
  */
 void usb_serial_handle_dcd_change(struct usb_serial_port *port,
-				struct tty_struct *tty, unsigned int status)
+				struct tty_struct *tty, bool status)
 {
 	dev_dbg(&port->dev, "%s - status %d\n", __func__, status);
 
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index fd59f600094a..f1b69a36bb2b 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -896,8 +896,7 @@  static inline bool uart_softcts_mode(struct uart_port *uport)
  * The following are helper functions for the low level drivers.
  */
 
-extern void uart_handle_dcd_change(struct uart_port *uport,
-		unsigned int status);
+extern void uart_handle_dcd_change(struct uart_port *uport, bool status);
 extern void uart_handle_cts_change(struct uart_port *uport,
 		unsigned int status);
 
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index dcb61ec11424..8f4a684973c9 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -170,7 +170,7 @@  int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
  *	send, please arise a tasklet or workqueue to do the real data transfer.
  *	Do not send data in this hook, it may lead to a deadlock.
  *
- * @dcd_change: [DRV] ``void ()(struct tty_struct *tty, unsigned int status)``
+ * @dcd_change: [DRV] ``void ()(struct tty_struct *tty, bool status)``
  *
  *	Tells the discipline that the DCD pin has changed its status. Used
  *	exclusively by the %N_PPS (Pulse-Per-Second) line discipline.
@@ -238,7 +238,7 @@  struct tty_ldisc_ops {
 	void	(*receive_buf)(struct tty_struct *tty, const unsigned char *cp,
 			       const char *fp, int count);
 	void	(*write_wakeup)(struct tty_struct *tty);
-	void	(*dcd_change)(struct tty_struct *tty, unsigned int status);
+	void	(*dcd_change)(struct tty_struct *tty, bool status);
 	int	(*receive_buf2)(struct tty_struct *tty, const unsigned char *cp,
 				const char *fp, int count);
 	void	(*lookahead_buf)(struct tty_struct *tty, const unsigned char *cp,
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index c597357853d9..6fa608cb4d98 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -372,7 +372,7 @@  static inline int usb_serial_handle_break(struct usb_serial_port *port)
 #endif
 
 void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port,
-		struct tty_struct *tty, unsigned int status);
+				  struct tty_struct *tty, bool status);
 
 
 int usb_serial_bus_register(struct usb_serial_driver *device);