From: Jonathan Cameron <jic23@kernel.org>
To: Mugilraj Dhavachelvan <dmugil2000@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Dragos.Bogdan@analog.com, Darius.Berghe@analog.com,
Rob Herring <robh+dt@kernel.org>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Guenter Roeck <linux@roeck-us.net>,
Chris Packham <chris.packham@alliedtelesis.co.nz>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Alexandru Ardelean <alexandru.ardelean@analog.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: potentiometer: Add driver support for AD5110
Date: Sun, 8 Aug 2021 17:22:57 +0100 [thread overview]
Message-ID: <20210808172257.59b13400@jic23-huawei> (raw)
In-Reply-To: <66d670d6-0374-88ae-c4c1-efd60b54bbd2@gmail.com>
On Sat, 7 Aug 2021 23:04:18 +0530
Mugilraj Dhavachelvan <dmugil2000@gmail.com> wrote:
> Sorry some formatting issues happened in my previous mail.
>
> On 07/08/21 10:56 pm, Mugilraj Dhavachelvan wrote:
> >
> >
> > On 07/08/21 5:41 pm, Lars-Peter Clausen wrote:
> >> On 8/7/21 7:08 AM, Mugilraj Dhavachelvan wrote:
> >>> The AD5110/AD5112/AD5114 provide a nonvolatile solution
> >>> for 128-/64-/32-position adjustment applications, offering
> >>> guaranteed low resistor tolerance errors of ±8% and up to
> >>> ±6 mA current density.
> >>>
> >>> Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD5110_5112_5114.pdf
> >>> Signed-off-by: Mugilraj Dhavachelvan <dmugil2000@gmail.com>
> >>
> >> Thanks for the patch. This looks really good>
> >>
>
...
> >>> +
> >>> +static IIO_DEVICE_ATTR(wiper_pos_eeprom, 0644,
> >>> + ad5110_eeprom_read,
> >>> + ad5110_eeprom_write, 0);
> >> This is new custom ABI and needs to be documented
We have existing similar ABI in dac/mcp4725 which is simply
called store_eeprom
It's in the main docs
Documentation/ABI/testing/sysfs-bus-iio as storing
device configuration. I'm guessing this device doesn't have
other configuration so that description will work?
>
> > I'm not aware of this, fixed in v2.
> >>> +static int ad5110_write_raw(struct iio_dev *indio_dev,
> >>> + struct iio_chan_spec const *chan,
> >>> + int val, int val2, long mask)
> >>> +{
> >>> + struct ad5110_data *data = iio_priv(indio_dev);
> >>> + int ret;
> >>> +
> >>> + switch (mask) {
> >>> + case IIO_CHAN_INFO_RAW:
> >>> + if (val >= data->cfg->max_pos || val < 0)
> >> val == data->cfg->max_pos is a valid setting. Writing max_pos puts it in top-scale mode which gives maximum resistance.
> > Fixed in v2.
> >>> + return -EINVAL;
> >>> +
> >>> + return ad5110_write(data, AD5110_RDAC_WR, val << data->cfg->shift);
> >>> + case IIO_CHAN_INFO_ENABLE:
> >>> + if (val < 0 || val > 1)
> >>> + return -EINVAL;
> >>> + if (data->enable == val)
> >>> + return 0;
> >>> + ret = ad5110_write(data, AD5110_SHUTDOWN, val);
> >> Doesn't val have to be inverted to get the right behavior
>
> > I just replicated the datasheet operation.
> > You mean,
> > 1 - shutdown off
> > 0 - shutdown on
> > If yes, then the user won't get confused with the datasheet and the behavior of the driver?
> > Or Is it work like this? But yeah even I like this change it's more convenient.
ABI has to be consistent and writing an enable attribute with 1 has to mean enabling it whatever
approach the datasheet takes to describe things. Most users don't read
datasheets so interface needs to be intuitive.
> >>> + if (ret)
> >>> + return ret;
> >>> + data->enable = val;
> >>> + return 0;
> >>> + default:
> >>> + return -EINVAL;
> >>> + }
> >>> +}
> >> [...]
> > Thanks for feedback!!
> >
next prev parent reply other threads:[~2021-08-08 16:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-07 5:08 [PATCH 0/2] iio: potentiometer: Add driver support for AD5110 Mugilraj Dhavachelvan
2021-08-07 5:08 ` [PATCH 1/2] dt-bindings: iio: potentiometer: Add AD5110 in trivial-devices Mugilraj Dhavachelvan
2021-08-07 5:08 ` [PATCH 2/2] iio: potentiometer: Add driver support for AD5110 Mugilraj Dhavachelvan
2021-08-07 12:11 ` Lars-Peter Clausen
2021-08-07 17:26 ` Mugilraj Dhavachelvan
2021-08-07 17:34 ` Mugilraj Dhavachelvan
2021-08-08 16:22 ` Jonathan Cameron [this message]
2021-08-07 12:17 ` Lars-Peter Clausen
2021-08-07 17:28 ` Mugilraj Dhavachelvan
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=20210808172257.59b13400@jic23-huawei \
--to=jic23@kernel.org \
--cc=Darius.Berghe@analog.com \
--cc=Dragos.Bogdan@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandru.ardelean@analog.com \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=devicetree@vger.kernel.org \
--cc=dmugil2000@gmail.com \
--cc=krzk@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--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