linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] Stop NULLifying match pointer in of_match_device()
@ 2019-10-04 21:43 Stephen Boyd
  2019-10-04 21:43 ` [PATCH 01/10] leds: pca953x: Use of_device_get_match_data() Stephen Boyd
                   ` (9 more replies)
  0 siblings, 10 replies; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alessandro Zummo, Alexandre Belloni, Alexandre Torgue,
	alsa-devel, Andrew Lunn, Arnd Bergmann, Dan Murphy,
	David S. Miller, Frank Rowand, Geert Uytterhoeven,
	Greg Kroah-Hartman, Gregory Clement, Grygorii Strashko,
	Guenter Roeck, Jacek Anaszewski, Jacopo Mondi, Jaroslav Kysela,
	Jason Cooper, Jean Delvare, Jiri Slaby, Liam Girdwood,
	linux-hwmon, linux-leds, linux-media, linux-omap,
	linux-renesas-soc, linux-rtc, linux-serial, linux-spi, linux-usb,
	Mark Brown, Mauro Carvalho Chehab, Maxime Coquelin,
	Paul Cercueil, Pavel Machek, Richard Leitner, Riku Voipio,
	Rob Herring, Sebastian Hesselbarth, Takashi Iwai

of_match_device() uses of_match_ptr() to make the match table argument
NULL via the pre-processor when CONFIG_OF=n. This makes life harder for
compilers who think that match tables are never used and warn about
unused variables when CONFIG_OF=n. This series changes various callers
to use of_device_get_match_data() instead, which doesn't have this
problem, and removes the of_match_ptr() usage from of_match_device() so
that the compiler can stop complaining about unused variables. It will
do dead code elimination instead and remove the match table if it isn't
actually used.

Huge Cc list!

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: <alsa-devel@alsa-project.org>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Gregory Clement <gregory.clement@bootlin.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Jacopo Mondi <jacopo@jmondi.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: <linux-hwmon@vger.kernel.org>
Cc: <linux-leds@vger.kernel.org>
Cc: <linux-media@vger.kernel.org>
Cc: <linux-omap@vger.kernel.org>
Cc: <linux-renesas-soc@vger.kernel.org>
Cc: <linux-rtc@vger.kernel.org>
Cc: <linux-serial@vger.kernel.org>
Cc: <linux-spi@vger.kernel.org>
Cc: <linux-usb@vger.kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Richard Leitner <richard.leitner@skidata.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Takashi Iwai <tiwai@suse.com>

Stephen Boyd (10):
  leds: pca953x: Use of_device_get_match_data()
  media: renesas-ceu: Use of_device_get_match_data()
  rtc: armada38x: Use of_device_get_match_data()
  drivers: net: davinci_mdio: Use of_device_get_match_data()
  serial: stm32: Use of_device_get_match_data()
  usb: usb251xb: Use of_device_get_match_data()
  ASoC: jz4740: Use of_device_get_match_data()
  spi: gpio: Look for a device node instead of match
  hwmon: (lm70) Avoid undefined reference to match table
  of/device: Don't NULLify match table in of_match_device() with
    CONFIG_OF=n

 drivers/hwmon/lm70.c                   |  2 +-
 drivers/leds/leds-pca9532.c            | 14 +----
 drivers/media/platform/renesas-ceu.c   |  2 +-
 drivers/net/ethernet/ti/davinci_mdio.c | 12 ++---
 drivers/rtc/rtc-armada38x.c            | 10 ++--
 drivers/spi/spi-gpio.c                 |  5 +-
 drivers/tty/serial/stm32-usart.c       | 71 ++++++++++++--------------
 drivers/tty/serial/stm32-usart.h       |  2 +-
 drivers/usb/misc/usb251xb.c            | 12 ++---
 include/linux/of_device.h              |  4 +-
 sound/soc/jz4740/jz4740-i2s.c          |  5 +-
 11 files changed, 55 insertions(+), 84 deletions(-)


base-commit: 54ecb8f7028c5eb3d740bb82b0f1d90f2df63c5c
-- 
Sent by a computer through tubes

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

* [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-06 12:15   ` Jacek Anaszewski
                     ` (4 more replies)
  2019-10-04 21:43 ` [PATCH 02/10] media: renesas-ceu: " Stephen Boyd
                   ` (8 subsequent siblings)
  9 siblings, 5 replies; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Riku Voipio, Rob Herring,
	Frank Rowand, Jacek Anaszewski, Pavel Machek, Dan Murphy,
	linux-leds

This driver can use the of_device_get_match_data() API to simplify the
code. Replace calls to of_match_device() with this newer API under the
assumption that where it is called will be when we know the device is
backed by a DT node. This nicely avoids referencing the match table when
it is undefined with configurations where CONFIG_OF=n.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: <linux-leds@vger.kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 drivers/leds/leds-pca9532.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index c7c7199e8ebd..7d515d5e57bd 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -467,16 +467,11 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np)
 {
 	struct pca9532_platform_data *pdata;
 	struct device_node *child;
-	const struct of_device_id *match;
 	int devid, maxleds;
 	int i = 0;
 	const char *state;
 
-	match = of_match_device(of_pca9532_leds_match, dev);
-	if (!match)
-		return ERR_PTR(-ENODEV);
-
-	devid = (int)(uintptr_t)match->data;
+	devid = (int)(uintptr_t)of_device_get_match_data(dev);
 	maxleds = pca9532_chip_info_tbl[devid].num_leds;
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
@@ -509,7 +504,6 @@ static int pca9532_probe(struct i2c_client *client,
 	const struct i2c_device_id *id)
 {
 	int devid;
-	const struct of_device_id *of_id;
 	struct pca9532_data *data = i2c_get_clientdata(client);
 	struct pca9532_platform_data *pca9532_pdata =
 			dev_get_platdata(&client->dev);
@@ -525,11 +519,7 @@ static int pca9532_probe(struct i2c_client *client,
 			dev_err(&client->dev, "no platform data\n");
 			return -EINVAL;
 		}
-		of_id = of_match_device(of_pca9532_leds_match,
-				&client->dev);
-		if (unlikely(!of_id))
-			return -EINVAL;
-		devid = (int)(uintptr_t) of_id->data;
+		devid = (int)(uintptr_t)of_device_get_match_data(&client->dev);
 	} else {
 		devid = id->driver_data;
 	}
-- 
Sent by a computer through tubes


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

* [PATCH 02/10] media: renesas-ceu: Use of_device_get_match_data()
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
  2019-10-04 21:43 ` [PATCH 01/10] leds: pca953x: Use of_device_get_match_data() Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-09 12:54   ` Mauro Carvalho Chehab
  2019-10-04 21:43 ` [PATCH 03/10] rtc: armada38x: " Stephen Boyd
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Jacopo Mondi,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, linux-media,
	linux-renesas-soc

This driver can use the replacement API instead of calling
of_match_device() and then dereferencing the pointer that is returned.
This nicely avoids referencing the match table when it is undefined with
configurations where CONFIG_OF=n.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jacopo Mondi <jacopo@jmondi.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-media@vger.kernel.org>
Cc: <linux-renesas-soc@vger.kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 drivers/media/platform/renesas-ceu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c
index 197b3991330d..60518bbc2cd5 100644
--- a/drivers/media/platform/renesas-ceu.c
+++ b/drivers/media/platform/renesas-ceu.c
@@ -1679,7 +1679,7 @@ static int ceu_probe(struct platform_device *pdev)
 	v4l2_async_notifier_init(&ceudev->notifier);
 
 	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
-		ceu_data = of_match_device(ceu_of_match, dev)->data;
+		ceu_data = of_device_get_match_data(dev);
 		num_subdevs = ceu_parse_dt(ceudev);
 	} else if (dev->platform_data) {
 		/* Assume SH4 if booting with platform data. */
-- 
Sent by a computer through tubes


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

* [PATCH 03/10] rtc: armada38x: Use of_device_get_match_data()
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
  2019-10-04 21:43 ` [PATCH 01/10] leds: pca953x: Use of_device_get_match_data() Stephen Boyd
  2019-10-04 21:43 ` [PATCH 02/10] media: renesas-ceu: " Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-07 13:53   ` Alexandre Belloni
  2019-10-04 21:43 ` [PATCH 04/10] drivers: net: davinci_mdio: " Stephen Boyd
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Jason Cooper, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Alessandro Zummo,
	Alexandre Belloni, Rob Herring, Frank Rowand, linux-rtc

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.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@bootlin.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-rtc@vger.kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 drivers/rtc/rtc-armada38x.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
index 9351bd52477e..94d7c22fc4f3 100644
--- a/drivers/rtc/rtc-armada38x.c
+++ b/drivers/rtc/rtc-armada38x.c
@@ -74,7 +74,7 @@ struct armada38x_rtc {
 	int		    irq;
 	bool		    initialized;
 	struct value_to_freq *val_to_freq;
-	struct armada38x_rtc_data *data;
+	const struct armada38x_rtc_data *data;
 };
 
 #define ALARM1	0
@@ -501,17 +501,14 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
 {
 	struct resource *res;
 	struct armada38x_rtc *rtc;
-	const struct of_device_id *match;
-
-	match = of_match_device(armada38x_rtc_of_match_table, &pdev->dev);
-	if (!match)
-		return -ENODEV;
 
 	rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc),
 			    GFP_KERNEL);
 	if (!rtc)
 		return -ENOMEM;
 
+	rtc->data = of_device_get_match_data(&pdev->dev);
+
 	rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR,
 				sizeof(struct value_to_freq), GFP_KERNEL);
 	if (!rtc->val_to_freq)
@@ -553,7 +550,6 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
 		 */
 		rtc->rtc_dev->ops = &armada38x_rtc_ops_noirq;
 	}
-	rtc->data = (struct armada38x_rtc_data *)match->data;
 
 	/* Update RTC-MBUS bridge timing parameters */
 	rtc->data->update_mbus_timing(rtc);
-- 
Sent by a computer through tubes


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

* [PATCH 04/10] drivers: net: davinci_mdio: Use of_device_get_match_data()
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (2 preceding siblings ...)
  2019-10-04 21:43 ` [PATCH 03/10] rtc: armada38x: " Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-04 21:43 ` [PATCH 05/10] serial: stm32: " Stephen Boyd
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Grygorii Strashko,
	David S. Miller, Rob Herring, Frank Rowand, linux-omap

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.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-omap@vger.kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 drivers/net/ethernet/ti/davinci_mdio.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 38b7f6d35759..f78f7409df0c 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -358,20 +358,16 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 	}
 
 	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
