Skip to content

Commit b0c3604

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 d11f15d commit b0c3604

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>
@@ -794,18 +795,15 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_one *one)
794795

795796
static bool sc16is7xx_port_irq(struct sc16is7xx_port *s, int portno)
796797
{
797-
bool rc = true;
798798
unsigned int iir, rxlen;
799799
struct uart_port *port = &s->p[portno].port;
800800
struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
801801

802-
mutex_lock(&one->lock);
802+
guard(mutex)(&one->lock);
803803

804804
iir = sc16is7xx_port_read(port, SC16IS7XX_IIR_REG);
805-
if (iir & SC16IS7XX_IIR_NO_INT_BIT) {
806-
rc = false;
807-
goto out_port_irq;
808-
}
805+
if (iir & SC16IS7XX_IIR_NO_INT_BIT)
806+
return false;
809807

810808
iir &= SC16IS7XX_IIR_ID_MASK;
811809

@@ -845,10 +843,7 @@ static bool sc16is7xx_port_irq(struct sc16is7xx_port *s, int portno)
845843
break;
846844
}
847845

848-
out_port_irq:
849-
mutex_unlock(&one->lock);
850-
851-
return rc;
846+
return true;
852847
}
853848

854849
static irqreturn_t sc16is7xx_irq(int irq, void *dev_id)
@@ -878,9 +873,8 @@ static void sc16is7xx_tx_proc(struct kthread_work *ws)
878873
(port->rs485.delay_rts_before_send > 0))
879874
msleep(port->rs485.delay_rts_before_send);
880875

881-
mutex_lock(&one->lock);
876+
guard(mutex)(&one->lock);
882877
sc16is7xx_handle_tx(port);
883-
mutex_unlock(&one->lock);
884878
}
885879

886880
static void sc16is7xx_reconf_rs485(struct uart_port *port)
@@ -947,9 +941,8 @@ static void sc16is7xx_ms_proc(struct kthread_work *ws)
947941
struct sc16is7xx_port *s = dev_get_drvdata(one->port.dev);
948942

949943
if (one->port.state) {
950-
mutex_lock(&one->lock);
951-
sc16is7xx_update_mlines(one);
952-
mutex_unlock(&one->lock);
944+
scoped_guard(mutex, &one->lock)
945+
sc16is7xx_update_mlines(one);
953946

954947
kthread_queue_delayed_work(&s->kworker, &one->ms_work, HZ);
955948
}

0 commit comments

Comments
 (0)