X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fchar%2Fs3c2410-rtc.c;h=b0038b19b5056a7bbca2991b704749ed5d2a153a;hb=db7f44d96e0b605906abc38aaf34841a93885884;hp=8e61be34a1d328c5a948a646504ad65629eaef62;hpb=4fd416c14c583ee6ff1e2b17ab05e7e02e170e4c;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c index 8e61be3..b0038b1 100644 --- a/drivers/char/s3c2410-rtc.c +++ b/drivers/char/s3c2410-rtc.c @@ -20,10 +20,11 @@ #include #include #include -#include +#include #include #include #include +#include #include #include @@ -33,7 +34,6 @@ #include -#include #include /* need this for the RTC_AF definitions */ @@ -116,7 +116,7 @@ static void s3c2410_rtc_setfreq(int freq) /* Time read/write */ -static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm) +static int s3c2410_rtc_gettime(struct rtc_time *rtc_tm) { unsigned int have_retried = 0; @@ -151,6 +151,8 @@ static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm) rtc_tm->tm_year += 100; rtc_tm->tm_mon -= 1; + + return 0; } @@ -171,7 +173,7 @@ static int s3c2410_rtc_settime(struct rtc_time *tm) return 0; } -static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm) +static int s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm) { struct rtc_time *alm_tm = &alrm->time; unsigned int alm_en; @@ -231,6 +233,8 @@ static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm) } /* todo - set alrm->enabled ? */ + + return 0; } static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm) @@ -378,7 +382,7 @@ static struct rtc_ops s3c2410_rtcops = { .proc = s3c2410_rtc_proc, }; -static void s3c2410_rtc_enable(struct device *dev, int en) +static void s3c2410_rtc_enable(struct platform_device *pdev, int en) { unsigned int tmp; @@ -395,21 +399,21 @@ static void s3c2410_rtc_enable(struct device *dev, int en) /* re-enable the device, and check it is ok */ if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_RTCEN) == 0){ - dev_info(dev, "rtc disabled, re-enabling\n"); + dev_info(&pdev->dev, "rtc disabled, re-enabling\n"); tmp = readb(S3C2410_RTCCON); writeb(tmp | S3C2410_RTCCON_RTCEN , S3C2410_RTCCON); } if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_CNTSEL)){ - dev_info(dev, "removing S3C2410_RTCCON_CNTSEL\n"); + dev_info(&pdev->dev, "removing S3C2410_RTCCON_CNTSEL\n"); tmp = readb(S3C2410_RTCCON); writeb(tmp& ~S3C2410_RTCCON_CNTSEL , S3C2410_RTCCON); } if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_CLKRST)){ - dev_info(dev, "removing S3C2410_RTCCON_CLKRST\n"); + dev_info(&pdev->dev, "removing S3C2410_RTCCON_CLKRST\n"); tmp = readb(S3C2410_RTCCON); writeb(tmp & ~S3C2410_RTCCON_CLKRST, S3C2410_RTCCON); @@ -417,7 +421,7 @@ static void s3c2410_rtc_enable(struct device *dev, int en) } } -static int s3c2410_rtc_remove(struct device *dev) +static int s3c2410_rtc_remove(struct platform_device *dev) { unregister_rtc(&s3c2410_rtcops); @@ -434,25 +438,24 @@ static int s3c2410_rtc_remove(struct device *dev) return 0; } -static int s3c2410_rtc_probe(struct device *dev) +static int s3c2410_rtc_probe(struct platform_device *pdev) { - struct platform_device *pdev = to_platform_device(dev); struct resource *res; int ret; - pr_debug("%s: probe=%p, device=%p\n", __FUNCTION__, pdev, dev); + pr_debug("%s: probe=%p\n", __FUNCTION__, pdev); /* find the IRQs */ s3c2410_rtc_tickno = platform_get_irq(pdev, 1); - if (s3c2410_rtc_tickno <= 0) { - dev_err(dev, "no irq for rtc tick\n"); + if (s3c2410_rtc_tickno < 0) { + dev_err(&pdev->dev, "no irq for rtc tick\n"); return -ENOENT; } s3c2410_rtc_alarmno = platform_get_irq(pdev, 0); - if (s3c2410_rtc_alarmno <= 0) { - dev_err(dev, "no irq for alarm\n"); + if (s3c2410_rtc_alarmno < 0) { + dev_err(&pdev->dev, "no irq for alarm\n"); return -ENOENT; } @@ -463,7 +466,7 @@ static int s3c2410_rtc_probe(struct device *dev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { - dev_err(dev, "failed to get memory region resource\n"); + dev_err(&pdev->dev, "failed to get memory region resource\n"); return -ENOENT; } @@ -471,14 +474,14 @@ static int s3c2410_rtc_probe(struct device *dev) pdev->name); if (s3c2410_rtc_mem == NULL) { - dev_err(dev, "failed to reserve memory region\n"); + dev_err(&pdev->dev, "failed to reserve memory region\n"); ret = -ENOENT; goto exit_err; } s3c2410_rtc_base = ioremap(res->start, res->end - res->start + 1); if (s3c2410_rtc_base == NULL) { - dev_err(dev, "failed ioremap()\n"); + dev_err(&pdev->dev, "failed ioremap()\n"); ret = -EINVAL; goto exit_err; } @@ -490,7 +493,7 @@ static int s3c2410_rtc_probe(struct device *dev) /* check to see if everything is setup correctly */ - s3c2410_rtc_enable(dev, 1); + s3c2410_rtc_enable(pdev, 1); pr_debug("s3c2410_rtc: RTCCON=%02x\n", readb(S3C2410_RTCCON)); @@ -502,7 +505,7 @@ static int s3c2410_rtc_probe(struct device *dev) return 0; exit_err: - dev_err(dev, "error %d during initialisation\n", ret); + dev_err(&pdev->dev, "error %d during initialisation\n", ret); return ret; } @@ -515,37 +518,35 @@ static struct timespec s3c2410_rtc_delta; static int ticnt_save; -static int s3c2410_rtc_suspend(struct device *dev, pm_message_t state, u32 level) +static int s3c2410_rtc_suspend(struct platform_device *pdev, pm_message_t state) { struct rtc_time tm; struct timespec time; time.tv_nsec = 0; - if (level == SUSPEND_POWER_DOWN) { - /* save TICNT for anyone using periodic interrupts */ + /* save TICNT for anyone using periodic interrupts */ - ticnt_save = readb(S3C2410_TICNT); + ticnt_save = readb(S3C2410_TICNT); - /* calculate time delta for suspend */ + /* calculate time delta for suspend */ - s3c2410_rtc_gettime(&tm); - rtc_tm_to_time(&tm, &time.tv_sec); - save_time_delta(&s3c2410_rtc_delta, &time); - s3c2410_rtc_enable(dev, 0); - } + s3c2410_rtc_gettime(&tm); + rtc_tm_to_time(&tm, &time.tv_sec); + save_time_delta(&s3c2410_rtc_delta, &time); + s3c2410_rtc_enable(pdev, 0); return 0; } -static int s3c2410_rtc_resume(struct device *dev, u32 level) +static int s3c2410_rtc_resume(struct platform_device *pdev) { struct rtc_time tm; struct timespec time; time.tv_nsec = 0; - s3c2410_rtc_enable(dev, 1); + s3c2410_rtc_enable(pdev, 1); s3c2410_rtc_gettime(&tm); rtc_tm_to_time(&tm, &time.tv_sec); restore_time_delta(&s3c2410_rtc_delta, &time); @@ -558,13 +559,15 @@ static int s3c2410_rtc_resume(struct device *dev, u32 level) #define s3c2410_rtc_resume NULL #endif -static struct device_driver s3c2410_rtcdrv = { - .name = "s3c2410-rtc", - .bus = &platform_bus_type, +static struct platform_driver s3c2410_rtcdrv = { .probe = s3c2410_rtc_probe, .remove = s3c2410_rtc_remove, .suspend = s3c2410_rtc_suspend, .resume = s3c2410_rtc_resume, + .driver = { + .name = "s3c2410-rtc", + .owner = THIS_MODULE, + }, }; static char __initdata banner[] = "S3C2410 RTC, (c) 2004 Simtec Electronics\n"; @@ -572,12 +575,12 @@ static char __initdata banner[] = "S3C2410 RTC, (c) 2004 Simtec Electronics\n"; static int __init s3c2410_rtc_init(void) { printk(banner); - return driver_register(&s3c2410_rtcdrv); + return platform_driver_register(&s3c2410_rtcdrv); } static void __exit s3c2410_rtc_exit(void) { - driver_unregister(&s3c2410_rtcdrv); + platform_driver_unregister(&s3c2410_rtcdrv); } module_init(s3c2410_rtc_init);