Re: [PATCH 05/15] serial: sc16is7xx: use guards for simple mutex locks

From: Hugo Villeneuve

Date: Mon Sep 29 2025 - 20:27:17 EST


Hi Jiri,

On Mon, 29 Sep 2025 08:09:12 +0200
Jiri Slaby <jirislaby@xxxxxxxxxx> wrote:

> On 24. 09. 25, 17:37, Hugo Villeneuve wrote:
> > --- a/drivers/tty/serial/sc16is7xx.c
> > +++ b/drivers/tty/serial/sc16is7xx.c
> ...
> > @@ -829,9 +827,6 @@ static bool sc16is7xx_port_irq(struct sc16is7xx_port *s, int portno)
> > break;
> > }
> >
> > -out_port_irq:
> > - mutex_unlock(&one->lock);
> > -
> > return rc;
>
> No need for rc now AFAICT.

You are right, I will remove it in v2.

>
> > }
> >
> > @@ -874,9 +869,8 @@ static void sc16is7xx_tx_proc(struct kthread_work *ws)
> > (port->rs485.delay_rts_before_send > 0))
> > msleep(port->rs485.delay_rts_before_send);
> >
> > - mutex_lock(&one->lock);
> > + guard(mutex)(&one->lock);
> > sc16is7xx_handle_tx(port);
> > - mutex_unlock(&one->lock);
> > }
> >
> > static void sc16is7xx_reconf_rs485(struct uart_port *port)
> > @@ -943,9 +937,8 @@ static void sc16is7xx_ms_proc(struct kthread_work *ws)
> > struct sc16is7xx_port *s = dev_get_drvdata(one->port.dev);
> >
> > if (one->port.state) {
> > - mutex_lock(&one->lock);
> > + guard(mutex)(&one->lock);
> > sc16is7xx_update_mlines(one);
> > - mutex_unlock(&one->lock);
> >
> > kthread_queue_delayed_work(&s->kworker, &one->ms_work, HZ);
>
> Now the lock is held till here. R U sure it is OK?

Now that you mention it, I am sure its not OK :)

I will restore this one to the original lock/unlock code in V2.

Thank you,
Hugo.