linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: wim@iguana.be (Wim Van Sebroeck)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API enable/disable calls
Date: Fri, 20 Nov 2009 16:03:32 +0100	[thread overview]
Message-ID: <20091120150332.GY19336@infomag.iguana.be> (raw)
In-Reply-To: <E1NBUk5-0004Pg-Q4@rmk-PC.arm.linux.org.uk>

Acked-by: Wim Van Sebroeck <wim@iguana.be>

> clk_set_rate() is not supposed to be used to turn clocks on and off.
> That's what clk_enable/clk_disable is for.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
>  arch/arm/mach-pnx4008/clock.c  |    4 ++--
>  drivers/watchdog/pnx4008_wdt.c |   37 ++++++++++++++++++++++++-------------
>  2 files changed, 26 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
> index d12e0b1..270c254 100644
> --- a/arch/arm/mach-pnx4008/clock.c
> +++ b/arch/arm/mach-pnx4008/clock.c
> @@ -740,10 +740,10 @@ static struct clk wdt_ck = {
>  	.name = "wdt_ck",
>  	.parent = &per_ck,
>  	.flags = NEEDS_INITIALIZATION,
> -	.round_rate = &on_off_round_rate,
> -	.set_rate = &on_off_set_rate,
>  	.enable_shift = 0,
>  	.enable_reg = TIMCLKCTRL_REG,
> +	.enable = clk_reg_enable,
> +	.disable = clk_reg_disable,
>  };
>  
>  /* These clocks are visible outside this module
> diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
> index 9add3a8..e274f42 100644
> --- a/drivers/watchdog/pnx4008_wdt.c
> +++ b/drivers/watchdog/pnx4008_wdt.c
> @@ -96,9 +96,6 @@ static void wdt_enable(void)
>  {
>  	spin_lock(&io_lock);
>  
> -	if (wdt_clk)
> -		clk_set_rate(wdt_clk, 1);
> -
>  	/* stop counter, initiate counter reset */
>  	__raw_writel(RESET_COUNT, WDTIM_CTRL(wdt_base));
>  	/*wait for reset to complete. 100% guarantee event */
> @@ -125,19 +122,25 @@ static void wdt_disable(void)
>  	spin_lock(&io_lock);
>  
>  	__raw_writel(0, WDTIM_CTRL(wdt_base));	/*stop counter */
> -	if (wdt_clk)
> -		clk_set_rate(wdt_clk, 0);
>  
>  	spin_unlock(&io_lock);
>  }
>  
>  static int pnx4008_wdt_open(struct inode *inode, struct file *file)
>  {
> +	int ret;
> +
>  	if (test_and_set_bit(WDT_IN_USE, &wdt_status))
>  		return -EBUSY;
>  
>  	clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
>  
> +	ret = clk_enable(wdt_clk);
> +	if (ret) {
> +		clear_bit(WDT_IN_USE, &wdt_status);
> +		return ret;
> +	}
> +
>  	wdt_enable();
>  
>  	return nonseekable_open(inode, file);
> @@ -225,6 +228,7 @@ static int pnx4008_wdt_release(struct inode *inode, struct file *file)
>  		printk(KERN_WARNING "WATCHDOG: Device closed unexpectdly\n");
>  
>  	wdt_disable();
> +	clk_disable(wdt_clk);
>  	clear_bit(WDT_IN_USE, &wdt_status);
>  	clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
>  
> @@ -279,19 +283,27 @@ static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
>  		release_resource(wdt_mem);
>  		kfree(wdt_mem);
>  		goto out;
> -	} else
> -		clk_set_rate(wdt_clk, 1);
> +	}
> +
> +	ret = clk_enable(wdt_clk);
> +	if (ret) {
> +		release_resource(wdt_mem);
> +		kfree(wdt_mem);
> +		goto out;
> +	}
>  
>  	ret = misc_register(&pnx4008_wdt_miscdev);
>  	if (ret < 0) {
>  		printk(KERN_ERR MODULE_NAME "cannot register misc device\n");
>  		release_resource(wdt_mem);
>  		kfree(wdt_mem);
> -		clk_set_rate(wdt_clk, 0);
> +		clk_disable(wdt_clk);
> +		clk_put(wdt_clk);
>  	} else {
>  		boot_status = (__raw_readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ?
>  		    WDIOF_CARDRESET : 0;
>  		wdt_disable();		/*disable for now */
> +		clk_disable(wdt_clk);
>  		set_bit(WDT_DEVICE_INITED, &wdt_status);
>  	}
>  
> @@ -302,11 +314,10 @@ out:
>  static int __devexit pnx4008_wdt_remove(struct platform_device *pdev)
>  {
>  	misc_deregister(&pnx4008_wdt_miscdev);
> -	if (wdt_clk) {
> -		clk_set_rate(wdt_clk, 0);
> -		clk_put(wdt_clk);
> -		wdt_clk = NULL;
> -	}
> +
> +	clk_disable(wdt_clk);
> +	clk_put(wdt_clk);
> +
>  	if (wdt_mem) {
>  		release_resource(wdt_mem);
>  		kfree(wdt_mem);
> -- 
> 1.6.2.5
> 

  reply	other threads:[~2009-11-20 15:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
2009-11-20 10:32 ` [PATCH 01/10] ARM: PNX4008: convert to clkdev Russell King - ARM Linux
2009-11-20 10:46 ` [PATCH 06/10] ARM: PNX4008: convert i2c clocks to match by device only Russell King - ARM Linux
2009-11-20 10:50 ` [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver Russell King - ARM Linux
2009-11-21 12:53   ` Russell King - ARM Linux
2009-11-23 18:22     ` Vitaly Wool
2009-11-21 17:27   ` Linus Walleij
2009-11-21 18:59     ` Russell King - ARM Linux
2009-11-23 17:30       ` Kevin Wells
2009-11-25 21:19       ` Kevin Wells
2009-12-14 23:06         ` Russell King - ARM Linux
2009-12-15  0:16           ` Kevin Wells
2009-11-20 11:12 ` [PATCH 08/10] ARM: PNX4008: move i2c clock start/stop " Russell King - ARM Linux
2009-11-20 11:25 ` [PATCH 02/10] ARM: PNX4008: simplify clk enable/disable paths Russell King - ARM Linux
2009-11-20 11:28 ` [PATCH 03/10] ARM: PNX4008: provide clock enable/disable methods and initialization Russell King - ARM Linux
2009-11-20 11:44 ` [PATCH 09/10] ARM: PNX4008: convert i2c-pnx to use clk API enable/disable calls Russell King - ARM Linux
2009-11-20 12:46 ` [PATCH 10/10] ARM: PNX4008: get i2c clock rate from clk API Russell King - ARM Linux
2009-11-20 13:04 ` [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API enable/disable calls Russell King - ARM Linux
2009-11-20 15:03   ` Wim Van Sebroeck [this message]
2009-11-23 23:38     ` Kevin Wells
2009-11-23 23:50       ` Russell King - ARM Linux
2009-11-20 13:07 ` [PATCH 04/10] ARM: PNX4008: convert watchdog clocks to match by device only Russell King - ARM Linux
2009-11-20 15:01   ` Wim Van Sebroeck
2009-11-20 17:09     ` Russell King - ARM Linux

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=20091120150332.GY19336@infomag.iguana.be \
    --to=wim@iguana.be \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).