diff options
Diffstat (limited to 'drivers/rtc/rtc-bfin.c')
| -rw-r--r-- | drivers/rtc/rtc-bfin.c | 106 | 
1 files changed, 29 insertions, 77 deletions
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index b4b6087f223..fe4bdb06a55 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c @@ -20,9 +20,9 @@   * write would be discarded and things quickly fall apart.   *   * To keep this delay from significantly degrading performance (we, in theory, - * would have to sleep for up to 1 second everytime we wanted to write a + * would have to sleep for up to 1 second every time we wanted to write a   * register), we only check the write pending status before we start to issue - * a new write.  We bank on the idea that it doesnt matter when the sync + * a new write.  We bank on the idea that it doesn't matter when the sync   * happens so long as we don't attempt another write before it does.  The only   * time userspace would take this penalty is when they try and do multiple   * operations right after another ... but in this case, they need to take the @@ -240,40 +240,18 @@ static void bfin_rtc_int_set_alarm(struct bfin_rtc *rtc)  	 */  	bfin_rtc_int_set(rtc->rtc_alarm.tm_yday == -1 ? RTC_ISTAT_ALARM : RTC_ISTAT_ALARM_DAY);  } -static int bfin_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) + +static int bfin_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)  {  	struct bfin_rtc *rtc = dev_get_drvdata(dev); -	int ret = 0;  	dev_dbg_stamp(dev); - -	bfin_rtc_sync_pending(dev); - -	switch (cmd) { -	case RTC_UIE_ON: -		dev_dbg_stamp(dev); -		bfin_rtc_int_set(RTC_ISTAT_SEC); -		break; -	case RTC_UIE_OFF: -		dev_dbg_stamp(dev); -		bfin_rtc_int_clear(~RTC_ISTAT_SEC); -		break; - -	case RTC_AIE_ON: -		dev_dbg_stamp(dev); +	if (enabled)  		bfin_rtc_int_set_alarm(rtc); -		break; -	case RTC_AIE_OFF: -		dev_dbg_stamp(dev); +	else  		bfin_rtc_int_clear(~(RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)); -		break; - -	default: -		dev_dbg_stamp(dev); -		ret = -ENOIOCTLCMD; -	} -	return ret; +	return 0;  }  static int bfin_rtc_read_time(struct device *dev, struct rtc_time *tm) @@ -356,42 +334,44 @@ static int bfin_rtc_proc(struct device *dev, struct seq_file *seq)  }  static struct rtc_class_ops bfin_rtc_ops = { -	.ioctl         = bfin_rtc_ioctl,  	.read_time     = bfin_rtc_read_time,  	.set_time      = bfin_rtc_set_time,  	.read_alarm    = bfin_rtc_read_alarm,  	.set_alarm     = bfin_rtc_set_alarm,  	.proc          = bfin_rtc_proc, +	.alarm_irq_enable = bfin_rtc_alarm_irq_enable,  }; -static int __devinit bfin_rtc_probe(struct platform_device *pdev) +static int bfin_rtc_probe(struct platform_device *pdev)  {  	struct bfin_rtc *rtc;  	struct device *dev = &pdev->dev; -	int ret = 0; +	int ret;  	unsigned long timeout = jiffies + HZ;  	dev_dbg_stamp(dev);  	/* Allocate memory for our RTC struct */ -	rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); +	rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL);  	if (unlikely(!rtc))  		return -ENOMEM;  	platform_set_drvdata(pdev, rtc);  	device_init_wakeup(dev, 1);  	/* Register our RTC with the RTC framework */ -	rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, +	rtc->rtc_dev = devm_rtc_device_register(dev, pdev->name, &bfin_rtc_ops,  						THIS_MODULE); -	if (unlikely(IS_ERR(rtc->rtc_dev))) { -		ret = PTR_ERR(rtc->rtc_dev); -		goto err; -	} +	if (unlikely(IS_ERR(rtc->rtc_dev))) +		return PTR_ERR(rtc->rtc_dev);  	/* Grab the IRQ and init the hardware */ -	ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, 0, pdev->name, dev); +	ret = devm_request_irq(dev, IRQ_RTC, bfin_rtc_interrupt, 0, +				pdev->name, dev);  	if (unlikely(ret)) -		goto err_reg; +		dev_err(&pdev->dev, +			"unable to request IRQ; alarm won't work, " +			"and writes will be delayed\n"); +  	/* sometimes the bootloader touched things, but the write complete was not  	 * enabled, so let's just do a quick timeout here since the IRQ will not fire ...  	 */ @@ -402,33 +382,20 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev)  	bfin_write_RTC_SWCNT(0);  	return 0; - -err_reg: -	rtc_device_unregister(rtc->rtc_dev); -err: -	kfree(rtc); -	return ret;  } -static int __devexit bfin_rtc_remove(struct platform_device *pdev) +static int bfin_rtc_remove(struct platform_device *pdev)  { -	struct bfin_rtc *rtc = platform_get_drvdata(pdev);  	struct device *dev = &pdev->dev;  	bfin_rtc_reset(dev, 0); -	free_irq(IRQ_RTC, dev); -	rtc_device_unregister(rtc->rtc_dev); -	platform_set_drvdata(pdev, NULL); -	kfree(rtc);  	return 0;  } -#ifdef CONFIG_PM -static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int bfin_rtc_suspend(struct device *dev)  { -	struct device *dev = &pdev->dev; -  	dev_dbg_stamp(dev);  	if (device_may_wakeup(dev)) { @@ -440,10 +407,8 @@ static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state)  	return 0;  } -static int bfin_rtc_resume(struct platform_device *pdev) +static int bfin_rtc_resume(struct device *dev)  { -	struct device *dev = &pdev->dev; -  	dev_dbg_stamp(dev);  	if (device_may_wakeup(dev)) @@ -462,34 +427,21 @@ static int bfin_rtc_resume(struct platform_device *pdev)  	return 0;  } -#else -# define bfin_rtc_suspend NULL -# define bfin_rtc_resume  NULL  #endif +static SIMPLE_DEV_PM_OPS(bfin_rtc_pm_ops, bfin_rtc_suspend, bfin_rtc_resume); +  static struct platform_driver bfin_rtc_driver = {  	.driver		= {  		.name	= "rtc-bfin",  		.owner	= THIS_MODULE, +		.pm	= &bfin_rtc_pm_ops,  	},  	.probe		= bfin_rtc_probe, -	.remove		= __devexit_p(bfin_rtc_remove), -	.suspend	= bfin_rtc_suspend, -	.resume		= bfin_rtc_resume, +	.remove		= bfin_rtc_remove,  }; -static int __init bfin_rtc_init(void) -{ -	return platform_driver_register(&bfin_rtc_driver); -} - -static void __exit bfin_rtc_exit(void) -{ -	platform_driver_unregister(&bfin_rtc_driver); -} - -module_init(bfin_rtc_init); -module_exit(bfin_rtc_exit); +module_platform_driver(bfin_rtc_driver);  MODULE_DESCRIPTION("Blackfin On-Chip Real Time Clock Driver");  MODULE_AUTHOR("Mike Frysinger <vapier@gentoo.org>");  | 
