mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Hugo Villeneuve <hugo@hugovil.com>,
	hvilleneuve@dimonoff.com, jic23@kernel.org, lars@metafoo.de,
	robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] iio: adc: ti-ads7924: add Texas Instruments ADS7924 driver
Date: Tue, 10 Jan 2023 19:50:42 +0100	[thread overview]
Message-ID: <c4b5c190-5fb5-17f2-69ce-7137ef7f33db@wanadoo.fr> (raw)
In-Reply-To: <20230110160124.3853593-2-hugo@hugovil.com>

Le 10/01/2023 à 17:01, Hugo Villeneuve a écrit :
> From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> 
> The Texas Instruments ADS7924 is a 4 channels, 12-bit analog to
> digital converter (ADC) with an I2C interface.
> 
> Datasheet: https://www.ti.com/lit/gpn/ads7924
> 
> Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> ---

Hi,

should there be a v3, a few nits below.

CJ

>   MAINTAINERS                  |   7 +
>   drivers/iio/adc/Kconfig      |  11 +
>   drivers/iio/adc/Makefile     |   1 +
>   drivers/iio/adc/ti-ads7924.c | 492 +++++++++++++++++++++++++++++++++++
>   4 files changed, 511 insertions(+)
>   create mode 100644 drivers/iio/adc/ti-ads7924.c
> 

[...]

> +static int ads7924_get_channels_config(struct i2c_client *client,
> +				       struct iio_dev *indio_dev)
> +{
> +	struct ads7924_data *priv = iio_priv(indio_dev);
> +	struct device *dev = priv->dev;
> +	struct fwnode_handle *node;
> +	int num_channels = 0;
> +
> +	device_for_each_child_node(dev, node) {
> +		u32 pval;
> +		unsigned int channel;
> +
> +		if (fwnode_property_read_u32(node, "reg", &pval)) {
> +			dev_err(dev, "invalid reg on %pfw\n", node);
> +			continue;
> +		}
> +
> +		channel = pval;
> +		if (channel >= ADS7924_CHANNELS) {
> +			dev_err(dev, "invalid channel index %d on %pfw\n",
> +				channel, node);
> +			continue;
> +		}
> +
> +		num_channels++;
> +	}
> +
> +	if (num_channels > 0) {
> +		dev_dbg(dev, "found %d ADC channels\n", num_channels);
> +		return 0;
> +	} else {
> +		return -EINVAL;
> +	}

	if (num_channels <= 0)
		return -EINVAL;

	dev_dbg(dev, "found %d ADC channels\n", num_channels);
	return 0;

is much more usual.

> +}
> +

[...]

> +static int ads7924_reset(struct iio_dev *indio_dev)
> +{
> +	struct ads7924_data *data = iio_priv(indio_dev);
> +
> +	if (data->reset_gpio) {
> +		gpiod_set_value(data->reset_gpio, 1); /* Assert. */
> +		/* Educated guess: assert time not specified in datasheet... */
> +		mdelay(100);
> +		gpiod_set_value(data->reset_gpio, 0); /* Deassert. */
> +	} else {
> +		int ret;

having 'ret' near 'struct ads7924_data *data' is more usual and saves 1 LoC.

> +
> +		/*
> +		 * A write of 10101010 to this register will generate a
> +		 * software reset of the ADS7924.
> +		 */
> +		ret = regmap_write(data->regmap, ADS7924_RESET_REG, 0b10101010);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
> +};


  reply	other threads:[~2023-01-10 18:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 16:01 [PATCH v2 0/2] " Hugo Villeneuve
2023-01-10 16:01 ` [PATCH v2 1/2] " Hugo Villeneuve
2023-01-10 18:50   ` Christophe JAILLET [this message]
2023-01-11  0:23     ` Hugo Villeneuve
2023-01-10 23:09   ` kernel test robot
2023-01-12 19:00   ` Jonathan Cameron
2023-01-12 19:33     ` Hugo Villeneuve
2023-01-13 14:16       ` Jonathan Cameron
2023-01-12 19:38   ` Hugo Villeneuve
2023-01-12 19:39   ` Hugo Villeneuve
2023-01-10 16:01 ` [PATCH v2 2/2] dt-bindings: iio: adc: add Texas Instruments ADS7924 Hugo Villeneuve
2023-01-11  1:34   ` Rob Herring
2023-01-11 23:25     ` Hugo Villeneuve
2023-01-11  9:23   ` Krzysztof Kozlowski
2023-01-12  0:11     ` 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=c4b5c190-5fb5-17f2-69ce-7137ef7f33db@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=devicetree@vger.kernel.org \
    --cc=hugo@hugovil.com \
    --cc=hvilleneuve@dimonoff.com \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®