lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 01 Dec 2023 17:00:30 +0100
From:   Jan Kundrát <jan.kundrat@...net.cz>
To:     Hugo Villeneuve <hugo@...ovil.com>
Cc:     <gregkh@...uxfoundation.org>, <jirislaby@...nel.org>,
        <hvilleneuve@...onoff.com>, <linux-kernel@...r.kernel.org>,
        <linux-serial@...r.kernel.org>
Subject: Re: [PATCH 7/7] serial: max310x: use separate regmap name for each port

On čtvrtek 30. listopadu 2023 20:10:49 CET, Hugo Villeneuve wrote:
> From: Hugo Villeneuve <hvilleneuve@...onoff.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@...onoff.com>

I was carrying a similar patch locally, and this one works for me as well.

Reviewed-by: Jan Kundrát <jan.kundrat@...net.cz>
Tested-by: Jan Kundrát <jan.kundrat@...net.cz>

> ---
>  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, &regcfg);
> @@ -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, &regcfg_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, &regcfg_i2c);
>  	}
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