-		const struct of_device_id	*of_id;
+		const struct davinci_mdio_of_param *of_mdio_data;
 
 		ret = davinci_mdio_probe_dt(&data->pdata, pdev);
 		if (ret)
 			return ret;
 		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s", pdev->name);
 
-		of_id = of_match_device(davinci_mdio_of_mtable, &pdev->dev);
-		if (of_id) {
-			const struct davinci_mdio_of_param *of_mdio_data;
-
-			of_mdio_data = of_id->data;
-			if (of_mdio_data)
-				autosuspend_delay_ms =
+		of_mdio_data = of_device_get_match_data(&pdev->dev);
+		if (of_mdio_data) {
+			autosuspend_delay_ms =
 					of_mdio_data->autosuspend_delay_ms;
 		}
 	} else {
-- 
Sent by a computer through tubes


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

* [PATCH 05/10] serial: stm32: Use of_device_get_match_data()
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (3 preceding siblings ...)
  2019-10-04 21:43 ` [PATCH 04/10] drivers: net: davinci_mdio: " Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-05  6:53   ` Greg Kroah-Hartman
  2019-10-04 21:43 ` [PATCH 06/10] usb: usb251xb: " Stephen Boyd
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Greg Kroah-Hartman,
	Jiri Slaby, Maxime Coquelin, Alexandre Torgue, Rob Herring,
	Frank Rowand, linux-serial

This driver casts away the constness of struct stm32_usart_info that is
pointed to by the of match table. Use of_device_get_match_data() instead
of of_match_device() here and push the const throughout the code so that
we don't cast away const. This nicely avoids referencing the match table
when it is undefined with configurations where CONFIG_OF=n and fixes the
const issues.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-serial@vger.kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 drivers/tty/serial/stm32-usart.c | 71 +++++++++++++++-----------------
 drivers/tty/serial/stm32-usart.h |  2 +-
 2 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index df90747ee3a8..b837aa6e89a4 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -102,8 +102,8 @@ static int stm32_config_rs485(struct uart_port *port,
 			      struct serial_rs485 *rs485conf)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
-	struct stm32_usart_config *cfg = &stm32_port->info->cfg;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_config *cfg = &stm32_port->info->cfg;
 	u32 usartdiv, baud, cr1, cr3;
 	bool over8;
 
@@ -171,7 +171,7 @@ static int stm32_pending_rx(struct uart_port *port, u32 *sr, int *last_res,
 			    bool threaded)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	enum dma_status status;
 	struct dma_tx_state state;
 
@@ -196,7 +196,7 @@ static unsigned long stm32_get_char(struct uart_port *port, u32 *sr,
 				    int *last_res)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	unsigned long c;
 
 	if (stm32_port->rx_ch) {
@@ -216,7 +216,7 @@ static void stm32_receive_chars(struct uart_port *port, bool threaded)
 {
 	struct tty_port *tport = &port->state->port;
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	unsigned long c;
 	u32 sr;
 	char flag;
@@ -287,7 +287,7 @@ static void stm32_tx_dma_complete(void *arg)
 {
 	struct uart_port *port = arg;
 	struct stm32_port *stm32port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
 
 	stm32_clr_bits(port, ofs->cr3, USART_CR3_DMAT);
 	stm32port->tx_dma_busy = false;
@@ -299,7 +299,7 @@ static void stm32_tx_dma_complete(void *arg)
 static void stm32_tx_interrupt_enable(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 
 	/*
 	 * Enables TX FIFO threashold irq when FIFO is enabled,
@@ -314,7 +314,7 @@ static void stm32_tx_interrupt_enable(struct uart_port *port)
 static void stm32_tx_interrupt_disable(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 
 	if (stm32_port->fifoen)
 		stm32_clr_bits(port, ofs->cr3, USART_CR3_TXFTIE);
@@ -325,7 +325,7 @@ static void stm32_tx_interrupt_disable(struct uart_port *port)
 static void stm32_transmit_chars_pio(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	struct circ_buf *xmit = &port->state->xmit;
 
 	if (stm32_port->tx_dma_busy) {
@@ -352,7 +352,7 @@ static void stm32_transmit_chars_pio(struct uart_port *port)
 static void stm32_transmit_chars_dma(struct uart_port *port)
 {
 	struct stm32_port *stm32port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
 	struct circ_buf *xmit = &port->state->xmit;
 	struct dma_async_tx_descriptor *desc = NULL;
 	dma_cookie_t cookie;
@@ -413,7 +413,7 @@ static void stm32_transmit_chars_dma(struct uart_port *port)
 static void stm32_transmit_chars(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	struct circ_buf *xmit = &port->state->xmit;
 
 	if (port->x_char) {
@@ -453,7 +453,7 @@ static irqreturn_t stm32_interrupt(int irq, void *ptr)
 {
 	struct uart_port *port = ptr;
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	u32 sr;
 
 	spin_lock(&port->lock);
@@ -500,7 +500,7 @@ static irqreturn_t stm32_threaded_interrupt(int irq, void *ptr)
 static unsigned int stm32_tx_empty(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 
 	return readl_relaxed(port->membase + ofs->isr) & USART_SR_TXE;
 }
@@ -508,7 +508,7 @@ static unsigned int stm32_tx_empty(struct uart_port *port)
 static void stm32_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 
 	if ((mctrl & TIOCM_RTS) && (port->status & UPSTAT_AUTORTS))
 		stm32_set_bits(port, ofs->cr3, USART_CR3_RTSE);
@@ -543,7 +543,7 @@ static void stm32_start_tx(struct uart_port *port)
 static void stm32_throttle(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	unsigned long flags;
 
 	spin_lock_irqsave(&port->lock, flags);
@@ -558,7 +558,7 @@ static void stm32_throttle(struct uart_port *port)
 static void stm32_unthrottle(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	unsigned long flags;
 
 	spin_lock_irqsave(&port->lock, flags);
@@ -573,7 +573,7 @@ static void stm32_unthrottle(struct uart_port *port)
 static void stm32_stop_rx(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 
 	stm32_clr_bits(port, ofs->cr1, stm32_port->cr1_irq);
 	if (stm32_port->cr3_irq)
@@ -589,7 +589,7 @@ static void stm32_break_ctl(struct uart_port *port, int break_state)
 static int stm32_startup(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	const char *name = to_platform_device(port->dev)->name;
 	u32 val;
 	int ret;
@@ -625,8 +625,8 @@ static int stm32_startup(struct uart_port *port)
 static void stm32_shutdown(struct uart_port *port)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
-	struct stm32_usart_config *cfg = &stm32_port->info->cfg;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_config *cfg = &stm32_port->info->cfg;
 	u32 val, isr;
 	int ret;
 
@@ -682,8 +682,8 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios,
 			    struct ktermios *old)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
-	struct stm32_usart_config *cfg = &stm32_port->info->cfg;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_config *cfg = &stm32_port->info->cfg;
 	struct serial_rs485 *rs485conf = &port->rs485;
 	unsigned int baud, bits;
 	u32 usartdiv, mantissa, fraction, oversampling;
@@ -876,8 +876,8 @@ static void stm32_pm(struct uart_port *port, unsigned int state,
 {
 	struct stm32_port *stm32port = container_of(port,
 			struct stm32_port, port);
-	struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
-	struct stm32_usart_config *cfg = &stm32port->info->cfg;
+	const struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
+	const struct stm32_usart_config *cfg = &stm32port->info->cfg;
 	unsigned long flags = 0;
 
 	switch (state) {
@@ -1010,7 +1010,7 @@ MODULE_DEVICE_TABLE(of, stm32_match);
 static int stm32_of_dma_rx_probe(struct stm32_port *stm32port,
 				 struct platform_device *pdev)
 {
-	struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
 	struct uart_port *port = &stm32port->port;
 	struct device *dev = &pdev->dev;
 	struct dma_slave_config config;
@@ -1082,7 +1082,7 @@ static int stm32_of_dma_rx_probe(struct stm32_port *stm32port,
 static int stm32_of_dma_tx_probe(struct stm32_port *stm32port,
 				 struct platform_device *pdev)
 {
-	struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
 	struct uart_port *port = &stm32port->port;
 	struct device *dev = &pdev->dev;
 	struct dma_slave_config config;
@@ -1132,7 +1132,6 @@ static int stm32_of_dma_tx_probe(struct stm32_port *stm32port,
 
 static int stm32_serial_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	struct stm32_port *stm32port;
 	int ret;
 
@@ -1140,10 +1139,8 @@ static int stm32_serial_probe(struct platform_device *pdev)
 	if (!stm32port)
 		return -ENODEV;
 
-	match = of_match_device(stm32_match, &pdev->dev);
-	if (match && match->data)
-		stm32port->info = (struct stm32_usart_info *)match->data;
-	else
+	stm32port->info = of_device_get_match_data(&pdev->dev);
+	if (!stm32port->info)
 		return -EINVAL;
 
 	ret = stm32_init_port(stm32port, pdev);
@@ -1202,7 +1199,7 @@ static int stm32_serial_remove(struct platform_device *pdev)
 {
 	struct uart_port *port = platform_get_drvdata(pdev);
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 	int err;
 
 	pm_runtime_get_sync(&pdev->dev);
@@ -1247,7 +1244,7 @@ static int stm32_serial_remove(struct platform_device *pdev)
 static void stm32_console_putchar(struct uart_port *port, int ch)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
 
 	while (!(readl_relaxed(port->membase + ofs->isr) & USART_SR_TXE))
 		cpu_relax();
@@ -1259,8 +1256,8 @@ static void stm32_console_write(struct console *co, const char *s, unsigned cnt)
 {
 	struct uart_port *port = &stm32_ports[co->index].port;
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
-	struct stm32_usart_config *cfg = &stm32_port->info->cfg;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_config *cfg = &stm32_port->info->cfg;
 	unsigned long flags;
 	u32 old_cr1, new_cr1;
 	int locked = 1;
@@ -1346,8 +1343,8 @@ static void __maybe_unused stm32_serial_enable_wakeup(struct uart_port *port,
 						      bool enable)
 {
 	struct stm32_port *stm32_port = to_stm32_port(port);
-	struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
-	struct stm32_usart_config *cfg = &stm32_port->info->cfg;
+	const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+	const struct stm32_usart_config *cfg = &stm32_port->info->cfg;
 	u32 val;
 
 	if (stm32_port->wakeirq <= 0)
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index a175c1094dc8..2aa4d1149d97 100644
--- a/drivers/tty/serial/stm32-usart.h
+++ b/drivers/tty/serial/stm32-usart.h
@@ -259,7 +259,7 @@ struct stm32_usart_info stm32h7_info = {
 struct stm32_port {
 	struct uart_port port;
 	struct clk *clk;
-	struct stm32_usart_info *info;
+	const struct stm32_usart_info *info;
 	struct dma_chan *rx_ch;  /* dma rx channel            */
 	dma_addr_t rx_dma_buf;   /* dma rx buffer bus address */
 	unsigned char *rx_buf;   /* dma rx buffer cpu address */
-- 
Sent by a computer through tubes


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

* [PATCH 06/10] usb: usb251xb: Use of_device_get_match_data()
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (4 preceding siblings ...)
  2019-10-04 21:43 ` [PATCH 05/10] serial: stm32: " Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-05  6:53   ` Greg Kroah-Hartman
  2019-10-04 21:43 ` [PATCH 07/10] ASoC: jz4740: " Stephen Boyd
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Richard Leitner,
	Greg Kroah-Hartman, Rob Herring, Frank Rowand, linux-usb

Use the more modern API here instead of using of_match_device() and
avoid casting away const from the returned pointer by pushing the const
type through to the users. This nicely avoids referencing the match
table when it is undefined with configurations where CONFIG_OF=n and
avoids const issues.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Richard Leitner <richard.leitner@skidata.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-usb@vger.kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 drivers/usb/misc/usb251xb.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 6ca9111d150a..84f218a6843c 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -392,7 +392,7 @@ static void usb251xb_get_ports_field(struct usb251xb *hub,
 }
 
 static int usb251xb_get_ofdata(struct usb251xb *hub,
-			       struct usb251xb_data *data)
+			       const struct usb251xb_data *data)
 {
 	struct device *dev = hub->dev;
 	struct device_node *np = dev->of_node;
@@ -623,7 +623,7 @@ static const struct of_device_id usb251xb_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb251xb_of_match);
 #else /* CONFIG_OF */
 static int usb251xb_get_ofdata(struct usb251xb *hub,
-			       struct usb251xb_data *data)
+			       const struct usb251xb_data *data)
 {
 	return 0;
 }
@@ -633,13 +633,11 @@ static int usb251xb_probe(struct usb251xb *hub)
 {
 	struct device *dev = hub->dev;
 	struct device_node *np = dev->of_node;
-	const struct of_device_id *of_id = of_match_device(usb251xb_of_match,
-							   dev);
+	const struct usb251xb_data *usb_data = of_device_get_match_data(dev);
 	int err;
 
-	if (np && of_id) {
-		err = usb251xb_get_ofdata(hub,
-					  (struct usb251xb_data *)of_id->data);
+	if (np && usb_data) {
+		err = usb251xb_get_ofdata(hub, usb_data);
 		if (err) {
 			dev_err(dev, "failed to get ofdata: %d\n", err);
 			return err;
-- 
Sent by a computer through tubes


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

* [PATCH 07/10] ASoC: jz4740: Use of_device_get_match_data()
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (5 preceding siblings ...)
  2019-10-04 21:43 ` [PATCH 06/10] usb: usb251xb: " Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-07 13:03   ` Applied "ASoC: jz4740: Use of_device_get_match_data()" to the asoc tree Mark Brown
  2019-10-04 21:43 ` [PATCH 08/10] spi: gpio: Look for a device node instead of match Stephen Boyd
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Paul Cercueil, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, Rob Herring,
	Frank Rowand, alsa-devel

This probe function is only called if the device is backed by a DT node,
so switch this call to of_device_get_match_data() to reduce code size
and simplify a bit. This also avoids needing to reference a potentially
undefined variable because of_device_get_match_data() doesn't need to
know anything beyond the struct device to find the match table.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <alsa-devel@alsa-project.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 sound/soc/jz4740/jz4740-i2s.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c
index 13408de34055..d2dab4d24b87 100644
--- a/sound/soc/jz4740/jz4740-i2s.c
+++ b/sound/soc/jz4740/jz4740-i2s.c
@@ -503,9 +503,8 @@ static int jz4740_i2s_dev_probe(struct platform_device *pdev)
 	if (!i2s)
 		return -ENOMEM;
 
-	match = of_match_device(jz4740_of_matches, &pdev->dev);
-	if (match)
-		i2s->version = (enum jz47xx_i2s_version)match->data;
+	i2s->version =
+		(enum jz47xx_i2s_version)of_device_get_match_data(&pdev->dev);
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	i2s->base = devm_ioremap_resource(&pdev->dev, mem);
-- 
Sent by a computer through tubes


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

* [PATCH 08/10] spi: gpio: Look for a device node instead of match
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (6 preceding siblings ...)
  2019-10-04 21:43 ` [PATCH 07/10] ASoC: jz4740: " Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-07 13:03   ` Applied "spi: gpio: Look for a device node instead of match" to the spi tree Mark Brown
  2019-10-04 21:43 ` [PATCH 09/10] hwmon: (lm70) Avoid undefined reference to match table Stephen Boyd
  2019-10-04 21:43 ` [PATCH 10/10] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Stephen Boyd
  9 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Mark Brown, Rob Herring,
	Frank Rowand, linux-spi

This driver doesn't do anything with the match for the device node. The
logic is the same as looking to see if a device node exists or not
because this driver wouldn't probe unless there is a device node match
when the device is created from DT. Just test for the presence of the
device node to simplify and avoid referencing a potentially undefined
match table when CONFIG_OF=n.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-spi@vger.kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 drivers/spi/spi-gpio.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 1d3e23ec20a6..42f4d82e9c5a 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -362,9 +362,6 @@ static int spi_gpio_probe(struct platform_device *pdev)
 	struct spi_gpio			*spi_gpio;
 	struct device			*dev = &pdev->dev;
 	struct spi_bitbang		*bb;
-	const struct of_device_id	*of_id;
-
-	of_id = of_match_device(spi_gpio_dt_ids, &pdev->dev);
 
 	master = spi_alloc_master(dev, sizeof(*spi_gpio));
 	if (!master)
@@ -374,7 +371,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
 	if (status)
 		return status;
 
-	if (of_id)
+	if (pdev->dev.of_node)
 		status = spi_gpio_probe_dt(pdev, master);
 	else
 		status = spi_gpio_probe_pdata(pdev, master);
-- 
Sent by a computer through tubes


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

* [PATCH 09/10] hwmon: (lm70) Avoid undefined reference to match table
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (7 preceding siblings ...)
  2019-10-04 21:43 ` [PATCH 08/10] spi: gpio: Look for a device node instead of match Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-04 23:03   ` Guenter Roeck
  2019-10-04 21:43 ` [PATCH 10/10] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Stephen Boyd
  9 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Jean Delvare, Guenter Roeck,
	Rob Herring, Frank Rowand, linux-hwmon

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.

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>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 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 4122e59f0bb4..57480dada955 100644
--- a/drivers/hwmon/lm70.c
+++ b/drivers/hwmon/lm70.c
@@ -155,7 +155,7 @@ static int lm70_probe(struct spi_device *spi)
 	struct lm70 *p_lm70;
 	int chip;
 
-	match = of_match_device(lm70_of_ids, &spi->dev);
+	match = of_match_device(of_match_ptr(lm70_of_ids), &spi->dev);
 	if (match)
 		chip = (int)(uintptr_t)match->data;
 	else
-- 
Sent by a computer through tubes


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

* [PATCH 10/10] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n
  2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (8 preceding siblings ...)
  2019-10-04 21:43 ` [PATCH 09/10] hwmon: (lm70) Avoid undefined reference to match table Stephen Boyd
@ 2019-10-04 21:43 ` Stephen Boyd
  2019-10-17 17:47   ` Frank Rowand
  9 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-04 21:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, Geert Uytterhoeven, Rob Herring, Frank Rowand

This effectively reverts 1db73ae39a97 ("of/device: Nullify match table
in of_match_device() for CONFIG_OF=n") because that commit makes it more
surprising to users of this API that the arguments may never be
referenced by any code. This is because the pre-processor will replace
the argument with NULL and then the match table will be left unreferenced
by any code but the compiler optimizer doesn't know to drop it. This can
lead to compilers warning that match tables are unused, when we really
want to pass the match table to the API but have the compiler see that
it's all inlined and not used and then drop the match table while
silencing the warning. We're being too smart here and not giving the
compiler the chance to do dead code elimination.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Please ack or pick for immediate merge so the last patch can be merged.

 include/linux/of_device.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 8d31e39dd564..3f8ca55bc693 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -93,13 +93,11 @@ static inline int of_device_uevent_modalias(struct device *dev,
 
 static inline void of_device_node_put(struct device *dev) { }
 
-static inline const struct of_device_id *__of_match_device(
+static inline const struct of_device_id *of_match_device(
 		const struct of_device_id *matches, const struct device *dev)
 {
 	return NULL;
 }
-#define of_match_device(matches, dev)	\
-	__of_match_device(of_match_ptr(matches), (dev))
 
 static inline struct device_node *of_cpu_device_node_get(int cpu)
 {
-- 
Sent by a computer through tubes


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

* Re: [PATCH 09/10] hwmon: (lm70) Avoid undefined reference to match table
  2019-10-04 21:43 ` [PATCH 09/10] hwmon: (lm70) Avoid undefined reference to match table Stephen Boyd
@ 2019-10-04 23:03   ` Guenter Roeck
  0 siblings, 0 replies; 31+ messages in thread
From: Guenter Roeck @ 2019-10-04 23:03 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, Arnd Bergmann, Geert Uytterhoeven, Jean Delvare,
	Rob Herring, Frank Rowand, linux-hwmon

On Fri, Oct 04, 2019 at 02:43:33PM -0700, Stephen Boyd 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.
> 
> 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>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>

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

> ---
> 
> Please ack or pick for immediate merge so the last patch can be merged.
> 
>  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 4122e59f0bb4..57480dada955 100644
> --- a/drivers/hwmon/lm70.c
> +++ b/drivers/hwmon/lm70.c
> @@ -155,7 +155,7 @@ static int lm70_probe(struct spi_device *spi)
>  	struct lm70 *p_lm70;
>  	int chip;
>  
> -	match = of_match_device(lm70_of_ids, &spi->dev);
> +	match = of_match_device(of_match_ptr(lm70_of_ids), &spi->dev);
>  	if (match)
>  		chip = (int)(uintptr_t)match->data;
>  	else
> -- 
> Sent by a computer through tubes
> 

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

* Re: [PATCH 06/10] usb: usb251xb: Use of_device_get_match_data()
  2019-10-04 21:43 ` [PATCH 06/10] usb: usb251xb: " Stephen Boyd
@ 2019-10-05  6:53   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 31+ messages in thread
From: Greg Kroah-Hartman @ 2019-10-05  6:53 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, Arnd Bergmann, Geert Uytterhoeven, Richard Leitner,
	Rob Herring, Frank Rowand, linux-usb

On Fri, Oct 04, 2019 at 02:43:30PM -0700, Stephen Boyd wrote:
> Use the more modern API here instead of using of_match_device() and
> avoid casting away const from the returned pointer by pushing the const
> type through to the users. This nicely avoids referencing the match
> table when it is undefined with configurations where CONFIG_OF=n and
> avoids const issues.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Richard Leitner <richard.leitner@skidata.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: <linux-usb@vger.kernel.org>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> ---
> 
> Please ack or pick for immediate merge so the last patch can be merged.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH 05/10] serial: stm32: Use of_device_get_match_data()
  2019-10-04 21:43 ` [PATCH 05/10] serial: stm32: " Stephen Boyd
@ 2019-10-05  6:53   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 31+ messages in thread
From: Greg Kroah-Hartman @ 2019-10-05  6:53 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, Arnd Bergmann, Geert Uytterhoeven, Jiri Slaby,
	Maxime Coquelin, Alexandre Torgue, Rob Herring, Frank Rowand,
	linux-serial

On Fri, Oct 04, 2019 at 02:43:29PM -0700, Stephen Boyd wrote:
> This driver casts away the constness of struct stm32_usart_info that is
> pointed to by the of match table. Use of_device_get_match_data() instead
> of of_match_device() here and push the const throughout the code so that
> we don't cast away const. This nicely avoids referencing the match table
> when it is undefined with configurations where CONFIG_OF=n and fixes the
> const issues.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jslaby@suse.com>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Alexandre Torgue <alexandre.torgue@st.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: <linux-serial@vger.kernel.org>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> ---
> 
> Please ack or pick for immediate merge so the last patch can be merged.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-04 21:43 ` [PATCH 01/10] leds: pca953x: Use of_device_get_match_data() Stephen Boyd
@ 2019-10-06 12:15   ` Jacek Anaszewski
  2019-10-07  8:01   ` Geert Uytterhoeven
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 31+ messages in thread
From: Jacek Anaszewski @ 2019-10-06 12:15 UTC (permalink / raw)
  To: Stephen Boyd, linux-kernel
  Cc: Arnd Bergmann, Geert Uytterhoeven, Riku Voipio, Rob Herring,
	Frank Rowand, Pavel Machek, Dan Murphy, linux-leds

On 10/4/19 11:43 PM, Stephen Boyd wrote:
> This driver can use the of_device_get_match_data() API to simplify the
> code. Replace calls to of_match_device() with this newer API under the
> assumption that where it is called will be when we know the device is
> backed by a DT node. This nicely avoids referencing the match table when
> it is undefined with configurations where CONFIG_OF=n.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Riku Voipio <riku.voipio@iki.fi>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Dan Murphy <dmurphy@ti.com>
> Cc: <linux-leds@vger.kernel.org>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> ---
> 
> Please ack or pick for immediate merge so the last patch can be merged.
> 
>  drivers/leds/leds-pca9532.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
> index c7c7199e8ebd..7d515d5e57bd 100644
> --- a/drivers/leds/leds-pca9532.c
> +++ b/drivers/leds/leds-pca9532.c
> @@ -467,16 +467,11 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np)
>  {
>  	struct pca9532_platform_data *pdata;
>  	struct device_node *child;
> -	const struct of_device_id *match;
>  	int devid, maxleds;
>  	int i = 0;
>  	const char *state;
>  
> -	match = of_match_device(of_pca9532_leds_match, dev);
> -	if (!match)
> -		return ERR_PTR(-ENODEV);
> -
> -	devid = (int)(uintptr_t)match->data;
> +	devid = (int)(uintptr_t)of_device_get_match_data(dev);
>  	maxleds = pca9532_chip_info_tbl[devid].num_leds;
>  
>  	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> @@ -509,7 +504,6 @@ static int pca9532_probe(struct i2c_client *client,
>  	const struct i2c_device_id *id)
>  {
>  	int devid;
> -	const struct of_device_id *of_id;
>  	struct pca9532_data *data = i2c_get_clientdata(client);
>  	struct pca9532_platform_data *pca9532_pdata =
>  			dev_get_platdata(&client->dev);
> @@ -525,11 +519,7 @@ static int pca9532_probe(struct i2c_client *client,
>  			dev_err(&client->dev, "no platform data\n");
>  			return -EINVAL;
>  		}
> -		of_id = of_match_device(of_pca9532_leds_match,
> -				&client->dev);
> -		if (unlikely(!of_id))
> -			return -EINVAL;
> -		devid = (int)(uintptr_t) of_id->data;
> +		devid = (int)(uintptr_t)of_device_get_match_data(&client->dev);
>  	} else {
>  		devid = id->driver_data;
>  	}
> 

Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>

-- 
Best regards,
Jacek Anaszewski

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

* Re: [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-04 21:43 ` [PATCH 01/10] leds: pca953x: Use of_device_get_match_data() Stephen Boyd
  2019-10-06 12:15   ` Jacek Anaszewski
@ 2019-10-07  8:01   ` Geert Uytterhoeven
  2019-10-13 12:10   ` Pavel Machek
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 31+ messages in thread
From: Geert Uytterhoeven @ 2019-10-07  8:01 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Linux Kernel Mailing List, Arnd Bergmann, Riku Voipio,
	Rob Herring, Frank Rowand, Jacek Anaszewski, Pavel Machek,
	Dan Murphy, linux-leds

On Fri, Oct 4, 2019 at 11:43 PM Stephen Boyd <swboyd@chromium.org> wrote:
> This driver can use the of_device_get_match_data() API to simplify the
> code. Replace calls to of_match_device() with this newer API under the
> assumption that where it is called will be when we know the device is
> backed by a DT node. This nicely avoids referencing the match table when
> it is undefined with configurations where CONFIG_OF=n.
>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Riku Voipio <riku.voipio@iki.fi>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Dan Murphy <dmurphy@ti.com>
> Cc: <linux-leds@vger.kernel.org>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Applied "ASoC: jz4740: Use of_device_get_match_data()" to the asoc tree
  2019-10-04 21:43 ` [PATCH 07/10] ASoC: jz4740: " Stephen Boyd
@ 2019-10-07 13:03   ` Mark Brown
  0 siblings, 0 replies; 31+ messages in thread
From: Mark Brown @ 2019-10-07 13:03 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: alsa-devel, alsa-devel, Arnd Bergmann, Frank Rowand,
	Geert Uytterhoeven, Jaroslav Kysela, Liam Girdwood, linux-kernel,
	Mark Brown, Paul Cercueil, Rob Herring, Takashi Iwai

The patch

   ASoC: jz4740: Use of_device_get_match_data()

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 67ad656bdd703157154d0db5bf1b35a5a86073b9 Mon Sep 17 00:00:00 2001
From: Stephen Boyd <swboyd@chromium.org>
Date: Fri, 4 Oct 2019 14:43:31 -0700
Subject: [PATCH] ASoC: jz4740: Use of_device_get_match_data()

This probe function is only called if the device is backed by a DT node,
so switch this call to of_device_get_match_data() to reduce code size
and simplify a bit. This also avoids needing to reference a potentially
undefined variable because of_device_get_match_data() doesn't need to
know anything beyond the struct device to find the match table.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <alsa-devel@alsa-project.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20191004214334.149976-8-swboyd@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/jz4740/jz4740-i2s.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c
index 13408de34055..d2dab4d24b87 100644
--- a/sound/soc/jz4740/jz4740-i2s.c
+++ b/sound/soc/jz4740/jz4740-i2s.c
@@ -503,9 +503,8 @@ static int jz4740_i2s_dev_probe(struct platform_device *pdev)
 	if (!i2s)
 		return -ENOMEM;
 
-	match = of_match_device(jz4740_of_matches, &pdev->dev);
-	if (match)
-		i2s->version = (enum jz47xx_i2s_version)match->data;
+	i2s->version =
+		(enum jz47xx_i2s_version)of_device_get_match_data(&pdev->dev);
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	i2s->base = devm_ioremap_resource(&pdev->dev, mem);
-- 
2.20.1


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

* Applied "spi: gpio: Look for a device node instead of match" to the spi tree
  2019-10-04 21:43 ` [PATCH 08/10] spi: gpio: Look for a device node instead of match Stephen Boyd
@ 2019-10-07 13:03   ` Mark Brown
  0 siblings, 0 replies; 31+ messages in thread
From: Mark Brown @ 2019-10-07 13:03 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Arnd Bergmann, Frank Rowand, Geert Uytterhoeven, linux-kernel,
	linux-spi, linux-spi, Mark Brown, Rob Herring

The patch

   spi: gpio: Look for a device node instead of match

has been applied to the spi tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.5

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 62217f8b084a05dd2d84781a8ca065098df21ec7 Mon Sep 17 00:00:00 2001
From: Stephen Boyd <swboyd@chromium.org>
Date: Fri, 4 Oct 2019 14:43:32 -0700
Subject: [PATCH] spi: gpio: Look for a device node instead of match

This driver doesn't do anything with the match for the device node. The
logic is the same as looking to see if a device node exists or not
because this driver wouldn't probe unless there is a device node match
when the device is created from DT. Just test for the presence of the
device node to simplify and avoid referencing a potentially undefined
match table when CONFIG_OF=n.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-spi@vger.kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20191004214334.149976-9-swboyd@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-gpio.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 1d3e23ec20a6..42f4d82e9c5a 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -362,9 +362,6 @@ static int spi_gpio_probe(struct platform_device *pdev)
 	struct spi_gpio			*spi_gpio;
 	struct device			*dev = &pdev->dev;
 	struct spi_bitbang		*bb;
-	const struct of_device_id	*of_id;
-
-	of_id = of_match_device(spi_gpio_dt_ids, &pdev->dev);
 
 	master = spi_alloc_master(dev, sizeof(*spi_gpio));
 	if (!master)
@@ -374,7 +371,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
 	if (status)
 		return status;
 
-	if (of_id)
+	if (pdev->dev.of_node)
 		status = spi_gpio_probe_dt(pdev, master);
 	else
 		status = spi_gpio_probe_pdata(pdev, master);
-- 
2.20.1


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

* Re: [PATCH 03/10] rtc: armada38x: Use of_device_get_match_data()
  2019-10-04 21:43 ` [PATCH 03/10] rtc: armada38x: " Stephen Boyd
@ 2019-10-07 13:53   ` Alexandre Belloni
  0 siblings, 0 replies; 31+ messages in thread
From: Alexandre Belloni @ 2019-10-07 13:53 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, Arnd Bergmann, Geert Uytterhoeven, Jason Cooper,
	Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
	Alessandro Zummo, Rob Herring, Frank Rowand, linux-rtc

On 04/10/2019 14:43:27-0700, Stephen Boyd wrote:
> 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.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Jason Cooper <jason@lakedaemon.net>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: <linux-rtc@vger.kernel.org>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
> 
> Please ack or pick for immediate merge so the last patch can be merged.
> 
>  drivers/rtc/rtc-armada38x.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
> index 9351bd52477e..94d7c22fc4f3 100644
> --- a/drivers/rtc/rtc-armada38x.c
> +++ b/drivers/rtc/rtc-armada38x.c
> @@ -74,7 +74,7 @@ struct armada38x_rtc {
>  	int		    irq;
>  	bool		    initialized;
>  	struct value_to_freq *val_to_freq;
> -	struct armada38x_rtc_data *data;
> +	const struct armada38x_rtc_data *data;
>  };
>  
>  #define ALARM1	0
> @@ -501,17 +501,14 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
>  {
>  	struct resource *res;
>  	struct armada38x_rtc *rtc;
> -	const struct of_device_id *match;
> -
> -	match = of_match_device(armada38x_rtc_of_match_table, &pdev->dev);
> -	if (!match)
> -		return -ENODEV;
>  
>  	rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc),
>  			    GFP_KERNEL);
>  	if (!rtc)
>  		return -ENOMEM;
>  
> +	rtc->data = of_device_get_match_data(&pdev->dev);
> +
>  	rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR,
>  				sizeof(struct value_to_freq), GFP_KERNEL);
>  	if (!rtc->val_to_freq)
> @@ -553,7 +550,6 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
>  		 */
>  		rtc->rtc_dev->ops = &armada38x_rtc_ops_noirq;
>  	}
> -	rtc->data = (struct armada38x_rtc_data *)match->data;
>  
>  	/* Update RTC-MBUS bridge timing parameters */
>  	rtc->data->update_mbus_timing(rtc);
> -- 
> Sent by a computer through tubes
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH 02/10] media: renesas-ceu: Use of_device_get_match_data()
  2019-10-04 21:43 ` [PATCH 02/10] media: renesas-ceu: " Stephen Boyd
@ 2019-10-09 12:54   ` Mauro Carvalho Chehab
  2019-10-09 13:14     ` Jacopo Mondi
  0 siblings, 1 reply; 31+ messages in thread
From: Mauro Carvalho Chehab @ 2019-10-09 12:54 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, Arnd Bergmann, Geert Uytterhoeven, Jacopo Mondi,
	Rob Herring, Frank Rowand, linux-media, linux-renesas-soc

Em Fri,  4 Oct 2019 14:43:26 -0700
Stephen Boyd <swboyd@chromium.org> escreveu:

> This driver can use the replacement API instead of calling
> of_match_device() and then dereferencing the pointer that is returned.
> This nicely avoids referencing the match table when it is undefined with
> configurations where CONFIG_OF=n.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Jacopo Mondi <jacopo@jmondi.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: <linux-media@vger.kernel.org>
> Cc: <linux-renesas-soc@vger.kernel.org>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> ---
> 
> Please ack or pick for immediate merge so the last patch can be merged.

Feel free to merge it via your tree:

Acked-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


> 
>  drivers/media/platform/renesas-ceu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c
> index 197b3991330d..60518bbc2cd5 100644
> --- a/drivers/media/platform/renesas-ceu.c
> +++ b/drivers/media/platform/renesas-ceu.c
> @@ -1679,7 +1679,7 @@ static int ceu_probe(struct platform_device *pdev)
>  	v4l2_async_notifier_init(&ceudev->notifier);
>  
>  	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
> -		ceu_data = of_match_device(ceu_of_match, dev)->data;
> +		ceu_data = of_device_get_match_data(dev);
>  		num_subdevs = ceu_parse_dt(ceudev);
>  	} else if (dev->platform_data) {
>  		/* Assume SH4 if booting with platform data. */



Thanks,
Mauro

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

* Re: [PATCH 02/10] media: renesas-ceu: Use of_device_get_match_data()
  2019-10-09 12:54   ` Mauro Carvalho Chehab
@ 2019-10-09 13:14     ` Jacopo Mondi
  0 siblings, 0 replies; 31+ messages in thread
From: Jacopo Mondi @ 2019-10-09 13:14 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Stephen Boyd, linux-kernel, Arnd Bergmann, Geert Uytterhoeven,
	Rob Herring, Frank Rowand, linux-media, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 2153 bytes --]

Sorry,
   totally missed it

On Wed, Oct 09, 2019 at 09:54:40AM -0300, Mauro Carvalho Chehab wrote:
> Em Fri,  4 Oct 2019 14:43:26 -0700
> Stephen Boyd <swboyd@chromium.org> escreveu:
>
> > This driver can use the replacement API instead of calling
> > of_match_device() and then dereferencing the pointer that is returned.
> > This nicely avoids referencing the match table when it is undefined with
> > configurations where CONFIG_OF=n.
> >
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> > Cc: Jacopo Mondi <jacopo@jmondi.org>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: <linux-media@vger.kernel.org>
> > Cc: <linux-renesas-soc@vger.kernel.org>
> > Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> > ---
> >
> > Please ack or pick for immediate merge so the last patch can be merged.
>
> Feel free to merge it via your tree:
>
> Acked-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
>

The CEU driver does probably not need this as the dereferencing of the
pointer returned by of_match_device() is guarded by
IS_ENABLED(CONFIG_OF), but surely this does not hurt and it's nicer to
read.

With Mauro's ack mine is probably not needed, but:
Acked-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Thanks
   j
>
> >
> >  drivers/media/platform/renesas-ceu.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c
> > index 197b3991330d..60518bbc2cd5 100644
> > --- a/drivers/media/platform/renesas-ceu.c
> > +++ b/drivers/media/platform/renesas-ceu.c
> > @@ -1679,7 +1679,7 @@ static int ceu_probe(struct platform_device *pdev)
> >  	v4l2_async_notifier_init(&ceudev->notifier);
> >
> >  	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
> > -		ceu_data = of_match_device(ceu_of_match, dev)->data;
> > +		ceu_data = of_device_get_match_data(dev);
> >  		num_subdevs = ceu_parse_dt(ceudev);
> >  	} else if (dev->platform_data) {
> >  		/* Assume SH4 if booting with platform data. */
>
>
>
> Thanks,
> Mauro

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-04 21:43 ` [PATCH 01/10] leds: pca953x: Use of_device_get_match_data() Stephen Boyd
  2019-10-06 12:15   ` Jacek Anaszewski
  2019-10-07  8:01   ` Geert Uytterhoeven
@ 2019-10-13 12:10   ` Pavel Machek
  2019-10-14 17:50   ` Andy Shevchenko
  2019-11-04  9:09   ` Pavel Machek
  4 siblings, 0 replies; 31+ messages in thread
From: Pavel Machek @ 2019-10-13 12:10 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, Arnd Bergmann, Geert Uytterhoeven, Riku Voipio,
	Rob Herring, Frank Rowand, Jacek Anaszewski, Dan Murphy,
	linux-leds

[-- Attachment #1: Type: text/plain, Size: 2789 bytes --]

On Fri 2019-10-04 14:43:25, Stephen Boyd wrote:
> This driver can use the of_device_get_match_data() API to simplify the
> code. Replace calls to of_match_device() with this newer API under the
> assumption that where it is called will be when we know the device is
> backed by a DT node. This nicely avoids referencing the match table when
> it is undefined with configurations where CONFIG_OF=n.

Thanks, applied.

								Pavel

> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Riku Voipio <riku.voipio@iki.fi>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Dan Murphy <dmurphy@ti.com>
> Cc: <linux-leds@vger.kernel.org>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> ---
> 
> Please ack or pick for immediate merge so the last patch can be merged.
> 
>  drivers/leds/leds-pca9532.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
> index c7c7199e8ebd..7d515d5e57bd 100644
> --- a/drivers/leds/leds-pca9532.c
> +++ b/drivers/leds/leds-pca9532.c
> @@ -467,16 +467,11 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np)
>  {
>  	struct pca9532_platform_data *pdata;
>  	struct device_node *child;
> -	const struct of_device_id *match;
>  	int devid, maxleds;
>  	int i = 0;
>  	const char *state;
>  
> -	match = of_match_device(of_pca9532_leds_match, dev);
> -	if (!match)
> -		return ERR_PTR(-ENODEV);
> -
> -	devid = (int)(uintptr_t)match->data;
> +	devid = (int)(uintptr_t)of_device_get_match_data(dev);
>  	maxleds = pca9532_chip_info_tbl[devid].num_leds;
>  
>  	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> @@ -509,7 +504,6 @@ static int pca9532_probe(struct i2c_client *client,
>  	const struct i2c_device_id *id)
>  {
>  	int devid;
> -	const struct of_device_id *of_id;
>  	struct pca9532_data *data = i2c_get_clientdata(client);
>  	struct pca9532_platform_data *pca9532_pdata =
>  			dev_get_platdata(&client->dev);
> @@ -525,11 +519,7 @@ static int pca9532_probe(struct i2c_client *client,
>  			dev_err(&client->dev, "no platform data\n");
>  			return -EINVAL;
>  		}
> -		of_id = of_match_device(of_pca9532_leds_match,
> -				&client->dev);
> -		if (unlikely(!of_id))
> -			return -EINVAL;
> -		devid = (int)(uintptr_t) of_id->data;
> +		devid = (int)(uintptr_t)of_device_get_match_data(&client->dev);
>  	} else {
>  		devid = id->driver_data;
>  	}

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-04 21:43 ` [PATCH 01/10] leds: pca953x: Use of_device_get_match_data() Stephen Boyd
                     ` (2 preceding siblings ...)
  2019-10-13 12:10   ` Pavel Machek
@ 2019-10-14 17:50   ` Andy Shevchenko
  2019-10-14 20:54     ` Stephen Boyd
  2019-11-04  9:09   ` Pavel Machek
  4 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2019-10-14 17:50 UTC (permalink / raw)
  To: Stephen Boyd, Wolfram Sang
  Cc: Linux Kernel Mailing List, Arnd Bergmann, Geert Uytterhoeven,
	Riku Voipio, Rob Herring, Frank Rowand, Jacek Anaszewski,
	Pavel Machek, Dan Murphy, Linux LED Subsystem

On Sat, Oct 5, 2019 at 12:47 AM Stephen Boyd <swboyd@chromium.org> wrote:
>
> This driver can use the of_device_get_match_data() API to simplify the
> code. Replace calls to of_match_device() with this newer API under the
> assumption that where it is called will be when we know the device is
> backed by a DT node. This nicely avoids referencing the match table when
> it is undefined with configurations where CONFIG_OF=n.

> +       devid = (int)(uintptr_t)of_device_get_match_data(dev);

> +               devid = (int)(uintptr_t)of_device_get_match_data(&client->dev);

This still leaves it OF-centric.
Better to use device_get_match_data().

Also, I'm thinking that following may help to clean a lot of the i2c
client drivers

static inline // perhaps no
const void *i2c_device_get_match_data(struct i2c_client *client, const
struct i2c_device_id *id)
{
  if (id)
    return (const void *)id->driver_data;
  return device_get_match_data(&client->dev);
}

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-14 17:50   ` Andy Shevchenko
@ 2019-10-14 20:54     ` Stephen Boyd
  2019-10-15  9:02       ` Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-14 20:54 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang
  Cc: Linux Kernel Mailing List, Arnd Bergmann, Geert Uytterhoeven,
	Riku Voipio, Rob Herring, Frank Rowand, Jacek Anaszewski,
	Pavel Machek, Dan Murphy, Linux LED Subsystem

Quoting Andy Shevchenko (2019-10-14 10:50:06)
> On Sat, Oct 5, 2019 at 12:47 AM Stephen Boyd <swboyd@chromium.org> wrote:
> >
> > This driver can use the of_device_get_match_data() API to simplify the
> > code. Replace calls to of_match_device() with this newer API under the
> > assumption that where it is called will be when we know the device is
> > backed by a DT node. This nicely avoids referencing the match table when
> > it is undefined with configurations where CONFIG_OF=n.
> 
> > +       devid = (int)(uintptr_t)of_device_get_match_data(dev);
> 
> > +               devid = (int)(uintptr_t)of_device_get_match_data(&client->dev);
> 
> This still leaves it OF-centric.
> Better to use device_get_match_data().
> 
> Also, I'm thinking that following may help to clean a lot of the i2c
> client drivers
> 
> static inline // perhaps no
> const void *i2c_device_get_match_data(struct i2c_client *client, const
> struct i2c_device_id *id)
> {
>   if (id)
>     return (const void *)id->driver_data;
>   return device_get_match_data(&client->dev);
> }
> 

Looks alright to me. Maybe device_get_match_data() can look at the bus
and call some bus op if the firmware match isn't present? Then we can
replace a bunch of these calls with device_get_match_data() and it will
"do the right thing" regardless of what bus or firmware the device is
running on.


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

* Re: [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-14 20:54     ` Stephen Boyd
@ 2019-10-15  9:02       ` Andy Shevchenko
  2019-10-15 22:41         ` Stephen Boyd
  0 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2019-10-15  9:02 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Wolfram Sang, Linux Kernel Mailing List, Arnd Bergmann,
	Geert Uytterhoeven, Riku Voipio, Rob Herring, Frank Rowand,
	Jacek Anaszewski, Pavel Machek, Dan Murphy, Linux LED Subsystem

On Mon, Oct 14, 2019 at 11:54 PM Stephen Boyd <swboyd@chromium.org> wrote:
> Quoting Andy Shevchenko (2019-10-14 10:50:06)
> > On Sat, Oct 5, 2019 at 12:47 AM Stephen Boyd <swboyd@chromium.org> wrote:
> > >
> > > This driver can use the of_device_get_match_data() API to simplify the
> > > code. Replace calls to of_match_device() with this newer API under the
> > > assumption that where it is called will be when we know the device is
> > > backed by a DT node. This nicely avoids referencing the match table when
> > > it is undefined with configurations where CONFIG_OF=n.
> >
> > > +       devid = (int)(uintptr_t)of_device_get_match_data(dev);
> >
> > > +               devid = (int)(uintptr_t)of_device_get_match_data(&client->dev);
> >
> > This still leaves it OF-centric.
> > Better to use device_get_match_data().
> >
> > Also, I'm thinking that following may help to clean a lot of the i2c
> > client drivers
> >
> > static inline // perhaps no
> > const void *i2c_device_get_match_data(struct i2c_client *client, const
> > struct i2c_device_id *id)
> > {
> >   if (id)
> >     return (const void *)id->driver_data;
> >   return device_get_match_data(&client->dev);
> > }
> >
>
> Looks alright to me. Maybe device_get_match_data() can look at the bus
> and call some bus op if the firmware match isn't present? Then we can
> replace a bunch of these calls with device_get_match_data() and it will
> "do the right thing" regardless of what bus or firmware the device is
> running on.

It will be something ugly like

buses {
#ifdef I2C
&i2c_bus_type,
#endif
...
}

in the code. I won't do this.

See generic_match_buses[] for example.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-15  9:02       ` Andy Shevchenko
@ 2019-10-15 22:41         ` Stephen Boyd
  2019-10-16 13:46           ` Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Stephen Boyd @ 2019-10-15 22:41 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Wolfram Sang, Linux Kernel Mailing List, Arnd Bergmann,
	Geert Uytterhoeven, Riku Voipio, Rob Herring, Frank Rowand,
	Jacek Anaszewski, Pavel Machek, Dan Murphy, Linux LED Subsystem

Quoting Andy Shevchenko (2019-10-15 02:02:01)
> On Mon, Oct 14, 2019 at 11:54 PM Stephen Boyd <swboyd@chromium.org> wrote:
> > Quoting Andy Shevchenko (2019-10-14 10:50:06)
> > > On Sat, Oct 5, 2019 at 12:47 AM Stephen Boyd <swboyd@chromium.org> wrote:
> > > >
> > > > This driver can use the of_device_get_match_data() API to simplify the
> > > > code. Replace calls to of_match_device() with this newer API under the
> > > > assumption that where it is called will be when we know the device is
> > > > backed by a DT node. This nicely avoids referencing the match table when
> > > > it is undefined with configurations where CONFIG_OF=n.
> > >
> > > > +       devid = (int)(uintptr_t)of_device_get_match_data(dev);
> > >
> > > > +               devid = (int)(uintptr_t)of_device_get_match_data(&client->dev);
> > >
> > > This still leaves it OF-centric.
> > > Better to use device_get_match_data().
> > >
> > > Also, I'm thinking that following may help to clean a lot of the i2c
> > > client drivers
> > >
> > > static inline // perhaps no
> > > const void *i2c_device_get_match_data(struct i2c_client *client, const
> > > struct i2c_device_id *id)
> > > {
> > >   if (id)
> > >     return (const void *)id->driver_data;
> > >   return device_get_match_data(&client->dev);
> > > }
> > >
> >
> > Looks alright to me. Maybe device_get_match_data() can look at the bus
> > and call some bus op if the firmware match isn't present? Then we can
> > replace a bunch of these calls with device_get_match_data() and it will
> > "do the right thing" regardless of what bus or firmware the device is
> > running on.
> 
> It will be something ugly like
> 
> buses {
> #ifdef I2C
> &i2c_bus_type,
> #endif
> ...
> }
> 
> in the code. I won't do this.
> 
> See generic_match_buses[] for example.

Why is it like generic_match_buses[]? I thought it would look at
struct device::of_node or struct device::fw_node and try to extract
device data out that and if that fails it would fallback to some new
function like struct bus_type::get_match_data() that does the right
thing for the bus. In the case of i2c it would extract the i2c_client's
i2c_device_id pointer and return it onwards.


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

* Re: [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-15 22:41         ` Stephen Boyd
@ 2019-10-16 13:46           ` Andy Shevchenko
  0 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2019-10-16 13:46 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Wolfram Sang, Linux Kernel Mailing List, Arnd Bergmann,
	Geert Uytterhoeven, Riku Voipio, Rob Herring, Frank Rowand,
	Jacek Anaszewski, Pavel Machek, Dan Murphy, Linux LED Subsystem

On Wed, Oct 16, 2019 at 1:42 AM Stephen Boyd <swboyd@chromium.org> wrote:
> Quoting Andy Shevchenko (2019-10-15 02:02:01)
> > On Mon, Oct 14, 2019 at 11:54 PM Stephen Boyd <swboyd@chromium.org> wrote:
> > > Quoting Andy Shevchenko (2019-10-14 10:50:06)
> > > > On Sat, Oct 5, 2019 at 12:47 AM Stephen Boyd <swboyd@chromium.org> wrote:

> > > > Also, I'm thinking that following may help to clean a lot of the i2c
> > > > client drivers
> > > >
> > > > static inline // perhaps no
> > > > const void *i2c_device_get_match_data(struct i2c_client *client, const
> > > > struct i2c_device_id *id)
> > > > {
> > > >   if (id)
> > > >     return (const void *)id->driver_data;
> > > >   return device_get_match_data(&client->dev);
> > > > }
> > > >
> > >
> > > Looks alright to me. Maybe device_get_match_data() can look at the bus
> > > and call some bus op if the firmware match isn't present? Then we can
> > > replace a bunch of these calls with device_get_match_data() and it will
> > > "do the right thing" regardless of what bus or firmware the device is
> > > running on.
> >
> > It will be something ugly like
> >
> > buses {
> > #ifdef I2C
> > &i2c_bus_type,
> > #endif
> > ...
> > }
> >
> > in the code. I won't do this.
> >
> > See generic_match_buses[] for example.
>
> Why is it like generic_match_buses[]? I thought it would look at
> struct device::of_node or struct device::fw_node and try to extract
> device data out that and if that fails it would fallback to some new
> function like struct bus_type::get_match_data() that does the right
> thing for the bus. In the case of i2c it would extract the i2c_client's
> i2c_device_id pointer and return it onwards.

Can you send a patch for review?

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 10/10] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n
  2019-10-04 21:43 ` [PATCH 10/10] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Stephen Boyd
@ 2019-10-17 17:47   ` Frank Rowand
  2019-10-17 20:24     ` Rob Herring
  0 siblings, 1 reply; 31+ messages in thread
From: Frank Rowand @ 2019-10-17 17:47 UTC (permalink / raw)
  To: Stephen Boyd, linux-kernel, Rob Herring; +Cc: Arnd Bergmann, Geert Uytterhoeven

On 10/04/2019 16:43, Stephen Boyd wrote:
> This effectively reverts 1db73ae39a97 ("of/device: Nullify match table
> in of_match_device() for CONFIG_OF=n") because that commit makes it more
> surprising to users of this API that the arguments may never be
> referenced by any code. This is because the pre-processor will replace
> the argument with NULL and then the match table will be left unreferenced
> by any code but the compiler optimizer doesn't know to drop it. This can
> lead to compilers warning that match tables are unused, when we really
> want to pass the match table to the API but have the compiler see that
> it's all inlined and not used and then drop the match table while
> silencing the warning. We're being too smart here and not giving the
> compiler the chance to do dead code elimination.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> ---
> 
> Please ack or pick for immediate merge so the last patch can be merged.
> 
>  include/linux/of_device.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index 8d31e39dd564..3f8ca55bc693 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -93,13 +93,11 @@ static inline int of_device_uevent_modalias(struct device *dev,
>  
>  static inline void of_device_node_put(struct device *dev) { }
>  
> -static inline const struct of_device_id *__of_match_device(
> +static inline const struct of_device_id *of_match_device(
>  		const struct of_device_id *matches, const struct device *dev)
>  {
>  	return NULL;
>  }
> -#define of_match_device(matches, dev)	\
> -	__of_match_device(of_match_ptr(matches), (dev))
>  
>  static inline struct device_node *of_cpu_device_node_get(int cpu)
>  {
> 


Acked-by: Frank Rowand <frowand.list@gmail.com>

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

* Re: [PATCH 10/10] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n
  2019-10-17 17:47   ` Frank Rowand
@ 2019-10-17 20:24     ` Rob Herring
  2019-10-17 20:48       ` Stephen Boyd
  0 siblings, 1 reply; 31+ messages in thread
From: Rob Herring @ 2019-10-17 20:24 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, Arnd Bergmann, Geert Uytterhoeven, Frank Rowand

On Thu, Oct 17, 2019 at 12:48 PM Frank Rowand <frowand.list@gmail.com> wrote:
>
> On 10/04/2019 16:43, Stephen Boyd wrote:
> > This effectively reverts 1db73ae39a97 ("of/device: Nullify match table
> > in of_match_device() for CONFIG_OF=n") because that commit makes it more
> > surprising to users of this API that the arguments may never be
> > referenced by any code. This is because the pre-processor will replace
> > the argument with NULL and then the match table will be left unreferenced
> > by any code but the compiler optimizer doesn't know to drop it. This can
> > lead to compilers warning that match tables are unused, when we really
> > want to pass the match table to the API but have the compiler see that
> > it's all inlined and not used and then drop the match table while
> > silencing the warning. We're being too smart here and not giving the
> > compiler the chance to do dead code elimination.
> >
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> > ---
> >
> > Please ack or pick for immediate merge so the last patch can be merged.

As this one is the last patch, I guess you don't want it picked up by itself.

It seems everyone has acked rather than applying. Do you want me to
take the series?

Rob

> >
> >  include/linux/of_device.h | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> > index 8d31e39dd564..3f8ca55bc693 100644
> > --- a/include/linux/of_device.h
> > +++ b/include/linux/of_device.h
> > @@ -93,13 +93,11 @@ static inline int of_device_uevent_modalias(struct device *dev,
> >
> >  static inline void of_device_node_put(struct device *dev) { }
> >
> > -static inline const struct of_device_id *__of_match_device(
> > +static inline const struct of_device_id *of_match_device(
> >               const struct of_device_id *matches, const struct device *dev)
> >  {
> >       return NULL;
> >  }
> > -#define of_match_device(matches, dev)        \
> > -     __of_match_device(of_match_ptr(matches), (dev))
> >
> >  static inline struct device_node *of_cpu_device_node_get(int cpu)
> >  {
> >
>
>
> Acked-by: Frank Rowand <frowand.list@gmail.com>

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

* Re: [PATCH 10/10] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n
  2019-10-17 20:24     ` Rob Herring
@ 2019-10-17 20:48       ` Stephen Boyd
  0 siblings, 0 replies; 31+ messages in thread
From: Stephen Boyd @ 2019-10-17 20:48 UTC (permalink / raw)
  To: Rob Herring; +Cc: linux-kernel, Arnd Bergmann, Geert Uytterhoeven, Frank Rowand

Quoting Rob Herring (2019-10-17 13:24:23)
> On Thu, Oct 17, 2019 at 12:48 PM Frank Rowand <frowand.list@gmail.com> wrote:
> >
> > On 10/04/2019 16:43, Stephen Boyd wrote:
> > > This effectively reverts 1db73ae39a97 ("of/device: Nullify match table
> > > in of_match_device() for CONFIG_OF=n") because that commit makes it more
> > > surprising to users of this API that the arguments may never be
> > > referenced by any code. This is because the pre-processor will replace
> > > the argument with NULL and then the match table will be left unreferenced
> > > by any code but the compiler optimizer doesn't know to drop it. This can
> > > lead to compilers warning that match tables are unused, when we really
> > > want to pass the match table to the API but have the compiler see that
> > > it's all inlined and not used and then drop the match table while
> > > silencing the warning. We're being too smart here and not giving the
> > > compiler the chance to do dead code elimination.
> > >
> > > Cc: Arnd Bergmann <arnd@arndb.de>
> > > Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> > > Cc: Rob Herring <robh+dt@kernel.org>
> > > Cc: Frank Rowand <frowand.list@gmail.com>
> > > Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> > > ---
> > >
> > > Please ack or pick for immediate merge so the last patch can be merged.
> 
> As this one is the last patch, I guess you don't want it picked up by itself.
> 
> It seems everyone has acked rather than applying. Do you want me to
> take the series?
> 

It would be great if you could take the series.

Mark applied the ASoC and spi patches. I guess you can try to see if
those merged into mainline and then base on top, or just apply the same
patches on your tree and let the duplicates drop out in the merge path.


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

* Re: [PATCH 01/10] leds: pca953x: Use of_device_get_match_data()
  2019-10-04 21:43 ` [PATCH 01/10] leds: pca953x: Use of_device_get_match_data() Stephen Boyd
                     ` (3 preceding siblings ...)
  2019-10-14 17:50   ` Andy Shevchenko
@ 2019-11-04  9:09   ` Pavel Machek
  4 siblings, 0 replies; 31+ messages in thread
From: Pavel Machek @ 2019-11-04  9:09 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, Arnd Bergmann, Geert Uytterhoeven, Riku Voipio,
	Rob Herring, Frank Rowand, Jacek Anaszewski, Dan Murphy,
	linux-leds

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

Hi!

> This driver can use the of_device_get_match_data() API to simplify the
> code. Replace calls to of_match_device() with this newer API under the
> assumption that where it is called will be when we know the device is
> backed by a DT node. This nicely avoids referencing the match table when
> it is undefined with configurations where CONFIG_OF=n.


> Please ack or pick for immediate merge so the last patch can be
  merged.

I see nothing obviously wrong, so...

Acked-by: Pavel Machek <pavel@ucw.cz>

... but it did not apply on top of leds-next tree.

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

end of thread, other threads:[~2019-11-04  9:09 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 21:43 [PATCH 00/10] Stop NULLifying match pointer in of_match_device() Stephen Boyd
2019-10-04 21:43 ` [PATCH 01/10] leds: pca953x: Use of_device_get_match_data() Stephen Boyd
2019-10-06 12:15   ` Jacek Anaszewski
2019-10-07  8:01   ` Geert Uytterhoeven
2019-10-13 12:10   ` Pavel Machek
2019-10-14 17:50   ` Andy Shevchenko
2019-10-14 20:54     ` Stephen Boyd
2019-10-15  9:02       ` Andy Shevchenko
2019-10-15 22:41         ` Stephen Boyd
2019-10-16 13:46           ` Andy Shevchenko
2019-11-04  9:09   ` Pavel Machek
2019-10-04 21:43 ` [PATCH 02/10] media: renesas-ceu: " Stephen Boyd
2019-10-09 12:54   ` Mauro Carvalho Chehab
2019-10-09 13:14     ` Jacopo Mondi
2019-10-04 21:43 ` [PATCH 03/10] rtc: armada38x: " Stephen Boyd
2019-10-07 13:53   ` Alexandre Belloni
2019-10-04 21:43 ` [PATCH 04/10] drivers: net: davinci_mdio: " Stephen Boyd
2019-10-04 21:43 ` [PATCH 05/10] serial: stm32: " Stephen Boyd
2019-10-05  6:53   ` Greg Kroah-Hartman
2019-10-04 21:43 ` [PATCH 06/10] usb: usb251xb: " Stephen Boyd
2019-10-05  6:53   ` Greg Kroah-Hartman
2019-10-04 21:43 ` [PATCH 07/10] ASoC: jz4740: " Stephen Boyd
2019-10-07 13:03   ` Applied "ASoC: jz4740: Use of_device_get_match_data()" to the asoc tree Mark Brown
2019-10-04 21:43 ` [PATCH 08/10] spi: gpio: Look for a device node instead of match Stephen Boyd
2019-10-07 13:03   ` Applied "spi: gpio: Look for a device node instead of match" to the spi tree Mark Brown
2019-10-04 21:43 ` [PATCH 09/10] hwmon: (lm70) Avoid undefined reference to match table Stephen Boyd
2019-10-04 23:03   ` Guenter Roeck
2019-10-04 21:43 ` [PATCH 10/10] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Stephen Boyd
2019-10-17 17:47   ` Frank Rowand
2019-10-17 20:24     ` Rob Herring
2019-10-17 20:48       ` Stephen Boyd

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