devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Cosmin Tanislav <cosmin.tanislav@analog.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/5] iio: addac: ad74413r: add spi_device_id table
Date: Sat, 12 Nov 2022 16:50:49 +0000	[thread overview]
Message-ID: <20221112165049.51a5f391@jic23-huawei> (raw)
In-Reply-To: <20221111143921.742194-2-linux@rasmusvillemoes.dk>

On Fri, 11 Nov 2022 15:39:17 +0100
Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:

> Silence the run-time warning
> 
>   SPI driver ad74413r has no spi_device_id for adi,ad74412r
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
>  drivers/iio/addac/ad74413r.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
> index 899bcd83f40b..37485be88a63 100644
> --- a/drivers/iio/addac/ad74413r.c
> +++ b/drivers/iio/addac/ad74413r.c
> @@ -1457,12 +1457,20 @@ static const struct of_device_id ad74413r_dt_id[] = {
>  };
>  MODULE_DEVICE_TABLE(of, ad74413r_dt_id);
>  
> +static const struct spi_device_id ad74413r_spi_id[] = {
> +	{ .name = "ad74412r", .driver_data = (kernel_ulong_t)&ad74412r_chip_info_data },
> +	{ .name = "ad74413r", .driver_data = (kernel_ulong_t)&ad74413r_chip_info_data },
> +	{},
Trivial, but prefer not to have a comma after a "NULL" terminator like this.
It would never make sense to add anything after it in the array.
Now you are matching existing driver style, but I'd still rather not see more
instances of this added.

Also, driver_data is not currently used. It should be because adding this
spi_id table means the driver can be probed via various routes where
device_get_match_data() == NULL. 

Hence, alongside this change you need to have a fallback to cover that case.
Something along the lines of...

	st->chip_info = device_get_match_data(..);
	if (!st->chip_info) {
		struct spi_device_id *id = spi_get_device_id();
		if (!id)
			return -EINVAL;

		st->chip_info = (void *)id->driver_data;
		//or better yet cast to the correct type I'm just too lazy to look it up ;)
		if (!st->chip_info)
			return -EINVAL;

	}
> +};
> +MODULE_DEVICE_TABLE(spi, ad74413r_spi_id);
> +
>  static struct spi_driver ad74413r_driver = {
>  	.driver = {
>  		   .name = "ad74413r",
>  		   .of_match_table = ad74413r_dt_id,
>  	},
>  	.probe = ad74413r_probe,
> +	.id_table = ad74413r_spi_id,
>  };
>  
>  module_driver(ad74413r_driver,


  reply	other threads:[~2022-11-12 16:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11 14:39 [PATCH 0/5] iio: addac: ad74413r: various fixups Rasmus Villemoes
2022-11-11 14:39 ` [PATCH 1/5] iio: addac: ad74413r: add spi_device_id table Rasmus Villemoes
2022-11-12 16:50   ` Jonathan Cameron [this message]
2022-11-14  8:02     ` Rasmus Villemoes
2022-11-14 19:39       ` Jonathan Cameron
2022-11-11 14:39 ` [PATCH 2/5] dt-bindings: iio: ad74413r: make refin-supply optional Rasmus Villemoes
2022-11-12 16:54   ` Jonathan Cameron
2022-11-14  8:10     ` Rasmus Villemoes
2022-11-11 14:39 ` [PATCH 3/5] iio: addac: ad74413r: implement support for optional refin-supply Rasmus Villemoes
2022-11-12 16:56   ` Jonathan Cameron
2022-11-11 14:39 ` [PATCH 4/5] dt-bindings: iio: ad74413r: add optional reset-gpios Rasmus Villemoes
2022-11-12 17:00   ` Jonathan Cameron
2022-11-11 14:39 ` [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio Rasmus Villemoes
2022-11-12 17:07   ` Jonathan Cameron
2022-11-14  8:37     ` Rasmus Villemoes
2022-11-14 19:41       ` Jonathan Cameron
2022-11-14 13:52     ` Tanislav, Cosmin
2022-11-14 19:44       ` Jonathan Cameron
2022-11-15 14:49         ` Nuno Sá
2022-11-15 16:10           ` Jonathan Cameron
2022-11-15 19:10             ` Rasmus Villemoes
2022-11-16 10:22               ` Jonathan Cameron
2022-11-16 12:06                 ` Nuno Sá
2022-11-18 11:21                 ` Rasmus Villemoes
2022-11-15 14:53   ` Nuno Sá
2022-11-15  9:55 ` [PATCH v2 0/3] iio: addac: ad74413r: add spi device id table, support reset gpio Rasmus Villemoes
2022-11-15  9:55   ` [PATCH v2 1/3] iio: addac: ad74413r: add spi_device_id table Rasmus Villemoes
2022-11-15  9:55   ` [PATCH v2 2/3] dt-bindings: iio: ad74413r: add optional reset-gpios Rasmus Villemoes
2022-11-15 10:12     ` Krzysztof Kozlowski
2022-11-15  9:55   ` [PATCH v2 3/3] iio: addac: ad74413r: add support for reset-gpio Rasmus Villemoes
2022-11-23 20:55   ` [PATCH v2 0/3] iio: addac: ad74413r: add spi device id table, support reset gpio Jonathan Cameron

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=20221112165049.51a5f391@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=cosmin.tanislav@analog.com \
    --cc=devicetree@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --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).