mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Hugo Villeneuve <hugo@hugovil.com>, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	lech.perczak@camlingroup.com,
	Hugo Villeneuve <hvilleneuve@dimonoff.com>
Subject: Re: [PATCH v2 1/1] serial: sc16is7xx: improve regmap debugfs by using one regmap per port
Date: Tue, 21 Nov 2023 06:57:56 +0100	[thread overview]
Message-ID: <90ba18b8-1a31-498d-a103-5c91b80cea5b@kernel.org> (raw)
In-Reply-To: <20231120163931.2872431-2-hugo@hugovil.com>

On 20. 11. 23, 17:39, Hugo Villeneuve wrote:
> From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> 
> With this current driver regmap implementation, it is hard to make sense
> of the register addresses displayed using the regmap debugfs interface,
> because they do not correspond to the actual register addresses documented
> in the datasheet. For example, register 1 is displayed as registers 04 thru
> 07:
...
> --- a/drivers/tty/serial/sc16is7xx.c
> +++ b/drivers/tty/serial/sc16is7xx.c
...
>   #ifdef CONFIG_SERIAL_SC16IS7XX_SPI
>   static int sc16is7xx_spi_probe(struct spi_device *spi)
>   {
>   	const struct sc16is7xx_devtype *devtype;
> -	struct regmap *regmap;
> +	struct regmap *regmaps[2];

IMO, in all places, it would make sense to declare a VLA with 
devtype->nr_uart.

> +	unsigned int i;
>   	int ret;
>   
>   	/* Setup SPI bus */
> @@ -1732,11 +1736,20 @@ static int sc16is7xx_spi_probe(struct spi_device *spi)
>   		devtype = (struct sc16is7xx_devtype *)id_entry->driver_data;
>   	}
>   
> -	regcfg.max_register = (0xf << SC16IS7XX_REG_SHIFT) |
> -			      (devtype->nr_uart - 1);
> -	regmap = devm_regmap_init_spi(spi, &regcfg);
> +	for (i = 0; i < devtype->nr_uart; i++) {
> +		regcfg.name = sc16is7xx_regmap_name(i);
> +		/*
> +		 * If read_flag_mask is 0, the regmap code sets it to a default
> +		 * of 0x80. Since we specify our own mask, we must add the READ
> +		 * bit ourselves:
> +		 */
> +		regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i) |
> +			SC16IS7XX_SPI_READ_BIT;
> +		regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i);
> +		regmaps[i] = devm_regmap_init_spi(spi, &regcfg);

As you trip over the array until devtype->nr_uart which is of course up 
to 2. For now.

Or at least add an asserion: devtype->nr_uart <= 2 somewhere.

thanks,
-- 
js
suse labs


  reply	other threads:[~2023-11-21  5:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20 16:39 [PATCH v2 0/1] serial: sc16is7xx: improve regmap debugfs with " Hugo Villeneuve
2023-11-20 16:39 ` [PATCH v2 1/1] serial: sc16is7xx: improve regmap debugfs by using " Hugo Villeneuve
2023-11-21  5:57   ` Jiri Slaby [this message]
2023-11-21 16:15     ` Hugo Villeneuve

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=90ba18b8-1a31-498d-a103-5c91b80cea5b@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hugo@hugovil.com \
    --cc=hvilleneuve@dimonoff.com \
    --cc=lech.perczak@camlingroup.com \
    --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

all inboxes | Powered by JetHome®