Devicetree
 help / color / mirror / Atom feed
From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Marcelo Schmitt <marcelo.schmitt@analog.com>,
	apw@canonical.com, joe@perches.com, dwaipayanray1@gmail.com,
	lukas.bulwahn@gmail.com, paul.cercueil@analog.com,
	Michael.Hennerich@analog.com, lars@metafoo.de,
	robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	conor+dt@kernel.org, dan.carpenter@linaro.org,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 12/13] iio: adc: Add support for AD7091R-8
Date: Sun, 10 Dec 2023 16:54:21 -0300	[thread overview]
Message-ID: <ZXYXbYyb6sYbJQqE@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <20231210123343.2695a9dc@jic23-huawei>

Hi Jonathan,

Thank you for all comments to this set.
Will do the changes and send v4.

Thanks,
Marcelo

On 12/10, Jonathan Cameron wrote:
> On Thu, 7 Dec 2023 15:42:56 -0300
> Marcelo Schmitt <marcelo.schmitt@analog.com> wrote:
> 
> > Add support for Analog Devices AD7091R-2, AD7091R-4, and AD7091R-8
> > low power 12-Bit SAR ADCs with SPI interface.
> > Extend ad7091r-base driver so it can be used by the AD7091R-8 driver.
> > 
> > Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
> 
> A few trivial things inline.
> Otherwise looks pretty good to me.
> 
> Jonathan
> > diff --git a/drivers/iio/adc/ad7091r8.c b/drivers/iio/adc/ad7091r8.c
> > new file mode 100644
> > index 000000000000..8dc0f784913b
> > --- /dev/null
> > +++ b/drivers/iio/adc/ad7091r8.c
> > @@ -0,0 +1,261 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Analog Devices AD7091R8 12-bit SAR ADC driver
> > + *
> > + * Copyright 2023 Analog Devices Inc.
> > + */
> > +
> > +#include <linux/bitfield.h>
> > +#include <linux/iio/iio.h>
> > +#include <linux/module.h>
> > +#include <linux/regmap.h>
> > +#include <linux/gpio/consumer.h>
> > +#include <linux/spi/spi.h>
> > +
> > +#include "ad7091r-base.h"
> > +
> > +#define AD7091R8_REG_ADDR_MSK				GENMASK(15, 11)
> > +#define AD7091R8_RD_WR_FLAG_MSK				BIT(10)
> > +#define AD7091R8_REG_DATA_MSK				GENMASK(9, 0)
> > +
> > +#define AD7091R2_DEV_NAME				"ad7091r-2"
> > +#define AD7091R4_DEV_NAME				"ad7091r-4"
> > +#define AD7091R8_DEV_NAME				"ad7091r-8"
> Not seeing any advantage in these macros.  It will be more readable to just
> have the strings inline where the macros are currently used.
> 
> > +static int ad7091r8_gpio_setup(struct ad7091r_state *st)
> > +{
> > +	st->convst_gpio = devm_gpiod_get(st->dev, "adi,conversion-start",
> > +					 GPIOD_OUT_LOW);
> > +	if (IS_ERR(st->convst_gpio))
> > +		return dev_err_probe(st->dev, PTR_ERR(st->convst_gpio),
> > +				     "Error getting convst GPIO\n");
> > +
> > +	st->reset_gpio =  devm_gpiod_get_optional(st->dev, "reset",
> > +						  GPIOD_OUT_HIGH);
> > +	if (IS_ERR(st->reset_gpio))
> > +		return PTR_ERR(st->reset_gpio);
> Maybe a dev_err_probe() here as well both for consistency and for the
> debug info that gets stashed if it's EPROBE_DEFER
> > +
> > +	if (st->reset_gpio) {
> > +		fsleep(20);
> > +		gpiod_set_value_cansleep(st->reset_gpio, 0);
> > +	}
> > +
> > +	return 0;
> > +}
> 
> > +
> > +static struct ad7091r_init_info ad7091r2_init_info = {
> > +	.info_no_irq = AD7091R_SPI_CHIP_INFO(2),
> > +	.regmap_config = &ad7091r2_reg_conf,
> > +	.ad7091r_regmap_init = &ad7091r8_regmap_init,
> > +	.ad7091r_setup = &ad7091r8_gpio_setup
> > +};
> > +
> > +static struct ad7091r_init_info ad7091r4_init_info = {
> > +	.irq_info = AD7091R_SPI_CHIP_INFO_IRQ(4),
> > +	.info_no_irq = AD7091R_SPI_CHIP_INFO(4),
> > +	.regmap_config = &ad7091r4_reg_conf,
> > +	.ad7091r_regmap_init = &ad7091r8_regmap_init,
> > +	.ad7091r_setup = &ad7091r8_gpio_setup
> > +};
> > +
> > +static struct ad7091r_init_info ad7091r8_init_info = {
> > +	.irq_info = AD7091R_SPI_CHIP_INFO_IRQ(8),
> > +	.info_no_irq = AD7091R_SPI_CHIP_INFO(8),
> > +	.regmap_config = &ad7091r8_reg_conf,
> > +	.ad7091r_regmap_init = &ad7091r8_regmap_init,
> > +	.ad7091r_setup = &ad7091r8_gpio_setup
> > +};
> > +
> > +static int ad7091r8_spi_probe(struct spi_device *spi)
> > +{
> > +	const struct spi_device_id *id = spi_get_device_id(spi);
> > +	const struct ad7091r_init_info *init_info;
> > +
> > +	init_info = spi_get_device_match_data(spi);
> > +	if (!init_info)
> > +		return -EINVAL;
> > +
> > +	return ad7091r_probe(&spi->dev, id->name, init_info, NULL, spi->irq);
> id->name isn't generally a good idea because we end up with lots of odd corner
> cases if the of_device_id and spi_device_id tables get out of sync - which
> can happen if fallback compatibles get used.
> 
> Normal way round this is just put the naming of the device in the
> info structure.  Costs a little storage, but makes the code simpler
> and less probe to odd corner cases.  Also, I think you already have it
> in there!
> 
> > +}
> > +
> > +static const struct of_device_id ad7091r8_of_match[] = {
> > +	{ .compatible = "adi,ad7091r2", .data = &ad7091r2_init_info },
> > +	{ .compatible = "adi,ad7091r4", .data = &ad7091r4_init_info },
> > +	{ .compatible = "adi,ad7091r8", .data = &ad7091r8_init_info },
> > +	{ }
> > +};
> > +MODULE_DEVICE_TABLE(of, ad7091r8_of_match);
> > +
> > +static const struct spi_device_id ad7091r8_spi_id[] = {
> > +	{ "ad7091r2", (kernel_ulong_t)&ad7091r2_init_info },
> > +	{ "ad7091r4", (kernel_ulong_t)&ad7091r4_init_info },
> > +	{ "ad7091r8", (kernel_ulong_t)&ad7091r8_init_info },
> > +	{}
> Trivial but be consistent on spacing for these terminators.  I like a space, so
> { } but I don't mind if an author prefers {} as long as they are consistent!
> 
> > +};
> > +MODULE_DEVICE_TABLE(spi, ad7091r8_spi_id);
> 

  reply	other threads:[~2023-12-10 19:54 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 18:35 [PATCH v3 00/13] Add support for AD7091R-2/-4/-8 Marcelo Schmitt
2023-12-07 18:37 ` [PATCH v3 01/13] scripts: checkpatch: Add __aligned to the list of attribute notes Marcelo Schmitt
2023-12-07 18:56   ` Joe Perches
2023-12-08 12:21     ` Marcelo Schmitt
2023-12-07 18:37 ` [PATCH v3 02/13] iio: adc: ad7091r: Populate device driver data field Marcelo Schmitt
2023-12-07 23:18   ` David Lechner
2023-12-08 12:16     ` Marcelo Schmitt
2023-12-07 18:38 ` [PATCH v3 03/13] iio: adc: ad7091r: Set alert bit in config register Marcelo Schmitt
2023-12-10 12:13   ` Jonathan Cameron
2023-12-07 18:39 ` [PATCH v3 04/13] iio: adc: ad7091r: Align arguments to function call parenthesis Marcelo Schmitt
2023-12-07 18:40 ` [PATCH v3 05/13] iio: adc: ad7091r: Move generic AD7091R code to base driver and header file Marcelo Schmitt
2023-12-07 18:40 ` [PATCH v3 06/13] iio: adc: ad7091r: Move chip init data to container struct Marcelo Schmitt
2023-12-08 12:28   ` [PATCH v3 6/13] " kernel test robot
2023-12-07 18:41 ` [PATCH v3 07/13] iio: adc: ad7091r: Set device mode through chip_info callback Marcelo Schmitt
2023-12-10 12:35   ` Jonathan Cameron
2023-12-07 18:41 ` [PATCH v3 08/13] iio: adc: ad7091r: Enable internal vref if external vref is not supplied Marcelo Schmitt
2023-12-10 12:22   ` Jonathan Cameron
2023-12-07 18:41 ` [PATCH v3 09/13] iio: adc: ad7091r: Add chip_info callback to get conversion result channel Marcelo Schmitt
2023-12-07 18:42 ` [PATCH v3 10/13] dt-bindings: iio: Add AD7091R-8 Marcelo Schmitt
2023-12-07 23:56   ` David Lechner
2023-12-08 13:28     ` Marcelo Schmitt
2023-12-08 14:50       ` David Lechner
2023-12-10 12:26       ` Jonathan Cameron
2023-12-08  8:05   ` Krzysztof Kozlowski
2023-12-08 13:29     ` Marcelo Schmitt
2023-12-07 18:42 ` [PATCH v3 11/13] iio: adc: Split AD7091R-5 config symbol Marcelo Schmitt
2023-12-07 18:42 ` [PATCH v3 12/13] iio: adc: Add support for AD7091R-8 Marcelo Schmitt
2023-12-10 12:33   ` Jonathan Cameron
2023-12-10 19:54     ` Marcelo Schmitt [this message]
2023-12-07 18:43 ` [PATCH v3 13/13] MAINTAINERS: Add MAINTAINERS entry for AD7091R Marcelo Schmitt
2023-12-07 18:58   ` Joe Perches
2023-12-08 12:12     ` Marcelo Schmitt
2023-12-07 23:26 ` [PATCH v3 00/13] Add support for AD7091R-2/-4/-8 David Lechner
2023-12-08 13:50   ` Marcelo Schmitt

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=ZXYXbYyb6sYbJQqE@debian-BULLSEYE-live-builder-AMD64 \
    --to=marcelo.schmitt1@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=apw@canonical.com \
    --cc=conor+dt@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dwaipayanray1@gmail.com \
    --cc=jic23@kernel.org \
    --cc=joe@perches.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=marcelo.schmitt@analog.com \
    --cc=paul.cercueil@analog.com \
    --cc=robh+dt@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