From nobody Tue Feb 10 16:18:24 2026 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 953F819C569; Thu, 2 Oct 2025 14:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417078; cv=none; b=Y9blT0Z0zwmBxvbuB7DDo/wwXzyw1D+oy8ZwwEwyNo1C3Rrx4C+eerftN19BdIuIpYscGGZqzPZx2oRMKGxZcyB85+SyD9uGWo8RhPzUk1V3kzkZTGfTuNZahCf18XHPtGqPWwYTDPmL6u9dLqfhAC84c1ovayJQfj5JIRaO1sY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417078; c=relaxed/simple; bh=1DAS4rdhFoWP3g/phk9RE5Jk9RdcoTqceCOsHOSwo1E=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=Q9Xn7Z/WMAetmZtRiZoCFjljmsR59pjX/XKILZ445Uw8qZS0jJ8vAt6q+j55oMifkLin4l2dh+m6XxVHUtBtiWMpj3DPuV8C5u6cxENnTmKXGUttaHo0d6RA7n3Gf1nTIn+aTw/XXICoox1Gqr6Csfej+pOMVlTqiIX7IfNUyY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=Gn439t0t; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="Gn439t0t" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=jfX0u/k11WtqaDvYGV08FTUGbESdLYPWBkzZWH4ORMg=; b=Gn439t0teeDF3xfKK20Ddysc9X 2txvG2i2QZgFM/6QPPNPX78lXyGZhnwiWMdRpQlxyo72u/ckmv6W1J5XfGQrZWEsg8mZr+/vSMRcM m/ISNueOQx2AyGDGPykko7Hq8wc6LVr1wwDDSLTINNTczKMhA3WiX5usgzJHxXrEsp2A=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:59004 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1v4Kke-0005hy-Re; Thu, 02 Oct 2025 10:57:49 -0400 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org, fvallee@eukrea.fr Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com, Hugo Villeneuve Date: Thu, 2 Oct 2025 10:57:29 -0400 Message-Id: <20251002145738.3250272-7-hugo@hugovil.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251002145738.3250272-1-hugo@hugovil.com> References: <20251002145738.3250272-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Subject: [PATCH v2 06/15] serial: sc16is7xx: use guards for simple mutex locks X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Content-Type: text/plain; charset="utf-8" From: Hugo Villeneuve 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 --- Based on patch by Jiri Slaby (SUSE) : commit("serial: use guards for simple mutex locks") --- drivers/tty/serial/sc16is7xx.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 335695d0e7aa7..1acf5be03d489 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -11,6 +11,7 @@ #define DEFAULT_SYMBOL_NAMESPACE "SERIAL_NXP_SC16IS7XX" =20 #include +#include #include #include #include @@ -778,18 +779,15 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_= one *one) =20 static bool sc16is7xx_port_irq(struct sc16is7xx_port *s, int portno) { - bool rc =3D true; unsigned int iir, rxlen; struct uart_port *port =3D &s->p[portno].port; struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); =20 - mutex_lock(&one->lock); + guard(mutex)(&one->lock); =20 iir =3D sc16is7xx_port_read(port, SC16IS7XX_IIR_REG); - if (iir & SC16IS7XX_IIR_NO_INT_BIT) { - rc =3D false; - goto out_port_irq; - } + if (iir & SC16IS7XX_IIR_NO_INT_BIT) + return false; =20 iir &=3D SC16IS7XX_IIR_ID_MASK; =20 @@ -829,10 +827,7 @@ static bool sc16is7xx_port_irq(struct sc16is7xx_port *= s, int portno) break; } =20 -out_port_irq: - mutex_unlock(&one->lock); - - return rc; + return true; } =20 static irqreturn_t sc16is7xx_irq(int irq, void *dev_id) @@ -873,9 +868,8 @@ static void sc16is7xx_tx_proc(struct kthread_work *ws) (port->rs485.delay_rts_before_send > 0)) msleep(port->rs485.delay_rts_before_send); =20 - mutex_lock(&one->lock); + guard(mutex)(&one->lock); sc16is7xx_handle_tx(port); - mutex_unlock(&one->lock); } =20 static void sc16is7xx_reconf_rs485(struct uart_port *port) @@ -942,9 +936,8 @@ static void sc16is7xx_ms_proc(struct kthread_work *ws) struct sc16is7xx_port *s =3D dev_get_drvdata(one->port.dev); =20 if (one->port.state) { - mutex_lock(&one->lock); - sc16is7xx_update_mlines(one); - mutex_unlock(&one->lock); + scoped_guard(mutex, &one->lock) + sc16is7xx_update_mlines(one); =20 kthread_queue_delayed_work(&s->kworker, &one->ms_work, HZ); } --=20 2.39.5