diff mbox series

[v2,7/7] tty: serial: samsung: simplify getting OF match data

Message ID 20220307080925.54131-6-krzysztof.kozlowski@canonical.com (mailing list archive)
State New, archived
Headers show
Series tty: serial: samsung: minor fixes/cleanups | expand

Commit Message

Krzysztof Kozlowski March 7, 2022, 8:09 a.m. UTC
Simplify the code with of_device_get_match_data().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/tty/serial/samsung_tty.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Alim Akhtar March 7, 2022, 6:16 p.m. UTC | #1
>-----Original Message-----
>From: Krzysztof Kozlowski [mailto:krzysztof.kozlowski@canonical.com]
>Sent: Monday, March 7, 2022 1:39 PM
>To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>; Alim Akhtar
><alim.akhtar@samsung.com>; Greg Kroah-Hartman
><gregkh@linuxfoundation.org>; Jiri Slaby <jirislaby@kernel.org>; linux-arm-
>kernel@lists.infradead.org; linux-samsung-soc@vger.kernel.org; linux-
>serial@vger.kernel.org; linux-kernel@vger.kernel.org
>Subject: [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match
data
>
>Simplify the code with of_device_get_match_data().
>
>Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
>---

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>


> drivers/tty/serial/samsung_tty.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
>diff --git a/drivers/tty/serial/samsung_tty.c
>b/drivers/tty/serial/samsung_tty.c
>index 3ffae912217c..61c530bb377f 100644
>--- a/drivers/tty/serial/samsung_tty.c
>+++ b/drivers/tty/serial/samsung_tty.c
>@@ -2150,23 +2150,16 @@ static int s3c24xx_serial_init_port(struct
>s3c24xx_uart_port *ourport,
>
> /* Device driver serial port probe */
>
>-#ifdef CONFIG_OF
>-static const struct of_device_id s3c24xx_uart_dt_match[]; -#endif
>-
> static int probe_index;
>
> static inline const struct s3c24xx_serial_drv_data *
>s3c24xx_get_driver_data(struct platform_device *pdev)  {  #ifdef CONFIG_OF
>-	if (pdev->dev.of_node) {
>-		const struct of_device_id *match;
>-
>-		match = of_match_node(s3c24xx_uart_dt_match, pdev-
>>dev.of_node);
>-		return (struct s3c24xx_serial_drv_data *)match->data;
>-	}
>+	if (pdev->dev.of_node)
>+		return of_device_get_match_data(&pdev->dev);
> #endif
>+
> 	return (struct s3c24xx_serial_drv_data *)
> 			platform_get_device_id(pdev)->driver_data;
> }
>--
>2.32.0
Andy Shevchenko March 7, 2022, 8:24 p.m. UTC | #2
On Mon, Mar 7, 2022 at 11:20 AM Krzysztof Kozlowski
<krzysztof.kozlowski@canonical.com> wrote:
>
> Simplify the code with of_device_get_match_data().

You may get rid of ugly ifdeffery as well.

...

>  static inline const struct s3c24xx_serial_drv_data *
>  s3c24xx_get_driver_data(struct platform_device *pdev)
>  {
>  #ifdef CONFIG_OF
> -       if (pdev->dev.of_node) {
> -               const struct of_device_id *match;
> -
> -               match = of_match_node(s3c24xx_uart_dt_match, pdev->dev.of_node);
> -               return (struct s3c24xx_serial_drv_data *)match->data;
> -       }

> +       if (pdev->dev.of_node)

I believe it's never true when CONFIG_OF=n,

> +               return of_device_get_match_data(&pdev->dev);
>  #endif
> +
>         return (struct s3c24xx_serial_drv_data *)
>                         platform_get_device_id(pdev)->driver_data;
>  }
Krzysztof Kozlowski March 8, 2022, 7:19 a.m. UTC | #3
On 07/03/2022 21:24, Andy Shevchenko wrote:
> On Mon, Mar 7, 2022 at 11:20 AM Krzysztof Kozlowski
> <krzysztof.kozlowski@canonical.com> wrote:
>>
>> Simplify the code with of_device_get_match_data().
> 
> You may get rid of ugly ifdeffery as well.
> 
> ...
> 
>>  static inline const struct s3c24xx_serial_drv_data *
>>  s3c24xx_get_driver_data(struct platform_device *pdev)
>>  {
>>  #ifdef CONFIG_OF
>> -       if (pdev->dev.of_node) {
>> -               const struct of_device_id *match;
>> -
>> -               match = of_match_node(s3c24xx_uart_dt_match, pdev->dev.of_node);
>> -               return (struct s3c24xx_serial_drv_data *)match->data;
>> -       }
> 
>> +       if (pdev->dev.of_node)
> 
> I believe it's never true when CONFIG_OF=n,

Right, I can use dev_of_node() helper for that purpose as well. Thanks!


Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 3ffae912217c..61c530bb377f 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -2150,23 +2150,16 @@  static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
 
 /* Device driver serial port probe */
 
-#ifdef CONFIG_OF
-static const struct of_device_id s3c24xx_uart_dt_match[];
-#endif
-
 static int probe_index;
 
 static inline const struct s3c24xx_serial_drv_data *
 s3c24xx_get_driver_data(struct platform_device *pdev)
 {
 #ifdef CONFIG_OF
-	if (pdev->dev.of_node) {
-		const struct of_device_id *match;
-
-		match = of_match_node(s3c24xx_uart_dt_match, pdev->dev.of_node);
-		return (struct s3c24xx_serial_drv_data *)match->data;
-	}
+	if (pdev->dev.of_node)
+		return of_device_get_match_data(&pdev->dev);
 #endif
+
 	return (struct s3c24xx_serial_drv_data *)
 			platform_get_device_id(pdev)->driver_data;
 }