All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] watchdog: fix cleanup device code on registration
@ 2013-04-12  6:51 ` Kim, Milo
  0 siblings, 0 replies; 3+ messages in thread
From: Kim, Milo @ 2013-04-12  6:51 UTC (permalink / raw)
  To: wim; +Cc: linux-watchdog, linux-kernel

Duplicate lines of code are moved to cleanup_dev section.
And it returns 0 explicitly in case of no error.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
---
 drivers/watchdog/watchdog_dev.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 42bfc9a..37c2dcc 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -613,11 +613,7 @@ int watchdog_dev_register(struct watchdog_device *watchdog)
 	if (err) {
 		pr_err("watchdog%d unable to add device %d:%d\n",
 			watchdog->id,  MAJOR(watchdog_devt), watchdog->id);
-		if (watchdog->id == 0) {
-			misc_deregister(&watchdog_miscdev);
-			old_wdd = NULL;
-		}
-		return err;
+		goto cleanup_dev;
 	}
 
 	/* Activate the watchdog automatically by the driver itself */
@@ -625,13 +621,17 @@ int watchdog_dev_register(struct watchdog_device *watchdog)
 		err = watchdog_auto_start(watchdog);
 		if (err) {
 			cdev_del(&watchdog->cdev);
-			if (watchdog->id == 0) {
-				misc_deregister(&watchdog_miscdev);
-				old_wdd = NULL;
-			}
+			goto cleanup_dev;
 		}
 	}
 
+	return 0;
+
+cleanup_dev:
+	if (watchdog->id == 0) {
+		misc_deregister(&watchdog_miscdev);
+		old_wdd = NULL;
+	}
 	return err;
 }
 
-- 
1.7.9.5


Best Regards,
Milo



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

* [PATCH 2/2] watchdog: fix cleanup device code on registration
@ 2013-04-12  6:51 ` Kim, Milo
  0 siblings, 0 replies; 3+ messages in thread
From: Kim, Milo @ 2013-04-12  6:51 UTC (permalink / raw)
  To: wim; +Cc: linux-watchdog, linux-kernel

Duplicate lines of code are moved to cleanup_dev section.
And it returns 0 explicitly in case of no error.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
---
 drivers/watchdog/watchdog_dev.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 42bfc9a..37c2dcc 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -613,11 +613,7 @@ int watchdog_dev_register(struct watchdog_device *watchdog)
 	if (err) {
 		pr_err("watchdog%d unable to add device %d:%d\n",
 			watchdog->id,  MAJOR(watchdog_devt), watchdog->id);
-		if (watchdog->id == 0) {
-			misc_deregister(&watchdog_miscdev);
-			old_wdd = NULL;
-		}
-		return err;
+		goto cleanup_dev;
 	}
 
 	/* Activate the watchdog automatically by the driver itself */
@@ -625,13 +621,17 @@ int watchdog_dev_register(struct watchdog_device *watchdog)
 		err = watchdog_auto_start(watchdog);
 		if (err) {
 			cdev_del(&watchdog->cdev);
-			if (watchdog->id == 0) {
-				misc_deregister(&watchdog_miscdev);
-				old_wdd = NULL;
-			}
+			goto cleanup_dev;
 		}
 	}
 
+	return 0;
+
+cleanup_dev:
+	if (watchdog->id == 0) {
+		misc_deregister(&watchdog_miscdev);
+		old_wdd = NULL;
+	}
 	return err;
 }
 
-- 
1.7.9.5


Best Regards,
Milo


--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] watchdog: fix cleanup device code on registration
  2013-04-12  6:51 ` Kim, Milo
  (?)
@ 2013-04-12 14:57 ` Guenter Roeck
  -1 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2013-04-12 14:57 UTC (permalink / raw)
  To: Kim, Milo; +Cc: wim, linux-watchdog, linux-kernel

On Fri, Apr 12, 2013 at 06:51:48AM +0000, Kim, Milo wrote:
> Duplicate lines of code are moved to cleanup_dev section.
> And it returns 0 explicitly in case of no error.
> 
> Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
> ---
>  drivers/watchdog/watchdog_dev.c |   18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 42bfc9a..37c2dcc 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -613,11 +613,7 @@ int watchdog_dev_register(struct watchdog_device *watchdog)
>  	if (err) {
>  		pr_err("watchdog%d unable to add device %d:%d\n",
>  			watchdog->id,  MAJOR(watchdog_devt), watchdog->id);
> -		if (watchdog->id == 0) {
> -			misc_deregister(&watchdog_miscdev);
> -			old_wdd = NULL;
> -		}
> -		return err;
> +		goto cleanup_dev;
>  	}
>  
>  	/* Activate the watchdog automatically by the driver itself */
> @@ -625,13 +621,17 @@ int watchdog_dev_register(struct watchdog_device *watchdog)
>  		err = watchdog_auto_start(watchdog);
>  		if (err) {
>  			cdev_del(&watchdog->cdev);

If you are doing this, you should also move cdev_del into the cleanup path:

> -			if (watchdog->id == 0) {
> -				misc_deregister(&watchdog_miscdev);
> -				old_wdd = NULL;
> -			}
> +			goto cleanup_dev;
>  		}
>  	}
>  
> +	return 0;
> +
cleanup_cdev:
	cdev_del(&watchdog->cdev);

> +cleanup_dev:
> +	if (watchdog->id == 0) {
> +		misc_deregister(&watchdog_miscdev);
> +		old_wdd = NULL;
> +	}
>  	return err;
>  }
>  
> -- 
> 1.7.9.5
> 
> 
> Best Regards,
> Milo
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

end of thread, other threads:[~2013-04-12 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-12  6:51 [PATCH 2/2] watchdog: fix cleanup device code on registration Kim, Milo
2013-04-12  6:51 ` Kim, Milo
2013-04-12 14:57 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.