mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] tty: serial: mvebu-uart: use device_get_match_data()
@ 2026-11-03 20:13 Bramwel Barack
  2026-11-05 11:48 ` Pali Rohár
  0 siblings, 1 reply; 2+ messages in thread
From: Bramwel Barack @ 2026-11-03 20:13 UTC (permalink / raw)
  To: Pali Rohár, Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, linux-kernel, Bramwel Barack

Modernize the driver by replacing the legacy of_match_device() call
with the modern device_get_match_data() helper API. This cleans up
the boilerplate code by extracting the match driver data configuration
directly.

Consequently, drop the explicit inclusions of <linux/of_device.h> and
<linux/of_platform.h> as they are no longer required by the driver.
This allows us to also remove a now-redundant forward declaration and
 drop the problematic of_match_ptr() macro wrapper.

Signed-off-by: Bramwel Barack <bramwelbarack89@gmail.com>

---
Changes in v3:
  - Removed the redundant type cast from device_get_match_data() assignment as suggested by Jiri Slaby.
  - Marked the data pointer in struct mvebu_uart as const to match the return type of device_get_match_data() and prevent build errors.

Changes in v2:
  - Dropped the redundant forward declaration of mvebu_uart_of_match.
  - Removed the of_match_ptr() macro wrapper from the platform driver structure
    to prevent build warnings when compiling with CONFIG_OF disabled.
---
 drivers/tty/serial/mvebu-uart.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
index 33ea496c93b2..fcb8f3d52df8 100644
--- a/drivers/tty/serial/mvebu-uart.c
+++ b/drivers/tty/serial/mvebu-uart.c
@@ -18,9 +18,7 @@
 #include <linux/math64.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/of_device.h>
 #include <linux/of_irq.h>
-#include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/serial.h>
 #include <linux/serial_core.h>
@@ -154,7 +152,7 @@ struct mvebu_uart {
 	struct uart_port *port;
 	struct clk *clk;
 	int irq[UART_IRQ_COUNT];
-	struct mvebu_uart_driver_data *data;
+	const struct mvebu_uart_driver_data *data;
 #if defined(CONFIG_PM)
 	struct mvebu_uart_pm_regs pm_regs;
 #endif /* CONFIG_PM */
@@ -859,15 +857,12 @@ static const struct dev_pm_ops mvebu_uart_pm_ops = {
 };
 #endif /* CONFIG_PM */
 
-static const struct of_device_id mvebu_uart_of_match[];
 
 /* Counter to keep track of each UART port id when not using CONFIG_OF */
 static int uart_num_counter;
 
 static int mvebu_uart_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match = of_match_device(mvebu_uart_of_match,
-							   &pdev->dev);
 	struct uart_port *port;
 	struct mvebu_uart *mvuart;
 	struct resource *reg;
@@ -919,7 +914,7 @@ static int mvebu_uart_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	/* Get controller data depending on the compatible string */
-	mvuart->data = (struct mvebu_uart_driver_data *)match->data;
+	mvuart->data = device_get_match_data(&pdev->dev);
 	mvuart->port = port;
 
 	port->private_data = mvuart;
@@ -1016,7 +1011,7 @@ static struct platform_driver mvebu_uart_platform_driver = {
 	.probe	= mvebu_uart_probe,
 	.driver	= {
 		.name  = "mvebu-uart",
-		.of_match_table = of_match_ptr(mvebu_uart_of_match),
+		.of_match_table = mvebu_uart_of_match,
 		.suppress_bind_attrs = true,
 #if defined(CONFIG_PM)
 		.pm	= &mvebu_uart_pm_ops,
-- 
2.56.0


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

* Re: [PATCH v3] tty: serial: mvebu-uart: use device_get_match_data()
  2026-11-03 20:13 [PATCH v3] tty: serial: mvebu-uart: use device_get_match_data() Bramwel Barack
@ 2026-11-05 11:48 ` Pali Rohár
  0 siblings, 0 replies; 2+ messages in thread
From: Pali Rohár @ 2026-11-05 11:48 UTC (permalink / raw)
  To: Bramwel Barack; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel

