Linux-Watchdog Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] watchdog: meson_wdt: Use device_get_match_data() helper
@ 2021-04-01  2:25 Tian Tao
  2021-04-01  5:04 ` Christophe Leroy
  2021-04-05 14:49 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Tian Tao @ 2021-04-01  2:25 UTC (permalink / raw)
  To: wim, linux, khilman; +Cc: linux-watchdog, linux-arm-kernel

Use the device_get_match_data() helper instead of open coding.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
 drivers/watchdog/meson_wdt.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/watchdog/meson_wdt.c b/drivers/watchdog/meson_wdt.c
index 459f3ae..539feaa 100644
--- a/drivers/watchdog/meson_wdt.c
+++ b/drivers/watchdog/meson_wdt.c
@@ -162,7 +162,6 @@ static int meson_wdt_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct meson_wdt_dev *meson_wdt;
-	const struct of_device_id *of_id;
 	int err;
 
 	meson_wdt = devm_kzalloc(dev, sizeof(*meson_wdt), GFP_KERNEL);
@@ -173,12 +172,7 @@ static int meson_wdt_probe(struct platform_device *pdev)
 	if (IS_ERR(meson_wdt->wdt_base))
 		return PTR_ERR(meson_wdt->wdt_base);
 
-	of_id = of_match_device(meson_wdt_dt_ids, dev);
-	if (!of_id) {
-		dev_err(dev, "Unable to initialize WDT data\n");
-		return -ENODEV;
-	}
-	meson_wdt->data = of_id->data;
+	meson_wdt->data = device_get_match_data(dev);
 
 	meson_wdt->wdt_dev.parent = dev;
 	meson_wdt->wdt_dev.info = &meson_wdt_info;
-- 
2.7.4


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

* Re: [PATCH] watchdog: meson_wdt: Use device_get_match_data() helper
  2021-04-01  2:25 [PATCH] watchdog: meson_wdt: Use device_get_match_data() helper Tian Tao
@ 2021-04-01  5:04 ` Christophe Leroy
  2021-04-05 14:49 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Christophe Leroy @ 2021-04-01  5:04 UTC (permalink / raw)
  To: Tian Tao, wim, linux, khilman; +Cc: linux-watchdog, linux-arm-kernel



Le 01/04/2021 à 04:25, Tian Tao a écrit :
> Use the device_get_match_data() helper instead of open coding.
> 
> Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
> ---
>   drivers/watchdog/meson_wdt.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/watchdog/meson_wdt.c b/drivers/watchdog/meson_wdt.c
> index 459f3ae..539feaa 100644
> --- a/drivers/watchdog/meson_wdt.c
> +++ b/drivers/watchdog/meson_wdt.c
> @@ -162,7 +162,6 @@ static int meson_wdt_probe(struct platform_device *pdev)
>   {
>   	struct device *dev = &pdev->dev;
>   	struct meson_wdt_dev *meson_wdt;
> -	const struct of_device_id *of_id;
>   	int err;
>   
>   	meson_wdt = devm_kzalloc(dev, sizeof(*meson_wdt), GFP_KERNEL);
> @@ -173,12 +172,7 @@ static int meson_wdt_probe(struct platform_device *pdev)
>   	if (IS_ERR(meson_wdt->wdt_base))
>   		return PTR_ERR(meson_wdt->wdt_base);
>   
> -	of_id = of_match_device(meson_wdt_dt_ids, dev);
> -	if (!of_id) {
> -		dev_err(dev, "Unable to initialize WDT data\n");
> -		return -ENODEV;
> -	}
> -	meson_wdt->data = of_id->data;
> +	meson_wdt->data = device_get_match_data(dev);

Previously, it was returning -ENODEV on failure.
What happens now when device_get_match_data() returns NULL ?

>   
>   	meson_wdt->wdt_dev.parent = dev;
>   	meson_wdt->wdt_dev.info = &meson_wdt_info;
> 

Christophe

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

* Re: [PATCH] watchdog: meson_wdt: Use device_get_match_data() helper
  2021-04-01  2:25 [PATCH] watchdog: meson_wdt: Use device_get_match_data() helper Tian Tao
  2021-04-01  5:04 ` Christophe Leroy
@ 2021-04-05 14:49 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-04-05 14:49 UTC (permalink / raw)
  To: Tian Tao, wim, khilman; +Cc: linux-watchdog, linux-arm-kernel

On 3/31/21 7:25 PM, Tian Tao wrote:
> Use the device_get_match_data() helper instead of open coding.
> 
> Signed-off-by: Tian Tao <tiantao6@hisilicon.com>

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

> ---
>  drivers/watchdog/meson_wdt.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/watchdog/meson_wdt.c b/drivers/watchdog/meson_wdt.c
> index 459f3ae..539feaa 100644
> --- a/drivers/watchdog/meson_wdt.c
> +++ b/drivers/watchdog/meson_wdt.c
> @@ -162,7 +162,6 @@ static int meson_wdt_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct meson_wdt_dev *meson_wdt;
> -	const struct of_device_id *of_id;
>  	int err;
>  
>  	meson_wdt = devm_kzalloc(dev, sizeof(*meson_wdt), GFP_KERNEL);
> @@ -173,12 +172,7 @@ static int meson_wdt_probe(struct platform_device *pdev)
>  	if (IS_ERR(meson_wdt->wdt_base))
>  		return PTR_ERR(meson_wdt->wdt_base);
>  
> -	of_id = of_match_device(meson_wdt_dt_ids, dev);
> -	if (!of_id) {
> -		dev_err(dev, "Unable to initialize WDT data\n");
> -		return -ENODEV;
> -	}
> -	meson_wdt->data = of_id->data;
> +	meson_wdt->data = device_get_match_data(dev);
>  
>  	meson_wdt->wdt_dev.parent = dev;
>  	meson_wdt->wdt_dev.info = &meson_wdt_info;
> 


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01  2:25 [PATCH] watchdog: meson_wdt: Use device_get_match_data() helper Tian Tao
2021-04-01  5:04 ` Christophe Leroy
2021-04-05 14:49 ` Guenter Roeck

Linux-Watchdog Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-watchdog/0 linux-watchdog/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-watchdog linux-watchdog/ https://lore.kernel.org/linux-watchdog \
		linux-watchdog@vger.kernel.org
	public-inbox-index linux-watchdog

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-watchdog


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git