Commit a748384bba1754409383ba9f0738bffdfa3fd431
Committed by
Linus Torvalds
1 parent
fb144adc51
Exists in
master
and in
7 other branches
rtc: tw4030 add alarm/update interfaces
- implement alarm_irq_enable - return correct error code when registering fails [dbrownell@users.sourceforge.net: build fixes, force 1/sec irqs] Signed-off-by: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Cc: Tony Lindgren <tony@atomide.com> Cc: Samuel Ortiz <sameo@openedhand.com> Cc: rtc-linux@googlegroups.com Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 10 additions and 34 deletions Side-by-side Diff
drivers/rtc/rtc-twl4030.c
... | ... | @@ -120,7 +120,7 @@ |
120 | 120 | static unsigned char rtc_irq_bits; |
121 | 121 | |
122 | 122 | /* |
123 | - * Enable timer and/or alarm interrupts. | |
123 | + * Enable 1/second update and/or alarm interrupts. | |
124 | 124 | */ |
125 | 125 | static int set_rtc_irq_bit(unsigned char bit) |
126 | 126 | { |
... | ... | @@ -128,6 +128,7 @@ |
128 | 128 | int ret; |
129 | 129 | |
130 | 130 | val = rtc_irq_bits | bit; |
131 | + val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M; | |
131 | 132 | ret = twl4030_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); |
132 | 133 | if (ret == 0) |
133 | 134 | rtc_irq_bits = val; |
... | ... | @@ -136,7 +137,7 @@ |
136 | 137 | } |
137 | 138 | |
138 | 139 | /* |
139 | - * Disable timer and/or alarm interrupts. | |
140 | + * Disable update and/or alarm interrupts. | |
140 | 141 | */ |
141 | 142 | static int mask_rtc_irq_bit(unsigned char bit) |
142 | 143 | { |
... | ... | @@ -151,7 +152,7 @@ |
151 | 152 | return ret; |
152 | 153 | } |
153 | 154 | |
154 | -static inline int twl4030_rtc_alarm_irq_set_state(int enabled) | |
155 | +static int twl4030_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) | |
155 | 156 | { |
156 | 157 | int ret; |
157 | 158 | |
... | ... | @@ -163,7 +164,7 @@ |
163 | 164 | return ret; |
164 | 165 | } |
165 | 166 | |
166 | -static inline int twl4030_rtc_irq_set_state(int enabled) | |
167 | +static int twl4030_rtc_update_irq_enable(struct device *dev, unsigned enabled) | |
167 | 168 | { |
168 | 169 | int ret; |
169 | 170 | |
... | ... | @@ -292,7 +293,7 @@ |
292 | 293 | unsigned char alarm_data[ALL_TIME_REGS + 1]; |
293 | 294 | int ret; |
294 | 295 | |
295 | - ret = twl4030_rtc_alarm_irq_set_state(0); | |
296 | + ret = twl4030_rtc_alarm_irq_enable(dev, 0); | |
296 | 297 | if (ret) |
297 | 298 | goto out; |
298 | 299 | |
299 | 300 | |
... | ... | @@ -312,35 +313,11 @@ |
312 | 313 | } |
313 | 314 | |
314 | 315 | if (alm->enabled) |
315 | - ret = twl4030_rtc_alarm_irq_set_state(1); | |
316 | + ret = twl4030_rtc_alarm_irq_enable(dev, 1); | |
316 | 317 | out: |
317 | 318 | return ret; |
318 | 319 | } |
319 | 320 | |
320 | -#ifdef CONFIG_RTC_INTF_DEV | |
321 | - | |
322 | -static int twl4030_rtc_ioctl(struct device *dev, unsigned int cmd, | |
323 | - unsigned long arg) | |
324 | -{ | |
325 | - switch (cmd) { | |
326 | - case RTC_AIE_OFF: | |
327 | - return twl4030_rtc_alarm_irq_set_state(0); | |
328 | - case RTC_AIE_ON: | |
329 | - return twl4030_rtc_alarm_irq_set_state(1); | |
330 | - case RTC_UIE_OFF: | |
331 | - return twl4030_rtc_irq_set_state(0); | |
332 | - case RTC_UIE_ON: | |
333 | - return twl4030_rtc_irq_set_state(1); | |
334 | - | |
335 | - default: | |
336 | - return -ENOIOCTLCMD; | |
337 | - } | |
338 | -} | |
339 | - | |
340 | -#else | |
341 | -#define twl4030_rtc_ioctl NULL | |
342 | -#endif | |
343 | - | |
344 | 321 | static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc) |
345 | 322 | { |
346 | 323 | unsigned long events = 0; |
347 | 324 | |
... | ... | @@ -400,11 +377,12 @@ |
400 | 377 | } |
401 | 378 | |
402 | 379 | static struct rtc_class_ops twl4030_rtc_ops = { |
403 | - .ioctl = twl4030_rtc_ioctl, | |
404 | 380 | .read_time = twl4030_rtc_read_time, |
405 | 381 | .set_time = twl4030_rtc_set_time, |
406 | 382 | .read_alarm = twl4030_rtc_read_alarm, |
407 | 383 | .set_alarm = twl4030_rtc_set_alarm, |
384 | + .alarm_irq_enable = twl4030_rtc_alarm_irq_enable, | |
385 | + .update_irq_enable = twl4030_rtc_update_irq_enable, | |
408 | 386 | }; |
409 | 387 | |
410 | 388 | /*----------------------------------------------------------------------*/ |
... | ... | @@ -422,7 +400,7 @@ |
422 | 400 | rtc = rtc_device_register(pdev->name, |
423 | 401 | &pdev->dev, &twl4030_rtc_ops, THIS_MODULE); |
424 | 402 | if (IS_ERR(rtc)) { |
425 | - ret = -EINVAL; | |
403 | + ret = PTR_ERR(rtc); | |
426 | 404 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", |
427 | 405 | PTR_ERR(rtc)); |
428 | 406 | goto out0; |
... | ... | @@ -432,7 +410,6 @@ |
432 | 410 | platform_set_drvdata(pdev, rtc); |
433 | 411 | |
434 | 412 | ret = twl4030_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); |
435 | - | |
436 | 413 | if (ret < 0) |
437 | 414 | goto out1; |
438 | 415 | |
... | ... | @@ -474,7 +451,6 @@ |
474 | 451 | goto out2; |
475 | 452 | |
476 | 453 | return ret; |
477 | - | |
478 | 454 | |
479 | 455 | out2: |
480 | 456 | free_irq(irq, rtc); |