diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-05-22 02:36:56 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-05-22 02:36:56 -0400 |
commit | cf9b59e9d3e008591d1f54830f570982bb307a0d (patch) | |
tree | 113478ce8fd8c832ba726ffdf59b82cb46356476 /arch/cris | |
parent | 44504b2bebf8b5823c59484e73096a7d6574471d (diff) | |
parent | f4b87dee923342505e1ddba8d34ce9de33e75050 (diff) |
Merge remote branch 'origin' into secretlab/next-devicetree
Merging in current state of Linus' tree to deal with merge conflicts and
build failures in vio.c after merge.
Conflicts:
drivers/i2c/busses/i2c-cpm.c
drivers/i2c/busses/i2c-mpc.c
drivers/net/gianfar.c
Also fixed up one line in arch/powerpc/kernel/vio.c to use the
correct node pointer.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/cris')
-rw-r--r-- | arch/cris/Kconfig | 3 | ||||
-rw-r--r-- | arch/cris/arch-v10/drivers/eeprom.c | 48 | ||||
-rw-r--r-- | arch/cris/arch-v10/kernel/time.c | 37 | ||||
-rw-r--r-- | arch/cris/arch-v32/kernel/time.c | 40 | ||||
-rw-r--r-- | arch/cris/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | arch/cris/include/asm/thread_info.h | 2 | ||||
-rw-r--r-- | arch/cris/kernel/time.c | 20 |
7 files changed, 35 insertions, 117 deletions
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index 059eac6abda1..e25bf4440b51 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig | |||
@@ -23,6 +23,9 @@ config RWSEM_XCHGADD_ALGORITHM | |||
23 | config GENERIC_TIME | 23 | config GENERIC_TIME |
24 | def_bool y | 24 | def_bool y |
25 | 25 | ||
26 | config GENERIC_CMOS_UPDATE | ||
27 | def_bool y | ||
28 | |||
26 | config ARCH_USES_GETTIMEOFFSET | 29 | config ARCH_USES_GETTIMEOFFSET |
27 | def_bool y | 30 | def_bool y |
28 | 31 | ||
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c index 1f2ae909d3e6..c3405507a3d1 100644 --- a/arch/cris/arch-v10/drivers/eeprom.c +++ b/arch/cris/arch-v10/drivers/eeprom.c | |||
@@ -73,8 +73,7 @@ struct eeprom_type | |||
73 | int adapt_state; /* 1 = To high , 0 = Even, -1 = To low */ | 73 | int adapt_state; /* 1 = To high , 0 = Even, -1 = To low */ |
74 | 74 | ||
75 | /* this one is to keep the read/write operations atomic */ | 75 | /* this one is to keep the read/write operations atomic */ |
76 | wait_queue_head_t wait_q; | 76 | struct mutex lock; |
77 | volatile int busy; | ||
78 | int retry_cnt_addr; /* Used to keep track of number of retries for | 77 | int retry_cnt_addr; /* Used to keep track of number of retries for |
79 | adaptive timing adjustments */ | 78 | adaptive timing adjustments */ |
80 | int retry_cnt_read; | 79 | int retry_cnt_read; |
@@ -115,8 +114,7 @@ const struct file_operations eeprom_fops = | |||
115 | 114 | ||
116 | int __init eeprom_init(void) | 115 | int __init eeprom_init(void) |
117 | { | 116 | { |
118 | init_waitqueue_head(&eeprom.wait_q); | 117 | mutex_init(&eeprom.lock); |
119 | eeprom.busy = 0; | ||
120 | 118 | ||
121 | #ifdef CONFIG_ETRAX_I2C_EEPROM_PROBE | 119 | #ifdef CONFIG_ETRAX_I2C_EEPROM_PROBE |
122 | #define EETEXT "Found" | 120 | #define EETEXT "Found" |
@@ -439,10 +437,7 @@ static loff_t eeprom_lseek(struct file * file, loff_t offset, int orig) | |||
439 | 437 | ||
440 | static int eeprom_read_buf(loff_t addr, char * buf, int count) | 438 | static int eeprom_read_buf(loff_t addr, char * buf, int count) |
441 | { | 439 | { |
442 | struct file f; | 440 | return eeprom_read(NULL, buf, count, &addr); |
443 | |||
444 | f.f_pos = addr; | ||
445 | return eeprom_read(&f, buf, count, &addr); | ||
446 | } | 441 | } |
447 | 442 | ||
448 | 443 | ||
@@ -452,7 +447,7 @@ static int eeprom_read_buf(loff_t addr, char * buf, int count) | |||
452 | static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t *off) | 447 | static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t *off) |
453 | { | 448 | { |
454 | int read=0; | 449 | int read=0; |
455 | unsigned long p = file->f_pos; | 450 | unsigned long p = *off; |
456 | 451 | ||
457 | unsigned char page; | 452 | unsigned char page; |
458 | 453 | ||
@@ -461,12 +456,9 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t | |||
461 | return -EFAULT; | 456 | return -EFAULT; |
462 | } | 457 | } |
463 | 458 | ||
464 | wait_event_interruptible(eeprom.wait_q, !eeprom.busy); | 459 | if (mutex_lock_interruptible(&eeprom.lock)) |
465 | if (signal_pending(current)) | ||
466 | return -EINTR; | 460 | return -EINTR; |
467 | 461 | ||
468 | eeprom.busy++; | ||
469 | |||
470 | page = (unsigned char) (p >> 8); | 462 | page = (unsigned char) (p >> 8); |
471 | 463 | ||
472 | if(!eeprom_address(p)) | 464 | if(!eeprom_address(p)) |
@@ -476,8 +468,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t | |||
476 | i2c_stop(); | 468 | i2c_stop(); |
477 | 469 | ||
478 | /* don't forget to wake them up */ | 470 | /* don't forget to wake them up */ |
479 | eeprom.busy--; | 471 | mutex_unlock(&eeprom.lock); |
480 | wake_up_interruptible(&eeprom.wait_q); | ||
481 | return -EFAULT; | 472 | return -EFAULT; |
482 | } | 473 | } |
483 | 474 | ||
@@ -501,11 +492,10 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t | |||
501 | 492 | ||
502 | if(read > 0) | 493 | if(read > 0) |
503 | { | 494 | { |
504 | file->f_pos += read; | 495 | *off += read; |
505 | } | 496 | } |
506 | 497 | ||
507 | eeprom.busy--; | 498 | mutex_unlock(&eeprom.lock); |
508 | wake_up_interruptible(&eeprom.wait_q); | ||
509 | return read; | 499 | return read; |
510 | } | 500 | } |
511 | 501 | ||
@@ -513,11 +503,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t | |||
513 | 503 | ||
514 | static int eeprom_write_buf(loff_t addr, const char * buf, int count) | 504 | static int eeprom_write_buf(loff_t addr, const char * buf, int count) |
515 | { | 505 | { |
516 | struct file f; | 506 | return eeprom_write(NULL, buf, count, &addr); |
517 | |||
518 | f.f_pos = addr; | ||
519 | |||
520 | return eeprom_write(&f, buf, count, &addr); | ||
521 | } | 507 | } |
522 | 508 | ||
523 | 509 | ||
@@ -534,16 +520,14 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count, | |||
534 | return -EFAULT; | 520 | return -EFAULT; |
535 | } | 521 | } |
536 | 522 | ||
537 | wait_event_interruptible(eeprom.wait_q, !eeprom.busy); | ||
538 | /* bail out if we get interrupted */ | 523 | /* bail out if we get interrupted */ |
539 | if (signal_pending(current)) | 524 | if (mutex_lock_interruptible(&eeprom.lock)) |
540 | return -EINTR; | 525 | return -EINTR; |
541 | eeprom.busy++; | ||
542 | for(i = 0; (i < EEPROM_RETRIES) && (restart > 0); i++) | 526 | for(i = 0; (i < EEPROM_RETRIES) && (restart > 0); i++) |
543 | { | 527 | { |
544 | restart = 0; | 528 | restart = 0; |
545 | written = 0; | 529 | written = 0; |
546 | p = file->f_pos; | 530 | p = *off; |
547 | 531 | ||
548 | 532 | ||
549 | while( (written < count) && (p < eeprom.size)) | 533 | while( (written < count) && (p < eeprom.size)) |
@@ -556,8 +540,7 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count, | |||
556 | i2c_stop(); | 540 | i2c_stop(); |
557 | 541 | ||
558 | /* don't forget to wake them up */ | 542 | /* don't forget to wake them up */ |
559 | eeprom.busy--; | 543 | mutex_unlock(&eeprom.lock); |
560 | wake_up_interruptible(&eeprom.wait_q); | ||
561 | return -EFAULT; | 544 | return -EFAULT; |
562 | } | 545 | } |
563 | #ifdef EEPROM_ADAPTIVE_TIMING | 546 | #ifdef EEPROM_ADAPTIVE_TIMING |
@@ -669,12 +652,11 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count, | |||
669 | } /* while */ | 652 | } /* while */ |
670 | } /* for */ | 653 | } /* for */ |
671 | 654 | ||
672 | eeprom.busy--; | 655 | mutex_unlock(&eeprom.lock); |
673 | wake_up_interruptible(&eeprom.wait_q); | 656 | if (written == 0 && p >= eeprom.size){ |
674 | if (written == 0 && file->f_pos >= eeprom.size){ | ||
675 | return -ENOSPC; | 657 | return -ENOSPC; |
676 | } | 658 | } |
677 | file->f_pos += written; | 659 | *off = p; |
678 | return written; | 660 | return written; |
679 | } | 661 | } |
680 | 662 | ||
diff --git a/arch/cris/arch-v10/kernel/time.c b/arch/cris/arch-v10/kernel/time.c index 31ca1418d5a7..30adae594aef 100644 --- a/arch/cris/arch-v10/kernel/time.c +++ b/arch/cris/arch-v10/kernel/time.c | |||
@@ -26,7 +26,6 @@ | |||
26 | /* it will make jiffies at 96 hz instead of 100 hz though */ | 26 | /* it will make jiffies at 96 hz instead of 100 hz though */ |
27 | #undef USE_CASCADE_TIMERS | 27 | #undef USE_CASCADE_TIMERS |
28 | 28 | ||
29 | extern void update_xtime_from_cmos(void); | ||
30 | extern int set_rtc_mmss(unsigned long nowtime); | 29 | extern int set_rtc_mmss(unsigned long nowtime); |
31 | extern int have_rtc; | 30 | extern int have_rtc; |
32 | 31 | ||
@@ -188,8 +187,6 @@ stop_watchdog(void) | |||
188 | #endif | 187 | #endif |
189 | } | 188 | } |
190 | 189 | ||
191 | /* last time the cmos clock got updated */ | ||
192 | static long last_rtc_update = 0; | ||
193 | 190 | ||
194 | /* | 191 | /* |
195 | * timer_interrupt() needs to keep up the real-time clock, | 192 | * timer_interrupt() needs to keep up the real-time clock, |
@@ -232,24 +229,6 @@ timer_interrupt(int irq, void *dev_id) | |||
232 | do_timer(1); | 229 | do_timer(1); |
233 | 230 | ||
234 | cris_do_profile(regs); /* Save profiling information */ | 231 | cris_do_profile(regs); /* Save profiling information */ |
235 | |||
236 | /* | ||
237 | * If we have an externally synchronized Linux clock, then update | ||
238 | * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be | ||
239 | * called as close as possible to 500 ms before the new second starts. | ||
240 | * | ||
241 | * The division here is not time critical since it will run once in | ||
242 | * 11 minutes | ||
243 | */ | ||
244 | if (ntp_synced() && | ||
245 | xtime.tv_sec > last_rtc_update + 660 && | ||
246 | (xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 && | ||
247 | (xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) { | ||
248 | if (set_rtc_mmss(xtime.tv_sec) == 0) | ||
249 | last_rtc_update = xtime.tv_sec; | ||
250 | else | ||
251 | last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */ | ||
252 | } | ||
253 | return IRQ_HANDLED; | 232 | return IRQ_HANDLED; |
254 | } | 233 | } |
255 | 234 | ||
@@ -274,22 +253,10 @@ time_init(void) | |||
274 | */ | 253 | */ |
275 | loops_per_usec = 50; | 254 | loops_per_usec = 50; |
276 | 255 | ||
277 | if(RTC_INIT() < 0) { | 256 | if(RTC_INIT() < 0) |
278 | /* no RTC, start at 1980 */ | ||
279 | xtime.tv_sec = 0; | ||
280 | xtime.tv_nsec = 0; | ||
281 | have_rtc = 0; | 257 | have_rtc = 0; |
282 | } else { | 258 | else |
283 | /* get the current time */ | ||
284 | have_rtc = 1; | 259 | have_rtc = 1; |
285 | update_xtime_from_cmos(); | ||
286 | } | ||
287 | |||
288 | /* | ||
289 | * Initialize wall_to_monotonic such that adding it to xtime will yield zero, the | ||
290 | * tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC). | ||
291 | */ | ||
292 | set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec); | ||
293 | 260 | ||
294 | /* Setup the etrax timers | 261 | /* Setup the etrax timers |
295 | * Base frequency is 25000 hz, divider 250 -> 100 HZ | 262 | * Base frequency is 25000 hz, divider 250 -> 100 HZ |
diff --git a/arch/cris/arch-v32/kernel/time.c b/arch/cris/arch-v32/kernel/time.c index b1920d8de403..1ee0e1010228 100644 --- a/arch/cris/arch-v32/kernel/time.c +++ b/arch/cris/arch-v32/kernel/time.c | |||
@@ -44,7 +44,6 @@ unsigned long timer_regs[NR_CPUS] = | |||
44 | #endif | 44 | #endif |
45 | }; | 45 | }; |
46 | 46 | ||
47 | extern void update_xtime_from_cmos(void); | ||
48 | extern int set_rtc_mmss(unsigned long nowtime); | 47 | extern int set_rtc_mmss(unsigned long nowtime); |
49 | extern int have_rtc; | 48 | extern int have_rtc; |
50 | 49 | ||
@@ -198,9 +197,6 @@ handle_watchdog_bite(struct pt_regs* regs) | |||
198 | #endif | 197 | #endif |
199 | } | 198 | } |
200 | 199 | ||
201 | /* Last time the cmos clock got updated. */ | ||
202 | static long last_rtc_update = 0; | ||
203 | |||
204 | /* | 200 | /* |
205 | * timer_interrupt() needs to keep up the real-time clock, | 201 | * timer_interrupt() needs to keep up the real-time clock, |
206 | * as well as call the "do_timer()" routine every clocktick. | 202 | * as well as call the "do_timer()" routine every clocktick. |
@@ -238,25 +234,6 @@ timer_interrupt(int irq, void *dev_id) | |||
238 | 234 | ||
239 | /* Call the real timer interrupt handler */ | 235 | /* Call the real timer interrupt handler */ |
240 | do_timer(1); | 236 | do_timer(1); |
241 | |||
242 | /* | ||
243 | * If we have an externally synchronized Linux clock, then update | ||
244 | * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be | ||
245 | * called as close as possible to 500 ms before the new second starts. | ||
246 | * | ||
247 | * The division here is not time critical since it will run once in | ||
248 | * 11 minutes | ||
249 | */ | ||
250 | if ((time_status & STA_UNSYNC) == 0 && | ||
251 | xtime.tv_sec > last_rtc_update + 660 && | ||
252 | (xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 && | ||
253 | (xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) { | ||
254 | if (set_rtc_mmss(xtime.tv_sec) == 0) | ||
255 | last_rtc_update = xtime.tv_sec; | ||
256 | else | ||
257 | /* Do it again in 60 s */ | ||
258 | last_rtc_update = xtime.tv_sec - 600; | ||
259 | } | ||
260 | return IRQ_HANDLED; | 237 | return IRQ_HANDLED; |
261 | } | 238 | } |
262 | 239 | ||
@@ -309,23 +286,10 @@ time_init(void) | |||
309 | */ | 286 | */ |
310 | loops_per_usec = 50; | 287 | loops_per_usec = 50; |
311 | 288 | ||
312 | if(RTC_INIT() < 0) { | 289 | if(RTC_INIT() < 0) |
313 | /* No RTC, start at 1980 */ | ||
314 | xtime.tv_sec = 0; | ||
315 | xtime.tv_nsec = 0; | ||
316 | have_rtc = 0; | 290 | have_rtc = 0; |
317 | } else { | 291 | else |
318 | /* Get the current time */ | ||
319 | have_rtc = 1; | 292 | have_rtc = 1; |
320 | update_xtime_from_cmos(); | ||
321 | } | ||
322 | |||
323 | /* | ||
324 | * Initialize wall_to_monotonic such that adding it to | ||
325 | * xtime will yield zero, the tv_nsec field must be normalized | ||
326 | * (i.e., 0 <= nsec < NSEC_PER_SEC). | ||
327 | */ | ||
328 | set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec); | ||
329 | 293 | ||
330 | /* Start CPU local timer. */ | 294 | /* Start CPU local timer. */ |
331 | cris_timer_init(); | 295 | cris_timer_init(); |
diff --git a/arch/cris/include/asm/atomic.h b/arch/cris/include/asm/atomic.h index a6aca819e9f3..88dc9b9c4ba0 100644 --- a/arch/cris/include/asm/atomic.h +++ b/arch/cris/include/asm/atomic.h | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | #define ATOMIC_INIT(i) { (i) } | 16 | #define ATOMIC_INIT(i) { (i) } |
17 | 17 | ||
18 | #define atomic_read(v) ((v)->counter) | 18 | #define atomic_read(v) (*(volatile int *)&(v)->counter) |
19 | #define atomic_set(v,i) (((v)->counter) = (i)) | 19 | #define atomic_set(v,i) (((v)->counter) = (i)) |
20 | 20 | ||
21 | /* These should be written in asm but we do it in C for now. */ | 21 | /* These should be written in asm but we do it in C for now. */ |
diff --git a/arch/cris/include/asm/thread_info.h b/arch/cris/include/asm/thread_info.h index c3aade36c330..91776069ca80 100644 --- a/arch/cris/include/asm/thread_info.h +++ b/arch/cris/include/asm/thread_info.h | |||
@@ -85,7 +85,7 @@ struct thread_info { | |||
85 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ | 85 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ |
86 | #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ | 86 | #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ |
87 | #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ | 87 | #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ |
88 | #define TIF_MEMDIE 17 | 88 | #define TIF_MEMDIE 17 /* is terminating due to OOM killer */ |
89 | #define TIF_FREEZE 18 /* is freezing for suspend */ | 89 | #define TIF_FREEZE 18 /* is freezing for suspend */ |
90 | 90 | ||
91 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | 91 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) |
diff --git a/arch/cris/kernel/time.c b/arch/cris/kernel/time.c index a05dd31f3efb..c72730d20ef6 100644 --- a/arch/cris/kernel/time.c +++ b/arch/cris/kernel/time.c | |||
@@ -98,6 +98,8 @@ unsigned long | |||
98 | get_cmos_time(void) | 98 | get_cmos_time(void) |
99 | { | 99 | { |
100 | unsigned int year, mon, day, hour, min, sec; | 100 | unsigned int year, mon, day, hour, min, sec; |
101 | if(!have_rtc) | ||
102 | return 0; | ||
101 | 103 | ||
102 | sec = CMOS_READ(RTC_SECONDS); | 104 | sec = CMOS_READ(RTC_SECONDS); |
103 | min = CMOS_READ(RTC_MINUTES); | 105 | min = CMOS_READ(RTC_MINUTES); |
@@ -119,19 +121,19 @@ get_cmos_time(void) | |||
119 | return mktime(year, mon, day, hour, min, sec); | 121 | return mktime(year, mon, day, hour, min, sec); |
120 | } | 122 | } |
121 | 123 | ||
122 | /* update xtime from the CMOS settings. used when /dev/rtc gets a SET_TIME. | ||
123 | * TODO: this doesn't reset the fancy NTP phase stuff as do_settimeofday does. | ||
124 | */ | ||
125 | 124 | ||
126 | void | 125 | int update_persistent_clock(struct timespec now) |
127 | update_xtime_from_cmos(void) | ||
128 | { | 126 | { |
129 | if(have_rtc) { | 127 | return set_rtc_mmss(now.tv_sec); |
130 | xtime.tv_sec = get_cmos_time(); | ||
131 | xtime.tv_nsec = 0; | ||
132 | } | ||
133 | } | 128 | } |
134 | 129 | ||
130 | void read_persistent_clock(struct timespec *ts) | ||
131 | { | ||
132 | ts->tv_sec = get_cmos_time(); | ||
133 | ts->tv_nsec = 0; | ||
134 | } | ||
135 | |||
136 | |||
135 | extern void cris_profile_sample(struct pt_regs* regs); | 137 | extern void cris_profile_sample(struct pt_regs* regs); |
136 | 138 | ||
137 | void | 139 | void |