Linux Watchdog driver development
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Viresh Kumar <viresh.kumar@st.com>
Cc: wim@iguana.be, linus.walleij@stericsson.com,
	srinidhi.kasagar@stericsson.com, spear-devel@list.st.com,
	viresh.linux@gmail.com, alan@lxorguk.ukuu.org.uk,
	linux-arm-kernel@lists.infradead.org,
	linux-watchdog@vger.kernel.org
Subject: Re: [PATCH 14/15] watchdog/mpcore_wdt: Add clock framework support
Date: Wed, 7 Mar 2012 11:18:33 +0000	[thread overview]
Message-ID: <20120307111833.GQ17370@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <9ec7141baa4b1c1a0503893749e7ce0e19bb5029.1331115752.git.viresh.kumar@st.com>

On Wed, Mar 07, 2012 at 03:57:55PM +0530, Viresh Kumar wrote:
> @@ -156,10 +159,22 @@ static int mpcore_wdt_open(struct inode *inode, struct file *file)
>  
>  	file->private_data = wdt;
>  
> +	if (wdt->clk) {

	if (!IS_ERR(wdt->clk)) {

> +		ret = clk_enable(wdt->clk);

What about preparing the clock?

> +		if (ret) {
> +			dev_err(wdt->dev, "clock enable fail");
> +			goto err;
> +		}
> +	}
> +
>  	/* Activate timer */
>  	mpcore_wdt_start(wdt);
>  
>  	return nonseekable_open(inode, file);
> +
> +err:
> +	clear_bit(0, &wdt->timer_alive);
> +	return ret;
>  }
>  
>  static int mpcore_wdt_release(struct inode *inode, struct file *file)
> @@ -169,9 +184,12 @@ static int mpcore_wdt_release(struct inode *inode, struct file *file)
>  	/*
>  	 * Shut off the timer. Lock it in if it's a module and we set nowayout
>  	 */
> -	if (wdt->expect_close == 42)
> +	if (wdt->expect_close == 42) {
>  		mpcore_wdt_stop(wdt);
> -	else {
> +
> +		if (wdt->clk)

		if (!IS_ERR(wdt->clk))

> +			clk_disable(wdt->clk);

What about unpreparing the clock?

> +	} else {
>  		dev_printk(KERN_CRIT, wdt->dev,
>  				"unexpected close, not stopping watchdog!\n");
>  		mpcore_wdt_keepalive(wdt);
> @@ -350,6 +368,28 @@ static int __devinit mpcore_wdt_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> +	wdt->clk = clk_get(&pdev->dev, NULL);
> +	if (IS_ERR(wdt->clk)) {
> +		dev_warn(&pdev->dev, "Clock not found\n");
> +		wdt->clk = NULL;

Remove this line.

> +	}
> +
> +	if (wdt->clk) {

	if (!IS_ERR(wdt->clk)) {

> +		ret = clk_enable(wdt->clk);

What about preparing the clock?

> +		if (ret) {
> +			dev_err(&pdev->dev, "Clock enable failed\n");
> +			goto err_put_clk;
> +		}
> +	}
> +
> +	wdt->boot_status = (readl(wdt->base + TWD_WDOG_RESETSTAT) &
> +			TWD_WDOG_RESETSTAT_MASK) ? WDIOF_CARDRESET : 0;
> +
> +	mpcore_wdt_stop(wdt);
> +
> +	if (wdt->clk)
> +		clk_disable(wdt->clk);

Same two comments...

> +
>  	/*
>  	 * Check that the margin value is within it's range;
>  	 * if not reset to the default
> @@ -368,25 +408,32 @@ static int __devinit mpcore_wdt_probe(struct platform_device *pdev)
>  		dev_printk(KERN_ERR, wdt->dev,
>  			"cannot register miscdev on minor=%d (err=%d)\n",
>  							WATCHDOG_MINOR, ret);
> -		return ret;
> +		goto err_put_clk;
>  	}
>  
> -	wdt->boot_status = (readl(wdt->base + TWD_WDOG_RESETSTAT) &
> -			TWD_WDOG_RESETSTAT_MASK) ? WDIOF_CARDRESET : 0;
> -
> -	mpcore_wdt_stop(wdt);
>  	platform_set_drvdata(pdev, wdt);
>  	mpcore_wdt_pdev = pdev;
>  
>  	return 0;
> +
> +err_put_clk:
> +	if (wdt->clk)
> +		clk_put(wdt->clk);
> +
> +	return ret;
>  }
>  
>  static int __devexit mpcore_wdt_remove(struct platform_device *pdev)
>  {
> +	struct mpcore_wdt *wdt = platform_get_drvdata(pdev);
> +
>  	platform_set_drvdata(pdev, NULL);
>  
>  	misc_deregister(&mpcore_wdt_miscdev);
>  
> +	if (wdt->clk)
> +		clk_put(wdt->clk);

Same comments.

> +
>  	mpcore_wdt_pdev = NULL;
>  
>  	return 0;
> @@ -399,6 +446,9 @@ static int mpcore_wdt_suspend(struct device *dev)
>  
>  	if (test_bit(0, &wdt->timer_alive))
>  		mpcore_wdt_stop(wdt);		/* Turn the WDT off */
> +
> +	if (wdt->clk)
> +		clk_disable(wdt->clk);

Same comments...  And what if the watchdog is not open?  Doesn't this
disable an already disabled clock?

>  	return 0;
>  }
>  
> @@ -407,8 +457,13 @@ static int mpcore_wdt_resume(struct device *dev)
>  	struct mpcore_wdt *wdt = dev_get_drvdata(dev);
>  
>  	/* re-activate timer */
> -	if (test_bit(0, &wdt->timer_alive))
> +	if (test_bit(0, &wdt->timer_alive)) {
> +		if (wdt->clk)
> +			clk_enable(wdt->clk);

Same two comments.

> +
>  		mpcore_wdt_start(wdt);
> +	}
> +
>  	return 0;
>  }
>  #endif
> -- 
> 1.7.8.110.g4cb5d
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2012-03-07 11:18 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 10:27 [PATCH 00/15] watchdog/mpcore: updates & fixes Viresh Kumar
2012-03-07 10:27 ` [PATCH 01/15] watchdog/mpcore_wdt: Fix multiline comments Viresh Kumar
2012-03-07 10:27 ` [PATCH 02/15] watchdog/mpcore_wdt: Add blank line after variable definitions in routines Viresh Kumar
2012-03-07 10:27 ` [PATCH 03/15] watchdog/mpcore_wdt: Arrange #includes in alphabetical order Viresh Kumar
2012-03-07 10:27 ` [PATCH 04/15] watchdog/mpcore_wdt: remove multiple 'ret = 0' statements from ioctl ops Viresh Kumar
2012-03-07 10:27 ` [PATCH 05/15] watchdog/mpcore_wdt: Rename dev to pdev for pointing to struct platform_device Viresh Kumar
2012-03-07 10:27 ` [PATCH 06/15] watchdog/mpcore_wdt: do request_irq before registering misc device Viresh Kumar
2012-03-07 10:27 ` [PATCH 07/15] watchdog/mpcore_wdt: Use devm routines Viresh Kumar
2012-03-07 10:27 ` [PATCH 08/15] watchdog/mpcore_wdt: handle module param mpcore_margin in probe Viresh Kumar
2012-03-07 10:27 ` [PATCH 09/15] watchdog/mpcore_wdt: convert to use module_platform_driver() Viresh Kumar
2012-03-07 10:27 ` [PATCH 10/15] watchdog/mpcore_wdt: Add support for dev_pm_ops interface Viresh Kumar
2012-03-07 11:38   ` Sergei Shtylyov
2012-03-07 12:11     ` viresh kumar
2012-03-07 10:27 ` [PATCH 11/15] watchdog/mpcore_wdt: disable wdt in suspend only if it is busy Viresh Kumar
2012-03-07 10:27 ` [PATCH 12/15] watchdog/mpcore_wdt: Add support for WDIOF_CARDRESET Viresh Kumar
2012-03-07 11:40   ` Sergei Shtylyov
2012-03-07 12:10     ` viresh kumar
2012-03-07 10:27 ` [PATCH 13/15] watchdog/mpcore_wdt: Allow platform_get_irq() to fail Viresh Kumar
2012-03-07 10:27 ` [PATCH 14/15] watchdog/mpcore_wdt: Add clock framework support Viresh Kumar
2012-03-07 11:17   ` Srinidhi Kasagar
2012-03-07 12:13     ` viresh kumar
2012-03-07 11:18   ` Russell King - ARM Linux [this message]
2012-03-07 12:20     ` viresh kumar
2012-03-07 12:27       ` Russell King - ARM Linux
2012-03-07 12:37         ` viresh kumar
2012-03-07 12:47           ` Russell King - ARM Linux
2012-03-07 10:27 ` [PATCH 15/15] watchdog/mpcore_wdt: use correct clk_rate to program timeout Viresh Kumar
2012-03-07 10:34 ` [PATCH 00/15] watchdog/mpcore: updates & fixes Wolfram Sang
2012-03-07 12:26   ` viresh kumar
2012-03-07 12:48     ` Wolfram Sang

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=20120307111833.GQ17370@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=spear-devel@list.st.com \
    --cc=srinidhi.kasagar@stericsson.com \
    --cc=viresh.kumar@st.com \
    --cc=viresh.linux@gmail.com \
    --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