[09/10] serial: Make uart_handle_cts_change() status param bool
Commit Message
Convert uart_handle_cts_change() to bool which is more appropriate
than unsigned int.
Cleanup callsites from operations that are not necessary with bool.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/tty/serial/imx.c | 2 +-
drivers/tty/serial/max3100.c | 2 +-
drivers/tty/serial/max310x.c | 3 +--
drivers/tty/serial/serial_core.c | 4 ++--
include/linux/serial_core.h | 3 +--
5 files changed, 6 insertions(+), 8 deletions(-)
Comments
On 04. 01. 23, 16:15, Ilpo Järvinen wrote:
> Convert uart_handle_cts_change() to bool which is more appropriate
> than unsigned int.
>
> Cleanup callsites from operations that are not necessary with bool.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
...
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -3285,11 +3285,11 @@ EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
> /**
> * uart_handle_cts_change - handle a change of clear-to-send state
> * @uport: uart_port structure for the open port
> - * @status: new clear to send status, nonzero if active
> + * @status: new clear to send status, true if active
ANyone else having troubles to parse "new clear to send status"?
> *
> * Caller must hold uport->lock.
> */
> -void uart_handle_cts_change(struct uart_port *uport, unsigned int status)
> +void uart_handle_cts_change(struct uart_port *uport, bool status)
This should be "bool active" then.
thanks,
On Thu, 5 Jan 2023, Jiri Slaby wrote:
> On 04. 01. 23, 16:15, Ilpo Järvinen wrote:
> > Convert uart_handle_cts_change() to bool which is more appropriate
> > than unsigned int.
> >
> > Cleanup callsites from operations that are not necessary with bool.
> >
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ...
> > --- a/drivers/tty/serial/serial_core.c
> > +++ b/drivers/tty/serial/serial_core.c
> > @@ -3285,11 +3285,11 @@ EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
> > /**
> > * uart_handle_cts_change - handle a change of clear-to-send state
> > * @uport: uart_port structure for the open port
> > - * @status: new clear to send status, nonzero if active
> > + * @status: new clear to send status, true if active
>
> ANyone else having troubles to parse "new clear to send status"?
I could change that into new clear-to-send status while at it.
> > *
> > * Caller must hold uport->lock.
> > */
> > -void uart_handle_cts_change(struct uart_port *uport, unsigned int status)
> > +void uart_handle_cts_change(struct uart_port *uport, bool status)
>
> This should be "bool active" then.
Yeah. I'll change in the previous patch too which also had "status".
On Thu, Jan 05, 2023 at 07:23:49AM +0100, Jiri Slaby wrote:
> On 04. 01. 23, 16:15, Ilpo Järvinen wrote:
> > Convert uart_handle_cts_change() to bool which is more appropriate
> > than unsigned int.
> >
> > Cleanup callsites from operations that are not necessary with bool.
> >
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ...
> > --- a/drivers/tty/serial/serial_core.c
> > +++ b/drivers/tty/serial/serial_core.c
> > @@ -3285,11 +3285,11 @@ EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
> > /**
> > * uart_handle_cts_change - handle a change of clear-to-send state
> > * @uport: uart_port structure for the open port
> > - * @status: new clear to send status, nonzero if active
> > + * @status: new clear to send status, true if active
>
> ANyone else having troubles to parse "new clear to send status"?
Yeah, adding the missing hyphens should improve things:
new clear-to-send status, true if active
Johan
@@ -771,7 +771,7 @@ static irqreturn_t __imx_uart_rtsint(int irq, void *dev_id)
imx_uart_writel(sport, USR1_RTSD, USR1);
usr1 = imx_uart_readl(sport, USR1) & USR1_RTSS;
- uart_handle_cts_change(&sport->port, !!usr1);
+ uart_handle_cts_change(&sport->port, usr1);
wake_up_interruptible(&sport->port.state->port.delta_msr_wait);
return IRQ_HANDLED;
@@ -247,7 +247,7 @@ static int max3100_handlerx(struct max3100_port *s, u16 rx)
cts = (rx & MAX3100_CTS) > 0;
if (s->cts != cts) {
s->cts = cts;
- uart_handle_cts_change(&s->port, cts ? TIOCM_CTS : 0);
+ uart_handle_cts_change(&s->port, cts);
}
return ret;
@@ -819,8 +819,7 @@ static irqreturn_t max310x_port_irq(struct max310x_port *s, int portno)
if (ists & MAX310X_IRQ_CTS_BIT) {
lsr = max310x_port_read(port, MAX310X_LSR_IRQSTS_REG);
- uart_handle_cts_change(port,
- !!(lsr & MAX310X_LSR_CTS_BIT));
+ uart_handle_cts_change(port, lsr & MAX310X_LSR_CTS_BIT);
}
if (rxlen)
max310x_handle_rx(port, rxlen);
@@ -3285,11 +3285,11 @@ EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
/**
* uart_handle_cts_change - handle a change of clear-to-send state
* @uport: uart_port structure for the open port
- * @status: new clear to send status, nonzero if active
+ * @status: new clear to send status, true if active
*
* Caller must hold uport->lock.
*/
-void uart_handle_cts_change(struct uart_port *uport, unsigned int status)
+void uart_handle_cts_change(struct uart_port *uport, bool status)
{
lockdep_assert_held_once(&uport->lock);
@@ -897,8 +897,7 @@ static inline bool uart_softcts_mode(struct uart_port *uport)
*/
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);
+extern void uart_handle_cts_change(struct uart_port *uport, bool status);
extern void uart_insert_char(struct uart_port *port, unsigned int status,
unsigned int overrun, unsigned int ch, unsigned int flag);