diff mbox series

[v2,5/6] hwmon: (lm70) Avoid undefined reference to match table

Message ID 20210123034428.2841052-6-swboyd@chromium.org
State New
Headers show
Series Stop NULLifying match pointer in of_match_device() | expand

Commit Message

Stephen Boyd Jan. 23, 2021, 3:44 a.m. UTC
We're going to remove of_match_ptr() from the definition of
of_match_device() when CONFIG_OF=n. This way we can always be certain
that of_match_device() acts the same when CONFIG_OF is set and when it
isn't. Add of_match_ptr() here so that this doesn't break when that
change is made to the of_match_device() API.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
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>
---

Please ack so Rob can apply.

 drivers/hwmon/lm70.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rob Herring (Arm) Jan. 26, 2021, 6:30 p.m. UTC | #1
On Fri, Jan 22, 2021 at 9:44 PM Stephen Boyd <swboyd@chromium.org> wrote:
>

> We're going to remove of_match_ptr() from the definition of

> of_match_device() when CONFIG_OF=n. This way we can always be certain

> that of_match_device() acts the same when CONFIG_OF is set and when it

> isn't. Add of_match_ptr() here so that this doesn't break when that

> change is made to the of_match_device() API.

>

> Signed-off-by: Stephen Boyd <swboyd@chromium.org>

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

> 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>

> ---

>

> Please ack so Rob can apply.

>

>  drivers/hwmon/lm70.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c

> index ae2b84263a44..e3153ae80634 100644

> --- a/drivers/hwmon/lm70.c

> +++ b/drivers/hwmon/lm70.c

> @@ -178,7 +178,7 @@ static int lm70_probe(struct spi_device *spi)

>         struct lm70 *p_lm70;

>         int chip;

>

> -       of_match = of_match_device(lm70_of_ids, &spi->dev);

> +       of_match = of_match_device(of_match_ptr(lm70_of_ids), &spi->dev);

>         if (of_match)

>                 chip = (int)(uintptr_t)of_match->data;


Why can't this do:

if (spi->dev.of_node)
    chip = (int)(uintptr_t)of_device_get_match_data();
else {

>         else {

> --

> https://chromeos.dev

>
diff mbox series

Patch

diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
index ae2b84263a44..e3153ae80634 100644
--- a/drivers/hwmon/lm70.c
+++ b/drivers/hwmon/lm70.c
@@ -178,7 +178,7 @@  static int lm70_probe(struct spi_device *spi)
 	struct lm70 *p_lm70;
 	int chip;
 
-	of_match = of_match_device(lm70_of_ids, &spi->dev);
+	of_match = of_match_device(of_match_ptr(lm70_of_ids), &spi->dev);
 	if (of_match)
 		chip = (int)(uintptr_t)of_match->data;
 	else {