devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: George Mois <george.mois@analog.com>, <jic23@kernel.org>,
	<robh+dt@kernel.org>, <krzysztof.kozlowski+dt@linaro.org>,
	<linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <lucas.p.stankus@gmail.com>
Subject: Re: [PATCH 2/2] drivers: iio: accel adxl312 and adxl314 support
Date: Tue, 16 Aug 2022 13:44:33 +0100	[thread overview]
Message-ID: <20220816134433.00002900@huawei.com> (raw)
In-Reply-To: <8cf4ea9e-89a4-1ab0-334b-9ecc5b1e6f25@linaro.org>

On Tue, 16 Aug 2022 14:16:13 +0300
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:

> On 16/08/2022 13:28, George Mois wrote:
> > ADXL312 and ADXL314 are small, thin, low power, 3-axis accelerometers
> > with high resolution (13-bit) measurement up to +/-12 g and +/- 200 g
> > respectively.
> >   
> 
> Thank you for your patch. There is something to discuss/improve.
> 
> >  
> >  static const struct spi_device_id adxl313_spi_id[] = {
> > -	{ "adxl313" },
> > +	{ "adxl312", ADXL312 },
> > +	{ "adxl313", ADXL313 },
> > +	{ "adxl314", ADXL314 },
> >  	{ }
> >  };
> >  
> >  MODULE_DEVICE_TABLE(spi, adxl313_spi_id);
> >  
> >  static const struct of_device_id adxl313_of_match[] = {
> > +	{ .compatible = "adi,adxl312" },
> >  	{ .compatible = "adi,adxl313" },
> > +	{ .compatible = "adi,adxl314" },  
> 
> You miss here driver data. I don't remember which driver matching takes
> precedence (especially in various cases like DT platforms with device
> instantiated by MFD), but for consistency I think both device id tables
> should have same driver data.

You can set it up to try device_get_match_data() first then fallback
to the adxl313_spi_id[] table but there isn't a nice 'standard' way to
do it.

If that isn't done, then IIRC the match is against the compatible with
the vendor ID dropped and the table used is the spi_device_id one.
Which is just annoyingly complex and relies on the strings matching.

In the ideal world the spi_device_id table would go away but there are
still a few users (greybus - I think + remaining board files).
So for now something like

a = device_get_match_data(dev);
if (!a)
	a = &adxl31x_spi_regmap_config[id->data];

Provides a good way of ensuring the id tables don't need to remain
in sync.

Jonathan


> 
> 
> Best regards,
> Krzysztof


  reply	other threads:[~2022-08-16 12:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 10:28 [PATCH 0/2] Add support for ADXL312 and ADXL314 accelerometers George Mois
2022-08-16 10:28 ` [PATCH 1/2] bindings: iio: accel: extend adxl313 documentation file George Mois
2022-08-16 11:14   ` Krzysztof Kozlowski
2022-08-16 10:28 ` [PATCH 2/2] drivers: iio: accel adxl312 and adxl314 support George Mois
2022-08-16 11:16   ` Krzysztof Kozlowski
2022-08-16 12:44     ` Jonathan Cameron [this message]
2022-08-16 13:34       ` Krzysztof Kozlowski
2022-08-16 13:40         ` Jonathan Cameron
2022-08-16 14:09   ` Jonathan Cameron
2022-08-18 10:11     ` Mois, George
2022-08-20 10:34       ` Jonathan Cameron
2022-08-16 16:21   ` kernel test robot
2022-08-16 16:31   ` kernel test robot

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=20220816134433.00002900@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=devicetree@vger.kernel.org \
    --cc=george.mois@analog.com \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.p.stankus@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).