Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1598388 > unrolled thread

[PATCH v2 2/3] watchdog: s3c2410: Simplify getting driver data

Started byKrzysztof Kozlowski <krzk@kernel.org>
First post2017-03-11 18:50 +0100
Last post2017-03-12 22:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 2/3] watchdog: s3c2410: Simplify getting driver data Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-11 18:50 +0100
    Re: [PATCH v2 2/3] watchdog: s3c2410: Simplify getting driver data Guenter Roeck <linux@roeck-us.net> - 2017-03-12 22:10 +0100

#1598388 — [PATCH v2 2/3] watchdog: s3c2410: Simplify getting driver data

FromKrzysztof Kozlowski <krzk@kernel.org>
Date2017-03-11 18:50 +0100
Subject[PATCH v2 2/3] watchdog: s3c2410: Simplify getting driver data
Message-ID<tjTjr-65c-1@gated-at.bofh.it>
Simplify the flow in helper function for getting the driver data by
using of_device_get_match_data() and only one if() branch.

The code should be equivalent.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/watchdog/s3c2410_wdt.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 5eaec319e499..d7ddee0668c3 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -37,6 +37,7 @@
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 #include <linux/delay.h>
@@ -510,14 +511,16 @@ static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt)
 static inline const struct s3c2410_wdt_variant *
 s3c2410_get_wdt_drv_data(struct platform_device *pdev)
 {
-	if (pdev->dev.of_node) {
-		const struct of_device_id *match;
-		match = of_match_node(s3c2410_wdt_match, pdev->dev.of_node);
-		return (const struct s3c2410_wdt_variant *)match->data;
-	} else {
-		return (const struct s3c2410_wdt_variant *)
-			platform_get_device_id(pdev)->driver_data;
+	const struct s3c2410_wdt_variant *variant;
+
+	variant = of_device_get_match_data(&pdev->dev);
+	if (!variant) {
+		/* Device matched by platform_device_id */
+		variant = (const struct s3c2410_wdt_variant *)
+			  platform_get_device_id(pdev)->driver_data;
 	}
+
+	return variant;
 }
 
 static int s3c2410wdt_probe(struct platform_device *pdev)
-- 
2.9.3

[toc] | [next] | [standalone]


#1598759

FromGuenter Roeck <linux@roeck-us.net>
Date2017-03-12 22:10 +0100
Message-ID<tkiUy-73E-15@gated-at.bofh.it>
In reply to#1598388
On 03/11/2017 09:42 AM, Krzysztof Kozlowski wrote:
> Simplify the flow in helper function for getting the driver data by
> using of_device_get_match_data() and only one if() branch.
>
> The code should be equivalent.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  drivers/watchdog/s3c2410_wdt.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
> index 5eaec319e499..d7ddee0668c3 100644
> --- a/drivers/watchdog/s3c2410_wdt.c
> +++ b/drivers/watchdog/s3c2410_wdt.c
> @@ -37,6 +37,7 @@
>  #include <linux/slab.h>
>  #include <linux/err.h>
>  #include <linux/of.h>
> +#include <linux/of_device.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/regmap.h>
>  #include <linux/delay.h>
> @@ -510,14 +511,16 @@ static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt)
>  static inline const struct s3c2410_wdt_variant *
>  s3c2410_get_wdt_drv_data(struct platform_device *pdev)
>  {
> -	if (pdev->dev.of_node) {
> -		const struct of_device_id *match;
> -		match = of_match_node(s3c2410_wdt_match, pdev->dev.of_node);
> -		return (const struct s3c2410_wdt_variant *)match->data;
> -	} else {
> -		return (const struct s3c2410_wdt_variant *)
> -			platform_get_device_id(pdev)->driver_data;
> +	const struct s3c2410_wdt_variant *variant;
> +
> +	variant = of_device_get_match_data(&pdev->dev);
> +	if (!variant) {
> +		/* Device matched by platform_device_id */
> +		variant = (const struct s3c2410_wdt_variant *)

Please drop the const and rebase to the simplified patch 1/3.

> +			  platform_get_device_id(pdev)->driver_data;
>  	}
> +
> +	return variant;
>  }
>
>  static int s3c2410wdt_probe(struct platform_device *pdev)
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web