All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] hwmon: (lm70) Use device_get_match_data()
@ 2021-01-28 21:57 Rob Herring
  2021-01-28 22:12 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2021-01-28 21:57 UTC (permalink / raw
  To: Stephen Boyd, Guenter Roeck
  Cc: devicetree, linux-kernel, linux-hwmon, Arnd Bergmann,
	Geert Uytterhoeven, Jean Delvare, Rob Herring, Frank Rowand

From: Stephen Boyd <swboyd@chromium.org>

Use the more modern API to get the match data out of the of match table.
This saves some code, lines, and nicely avoids referencing the match
table when it is undefined with configurations where CONFIG_OF=n.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-hwmon@vger.kernel.org>
[robh: rework to use device_get_match_data()]
Signed-off-by: Rob Herring <robh@kernel.org>
---
v3:
- Reworked to use device_get_match_data(). Lifted Stephen's commit 
  message from another patch. :)

Please ack and I'll add to the rest of the series.

 drivers/hwmon/lm70.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
index ae2b84263a44..40eab3349904 100644
--- a/drivers/hwmon/lm70.c
+++ b/drivers/hwmon/lm70.c
@@ -22,9 +22,9 @@
 #include <linux/hwmon.h>
 #include <linux/mutex.h>
 #include <linux/mod_devicetable.h>
+#include <linux/property.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
-#include <linux/of_device.h>
 #include <linux/acpi.h>
 
 #define DRVNAME		"lm70"
@@ -173,25 +173,15 @@ MODULE_DEVICE_TABLE(acpi, lm70_acpi_ids);
 
 static int lm70_probe(struct spi_device *spi)
 {
-	const struct of_device_id *of_match;
 	struct device *hwmon_dev;
 	struct lm70 *p_lm70;
 	int chip;
 
-	of_match = of_match_device(lm70_of_ids, &spi->dev);
-	if (of_match)
-		chip = (int)(uintptr_t)of_match->data;
-	else {
-#ifdef CONFIG_ACPI
-		const struct acpi_device_id *acpi_match;
+	if (dev_fwnode(&spi->dev))
+		chip = (int)(uintptr_t)device_get_match_data(&spi->dev);
+	else
+		chip = spi_get_device_id(spi)->driver_data;
 
-		acpi_match = acpi_match_device(lm70_acpi_ids, &spi->dev);
-		if (acpi_match)
-			chip = (int)(uintptr_t)acpi_match->driver_data;
-		else
-#endif
-			chip = spi_get_device_id(spi)->driver_data;
-	}
 
 	/* signaling is SPI_MODE_0 */
 	if (spi->mode & (SPI_CPOL | SPI_CPHA))
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] hwmon: (lm70) Use device_get_match_data()
  2021-01-28 21:57 [PATCH v3] hwmon: (lm70) Use device_get_match_data() Rob Herring
@ 2021-01-28 22:12 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-01-28 22:12 UTC (permalink / raw
  To: Rob Herring
  Cc: Stephen Boyd, devicetree, linux-kernel, linux-hwmon,
	Arnd Bergmann, Geert Uytterhoeven, Jean Delvare, Rob Herring,
	Frank Rowand

On Thu, Jan 28, 2021 at 03:57:42PM -0600, Rob Herring wrote:
> From: Stephen Boyd <swboyd@chromium.org>
> 
> Use the more modern API to get the match data out of the of match table.
> This saves some code, lines, and nicely avoids referencing the match
> table when it is undefined with configurations where CONFIG_OF=n.
> 
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: <linux-hwmon@vger.kernel.org>
> [robh: rework to use device_get_match_data()]
> Signed-off-by: Rob Herring <robh@kernel.org>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
> v3:
> - Reworked to use device_get_match_data(). Lifted Stephen's commit 
>   message from another patch. :)
> 
> Please ack and I'll add to the rest of the series.
> 
>  drivers/hwmon/lm70.c | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
> index ae2b84263a44..40eab3349904 100644
> --- a/drivers/hwmon/lm70.c
> +++ b/drivers/hwmon/lm70.c
> @@ -22,9 +22,9 @@
>  #include <linux/hwmon.h>
>  #include <linux/mutex.h>
>  #include <linux/mod_devicetable.h>
> +#include <linux/property.h>
>  #include <linux/spi/spi.h>
>  #include <linux/slab.h>
> -#include <linux/of_device.h>
>  #include <linux/acpi.h>
>  
>  #define DRVNAME		"lm70"
> @@ -173,25 +173,15 @@ MODULE_DEVICE_TABLE(acpi, lm70_acpi_ids);
>  
>  static int lm70_probe(struct spi_device *spi)
>  {
> -	const struct of_device_id *of_match;
>  	struct device *hwmon_dev;
>  	struct lm70 *p_lm70;
>  	int chip;
>  
> -	of_match = of_match_device(lm70_of_ids, &spi->dev);
> -	if (of_match)
> -		chip = (int)(uintptr_t)of_match->data;
> -	else {
> -#ifdef CONFIG_ACPI
> -		const struct acpi_device_id *acpi_match;
> +	if (dev_fwnode(&spi->dev))
> +		chip = (int)(uintptr_t)device_get_match_data(&spi->dev);
> +	else
> +		chip = spi_get_device_id(spi)->driver_data;
>  
> -		acpi_match = acpi_match_device(lm70_acpi_ids, &spi->dev);
> -		if (acpi_match)
> -			chip = (int)(uintptr_t)acpi_match->driver_data;
> -		else
> -#endif
> -			chip = spi_get_device_id(spi)->driver_data;
> -	}
>  
>  	/* signaling is SPI_MODE_0 */
>  	if (spi->mode & (SPI_CPOL | SPI_CPHA))
> -- 
> 2.27.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-28 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-28 21:57 [PATCH v3] hwmon: (lm70) Use device_get_match_data() Rob Herring
2021-01-28 22:12 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.