forked from mirrors/linux
		
	drivers/rtc/rtc-sa1100.c: move clock enable/disable to probe/remove
The original sa1100_rtc_open/sa1100_rtc_release will be called when the /dev/rtc0 is opened or closed. In fact, these two functions will enable/disable the clock. Disabling clock will make rtc not work. So only enable/disable clock when probe/remove the device. Signed-off-by: Chao Xie <chao.xie@marvell.com> Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com> Cc: Leo Song <liangs@marvell.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									5e0b2704a1
								
							
						
					
					
						commit
						0cc0c38e91
					
				
					 1 changed files with 6 additions and 5 deletions
				
			
		| 
						 | 
					@ -108,9 +108,6 @@ static int sa1100_rtc_open(struct device *dev)
 | 
				
			||||||
	struct rtc_device *rtc = info->rtc;
 | 
						struct rtc_device *rtc = info->rtc;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = clk_prepare_enable(info->clk);
 | 
					 | 
				
			||||||
	if (ret)
 | 
					 | 
				
			||||||
		goto fail_clk;
 | 
					 | 
				
			||||||
	ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev);
 | 
						ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev);
 | 
				
			||||||
	if (ret) {
 | 
						if (ret) {
 | 
				
			||||||
		dev_err(dev, "IRQ %d already in use.\n", info->irq_1hz);
 | 
							dev_err(dev, "IRQ %d already in use.\n", info->irq_1hz);
 | 
				
			||||||
| 
						 | 
					@ -130,7 +127,6 @@ static int sa1100_rtc_open(struct device *dev)
 | 
				
			||||||
	free_irq(info->irq_1hz, dev);
 | 
						free_irq(info->irq_1hz, dev);
 | 
				
			||||||
 fail_ui:
 | 
					 fail_ui:
 | 
				
			||||||
	clk_disable_unprepare(info->clk);
 | 
						clk_disable_unprepare(info->clk);
 | 
				
			||||||
 fail_clk:
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,7 +140,6 @@ static void sa1100_rtc_release(struct device *dev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	free_irq(info->irq_alarm, dev);
 | 
						free_irq(info->irq_alarm, dev);
 | 
				
			||||||
	free_irq(info->irq_1hz, dev);
 | 
						free_irq(info->irq_1hz, dev);
 | 
				
			||||||
	clk_disable_unprepare(info->clk);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
 | 
					static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
 | 
				
			||||||
| 
						 | 
					@ -253,6 +248,9 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
 | 
				
			||||||
	spin_lock_init(&info->lock);
 | 
						spin_lock_init(&info->lock);
 | 
				
			||||||
	platform_set_drvdata(pdev, info);
 | 
						platform_set_drvdata(pdev, info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = clk_prepare_enable(info->clk);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							goto err_enable_clk;
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * According to the manual we should be able to let RTTR be zero
 | 
						 * According to the manual we should be able to let RTTR be zero
 | 
				
			||||||
	 * and then a default diviser for a 32.768KHz clock is used.
 | 
						 * and then a default diviser for a 32.768KHz clock is used.
 | 
				
			||||||
| 
						 | 
					@ -305,6 +303,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
err_dev:
 | 
					err_dev:
 | 
				
			||||||
 | 
						clk_disable_unprepare(info->clk);
 | 
				
			||||||
 | 
					err_enable_clk:
 | 
				
			||||||
	platform_set_drvdata(pdev, NULL);
 | 
						platform_set_drvdata(pdev, NULL);
 | 
				
			||||||
	clk_put(info->clk);
 | 
						clk_put(info->clk);
 | 
				
			||||||
err_clk:
 | 
					err_clk:
 | 
				
			||||||
| 
						 | 
					@ -318,6 +318,7 @@ static int sa1100_rtc_remove(struct platform_device *pdev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (info) {
 | 
						if (info) {
 | 
				
			||||||
		rtc_device_unregister(info->rtc);
 | 
							rtc_device_unregister(info->rtc);
 | 
				
			||||||
 | 
							clk_disable_unprepare(info->clk);
 | 
				
			||||||
		clk_put(info->clk);
 | 
							clk_put(info->clk);
 | 
				
			||||||
		platform_set_drvdata(pdev, NULL);
 | 
							platform_set_drvdata(pdev, NULL);
 | 
				
			||||||
		kfree(info);
 | 
							kfree(info);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue