Skip to content

Commit 811b44b

Browse files
hvilleneuvedoogregkh
authored andcommitted
serial: sc16is7xx: use guards for simple mutex locks
[ Upstream commit 0f4f88b ] Guards can help to make the code more readable, so use them wherever they do so. In sc16is7xx_port_irq(), labels and 'rc' locals are eliminated completely. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Link: https://patch.msgid.link/20251027142957.1032073-6-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Stable-dep-of: 246ac11 ("serial: sc16is7xx: enable THRI before filling TX FIFO") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a289a78 commit 811b44b

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

drivers/tty/serial/sc16is7xx.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/bitops.h>
1212
#include <linux/bits.h>
13+
#include <linux/cleanup.h>
1314
#include <linux/clk.h>
1415
#include <linux/delay.h>
1516
#include <linux/device.h>
@@ -791,18 +792,15 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_one *one)
791792

792793
static bool sc16is7xx_port_irq(struct sc16is7xx_port *s, int portno)
793794
{
794-
bool rc = true;
795795
unsigned int iir, rxlen;
796796
struct uart_port *port = &s->p[portno].port;
797797
struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
798798

799-
mutex_lock(&one->lock);
799+
guard(mutex)(&one->lock);
800800

801801
iir = sc16is7xx_port_read(port, SC16IS7XX_IIR_REG);
802-
if (iir & SC16IS7XX_IIR_NO_INT_BIT) {
803-
rc = false;
804-
goto out_port_irq;
805-
}
802+
if (iir & SC16IS7XX_IIR_NO_INT_BIT)
803+
return false;
806804

807805
iir &= SC16IS7XX_IIR_ID_MASK;
808806

@@ -842,10 +840,7 @@ static bool sc16is7xx_port_irq(struct sc16is7xx_port *s, int portno)
842840
break;
843841
}
844842

845-
out_port_irq:
846-
mutex_unlock(&one->lock);
847-
848-
return rc;
843+
return true;
849844
}
850845

851846
static irqreturn_t sc16is7xx_irq(int irq, void *dev_id)
@@ -875,9 +870,8 @@ static void sc16is7xx_tx_proc(struct kthread_work *ws)
875870
(port->rs485.delay_rts_before_send > 0))
876871
msleep(port->rs485.delay_rts_before_send);
877872

878-
mutex_lock(&one->lock);
873+
guard(mutex)(&one->lock);
879874
sc16is7xx_handle_tx(port);
880-
mutex_unlock(&one->lock);
881875
}
882876

883877
static void sc16is7xx_reconf_rs485(struct uart_port *port)
@@ -944,9 +938,8 @@ static void sc16is7xx_ms_proc(struct kthread_work *ws)
944938
struct sc16is7xx_port *s = dev_get_drvdata(one->port.dev);
945939

946940
if (one->port.state) {
947-
mutex_lock(&one->lock);
948-
sc16is7xx_update_mlines(one);
949-
mutex_unlock(&one->lock);
941+
scoped_guard(mutex, &one->lock)
942+
sc16is7xx_update_mlines(one);
950943

951944
kthread_queue_delayed_work(&s->kworker, &one->ms_work, HZ);
952945
}

0 commit comments

Comments
 (0)