From: Slawomir Stepien <sst@poczta.fm>
To: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: potentiometer: add driver for Maxim Integrated DS1803
Date: Fri, 8 Apr 2016 19:06:06 +0200 [thread overview]
Message-ID: <20160408170606.GA20159@x220> (raw)
In-Reply-To: <alpine.DEB.2.02.1604081755420.8980@pmeerw.net>
On Apr 08, 2016 18:00, Peter Meerwald-Stadler wrote:
>
> > > maybe a #define to explain the name of register 0
> >
> > Well this zero is not register nor any kind of command that DS1803 needs to send
> > back pots values.
> > DS1803 only requires the standard R/W bit to be set as read.
> > I used _word_ function series to get back a word (16 bits) as this poti returns
> > 16 bits.
> >
> > How should I named it?
> >
> > #define NON_COMMAND 0
> > ?
>
> maybe i2c_transfer() is more appropriate then
>
> u8 databuf[2];
> struct i2c_msg msgs[2] = {
> { .addr = client->addr, .len = sizeof(databuf), .buf = databuf,
> .flags = I2C_M_RD } };
> ret = i2c_transfer(client->adapter, msgs, 2);
>
> this does not send any data to the chip but only reads two bytes
Good point. But maybe the better solution would be to use i2c_master_recv?
Anyhow I will check both options ;)
> > Or should I use different function? (2x i2c_smbus_read_byte?)
> >
> > The i2c_smbus_read_byte() function also used 0 as command
> > for its transfers...
>
> > > > +static int ds1803_write_raw(struct iio_dev *indio_dev,
> > > > + struct iio_chan_spec const *chan,
> > > > + int val, int val2, long mask)
> > > > +{
> > > > + struct ds1803_data *data = iio_priv(indio_dev);
> > > > + int pot = chan->channel;
> > > > +
> > > > + switch (mask) {
> > > > + case IIO_CHAN_INFO_RAW:
> > > > + if (val > DS1803_MAX_POS || val < 0)
> > >
> > > check that val2 is 0 or use .write_raw_get_fmt
> >
> > At this point I do not know why should I do it, but I will look into that.
>
> write_raw expects a VAL_INT_PLUS_MICROS per default, passed
> in val and val2
>
> you can change that with .write_raw_get_fmt (e.g. to expect VAL_INT),
> or just make sure that the micros are 0
Thank you for the explanation.
--
Slawomir Stepien
prev parent reply other threads:[~2016-04-08 17:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 16:51 [PATCH] iio: potentiometer: add driver for Maxim Integrated DS1803 Slawomir Stepien
2016-04-07 19:36 ` Peter Meerwald-Stadler
2016-04-08 15:28 ` Slawomir Stepien
2016-04-08 16:00 ` Peter Meerwald-Stadler
2016-04-08 17:06 ` Slawomir Stepien [this message]
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=20160408170606.GA20159@x220 \
--to=sst@poczta.fm \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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;
as well as URLs for NNTP newsgroup(s).