aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-dev.c23
-rw-r--r--drivers/rtc/rtc-m48t86.c72
-rw-r--r--drivers/rtc/rtc-sa1100.c8
-rw-r--r--drivers/rtc/rtc-test.c2
-rw-r--r--drivers/rtc/rtc-vr41xx.c2
5 files changed, 56 insertions, 51 deletions
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index b1e3e6179e56..2011567005f9 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -58,7 +58,7 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
58 unsigned long data; 58 unsigned long data;
59 ssize_t ret; 59 ssize_t ret;
60 60
61 if (count < sizeof(unsigned long)) 61 if (count != sizeof(unsigned int) && count < sizeof(unsigned long))
62 return -EINVAL; 62 return -EINVAL;
63 63
64 add_wait_queue(&rtc->irq_queue, &wait); 64 add_wait_queue(&rtc->irq_queue, &wait);
@@ -90,11 +90,16 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
90 if (ret == 0) { 90 if (ret == 0) {
91 /* Check for any data updates */ 91 /* Check for any data updates */
92 if (rtc->ops->read_callback) 92 if (rtc->ops->read_callback)
93 data = rtc->ops->read_callback(rtc->class_dev.dev, data); 93 data = rtc->ops->read_callback(rtc->class_dev.dev,
94 94 data);
95 ret = put_user(data, (unsigned long __user *)buf); 95
96 if (ret == 0) 96 if (sizeof(int) != sizeof(long) &&
97 ret = sizeof(unsigned long); 97 count == sizeof(unsigned int))
98 ret = put_user(data, (unsigned int __user *)buf) ?:
99 sizeof(unsigned int);
100 else
101 ret = put_user(data, (unsigned long __user *)buf) ?:
102 sizeof(unsigned long);
98 } 103 }
99 return ret; 104 return ret;
100} 105}
@@ -136,13 +141,13 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
136 /* try the driver's ioctl interface */ 141 /* try the driver's ioctl interface */
137 if (ops->ioctl) { 142 if (ops->ioctl) {
138 err = ops->ioctl(class_dev->dev, cmd, arg); 143 err = ops->ioctl(class_dev->dev, cmd, arg);
139 if (err != -EINVAL) 144 if (err != -ENOIOCTLCMD)
140 return err; 145 return err;
141 } 146 }
142 147
143 /* if the driver does not provide the ioctl interface 148 /* if the driver does not provide the ioctl interface
144 * or if that particular ioctl was not implemented 149 * or if that particular ioctl was not implemented
145 * (-EINVAL), we will try to emulate here. 150 * (-ENOIOCTLCMD), we will try to emulate here.
146 */ 151 */
147 152
148 switch (cmd) { 153 switch (cmd) {
@@ -228,7 +233,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
228 break; 233 break;
229 234
230 default: 235 default:
231 err = -EINVAL; 236 err = -ENOTTY;
232 break; 237 break;
233 } 238 }
234 239
diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c
index f6e7ee04f3dc..8c0d1a6739ad 100644
--- a/drivers/rtc/rtc-m48t86.c
+++ b/drivers/rtc/rtc-m48t86.c
@@ -48,33 +48,33 @@ static int m48t86_rtc_read_time(struct device *dev, struct rtc_time *tm)
48 struct platform_device *pdev = to_platform_device(dev); 48 struct platform_device *pdev = to_platform_device(dev);
49 struct m48t86_ops *ops = pdev->dev.platform_data; 49 struct m48t86_ops *ops = pdev->dev.platform_data;
50 50
51 reg = ops->readb(M48T86_REG_B); 51 reg = ops->readbyte(M48T86_REG_B);
52 52
53 if (reg & M48T86_REG_B_DM) { 53 if (reg & M48T86_REG_B_DM) {
54 /* data (binary) mode */ 54 /* data (binary) mode */
55 tm->tm_sec = ops->readb(M48T86_REG_SEC); 55 tm->tm_sec = ops->readbyte(M48T86_REG_SEC);
56 tm->tm_min = ops->readb(M48T86_REG_MIN); 56 tm->tm_min = ops->readbyte(M48T86_REG_MIN);
57 tm->tm_hour = ops->readb(M48T86_REG_HOUR) & 0x3F; 57 tm->tm_hour = ops->readbyte(M48T86_REG_HOUR) & 0x3F;
58 tm->tm_mday = ops->readb(M48T86_REG_DOM); 58 tm->tm_mday = ops->readbyte(M48T86_REG_DOM);
59 /* tm_mon is 0-11 */ 59 /* tm_mon is 0-11 */
60 tm->tm_mon = ops->readb(M48T86_REG_MONTH) - 1; 60 tm->tm_mon = ops->readbyte(M48T86_REG_MONTH) - 1;
61 tm->tm_year = ops->readb(M48T86_REG_YEAR) + 100; 61 tm->tm_year = ops->readbyte(M48T86_REG_YEAR) + 100;
62 tm->tm_wday = ops->readb(M48T86_REG_DOW); 62 tm->tm_wday = ops->readbyte(M48T86_REG_DOW);
63 } else { 63 } else {
64 /* bcd mode */ 64 /* bcd mode */
65 tm->tm_sec = BCD2BIN(ops->readb(M48T86_REG_SEC)); 65 tm->tm_sec = BCD2BIN(ops->readbyte(M48T86_REG_SEC));
66 tm->tm_min = BCD2BIN(ops->readb(M48T86_REG_MIN)); 66 tm->tm_min = BCD2BIN(ops->readbyte(M48T86_REG_MIN));
67 tm->tm_hour = BCD2BIN(ops->readb(M48T86_REG_HOUR) & 0x3F); 67 tm->tm_hour = BCD2BIN(ops->readbyte(M48T86_REG_HOUR) & 0x3F);
68 tm->tm_mday = BCD2BIN(ops->readb(M48T86_REG_DOM)); 68 tm->tm_mday = BCD2BIN(ops->readbyte(M48T86_REG_DOM));
69 /* tm_mon is 0-11 */ 69 /* tm_mon is 0-11 */
70 tm->tm_mon = BCD2BIN(ops->readb(M48T86_REG_MONTH)) - 1; 70 tm->tm_mon = BCD2BIN(ops->readbyte(M48T86_REG_MONTH)) - 1;
71 tm->tm_year = BCD2BIN(ops->readb(M48T86_REG_YEAR)) + 100; 71 tm->tm_year = BCD2BIN(ops->readbyte(M48T86_REG_YEAR)) + 100;
72 tm->tm_wday = BCD2BIN(ops->readb(M48T86_REG_DOW)); 72 tm->tm_wday = BCD2BIN(ops->readbyte(M48T86_REG_DOW));
73 } 73 }
74 74
75 /* correct the hour if the clock is in 12h mode */ 75 /* correct the hour if the clock is in 12h mode */
76 if (!(reg & M48T86_REG_B_H24)) 76 if (!(reg & M48T86_REG_B_H24))
77 if (ops->readb(M48T86_REG_HOUR) & 0x80) 77 if (ops->readbyte(M48T86_REG_HOUR) & 0x80)
78 tm->tm_hour += 12; 78 tm->tm_hour += 12;
79 79
80 return 0; 80 return 0;
@@ -86,35 +86,35 @@ static int m48t86_rtc_set_time(struct device *dev, struct rtc_time *tm)
86 struct platform_device *pdev = to_platform_device(dev); 86 struct platform_device *pdev = to_platform_device(dev);
87 struct m48t86_ops *ops = pdev->dev.platform_data; 87 struct m48t86_ops *ops = pdev->dev.platform_data;
88 88
89 reg = ops->readb(M48T86_REG_B); 89 reg = ops->readbyte(M48T86_REG_B);
90 90
91 /* update flag and 24h mode */ 91 /* update flag and 24h mode */
92 reg |= M48T86_REG_B_SET | M48T86_REG_B_H24; 92 reg |= M48T86_REG_B_SET | M48T86_REG_B_H24;
93 ops->writeb(reg, M48T86_REG_B); 93 ops->writebyte(reg, M48T86_REG_B);
94 94
95 if (reg & M48T86_REG_B_DM) { 95 if (reg & M48T86_REG_B_DM) {
96 /* data (binary) mode */ 96 /* data (binary) mode */
97 ops->writeb(tm->tm_sec, M48T86_REG_SEC); 97 ops->writebyte(tm->tm_sec, M48T86_REG_SEC);
98 ops->writeb(tm->tm_min, M48T86_REG_MIN); 98 ops->writebyte(tm->tm_min, M48T86_REG_MIN);
99 ops->writeb(tm->tm_hour, M48T86_REG_HOUR); 99 ops->writebyte(tm->tm_hour, M48T86_REG_HOUR);
100 ops->writeb(tm->tm_mday, M48T86_REG_DOM); 100 ops->writebyte(tm->tm_mday, M48T86_REG_DOM);
101 ops->writeb(tm->tm_mon + 1, M48T86_REG_MONTH); 101 ops->writebyte(tm->tm_mon + 1, M48T86_REG_MONTH);
102 ops->writeb(tm->tm_year % 100, M48T86_REG_YEAR); 102 ops->writebyte(tm->tm_year % 100, M48T86_REG_YEAR);
103 ops->writeb(tm->tm_wday, M48T86_REG_DOW); 103 ops->writebyte(tm->tm_wday, M48T86_REG_DOW);
104 } else { 104 } else {
105 /* bcd mode */ 105 /* bcd mode */
106 ops->writeb(BIN2BCD(tm->tm_sec), M48T86_REG_SEC); 106 ops->writebyte(BIN2BCD(tm->tm_sec), M48T86_REG_SEC);
107 ops->writeb(BIN2BCD(tm->tm_min), M48T86_REG_MIN); 107 ops->writebyte(BIN2BCD(tm->tm_min), M48T86_REG_MIN);
108 ops->writeb(BIN2BCD(tm->tm_hour), M48T86_REG_HOUR); 108 ops->writebyte(BIN2BCD(tm->tm_hour), M48T86_REG_HOUR);
109 ops->writeb(BIN2BCD(tm->tm_mday), M48T86_REG_DOM); 109 ops->writebyte(BIN2BCD(tm->tm_mday), M48T86_REG_DOM);
110 ops->writeb(BIN2BCD(tm->tm_mon + 1), M48T86_REG_MONTH); 110 ops->writebyte(BIN2BCD(tm->tm_mon + 1), M48T86_REG_MONTH);
111 ops->writeb(BIN2BCD(tm->tm_year % 100), M48T86_REG_YEAR); 111 ops->writebyte(BIN2BCD(tm->tm_year % 100), M48T86_REG_YEAR);
112 ops->writeb(BIN2BCD(tm->tm_wday), M48T86_REG_DOW); 112 ops->writebyte(BIN2BCD(tm->tm_wday), M48T86_REG_DOW);
113 } 113 }
114 114
115 /* update ended */ 115 /* update ended */
116 reg &= ~M48T86_REG_B_SET; 116 reg &= ~M48T86_REG_B_SET;
117 ops->writeb(reg, M48T86_REG_B); 117 ops->writebyte(reg, M48T86_REG_B);
118 118
119 return 0; 119 return 0;
120} 120}
@@ -125,12 +125,12 @@ static int m48t86_rtc_proc(struct device *dev, struct seq_file *seq)
125 struct platform_device *pdev = to_platform_device(dev); 125 struct platform_device *pdev = to_platform_device(dev);
126 struct m48t86_ops *ops = pdev->dev.platform_data; 126 struct m48t86_ops *ops = pdev->dev.platform_data;
127 127
128 reg = ops->readb(M48T86_REG_B); 128 reg = ops->readbyte(M48T86_REG_B);
129 129
130 seq_printf(seq, "mode\t\t: %s\n", 130 seq_printf(seq, "mode\t\t: %s\n",
131 (reg & M48T86_REG_B_DM) ? "binary" : "bcd"); 131 (reg & M48T86_REG_B_DM) ? "binary" : "bcd");
132 132
133 reg = ops->readb(M48T86_REG_D); 133 reg = ops->readbyte(M48T86_REG_D);
134 134
135 seq_printf(seq, "battery\t\t: %s\n", 135 seq_printf(seq, "battery\t\t: %s\n",
136 (reg & M48T86_REG_D_VRT) ? "ok" : "exhausted"); 136 (reg & M48T86_REG_D_VRT) ? "ok" : "exhausted");
@@ -157,7 +157,7 @@ static int __devinit m48t86_rtc_probe(struct platform_device *dev)
157 platform_set_drvdata(dev, rtc); 157 platform_set_drvdata(dev, rtc);
158 158
159 /* read battery status */ 159 /* read battery status */
160 reg = ops->readb(M48T86_REG_D); 160 reg = ops->readbyte(M48T86_REG_D);
161 dev_info(&dev->dev, "battery %s\n", 161 dev_info(&dev->dev, "battery %s\n",
162 (reg & M48T86_REG_D_VRT) ? "ok" : "exhausted"); 162 (reg & M48T86_REG_D_VRT) ? "ok" : "exhausted");
163 163
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index a23ec54989f6..a997529f8926 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -178,9 +178,9 @@ static int sa1100_rtc_open(struct device *dev)
178 return 0; 178 return 0;
179 179
180 fail_pi: 180 fail_pi:
181 free_irq(IRQ_RTCAlrm, NULL); 181 free_irq(IRQ_RTCAlrm, dev);
182 fail_ai: 182 fail_ai:
183 free_irq(IRQ_RTC1Hz, NULL); 183 free_irq(IRQ_RTC1Hz, dev);
184 fail_ui: 184 fail_ui:
185 return ret; 185 return ret;
186} 186}
@@ -247,7 +247,7 @@ static int sa1100_rtc_ioctl(struct device *dev, unsigned int cmd,
247 rtc_freq = arg; 247 rtc_freq = arg;
248 return 0; 248 return 0;
249 } 249 }
250 return -EINVAL; 250 return -ENOIOCTLCMD;
251} 251}
252 252
253static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) 253static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
@@ -295,7 +295,7 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
295 295
296static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) 296static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)
297{ 297{
298 seq_printf(seq, "trim/divider\t: 0x%08x\n", RTTR); 298 seq_printf(seq, "trim/divider\t: 0x%08lx\n", RTTR);
299 seq_printf(seq, "alarm_IRQ\t: %s\n", 299 seq_printf(seq, "alarm_IRQ\t: %s\n",
300 (RTSR & RTSR_ALE) ? "yes" : "no" ); 300 (RTSR & RTSR_ALE) ? "yes" : "no" );
301 seq_printf(seq, "update_IRQ\t: %s\n", 301 seq_printf(seq, "update_IRQ\t: %s\n",
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index e1f7e8e86daf..e1fa5fe7901f 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -71,7 +71,7 @@ static int test_rtc_ioctl(struct device *dev, unsigned int cmd,
71 return 0; 71 return 0;
72 72
73 default: 73 default:
74 return -EINVAL; 74 return -ENOIOCTLCMD;
75 } 75 }
76} 76}
77 77
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index 4d49fd501198..277596c302e3 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -270,7 +270,7 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long
270 epoch = arg; 270 epoch = arg;
271 break; 271 break;
272 default: 272 default:
273 return -EINVAL; 273 return -ENOIOCTLCMD;
274 } 274 }
275 275
276 return 0; 276 return 0;