From: Lars-Peter Clausen <lars@metafoo.de>
To: Matt Ranostay <mranostay@gmail.com>
Cc: "Marek Vašut" <marex@denx.de>, "Matt Porter" <matt@ohporter.com>,
"Pantelis Antoniou" <pantelis.antoniou@gmail.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 2/2] iio: proximity: add support for PulsedLight LIDAR
Date: Mon, 03 Aug 2015 10:00:29 +0200 [thread overview]
Message-ID: <55BF1F9D.30207@metafoo.de> (raw)
In-Reply-To: <CAKzfze_ZNeSBo_hKn4ju1uNM4iyaFrvGo89Dv_80DK3Tfb24yg@mail.gmail.com>
On 08/02/2015 11:28 PM, Matt Ranostay wrote:
> On Sun, Aug 2, 2015 at 2:42 AM, Lars-Peter Clausen <lars@metafoo.de> wrote:
>> On 08/01/2015 05:58 AM, Matt Ranostay wrote:
>> [...]
>>> +
>>> +struct lidar_data {
>>> + struct mutex lock;
>>> + struct iio_dev *indio_dev;
>>> + struct i2c_client *client;
>>> +
>>> + /* config */
>>> + int calib_bias;
>>> +
>>> + u16 buffer[5]; /* 2 byte distance + 8 byte timestamp */
>>
>> Needs to be in its own cacheline to avoid issues if the I2C controller is
>> using DMA.
>
> Ah though this was only needed for SPI.
At least some I2C master drivers directly use the buffer for DMA. But I was
being stupid here anyway, you don't actually pass the buffer itself to the
I2C transfer functions so everything is fine as it was.
>
>>
>> u16 buffer[5] ____cacheline_aligned;
>>
>>> +};
>> [...]
>>> +static inline int lidar_read_byte(struct lidar_data *data, int reg)
>>
>> I'd drop the inline. The compiler is smart enough to figure out whether it
>> makes sense to inline it or not.
>>
> Got it.
>
>>> +{
>>> + struct i2c_client *client = data->client;
>>> + int ret;
>>> +
>>> + ret = i2c_smbus_write_byte(client, reg);
>>> + if (ret < 0) {
>>> + dev_err(&client->dev, "cannot write addr value");
>>> + return ret;
>>> + }
>>> +
>>> + ret = i2c_smbus_read_byte(client);
>>> + if (ret < 0) {
>>> + dev_err(&client->dev, "cannot read data value");
>>> + return ret;
>>> + }
>>
>> Instead of using a write_byte/read_byte combination rather use
>> i2c_smbus_read_byte_data(). I think that will do the same, but in one atomic
>> operation.
> Yes I would normally do that but this device doesn't seem to support
> that functionally, always returns zeros.
That's an interesting device. Maybe add a comment explaining the oddity. I'm
sure I'm not the only one who'll wonder about this.
[...]
>>> +static struct i2c_driver lidar_driver = {
>>> + .driver = {
>>> + .name = LIDAR_DRV_NAME,
>>> + .owner = THIS_MODULE,
>>
>> You added a DT vendor prefix, but there is no of match table for the driver.
>
> So without of_match_table it isn't needed to have a vendor id?
> "pulsedlight,lidar" maps to the i2c_device_id
I thinking the other way around. If you intend to instantiate the device via
devicetree it is better to explicit add a of_device_id table rather than
relying on the implicit mechanism that uses i2c_device_id.
You should also add an entry for the device to
Documentation/devicetree/bindings/i2c/trivial-devices.txt
next prev parent reply other threads:[~2015-08-03 8:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-01 3:58 [PATCH 0/2] iio: proximity: add PulsedLight LIDAR sensor support Matt Ranostay
2015-08-01 3:58 ` [PATCH 1/2] devicetree: add PulsedLight vendor prefix Matt Ranostay
2015-08-01 3:58 ` [PATCH 2/2] iio: proximity: add support for PulsedLight LIDAR Matt Ranostay
2015-08-01 8:39 ` Vladimir Barinov
2015-08-01 21:17 ` Jonathan Cameron
2015-08-01 22:22 ` Matt Ranostay
2015-08-02 7:36 ` Vladimir Barinov
2015-08-02 18:18 ` Jonathan Cameron
2015-08-02 9:42 ` Lars-Peter Clausen
2015-08-02 18:23 ` Jonathan Cameron
2015-08-02 18:39 ` Lars-Peter Clausen
2015-08-02 19:52 ` Jonathan Cameron
2015-08-02 21:28 ` Matt Ranostay
2015-08-03 8:00 ` Lars-Peter Clausen [this message]
2015-08-03 8:19 ` Matt Ranostay
2015-08-02 9:45 ` Lars-Peter Clausen
-- strict thread matches above, loose matches on Subject: below --
2015-08-12 6:01 [PATCH v5 0/2] iio: proximity: add PulsedLight LIDAR sensor support Matt Ranostay
2015-08-12 6:01 ` [PATCH 2/2] iio: proximity: add support for PulsedLight LIDAR Matt Ranostay
2015-08-16 8:24 ` Jonathan Cameron
2015-08-18 2:33 ` Matt Ranostay
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=55BF1F9D.30207@metafoo.de \
--to=lars@metafoo.de \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=marex@denx.de \
--cc=matt@ohporter.com \
--cc=mranostay@gmail.com \
--cc=pantelis.antoniou@gmail.com \
/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).