mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh@nvidia.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mark Brown <broonie@kernel.org>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v1 1/2] spi: deduplicate spi_match_id() in __spi_register_driver()
Date: Tue, 23 Nov 2021 15:22:38 +0000	[thread overview]
Message-ID: <1572a2ff-dcfb-422f-c4c3-5a454a36d31d@nvidia.com> (raw)
In-Reply-To: <20211119173718.52938-1-andriy.shevchenko@linux.intel.com>

Hi Andy,

On 19/11/2021 17:37, Andy Shevchenko wrote:
> The same logic is used in spi_match_id() and in the __spi_register_driver().
> By switching the former from taking struct spi_device * to const char * as
> the second parameter we may deduplicate the code.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/spi/spi.c | 17 ++++++-----------
>   1 file changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index b23e675953e1..dfa06103150e 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -315,11 +315,10 @@ static void spi_statistics_add_transfer_stats(struct spi_statistics *stats,
>    * and the sysfs version makes coldplug work too.
>    */
>   
> -static const struct spi_device_id *spi_match_id(const struct spi_device_id *id,
> -						const struct spi_device *sdev)
> +static const struct spi_device_id *spi_match_id(const struct spi_device_id *id, const char *name)
>   {
>   	while (id->name[0]) {
> -		if (!strcmp(sdev->modalias, id->name))
> +		if (!strcmp(name, id->name))
>   			return id;
>   		id++;
>   	}
> @@ -330,7 +329,7 @@ const struct spi_device_id *spi_get_device_id(const struct spi_device *sdev)
>   {
>   	const struct spi_driver *sdrv = to_spi_driver(sdev->dev.driver);
>   
> -	return spi_match_id(sdrv->id_table, sdev);
> +	return spi_match_id(sdrv->id_table, sdev->modalias);
>   }
>   EXPORT_SYMBOL_GPL(spi_get_device_id);
>   
> @@ -352,7 +351,7 @@ static int spi_match_device(struct device *dev, struct device_driver *drv)
>   		return 1;
>   
>   	if (sdrv->id_table)
> -		return !!spi_match_id(sdrv->id_table, spi);
> +		return !!spi_match_id(sdrv->id_table, spi->modalias);
>   
>   	return strcmp(spi->modalias, drv->name) == 0;
>   }
> @@ -474,12 +473,8 @@ int __spi_register_driver(struct module *owner, struct spi_driver *sdrv)
>   			if (sdrv->id_table) {
>   				const struct spi_device_id *spi_id;
>   
> -				for (spi_id = sdrv->id_table; spi_id->name[0];
> -				     spi_id++)
> -					if (strcmp(spi_id->name, of_name) == 0)
> -						break;
> -
> -				if (spi_id->name[0])
> +				spi_id = spi_match_id(sdrv->id_table, of_name);
> +				if (!spi_id)
>   					continue;
>   			} else {
>   				if (strcmp(sdrv->driver.name, of_name) == 0)
> 


Following this change I am seeing the following warnings again although 
most of these have now been fixed ...

  WARNING KERN SPI driver mtd_dataflash has no spi_device_id for atmel,at45
  WARNING KERN SPI driver mtd_dataflash has no spi_device_id for 
atmel,dataflash
  WARNING KERN SPI driver spi-nor has no spi_device_id for jedec,spi-nor
  WARNING KERN SPI driver mmc_spi has no spi_device_id for mmc-spi-slot
  WARNING KERN SPI driver cros-ec-spi has no spi_device_id for 
google,cros-ec-spi

I have not looked any further yet, but this appears to cause the SPI ID 
match to fail.

Cheers
Jon

-- 
nvpublic

  parent reply	other threads:[~2021-11-23 15:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 17:37 Andy Shevchenko
2021-11-19 17:37 ` [PATCH v1 2/2] spi: Fix multi-line comment style Andy Shevchenko
2021-11-22 15:47   ` Mark Brown
2021-11-22 17:09     ` Andy Shevchenko
2021-11-22 17:15       ` Andy Shevchenko
2021-11-23  0:00 ` [PATCH v1 1/2] spi: deduplicate spi_match_id() in __spi_register_driver() Mark Brown
2021-11-23 15:22 ` Jon Hunter [this message]
2021-11-23 15:43   ` Andy Shevchenko
2021-11-23 16:51   ` Andy Shevchenko

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=1572a2ff-dcfb-422f-c4c3-5a454a36d31d@nvidia.com \
    --to=jonathanh@nvidia.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-tegra@vger.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

Powered by JetHome