From: Jonathan Cameron <jic23@kernel.org>
To: Marek Vasut <marex@denx.de>
Cc: linux-iio@vger.kernel.org, Andy Shevchenko <andy@kernel.org>,
Daniel Baluta <daniel.baluta@nxp.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v4 10/10] iio: adc: ti-ads1015: Switch to read_avail
Date: Mon, 28 Mar 2022 17:52:37 +0100 [thread overview]
Message-ID: <20220328175237.46f624ab@jic23-huawei> (raw)
In-Reply-To: <2a5699df-51b0-de6f-6651-b0e0eefd8667@denx.de>
On Mon, 28 Mar 2022 02:31:32 +0200
Marek Vasut <marex@denx.de> wrote:
> On 3/27/22 17:18, Jonathan Cameron wrote:
> > On Tue, 22 Mar 2022 23:02:10 +0100
> > Marek Vasut <marex@denx.de> wrote:
> >
> >> Replace sysfs attributes with read_avail() callback. This also permits
> >> removal of ads1115_info, since the scale attribute tables are now part
> >> of chip data.
> >>
> >> Signed-off-by: Marek Vasut <marex@denx.de>
> >> Cc: Andy Shevchenko <andy@kernel.org>
> >> Cc: Daniel Baluta <daniel.baluta@nxp.com>
> >> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > Sorry, I didn't catch your question on v3 about why I was advocating
> > signed.
> >
> > You are passing pointers to those arrays as signed in the
> > read_avail.
> >
> > Obviously you can 'get away with it' because the values are small
> > positive numbers and hence in 2's complement the data representation
> > will be the same. Not pretty though so my inclination would
> > be to keep them signed everywhere.
> >
> > If you are fine with that change I can change it whilst applying if
> > nothing else comes up in review.
>
> I'm fine with it, although I did switch them all to unsigned int in this
> V4 (unless I'm missing something still).
You switched to unsigned int, but...
+static int ads1015_read_avail(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ const int **vals, int *type, int *length,
+ long mask)
+{
+ struct ads1015_data *data = iio_priv(indio_dev);
+
+ if (chan->type != IIO_VOLTAGE)
+ return -EINVAL;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SCALE:
+ *type = IIO_VAL_FRACTIONAL_LOG2;
+ *vals = data->chip->scale;
This then uses them as signed integers. Which as mentioned is
technically not a bug, but that's only because the numbers
are small.. So better to go signed throughout.
+ *length = data->chip->scale_len;
+ return IIO_AVAIL_LIST;
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ *type = IIO_VAL_INT;
+ *vals = data->chip->data_rate;
+ *length = data->chip->data_rate_len;
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
+
next prev parent reply other threads:[~2022-03-28 16:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 22:02 [PATCH v4 01/10] dt-bindings: iio: adc: ti,ads1015: Add missing ADS1115 compatible string Marek Vasut
2022-03-22 22:02 ` [PATCH v4 02/10] dt-bindings: iio: adc: ti,ads1015: Add TLA2024 " Marek Vasut
2022-03-22 22:02 ` [PATCH v4 03/10] iio: adc: ti-ads1015: Switch to static const writeable ranges table Marek Vasut
2022-03-22 22:02 ` [PATCH v4 04/10] iio: adc: ti-ads1015: Deduplicate channel macros Marek Vasut
2022-03-22 22:02 ` [PATCH v4 05/10] iio: adc: ti-ads1015: Make channel event_spec optional Marek Vasut
2022-03-22 22:02 ` [PATCH v4 06/10] iio: adc: ti-ads1015: Add TLA2024 support Marek Vasut
2022-03-22 22:02 ` [PATCH v4 07/10] iio: adc: ti-ads1015: Add static assert to test if shifted realbits fit into storagebits Marek Vasut
2022-03-22 22:02 ` [PATCH v4 08/10] iio: adc: ti-ads1015: Convert to OF match data Marek Vasut
2022-03-22 22:02 ` [PATCH v4 09/10] iio: adc: ti-ads1015: Replace data_rate with chip data struct ads1015_data Marek Vasut
2022-03-22 22:02 ` [PATCH v4 10/10] iio: adc: ti-ads1015: Switch to read_avail Marek Vasut
2022-03-27 15:18 ` Jonathan Cameron
2022-03-27 19:33 ` Andy Shevchenko
2022-03-28 0:31 ` Marek Vasut
2022-03-28 16:52 ` Jonathan Cameron [this message]
2022-03-28 16:50 ` Marek Vasut
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=20220328175237.46f624ab@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=andy@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=linux-iio@vger.kernel.org \
--cc=marex@denx.de \
/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