From: Mike Looijmans <mike.looijmans@topic.nl>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: devicetree@vger.kernel.org, linux-iio@vger.kernel.org,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Caleb Connolly <caleb.connolly@linaro.org>,
ChiYuan Huang <cy_huang@richtek.com>,
ChiaEn Wu <chiaen_wu@richtek.com>,
Cosmin Tanislav <demonsingur@gmail.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Ibrahim Tilki <Ibrahim.Tilki@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Marcelo Schmitt <marcelo.schmitt1@gmail.com>,
Ramona Bolboaca <ramona.bolboaca@analog.com>,
William Breathitt Gray <william.gray@linaro.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: adc: Add driver for TI ADS1100 and ADS1000 chips
Date: Fri, 17 Feb 2023 16:10:49 +0100 [thread overview]
Message-ID: <b3fde4a8-e344-9d3d-0b1e-9a11c4dd09de@topic.nl> (raw)
In-Reply-To: <Y+9zR3bhlEMuma66@smile.fi.intel.com>
Thanks for your quick feedback. Replies below (skipping signature added
by borked mailserver)
I'll post a v2, want to do some testing first with the changes and I'll
have hardware access by the end of next week.
No further comment from me means I agree and will change as requested.
Met vriendelijke groet / kind regards,
Mike Looijmans
System Expert
TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands
T: +31 (0) 499 33 69 69
E: mike.looijmans@topicproducts.com
W: www.topic.nl
Please consider the environment before printing this e-mail
On 17-02-2023 13:29, Andy Shevchenko wrote:
> On Fri, Feb 17, 2023 at 10:31:28AM +0100, Mike Looijmans wrote:
>> The ADS1100 is a 16-bit ADC (at 8 samples per second).
>> The ADS1000 is similar, but has a fixed data rate.
> Any Datasheet link available?
Yes, will add a friendly link.
> ...
>
>> +static const int ads1100_data_rate[] = {128, 32, 16, 8};
>> +static const int ads1100_data_rate_scale[] = {2048, 8192, 16384, 32768};
>> +static const int ads1100_gain[] = {1, 2, 4, 8};
> Do you need all of them as tables? They all can be derived from a single table
> or without any table at all (just three values).
I think the "data_rate" tables make the driver smaller in size, it's not
a straight power-of-two list. I want them anyway for passing as "avail"
sequences.
The "gain" is a simple power-of-two and might be replaced with code, but
makes the "avail" more complex. Even in this case, the code to generate
the list will be larger than the list itself, and I need the list in
memory for the IIO_AVAIL function anyway.
> ...
>
>> +#ifdef CONFIG_PM
> Why?
I based this on the ADS1015 driver. Which appears to be outdated, I'll
convert to DEFINE_RUNTIME_DEV_PM_OPS
+ int ret;
>> + u8 buffer[2];
> __be16 buffer;
>
>> +
>> + if (chan != 0)
>> + return -EINVAL;
>> +
>> + ret = i2c_master_recv(data->client, buffer, sizeof(buffer));
>> + if (ret < 0) {
>> + dev_err(&data->client->dev, "I2C read fail: %d\n", ret);
>> + return ret;
>> + }
>> +
>> + *val = (s16)(((u16)buffer[0] << 8) | buffer[1]);
> (s16)be16_to_cpu();
>
> But (s16) looks suspicious. Should you use sign_extend32()?
The chip always returns a 16-bit 2's complement value, even when only 12
bits are actually used. I'll use sign_extend anyway, just to improve
readability and take away doubts such as these.
--
Mike Looijmans
next prev parent reply other threads:[~2023-02-17 15:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 9:31 [PATCH 1/2] dt-bindings: iio: adc: Add driver for TI ADS1100 and ADS1000 Mike Looijmans
2023-02-17 9:31 ` [PATCH 2/2] iio: adc: Add driver for TI ADS1100 and ADS1000 chips Mike Looijmans
2023-02-17 12:29 ` Andy Shevchenko
2023-02-17 15:10 ` Mike Looijmans [this message]
2023-02-18 16:48 ` Jonathan Cameron
2023-02-25 11:03 ` Mike Looijmans
2023-02-25 17:01 ` Jonathan Cameron
2023-02-26 8:24 ` Mike Looijmans
2023-02-26 12:53 ` Jonathan Cameron
2023-02-17 9:36 ` [PATCH 1/2] dt-bindings: iio: adc: Add driver for TI ADS1100 and ADS1000 Krzysztof Kozlowski
2023-02-17 14:17 ` Mike Looijmans
2023-02-17 13:47 ` Rob Herring
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=b3fde4a8-e344-9d3d-0b1e-9a11c4dd09de@topic.nl \
--to=mike.looijmans@topic.nl \
--cc=Ibrahim.Tilki@analog.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=caleb.connolly@linaro.org \
--cc=chiaen_wu@richtek.com \
--cc=cy_huang@richtek.com \
--cc=demonsingur@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--cc=ramona.bolboaca@analog.com \
--cc=william.gray@linaro.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