diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-18 12:43:09 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-18 12:43:09 -0400 |
| commit | 515b696b282f856c3ad1679ccd658120faa387d0 (patch) | |
| tree | d9d7c1185c396617f128ca23463062308d11393b /drivers/rtc | |
| parent | fa877c71e2136bd682b45022c96d5e073ced9f58 (diff) | |
| parent | 064a16dc41be879d12bd5de5d2f9d38d890e0ee7 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6: (262 commits)
sh: mach-ecovec24: Add user debug switch support
sh: Kill off unused se_skipped in alignment trap notification code.
sh: Wire up HAVE_SYSCALL_TRACEPOINTS.
video: sh_mobile_lcdcfb: use both register sets for display panning
video: sh_mobile_lcdcfb: implement display panning
sh: Fix up sh7705 flush_dcache_page() build.
sh: kfr2r09: document the PLL/FLL <-> RF relationship.
sh: mach-ecovec24: need asm/clock.h.
sh: mach-ecovec24: deassert usb irq on boot.
sh: Add KEYSC support for EcoVec24
sh: add kycr2_delay for sh_keysc
sh: cpufreq: Include CPU id in info messages.
sh: multi-evt support for SH-X3 proto CPU.
sh: clkfwk: remove bogus set_bus_parent() from SH7709.
sh: Fix the indication point of the liquid crystal of AP-325RXA(AP3300)
sh: Add EcoVec24 romImage defconfig
sh: USB disable process is needed if romImage boot for EcoVec24
sh: EcoVec24: add HIZA setting for LED
sh: EcoVec24: write MAC address in boot
sh: Add romImage support for EcoVec24
...
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/rtc-ds1302.c | 69 | ||||
| -rw-r--r-- | drivers/rtc/rtc-sh.c | 97 |
2 files changed, 48 insertions, 118 deletions
diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index 184556620778..d490628b64da 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c | |||
| @@ -1,26 +1,25 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Dallas DS1302 RTC Support | 2 | * Dallas DS1302 RTC Support |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2002 David McCullough | 4 | * Copyright (C) 2002 David McCullough |
| 5 | * Copyright (C) 2003 - 2007 Paul Mundt | 5 | * Copyright (C) 2003 - 2007 Paul Mundt |
| 6 | * | 6 | * |
| 7 | * This file is subject to the terms and conditions of the GNU General Public | 7 | * This file is subject to the terms and conditions of the GNU General Public |
| 8 | * License version 2. See the file "COPYING" in the main directory of | 8 | * License version 2. See the file "COPYING" in the main directory of |
| 9 | * this archive for more details. | 9 | * this archive for more details. |
| 10 | */ | 10 | */ |
| 11 | |||
| 11 | #include <linux/init.h> | 12 | #include <linux/init.h> |
| 12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 13 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
| 14 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
| 15 | #include <linux/time.h> | ||
| 16 | #include <linux/rtc.h> | 16 | #include <linux/rtc.h> |
| 17 | #include <linux/spinlock.h> | ||
| 18 | #include <linux/io.h> | 17 | #include <linux/io.h> |
| 19 | #include <linux/bcd.h> | 18 | #include <linux/bcd.h> |
| 20 | #include <asm/rtc.h> | 19 | #include <asm/rtc.h> |
| 21 | 20 | ||
| 22 | #define DRV_NAME "rtc-ds1302" | 21 | #define DRV_NAME "rtc-ds1302" |
| 23 | #define DRV_VERSION "0.1.0" | 22 | #define DRV_VERSION "0.1.1" |
| 24 | 23 | ||
| 25 | #define RTC_CMD_READ 0x81 /* Read command */ | 24 | #define RTC_CMD_READ 0x81 /* Read command */ |
| 26 | #define RTC_CMD_WRITE 0x80 /* Write command */ | 25 | #define RTC_CMD_WRITE 0x80 /* Write command */ |
| @@ -47,11 +46,6 @@ | |||
| 47 | #error "Add support for your platform" | 46 | #error "Add support for your platform" |
| 48 | #endif | 47 | #endif |
| 49 | 48 | ||
| 50 | struct ds1302_rtc { | ||
| 51 | struct rtc_device *rtc_dev; | ||
| 52 | spinlock_t lock; | ||
| 53 | }; | ||
| 54 | |||
| 55 | static void ds1302_sendbits(unsigned int val) | 49 | static void ds1302_sendbits(unsigned int val) |
| 56 | { | 50 | { |
| 57 | int i; | 51 | int i; |
| @@ -103,10 +97,6 @@ static void ds1302_writebyte(unsigned int addr, unsigned int val) | |||
| 103 | 97 | ||
| 104 | static int ds1302_rtc_read_time(struct device *dev, struct rtc_time *tm) | 98 | static int ds1302_rtc_read_time(struct device *dev, struct rtc_time *tm) |
| 105 | { | 99 | { |
| 106 | struct ds1302_rtc *rtc = dev_get_drvdata(dev); | ||
| 107 | |||
| 108 | spin_lock_irq(&rtc->lock); | ||
| 109 | |||
| 110 | tm->tm_sec = bcd2bin(ds1302_readbyte(RTC_ADDR_SEC)); | 100 | tm->tm_sec = bcd2bin(ds1302_readbyte(RTC_ADDR_SEC)); |
| 111 | tm->tm_min = bcd2bin(ds1302_readbyte(RTC_ADDR_MIN)); | 101 | tm->tm_min = bcd2bin(ds1302_readbyte(RTC_ADDR_MIN)); |
| 112 | tm->tm_hour = bcd2bin(ds1302_readbyte(RTC_ADDR_HOUR)); | 102 | tm->tm_hour = bcd2bin(ds1302_readbyte(RTC_ADDR_HOUR)); |
| @@ -118,26 +108,17 @@ static int ds1302_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
| 118 | if (tm->tm_year < 70) | 108 | if (tm->tm_year < 70) |
| 119 | tm->tm_year += 100; | 109 | tm->tm_year += 100; |
| 120 | 110 | ||
| 121 | spin_unlock_irq(&rtc->lock); | ||
| 122 | |||
| 123 | dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " | 111 | dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " |
| 124 | "mday=%d, mon=%d, year=%d, wday=%d\n", | 112 | "mday=%d, mon=%d, year=%d, wday=%d\n", |
| 125 | __func__, | 113 | __func__, |
| 126 | tm->tm_sec, tm->tm_min, tm->tm_hour, | 114 | tm->tm_sec, tm->tm_min, tm->tm_hour, |
| 127 | tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday); | 115 | tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday); |
| 128 | 116 | ||
| 129 | if (rtc_valid_tm(tm) < 0) | 117 | return rtc_valid_tm(tm); |
| 130 | dev_err(dev, "invalid date\n"); | ||
| 131 | |||
| 132 | return 0; | ||
| 133 | } | 118 | } |
| 134 | 119 | ||
| 135 | static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm) | 120 | static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm) |
| 136 | { | 121 | { |
| 137 | struct ds1302_rtc *rtc = dev_get_drvdata(dev); | ||
| 138 | |||
| 139 | spin_lock_irq(&rtc->lock); | ||
| 140 | |||
| 141 | /* Stop RTC */ | 122 | /* Stop RTC */ |
| 142 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); | 123 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); |
| 143 | 124 | ||
| @@ -152,8 +133,6 @@ static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
| 152 | /* Start RTC */ | 133 | /* Start RTC */ |
| 153 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80); | 134 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80); |
| 154 | 135 | ||
| 155 | spin_unlock_irq(&rtc->lock); | ||
| 156 | |||
| 157 | return 0; | 136 | return 0; |
| 158 | } | 137 | } |
| 159 | 138 | ||
| @@ -170,9 +149,7 @@ static int ds1302_rtc_ioctl(struct device *dev, unsigned int cmd, | |||
| 170 | if (copy_from_user(&tcs_val, (int __user *)arg, sizeof(int))) | 149 | if (copy_from_user(&tcs_val, (int __user *)arg, sizeof(int))) |
| 171 | return -EFAULT; | 150 | return -EFAULT; |
| 172 | 151 | ||
| 173 | spin_lock_irq(&rtc->lock); | ||
| 174 | ds1302_writebyte(RTC_ADDR_TCR, (0xa0 | tcs_val * 0xf)); | 152 | ds1302_writebyte(RTC_ADDR_TCR, (0xa0 | tcs_val * 0xf)); |
| 175 | spin_unlock_irq(&rtc->lock); | ||
| 176 | return 0; | 153 | return 0; |
| 177 | } | 154 | } |
| 178 | #endif | 155 | #endif |
| @@ -187,10 +164,9 @@ static struct rtc_class_ops ds1302_rtc_ops = { | |||
| 187 | .ioctl = ds1302_rtc_ioctl, | 164 | .ioctl = ds1302_rtc_ioctl, |
| 188 | }; | 165 | }; |
| 189 | 166 | ||
| 190 | static int __devinit ds1302_rtc_probe(struct platform_device *pdev) | 167 | static int __init ds1302_rtc_probe(struct platform_device *pdev) |
| 191 | { | 168 | { |
| 192 | struct ds1302_rtc *rtc; | 169 | struct rtc_device *rtc; |
| 193 | int ret; | ||
| 194 | 170 | ||
| 195 | /* Reset */ | 171 | /* Reset */ |
| 196 | set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK)); | 172 | set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK)); |
| @@ -200,37 +176,23 @@ static int __devinit ds1302_rtc_probe(struct platform_device *pdev) | |||
| 200 | if (ds1302_readbyte(RTC_ADDR_RAM0) != 0x42) | 176 | if (ds1302_readbyte(RTC_ADDR_RAM0) != 0x42) |
| 201 | return -ENODEV; | 177 | return -ENODEV; |
| 202 | 178 | ||
| 203 | rtc = kzalloc(sizeof(struct ds1302_rtc), GFP_KERNEL); | 179 | rtc = rtc_device_register("ds1302", &pdev->dev, |
| 204 | if (unlikely(!rtc)) | ||
| 205 | return -ENOMEM; | ||
| 206 | |||
| 207 | spin_lock_init(&rtc->lock); | ||
| 208 | rtc->rtc_dev = rtc_device_register("ds1302", &pdev->dev, | ||
| 209 | &ds1302_rtc_ops, THIS_MODULE); | 180 | &ds1302_rtc_ops, THIS_MODULE); |
| 210 | if (IS_ERR(rtc->rtc_dev)) { | 181 | if (IS_ERR(rtc)) |
| 211 | ret = PTR_ERR(rtc->rtc_dev); | 182 | return PTR_ERR(rtc); |
| 212 | goto out; | ||
| 213 | } | ||
| 214 | 183 | ||
| 215 | platform_set_drvdata(pdev, rtc); | 184 | platform_set_drvdata(pdev, rtc); |
| 216 | 185 | ||
| 217 | return 0; | 186 | return 0; |
| 218 | out: | ||
| 219 | kfree(rtc); | ||
| 220 | return ret; | ||
| 221 | } | 187 | } |
| 222 | 188 | ||
| 223 | static int __devexit ds1302_rtc_remove(struct platform_device *pdev) | 189 | static int __devexit ds1302_rtc_remove(struct platform_device *pdev) |
| 224 | { | 190 | { |
| 225 | struct ds1302_rtc *rtc = platform_get_drvdata(pdev); | 191 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
| 226 | |||
| 227 | if (likely(rtc->rtc_dev)) | ||
| 228 | rtc_device_unregister(rtc->rtc_dev); | ||
| 229 | 192 | ||
| 193 | rtc_device_unregister(rtc); | ||
| 230 | platform_set_drvdata(pdev, NULL); | 194 | platform_set_drvdata(pdev, NULL); |
| 231 | 195 | ||
| 232 | kfree(rtc); | ||
| 233 | |||
| 234 | return 0; | 196 | return 0; |
| 235 | } | 197 | } |
| 236 | 198 | ||
| @@ -239,13 +201,12 @@ static struct platform_driver ds1302_platform_driver = { | |||
| 239 | .name = DRV_NAME, | 201 | .name = DRV_NAME, |
| 240 | .owner = THIS_MODULE, | 202 | .owner = THIS_MODULE, |
| 241 | }, | 203 | }, |
| 242 | .probe = ds1302_rtc_probe, | 204 | .remove = __exit_p(ds1302_rtc_remove), |
| 243 | .remove = __devexit_p(ds1302_rtc_remove), | ||
| 244 | }; | 205 | }; |
| 245 | 206 | ||
| 246 | static int __init ds1302_rtc_init(void) | 207 | static int __init ds1302_rtc_init(void) |
| 247 | { | 208 | { |
| 248 | return platform_driver_register(&ds1302_platform_driver); | 209 | return platform_driver_probe(&ds1302_platform_driver, ds1302_rtc_probe); |
| 249 | } | 210 | } |
| 250 | 211 | ||
| 251 | static void __exit ds1302_rtc_exit(void) | 212 | static void __exit ds1302_rtc_exit(void) |
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index d7310adb7152..e6ed5404bca0 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | #include <asm/rtc.h> | 29 | #include <asm/rtc.h> |
| 30 | 30 | ||
| 31 | #define DRV_NAME "sh-rtc" | 31 | #define DRV_NAME "sh-rtc" |
| 32 | #define DRV_VERSION "0.2.2" | 32 | #define DRV_VERSION "0.2.3" |
| 33 | 33 | ||
| 34 | #define RTC_REG(r) ((r) * rtc_reg_size) | 34 | #define RTC_REG(r) ((r) * rtc_reg_size) |
| 35 | 35 | ||
| @@ -215,7 +215,7 @@ static irqreturn_t sh_rtc_shared(int irq, void *dev_id) | |||
| 215 | return IRQ_RETVAL(ret); | 215 | return IRQ_RETVAL(ret); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | static inline void sh_rtc_setpie(struct device *dev, unsigned int enable) | 218 | static int sh_rtc_irq_set_state(struct device *dev, int enable) |
| 219 | { | 219 | { |
| 220 | struct sh_rtc *rtc = dev_get_drvdata(dev); | 220 | struct sh_rtc *rtc = dev_get_drvdata(dev); |
| 221 | unsigned int tmp; | 221 | unsigned int tmp; |
| @@ -225,17 +225,22 @@ static inline void sh_rtc_setpie(struct device *dev, unsigned int enable) | |||
| 225 | tmp = readb(rtc->regbase + RCR2); | 225 | tmp = readb(rtc->regbase + RCR2); |
| 226 | 226 | ||
| 227 | if (enable) { | 227 | if (enable) { |
| 228 | rtc->periodic_freq |= PF_KOU; | ||
| 228 | tmp &= ~RCR2_PEF; /* Clear PES bit */ | 229 | tmp &= ~RCR2_PEF; /* Clear PES bit */ |
| 229 | tmp |= (rtc->periodic_freq & ~PF_HP); /* Set PES2-0 */ | 230 | tmp |= (rtc->periodic_freq & ~PF_HP); /* Set PES2-0 */ |
| 230 | } else | 231 | } else { |
| 232 | rtc->periodic_freq &= ~PF_KOU; | ||
| 231 | tmp &= ~(RCR2_PESMASK | RCR2_PEF); | 233 | tmp &= ~(RCR2_PESMASK | RCR2_PEF); |
| 234 | } | ||
| 232 | 235 | ||
| 233 | writeb(tmp, rtc->regbase + RCR2); | 236 | writeb(tmp, rtc->regbase + RCR2); |
| 234 | 237 | ||
| 235 | spin_unlock_irq(&rtc->lock); | 238 | spin_unlock_irq(&rtc->lock); |
| 239 | |||
| 240 | return 0; | ||
| 236 | } | 241 | } |
| 237 | 242 | ||
| 238 | static inline int sh_rtc_setfreq(struct device *dev, unsigned int freq) | 243 | static int sh_rtc_irq_set_freq(struct device *dev, int freq) |
| 239 | { | 244 | { |
| 240 | struct sh_rtc *rtc = dev_get_drvdata(dev); | 245 | struct sh_rtc *rtc = dev_get_drvdata(dev); |
| 241 | int tmp, ret = 0; | 246 | int tmp, ret = 0; |
| @@ -278,10 +283,8 @@ static inline int sh_rtc_setfreq(struct device *dev, unsigned int freq) | |||
| 278 | ret = -ENOTSUPP; | 283 | ret = -ENOTSUPP; |
| 279 | } | 284 | } |
| 280 | 285 | ||
| 281 | if (ret == 0) { | 286 | if (ret == 0) |
| 282 | rtc->periodic_freq |= tmp; | 287 | rtc->periodic_freq |= tmp; |
| 283 | rtc->rtc_dev->irq_freq = freq; | ||
| 284 | } | ||
| 285 | 288 | ||
| 286 | spin_unlock_irq(&rtc->lock); | 289 | spin_unlock_irq(&rtc->lock); |
| 287 | return ret; | 290 | return ret; |
| @@ -346,10 +349,6 @@ static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
| 346 | unsigned int ret = 0; | 349 | unsigned int ret = 0; |
| 347 | 350 | ||
| 348 | switch (cmd) { | 351 | switch (cmd) { |
| 349 | case RTC_PIE_OFF: | ||
| 350 | case RTC_PIE_ON: | ||
| 351 | sh_rtc_setpie(dev, cmd == RTC_PIE_ON); | ||
| 352 | break; | ||
| 353 | case RTC_AIE_OFF: | 352 | case RTC_AIE_OFF: |
| 354 | case RTC_AIE_ON: | 353 | case RTC_AIE_ON: |
| 355 | sh_rtc_setaie(dev, cmd == RTC_AIE_ON); | 354 | sh_rtc_setaie(dev, cmd == RTC_AIE_ON); |
| @@ -362,13 +361,6 @@ static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
| 362 | rtc->periodic_freq |= PF_OXS; | 361 | rtc->periodic_freq |= PF_OXS; |
| 363 | sh_rtc_setcie(dev, 1); | 362 | sh_rtc_setcie(dev, 1); |
| 364 | break; | 363 | break; |
| 365 | case RTC_IRQP_READ: | ||
| 366 | ret = put_user(rtc->rtc_dev->irq_freq, | ||
| 367 | (unsigned long __user *)arg); | ||
| 368 | break; | ||
| 369 | case RTC_IRQP_SET: | ||
| 370 | ret = sh_rtc_setfreq(dev, arg); | ||
| 371 | break; | ||
| 372 | default: | 364 | default: |
| 373 | ret = -ENOIOCTLCMD; | 365 | ret = -ENOIOCTLCMD; |
| 374 | } | 366 | } |
| @@ -602,28 +594,6 @@ static int sh_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
| 602 | return 0; | 594 | return 0; |
| 603 | } | 595 | } |
| 604 | 596 | ||
| 605 | static int sh_rtc_irq_set_state(struct device *dev, int enabled) | ||
| 606 | { | ||
| 607 | struct platform_device *pdev = to_platform_device(dev); | ||
| 608 | struct sh_rtc *rtc = platform_get_drvdata(pdev); | ||
| 609 | |||
| 610 | if (enabled) { | ||
| 611 | rtc->periodic_freq |= PF_KOU; | ||
| 612 | return sh_rtc_ioctl(dev, RTC_PIE_ON, 0); | ||
| 613 | } else { | ||
| 614 | rtc->periodic_freq &= ~PF_KOU; | ||
| 615 | return sh_rtc_ioctl(dev, RTC_PIE_OFF, 0); | ||
| 616 | } | ||
| 617 | } | ||
| 618 | |||
| 619 | static int sh_rtc_irq_set_freq(struct device *dev, int freq) | ||
| 620 | { | ||
| 621 | if (!is_power_of_2(freq)) | ||
| 622 | return -EINVAL; | ||
| 623 | |||
| 624 | return sh_rtc_ioctl(dev, RTC_IRQP_SET, freq); | ||
| 625 | } | ||
| 626 | |||
| 627 | static struct rtc_class_ops sh_rtc_ops = { | 597 | static struct rtc_class_ops sh_rtc_ops = { |
| 628 | .ioctl = sh_rtc_ioctl, | 598 | .ioctl = sh_rtc_ioctl, |
| 629 | .read_time = sh_rtc_read_time, | 599 | .read_time = sh_rtc_read_time, |
| @@ -635,7 +605,7 @@ static struct rtc_class_ops sh_rtc_ops = { | |||
| 635 | .proc = sh_rtc_proc, | 605 | .proc = sh_rtc_proc, |
| 636 | }; | 606 | }; |
| 637 | 607 | ||
| 638 | static int __devinit sh_rtc_probe(struct platform_device *pdev) | 608 | static int __init sh_rtc_probe(struct platform_device *pdev) |
| 639 | { | 609 | { |
| 640 | struct sh_rtc *rtc; | 610 | struct sh_rtc *rtc; |
| 641 | struct resource *res; | 611 | struct resource *res; |
| @@ -702,13 +672,6 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev) | |||
| 702 | 672 | ||
| 703 | clk_enable(rtc->clk); | 673 | clk_enable(rtc->clk); |
| 704 | 674 | ||
| 705 | rtc->rtc_dev = rtc_device_register("sh", &pdev->dev, | ||
| 706 | &sh_rtc_ops, THIS_MODULE); | ||
| 707 | if (IS_ERR(rtc->rtc_dev)) { | ||
| 708 | ret = PTR_ERR(rtc->rtc_dev); | ||
| 709 | goto err_unmap; | ||
| 710 | } | ||
| 711 | |||
| 712 | rtc->capabilities = RTC_DEF_CAPABILITIES; | 675 | rtc->capabilities = RTC_DEF_CAPABILITIES; |
| 713 | if (pdev->dev.platform_data) { | 676 | if (pdev->dev.platform_data) { |
| 714 | struct sh_rtc_platform_info *pinfo = pdev->dev.platform_data; | 677 | struct sh_rtc_platform_info *pinfo = pdev->dev.platform_data; |
| @@ -720,10 +683,6 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev) | |||
| 720 | rtc->capabilities |= pinfo->capabilities; | 683 | rtc->capabilities |= pinfo->capabilities; |
| 721 | } | 684 | } |
| 722 | 685 | ||
| 723 | rtc->rtc_dev->max_user_freq = 256; | ||
| 724 | |||
| 725 | platform_set_drvdata(pdev, rtc); | ||
| 726 | |||
| 727 | if (rtc->carry_irq <= 0) { | 686 | if (rtc->carry_irq <= 0) { |
| 728 | /* register shared periodic/carry/alarm irq */ | 687 | /* register shared periodic/carry/alarm irq */ |
| 729 | ret = request_irq(rtc->periodic_irq, sh_rtc_shared, | 688 | ret = request_irq(rtc->periodic_irq, sh_rtc_shared, |
| @@ -767,13 +726,26 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev) | |||
| 767 | } | 726 | } |
| 768 | } | 727 | } |
| 769 | 728 | ||
| 729 | platform_set_drvdata(pdev, rtc); | ||
| 730 | |||
| 770 | /* everything disabled by default */ | 731 | /* everything disabled by default */ |
| 771 | rtc->periodic_freq = 0; | 732 | sh_rtc_irq_set_freq(&pdev->dev, 0); |
| 772 | rtc->rtc_dev->irq_freq = 0; | 733 | sh_rtc_irq_set_state(&pdev->dev, 0); |
| 773 | sh_rtc_setpie(&pdev->dev, 0); | ||
| 774 | sh_rtc_setaie(&pdev->dev, 0); | 734 | sh_rtc_setaie(&pdev->dev, 0); |
| 775 | sh_rtc_setcie(&pdev->dev, 0); | 735 | sh_rtc_setcie(&pdev->dev, 0); |
| 776 | 736 | ||
| 737 | rtc->rtc_dev = rtc_device_register("sh", &pdev->dev, | ||
| 738 | &sh_rtc_ops, THIS_MODULE); | ||
| 739 | if (IS_ERR(rtc->rtc_dev)) { | ||
| 740 | ret = PTR_ERR(rtc->rtc_dev); | ||
| 741 | free_irq(rtc->periodic_irq, rtc); | ||
| 742 | free_irq(rtc->carry_irq, rtc); | ||
| 743 | free_irq(rtc->alarm_irq, rtc); | ||
| 744 | goto err_unmap; | ||
| 745 | } | ||
| 746 | |||
| 747 | rtc->rtc_dev->max_user_freq = 256; | ||
| 748 | |||
| 777 | /* reset rtc to epoch 0 if time is invalid */ | 749 | /* reset rtc to epoch 0 if time is invalid */ |
| 778 | if (rtc_read_time(rtc->rtc_dev, &r) < 0) { | 750 | if (rtc_read_time(rtc->rtc_dev, &r) < 0) { |
| 779 | rtc_time_to_tm(0, &r); | 751 | rtc_time_to_tm(0, &r); |
| @@ -795,14 +767,13 @@ err_badres: | |||
| 795 | return ret; | 767 | return ret; |
| 796 | } | 768 | } |
| 797 | 769 | ||
| 798 | static int __devexit sh_rtc_remove(struct platform_device *pdev) | 770 | static int __exit sh_rtc_remove(struct platform_device *pdev) |
| 799 | { | 771 | { |
| 800 | struct sh_rtc *rtc = platform_get_drvdata(pdev); | 772 | struct sh_rtc *rtc = platform_get_drvdata(pdev); |
| 801 | 773 | ||
| 802 | if (likely(rtc->rtc_dev)) | 774 | rtc_device_unregister(rtc->rtc_dev); |
| 803 | rtc_device_unregister(rtc->rtc_dev); | 775 | sh_rtc_irq_set_state(&pdev->dev, 0); |
| 804 | 776 | ||
| 805 | sh_rtc_setpie(&pdev->dev, 0); | ||
| 806 | sh_rtc_setaie(&pdev->dev, 0); | 777 | sh_rtc_setaie(&pdev->dev, 0); |
| 807 | sh_rtc_setcie(&pdev->dev, 0); | 778 | sh_rtc_setcie(&pdev->dev, 0); |
| 808 | 779 | ||
| @@ -813,9 +784,8 @@ static int __devexit sh_rtc_remove(struct platform_device *pdev) | |||
| 813 | free_irq(rtc->alarm_irq, rtc); | 784 | free_irq(rtc->alarm_irq, rtc); |
| 814 | } | 785 | } |
| 815 | 786 | ||
| 816 | release_resource(rtc->res); | ||
| 817 | |||
| 818 | iounmap(rtc->regbase); | 787 | iounmap(rtc->regbase); |
| 788 | release_resource(rtc->res); | ||
| 819 | 789 | ||
| 820 | clk_disable(rtc->clk); | 790 | clk_disable(rtc->clk); |
| 821 | clk_put(rtc->clk); | 791 | clk_put(rtc->clk); |
| @@ -867,13 +837,12 @@ static struct platform_driver sh_rtc_platform_driver = { | |||
| 867 | .owner = THIS_MODULE, | 837 | .owner = THIS_MODULE, |
| 868 | .pm = &sh_rtc_dev_pm_ops, | 838 | .pm = &sh_rtc_dev_pm_ops, |
| 869 | }, | 839 | }, |
| 870 | .probe = sh_rtc_probe, | 840 | .remove = __exit_p(sh_rtc_remove), |
| 871 | .remove = __devexit_p(sh_rtc_remove), | ||
| 872 | }; | 841 | }; |
| 873 | 842 | ||
| 874 | static int __init sh_rtc_init(void) | 843 | static int __init sh_rtc_init(void) |
| 875 | { | 844 | { |
| 876 | return platform_driver_register(&sh_rtc_platform_driver); | 845 | return platform_driver_probe(&sh_rtc_platform_driver, sh_rtc_probe); |
| 877 | } | 846 | } |
| 878 | 847 | ||
| 879 | static void __exit sh_rtc_exit(void) | 848 | static void __exit sh_rtc_exit(void) |
