From: Hugo Villeneuve <hugo@hugovil.com>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org,
hvilleneuve@dimonoff.com
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
hugo@hugovil.com
Subject: [PATCH 7/7] serial: max310x: use separate regmap name for each port
Date: Thu, 30 Nov 2023 14:10:49 -0500 [thread overview]
Message-ID: <20231130191050.3165862-8-hugo@hugovil.com> (raw)
In-Reply-To: <20231130191050.3165862-1-hugo@hugovil.com>
From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Use a separate regmap name for each port so that each port can have its own
debugfs entry, allowing to access each port registers independently.
For example, a four channels/ports device like the MAX14830 will have four
entries in its regmap debugfs:
$ find /sys/kernel/debug/regmap -type d | grep spi0.0
/sys/kernel/debug/regmap/spi0.0-port0
/sys/kernel/debug/regmap/spi0.0-port1
/sys/kernel/debug/regmap/spi0.0-port2
/sys/kernel/debug/regmap/spi0.0-port3
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
drivers/tty/serial/max310x.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 58dd5cc62014..d2eca05a6966 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -27,6 +27,7 @@
#include <linux/uaccess.h>
#define MAX310X_NAME "max310x"
+#define MAX310X_PORT_NAME_SUFFIX "port"
#define MAX310X_MAJOR 204
#define MAX310X_MINOR 209
#define MAX310X_UART_NRMAX 16
@@ -1486,6 +1487,15 @@ static struct regmap_config regcfg = {
.max_raw_write = MAX310X_FIFO_SIZE,
};
+static const char *max310x_regmap_name(unsigned int port_id)
+{
+ static char buf[sizeof(MAX310X_PORT_NAME_SUFFIX __stringify(MAX310X_MAX_PORTS))];
+
+ snprintf(buf, sizeof(buf), MAX310X_PORT_NAME_SUFFIX "%u", port_id);
+
+ return buf;
+}
+
#ifdef CONFIG_SPI_MASTER
static int max310x_spi_extended_reg_enable(struct device *dev, bool enable)
{
@@ -1521,6 +1531,8 @@ static int max310x_spi_probe(struct spi_device *spi)
for (i = 0; i < devtype->nr; i++) {
u8 port_mask = i * 0x20;
+
+ regcfg.name = max310x_regmap_name(i);
regcfg.read_flag_mask = port_mask;
regcfg.write_flag_mask = port_mask | MAX310X_WRITE_BIT;
regmaps[i] = devm_regmap_init_spi(spi, ®cfg);
@@ -1617,6 +1629,7 @@ static int max310x_i2c_probe(struct i2c_client *client)
client->addr, devtype->slave_addr.min,
devtype->slave_addr.max);
+ regcfg_i2c.name = max310x_regmap_name(0);
regmaps[0] = devm_regmap_init_i2c(client, ®cfg_i2c);
for (i = 1; i < devtype->nr; i++) {
@@ -1625,6 +1638,7 @@ static int max310x_i2c_probe(struct i2c_client *client)
client->adapter,
port_addr);
+ regcfg_i2c.name = max310x_regmap_name(i);
regmaps[i] = devm_regmap_init_i2c(port_client, ®cfg_i2c);
}
--
2.39.2
next prev parent reply other threads:[~2023-11-30 19:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 19:10 [PATCH 0/7] serial: sc16is7xx and max310x: regmap fixes and improvements Hugo Villeneuve
2023-11-30 19:10 ` [PATCH 1/7] serial: sc16is7xx: fix snprintf format specifier in sc16is7xx_regmap_name() Hugo Villeneuve
2023-12-06 6:29 ` kernel test robot
2023-12-07 17:52 ` Hugo Villeneuve
2023-12-07 18:24 ` Andy Shevchenko
2023-12-07 19:02 ` Hugo Villeneuve
2023-12-12 20:03 ` Hugo Villeneuve
2023-12-13 14:43 ` Andy Shevchenko
2023-12-07 19:45 ` David Laight
2023-12-07 1:44 ` Greg KH
2023-12-07 16:02 ` Hugo Villeneuve
2023-12-07 1:45 ` Greg KH
2023-12-07 16:05 ` Hugo Villeneuve
2023-11-30 19:10 ` [PATCH 2/7] serial: sc16is7xx: remove global regmap from struct sc16is7xx_port Hugo Villeneuve
2023-11-30 19:10 ` [PATCH 3/7] serial: sc16is7xx: remove unused line structure member Hugo Villeneuve
2023-11-30 19:10 ` [PATCH 4/7] serial: sc16is7xx: add macro for max number of UART ports Hugo Villeneuve
2023-11-30 19:10 ` [PATCH 5/7] serial: sc16is7xx: improve sc16is7xx_regmap_name() buffer size computation Hugo Villeneuve
2023-11-30 19:10 ` [PATCH 6/7] serial: max310x: add macro for max number of ports Hugo Villeneuve
2023-12-01 15:59 ` Jan Kundrát
2023-11-30 19:10 ` Hugo Villeneuve [this message]
2023-12-01 16:00 ` [PATCH 7/7] serial: max310x: use separate regmap name for each port Jan Kundrát
2023-12-06 14:22 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231130191050.3165862-8-hugo@hugovil.com \
--to=hugo@hugovil.com \
--cc=gregkh@linuxfoundation.org \
--cc=hvilleneuve@dimonoff.com \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox