public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH v2 1/2] iio: dac: ad5755: make use of of_device_id table
Date: Mon, 26 Feb 2024 19:25:55 +0000	[thread overview]
Message-ID: <20240226192555.14aa178e@jic23-huawei> (raw)
In-Reply-To: <20240225201654.49450-1-krzysztof.kozlowski@linaro.org>

On Sun, 25 Feb 2024 21:16:53 +0100
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:

> Populate the of_device_id table with match data, reference it in the
> spi_driver struct and use spi_get_device_match_data() to perform the
> type matching to fix warning:
> 
>   ad5755.c:866:34: error: unused variable 'ad5755_of_match' [-Werror,-Wunused-const-variable]
> 
> This is also preferred way of matching device variants, then relying on
> fallback via spi_device_id.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---
> 
> Rework according to comments.
> 
> An old v1:
> https://lore.kernel.org/all/20230810111933.205619-1-krzysztof.kozlowski@linaro.org/
> ---
>  drivers/iio/dac/ad5755.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
> index 404865e35460..877c1125d892 100644
> --- a/drivers/iio/dac/ad5755.c
> +++ b/drivers/iio/dac/ad5755.c
> @@ -809,7 +809,7 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev)
>  
>  static int ad5755_probe(struct spi_device *spi)
>  {
> -	enum ad5755_type type = spi_get_device_id(spi)->driver_data;
> +	enum ad5755_type type = (kernel_ulong_t)spi_get_device_match_data(spi);
>  	const struct ad5755_platform_data *pdata;
>  	struct iio_dev *indio_dev;
>  	struct ad5755_state *st;
> @@ -864,11 +864,11 @@ static const struct spi_device_id ad5755_id[] = {
>  MODULE_DEVICE_TABLE(spi, ad5755_id);
>  
>  static const struct of_device_id ad5755_of_match[] = {
> -	{ .compatible = "adi,ad5755" },
> -	{ .compatible = "adi,ad5755-1" },
> -	{ .compatible = "adi,ad5757" },
> -	{ .compatible = "adi,ad5735" },
> -	{ .compatible = "adi,ad5737" },
> +	{ .compatible = "adi,ad5755", (void *)ID_AD5755 },
> +	{ .compatible = "adi,ad5755-1", (void *)ID_AD5755 },
> +	{ .compatible = "adi,ad5757", (void *)ID_AD5757 },
> +	{ .compatible = "adi,ad5735", (void *)ID_AD5735 },
> +	{ .compatible = "adi,ad5737", (void *)ID_AD5737 },
If the enum value is 0, what happens?  We ignore the return value and
check the other table - so still fragile :(

That's why I asked that these be pointers, not enum values...

>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, ad5755_of_match);
> @@ -876,6 +876,7 @@ MODULE_DEVICE_TABLE(of, ad5755_of_match);
>  static struct spi_driver ad5755_driver = {
>  	.driver = {
>  		.name = "ad5755",
> +		.of_match_table = ad5755_of_match,
>  	},
>  	.probe = ad5755_probe,
>  	.id_table = ad5755_id,


      parent reply	other threads:[~2024-02-26 19:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-25 20:16 [PATCH v2 1/2] iio: dac: ad5755: make use of of_device_id table Krzysztof Kozlowski
2024-02-25 20:16 ` [PATCH v2 2/2] iio: proximity: isl29501: " Krzysztof Kozlowski
2024-02-26 19:27   ` Jonathan Cameron
2024-02-26 19:25 ` Jonathan Cameron [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=20240226192555.14aa178e@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=justinstitt@google.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.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