mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Kim, Milo" <Milo.Kim@ti.com>
Cc: "wim@iguana.be" <wim@iguana.be>,
	"linux-watchdog@vger.kernel.org" <linux-watchdog@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] watchdog: fix cleanup device code on registration
Date: Fri, 12 Apr 2013 07:57:33 -0700	[thread overview]
Message-ID: <20130412145733.GA28704@roeck-us.net> (raw)
In-Reply-To: <A874F61F95741C4A9BA573A70FE3998F82E4BBCA@DQHE02.ent.ti.com>

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
> 

      reply	other threads:[~2013-04-12 14:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-12  6:51 Kim, Milo
2013-04-12 14:57 ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130412145733.GA28704@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=Milo.Kim@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wim@iguana.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®