diff mbox series

watchdog: meson_wdt: Use device_get_match_data() helper

Message ID 1617243921-56774-1-git-send-email-tiantao6@hisilicon.com
State New
Headers show
Series watchdog: meson_wdt: Use device_get_match_data() helper | expand

Commit Message

Tian Tao April 1, 2021, 2:25 a.m. UTC
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(-)

Comments

Christophe Leroy April 1, 2021, 5:04 a.m. UTC | #1
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
Guenter Roeck April 5, 2021, 2:49 p.m. UTC | #2
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;

>
diff mbox series

Patch

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;