linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] watchdog: ebc-c384_wdt: Utilize devm_ functions in driver probe callback
@ 2017-01-24 22:02 William Breathitt Gray
  2017-01-24 22:19 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: William Breathitt Gray @ 2017-01-24 22:02 UTC (permalink / raw)
  To: wim, linux; +Cc: linux-watchdog, linux-kernel, William Breathitt Gray

The devm_ resource manager functions allow memory to be automatically
released when a device is unbound. This patch takes advantage of the
resource manager functions and replaces the watchdog_register_device
call with the devm_watchdog_register_device call. In addition, the
ebc_c384_wdt_remove function has been removed as no longer necessary due
to the use of the relevant devm_ resource manager functions.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
Changes in v2:
  - Removed dev_set_drvdata call in ebc_c384_wdt_probe; now that
    ebc_c384_wdt_remove is gone, the driver_data doesn't need to be set

 drivers/watchdog/ebc-c384_wdt.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/watchdog/ebc-c384_wdt.c b/drivers/watchdog/ebc-c384_wdt.c
index 4b849b8e..2170b275 100644
--- a/drivers/watchdog/ebc-c384_wdt.c
+++ b/drivers/watchdog/ebc-c384_wdt.c
@@ -121,18 +121,7 @@ static int ebc_c384_wdt_probe(struct device *dev, unsigned int id)
 		dev_warn(dev, "Invalid timeout (%u seconds), using default (%u seconds)\n",
 			timeout, WATCHDOG_TIMEOUT);
 
-	dev_set_drvdata(dev, wdd);
-
-	return watchdog_register_device(wdd);
-}
-
-static int ebc_c384_wdt_remove(struct device *dev, unsigned int id)
-{
-	struct watchdog_device *wdd = dev_get_drvdata(dev);
-
-	watchdog_unregister_device(wdd);
-
-	return 0;
+	return devm_watchdog_register_device(dev, wdd);
 }
 
 static struct isa_driver ebc_c384_wdt_driver = {
@@ -140,7 +129,6 @@ static struct isa_driver ebc_c384_wdt_driver = {
 	.driver = {
 		.name = MODULE_NAME
 	},
-	.remove = ebc_c384_wdt_remove
 };
 
 static int __init ebc_c384_wdt_init(void)
-- 
2.11.0

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

* Re: [PATCH v2] watchdog: ebc-c384_wdt: Utilize devm_ functions in driver probe callback
  2017-01-24 22:02 [PATCH v2] watchdog: ebc-c384_wdt: Utilize devm_ functions in driver probe callback William Breathitt Gray
@ 2017-01-24 22:19 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2017-01-24 22:19 UTC (permalink / raw)
  To: William Breathitt Gray; +Cc: wim, linux-watchdog, linux-kernel

On Tue, Jan 24, 2017 at 05:02:33PM -0500, William Breathitt Gray wrote:
> The devm_ resource manager functions allow memory to be automatically
> released when a device is unbound. This patch takes advantage of the
> resource manager functions and replaces the watchdog_register_device
> call with the devm_watchdog_register_device call. In addition, the
> ebc_c384_wdt_remove function has been removed as no longer necessary due
> to the use of the relevant devm_ resource manager functions.
> 
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>

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

> ---
> Changes in v2:
>   - Removed dev_set_drvdata call in ebc_c384_wdt_probe; now that
>     ebc_c384_wdt_remove is gone, the driver_data doesn't need to be set
> 
>  drivers/watchdog/ebc-c384_wdt.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/drivers/watchdog/ebc-c384_wdt.c b/drivers/watchdog/ebc-c384_wdt.c
> index 4b849b8e..2170b275 100644
> --- a/drivers/watchdog/ebc-c384_wdt.c
> +++ b/drivers/watchdog/ebc-c384_wdt.c
> @@ -121,18 +121,7 @@ static int ebc_c384_wdt_probe(struct device *dev, unsigned int id)
>  		dev_warn(dev, "Invalid timeout (%u seconds), using default (%u seconds)\n",
>  			timeout, WATCHDOG_TIMEOUT);
>  
> -	dev_set_drvdata(dev, wdd);
> -
> -	return watchdog_register_device(wdd);
> -}
> -
> -static int ebc_c384_wdt_remove(struct device *dev, unsigned int id)
> -{
> -	struct watchdog_device *wdd = dev_get_drvdata(dev);
> -
> -	watchdog_unregister_device(wdd);
> -
> -	return 0;
> +	return devm_watchdog_register_device(dev, wdd);
>  }
>  
>  static struct isa_driver ebc_c384_wdt_driver = {
> @@ -140,7 +129,6 @@ static struct isa_driver ebc_c384_wdt_driver = {
>  	.driver = {
>  		.name = MODULE_NAME
>  	},
> -	.remove = ebc_c384_wdt_remove
>  };
>  
>  static int __init ebc_c384_wdt_init(void)
> -- 
> 2.11.0
> 

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

end of thread, other threads:[~2017-01-24 22:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24 22:02 [PATCH v2] watchdog: ebc-c384_wdt: Utilize devm_ functions in driver probe callback William Breathitt Gray
2017-01-24 22:19 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).