[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20231121111504.6fca4b22bd6d3cc05c6fb668@hugovil.com>
Date: Tue, 21 Nov 2023 11:15:04 -0500
From: Hugo Villeneuve <hugo@...ovil.com>
To: Jiri Slaby <jirislaby@...nel.org>
Cc: gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org, lech.perczak@...lingroup.com,
Hugo Villeneuve <hvilleneuve@...onoff.com>
Subject: Re: [PATCH v2 1/1] serial: sc16is7xx: improve regmap debugfs by
using one regmap per port
On Tue, 21 Nov 2023 06:57:56 +0100
Jiri Slaby <jirislaby@...nel.org> wrote:
> On 20. 11. 23, 17:39, Hugo Villeneuve wrote:
> > From: Hugo Villeneuve <hvilleneuve@...onoff.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.
Hi Jiri,
are VLA now allowed in kernel code?
> > + 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, ®cfg);
> > + 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, ®cfg);
>
> 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.
devtype->nr_uart is coming from const struct sc16is7xx_devtype, so it
is always a constant, do we need an assert in this case?
Hugo.
> thanks,
> --
> js
> suse labs
>
>
Powered by blists - more mailing lists