diff options
author | Mike Frysinger <vapier.adi@gmail.com> | 2008-08-20 17:09:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-20 18:40:30 -0400 |
commit | fe2e1cf83a46c879a66ec5146ba7a09a6aef0a5c (patch) | |
tree | c7b0fa660cdf2c4f79d484603acc2ce78f3828c6 /drivers/rtc/rtc-bfin.c | |
parent | 1804dc6e145f3f24a8c94deddfc0a986d380a27f (diff) |
Blackfin RTC Driver: move irq request/free out of open/release and into probe/remove so that the non-dev interfaces (like sysfs) work as expected
Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-bfin.c')
-rw-r--r-- | drivers/rtc/rtc-bfin.c | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index a1af4c27939..51741dc1291 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c | |||
@@ -218,26 +218,6 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id) | |||
218 | return IRQ_NONE; | 218 | return IRQ_NONE; |
219 | } | 219 | } |
220 | 220 | ||
221 | static int bfin_rtc_open(struct device *dev) | ||
222 | { | ||
223 | int ret; | ||
224 | |||
225 | dev_dbg_stamp(dev); | ||
226 | |||
227 | ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, IRQF_SHARED, to_platform_device(dev)->name, dev); | ||
228 | if (!ret) | ||
229 | bfin_rtc_reset(dev, RTC_ISTAT_WRITE_COMPLETE); | ||
230 | |||
231 | return ret; | ||
232 | } | ||
233 | |||
234 | static void bfin_rtc_release(struct device *dev) | ||
235 | { | ||
236 | dev_dbg_stamp(dev); | ||
237 | bfin_rtc_reset(dev, 0); | ||
238 | free_irq(IRQ_RTC, dev); | ||
239 | } | ||
240 | |||
241 | static void bfin_rtc_int_set(u16 rtc_int) | 221 | static void bfin_rtc_int_set(u16 rtc_int) |
242 | { | 222 | { |
243 | bfin_write_RTC_ISTAT(rtc_int); | 223 | bfin_write_RTC_ISTAT(rtc_int); |
@@ -370,8 +350,6 @@ static int bfin_rtc_proc(struct device *dev, struct seq_file *seq) | |||
370 | } | 350 | } |
371 | 351 | ||
372 | static struct rtc_class_ops bfin_rtc_ops = { | 352 | static struct rtc_class_ops bfin_rtc_ops = { |
373 | .open = bfin_rtc_open, | ||
374 | .release = bfin_rtc_release, | ||
375 | .ioctl = bfin_rtc_ioctl, | 353 | .ioctl = bfin_rtc_ioctl, |
376 | .read_time = bfin_rtc_read_time, | 354 | .read_time = bfin_rtc_read_time, |
377 | .set_time = bfin_rtc_set_time, | 355 | .set_time = bfin_rtc_set_time, |
@@ -383,29 +361,37 @@ static struct rtc_class_ops bfin_rtc_ops = { | |||
383 | static int __devinit bfin_rtc_probe(struct platform_device *pdev) | 361 | static int __devinit bfin_rtc_probe(struct platform_device *pdev) |
384 | { | 362 | { |
385 | struct bfin_rtc *rtc; | 363 | struct bfin_rtc *rtc; |
364 | struct device *dev = &pdev->dev; | ||
386 | int ret = 0; | 365 | int ret = 0; |
387 | 366 | ||
388 | dev_dbg_stamp(&pdev->dev); | 367 | dev_dbg_stamp(dev); |
389 | 368 | ||
369 | /* Allocate memory for our RTC struct */ | ||
390 | rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); | 370 | rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); |
391 | if (unlikely(!rtc)) | 371 | if (unlikely(!rtc)) |
392 | return -ENOMEM; | 372 | return -ENOMEM; |
373 | platform_set_drvdata(pdev, rtc); | ||
393 | 374 | ||
394 | rtc->rtc_dev = rtc_device_register(pdev->name, &pdev->dev, &bfin_rtc_ops, THIS_MODULE); | 375 | /* Grab the IRQ and init the hardware */ |
395 | if (IS_ERR(rtc)) { | 376 | ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, IRQF_SHARED, pdev->name, dev); |
396 | ret = PTR_ERR(rtc->rtc_dev); | 377 | if (unlikely(ret)) |
397 | goto err; | 378 | goto err; |
398 | } | 379 | bfin_rtc_reset(dev, RTC_ISTAT_WRITE_COMPLETE); |
399 | |||
400 | /* see comment at top of file about stopwatch/PIE */ | ||
401 | bfin_write_RTC_SWCNT(0); | 380 | bfin_write_RTC_SWCNT(0); |
402 | 381 | ||
403 | platform_set_drvdata(pdev, rtc); | 382 | /* Register our RTC with the RTC framework */ |
383 | rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, THIS_MODULE); | ||
384 | if (unlikely(IS_ERR(rtc))) { | ||
385 | ret = PTR_ERR(rtc->rtc_dev); | ||
386 | goto err_irq; | ||
387 | } | ||
404 | 388 | ||
405 | device_init_wakeup(&pdev->dev, 1); | 389 | device_init_wakeup(dev, 1); |
406 | 390 | ||
407 | return 0; | 391 | return 0; |
408 | 392 | ||
393 | err_irq: | ||
394 | free_irq(IRQ_RTC, dev); | ||
409 | err: | 395 | err: |
410 | kfree(rtc); | 396 | kfree(rtc); |
411 | return ret; | 397 | return ret; |
@@ -414,7 +400,10 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev) | |||
414 | static int __devexit bfin_rtc_remove(struct platform_device *pdev) | 400 | static int __devexit bfin_rtc_remove(struct platform_device *pdev) |
415 | { | 401 | { |
416 | struct bfin_rtc *rtc = platform_get_drvdata(pdev); | 402 | struct bfin_rtc *rtc = platform_get_drvdata(pdev); |
403 | struct device *dev = &pdev->dev; | ||
417 | 404 | ||
405 | bfin_rtc_reset(dev, 0); | ||
406 | free_irq(IRQ_RTC, dev); | ||
418 | rtc_device_unregister(rtc->rtc_dev); | 407 | rtc_device_unregister(rtc->rtc_dev); |
419 | platform_set_drvdata(pdev, NULL); | 408 | platform_set_drvdata(pdev, NULL); |
420 | kfree(rtc); | 409 | kfree(rtc); |