aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2009-06-18 19:49:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-19 19:46:05 -0400
commite6229bec25be4ba00f31dd26e25721cc96c22262 (patch)
treea27e4c51dd8b9aaeb589a147a22bbd06bde77cf0 /drivers
parent575c5807f6842422e9fe2432fd48dfcc1d7aef41 (diff)
rtc: make rtc_update_irq callable with irqs enabled
The rtc_update_irq() might be called with irqs enabled, if a interrupt handler was registered without IRQF_DISABLED. Use spin_lock_irqsave/spin_unlock_irqrestore instead of spin_lock/spin_unlock. Also update kerneldoc and drivers which do extra work to follow the current interface spec, as suggestted by David Brownell. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/interface.c12
-rw-r--r--drivers/rtc/rtc-dev.c6
-rw-r--r--drivers/rtc/rtc-ds1305.c3
-rw-r--r--drivers/rtc/rtc-ds1307.c5
-rw-r--r--drivers/rtc/rtc-ds1374.c5
-rw-r--r--drivers/rtc/rtc-test.c2
6 files changed, 9 insertions, 24 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 4348c4b0d453..4cdb31a362ca 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -371,19 +371,21 @@ EXPORT_SYMBOL_GPL(rtc_update_irq_enable);
371 * @rtc: the rtc device 371 * @rtc: the rtc device
372 * @num: how many irqs are being reported (usually one) 372 * @num: how many irqs are being reported (usually one)
373 * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF 373 * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF
374 * Context: in_interrupt(), irqs blocked 374 * Context: any
375 */ 375 */
376void rtc_update_irq(struct rtc_device *rtc, 376void rtc_update_irq(struct rtc_device *rtc,
377 unsigned long num, unsigned long events) 377 unsigned long num, unsigned long events)
378{ 378{
379 spin_lock(&rtc->irq_lock); 379 unsigned long flags;
380
381 spin_lock_irqsave(&rtc->irq_lock, flags);
380 rtc->irq_data = (rtc->irq_data + (num << 8)) | events; 382 rtc->irq_data = (rtc->irq_data + (num << 8)) | events;
381 spin_unlock(&rtc->irq_lock); 383 spin_unlock_irqrestore(&rtc->irq_lock, flags);
382 384
383 spin_lock(&rtc->irq_task_lock); 385 spin_lock_irqsave(&rtc->irq_task_lock, flags);
384 if (rtc->irq_task) 386 if (rtc->irq_task)
385 rtc->irq_task->func(rtc->irq_task->private_data); 387 rtc->irq_task->func(rtc->irq_task->private_data);
386 spin_unlock(&rtc->irq_task_lock); 388 spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
387 389
388 wake_up_interruptible(&rtc->irq_queue); 390 wake_up_interruptible(&rtc->irq_queue);
389 kill_fasync(&rtc->async_queue, SIGIO, POLL_IN); 391 kill_fasync(&rtc->async_queue, SIGIO, POLL_IN);
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 45152f4952d6..8a11de9552cd 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -60,8 +60,7 @@ static void rtc_uie_task(struct work_struct *work)
60 60
61 err = rtc_read_time(rtc, &tm); 61 err = rtc_read_time(rtc, &tm);
62 62
63 local_irq_disable(); 63 spin_lock_irq(&rtc->irq_lock);
64 spin_lock(&rtc->irq_lock);
65 if (rtc->stop_uie_polling || err) { 64 if (rtc->stop_uie_polling || err) {
66 rtc->uie_task_active = 0; 65 rtc->uie_task_active = 0;
67 } else if (rtc->oldsecs != tm.tm_sec) { 66 } else if (rtc->oldsecs != tm.tm_sec) {
@@ -74,10 +73,9 @@ static void rtc_uie_task(struct work_struct *work)
74 } else if (schedule_work(&rtc->uie_task) == 0) { 73 } else if (schedule_work(&rtc->uie_task) == 0) {
75 rtc->uie_task_active = 0; 74 rtc->uie_task_active = 0;
76 } 75 }
77 spin_unlock(&rtc->irq_lock); 76 spin_unlock_irq(&rtc->irq_lock);
78 if (num) 77 if (num)
79 rtc_update_irq(rtc, num, RTC_UF | RTC_IRQF); 78 rtc_update_irq(rtc, num, RTC_UF | RTC_IRQF);
80 local_irq_enable();
81} 79}
82static void rtc_uie_timer(unsigned long data) 80static void rtc_uie_timer(unsigned long data)
83{ 81{
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c
index fc372df6534b..8f410e59d9f5 100644
--- a/drivers/rtc/rtc-ds1305.c
+++ b/drivers/rtc/rtc-ds1305.c
@@ -499,10 +499,7 @@ static void ds1305_work(struct work_struct *work)
499 if (!test_bit(FLAG_EXITING, &ds1305->flags)) 499 if (!test_bit(FLAG_EXITING, &ds1305->flags))
500 enable_irq(spi->irq); 500 enable_irq(spi->irq);
501 501
502 /* rtc_update_irq() requires an IRQ-disabled context */
503 local_irq_disable();
504 rtc_update_irq(ds1305->rtc, 1, RTC_AF | RTC_IRQF); 502 rtc_update_irq(ds1305->rtc, 1, RTC_AF | RTC_IRQF);
505 local_irq_enable();
506} 503}
507 504
508/* 505/*
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 8a6f9a9f9cb8..47a93c022d91 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -267,12 +267,7 @@ static void ds1307_work(struct work_struct *work)
267 control &= ~DS1337_BIT_A1IE; 267 control &= ~DS1337_BIT_A1IE;
268 i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL, control); 268 i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL, control);
269 269
270 /* rtc_update_irq() assumes that it is called
271 * from IRQ-disabled context.
272 */
273 local_irq_disable();
274 rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF); 270 rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF);
275 local_irq_enable();
276 } 271 }
277 272
278out: 273out:
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 4d32e328f6cd..32b27739ec2a 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -296,12 +296,7 @@ static void ds1374_work(struct work_struct *work)
296 control &= ~(DS1374_REG_CR_WACE | DS1374_REG_CR_AIE); 296 control &= ~(DS1374_REG_CR_WACE | DS1374_REG_CR_AIE);
297 i2c_smbus_write_byte_data(client, DS1374_REG_CR, control); 297 i2c_smbus_write_byte_data(client, DS1374_REG_CR, control);
298 298
299 /* rtc_update_irq() assumes that it is called
300 * from IRQ-disabled context.
301 */
302 local_irq_disable();
303 rtc_update_irq(ds1374->rtc, 1, RTC_AF | RTC_IRQF); 299 rtc_update_irq(ds1374->rtc, 1, RTC_AF | RTC_IRQF);
304 local_irq_enable();
305 } 300 }
306 301
307out: 302out:
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index e478280ff628..51725f7755b0 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -93,7 +93,6 @@ static ssize_t test_irq_store(struct device *dev,
93 struct rtc_device *rtc = platform_get_drvdata(plat_dev); 93 struct rtc_device *rtc = platform_get_drvdata(plat_dev);
94 94
95 retval = count; 95 retval = count;
96 local_irq_disable();
97 if (strncmp(buf, "tick", 4) == 0) 96 if (strncmp(buf, "tick", 4) == 0)
98 rtc_update_irq(rtc, 1, RTC_PF | RTC_IRQF); 97 rtc_update_irq(rtc, 1, RTC_PF | RTC_IRQF);
99 else if (strncmp(buf, "alarm", 5) == 0) 98 else if (strncmp(buf, "alarm", 5) == 0)
@@ -102,7 +101,6 @@ static ssize_t test_irq_store(struct device *dev,
102 rtc_update_irq(rtc, 1, RTC_UF | RTC_IRQF); 101 rtc_update_irq(rtc, 1, RTC_UF | RTC_IRQF);
103 else 102 else
104 retval = -EINVAL; 103 retval = -EINVAL;
105 local_irq_enable();
106 104
107 return retval; 105 return retval;
108} 106}