linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6]  Stop NULLifying match pointer in of_match_device()
@ 2021-01-23  3:44 Stephen Boyd
  2021-01-23  3:44 ` [PATCH v2 1/6] media: renesas-ceu: Use of_device_get_match_data() Stephen Boyd
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Stephen Boyd @ 2021-01-23  3:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree, Alexandre Torgue, Arnd Bergmann,
	David S. Miller, Frank Rowand, Geert Uytterhoeven,
	Greg Kroah-Hartman, Grygorii Strashko, Guenter Roeck,
	Jacopo Mondi, Jean Delvare, Jiri Slaby, linux-hwmon, linux-media,
	linux-omap, linux-renesas-soc, linux-serial, linux-usb,
	Mauro Carvalho Chehab, Maxime Coquelin, Richard Leitner,
	Rob Herring

(This is a continuation of this series[1] per Rob's request. I've picked
up the acks, etc. with b4 and compile tested the patches along with an
arm64 allmodconfig build. Presumably Rob will pick these up directly.)

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.

[1] https://lore.kernel.org/r/20191004214334.149976-1-swboyd@chromium.org

Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Arnd Bergmann <arnd@arndb.de>
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: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Jacopo Mondi <jacopo@jmondi.org>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: <linux-hwmon@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
Cc: <linux-media@vger.kernel.org>
Cc: <linux-omap@vger.kernel.org>
Cc: <linux-renesas-soc@vger.kernel.org>
Cc: <linux-serial@vger.kernel.org>
Cc: <linux-usb@vger.kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Richard Leitner <richard.leitner@skidata.com>
Cc: Rob Herring <robh+dt@kernel.org>

Stephen Boyd (6):
  media: renesas-ceu: 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()
  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/media/platform/renesas-ceu.c   |  2 +-
 drivers/net/ethernet/ti/davinci_mdio.c | 12 ++---
 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 +-
 7 files changed, 47 insertions(+), 58 deletions(-)


base-commit: 19c329f6808995b142b3966301f217c831e7cf31
-- 
https://chromeos.dev


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

* [PATCH v2 1/6] media: renesas-ceu: Use of_device_get_match_data()
  2021-01-23  3:44 [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Stephen Boyd
@ 2021-01-23  3:44 ` Stephen Boyd
  2021-01-25  8:30   ` Geert Uytterhoeven
  2021-01-23  3:44 ` [PATCH v2 2/6] drivers: net: davinci_mdio: " Stephen Boyd
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Stephen Boyd @ 2021-01-23  3:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree, Mauro Carvalho Chehab, Jacopo Mondi,
	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.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
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>
---

Please ack so Rob can apply.

 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 4a633ad0e8fa..352e7c84d5ba 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. */
-- 
https://chromeos.dev


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

* [PATCH v2 2/6] drivers: net: davinci_mdio: Use of_device_get_match_data()
  2021-01-23  3:44 [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Stephen Boyd
  2021-01-23  3:44 ` [PATCH v2 1/6] media: renesas-ceu: Use of_device_get_match_data() Stephen Boyd
@ 2021-01-23  3:44 ` Stephen Boyd
  2021-01-26 13:11   ` Grygorii Strashko
  2021-01-23  3:44 ` [PATCH v2 3/6] serial: stm32: " Stephen Boyd
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Stephen Boyd @ 2021-01-23  3:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree, 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.

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

Please ack so Rob can apply.

 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 cfff3d48807a..a4efd5e35158 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 {
-- 
https://chromeos.dev


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

* [PATCH v2 3/6] serial: stm32: Use of_device_get_match_data()
  2021-01-23  3:44 [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Stephen Boyd
  2021-01-23  3:44 ` [PATCH v2 1/6] media: renesas-ceu: Use of_device_get_match_data() Stephen Boyd
  2021-01-23  3:44 ` [PATCH v2 2/6] drivers: net: davinci_mdio: " Stephen Boyd
@ 2021-01-23  3:44 ` Stephen Boyd
  2021-01-23  3:44 ` [PATCH v2 4/6] usb: usb251xb: " Stephen Boyd
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2021-01-23  3:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree, Greg Kroah-Hartman, Arnd Bergmann,
	Geert Uytterhoeven, 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.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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>
---

Please ack so Rob can apply.

 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 f4de32d3f2af..99f04db73830 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -99,8 +99,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;
 
@@ -166,7 +166,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;
 
@@ -191,7 +191,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) {
@@ -211,7 +211,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;
@@ -282,7 +282,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;
@@ -294,7 +294,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,
@@ -309,7 +309,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);
@@ -320,7 +320,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) {
@@ -347,7 +347,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;
 	unsigned int count, i;
@@ -407,7 +407,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) {
@@ -447,7 +447,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);
@@ -494,7 +494,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;
 }