On Tuesday 03 November 2026 23:13:05 Bramwel Barack wrote:
> Modernize the driver by replacing the legacy of_match_device() call
> with the modern device_get_match_data() helper API. This cleans up
> the boilerplate code by extracting the match driver data configuration
> directly.
> 
> Consequently, drop the explicit inclusions of <linux/of_device.h> and
> <linux/of_platform.h> as they are no longer required by the driver.
> This allows us to also remove a now-redundant forward declaration and
>  drop the problematic of_match_ptr() macro wrapper.
> 
> Signed-off-by: Bramwel Barack <bramwelbarack89@gmail.com>

Looks good,

Acked-by: Pali Rohár <pali@kernel.org>

> ---
> Changes in v3:
>   - Removed the redundant type cast from device_get_match_data() assignment as suggested by Jiri Slaby.
>   - Marked the data pointer in struct mvebu_uart as const to match the return type of device_get_match_data() and prevent build errors.
> 
> Changes in v2:
>   - Dropped the redundant forward declaration of mvebu_uart_of_match.
>   - Removed the of_match_ptr() macro wrapper from the platform driver structure
>     to prevent build warnings when compiling with CONFIG_OF disabled.
> ---
>  drivers/tty/serial/mvebu-uart.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
> index 33ea496c93b2..fcb8f3d52df8 100644
> --- a/drivers/tty/serial/mvebu-uart.c
> +++ b/drivers/tty/serial/mvebu-uart.c
> @@ -18,9 +18,7 @@
>  #include <linux/math64.h>
>  #include <linux/of.h>
>  #include <linux/of_address.h>
> -#include <linux/of_device.h>
>  #include <linux/of_irq.h>
> -#include <linux/of_platform.h>
>  #include <linux/platform_device.h>
>  #include <linux/serial.h>
>  #include <linux/serial_core.h>
> @@ -154,7 +152,7 @@ struct mvebu_uart {
>  	struct uart_port *port;
>  	struct clk *clk;
>  	int irq[UART_IRQ_COUNT];
> -	struct mvebu_uart_driver_data *data;
> +	const struct mvebu_uart_driver_data *data;
>  #if defined(CONFIG_PM)
>  	struct mvebu_uart_pm_regs pm_regs;
>  #endif /* CONFIG_PM */
> @@ -859,15 +857,12 @@ static const struct dev_pm_ops mvebu_uart_pm_ops = {
>  };
>  #endif /* CONFIG_PM */
>  
> -static const struct of_device_id mvebu_uart_of_match[];
>  
>  /* Counter to keep track of each UART port id when not using CONFIG_OF */
>  static int uart_num_counter;
>  
>  static int mvebu_uart_probe(struct platform_device *pdev)
>  {
> -	const struct of_device_id *match = of_match_device(mvebu_uart_of_match,
> -							   &pdev->dev);
>  	struct uart_port *port;
>  	struct mvebu_uart *mvuart;
>  	struct resource *reg;
> @@ -919,7 +914,7 @@ static int mvebu_uart_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	/* Get controller data depending on the compatible string */
> -	mvuart->data = (struct mvebu_uart_driver_data *)match->data;
> +	mvuart->data = device_get_match_data(&pdev->dev);
>  	mvuart->port = port;
>  
>  	port->private_data = mvuart;
> @@ -1016,7 +1011,7 @@ static struct platform_driver mvebu_uart_platform_driver = {
>  	.probe	= mvebu_uart_probe,
>  	.driver	= {
>  		.name  = "mvebu-uart",
> -		.of_match_table = of_match_ptr(mvebu_uart_of_match),
> +		.of_match_table = mvebu_uart_of_match,
>  		.suppress_bind_attrs = true,
>  #if defined(CONFIG_PM)
>  		.pm	= &mvebu_uart_pm_ops,
> -- 
> 2.56.0
> 

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

end of thread, other threads:[~2026-11-05 11:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 20:13 [PATCH v3] tty: serial: mvebu-uart: use device_get_match_data() Bramwel Barack
2026-11-05 11:48 ` Pali Rohár

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®