[v2,08/17] serial: max310x: use separate regmap name for each port
Commit Message
From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Use a separate regmap name for each port so they can each have their 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
Cc: Jan Kundrát <jan.kundrat@cesnet.cz>
Link: https://lore.kernel.org/all/77f101f1-897d-4e6d-a8fd-27b818caf768@cesnet.cz/
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
I didn't put again Jan Kundrát's Reviewed-by and Tested-by tags since this
version has modifications compared to the original one.
---
drivers/tty/serial/max310x.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
Comments
On Thu, Jan 18, 2024 at 5:22 PM Hugo Villeneuve <hugo@hugovil.com> wrote:
>
> From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
>
> Use a separate regmap name for each port so they can each have their 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
Just a side note for the future. The above is an example of "Useless
use of grep".
`find` has a `-name` parameter for such, using `find ...-name
'spi0.0*'` makes the grep unnecessary.
> /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
On Thu, 18 Jan 2024 17:30:16 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Thu, Jan 18, 2024 at 5:22 PM Hugo Villeneuve <hugo@hugovil.com> wrote:
> >
> > From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> >
> > Use a separate regmap name for each port so they can each have their 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
>
> Just a side note for the future. The above is an example of "Useless
> use of grep".
> `find` has a `-name` parameter for such, using `find ...-name
> 'spi0.0*'` makes the grep unnecessary.
Hi,
yes, I fixed a similar one in the sc16is7xx serie, but forgot to update
this one :)
Will fix it if sending V3.
Hugo Villeneuve
>
> > /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
>
> --
> With Best Regards,
> Andy Shevchenko
@@ -1486,6 +1486,19 @@ static struct regmap_config regcfg = {
.max_raw_write = MAX310X_FIFO_SIZE,
};
+static const char *max310x_regmap_name(u8 port_id)
+{
+ switch (port_id) {
+ case 0: return "port0";
+ case 1: return "port1";
+ case 2: return "port2";
+ case 3: return "port3";
+ default:
+ WARN_ON(true);
+ return NULL;
+ }
+}
+
#ifdef CONFIG_SPI_MASTER
static int max310x_spi_extended_reg_enable(struct device *dev, bool enable)
{
@@ -1521,6 +1534,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);
@@ -1620,6 +1635,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++) {
@@ -1628,6 +1644,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);
}