@@ -502,7 +502,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);
@@ -579,7 +579,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);
@@ -594,7 +594,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);
@@ -609,7 +609,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)
@@ -625,7 +625,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;
@@ -661,8 +661,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;
 
@@ -721,8 +721,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;
@@ -921,8 +921,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) {
@@ -1081,7 +1081,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;
@@ -1152,7 +1152,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;
@@ -1202,7 +1202,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;
 
@@ -1210,10 +1209,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);
@@ -1272,7 +1269,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);
@@ -1317,7 +1314,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();
@@ -1329,8 +1326,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;
@@ -1416,8 +1413,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 d4c916e78d40..cb4f327c46db 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 */
-- 
https://chromeos.dev


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

* [PATCH v2 4/6] usb: usb251xb: Use of_device_get_match_data()
  2021-01-23  3:44 [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (2 preceding siblings ...)
  2021-01-23  3:44 ` [PATCH v2 3/6] serial: stm32: " Stephen Boyd
@ 2021-01-23  3:44 ` Stephen Boyd
  2021-01-23  3:44 ` [PATCH v2 5/6] hwmon: (lm70) Avoid undefined reference to match table Stephen Boyd
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2021-01-23  3:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree, Greg Kroah-Hartman, Arnd Bergmann,
	Geert Uytterhoeven, Richard Leitner, 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.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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>
---

Please ack so Rob can apply.

 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 29fe5771c21b..507deef1f709 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -396,7 +396,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;
@@ -630,7 +630,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;
 }
@@ -647,13 +647,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;
-- 
https://chromeos.dev


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

* [PATCH v2 5/6] hwmon: (lm70) Avoid undefined reference to match table
  2021-01-23  3:44 [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (3 preceding siblings ...)
  2021-01-23  3:44 ` [PATCH v2 4/6] usb: usb251xb: " Stephen Boyd
@ 2021-01-23  3:44 ` Stephen Boyd
  2021-01-23  6:09   ` Guenter Roeck
  2021-01-26 18:30   ` Rob Herring
  2021-01-23  3:44 ` [PATCH v2 6/6] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Stephen Boyd
  2021-01-26 18:21 ` [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Rob Herring
  6 siblings, 2 replies; 14+ messages in thread
From: Stephen Boyd @ 2021-01-23  3:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree, Guenter Roeck, Arnd Bergmann,
	Geert Uytterhoeven, Jean Delvare, 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.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-hwmon@vger.kernel.org>
---

Please ack so Rob can apply.

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

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


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

* [PATCH v2 6/6] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n
  2021-01-23  3:44 [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (4 preceding siblings ...)
  2021-01-23  3:44 ` [PATCH v2 5/6] hwmon: (lm70) Avoid undefined reference to match table Stephen Boyd
@ 2021-01-23  3:44 ` Stephen Boyd
  2021-01-25  8:33   ` Geert Uytterhoeven
  2021-01-25  9:46   ` Arnd Bergmann
  2021-01-26 18:21 ` [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Rob Herring
  6 siblings, 2 replies; 14+ messages in thread
From: Stephen Boyd @ 2021-01-23  3:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree, Frank Rowand, Arnd Bergmann,
	Geert Uytterhoeven, Rob Herring

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.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Frank Rowand <frowand.list@gmail.com>
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>
---

Please ack so Rob can apply.

 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 07ca187fc5e4..937f32f6aecb 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -99,13 +99,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)
 {
-- 
https://chromeos.dev


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

* Re: [PATCH v2 5/6] hwmon: (lm70) Avoid undefined reference to match table
  2021-01-23  3:44 ` [PATCH v2 5/6] hwmon: (lm70) Avoid undefined reference to match table Stephen Boyd
@ 2021-01-23  6:09   ` Guenter Roeck
  2021-01-26 18:30   ` Rob Herring
  1 sibling, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2021-01-23  6:09 UTC (permalink / raw)
  To: Stephen Boyd, Rob Herring
  Cc: linux-kernel, devicetree, Arnd Bergmann, Geert Uytterhoeven,
	Jean Delvare, Rob Herring, Frank Rowand, linux-hwmon

On 1/22/21 7:44 PM, 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.
> 
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> Acked-by: Guenter Roeck <linux@roeck-us.net>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: <linux-hwmon@vger.kernel.org>
> ---
> 
> Please ack so Rob can apply.
> 

This patch already has my Acked-by: above.

Guenter

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


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

* Re: [PATCH v2 1/6] media: renesas-ceu: Use of_device_get_match_data()
  2021-01-23  3:44 ` [PATCH v2 1/6] media: renesas-ceu: Use of_device_get_match_data() Stephen Boyd
@ 2021-01-25  8:30   ` Geert Uytterhoeven
  0 siblings, 0 replies; 14+ messages in thread
From: Geert Uytterhoeven @ 2021-01-25  8:30 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Rob Herring, Linux Kernel Mailing List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Mauro Carvalho Chehab, Jacopo Mondi, Arnd Bergmann, Jacopo Mondi,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Linux Media Mailing List, Linux-Renesas

On Sat, Jan 23, 2021 at 4:44 AM Stephen Boyd <swboyd@chromium.org> wrote:
> 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.
>
> 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] 14+ messages in thread

* Re: [PATCH v2 6/6] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n
  2021-01-23  3:44 ` [PATCH v2 6/6] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Stephen Boyd
@ 2021-01-25  8:33   ` Geert Uytterhoeven
  2021-01-25  9:46   ` Arnd Bergmann
  1 sibling, 0 replies; 14+ messages in thread
From: Geert Uytterhoeven @ 2021-01-25  8:33 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Rob Herring, Linux Kernel Mailing List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Frank Rowand, Arnd Bergmann, Rob Herring

On Sat, Jan 23, 2021 at 4:44 AM Stephen Boyd <swboyd@chromium.org> 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.
>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> Acked-by: Frank Rowand <frowand.list@gmail.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-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] 14+ messages in thread

* Re: [PATCH v2 6/6] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n
  2021-01-23  3:44 ` [PATCH v2 6/6] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Stephen Boyd
  2021-01-25  8:33   ` Geert Uytterhoeven
@ 2021-01-25  9:46   ` Arnd Bergmann
  1 sibling, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2021-01-25  9:46 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Rob Herring, linux-kernel, DTML, Frank Rowand, Arnd Bergmann,
	Geert Uytterhoeven, Rob Herring

On Sat, Jan 23, 2021 at 4:44 AM Stephen Boyd <swboyd@chromium.org> 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.
>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> Acked-by: Frank Rowand <frowand.list@gmail.com>
> 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>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH v2 2/6] drivers: net: davinci_mdio: Use of_device_get_match_data()
  2021-01-23  3:44 ` [PATCH v2 2/6] drivers: net: davinci_mdio: " Stephen Boyd
@ 2021-01-26 13:11   ` Grygorii Strashko
  0 siblings, 0 replies; 14+ messages in thread
From: Grygorii Strashko @ 2021-01-26 13:11 UTC (permalink / raw)
  To: Stephen Boyd, Rob Herring
  Cc: linux-kernel, devicetree, Arnd Bergmann, Geert Uytterhoeven,
	David S. Miller, Rob Herring, Frank Rowand, linux-omap



On 23/01/2021 05:44, 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.
> 
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> 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>
> ---
> 
> Please ack so Rob can apply.
> 
>   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 cfff3d48807a..a4efd5e35158 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 {
> 

Thank you.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>

-- 
Best regards,
grygorii

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

* Re: [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device()
  2021-01-23  3:44 [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Stephen Boyd
                   ` (5 preceding siblings ...)
  2021-01-23  3:44 ` [PATCH v2 6/6] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Stephen Boyd
@ 2021-01-26 18:21 ` Rob Herring
  6 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2021-01-26 18:21 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, devicetree, Alexandre Torgue, Arnd Bergmann,
	David S. Miller, Frank Rowand, Geert Uytterhoeven,
	Greg Kroah-Hartman, Grygorii Strashko, Guenter Roeck,
	Jacopo Mondi, Jean Delvare, Jiri Slaby, Linux HWMON List,
	Linux Media Mailing List, linux-omap,
	open list:MEDIA DRIVERS FOR RENESAS - FCP,
	open list:SERIAL DRIVERS, Linux USB List, Mauro Carvalho Chehab,
	Maxime Coquelin, Richard Leitner

On Fri, Jan 22, 2021 at 9:44 PM Stephen Boyd <swboyd@chromium.org> wrote:
>
> (This is a continuation of this series[1] per Rob's request. I've picked
> up the acks, etc. with b4 and compile tested the patches along with an
> arm64 allmodconfig build. Presumably Rob will pick these up directly.)
>
> 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.
>
> [1] https://lore.kernel.org/r/20191004214334.149976-1-swboyd@chromium.org
>
> Cc: Alexandre Torgue <alexandre.torgue@st.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> 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: Grygorii Strashko <grygorii.strashko@ti.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Jacopo Mondi <jacopo@jmondi.org>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Jiri Slaby <jslaby@suse.com>
> Cc: <linux-hwmon@vger.kernel.org>
> Cc: <linux-kernel@vger.kernel.org>,
> Cc: <linux-media@vger.kernel.org>
> Cc: <linux-omap@vger.kernel.org>
> Cc: <linux-renesas-soc@vger.kernel.org>
> Cc: <linux-serial@vger.kernel.org>
> Cc: <linux-usb@vger.kernel.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Richard Leitner <richard.leitner@skidata.com>
> Cc: Rob Herring <robh+dt@kernel.org>
>
> Stephen Boyd (6):
>   media: renesas-ceu: 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()
>   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/media/platform/renesas-ceu.c   |  2 +-
>  drivers/net/ethernet/ti/davinci_mdio.c | 12 ++---
>  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 +-
>  7 files changed, 47 insertions(+), 58 deletions(-)

Series applied.


Rob

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

* Re: [PATCH v2 5/6] hwmon: (lm70) Avoid undefined reference to match table
  2021-01-23  3:44 ` [PATCH v2 5/6] hwmon: (lm70) Avoid undefined reference to match table Stephen Boyd
  2021-01-23  6:09   ` Guenter Roeck
@ 2021-01-26 18:30   ` Rob Herring
  1 sibling, 0 replies; 14+ messages in thread
From: Rob Herring @ 2021-01-26 18:30 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, devicetree, Guenter Roeck, Arnd Bergmann,
	Geert Uytterhoeven, Jean Delvare, Frank Rowand, Linux HWMON List

On Fri, Jan 22, 2021 at 9:44 PM Stephen Boyd <swboyd@chromium.org> wrote:
>
> We're going to remove of_match_ptr() from the definition of
> of_match_device() when CONFIG_OF=n. This way we can always be certain
> that of_match_device() acts the same when CONFIG_OF is set and when it
> isn't. Add of_match_ptr() here so that this doesn't break when that
> change is made to the of_match_device() API.
>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> Acked-by: Guenter Roeck <linux@roeck-us.net>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: <linux-hwmon@vger.kernel.org>
> ---
>
> Please ack so Rob can apply.
>
>  drivers/hwmon/lm70.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
> index ae2b84263a44..e3153ae80634 100644
> --- a/drivers/hwmon/lm70.c
> +++ b/drivers/hwmon/lm70.c
> @@ -178,7 +178,7 @@ static int lm70_probe(struct spi_device *spi)
>         struct lm70 *p_lm70;
>         int chip;
>
> -       of_match = of_match_device(lm70_of_ids, &spi->dev);
> +       of_match = of_match_device(of_match_ptr(lm70_of_ids), &spi->dev);
>         if (of_match)
>                 chip = (int)(uintptr_t)of_match->data;

Why can't this do:

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

>         else {
> --
> https://chromeos.dev
>

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

end of thread, other threads:[~2021-01-27  7:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-23  3:44 [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Stephen Boyd
2021-01-23  3:44 ` [PATCH v2 1/6] media: renesas-ceu: Use of_device_get_match_data() Stephen Boyd
2021-01-25  8:30   ` Geert Uytterhoeven
2021-01-23  3:44 ` [PATCH v2 2/6] drivers: net: davinci_mdio: " Stephen Boyd
2021-01-26 13:11   ` Grygorii Strashko
2021-01-23  3:44 ` [PATCH v2 3/6] serial: stm32: " Stephen Boyd
2021-01-23  3:44 ` [PATCH v2 4/6] usb: usb251xb: " Stephen Boyd
2021-01-23  3:44 ` [PATCH v2 5/6] hwmon: (lm70) Avoid undefined reference to match table Stephen Boyd
2021-01-23  6:09   ` Guenter Roeck
2021-01-26 18:30   ` Rob Herring
2021-01-23  3:44 ` [PATCH v2 6/6] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Stephen Boyd
2021-01-25  8:33   ` Geert Uytterhoeven
2021-01-25  9:46   ` Arnd Bergmann
2021-01-26 18:21 ` [PATCH v2 0/6] Stop NULLifying match pointer in of_match_device() Rob Herring

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