From nobody Mon Feb 9 09:29:29 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 1B151136672; Thu, 2 Oct 2025 14:57:51 +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=1759417075; cv=none; b=cavegfSEEVs1NJ4swayNgBNPXSonqZfLrAK47LjObgu/lyIpRxvMODTaa147MczSWQO8iaQJtEPNWywCaWURF1ItimUxWRt/IMeBel6QUnIDwle8wBfPgVUnfyLSSTXyJIKjYZkTkkqXz5PtlE53Ymr9kUXvfg5cMkZRz08KQqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417075; c=relaxed/simple; bh=VQ4K3mbYDF7RCOQuQTRrICrxJ9EawHCBs0QoYZtZhZ4=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=l23HLUoHbN1CYIDPPldPRHw0DkqnzK86dzcyCnibfkw2nv2Pd6iBOuOjpnw59p1/efqSMTbxcBjyXcl8otRkMsVy5Qssfsh/ud9nYONDP15sbC1Hz247jZcdEyll+BOJTX9faCq/dtBLs0nTqgRg6MhqibQaQ9VDIk+XymI7hrw= 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=fSc1wIwq; 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="fSc1wIwq" 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=SI53DqfwOlhDf1zYe8DxLPZIvnq90SSUoK0E9Zs7Q4Q=; b=fSc1wIwq+o5jyGGbbESjVbCpU1 vwZOnPXI8EbFn6dREzwVLnMjN7si4m6Xdym9SoMFyE16eLaRkkujQVznq99TBMOFF7Fh7ZzIzrqci ikPkc+Wj67UCsFxnwZ29lsj8jORnj8xuVWyWN0FHMuc0bpWsPXl6AXKzDWZHqoLGqBas=; 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 1v4Kka-0005hy-I9; Thu, 02 Oct 2025 10:57:44 -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 , stable@vger.kernel.org Date: Thu, 2 Oct 2025 10:57:24 -0400 Message-Id: <20251002145738.3250272-2-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 01/15] serial: sc16is7xx: remove useless enable of enhanced features 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 Commit 43c51bb573aa ("sc16is7xx: make sure device is in suspend once probed") permanently enabled access to the enhanced features in sc16is7xx_probe(), and it is never disabled after that. Therefore, remove useless re-enable of enhanced features in sc16is7xx_set_baud(). Fixes: 43c51bb573aa ("sc16is7xx: make sure device is in suspend once probed= ") Cc: stable@vger.kernel.org Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 1a2c4c14f6aac..c7435595dce13 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -588,13 +588,6 @@ static int sc16is7xx_set_baud(struct uart_port *port, = int baud) div /=3D prescaler; } =20 - /* Enable enhanced features */ - sc16is7xx_efr_lock(port); - sc16is7xx_port_update(port, SC16IS7XX_EFR_REG, - SC16IS7XX_EFR_ENABLE_BIT, - SC16IS7XX_EFR_ENABLE_BIT); - sc16is7xx_efr_unlock(port); - /* If bit MCR_CLKSEL is set, the divide by 4 prescaler is activated. */ sc16is7xx_port_update(port, SC16IS7XX_MCR_REG, SC16IS7XX_MCR_CLKSEL_BIT, --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 0DAAB13A258; Thu, 2 Oct 2025 14:57:52 +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=1759417074; cv=none; b=qrNVqKcvQTN999t/UEd9OW0DunkYf4FpbnMrgmjLXcUPRBxFUVvK13jbvveS8yAccJipGRaAt79vjvvlXyTQUGW7h011NHxX3SvAMFUf1olItcMLf/mQhzVCed4sdyUfh3BP6qGaKtQL5CKmSiUEVqkwroDOAquxCPsu7kZE5CA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417074; c=relaxed/simple; bh=vRBGm9s/dyL+mafpUYppZ1yooY3Npezr9ZaoASLiS50=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=DDVu5cV7hv0+7CBjxJG4fvdNrwEzMZ3NgqRCuwS1YfIh21ubGy5yL9MKvzwNkfs+I8v4ldCC8WvqmgbtlV4YAEQM6v6Zso9gUpTuYOrK3j5vjj7Swxu/9895d2L0EpQedrdrT2uRSkxGJoJghd5y978N4HCptjyrA0lxMLU9q2k= 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=rAp8Vl3v; 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="rAp8Vl3v" 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=9stedbZ0oenGDNSu79soTv0x9oOzbagK1AmdZRDf5wY=; b=rAp8Vl3vkbH8pXu1cym0w3R8YF PWNFu9eWzudoR6aP8Fjq03vtqrd0obprnGGfTtRjt/3b0xGGvKY49qPfdHJQCS/+FIG8d7Xa3Xv3U rxWeUqx7g82vv2GexZebCp8383EvFJRXddK26YdSUXWc7kJ3vcXWB9jNmZ0Zt7hb8Iqg=; 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 1v4Kkb-0005hy-Au; Thu, 02 Oct 2025 10:57:45 -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:25 -0400 Message-Id: <20251002145738.3250272-3-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 02/15] serial: sc16is7xx: rename LCR macros to better reflect usage 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 There is no reference to CONF_MODE_A or CONF_MODE_B in the manufacturer's datasheet. Rename register set configuration macros for the LCR register, to better show their intended usage to select either the Special register set, or the Enhanced register set. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index c7435595dce13..330d95446f1d7 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -149,10 +149,12 @@ #define SC16IS7XX_LCR_WORD_LEN_6 (0x01) #define SC16IS7XX_LCR_WORD_LEN_7 (0x02) #define SC16IS7XX_LCR_WORD_LEN_8 (0x03) -#define SC16IS7XX_LCR_CONF_MODE_A SC16IS7XX_LCR_DLAB_BIT /* Special - * reg set */ -#define SC16IS7XX_LCR_CONF_MODE_B 0xBF /* Enhanced - * reg set */ +#define SC16IS7XX_LCR_REG_SET_SPECIAL SC16IS7XX_LCR_DLAB_BIT /* Special + * reg set + */ +#define SC16IS7XX_LCR_REG_SET_ENHANCED 0xBF /* Enhanced + * reg set + */ =20 /* MCR register bits */ #define SC16IS7XX_MCR_DTR_BIT BIT(0) /* DTR complement @@ -442,7 +444,7 @@ static void sc16is7xx_efr_lock(struct uart_port *port) one->old_lcr =3D sc16is7xx_port_read(port, SC16IS7XX_LCR_REG); =20 /* Enable access to Enhanced register set */ - sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_CONF_MODE_B); + sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_REG_SET_ENHAN= CED); =20 /* Disable cache updates when writing to EFR registers */ regcache_cache_bypass(one->regmap, true); @@ -598,7 +600,7 @@ static int sc16is7xx_set_baud(struct uart_port *port, i= nt baud) /* Backup LCR and access special register set (DLL/DLH) */ lcr =3D sc16is7xx_port_read(port, SC16IS7XX_LCR_REG); sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, - SC16IS7XX_LCR_CONF_MODE_A); + SC16IS7XX_LCR_REG_SET_SPECIAL); =20 /* Write the new divisor */ regcache_cache_bypass(one->regmap, true); @@ -1650,7 +1652,7 @@ int sc16is7xx_probe(struct device *dev, const struct = sc16is7xx_devtype *devtype, =20 /* Enable EFR */ sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG, - SC16IS7XX_LCR_CONF_MODE_B); + SC16IS7XX_LCR_REG_SET_ENHANCED); =20 regcache_cache_bypass(regmaps[i], true); =20 --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 374D01547C9; Thu, 2 Oct 2025 14:57:54 +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=1759417077; cv=none; b=nSO1bzdPk1HvkXkUHElLxbBzZbvFCOaA4O5VLkwBDj+JHSTBIMq0IWZuhtRYngIe0z7XxZji9a7CflVPhQtIkeQYcTwBDtUDCgoaRsIvO48Z3vTJlXu3Rk9q+L44axD/VNG56/dBjK7NaJqH9Em7Fon5PlWyBBsg0xxgAQxl470= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417077; c=relaxed/simple; bh=3GSup+pKaTPRC904bUvLbtEi8OPatrZ73gmCrwgiD90=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=S6t5MQha2Nk5VqMWehcxInVlZHBvTCs7AsPqOT4cD+6tzSpt5uZO/5Blb1iS1RPPfuVZ5DU4lJZlzSoT/iEhWkv4lWIjnT8H0BbYgXxlnNFpvDyIcmuDNhsJWdA1bmSJU/yqx2zr9wISiQDoQ8QjBzMVrYcZBu8LBM4Sl8N/St8= 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=ZqjFypt2; 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="ZqjFypt2" 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=aJMlqD2Q484a3VTqtujlReqh/fkDfF327hDpwcyhVMY=; b=ZqjFypt2l+FX4KimcHsTYE6LLG Z+BvDnbshc23I+OgLPeFMEAVmetubama215LKXY++OKvHvgB611DnuihUswbEljYyw+PzpjnpdGv/ LTatPwCfHzvPtR6LhAdEKIRblYuNGMgxdfe83UArq/cY+kUtYjtzwiJSnwf6B4nDu8Uc=; 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 1v4Kkc-0005hy-40; Thu, 02 Oct 2025 10:57:46 -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:26 -0400 Message-Id: <20251002145738.3250272-4-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 03/15] serial: sc16is7xx: rename EFR mutex with generic name 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 This mutex is used as a lock when accessing registers that share the same address space, not necessarily EFR registers. For example, address 0x06 is shared by MSR, TCR and XOFF1 registers, independently of EFR. Rename the mutex with a more generic name to avoid misinterpreting its usage. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 330d95446f1d7..26b34f23ed5fe 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -330,7 +330,7 @@ struct sc16is7xx_one_config { struct sc16is7xx_one { struct uart_port port; struct regmap *regmap; - struct mutex efr_lock; /* EFR registers access */ + struct mutex lock; /* For registers sharing same address space. */ struct kthread_work tx_work; struct kthread_work reg_work; struct kthread_delayed_work ms_work; @@ -438,7 +438,7 @@ static void sc16is7xx_efr_lock(struct uart_port *port) { struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); =20 - mutex_lock(&one->efr_lock); + mutex_lock(&one->lock); =20 /* Backup content of LCR. */ one->old_lcr =3D sc16is7xx_port_read(port, SC16IS7XX_LCR_REG); @@ -460,7 +460,7 @@ static void sc16is7xx_efr_unlock(struct uart_port *port) /* Restore original content of LCR */ sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, one->old_lcr); =20 - mutex_unlock(&one->efr_lock); + mutex_unlock(&one->lock); } =20 static void sc16is7xx_ier_clear(struct uart_port *port, u8 bit) @@ -595,7 +595,7 @@ static int sc16is7xx_set_baud(struct uart_port *port, i= nt baud) SC16IS7XX_MCR_CLKSEL_BIT, prescaler =3D=3D 1 ? 0 : SC16IS7XX_MCR_CLKSEL_BIT); =20 - mutex_lock(&one->efr_lock); + mutex_lock(&one->lock); =20 /* Backup LCR and access special register set (DLL/DLH) */ lcr =3D sc16is7xx_port_read(port, SC16IS7XX_LCR_REG); @@ -611,7 +611,7 @@ static int sc16is7xx_set_baud(struct uart_port *port, i= nt baud) /* Restore LCR and access to general register set */ sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, lcr); =20 - mutex_unlock(&one->efr_lock); + mutex_unlock(&one->lock); =20 return DIV_ROUND_CLOSEST((clk / prescaler) / 16, div); } @@ -758,7 +758,7 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_on= e *one) unsigned long flags; unsigned int status, changed; =20 - lockdep_assert_held_once(&one->efr_lock); + lockdep_assert_held_once(&one->lock); =20 status =3D sc16is7xx_get_hwmctrl(port); changed =3D status ^ one->old_mctrl; @@ -789,7 +789,7 @@ static bool sc16is7xx_port_irq(struct sc16is7xx_port *s= , int portno) struct uart_port *port =3D &s->p[portno].port; struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); =20 - mutex_lock(&one->efr_lock); + mutex_lock(&one->lock); =20 iir =3D sc16is7xx_port_read(port, SC16IS7XX_IIR_REG); if (iir & SC16IS7XX_IIR_NO_INT_BIT) { @@ -836,7 +836,7 @@ static bool sc16is7xx_port_irq(struct sc16is7xx_port *s= , int portno) } =20 out_port_irq: - mutex_unlock(&one->efr_lock); + mutex_unlock(&one->lock); =20 return rc; } @@ -880,9 +880,9 @@ 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->efr_lock); + mutex_lock(&one->lock); sc16is7xx_handle_tx(port); - mutex_unlock(&one->efr_lock); + mutex_unlock(&one->lock); } =20 static void sc16is7xx_reconf_rs485(struct uart_port *port) @@ -949,9 +949,9 @@ 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->efr_lock); + mutex_lock(&one->lock); sc16is7xx_update_mlines(one); - mutex_unlock(&one->efr_lock); + mutex_unlock(&one->lock); =20 kthread_queue_delayed_work(&s->kworker, &one->ms_work, HZ); } @@ -1625,7 +1625,7 @@ int sc16is7xx_probe(struct device *dev, const struct = sc16is7xx_devtype *devtype, s->p[i].old_mctrl =3D 0; s->p[i].regmap =3D regmaps[i]; =20 - mutex_init(&s->p[i].efr_lock); + mutex_init(&s->p[i].lock); =20 ret =3D uart_get_rs485_mode(&s->p[i].port); if (ret) --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 BB7421624E9; Thu, 2 Oct 2025 14:57:54 +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=1759417076; cv=none; b=gKiuPGaNA9FYxGmwIVXvSd/qwa02zeVyyftYIkuv7aDjIWqU6FuBaxv5GdKOHixbiTOcx/MUpQCn8wDws80YxH0hXjQ705eD8UgqCUheIQwjgBoMxBcPqlaTtYtRtYXeHBKFNfaAYgWMjsVaUxYUcPrN8hjQdEhq7efVaKZ9CdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417076; c=relaxed/simple; bh=7Ha/GqIua9/ChaOBE549z8GD/x5rObpIWEV80xKeEI8=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=S6GPuKhe+zJN9g1hhrR0vwfhnLcE5k2uPXNWzNqeW+tNMMdfB8VjkVPvGR+BTHmH9qCUXw5Nn6Ca26rR3JpPDMnE4d/A0vRH18+Bj+8HZ39yexdR/APYvdDeDLdv175sjdxCFYM2ozposc/5FXyu4ueJeAcKoGc8thEsnJ55B7Q= 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=ZEOi5mGH; 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="ZEOi5mGH" 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=8jMeiYcJ4IAwPEnHXSKqmQcGOw+ff5KoMj+tTxq4440=; b=ZEOi5mGHPHWadPrMAMlMSPqskK d7iGGS6R3HH0CWujRix+6kDxV+hvspBsku9ntalNEQ4Y/337E0comc9RlfPQDPjZDzW6ZgfxEEa4r wrnBWDJV+7PmQihau9W3iUVpnAG/sdQhvwXbDYY5D0y79NkJqwnLOcFHWjgRf7s4eSU0=; 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 1v4Kkd-0005hy-0c; Thu, 02 Oct 2025 10:57:47 -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:27 -0400 Message-Id: <20251002145738.3250272-5-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 04/15] serial: sc16is7xx: define common register access function 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 Rename lock/unlock functions to make it more generic and applicable to both the Enhanced register set and the Special register set. Use this new generic function when accessing the Special register set in sc16is7xx_set_baud(), and when accessing the Enhanced register set in sc16is7xx_set_termios() and sc16is7xx_probe(). This helps readability and also avoid to make future mistakes when accessing these obfuscated registers. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 74 ++++++++++++++-------------------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 26b34f23ed5fe..72e4c4f80f7f5 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -421,20 +421,24 @@ static void sc16is7xx_power(struct uart_port *port, i= nt on) } =20 /* - * In an amazing feat of design, the Enhanced Features Register (EFR) - * shares the address of the Interrupt Identification Register (IIR). - * Access to EFR is switched on by writing a magic value (0xbf) to the - * Line Control Register (LCR). Any interrupt firing during this time will - * see the EFR where it expects the IIR to be, leading to + * In an amazing feat of design, the enhanced register set shares the + * addresses 0x02 and 0x04-0x07 with the general register set. + * The special register set also shares the addresses 0x00-0x01 with the + * general register set. + * + * Access to the enhanced or special register set is enabled by writing a = magic + * value to the Line Control Register (LCR). When enhanced register set ac= cess + * is enabled, for example, any interrupt firing during this time will see= the + * EFR where it expects the IIR to be, leading to * "Unexpected interrupt" messages. * - * Prevent this possibility by claiming a mutex while accessing the EFR, - * and claiming the same mutex from within the interrupt handler. This is - * similar to disabling the interrupt, but that doesn't work because the - * bulk of the interrupt processing is run as a workqueue job in thread - * context. + * Prevent this possibility by claiming a mutex when access to the enhanced + * or special register set is enabled, and claiming the same mutex from wi= thin + * the interrupt handler. This is similar to disabling the interrupt, but = that + * doesn't work because the bulk of the interrupt processing is run as a + * workqueue job in thread context. */ -static void sc16is7xx_efr_lock(struct uart_port *port) +static void sc16is7xx_regs_lock(struct uart_port *port, u8 register_set) { struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); =20 @@ -443,18 +447,18 @@ static void sc16is7xx_efr_lock(struct uart_port *port) /* Backup content of LCR. */ one->old_lcr =3D sc16is7xx_port_read(port, SC16IS7XX_LCR_REG); =20 - /* Enable access to Enhanced register set */ - sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_REG_SET_ENHAN= CED); + /* Enable access to the desired register set */ + sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, register_set); =20 - /* Disable cache updates when writing to EFR registers */ + /* Disable cache updates when writing to non-general registers */ regcache_cache_bypass(one->regmap, true); } =20 -static void sc16is7xx_efr_unlock(struct uart_port *port) +static void sc16is7xx_regs_unlock(struct uart_port *port) { struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); =20 - /* Re-enable cache updates when writing to normal registers */ + /* Re-enable cache updates when writing to general registers */ regcache_cache_bypass(one->regmap, false); =20 /* Restore original content of LCR */ @@ -580,8 +584,6 @@ static bool sc16is7xx_regmap_noinc(struct device *dev, = unsigned int reg) */ static int sc16is7xx_set_baud(struct uart_port *port, int baud) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); - u8 lcr; unsigned int prescaler =3D 1; unsigned long clk =3D port->uartclk, div =3D clk / 16 / baud; =20 @@ -595,23 +597,15 @@ static int sc16is7xx_set_baud(struct uart_port *port,= int baud) SC16IS7XX_MCR_CLKSEL_BIT, prescaler =3D=3D 1 ? 0 : SC16IS7XX_MCR_CLKSEL_BIT); =20 - mutex_lock(&one->lock); - - /* Backup LCR and access special register set (DLL/DLH) */ - lcr =3D sc16is7xx_port_read(port, SC16IS7XX_LCR_REG); - sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, - SC16IS7XX_LCR_REG_SET_SPECIAL); + /* Access special register set (DLL/DLH) */ + sc16is7xx_regs_lock(port, SC16IS7XX_LCR_REG_SET_SPECIAL); =20 /* Write the new divisor */ - regcache_cache_bypass(one->regmap, true); sc16is7xx_port_write(port, SC16IS7XX_DLH_REG, div / 256); sc16is7xx_port_write(port, SC16IS7XX_DLL_REG, div % 256); - regcache_cache_bypass(one->regmap, false); =20 - /* Restore LCR and access to general register set */ - sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, lcr); - - mutex_unlock(&one->lock); + /* Restore access to general register set */ + sc16is7xx_regs_unlock(port); =20 return DIV_ROUND_CLOSEST((clk / prescaler) / 16, div); } @@ -1108,12 +1102,12 @@ static void sc16is7xx_set_termios(struct uart_port = *port, sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, lcr); =20 /* Update EFR registers */ - sc16is7xx_efr_lock(port); + sc16is7xx_regs_lock(port, SC16IS7XX_LCR_REG_SET_ENHANCED); sc16is7xx_port_write(port, SC16IS7XX_XON1_REG, termios->c_cc[VSTART]); sc16is7xx_port_write(port, SC16IS7XX_XOFF1_REG, termios->c_cc[VSTOP]); sc16is7xx_port_update(port, SC16IS7XX_EFR_REG, SC16IS7XX_EFR_FLOWCTRL_BITS, flow); - sc16is7xx_efr_unlock(port); + sc16is7xx_regs_unlock(port); =20 /* Get baud rate generator configuration */ baud =3D uart_get_baud_rate(port, termios, old, @@ -1631,6 +1625,9 @@ int sc16is7xx_probe(struct device *dev, const struct = sc16is7xx_devtype *devtype, if (ret) goto out_ports; =20 + /* Enable access to general register set */ + sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG, 0x00); + /* Disable all interrupts */ sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_IER_REG, 0); /* Disable TX/RX */ @@ -1650,20 +1647,11 @@ int sc16is7xx_probe(struct device *dev, const struc= t sc16is7xx_devtype *devtype, =20 port_registered[i] =3D true; =20 - /* Enable EFR */ - sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG, - SC16IS7XX_LCR_REG_SET_ENHANCED); - - regcache_cache_bypass(regmaps[i], true); - + sc16is7xx_regs_lock(&s->p[i].port, SC16IS7XX_LCR_REG_SET_ENHANCED); /* Enable write access to enhanced features */ sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_EFR_REG, SC16IS7XX_EFR_ENABLE_BIT); - - regcache_cache_bypass(regmaps[i], false); - - /* Restore access to general registers */ - sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG, 0x00); + sc16is7xx_regs_unlock(&s->p[i].port); =20 /* Go to suspend mode */ sc16is7xx_power(&s->p[i].port, 0); --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 BB794165F1A; Thu, 2 Oct 2025 14:57:54 +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=1759417076; cv=none; b=AOjkRHMIJI2cnId1sWPkJISpiyMEq9b7AOyybQi3fOFypcVMQBvRCo851L8LO+PGu7DTCoBf7eIGJJYmqbjiy1X2AfTsh5/P46G796zWGvnt31QbdmhMveuO9xUA2TP+xGRenyAkomAj3UDgwb49HoE2e4APpm5XaE5ux4JoqLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417076; c=relaxed/simple; bh=u6Lx9QF35BQSo458PLEIGbTD/o5v3/ya3P+BZHwKBfM=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=W65ISpRvlxIoKDOtquoDZ6jcf8PmRQMBgFfzUw49QSSAP+zUruSJoNACVNAjpqzdi74pQ0KY7NhuFjVvoaEPRKd2rGCPug6MnygX375/x46sWISaGlRcQa/wRpyqKcbr8kwJjIHyitiRRiqgBfvRucrYqOg9HqVNAYYuvCz+E/s= 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=U9J5poAp; 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="U9J5poAp" 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=04i7Sp88FFJOPgnn3H/zi1ltQiHU4cbmVZhpQuluM14=; b=U9J5poAp5GRqSRpYU24jLj5zTq IE7x8hFcHkm37r1YMgHkpJIIeh5Q42jMArUHxGRobkHfNI7yXMLfGKCfYVrURM0GC0SODG9WBLQlt 57WYETtY0ArhXwkrUytqGpNL4iwfvbb3zgnsCcygd62X2HJWG6Ya/obPd8lvwNbdXEdc=; 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 1v4Kkd-0005hy-Ti; Thu, 02 Oct 2025 10:57:48 -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:28 -0400 Message-Id: <20251002145738.3250272-6-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 05/15] serial: sc16is7xx: remove unnecessary pointer cast 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 There is no need to cast from a void * pointer, so remove this cast. Also remove empty line inavertently added in commit d5078509c8b0 ("serial: sc16is7xx: improve do/while loop in sc16is7xx_irq()") and change variables order to follow reversed xmas tree. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 72e4c4f80f7f5..335695d0e7aa7 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -837,10 +837,9 @@ static bool sc16is7xx_port_irq(struct sc16is7xx_port *= s, int portno) =20 static irqreturn_t sc16is7xx_irq(int irq, void *dev_id) { + struct sc16is7xx_port *s =3D dev_id; bool keep_polling; =20 - struct sc16is7xx_port *s =3D (struct sc16is7xx_port *)dev_id; - do { int i; =20 --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 From nobody Mon Feb 9 09:29:29 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 C09DE19D880; 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=uAsKwZO6IniemDbW3PZrV2m09kqS7cQkBaLLtpuNTIZWYu5DjVq8Qy0w1/hPVuFhlQz3rOh+EDoC3a2S2ANL3xVVqosr5aDPmcg23IK2ixMhu1tNoLa76uOpwQUZl6SNDFOUjsI+guwPmxbaAx+mYcgSZlVusCkeP48B21ckoGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417078; c=relaxed/simple; bh=alnAlEaa3VhrHS5fE/2q3E8Q4I3DCkMJzv3wETeAjd4=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=huO/zG2oaWNMeHQZK5lRKTPTd4RG5TkAydXnjc+YoxzxxWrW7z4iqUCtYauCs/HWh7QBMnz3tSWg04e0Uhn2uq7ZfSFGgiQYJli5ivtip3XFOHRE8qvsfnPBsO9UkhsGfFljVCo1XsNZQ2GGVGY/DTEJXZ5Kw4s4feEtNPu1k7E= 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=QT5sNETH; 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="QT5sNETH" 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=uHg8PKvTJuxb1S+SGCKDBR4VebV7fuq1HHKPiPau62Y=; b=QT5sNETHx/2Mif3ierYM4N++tl z+t6rB/GOqMa9IWWpSSilSsmTNPI3cgVDGl8Bneey6tp0wNdYmhqH3DlK0wivMHrAhlDwYTx6bDRV RVFZKOMhkL7TzyUT28Irs/A3QOzLYgFfHnEz/nE/E8JBzzHzNz5eUPxj1fMaUUGqPC3w=; 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 1v4Kkf-0005hy-Kw; 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:30 -0400 Message-Id: <20251002145738.3250272-8-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 07/15] serial: sc16is7xx: drop -ENOMEM error message 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 Core already prints detailed error messages on ENOMEM errors and drivers should avoid repeating it. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 1acf5be03d489..ce2a0967ffdf4 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1527,10 +1527,8 @@ int sc16is7xx_probe(struct device *dev, const struct= sc16is7xx_devtype *devtype, =20 /* Alloc port structure */ s =3D devm_kzalloc(dev, struct_size(s, p, devtype->nr_uart), GFP_KERNEL); - if (!s) { - dev_err(dev, "Error allocating port structure\n"); + if (!s) return -ENOMEM; - } =20 /* Always ask for fixed clock rate from a property. */ device_property_read_u32(dev, "clock-frequency", &uartclk); --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 1B0FE3C1F; Thu, 2 Oct 2025 14:57:51 +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=1759417073; cv=none; b=mFK+EJoKqLXlT+FqHV3WpAz/ulCBqL/RyelGiazft+1R9K879ql74qIEIyupdZxLMfcmsui82QrqJl0jGzEOm51m/FvsYcNnGRxGBlbCe0ee7EsV/9lM3IKbflm434TAp3tqpdxP5LPYUoOIQiyWadG3b0U0ln9bA4lTy8UK/HQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417073; c=relaxed/simple; bh=QTdYORm3Ar5449orCUvpuyQ/EEELMgXHqxN9Y6MQxWs=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=mZAdTvnjVmFtUKwinXnDwKxdqJZ1nz716pOLf3JuVZG+gfxtBRmnX3nNAUD5xz7Sk1zNi6q7sdrTIYVR0utTa1NWWkAY9s0VnguTRHwlDzKng6N41CmL2MAhyVExQcwBNxYy9YrNclJtrRxuvBMDbGPjyXpyvSZ0ZrAYikryI5g= 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=HAc9n0sN; 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="HAc9n0sN" 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=Nh2cTwNgEe/lYYJk+cy3OBnV4tfGoYgLU0GsiudsnzQ=; b=HAc9n0sNyrGoqy6SjemJLqMKPn ecbf1MlcUDDCWEXbmJzhwaGdRlGPCARxPKVvW2b4L3288fqyiH14xotZY+7e+bFEewCUHMkKTL6kN bwT6jrKoHXH5w/5s2PFGEW594KSw4PHbqR5aXi+dJv4ymi7QULgQlvaHDoLcdJObfYRc=; 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 1v4Kkg-0005hy-Cd; Thu, 02 Oct 2025 10:57:50 -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:31 -0400 Message-Id: <20251002145738.3250272-9-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 08/15] serial: sc16is7xx: declare SPR/TLR/XOFF2 register as volatile 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 SPR shares the same address space as TLR and XOFF2. If SPR or TLR were to be used eventually, this could lead to incorrect read value from the cache. Prevent this potential bug by declaring SPR/TLR/XOFF2 as volatile. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index ce2a0967ffdf4..281cbb2274e50 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -546,6 +546,7 @@ static bool sc16is7xx_regmap_volatile(struct device *de= v, unsigned int reg) case SC16IS7XX_IIR_REG: case SC16IS7XX_LSR_REG: case SC16IS7XX_MSR_REG: + case SC16IS7XX_SPR_REG: /* Shared address space with TLR & XOFF2 */ case SC16IS7XX_TXLVL_REG: case SC16IS7XX_RXLVL_REG: case SC16IS7XX_IOSTATE_REG: --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 0DB0E13A3ED; Thu, 2 Oct 2025 14:57:52 +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=1759417074; cv=none; b=U3W3JpP+oHO2Hkl7tJ0eBlbGNOa+xJ6jH4Ujaa1LL7b29YrvxTQ4BeMPZ4iSQBl5/4t904hT2L6di1Y8k1DZgSganem0qJfp7zOaaY5kL29HvHf5tsujaZjDka4umSP+sgBDIZ6L8GrI0zkZVHbv9seFjhxWH10z4PoCwL7a9PQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417074; c=relaxed/simple; bh=ToQyPN+TlA1UPUy/7j+kBOYM/xKJ643CH87sHP0DMXU=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=jvOJ8iBVkgKI7c0TKJNo72Qy3DXB/ec4DEg5QwOCC32vMuLMFyOxV+6Vsaf56VF9h1oSaedmrP7N1TgSwK/UqL1oyM/DQvYYxCVocAANh4Acu0utCGT/Ardj2SvrRbG0vGUJpFAd3iTrRNI1Yy2/KkuA0IGIUBlOZiKNDyLa4Tk= 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=LMWIuDD1; 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="LMWIuDD1" 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=ekdaWYWzuGlTbvIE22/p4Lpz6i0MAI27A3e2yCrkMgE=; b=LMWIuDD1RTztxh+eVhXdtJ561x OWjQAYccUrzGS2kZsUdvuW9vN5zxij3rIwPms8IE7TN2rWDtW+zD/QyzvRwNWxcSd21jiz3eSWSTV ZyefxhYwnaUtyErjwZ2Y/jepIRocExXZz2KWaZ6GnZoitad+jMBoJGs4eh14POtHhNKM=; 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 1v4Kkh-0005hy-7M; Thu, 02 Oct 2025 10:57:51 -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:32 -0400 Message-Id: <20251002145738.3250272-10-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 09/15] serial: sc16is7xx: move port/channel init to separate function 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 The sc16is7xx_probe() function is very long. To improve readability, move port/channel initialization to a separate function. No functional change intended. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 127 ++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 57 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 281cbb2274e50..a7a6d613459dc 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1499,6 +1499,75 @@ static int sc16is7xx_reset(struct device *dev, struc= t regmap *regmap) return 0; } =20 +static int sc16is7xx_setup_channel(struct sc16is7xx_one *one, int i, + bool *port_registered) +{ + struct uart_port *port =3D &one->port; + int ret; + + ret =3D ida_alloc_max(&sc16is7xx_lines, SC16IS7XX_MAX_DEVS - 1, GFP_KERNE= L); + if (ret < 0) + return ret; + + port->line =3D ret; + + /* Initialize port data */ + port->type =3D PORT_SC16IS7XX; + port->fifosize =3D SC16IS7XX_FIFO_SIZE; + port->flags =3D UPF_FIXED_TYPE | UPF_LOW_LATENCY; + port->iobase =3D i; + /* + * Use all ones as membase to make sure uart_configure_port() in + * serial_core.c does not abort for SPI/I2C devices where the + * membase address is not applicable. + */ + port->membase =3D (void __iomem *)~0; + port->iotype =3D UPIO_PORT; + port->rs485_config =3D sc16is7xx_config_rs485; + port->rs485_supported =3D sc16is7xx_rs485_supported; + port->ops =3D &sc16is7xx_ops; + one->old_mctrl =3D 0; + + mutex_init(&one->lock); + + ret =3D uart_get_rs485_mode(port); + if (ret) + return ret; + + /* Enable access to general register set */ + sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, 0x00); + + /* Disable all interrupts */ + sc16is7xx_port_write(port, SC16IS7XX_IER_REG, 0); + /* Disable TX/RX */ + sc16is7xx_port_write(port, SC16IS7XX_EFCR_REG, + SC16IS7XX_EFCR_RXDISABLE_BIT | + SC16IS7XX_EFCR_TXDISABLE_BIT); + + /* Initialize kthread work structs */ + kthread_init_work(&one->tx_work, sc16is7xx_tx_proc); + kthread_init_work(&one->reg_work, sc16is7xx_reg_proc); + kthread_init_delayed_work(&one->ms_work, sc16is7xx_ms_proc); + + /* Register port */ + ret =3D uart_add_one_port(&sc16is7xx_uart, port); + if (ret) + return ret; + + *port_registered =3D true; + + sc16is7xx_regs_lock(port, SC16IS7XX_LCR_REG_SET_ENHANCED); + /* Enable write access to enhanced features */ + sc16is7xx_port_write(port, SC16IS7XX_EFR_REG, + SC16IS7XX_EFR_ENABLE_BIT); + sc16is7xx_regs_unlock(port); + + /* Go to suspend mode */ + sc16is7xx_power(port, 0); + + return 0; +} + int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *de= vtype, struct regmap *regmaps[], int irq) { @@ -1582,70 +1651,14 @@ int sc16is7xx_probe(struct device *dev, const struc= t sc16is7xx_devtype *devtype, } =20 for (i =3D 0; i < devtype->nr_uart; ++i) { - ret =3D ida_alloc_max(&sc16is7xx_lines, - SC16IS7XX_MAX_DEVS - 1, GFP_KERNEL); - if (ret < 0) - goto out_ports; - - s->p[i].port.line =3D ret; - - /* Initialize port data */ s->p[i].port.dev =3D dev; s->p[i].port.irq =3D irq; - s->p[i].port.type =3D PORT_SC16IS7XX; - s->p[i].port.fifosize =3D SC16IS7XX_FIFO_SIZE; - s->p[i].port.flags =3D UPF_FIXED_TYPE | UPF_LOW_LATENCY; - s->p[i].port.iobase =3D i; - /* - * Use all ones as membase to make sure uart_configure_port() in - * serial_core.c does not abort for SPI/I2C devices where the - * membase address is not applicable. - */ - s->p[i].port.membase =3D (void __iomem *)~0; - s->p[i].port.iotype =3D UPIO_PORT; s->p[i].port.uartclk =3D freq; - s->p[i].port.rs485_config =3D sc16is7xx_config_rs485; - s->p[i].port.rs485_supported =3D sc16is7xx_rs485_supported; - s->p[i].port.ops =3D &sc16is7xx_ops; - s->p[i].old_mctrl =3D 0; s->p[i].regmap =3D regmaps[i]; =20 - mutex_init(&s->p[i].lock); - - ret =3D uart_get_rs485_mode(&s->p[i].port); + ret =3D sc16is7xx_setup_channel(&s->p[i], i, &port_registered[i]); if (ret) goto out_ports; - - /* Enable access to general register set */ - sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG, 0x00); - - /* Disable all interrupts */ - sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_IER_REG, 0); - /* Disable TX/RX */ - sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_EFCR_REG, - SC16IS7XX_EFCR_RXDISABLE_BIT | - SC16IS7XX_EFCR_TXDISABLE_BIT); - - /* Initialize kthread work structs */ - kthread_init_work(&s->p[i].tx_work, sc16is7xx_tx_proc); - kthread_init_work(&s->p[i].reg_work, sc16is7xx_reg_proc); - kthread_init_delayed_work(&s->p[i].ms_work, sc16is7xx_ms_proc); - - /* Register port */ - ret =3D uart_add_one_port(&sc16is7xx_uart, &s->p[i].port); - if (ret) - goto out_ports; - - port_registered[i] =3D true; - - sc16is7xx_regs_lock(&s->p[i].port, SC16IS7XX_LCR_REG_SET_ENHANCED); - /* Enable write access to enhanced features */ - sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_EFR_REG, - SC16IS7XX_EFR_ENABLE_BIT); - sc16is7xx_regs_unlock(&s->p[i].port); - - /* Go to suspend mode */ - sc16is7xx_power(&s->p[i].port, 0); } =20 sc16is7xx_setup_irda_ports(s); --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 62EF8156230; Thu, 2 Oct 2025 14:57:54 +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=1759417077; cv=none; b=o5Qqq/Z79R+7mrXQ1FZyCGNzMqnTUk5T84atKlEVWD1kyE+pWKF4+rOogCiHqCWD6AHT5BssqjWsJs5/QwS8pwlF70wxwOGhr8fNMiZZnmfsH8ljFtHqeBDMfSH5qh2j0UaEnriwyp5gtbcB0/ASX0lfFVwgDnafy9c1haSUzLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417077; c=relaxed/simple; bh=gMNy4QEbMqeU8/mITQaIbAbDT/RyVu50K3NKNO/RmR0=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=mJeq4GFBU7umDxJJs3o8zwm2CHWTSkmYE4udLq0DNZPt4U8vkswEhSDMHBSsnodIelRFyCrSBli2SbqUcyu3CVQfwU3kqq2F4YgdHze4e5brmBvZPURttosQglOQmwTXBumIyqd9NzVX0Kttg6WLLxSXtob1lLKWkLikYcv3Xgg= 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=GU7+lusN; 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="GU7+lusN" 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=rEQHKSVgxMuVe+bIU/NsbGX/h3ToaQ335nLkMWEqPAs=; b=GU7+lusNsDpkM7nGxHBCAJgCRk itqcOBmNS8bbJUBcbAwGw9krDWPEI5neB1/U+O75rn7zU9YINjen6oXiVFFqjNWk68X2NUCId+OZx XOMVNNfM4KNuO9RjYeccLnjQmbbtOXCH8wUp8q5bQRMO6xGFlfFt1hZQcdOktjvO7GqA=; 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 1v4Kki-0005hy-9S; Thu, 02 Oct 2025 10:57:52 -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:33 -0400 Message-Id: <20251002145738.3250272-11-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 10/15] serial: sc16is7xx: simplify to_sc16is7xx_one() with a single parameter 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 Simplify macro to_sc16is7xx_one() to only take one parameter, as most of the time (19) it is called with the "port" structure name. This improves readability. For the remaining places where it is called (4), simply use container_of() locally. This is similar to what is done in other drivers (ex: max310x). For sc16is7xx_tx_proc(), first assigning "one" variable allows to simplify "port" variable init. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 48 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index a7a6d613459dc..c6d4ad8d84d16 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -366,11 +366,11 @@ static struct uart_driver sc16is7xx_uart =3D { .nr =3D SC16IS7XX_MAX_DEVS, }; =20 -#define to_sc16is7xx_one(p,e) ((container_of((p), struct sc16is7xx_one, e)= )) +#define to_sc16is7xx_one(p) container_of((p), struct sc16is7xx_one, port) =20 static u8 sc16is7xx_port_read(struct uart_port *port, u8 reg) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); unsigned int val =3D 0; =20 regmap_read(one->regmap, reg, &val); @@ -380,21 +380,21 @@ static u8 sc16is7xx_port_read(struct uart_port *port,= u8 reg) =20 static void sc16is7xx_port_write(struct uart_port *port, u8 reg, u8 val) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 regmap_write(one->regmap, reg, val); } =20 static void sc16is7xx_fifo_read(struct uart_port *port, u8 *rxbuf, unsigne= d int rxlen) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 regmap_noinc_read(one->regmap, SC16IS7XX_RHR_REG, rxbuf, rxlen); } =20 static void sc16is7xx_fifo_write(struct uart_port *port, u8 *txbuf, u8 to_= send) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 /* * Don't send zero-length data, at least on SPI it confuses the chip @@ -409,7 +409,7 @@ static void sc16is7xx_fifo_write(struct uart_port *port= , u8 *txbuf, u8 to_send) static void sc16is7xx_port_update(struct uart_port *port, u8 reg, u8 mask, u8 val) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 regmap_update_bits(one->regmap, reg, mask, val); } @@ -441,7 +441,7 @@ static void sc16is7xx_power(struct uart_port *port, int= on) */ static void sc16is7xx_regs_lock(struct uart_port *port, u8 register_set) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 mutex_lock(&one->lock); =20 @@ -457,7 +457,7 @@ static void sc16is7xx_regs_lock(struct uart_port *port,= u8 register_set) =20 static void sc16is7xx_regs_unlock(struct uart_port *port) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 /* Re-enable cache updates when writing to general registers */ regcache_cache_bypass(one->regmap, false); @@ -471,7 +471,7 @@ static void sc16is7xx_regs_unlock(struct uart_port *por= t) static void sc16is7xx_ier_clear(struct uart_port *port, u8 bit) { struct sc16is7xx_port *s =3D dev_get_drvdata(port->dev); - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 lockdep_assert_held_once(&port->lock); =20 @@ -484,7 +484,7 @@ static void sc16is7xx_ier_clear(struct uart_port *port,= u8 bit) static void sc16is7xx_ier_set(struct uart_port *port, u8 bit) { struct sc16is7xx_port *s =3D dev_get_drvdata(port->dev); - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 lockdep_assert_held_once(&port->lock); =20 @@ -615,7 +615,7 @@ static int sc16is7xx_set_baud(struct uart_port *port, i= nt baud) static void sc16is7xx_handle_rx(struct uart_port *port, unsigned int rxlen, unsigned int iir) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); unsigned int lsr =3D 0, bytes_read, i; bool read_lsr =3D (iir =3D=3D SC16IS7XX_IIR_RLSE_SRC); u8 ch, flag; @@ -782,7 +782,7 @@ static bool sc16is7xx_port_irq(struct sc16is7xx_port *s= , int portno) { unsigned int iir, rxlen; struct uart_port *port =3D &s->p[portno].port; - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 guard(mutex)(&one->lock); =20 @@ -862,8 +862,8 @@ static void sc16is7xx_poll_proc(struct kthread_work *ws) =20 static void sc16is7xx_tx_proc(struct kthread_work *ws) { - struct uart_port *port =3D &(to_sc16is7xx_one(ws, tx_work)->port); - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D container_of(ws, struct sc16is7xx_one, tx_w= ork); + struct uart_port *port =3D &one->port; =20 if ((port->rs485.flags & SER_RS485_ENABLED) && (port->rs485.delay_rts_before_send > 0)) @@ -895,7 +895,7 @@ static void sc16is7xx_reconf_rs485(struct uart_port *po= rt) =20 static void sc16is7xx_reg_proc(struct kthread_work *ws) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(ws, reg_work); + struct sc16is7xx_one *one =3D container_of(ws, struct sc16is7xx_one, reg_= work); struct sc16is7xx_one_config config; unsigned long irqflags; =20 @@ -933,7 +933,7 @@ static void sc16is7xx_reg_proc(struct kthread_work *ws) =20 static void sc16is7xx_ms_proc(struct kthread_work *ws) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(ws, ms_work.work); + struct sc16is7xx_one *one =3D container_of(ws, struct sc16is7xx_one, ms_w= ork.work); struct sc16is7xx_port *s =3D dev_get_drvdata(one->port.dev); =20 if (one->port.state) { @@ -946,7 +946,7 @@ static void sc16is7xx_ms_proc(struct kthread_work *ws) =20 static void sc16is7xx_enable_ms(struct uart_port *port) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); struct sc16is7xx_port *s =3D dev_get_drvdata(port->dev); =20 lockdep_assert_held_once(&port->lock); @@ -957,7 +957,7 @@ static void sc16is7xx_enable_ms(struct uart_port *port) static void sc16is7xx_start_tx(struct uart_port *port) { struct sc16is7xx_port *s =3D dev_get_drvdata(port->dev); - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 kthread_queue_work(&s->kworker, &one->tx_work); } @@ -996,7 +996,7 @@ static unsigned int sc16is7xx_tx_empty(struct uart_port= *port) =20 static unsigned int sc16is7xx_get_mctrl(struct uart_port *port) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 /* Called with port lock taken so we can only return cached value */ return one->old_mctrl; @@ -1005,7 +1005,7 @@ static unsigned int sc16is7xx_get_mctrl(struct uart_p= ort *port) static void sc16is7xx_set_mctrl(struct uart_port *port, unsigned int mctrl) { struct sc16is7xx_port *s =3D dev_get_drvdata(port->dev); - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 one->config.flags |=3D SC16IS7XX_RECONF_MD; kthread_queue_work(&s->kworker, &one->reg_work); @@ -1022,7 +1022,7 @@ static void sc16is7xx_set_termios(struct uart_port *p= ort, struct ktermios *termios, const struct ktermios *old) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); unsigned int lcr, flow =3D 0; int baud; unsigned long flags; @@ -1125,7 +1125,7 @@ static int sc16is7xx_config_rs485(struct uart_port *p= ort, struct ktermios *termi struct serial_rs485 *rs485) { struct sc16is7xx_port *s =3D dev_get_drvdata(port->dev); - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 if (rs485->flags & SER_RS485_ENABLED) { /* @@ -1145,7 +1145,7 @@ static int sc16is7xx_config_rs485(struct uart_port *p= ort, struct ktermios *termi =20 static int sc16is7xx_startup(struct uart_port *port) { - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); struct sc16is7xx_port *s =3D dev_get_drvdata(port->dev); unsigned int val; unsigned long flags; @@ -1209,7 +1209,7 @@ static int sc16is7xx_startup(struct uart_port *port) static void sc16is7xx_shutdown(struct uart_port *port) { struct sc16is7xx_port *s =3D dev_get_drvdata(port->dev); - struct sc16is7xx_one *one =3D to_sc16is7xx_one(port, port); + struct sc16is7xx_one *one =3D to_sc16is7xx_one(port); =20 kthread_cancel_delayed_work_sync(&one->ms_work); =20 --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 D2FD019006B; Thu, 2 Oct 2025 14:57:55 +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=1759417077; cv=none; b=FKsj4e2qWSpXB7kvyP863rPtkAxqujt98UAOqwHxkWWRvoZSsCV2UjevIgYgQqDHqCgf+6EC/ygoEyyf47GqhnKAHc6rXIuZ53fYaL7P6zCSyKRoGVAq0PwpjJvZu4OqYGNLmqBfVM5v1NDgVAy4eE/a/c3vlbnDcvz3s02Qyx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417077; c=relaxed/simple; bh=/59pzaIpo3hxjYrwoqRQB9pU18sg+2ce7TE+GucMtQ4=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=ZOI+meTYYoDX3jv8tgTgJ7/Gr3w7RACdqGP070KCm8bP4vFaYkwbyPYnYv2uA+shwacpc27AM61pEONozXJo/Y84x4ZuzHYNOTOq6UNjEmKwuGoOtio6BL1kQ/Ex44ZqosxR/goZwENO/Y4T5uCE6LPEIP5EJVy9DFk/9VXMDeQ= 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=C/V1Y4qq; 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="C/V1Y4qq" 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=N0EipVfeJiCRsPTWh7G7K2zw8aa4aDpHL9PXk/Hc5Xg=; b=C/V1Y4qqd0TMBxDoiFEK+bQqhk ywEGouaWNA3uGjVq/KAnLnLniQrsK5hSnCp8m9vM43XAbH5bcbC886nQ4lZTVTHkang22L/U2vLT5 mXPTAfirDlPGYbTY3wqAXBnmcbZjbYfubEzo8MAvTO9dsUZga/oC9iOMDoAh3zTOUM54=; 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 1v4Kkj-0005hy-F5; Thu, 02 Oct 2025 10:57:54 -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 , Geert Uytterhoeven Date: Thu, 2 Oct 2025 10:57:34 -0400 Message-Id: <20251002145738.3250272-12-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 11/15] serial: sc16is7xx: Kconfig: allow building with COMPILE_TEST 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 Add COMPILE_TEST as an option to allow test building the driver. Suggested-by: Geert Uytterhoeven Link: https://lore.kernel.org/all/20240604083159.d984dd08741396ea4ca46418@h= ugovil.com/raw Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 8523ccfb364dd..9a90654dccd78 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1044,7 +1044,7 @@ config SERIAL_SCCNXP_CONSOLE =20 config SERIAL_SC16IS7XX tristate "NXP SC16IS7xx UART support" - depends on SPI_MASTER || I2C + depends on SPI_MASTER || I2C || COMPILE_TEST select SERIAL_CORE select SERIAL_SC16IS7XX_SPI if SPI_MASTER select SERIAL_SC16IS7XX_I2C if I2C --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 6F9EB1A76BB; Thu, 2 Oct 2025 14:57:57 +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=1759417079; cv=none; b=XaoccXuqjKE4iywwNndfgf5DODqPKs4uxVeWLHO/39hbVW1HGeKwFjQQww45iDxVfZm+PctTt26yqNJ77i4Om6KeL+SJNl/F6I2hZeN6NA4776aJSv/MGtfM5trqHTksLkwsMoZ+yjgKrrEYlusUdh+JPHT1uXfNazMPHXyQqZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417079; c=relaxed/simple; bh=6qedSYzS0ayeal9JrjXFgWkdWxh9ci9BhA4SlDvt4D8=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=iNCiBCHNrrv3qtjET7pwvzazEYB6csx+gIDm/8RnBcc+rGoYJ0wbGNGdJeoVp/+ZD7HowVJxaOSC4NBNNWVz7bBuFitHvwIIdn07MpNWE2b2/7fumf/YRTvFlSsTNb3NyUtZt2sIUuE1atws7BYTkR8K1GvkoDw1lotDHHMyEdY= 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=Jp3EqdH6; 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="Jp3EqdH6" 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=YuOC1vkYGHrM8fWmHS/yqyaGf9bwUcOKFIgyl6OUEhI=; b=Jp3EqdH6PM0dhQN9PBN7eTfZWo cpKEOeNBqcZF2ocSr256IUMRFZCb4eADQoKD9jJuSNOcvaA6XrjHGNgud6ZT3D7QiFvzNnGaha8gN NVs5YKyyqTsCGpUGK2XhgmFC36dvYeKeATBctCgjSqbSWxqVH0lx/C7kCdNgOUgMXszs=; 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 1v4Kkk-0005hy-SN; Thu, 02 Oct 2025 10:57:55 -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:35 -0400 Message-Id: <20251002145738.3250272-13-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 12/15] serial: sc16is7xx: use KBUILD_MODNAME 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 There is no need to redefine the driver name. Use KBUILD_MODNAME and get rid of DRV_NAME altogether. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 4 ++-- drivers/tty/serial/sc16is7xx.h | 1 - drivers/tty/serial/sc16is7xx_i2c.c | 4 ++-- drivers/tty/serial/sc16is7xx_spi.c | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index c6d4ad8d84d16..644f4e9233dbc 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -361,7 +361,7 @@ static DEFINE_IDA(sc16is7xx_lines); =20 static struct uart_driver sc16is7xx_uart =3D { .owner =3D THIS_MODULE, - .driver_name =3D SC16IS7XX_NAME, + .driver_name =3D KBUILD_MODNAME, .dev_name =3D "ttySC", .nr =3D SC16IS7XX_MAX_DEVS, }; @@ -1808,4 +1808,4 @@ module_exit(sc16is7xx_exit); =20 MODULE_LICENSE("GPL"); MODULE_AUTHOR("Jon Ringle "); -MODULE_DESCRIPTION("SC16IS7xx tty serial core driver"); +MODULE_DESCRIPTION(KBUILD_MODNAME " tty serial core driver"); diff --git a/drivers/tty/serial/sc16is7xx.h b/drivers/tty/serial/sc16is7xx.h index afb784eaee45b..9c584d6d35932 100644 --- a/drivers/tty/serial/sc16is7xx.h +++ b/drivers/tty/serial/sc16is7xx.h @@ -8,7 +8,6 @@ #include #include =20 -#define SC16IS7XX_NAME "sc16is7xx" #define SC16IS7XX_MAX_PORTS 2 /* Maximum number of UART ports per IC. */ =20 struct device; diff --git a/drivers/tty/serial/sc16is7xx_i2c.c b/drivers/tty/serial/sc16is= 7xx_i2c.c index cd7de9e057b85..699376c3b3a54 100644 --- a/drivers/tty/serial/sc16is7xx_i2c.c +++ b/drivers/tty/serial/sc16is7xx_i2c.c @@ -52,7 +52,7 @@ MODULE_DEVICE_TABLE(i2c, sc16is7xx_i2c_id_table); =20 static struct i2c_driver sc16is7xx_i2c_driver =3D { .driver =3D { - .name =3D SC16IS7XX_NAME, + .name =3D KBUILD_MODNAME, .of_match_table =3D sc16is7xx_dt_ids, }, .probe =3D sc16is7xx_i2c_probe, @@ -63,5 +63,5 @@ static struct i2c_driver sc16is7xx_i2c_driver =3D { module_i2c_driver(sc16is7xx_i2c_driver); =20 MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("SC16IS7xx I2C interface driver"); +MODULE_DESCRIPTION(KBUILD_MODNAME " interface driver"); MODULE_IMPORT_NS("SERIAL_NXP_SC16IS7XX"); diff --git a/drivers/tty/serial/sc16is7xx_spi.c b/drivers/tty/serial/sc16is= 7xx_spi.c index 20d736b657b17..7e76d0e38da7d 100644 --- a/drivers/tty/serial/sc16is7xx_spi.c +++ b/drivers/tty/serial/sc16is7xx_spi.c @@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(spi, sc16is7xx_spi_id_table); =20 static struct spi_driver sc16is7xx_spi_driver =3D { .driver =3D { - .name =3D SC16IS7XX_NAME, + .name =3D KBUILD_MODNAME, .of_match_table =3D sc16is7xx_dt_ids, }, .probe =3D sc16is7xx_spi_probe, @@ -86,5 +86,5 @@ static struct spi_driver sc16is7xx_spi_driver =3D { module_spi_driver(sc16is7xx_spi_driver); =20 MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("SC16IS7xx SPI interface driver"); +MODULE_DESCRIPTION(KBUILD_MODNAME " interface driver"); MODULE_IMPORT_NS("SERIAL_NXP_SC16IS7XX"); --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 C7C9E151991; Thu, 2 Oct 2025 14:57:58 +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=1759417080; cv=none; b=S9XGpbKTuuGBFVnrB8HgQjTjTS3d2x0rHggYOAI+pAiBgPnkhnIXM2i3XcxYMIDkDWB00T0S2dxxTK35aOMTPEI4dtH4dt0zxYNo+NrWzfWaGGVoOZgjx1tB7+E7q3NkSLm3g0fVpdBEd/sGm7LHId5zJ3yYNX7GbVZgpNEL01o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417080; c=relaxed/simple; bh=IjWZQxRbwm3maIX9Lg6a1zU954crPBEZ9m4lKowfbvk=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=FSv17xGflitpOKmvwUPE/yT/UNppjrPOyOn9MGjRHuR6Zr5FZgL59OmXrON/9ORjEeiGtzici3RbyEpuglnhfZ9kQETtnpkmSc0WqyGBrbVrDaMTt/LVnouVaNSOGN2Weut5OHf6mKIzSISTdv6VV5cd6EhaEBmpolWm/IOAPIM= 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=nNxo1B2S; 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="nNxo1B2S" 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=HdJyQ9WrvZzcCFahMYHp01Ira5K/dlNq8lQwchzPxxI=; b=nNxo1B2SKoOhFMBt3SCsuLIVua La73H8DKxwZNY+XtvJJl3wUtoWpSm029AIMZwFqQNHfGc7wS8BBZxED/73Ao2j/Nsg/AbNtz/xJfZ DDoznZRGyS903P2hiCbv31/TWNiFqKx6+Q7sodK9toq4A3dJMzMMYsXDiNHSIzaE6KbA=; 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 1v4Kkm-0005hy-3Q; Thu, 02 Oct 2025 10:57:56 -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:36 -0400 Message-Id: <20251002145738.3250272-14-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 13/15] serial: sc16is7xx: change conditional operator indentation 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 Move "?" conditional operator all on same line to improve readability. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 644f4e9233dbc..3faf821b8b89d 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1180,8 +1180,7 @@ static int sc16is7xx_startup(struct uart_port *port) /* This bit must be written with LCR[7] =3D 0 */ sc16is7xx_port_update(port, SC16IS7XX_MCR_REG, SC16IS7XX_MCR_IRDA_BIT, - one->irda_mode ? - SC16IS7XX_MCR_IRDA_BIT : 0); + one->irda_mode ? SC16IS7XX_MCR_IRDA_BIT : 0); =20 /* Enable the Rx and Tx FIFO */ sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 50EBE1DE2AD; Thu, 2 Oct 2025 14:57:59 +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=1759417081; cv=none; b=UBZfsV2gox/i09Uur1YRtqkn4mU/f2zrZajosPVqtdjKh74kVchIxaJz4YMp1Pp5lK24LCr/CSi9vnx0g20S+UfK6qTBIKJU2eStqAHRG99GNFN3mGvUPIzECqe1mKqP+32SDgr8JyIctddXLK9ssjcofg2rDVXD49rmo2fhAnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417081; c=relaxed/simple; bh=cv0776wE6L6vPhc8LktMi48w4rk9xW8uMbBJVEPfQCQ=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=glFfRdlcDGhy4cQpx3Hb0tQrZPI4le8sFa3gGNpbT0NrSM9k7w5x+kEPGpDv4YBhUFZmxxNAnAXcWlvAhMyLn4I5bujAcF40cKGsKczH22pkWWFzmTpZCMGwoRmBPTNOzkbZ5FOr67N/bANQiuOmog4iXnj3DNNPmxrF4/Em1zY= 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=qg55cWhp; 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="qg55cWhp" 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=U/M8bxS4SkUhlYmSY5BG8d9wjlgzoA0ZdMqi7Yz59NU=; b=qg55cWhpfsnMml2hk7aEdkosLl GeITsaG/R9biEqUxQpxwFjW/YuuzQgClYadmGuWmUb7jXlG4qvxL4eyb4DJlRs6y55D7PujMXDVi1 XDRQUHW94lB6gFrLOce/gHGT0oB/UM7+sqvuUUfRX5JUOWiQQ1q9LXGrfZSDSqZDdS5c=; 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 1v4Kkn-0005hy-0K; Thu, 02 Oct 2025 10:57:57 -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:37 -0400 Message-Id: <20251002145738.3250272-15-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 14/15] serial: sc16is7xx: reformat comments to improve readability 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 Fold some multi-line comments into a single line, taking advantage of the new 100 line length limit to improve readability and to have uniform style across driver. Add missing 's' to SC16IS7XX_MCR_TCRTLR_BIT registers comments. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 121 +++++++++++---------------------- 1 file changed, 39 insertions(+), 82 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 3faf821b8b89d..4898b4235d0da 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -50,18 +50,10 @@ #define SC16IS7XX_SPR_REG (0x07) /* Scratch Pad */ #define SC16IS7XX_TXLVL_REG (0x08) /* TX FIFO level */ #define SC16IS7XX_RXLVL_REG (0x09) /* RX FIFO level */ -#define SC16IS7XX_IODIR_REG (0x0a) /* I/O Direction - * - only on 75x/76x - */ -#define SC16IS7XX_IOSTATE_REG (0x0b) /* I/O State - * - only on 75x/76x - */ -#define SC16IS7XX_IOINTENA_REG (0x0c) /* I/O Interrupt Enable - * - only on 75x/76x - */ -#define SC16IS7XX_IOCONTROL_REG (0x0e) /* I/O Control - * - only on 75x/76x - */ +#define SC16IS7XX_IODIR_REG (0x0a) /* I/O Direction - only on 75x/76x */ +#define SC16IS7XX_IOSTATE_REG (0x0b) /* I/O State - only on 75x/76x */ +#define SC16IS7XX_IOINTENA_REG (0x0c) /* I/O Interrupt Enable - only on 7= 5x/76x */ +#define SC16IS7XX_IOCONTROL_REG (0x0e) /* I/O Control - only on 75x/76x */ #define SC16IS7XX_EFCR_REG (0x0f) /* Extra Features Control */ =20 /* TCR/TLR Register set: Only if ((MCR[2] =3D=3D 1) && (EFR[4] =3D=3D 1)) = */ @@ -81,12 +73,9 @@ =20 /* IER register bits */ #define SC16IS7XX_IER_RDI_BIT BIT(0) /* Enable RX data interrupt */ -#define SC16IS7XX_IER_THRI_BIT BIT(1) /* Enable TX holding register - * interrupt */ -#define SC16IS7XX_IER_RLSI_BIT BIT(2) /* Enable RX line status - * interrupt */ -#define SC16IS7XX_IER_MSI_BIT BIT(3) /* Enable Modem status - * interrupt */ +#define SC16IS7XX_IER_THRI_BIT BIT(1) /* Enable TX holding register int= errupt */ +#define SC16IS7XX_IER_RLSI_BIT BIT(2) /* Enable RX line status interrup= t */ +#define SC16IS7XX_IER_MSI_BIT BIT(3) /* Enable Modem status interrupt */ =20 /* IER register bits - write only if (EFR[4] =3D=3D 1) */ #define SC16IS7XX_IER_SLEEP_BIT BIT(4) /* Enable Sleep mode */ @@ -119,9 +108,8 @@ * - only on 75x/76x */ #define SC16IS7XX_IIR_XOFFI_SRC 0x10 /* Received Xoff */ -#define SC16IS7XX_IIR_CTSRTS_SRC 0x20 /* nCTS,nRTS change of state - * from active (LOW) - * to inactive (HIGH) +#define SC16IS7XX_IIR_CTSRTS_SRC 0x20 /* nCTS,nRTS change of state from a= ctive + * (LOW) to inactive (HIGH) */ /* LCR register bits */ #define SC16IS7XX_LCR_LENGTH0_BIT BIT(0) /* Word length bit 0 */ @@ -137,8 +125,7 @@ * * STOP length bit table: * 0 -> 1 stop bit - * 1 -> 1-1.5 stop bits if - * word length is 5, + * 1 -> 1-1.5 stop bits if word length is 5, * 2 stop bits otherwise */ #define SC16IS7XX_LCR_PARITY_BIT BIT(3) /* Parity bit enable */ @@ -150,31 +137,22 @@ #define SC16IS7XX_LCR_WORD_LEN_6 (0x01) #define SC16IS7XX_LCR_WORD_LEN_7 (0x02) #define SC16IS7XX_LCR_WORD_LEN_8 (0x03) -#define SC16IS7XX_LCR_REG_SET_SPECIAL SC16IS7XX_LCR_DLAB_BIT /* Special - * reg set - */ -#define SC16IS7XX_LCR_REG_SET_ENHANCED 0xBF /* Enhanced - * reg set - */ +#define SC16IS7XX_LCR_REG_SET_SPECIAL SC16IS7XX_LCR_DLAB_BIT /* Special re= g set */ +#define SC16IS7XX_LCR_REG_SET_ENHANCED 0xBF /* Enhanced = reg set */ =20 /* MCR register bits */ -#define SC16IS7XX_MCR_DTR_BIT BIT(0) /* DTR complement - * - only on 75x/76x - */ +#define SC16IS7XX_MCR_DTR_BIT BIT(0) /* DTR complement - only on 75x/76= x */ #define SC16IS7XX_MCR_RTS_BIT BIT(1) /* RTS complement */ -#define SC16IS7XX_MCR_TCRTLR_BIT BIT(2) /* TCR/TLR register enable */ +#define SC16IS7XX_MCR_TCRTLR_BIT BIT(2) /* TCR/TLR registers enable */ #define SC16IS7XX_MCR_LOOP_BIT BIT(4) /* Enable loopback test mode */ #define SC16IS7XX_MCR_XONANY_BIT BIT(5) /* Enable Xon Any - * - write enabled - * if (EFR[4] =3D=3D 1) + * - write enabled if (EFR[4] =3D=3D 1) */ #define SC16IS7XX_MCR_IRDA_BIT BIT(6) /* Enable IrDA mode - * - write enabled - * if (EFR[4] =3D=3D 1) + * - write enabled if (EFR[4] =3D=3D 1) */ #define SC16IS7XX_MCR_CLKSEL_BIT BIT(7) /* Divide clock by 4 - * - write enabled - * if (EFR[4] =3D=3D 1) + * - write enabled if (EFR[4] =3D=3D 1) */ =20 /* LSR register bits */ @@ -195,28 +173,19 @@ =20 /* MSR register bits */ #define SC16IS7XX_MSR_DCTS_BIT BIT(0) /* Delta CTS Clear To Send */ -#define SC16IS7XX_MSR_DDSR_BIT BIT(1) /* Delta DSR Data Set Ready - * or (IO4) +#define SC16IS7XX_MSR_DDSR_BIT BIT(1) /* Delta DSR Data Set Ready or (I= O4) * - only on 75x/76x */ -#define SC16IS7XX_MSR_DRI_BIT BIT(2) /* Delta RI Ring Indicator - * or (IO7) +#define SC16IS7XX_MSR_DRI_BIT BIT(2) /* Delta RI Ring Indicator or (IO7) * - only on 75x/76x */ -#define SC16IS7XX_MSR_DCD_BIT BIT(3) /* Delta CD Carrier Detect - * or (IO6) +#define SC16IS7XX_MSR_DCD_BIT BIT(3) /* Delta CD Carrier Detect or (IO6) * - only on 75x/76x */ #define SC16IS7XX_MSR_CTS_BIT BIT(4) /* CTS */ -#define SC16IS7XX_MSR_DSR_BIT BIT(5) /* DSR (IO4) - * - only on 75x/76x - */ -#define SC16IS7XX_MSR_RI_BIT BIT(6) /* RI (IO7) - * - only on 75x/76x - */ -#define SC16IS7XX_MSR_CD_BIT BIT(7) /* CD (IO6) - * - only on 75x/76x - */ +#define SC16IS7XX_MSR_DSR_BIT BIT(5) /* DSR (IO4) - only on 75x/76x */ +#define SC16IS7XX_MSR_RI_BIT BIT(6) /* RI (IO7) - only on 75x/76x */ +#define SC16IS7XX_MSR_CD_BIT BIT(7) /* CD (IO6) - only on 75x/76x */ =20 /* * TCR register bits @@ -255,54 +224,42 @@ #define SC16IS7XX_IOCONTROL_SRESET_BIT BIT(3) /* Software Reset */ =20 /* EFCR register bits */ -#define SC16IS7XX_EFCR_9BIT_MODE_BIT BIT(0) /* Enable 9-bit or Multidrop - * mode (RS485) */ +#define SC16IS7XX_EFCR_9BIT_MODE_BIT BIT(0) /* Enable 9-bit or Multidrop= mode (RS485) */ #define SC16IS7XX_EFCR_RXDISABLE_BIT BIT(1) /* Disable receiver */ #define SC16IS7XX_EFCR_TXDISABLE_BIT BIT(2) /* Disable transmitter */ #define SC16IS7XX_EFCR_AUTO_RS485_BIT BIT(4) /* Auto RS485 RTS direction= */ #define SC16IS7XX_EFCR_RTS_INVERT_BIT BIT(5) /* RTS output inversion */ #define SC16IS7XX_EFCR_IRDA_MODE_BIT BIT(7) /* IrDA mode - * 0 =3D rate upto 115.2 kbit/s - * - Only 75x/76x - * 1 =3D rate upto 1.152 Mbit/s - * - Only 76x + * 0 =3D rate up to 115.2 kbit/s - Only 75x/76x + * 1 =3D rate up to 1.152 Mbit/s - Only 76x */ =20 /* EFR register bits */ #define SC16IS7XX_EFR_AUTORTS_BIT BIT(6) /* Auto RTS flow ctrl enable */ #define SC16IS7XX_EFR_AUTOCTS_BIT BIT(7) /* Auto CTS flow ctrl enable */ #define SC16IS7XX_EFR_XOFF2_DETECT_BIT BIT(5) /* Enable Xoff2 detection = */ -#define SC16IS7XX_EFR_ENABLE_BIT BIT(4) /* Enable enhanced functions - * and writing to IER[7:4], - * FCR[5:4], MCR[7:5] +#define SC16IS7XX_EFR_ENABLE_BIT BIT(4) /* Enable enhanced functions and= writing to + * IER[7:4], FCR[5:4], MCR[7:5] */ #define SC16IS7XX_EFR_SWFLOW3_BIT BIT(3) #define SC16IS7XX_EFR_SWFLOW2_BIT BIT(2) /* * SWFLOW bits 3 & 2 table: - * 00 -> no transmitter flow - * control - * 01 -> transmitter generates - * XON2 and XOFF2 - * 10 -> transmitter generates - * XON1 and XOFF1 - * 11 -> transmitter generates - * XON1, XON2, XOFF1 and - * XOFF2 + * 00 -> no transmitter flow control + * 01 -> transmitter generates XON2 and XOFF2 + * 10 -> transmitter generates XON1 and XOFF1 + * 11 -> transmitter generates XON1, XON2, + * XOFF1 and XOFF2 */ #define SC16IS7XX_EFR_SWFLOW1_BIT BIT(1) #define SC16IS7XX_EFR_SWFLOW0_BIT BIT(0) /* * SWFLOW bits 1 & 0 table: - * 00 -> no received flow - * control - * 01 -> receiver compares - * XON2 and XOFF2 - * 10 -> receiver compares - * XON1 and XOFF1 - * 11 -> receiver compares - * XON1, XON2, XOFF1 and - * XOFF2 + * 00 -> no received flow control + * 01 -> receiver compares XON2 and XOFF2 + * 10 -> receiver compares XON1 and XOFF1 + * 11 -> receiver compares XON1, XON2, + * XOFF1 and XOFF2 */ #define SC16IS7XX_EFR_FLOWCTRL_BITS (SC16IS7XX_EFR_AUTORTS_BIT | \ SC16IS7XX_EFR_AUTOCTS_BIT | \ @@ -1152,7 +1109,7 @@ static int sc16is7xx_startup(struct uart_port *port) =20 sc16is7xx_power(port, 1); =20 - /* Reset FIFOs*/ + /* Reset FIFOs */ val =3D SC16IS7XX_FCR_RXRESET_BIT | SC16IS7XX_FCR_TXRESET_BIT; sc16is7xx_port_write(port, SC16IS7XX_FCR_REG, val); udelay(5); --=20 2.39.5 From nobody Mon Feb 9 09:29:29 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 389621E5B9A; Thu, 2 Oct 2025 14:58:00 +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=1759417081; cv=none; b=cGEOhJRBmJxt9EsuA/puCPmYzj0b1Hw28fOnNJ6iWnhMXjfiyFrdN/O9dUJmDIGotWQswKdaV5LdHq0ymjazd/zsqDReVmgLeNMa9j2sP5gUX85p67G/B6DcecCXsjsyrux/wdwy6cQCzJR96c0b9kRo0mYCk2yqITcbps532UE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759417081; c=relaxed/simple; bh=GCQy5NT/ubzrUMsnsLWKJUqAzFWNFZxLFuUUWhKDNjM=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=rVlBhnmuJE/OwamuxTRXMcI8yBMU591JSZFCAufaJ2NStRom/+ynP5wb2ry5EZ7g4Sb6CPgbAMYr9alI6Eetrl+Lef8s71IJe7NQO2mLrvlXq0Dnaq5l9f9TZhTsM9r+WR5PacDkqLQC+T1bsOHl1gKboFsDHoL1k/pUeeDrSek= 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=BB8ip93G; 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="BB8ip93G" 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=0t5o0gJzkUuCKY+o8R4Qgk/Wlxo2O4/jULe6c6ciClI=; b=BB8ip93Gn6p+aZWqbb+vftIfMW XIJ1F6hSBWgsHTCIpXduS7nLwwlyBwG8gqzS5oy2GK330vp4QjpopsaIpk/H88M5V6q73yAStw9o6 iCsLWwR9OYGXhLCquTylJu2U1JjnZyrOYme6lR4uNzkhpDj2xhTbWrBqbFDw9E43fhdM=; 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 1v4Kko-0005hy-D9; Thu, 02 Oct 2025 10:57:58 -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:38 -0400 Message-Id: <20251002145738.3250272-16-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 15/15] serial: sc16is7xx: add comments for lock requirements 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 Indicate why lock needs to be asserted when accessing MSR register, as this is not immediately obvious when looking at this register in the device datasheet. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 4898b4235d0da..1fd64a47341d8 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -499,10 +499,10 @@ EXPORT_SYMBOL_GPL(sc16is762_devtype); static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) { switch (reg) { - case SC16IS7XX_RHR_REG: - case SC16IS7XX_IIR_REG: - case SC16IS7XX_LSR_REG: - case SC16IS7XX_MSR_REG: + case SC16IS7XX_RHR_REG: /* Shared address space with THR & DLL */ + case SC16IS7XX_IIR_REG: /* Shared address space with FCR & EFR */ + case SC16IS7XX_LSR_REG: /* Shared address space with XON2 */ + case SC16IS7XX_MSR_REG: /* Shared address space with TCR & XOFF1 */ case SC16IS7XX_SPR_REG: /* Shared address space with TLR & XOFF2 */ case SC16IS7XX_TXLVL_REG: case SC16IS7XX_RXLVL_REG: @@ -711,6 +711,7 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_on= e *one) unsigned long flags; unsigned int status, changed; =20 + /* Lock required as MSR address is shared with TCR and XOFF1. */ lockdep_assert_held_once(&one->lock); =20 status =3D sc16is7xx_get_hwmctrl(port); --=20 2.39.5