Re: [PATCH 07/10] tty: Convert ->dtr_rts() to take bool argument

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

 



On Thu, 5 Jan 2023, Jiri Slaby wrote:

> On 04. 01. 23, 16:15, Ilpo Järvinen wrote:
> > Convert the raise/on parameter in ->dtr_rts() to bool through the
> > callchain. The parameter is used like bool. In USB serial, there
> > remains a few implicit bool -> larger type conversions because some
> > devices use u8 in their control messages.
> 
> Reviewed-by: Jiri Slaby <jirislaby@xxxxxxxxxx>
> 
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
> > ---
> ...
> > --- a/drivers/char/pcmcia/synclink_cs.c
> > +++ b/drivers/char/pcmcia/synclink_cs.c
> > @@ -378,7 +378,7 @@ static void async_mode(MGSLPC_INFO *info);
> >   static void tx_timeout(struct timer_list *t);
> >     static bool carrier_raised(struct tty_port *port);
> > -static void dtr_rts(struct tty_port *port, int onoff);
> > +static void dtr_rts(struct tty_port *port, bool onoff);
> 
> Not anything for this patch, but having this dubbed "onoff" instead of "on"
> makes it really confusing.
> 
> > --- a/drivers/mmc/core/sdio_uart.c
> > +++ b/drivers/mmc/core/sdio_uart.c
> > @@ -548,14 +548,14 @@ static bool uart_carrier_raised(struct tty_port
> > *tport)
> >    *	adjusted during an open, close and hangup.
> >    */
> >   -static void uart_dtr_rts(struct tty_port *tport, int onoff)
> > +static void uart_dtr_rts(struct tty_port *tport, bool onoff)
> >   {
> >   	struct sdio_uart_port *port =
> >   			container_of(tport, struct sdio_uart_port, port);
> >   	int ret = sdio_uart_claim_func(port);
> >   	if (ret)
> >   		return;
> > -	if (onoff == 0)
> > +	if (!onoff)
> >   		sdio_uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
> >   	else
> >   		sdio_uart_set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
> 
> Especially here. What does "!onoff" mean? If it were:
> 
> if (on)
>   sdio_uart_set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
> else
>   sdio_uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
> 
> it would be a lot more clear.
> 
> > --- a/drivers/tty/amiserial.c
> > +++ b/drivers/tty/amiserial.c
> > @@ -1459,7 +1459,7 @@ static bool amiga_carrier_raised(struct tty_port
> > *port)
> >   	return !(ciab.pra & SER_DCD);
> >   }
> >   -static void amiga_dtr_rts(struct tty_port *port, int raise)
> > +static void amiga_dtr_rts(struct tty_port *port, bool raise)
> 
> Or "raise". That makes sense too and we call it as such in
> tty_port_operations:
> 
> > --- a/include/linux/tty_port.h
> > +++ b/include/linux/tty_port.h
> ...
> > @@ -32,7 +32,7 @@ struct tty_struct;
> >    */
> >   struct tty_port_operations {
> >   	bool (*carrier_raised)(struct tty_port *port);
> > -	void (*dtr_rts)(struct tty_port *port, int raise);
> > +	void (*dtr_rts)(struct tty_port *port, bool raise);
> >   	void (*shutdown)(struct tty_port *port);
> >   	int (*activate)(struct tty_port *port, struct tty_struct *tty);
> >   	void (*destruct)(struct tty_port *port);
> 
> Care to fix that up too?

Sure. I noticed they were inconsistent but it didn't feel like changing 
the name "while at it" would be good as this is long already. I think I'll 
make another patch out of the name changes.

-- 
 i.

[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux