aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/hwmon/w83l785ts3
-rw-r--r--Documentation/kdump/kdump.txt5
-rw-r--r--MAINTAINERS12
-rw-r--r--arch/frv/mm/Makefile2
-rw-r--r--arch/ia64/kvm/kvm-ia64.c3
-rw-r--r--arch/m68knommu/kernel/asm-offsets.c1
-rw-r--r--arch/m68knommu/kernel/entry.S9
-rw-r--r--arch/m68knommu/kernel/setup.c2
-rw-r--r--arch/m68knommu/kernel/signal.c21
-rw-r--r--arch/m68knommu/kernel/traps.c88
-rw-r--r--arch/m68knommu/kernel/vmlinux.lds.S3
-rw-r--r--arch/m68knommu/platform/5206e/config.c2
-rw-r--r--arch/m68knommu/platform/5272/config.c4
-rw-r--r--arch/m68knommu/platform/528x/config.c266
-rw-r--r--arch/m68knommu/platform/5307/config.c3
-rw-r--r--arch/m68knommu/platform/coldfire/entry.S18
-rw-r--r--arch/mips/kernel/binfmt_elfn32.c5
-rw-r--r--arch/mips/kernel/binfmt_elfo32.c5
-rw-r--r--arch/powerpc/kernel/time.c4
-rw-r--r--arch/x86/kvm/i8254.c6
-rw-r--r--arch/x86/kvm/lapic.c6
-rw-r--r--block/blk-barrier.c3
-rw-r--r--block/blk-core.c5
-rw-r--r--block/blk-settings.c20
-rw-r--r--block/blk-tag.c8
-rw-r--r--block/bsg.c2
-rw-r--r--block/elevator.c5
-rw-r--r--crypto/authenc.c5
-rw-r--r--crypto/cryptd.c4
-rw-r--r--crypto/eseqiv.c3
-rw-r--r--drivers/base/cpu.c10
-rw-r--r--drivers/block/cciss.c8
-rw-r--r--drivers/char/i8k.c6
-rw-r--r--drivers/char/mmtimer.c24
-rw-r--r--drivers/char/synclink.c16
-rw-r--r--drivers/gpio/pca953x.c4
-rw-r--r--drivers/hwmon/adt7473.c45
-rw-r--r--drivers/hwmon/asb100.c4
-rw-r--r--drivers/hwmon/lm75.c5
-rw-r--r--drivers/hwmon/smsc47b397.c17
-rw-r--r--drivers/hwmon/w83793.c26
-rw-r--r--drivers/hwmon/w83l785ts.c4
-rw-r--r--drivers/isdn/hysdn/hysdn_procconf.c3
-rw-r--r--drivers/net/fec.c125
-rw-r--r--drivers/net/fec.h4
-rw-r--r--drivers/pcmcia/au1000_db1x00.c6
-rw-r--r--drivers/pcmcia/au1000_generic.c11
-rw-r--r--drivers/pcmcia/au1000_pb1x00.c14
-rw-r--r--drivers/pcmcia/au1000_xxs1500.c2
-rw-r--r--drivers/pcmcia/cardbus.c2
-rw-r--r--drivers/pcmcia/ds.c2
-rw-r--r--drivers/pcmcia/i82092.c6
-rw-r--r--drivers/pcmcia/omap_cf.c2
-rw-r--r--drivers/pcmcia/pd6729.c6
-rw-r--r--drivers/pcmcia/pxa2xx_lubbock.c8
-rw-r--r--drivers/pcmcia/pxa2xx_mainstone.c4
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c2
-rw-r--r--drivers/pcmcia/sa1100_assabet.c4
-rw-r--r--drivers/pcmcia/sa1100_badge4.c8
-rw-r--r--drivers/pcmcia/sa1100_cerf.c2
-rw-r--r--drivers/pcmcia/sa1100_jornada720.c4
-rw-r--r--drivers/pcmcia/sa1100_neponset.c4
-rw-r--r--drivers/pcmcia/sa1100_shannon.c8
-rw-r--r--drivers/pcmcia/sa1100_simpad.c2
-rw-r--r--drivers/pcmcia/soc_common.c17
-rw-r--r--drivers/pcmcia/soc_common.h1
-rw-r--r--drivers/pnp/pnpbios/rsparser.c6
-rw-r--r--drivers/scsi/mvsas.c4
-rw-r--r--drivers/scsi/ncr53c8xx.c2
-rw-r--r--drivers/serial/8250.c3
-rw-r--r--drivers/serial/8250_early.c2
-rw-r--r--drivers/serial/8250_pci.c14
-rw-r--r--drivers/serial/jsm/jsm.h1
-rw-r--r--drivers/serial/jsm/jsm_driver.c6
-rw-r--r--drivers/spi/spi_bfin5xx.c7
-rw-r--r--drivers/spi/spi_s3c24xx.c6
-rw-r--r--fs/autofs4/expire.c26
-rw-r--r--fs/autofs4/root.c38
-rw-r--r--fs/autofs4/waitq.c2
-rw-r--r--fs/fuse/file.c2
-rw-r--r--fs/utimes.c17
-rw-r--r--include/asm-arm/div64.h2
-rw-r--r--include/asm-frv/unaligned.h6
-rw-r--r--include/asm-generic/div64.h7
-rw-r--r--include/asm-ia64/dmi.h5
-rw-r--r--include/asm-ia64/io.h5
-rw-r--r--include/asm-m68k/div64.h1
-rw-r--r--include/asm-m68knommu/dma.h3
-rw-r--r--include/asm-m68knommu/param.h7
-rw-r--r--include/asm-mips/div64.h6
-rw-r--r--include/asm-mn10300/div64.h3
-rw-r--r--include/asm-um/div64.h1
-rw-r--r--include/asm-x86/div64.h34
-rw-r--r--include/asm-x86/dmi.h1
-rw-r--r--include/asm-x86/io_32.h5
-rw-r--r--include/crypto/scatterwalk.h4
-rw-r--r--include/linux/calc64.h49
-rw-r--r--include/linux/clocksource.h2
-rw-r--r--include/linux/compat.h3
-rw-r--r--include/linux/jiffies.h2
-rw-r--r--include/linux/math64.h84
-rw-r--r--include/linux/module.h19
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/linux/quota.h3
-rw-r--r--include/linux/string.h2
-rw-r--r--include/linux/sysfs.h6
-rw-r--r--include/linux/timex.h46
-rw-r--r--kernel/compat.c3
-rw-r--r--kernel/kexec.c2
-rw-r--r--kernel/module.c319
-rw-r--r--kernel/posix-cpu-timers.c11
-rw-r--r--kernel/sched.c6
-rw-r--r--kernel/sched_debug.c4
-rw-r--r--kernel/softirq.c20
-rw-r--r--kernel/time.c54
-rw-r--r--kernel/time/ntp.c398
-rw-r--r--kernel/time/timekeeping.c17
-rw-r--r--kernel/workqueue.c6
-rw-r--r--lib/div64.c35
-rw-r--r--lib/idr.c2
-rw-r--r--lib/string.c27
-rw-r--r--mm/memcontrol.c11
-rw-r--r--mm/slub.c9
-rw-r--r--mm/vmalloc.c1
-rw-r--r--net/ipv4/tcp_cubic.c4
-rw-r--r--net/netfilter/xt_connbytes.c5
126 files changed, 1403 insertions, 913 deletions
diff --git a/Documentation/hwmon/w83l785ts b/Documentation/hwmon/w83l785ts
index 1841cedc25b2..bd1fa9d4468d 100644
--- a/Documentation/hwmon/w83l785ts
+++ b/Documentation/hwmon/w83l785ts
@@ -33,7 +33,8 @@ Known Issues
33------------ 33------------
34 34
35On some systems (Asus), the BIOS is known to interfere with the driver 35On some systems (Asus), the BIOS is known to interfere with the driver
36and cause read errors. The driver will retry a given number of times 36and cause read errors. Or maybe the W83L785TS-S chip is simply unreliable,
37we don't really know. The driver will retry a given number of times
37(5 by default) and then give up, returning the old value (or 0 if 38(5 by default) and then give up, returning the old value (or 0 if
38there is no old value). It seems to work well enough so that you should 39there is no old value). It seems to work well enough so that you should
39not notice anything. Thanks to James Bolt for helping test this feature. 40not notice anything. Thanks to James Bolt for helping test this feature.
diff --git a/Documentation/kdump/kdump.txt b/Documentation/kdump/kdump.txt
index d0ac72cc19ff..b8e52c0355d3 100644
--- a/Documentation/kdump/kdump.txt
+++ b/Documentation/kdump/kdump.txt
@@ -245,6 +245,8 @@ The syntax is:
245 crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset] 245 crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset]
246 range=start-[end] 246 range=start-[end]
247 247
248 'start' is inclusive and 'end' is exclusive.
249
248For example: 250For example:
249 251
250 crashkernel=512M-2G:64M,2G-:128M 252 crashkernel=512M-2G:64M,2G-:128M
@@ -253,10 +255,11 @@ This would mean:
253 255
254 1) if the RAM is smaller than 512M, then don't reserve anything 256 1) if the RAM is smaller than 512M, then don't reserve anything
255 (this is the "rescue" case) 257 (this is the "rescue" case)
256 2) if the RAM size is between 512M and 2G, then reserve 64M 258 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M
257 3) if the RAM size is larger than 2G, then reserve 128M 259 3) if the RAM size is larger than 2G, then reserve 128M
258 260
259 261
262
260Boot into System Kernel 263Boot into System Kernel
261======================= 264=======================
262 265
diff --git a/MAINTAINERS b/MAINTAINERS
index c3a533d5d382..cae9001a670d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1196,9 +1196,9 @@ S: Maintained
1196 1196
1197CPUSETS 1197CPUSETS
1198P: Paul Jackson 1198P: Paul Jackson
1199P: Simon Derr 1199P: Paul Menage
1200M: pj@sgi.com 1200M: pj@sgi.com
1201M: simon.derr@bull.net 1201M: menage@google.com
1202L: linux-kernel@vger.kernel.org 1202L: linux-kernel@vger.kernel.org
1203W: http://www.bullopensource.org/cpuset/ 1203W: http://www.bullopensource.org/cpuset/
1204S: Supported 1204S: Supported
@@ -1557,6 +1557,14 @@ M: raisch@de.ibm.com
1557L: general@lists.openfabrics.org 1557L: general@lists.openfabrics.org
1558S: Supported 1558S: Supported
1559 1559
1560EMBEDDED LINUX
1561P: Paul Gortmaker
1562M: paul.gortmaker@windriver.com
1563P David Woodhouse
1564M: dwmw2@infradead.org
1565L: linux-embedded@vger.kernel.org
1566S: Maintained
1567
1560EMULEX LPFC FC SCSI DRIVER 1568EMULEX LPFC FC SCSI DRIVER
1561P: James Smart 1569P: James Smart
1562M: james.smart@emulex.com 1570M: james.smart@emulex.com
diff --git a/arch/frv/mm/Makefile b/arch/frv/mm/Makefile
index fb8b1d860f46..1bca5ab8a6ab 100644
--- a/arch/frv/mm/Makefile
+++ b/arch/frv/mm/Makefile
@@ -6,4 +6,4 @@ obj-y := init.o kmap.o
6 6
7obj-$(CONFIG_MMU) += \ 7obj-$(CONFIG_MMU) += \
8 pgalloc.o highmem.o fault.o extable.o cache-page.o tlb-flush.o tlb-miss.o \ 8 pgalloc.o highmem.o fault.o extable.o cache-page.o tlb-flush.o tlb-miss.o \
9 mmu-context.o dma-alloc.o unaligned.o elf-fdpic.o 9 mmu-context.o dma-alloc.o elf-fdpic.o
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 6df073240135..318b81100623 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1,4 +1,3 @@
1
2/* 1/*
3 * kvm_ia64.c: Basic KVM suppport On Itanium series processors 2 * kvm_ia64.c: Basic KVM suppport On Itanium series processors
4 * 3 *
@@ -431,7 +430,7 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu)
431 if (itc_diff < 0) 430 if (itc_diff < 0)
432 itc_diff = -itc_diff; 431 itc_diff = -itc_diff;
433 432
434 expires = div64_64(itc_diff, cyc_per_usec); 433 expires = div64_u64(itc_diff, cyc_per_usec);
435 kt = ktime_set(0, 1000 * expires); 434 kt = ktime_set(0, 1000 * expires);
436 vcpu->arch.ht_active = 1; 435 vcpu->arch.ht_active = 1;
437 hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS); 436 hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS);
diff --git a/arch/m68knommu/kernel/asm-offsets.c b/arch/m68knommu/kernel/asm-offsets.c
index fd0c685a7f11..c785d07c02cc 100644
--- a/arch/m68knommu/kernel/asm-offsets.c
+++ b/arch/m68knommu/kernel/asm-offsets.c
@@ -87,6 +87,7 @@ int main(void)
87 DEFINE(TI_TASK, offsetof(struct thread_info, task)); 87 DEFINE(TI_TASK, offsetof(struct thread_info, task));
88 DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain)); 88 DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
89 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); 89 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
90 DEFINE(TI_PREEMPTCOUNT, offsetof(struct thread_info, preempt_count));
90 DEFINE(TI_CPU, offsetof(struct thread_info, cpu)); 91 DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
91 92
92 return 0; 93 return 0;
diff --git a/arch/m68knommu/kernel/entry.S b/arch/m68knommu/kernel/entry.S
index 1e7ea6a3e1a1..f4782d2dce8f 100644
--- a/arch/m68knommu/kernel/entry.S
+++ b/arch/m68knommu/kernel/entry.S
@@ -32,6 +32,7 @@
32#include <asm/segment.h> 32#include <asm/segment.h>
33#include <asm/asm-offsets.h> 33#include <asm/asm-offsets.h>
34#include <asm/entry.h> 34#include <asm/entry.h>
35#include <asm/unistd.h>
35 36
36.text 37.text
37 38
@@ -140,3 +141,11 @@ ENTRY(sys_rt_sigreturn)
140 RESTORE_SWITCH_STACK 141 RESTORE_SWITCH_STACK
141 rts 142 rts
142 143
144ENTRY(ret_from_user_signal)
145 moveq #__NR_sigreturn,%d0
146 trap #0
147
148ENTRY(ret_from_user_rt_signal)
149 move #__NR_rt_sigreturn,%d0
150 trap #0
151
diff --git a/arch/m68knommu/kernel/setup.c b/arch/m68knommu/kernel/setup.c
index d6f0200316fe..03f4fe6a2fc0 100644
--- a/arch/m68knommu/kernel/setup.c
+++ b/arch/m68knommu/kernel/setup.c
@@ -162,7 +162,7 @@ void __init setup_arch(char **cmdline_p)
162 printk(KERN_INFO "DragonEngine II board support by Georges Menie\n"); 162 printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
163#endif 163#endif
164#ifdef CONFIG_M5235EVB 164#ifdef CONFIG_M5235EVB
165 printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)"); 165 printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)\n");
166#endif 166#endif
167 167
168#ifdef DEBUG 168#ifdef DEBUG
diff --git a/arch/m68knommu/kernel/signal.c b/arch/m68knommu/kernel/signal.c
index 70371378db86..bbfcae9e52b4 100644
--- a/arch/m68knommu/kernel/signal.c
+++ b/arch/m68knommu/kernel/signal.c
@@ -51,6 +51,8 @@
51 51
52#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 52#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
53 53
54void ret_from_user_signal(void);
55void ret_from_user_rt_signal(void);
54asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs); 56asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs);
55 57
56/* 58/*
@@ -539,10 +541,6 @@ static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs)
539 return err; 541 return err;
540} 542}
541 543
542static inline void push_cache (unsigned long vaddr)
543{
544}
545
546static inline void * 544static inline void *
547get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) 545get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
548{ 546{
@@ -586,16 +584,11 @@ static void setup_frame (int sig, struct k_sigaction *ka,
586 err |= copy_to_user (&frame->sc, &context, sizeof(context)); 584 err |= copy_to_user (&frame->sc, &context, sizeof(context));
587 585
588 /* Set up to return from userspace. */ 586 /* Set up to return from userspace. */
589 err |= __put_user(frame->retcode, &frame->pretcode); 587 err |= __put_user((void *) ret_from_user_signal, &frame->pretcode);
590 /* moveq #,d0; trap #0 */
591 err |= __put_user(0x70004e40 + (__NR_sigreturn << 16),
592 (long *)(frame->retcode));
593 588
594 if (err) 589 if (err)
595 goto give_sigsegv; 590 goto give_sigsegv;
596 591
597 push_cache ((unsigned long) &frame->retcode);
598
599 /* Set up registers for signal handler */ 592 /* Set up registers for signal handler */
600 wrusp ((unsigned long) frame); 593 wrusp ((unsigned long) frame);
601 regs->pc = (unsigned long) ka->sa.sa_handler; 594 regs->pc = (unsigned long) ka->sa.sa_handler;
@@ -655,17 +648,11 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
655 err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set)); 648 err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set));
656 649
657 /* Set up to return from userspace. */ 650 /* Set up to return from userspace. */
658 err |= __put_user(frame->retcode, &frame->pretcode); 651 err |= __put_user((void *) ret_from_user_rt_signal, &frame->pretcode);
659 /* moveq #,d0; notb d0; trap #0 */
660 err |= __put_user(0x70004600 + ((__NR_rt_sigreturn ^ 0xff) << 16),
661 (long *)(frame->retcode + 0));
662 err |= __put_user(0x4e40, (short *)(frame->retcode + 4));
663 652
664 if (err) 653 if (err)
665 goto give_sigsegv; 654 goto give_sigsegv;
666 655
667 push_cache ((unsigned long) &frame->retcode);
668
669 /* Set up registers for signal handler */ 656 /* Set up registers for signal handler */
670 wrusp ((unsigned long) frame); 657 wrusp ((unsigned long) frame);
671 regs->pc = (unsigned long) ka->sa.sa_handler; 658 regs->pc = (unsigned long) ka->sa.sa_handler;
diff --git a/arch/m68knommu/kernel/traps.c b/arch/m68knommu/kernel/traps.c
index 437a061d8b94..ec9aea652e79 100644
--- a/arch/m68knommu/kernel/traps.c
+++ b/arch/m68knommu/kernel/traps.c
@@ -28,6 +28,7 @@
28#include <linux/linkage.h> 28#include <linux/linkage.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/ptrace.h> 30#include <linux/ptrace.h>
31#include <linux/kallsyms.h>
31 32
32#include <asm/setup.h> 33#include <asm/setup.h>
33#include <asm/fpu.h> 34#include <asm/fpu.h>
@@ -102,56 +103,47 @@ asmlinkage void buserr_c(struct frame *fp)
102 force_sig(SIGSEGV, current); 103 force_sig(SIGSEGV, current);
103} 104}
104 105
105
106int kstack_depth_to_print = 48; 106int kstack_depth_to_print = 48;
107 107
108void show_stack(struct task_struct *task, unsigned long *stack) 108static void __show_stack(struct task_struct *task, unsigned long *stack)
109{ 109{
110 unsigned long *endstack, addr; 110 unsigned long *endstack, addr;
111 extern char _start, _etext; 111 unsigned long *last_stack;
112 int i; 112 int i;
113 113
114 if (!stack) { 114 if (!stack)
115 if (task) 115 stack = (unsigned long *)task->thread.ksp;
116 stack = (unsigned long *)task->thread.ksp;
117 else
118 stack = (unsigned long *)&stack;
119 }
120 116
121 addr = (unsigned long) stack; 117 addr = (unsigned long) stack;
122 endstack = (unsigned long *) PAGE_ALIGN(addr); 118 endstack = (unsigned long *) PAGE_ALIGN(addr);
123 119
124 printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack); 120 printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack);
125 for (i = 0; i < kstack_depth_to_print; i++) { 121 for (i = 0; i < kstack_depth_to_print; i++) {
126 if (stack + 1 > endstack) 122 if (stack + 1 + i > endstack)
127 break; 123 break;
128 if (i % 8 == 0) 124 if (i % 8 == 0)
129 printk("\n" KERN_EMERG " "); 125 printk("\n" KERN_EMERG " ");
130 printk(" %08lx", *stack++); 126 printk(" %08lx", *(stack + i));
131 } 127 }
132 printk("\n"); 128 printk("\n");
133 129
134 printk(KERN_EMERG "Call Trace:"); 130#ifdef CONFIG_FRAME_POINTER
135 i = 0; 131 printk(KERN_EMERG "Call Trace:\n");
136 while (stack + 1 <= endstack) { 132
137 addr = *stack++; 133 last_stack = stack - 1;
138 /* 134 while (stack <= endstack && stack > last_stack) {
139 * If the address is either in the text segment of the 135
140 * kernel, or in the region which contains vmalloc'ed 136 addr = *(stack + 1);
141 * memory, it *may* be the address of a calling 137 printk(KERN_EMERG " [%08lx] ", addr);
142 * routine; if so, print it so that someone tracing 138 print_symbol(KERN_CONT "%s\n", addr);
143 * down the cause of the crash will be able to figure 139
144 * out the call path that was taken. 140 last_stack = stack;
145 */ 141 stack = (unsigned long *)*stack;
146 if (((addr >= (unsigned long) &_start) &&
147 (addr <= (unsigned long) &_etext))) {
148 if (i % 4 == 0)
149 printk("\n" KERN_EMERG " ");
150 printk(" [<%08lx>]", addr);
151 i++;
152 }
153 } 142 }
154 printk("\n"); 143 printk("\n");
144#else
145 printk(KERN_EMERG "CONFIG_FRAME_POINTER disabled, no symbolic call trace\n");
146#endif
155} 147}
156 148
157void bad_super_trap(struct frame *fp) 149void bad_super_trap(struct frame *fp)
@@ -298,19 +290,47 @@ asmlinkage void set_esp0(unsigned long ssp)
298 current->thread.esp0 = ssp; 290 current->thread.esp0 = ssp;
299} 291}
300 292
301
302/* 293/*
303 * The architecture-independent backtrace generator 294 * The architecture-independent backtrace generator
304 */ 295 */
305void dump_stack(void) 296void dump_stack(void)
306{ 297{
307 unsigned long stack; 298 /*
299 * We need frame pointers for this little trick, which works as follows:
300 *
301 * +------------+ 0x00
302 * | Next SP | -> 0x0c
303 * +------------+ 0x04
304 * | Caller |
305 * +------------+ 0x08
306 * | Local vars | -> our stack var
307 * +------------+ 0x0c
308 * | Next SP | -> 0x18, that is what we pass to show_stack()
309 * +------------+ 0x10
310 * | Caller |
311 * +------------+ 0x14
312 * | Local vars |
313 * +------------+ 0x18
314 * | ... |
315 * +------------+
316 */
308 317
309 show_stack(current, &stack); 318 unsigned long *stack;
310}
311 319
320 stack = (unsigned long *)&stack;
321 stack++;
322 __show_stack(current, stack);
323}
312EXPORT_SYMBOL(dump_stack); 324EXPORT_SYMBOL(dump_stack);
313 325
326void show_stack(struct task_struct *task, unsigned long *stack)
327{
328 if (!stack && !task)
329 dump_stack();
330 else
331 __show_stack(task, stack);
332}
333
314#ifdef CONFIG_M68KFPU_EMU 334#ifdef CONFIG_M68KFPU_EMU
315asmlinkage void fpemu_signal(int signal, int code, void *addr) 335asmlinkage void fpemu_signal(int signal, int code, void *addr)
316{ 336{
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
index b44edb08e212..5592e0bf951f 100644
--- a/arch/m68knommu/kernel/vmlinux.lds.S
+++ b/arch/m68knommu/kernel/vmlinux.lds.S
@@ -64,6 +64,7 @@ SECTIONS {
64 _stext = . ; 64 _stext = . ;
65 TEXT_TEXT 65 TEXT_TEXT
66 SCHED_TEXT 66 SCHED_TEXT
67 LOCK_TEXT
67 *(.text.lock) 68 *(.text.lock)
68 69
69 . = ALIGN(16); /* Exception table */ 70 . = ALIGN(16); /* Exception table */
@@ -73,6 +74,7 @@ SECTIONS {
73 74
74 *(.rodata) *(.rodata.*) 75 *(.rodata) *(.rodata.*)
75 *(__vermagic) /* Kernel version magic */ 76 *(__vermagic) /* Kernel version magic */
77 *(__markers_strings)
76 *(.rodata1) 78 *(.rodata1)
77 *(.rodata.str1.1) 79 *(.rodata.str1.1)
78 80
@@ -182,6 +184,7 @@ SECTIONS {
182 *(COMMON) 184 *(COMMON)
183 . = ALIGN(4) ; 185 . = ALIGN(4) ;
184 _ebss = . ; 186 _ebss = . ;
187 _end = . ;
185 } > BSS 188 } > BSS
186 189
187} 190}
diff --git a/arch/m68knommu/platform/5206e/config.c b/arch/m68knommu/platform/5206e/config.c
index a6692e958f6b..d01a5d2b7557 100644
--- a/arch/m68knommu/platform/5206e/config.c
+++ b/arch/m68knommu/platform/5206e/config.c
@@ -48,7 +48,7 @@ static struct platform_device *m5206e_devices[] __initdata = {
48 48
49/***************************************************************************/ 49/***************************************************************************/
50 50
51static void __init m5206_uart_init_line(int line, int irq) 51static void __init m5206e_uart_init_line(int line, int irq)
52{ 52{
53 if (line == 0) { 53 if (line == 0) {
54 writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); 54 writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
diff --git a/arch/m68knommu/platform/5272/config.c b/arch/m68knommu/platform/5272/config.c
index 2aca599a1ca7..230bae691a7f 100644
--- a/arch/m68knommu/platform/5272/config.c
+++ b/arch/m68knommu/platform/5272/config.c
@@ -139,10 +139,6 @@ void __init config_BSP(char *commandp, int size)
139 /* Copy command line from FLASH to local buffer... */ 139 /* Copy command line from FLASH to local buffer... */
140 memcpy(commandp, (char *) 0xf0004000, size); 140 memcpy(commandp, (char *) 0xf0004000, size);
141 commandp[size-1] = 0; 141 commandp[size-1] = 0;
142#elif defined(CONFIG_MTD_KeyTechnology)
143 /* Copy command line from FLASH to local buffer... */
144 memcpy(commandp, (char *) 0xffe06000, size);
145 commandp[size-1] = 0;
146#elif defined(CONFIG_CANCam) 142#elif defined(CONFIG_CANCam)
147 /* Copy command line from FLASH to local buffer... */ 143 /* Copy command line from FLASH to local buffer... */
148 memcpy(commandp, (char *) 0xf0010000, size); 144 memcpy(commandp, (char *) 0xf0010000, size);
diff --git a/arch/m68knommu/platform/528x/config.c b/arch/m68knommu/platform/528x/config.c
index 036e1b73d944..dfdb5c2ed8e6 100644
--- a/arch/m68knommu/platform/528x/config.c
+++ b/arch/m68knommu/platform/528x/config.c
@@ -26,9 +26,240 @@
26#include <asm/mcfuart.h> 26#include <asm/mcfuart.h>
27#include <asm/mcfqspi.h> 27#include <asm/mcfqspi.h>
28 28
29#ifdef CONFIG_MTD_PARTITIONS
30#include <linux/mtd/partitions.h>
31#endif
32
29/***************************************************************************/ 33/***************************************************************************/
30 34
31void coldfire_reset(void); 35void coldfire_reset(void);
36static void coldfire_qspi_cs_control(u8 cs, u8 command);
37
38/***************************************************************************/
39
40#if defined(CONFIG_SPI)
41
42#if defined(CONFIG_WILDFIRE)
43#define SPI_NUM_CHIPSELECTS 0x02
44#define SPI_PAR_VAL 0x07 /* Enable DIN, DOUT, CLK */
45#define SPI_CS_MASK 0x18
46
47#define FLASH_BLOCKSIZE (1024*64)
48#define FLASH_NUMBLOCKS 16
49#define FLASH_TYPE "m25p80"
50
51#define M25P80_CS 0
52#define MMC_CS 1
53
54#ifdef CONFIG_MTD_PARTITIONS
55static struct mtd_partition stm25p_partitions[] = {
56 /* sflash */
57 [0] = {
58 .name = "stm25p80",
59 .offset = 0x00000000,
60 .size = FLASH_BLOCKSIZE * FLASH_NUMBLOCKS,
61 .mask_flags = 0
62 }
63};
64
65#endif
66
67#elif defined(CONFIG_WILDFIREMOD)
68
69#define SPI_NUM_CHIPSELECTS 0x08
70#define SPI_PAR_VAL 0x07 /* Enable DIN, DOUT, CLK */
71#define SPI_CS_MASK 0x78
72
73#define FLASH_BLOCKSIZE (1024*64)
74#define FLASH_NUMBLOCKS 64
75#define FLASH_TYPE "m25p32"
76/* Reserve 1M for the kernel parition */
77#define FLASH_KERNEL_SIZE (1024 * 1024)
78
79#define M25P80_CS 5
80#define MMC_CS 6
81
82#ifdef CONFIG_MTD_PARTITIONS
83static struct mtd_partition stm25p_partitions[] = {
84 /* sflash */
85 [0] = {
86 .name = "kernel",
87 .offset = FLASH_BLOCKSIZE * FLASH_NUMBLOCKS - FLASH_KERNEL_SIZE,
88 .size = FLASH_KERNEL_SIZE,
89 .mask_flags = 0
90 },
91 [1] = {
92 .name = "image",
93 .offset = 0x00000000,
94 .size = FLASH_BLOCKSIZE * FLASH_NUMBLOCKS - FLASH_KERNEL_SIZE,
95 .mask_flags = 0
96 },
97 [2] = {
98 .name = "all",
99 .offset = 0x00000000,
100 .size = FLASH_BLOCKSIZE * FLASH_NUMBLOCKS,
101 .mask_flags = 0
102 }
103};
104#endif
105
106#else
107#define SPI_NUM_CHIPSELECTS 0x04
108#define SPI_PAR_VAL 0x7F /* Enable DIN, DOUT, CLK, CS0 - CS4 */
109#endif
110
111#ifdef MMC_CS
112static struct coldfire_spi_chip flash_chip_info = {
113 .mode = SPI_MODE_0,
114 .bits_per_word = 16,
115 .del_cs_to_clk = 17,
116 .del_after_trans = 1,
117 .void_write_data = 0
118};
119
120static struct coldfire_spi_chip mmc_chip_info = {
121 .mode = SPI_MODE_0,
122 .bits_per_word = 16,
123 .del_cs_to_clk = 17,
124 .del_after_trans = 1,
125 .void_write_data = 0xFFFF
126};
127#endif
128
129#ifdef M25P80_CS
130static struct flash_platform_data stm25p80_platform_data = {
131 .name = "ST M25P80 SPI Flash chip",
132#ifdef CONFIG_MTD_PARTITIONS
133 .parts = stm25p_partitions,
134 .nr_parts = sizeof(stm25p_partitions) / sizeof(*stm25p_partitions),
135#endif
136 .type = FLASH_TYPE
137};
138#endif
139
140static struct spi_board_info spi_board_info[] __initdata = {
141#ifdef M25P80_CS
142 {
143 .modalias = "m25p80",
144 .max_speed_hz = 16000000,
145 .bus_num = 1,
146 .chip_select = M25P80_CS,
147 .platform_data = &stm25p80_platform_data,
148 .controller_data = &flash_chip_info
149 },
150#endif
151#ifdef MMC_CS
152 {
153 .modalias = "mmc_spi",
154 .max_speed_hz = 16000000,
155 .bus_num = 1,
156 .chip_select = MMC_CS,
157 .controller_data = &mmc_chip_info
158 }
159#endif
160};
161
162static struct coldfire_spi_master coldfire_master_info = {
163 .bus_num = 1,
164 .num_chipselect = SPI_NUM_CHIPSELECTS,
165 .irq_source = MCF5282_QSPI_IRQ_SOURCE,
166 .irq_vector = MCF5282_QSPI_IRQ_VECTOR,
167 .irq_mask = ((0x01 << MCF5282_QSPI_IRQ_SOURCE) | 0x01),
168 .irq_lp = 0x2B, /* Level 5 and Priority 3 */
169 .par_val = SPI_PAR_VAL,
170 .cs_control = coldfire_qspi_cs_control,
171};
172
173static struct resource coldfire_spi_resources[] = {
174 [0] = {
175 .name = "qspi-par",
176 .start = MCF5282_QSPI_PAR,
177 .end = MCF5282_QSPI_PAR,
178 .flags = IORESOURCE_MEM
179 },
180
181 [1] = {
182 .name = "qspi-module",
183 .start = MCF5282_QSPI_QMR,
184 .end = MCF5282_QSPI_QMR + 0x18,
185 .flags = IORESOURCE_MEM
186 },
187
188 [2] = {
189 .name = "qspi-int-level",
190 .start = MCF5282_INTC0 + MCFINTC_ICR0 + MCF5282_QSPI_IRQ_SOURCE,
191 .end = MCF5282_INTC0 + MCFINTC_ICR0 + MCF5282_QSPI_IRQ_SOURCE,
192 .flags = IORESOURCE_MEM
193 },
194
195 [3] = {
196 .name = "qspi-int-mask",
197 .start = MCF5282_INTC0 + MCFINTC_IMRL,
198 .end = MCF5282_INTC0 + MCFINTC_IMRL,
199 .flags = IORESOURCE_MEM
200 }
201};
202
203static struct platform_device coldfire_spi = {
204 .name = "spi_coldfire",
205 .id = -1,
206 .resource = coldfire_spi_resources,
207 .num_resources = ARRAY_SIZE(coldfire_spi_resources),
208 .dev = {
209 .platform_data = &coldfire_master_info,
210 }
211};
212
213static void coldfire_qspi_cs_control(u8 cs, u8 command)
214{
215 u8 cs_bit = ((0x01 << cs) << 3) & SPI_CS_MASK;
216
217#if defined(CONFIG_WILDFIRE)
218 u8 cs_mask = ~(((0x01 << cs) << 3) & SPI_CS_MASK);
219#endif
220#if defined(CONFIG_WILDFIREMOD)
221 u8 cs_mask = (cs << 3) & SPI_CS_MASK;
222#endif
223
224 /*
225 * Don't do anything if the chip select is not
226 * one of the port qs pins.
227 */
228 if (command & QSPI_CS_INIT) {
229#if defined(CONFIG_WILDFIRE)
230 MCF5282_GPIO_DDRQS |= cs_bit;
231 MCF5282_GPIO_PQSPAR &= ~cs_bit;
232#endif
233
234#if defined(CONFIG_WILDFIREMOD)
235 MCF5282_GPIO_DDRQS |= SPI_CS_MASK;
236 MCF5282_GPIO_PQSPAR &= ~SPI_CS_MASK;
237#endif
238 }
239
240 if (command & QSPI_CS_ASSERT) {
241 MCF5282_GPIO_PORTQS &= ~SPI_CS_MASK;
242 MCF5282_GPIO_PORTQS |= cs_mask;
243 } else if (command & QSPI_CS_DROP) {
244 MCF5282_GPIO_PORTQS |= SPI_CS_MASK;
245 }
246}
247
248static int __init spi_dev_init(void)
249{
250 int retval;
251
252 retval = platform_device_register(&coldfire_spi);
253 if (retval < 0)
254 return retval;
255
256 if (ARRAY_SIZE(spi_board_info))
257 retval = spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
258
259 return retval;
260}
261
262#endif /* CONFIG_SPI */
32 263
33/***************************************************************************/ 264/***************************************************************************/
34 265
@@ -111,10 +342,43 @@ void mcf_autovector(unsigned int vec)
111 342
112/***************************************************************************/ 343/***************************************************************************/
113 344
345#ifdef CONFIG_WILDFIRE
346void wildfire_halt(void)
347{
348 writeb(0, 0x30000007);
349 writeb(0x2, 0x30000007);
350}
351#endif
352
353#ifdef CONFIG_WILDFIREMOD
354void wildfiremod_halt(void)
355{
356 printk(KERN_INFO "WildFireMod hibernating...\n");
357
358 /* Set portE.5 to Digital IO */
359 MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2));
360
361 /* Make portE.5 an output */
362 MCF5282_GPIO_DDRE |= (1 << 5);
363
364 /* Now toggle portE.5 from low to high */
365 MCF5282_GPIO_PORTE &= ~(1 << 5);
366 MCF5282_GPIO_PORTE |= (1 << 5);
367
368 printk(KERN_EMERG "Failed to hibernate. Halting!\n");
369}
370#endif
371
114void __init config_BSP(char *commandp, int size) 372void __init config_BSP(char *commandp, int size)
115{ 373{
116 mcf_disableall(); 374 mcf_disableall();
117 mach_reset = coldfire_reset; 375
376#ifdef CONFIG_WILDFIRE
377 mach_halt = wildfire_halt;
378#endif
379#ifdef CONFIG_WILDFIREMOD
380 mach_halt = wildfiremod_halt;
381#endif
118} 382}
119 383
120/***************************************************************************/ 384/***************************************************************************/
diff --git a/arch/m68knommu/platform/5307/config.c b/arch/m68knommu/platform/5307/config.c
index 92dc862fa826..11cff6625dcc 100644
--- a/arch/m68knommu/platform/5307/config.c
+++ b/arch/m68knommu/platform/5307/config.c
@@ -124,8 +124,7 @@ void __init config_BSP(char *commandp, int size)
124 mcf_setimr(MCFSIM_IMR_MASKALL); 124 mcf_setimr(MCFSIM_IMR_MASKALL);
125 125
126#if defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \ 126#if defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
127 defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \ 127 defined(CONFIG_SECUREEDGEMP3) || defined(CONFIG_CLEOPATRA)
128 defined(CONFIG_CLEOPATRA)
129 /* Copy command line from FLASH to local buffer... */ 128 /* Copy command line from FLASH to local buffer... */
130 memcpy(commandp, (char *) 0xf0004000, size); 129 memcpy(commandp, (char *) 0xf0004000, size);
131 commandp[size-1] = 0; 130 commandp[size-1] = 0;
diff --git a/arch/m68knommu/platform/coldfire/entry.S b/arch/m68knommu/platform/coldfire/entry.S
index 111b66dc737b..1e3c0dcbd7ac 100644
--- a/arch/m68knommu/platform/coldfire/entry.S
+++ b/arch/m68knommu/platform/coldfire/entry.S
@@ -103,9 +103,26 @@ ret_from_signal:
103 addql #4,%sp 103 addql #4,%sp
104 104
105ret_from_exception: 105ret_from_exception:
106 move #0x2700,%sr /* disable intrs */
106 btst #5,%sp@(PT_SR) /* check if returning to kernel */ 107 btst #5,%sp@(PT_SR) /* check if returning to kernel */
107 jeq Luser_return /* if so, skip resched, signals */ 108 jeq Luser_return /* if so, skip resched, signals */
108 109
110#ifdef CONFIG_PREEMPT
111 movel %sp,%d1 /* get thread_info pointer */
112 andl #-THREAD_SIZE,%d1 /* at base of kernel stack */
113 movel %d1,%a0
114 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */
115 andl #_TIF_NEED_RESCHED,%d1
116 jeq Lkernel_return
117
118 movel %a0@(TI_PREEMPTCOUNT),%d1
119 cmpl #0,%d1
120 jne Lkernel_return
121
122 pea Lkernel_return
123 jmp preempt_schedule_irq /* preempt the kernel */
124#endif
125
109Lkernel_return: 126Lkernel_return:
110 moveml %sp@,%d1-%d5/%a0-%a2 127 moveml %sp@,%d1-%d5/%a0-%a2
111 lea %sp@(32),%sp /* space for 8 regs */ 128 lea %sp@(32),%sp /* space for 8 regs */
@@ -140,6 +157,7 @@ Lreturn:
140 157
141Lwork_to_do: 158Lwork_to_do:
142 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */ 159 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */
160 move #0x2000,%sr /* enable intrs again */
143 btst #TIF_NEED_RESCHED,%d1 161 btst #TIF_NEED_RESCHED,%d1
144 jne reschedule 162 jne reschedule
145 163
diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
index 77db3473deab..9fdd8bcdd21e 100644
--- a/arch/mips/kernel/binfmt_elfn32.c
+++ b/arch/mips/kernel/binfmt_elfn32.c
@@ -54,6 +54,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
54#include <linux/module.h> 54#include <linux/module.h>
55#include <linux/elfcore.h> 55#include <linux/elfcore.h>
56#include <linux/compat.h> 56#include <linux/compat.h>
57#include <linux/math64.h>
57 58
58#define elf_prstatus elf_prstatus32 59#define elf_prstatus elf_prstatus32
59struct elf_prstatus32 60struct elf_prstatus32
@@ -102,8 +103,8 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
102 * one divide. 103 * one divide.
103 */ 104 */
104 u64 nsec = (u64)jiffies * TICK_NSEC; 105 u64 nsec = (u64)jiffies * TICK_NSEC;
105 long rem; 106 u32 rem;
106 value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &rem); 107 value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
107 value->tv_usec = rem / NSEC_PER_USEC; 108 value->tv_usec = rem / NSEC_PER_USEC;
108} 109}
109 110
diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
index 08f4cd781ee3..e1333d7319e2 100644
--- a/arch/mips/kernel/binfmt_elfo32.c
+++ b/arch/mips/kernel/binfmt_elfo32.c
@@ -56,6 +56,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
56#include <linux/module.h> 56#include <linux/module.h>
57#include <linux/elfcore.h> 57#include <linux/elfcore.h>
58#include <linux/compat.h> 58#include <linux/compat.h>
59#include <linux/math64.h>
59 60
60#define elf_prstatus elf_prstatus32 61#define elf_prstatus elf_prstatus32
61struct elf_prstatus32 62struct elf_prstatus32
@@ -104,8 +105,8 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
104 * one divide. 105 * one divide.
105 */ 106 */
106 u64 nsec = (u64)jiffies * TICK_NSEC; 107 u64 nsec = (u64)jiffies * TICK_NSEC;
107 long rem; 108 u32 rem;
108 value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &rem); 109 value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
109 value->tv_usec = rem / NSEC_PER_USEC; 110 value->tv_usec = rem / NSEC_PER_USEC;
110} 111}
111 112
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 3b26fbd6bec9..73401e83739a 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -149,7 +149,7 @@ EXPORT_SYMBOL(tb_ticks_per_sec); /* for cputime_t conversions */
149u64 tb_to_xs; 149u64 tb_to_xs;
150unsigned tb_to_us; 150unsigned tb_to_us;
151 151
152#define TICKLEN_SCALE TICK_LENGTH_SHIFT 152#define TICKLEN_SCALE NTP_SCALE_SHIFT
153u64 last_tick_len; /* units are ns / 2^TICKLEN_SCALE */ 153u64 last_tick_len; /* units are ns / 2^TICKLEN_SCALE */
154u64 ticklen_to_xs; /* 0.64 fraction */ 154u64 ticklen_to_xs; /* 0.64 fraction */
155 155
@@ -1007,8 +1007,6 @@ void __init time_init(void)
1007 vdso_data->stamp_xsec = (u64) xtime.tv_sec * XSEC_PER_SEC; 1007 vdso_data->stamp_xsec = (u64) xtime.tv_sec * XSEC_PER_SEC;
1008 vdso_data->tb_to_xs = tb_to_xs; 1008 vdso_data->tb_to_xs = tb_to_xs;
1009 1009
1010 time_freq = 0;
1011
1012 write_sequnlock_irqrestore(&xtime_lock, flags); 1010 write_sequnlock_irqrestore(&xtime_lock, flags);
1013 1011
1014 /* Register the clocksource, if we're not running on iSeries */ 1012 /* Register the clocksource, if we're not running on iSeries */
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 361e31611276..4c943eabacc3 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -35,7 +35,7 @@
35#include "i8254.h" 35#include "i8254.h"
36 36
37#ifndef CONFIG_X86_64 37#ifndef CONFIG_X86_64
38#define mod_64(x, y) ((x) - (y) * div64_64(x, y)) 38#define mod_64(x, y) ((x) - (y) * div64_u64(x, y))
39#else 39#else
40#define mod_64(x, y) ((x) % (y)) 40#define mod_64(x, y) ((x) % (y))
41#endif 41#endif
@@ -60,8 +60,8 @@ static u64 muldiv64(u64 a, u32 b, u32 c)
60 rl = (u64)u.l.low * (u64)b; 60 rl = (u64)u.l.low * (u64)b;
61 rh = (u64)u.l.high * (u64)b; 61 rh = (u64)u.l.high * (u64)b;
62 rh += (rl >> 32); 62 rh += (rl >> 32);
63 res.l.high = div64_64(rh, c); 63 res.l.high = div64_u64(rh, c);
64 res.l.low = div64_64(((mod_64(rh, c) << 32) + (rl & 0xffffffff)), c); 64 res.l.low = div64_u64(((mod_64(rh, c) << 32) + (rl & 0xffffffff)), c);
65 return res.ll; 65 return res.ll;
66} 66}
67 67
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 57ac4e4c556a..36809d79788b 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -25,13 +25,13 @@
25#include <linux/hrtimer.h> 25#include <linux/hrtimer.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/math64.h>
28#include <asm/processor.h> 29#include <asm/processor.h>
29#include <asm/msr.h> 30#include <asm/msr.h>
30#include <asm/page.h> 31#include <asm/page.h>
31#include <asm/current.h> 32#include <asm/current.h>
32#include <asm/apicdef.h> 33#include <asm/apicdef.h>
33#include <asm/atomic.h> 34#include <asm/atomic.h>
34#include <asm/div64.h>
35#include "irq.h" 35#include "irq.h"
36 36
37#define PRId64 "d" 37#define PRId64 "d"
@@ -526,8 +526,8 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
526 } else 526 } else
527 passed = ktime_sub(now, apic->timer.last_update); 527 passed = ktime_sub(now, apic->timer.last_update);
528 528
529 counter_passed = div64_64(ktime_to_ns(passed), 529 counter_passed = div64_u64(ktime_to_ns(passed),
530 (APIC_BUS_CYCLE_NS * apic->timer.divide_count)); 530 (APIC_BUS_CYCLE_NS * apic->timer.divide_count));
531 531
532 if (counter_passed > tmcct) { 532 if (counter_passed > tmcct) {
533 if (unlikely(!apic_lvtt_period(apic))) { 533 if (unlikely(!apic_lvtt_period(apic))) {
diff --git a/block/blk-barrier.c b/block/blk-barrier.c
index 66e55288178c..a09ead19f9c5 100644
--- a/block/blk-barrier.c
+++ b/block/blk-barrier.c
@@ -26,8 +26,7 @@ int blk_queue_ordered(struct request_queue *q, unsigned ordered,
26{ 26{
27 if (ordered & (QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH) && 27 if (ordered & (QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH) &&
28 prepare_flush_fn == NULL) { 28 prepare_flush_fn == NULL) {
29 printk(KERN_ERR "%s: prepare_flush_fn required\n", 29 printk(KERN_ERR "%s: prepare_flush_fn required\n", __func__);
30 __FUNCTION__);
31 return -EINVAL; 30 return -EINVAL;
32 } 31 }
33 32
diff --git a/block/blk-core.c b/block/blk-core.c
index 5d09f8c56024..b754a4a2f9bd 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -136,7 +136,7 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
136 136
137 if (unlikely(nbytes > bio->bi_size)) { 137 if (unlikely(nbytes > bio->bi_size)) {
138 printk(KERN_ERR "%s: want %u bytes done, %u left\n", 138 printk(KERN_ERR "%s: want %u bytes done, %u left\n",
139 __FUNCTION__, nbytes, bio->bi_size); 139 __func__, nbytes, bio->bi_size);
140 nbytes = bio->bi_size; 140 nbytes = bio->bi_size;
141 } 141 }
142 142
@@ -1566,8 +1566,7 @@ static int __end_that_request_first(struct request *req, int error,
1566 if (unlikely(bio->bi_idx >= bio->bi_vcnt)) { 1566 if (unlikely(bio->bi_idx >= bio->bi_vcnt)) {
1567 blk_dump_rq_flags(req, "__end_that"); 1567 blk_dump_rq_flags(req, "__end_that");
1568 printk(KERN_ERR "%s: bio idx %d >= vcnt %d\n", 1568 printk(KERN_ERR "%s: bio idx %d >= vcnt %d\n",
1569 __FUNCTION__, bio->bi_idx, 1569 __func__, bio->bi_idx, bio->bi_vcnt);
1570 bio->bi_vcnt);
1571 break; 1570 break;
1572 } 1571 }
1573 1572
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 6089384ab064..bb93d4c32775 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -168,8 +168,8 @@ void blk_queue_max_sectors(struct request_queue *q, unsigned int max_sectors)
168{ 168{
169 if ((max_sectors << 9) < PAGE_CACHE_SIZE) { 169 if ((max_sectors << 9) < PAGE_CACHE_SIZE) {
170 max_sectors = 1 << (PAGE_CACHE_SHIFT - 9); 170 max_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
171 printk(KERN_INFO "%s: set to minimum %d\n", __FUNCTION__, 171 printk(KERN_INFO "%s: set to minimum %d\n",
172 max_sectors); 172 __func__, max_sectors);
173 } 173 }
174 174
175 if (BLK_DEF_MAX_SECTORS > max_sectors) 175 if (BLK_DEF_MAX_SECTORS > max_sectors)
@@ -196,8 +196,8 @@ void blk_queue_max_phys_segments(struct request_queue *q,
196{ 196{
197 if (!max_segments) { 197 if (!max_segments) {
198 max_segments = 1; 198 max_segments = 1;
199 printk(KERN_INFO "%s: set to minimum %d\n", __FUNCTION__, 199 printk(KERN_INFO "%s: set to minimum %d\n",
200 max_segments); 200 __func__, max_segments);
201 } 201 }
202 202
203 q->max_phys_segments = max_segments; 203 q->max_phys_segments = max_segments;
@@ -220,8 +220,8 @@ void blk_queue_max_hw_segments(struct request_queue *q,
220{ 220{
221 if (!max_segments) { 221 if (!max_segments) {
222 max_segments = 1; 222 max_segments = 1;
223 printk(KERN_INFO "%s: set to minimum %d\n", __FUNCTION__, 223 printk(KERN_INFO "%s: set to minimum %d\n",
224 max_segments); 224 __func__, max_segments);
225 } 225 }
226 226
227 q->max_hw_segments = max_segments; 227 q->max_hw_segments = max_segments;
@@ -241,8 +241,8 @@ void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size)
241{ 241{
242 if (max_size < PAGE_CACHE_SIZE) { 242 if (max_size < PAGE_CACHE_SIZE) {
243 max_size = PAGE_CACHE_SIZE; 243 max_size = PAGE_CACHE_SIZE;
244 printk(KERN_INFO "%s: set to minimum %d\n", __FUNCTION__, 244 printk(KERN_INFO "%s: set to minimum %d\n",
245 max_size); 245 __func__, max_size);
246 } 246 }
247 247
248 q->max_segment_size = max_size; 248 q->max_segment_size = max_size;
@@ -357,8 +357,8 @@ void blk_queue_segment_boundary(struct request_queue *q, unsigned long mask)
357{ 357{
358 if (mask < PAGE_CACHE_SIZE - 1) { 358 if (mask < PAGE_CACHE_SIZE - 1) {
359 mask = PAGE_CACHE_SIZE - 1; 359 mask = PAGE_CACHE_SIZE - 1;
360 printk(KERN_INFO "%s: set to minimum %lx\n", __FUNCTION__, 360 printk(KERN_INFO "%s: set to minimum %lx\n",
361 mask); 361 __func__, mask);
362 } 362 }
363 363
364 q->seg_boundary_mask = mask; 364 q->seg_boundary_mask = mask;
diff --git a/block/blk-tag.c b/block/blk-tag.c
index e176ddbe599e..de64e0429977 100644
--- a/block/blk-tag.c
+++ b/block/blk-tag.c
@@ -112,7 +112,7 @@ init_tag_map(struct request_queue *q, struct blk_queue_tag *tags, int depth)
112 if (q && depth > q->nr_requests * 2) { 112 if (q && depth > q->nr_requests * 2) {
113 depth = q->nr_requests * 2; 113 depth = q->nr_requests * 2;
114 printk(KERN_ERR "%s: adjusted depth to %d\n", 114 printk(KERN_ERR "%s: adjusted depth to %d\n",
115 __FUNCTION__, depth); 115 __func__, depth);
116 } 116 }
117 117
118 tag_index = kzalloc(depth * sizeof(struct request *), GFP_ATOMIC); 118 tag_index = kzalloc(depth * sizeof(struct request *), GFP_ATOMIC);
@@ -296,13 +296,13 @@ void blk_queue_end_tag(struct request_queue *q, struct request *rq)
296 296
297 if (unlikely(bqt->tag_index[tag] == NULL)) 297 if (unlikely(bqt->tag_index[tag] == NULL))
298 printk(KERN_ERR "%s: tag %d is missing\n", 298 printk(KERN_ERR "%s: tag %d is missing\n",
299 __FUNCTION__, tag); 299 __func__, tag);
300 300
301 bqt->tag_index[tag] = NULL; 301 bqt->tag_index[tag] = NULL;
302 302
303 if (unlikely(!test_bit(tag, bqt->tag_map))) { 303 if (unlikely(!test_bit(tag, bqt->tag_map))) {
304 printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n", 304 printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n",
305 __FUNCTION__, tag); 305 __func__, tag);
306 return; 306 return;
307 } 307 }
308 /* 308 /*
@@ -340,7 +340,7 @@ int blk_queue_start_tag(struct request_queue *q, struct request *rq)
340 if (unlikely((rq->cmd_flags & REQ_QUEUED))) { 340 if (unlikely((rq->cmd_flags & REQ_QUEUED))) {
341 printk(KERN_ERR 341 printk(KERN_ERR
342 "%s: request %p for device [%s] already tagged %d", 342 "%s: request %p for device [%s] already tagged %d",
343 __FUNCTION__, rq, 343 __func__, rq,
344 rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->tag); 344 rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->tag);
345 BUG(); 345 BUG();
346 } 346 }
diff --git a/block/bsg.c b/block/bsg.c
index 23ea4fd1a66d..fa796b605f55 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -57,7 +57,7 @@ enum {
57#undef BSG_DEBUG 57#undef BSG_DEBUG
58 58
59#ifdef BSG_DEBUG 59#ifdef BSG_DEBUG
60#define dprintk(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ##args) 60#define dprintk(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ##args)
61#else 61#else
62#define dprintk(fmt, args...) 62#define dprintk(fmt, args...)
63#endif 63#endif
diff --git a/block/elevator.c b/block/elevator.c
index ac5310ef8270..980f8ae147b4 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -650,7 +650,7 @@ void elv_insert(struct request_queue *q, struct request *rq, int where)
650 650
651 default: 651 default:
652 printk(KERN_ERR "%s: bad insertion point %d\n", 652 printk(KERN_ERR "%s: bad insertion point %d\n",
653 __FUNCTION__, where); 653 __func__, where);
654 BUG(); 654 BUG();
655 } 655 }
656 656
@@ -808,8 +808,7 @@ struct request *elv_next_request(struct request_queue *q)
808 rq->cmd_flags |= REQ_QUIET; 808 rq->cmd_flags |= REQ_QUIET;
809 end_queued_request(rq, 0); 809 end_queued_request(rq, 0);
810 } else { 810 } else {
811 printk(KERN_ERR "%s: bad return=%d\n", __FUNCTION__, 811 printk(KERN_ERR "%s: bad return=%d\n", __func__, ret);
812 ret);
813 break; 812 break;
814 } 813 }
815 } 814 }
diff --git a/crypto/authenc.c b/crypto/authenc.c
index ed8ac5a6fa5f..4b226768752a 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -217,9 +217,10 @@ static void crypto_authenc_givencrypt_done(struct crypto_async_request *req,
217 int err) 217 int err)
218{ 218{
219 if (!err) { 219 if (!err) {
220 struct aead_givcrypt_request *greq = req->data; 220 struct aead_request *areq = req->data;
221 struct skcipher_givcrypt_request *greq = aead_request_ctx(areq);
221 222
222 err = crypto_authenc_genicv(&greq->areq, greq->giv, 0); 223 err = crypto_authenc_genicv(areq, greq->giv, 0);
223 } 224 }
224 225
225 aead_request_complete(req->data, err); 226 aead_request_complete(req->data, err);
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index 250425263e00..b150de562057 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -190,8 +190,10 @@ static struct crypto_instance *cryptd_alloc_instance(struct crypto_alg *alg,
190 int err; 190 int err;
191 191
192 inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL); 192 inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
193 if (IS_ERR(inst)) 193 if (!inst) {
194 inst = ERR_PTR(-ENOMEM);
194 goto out; 195 goto out;
196 }
195 197
196 err = -ENAMETOOLONG; 198 err = -ENAMETOOLONG;
197 if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, 199 if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,
diff --git a/crypto/eseqiv.c b/crypto/eseqiv.c
index b14f14e314b6..881d30910434 100644
--- a/crypto/eseqiv.c
+++ b/crypto/eseqiv.c
@@ -136,7 +136,8 @@ static int eseqiv_givencrypt(struct skcipher_givcrypt_request *req)
136 } 136 }
137 137
138 ablkcipher_request_set_crypt(subreq, reqctx->src, dst, 138 ablkcipher_request_set_crypt(subreq, reqctx->src, dst,
139 req->creq.nbytes, req->creq.info); 139 req->creq.nbytes + ivsize,
140 req->creq.info);
140 141
141 memcpy(req->creq.info, ctx->salt, ivsize); 142 memcpy(req->creq.info, ctx->salt, ivsize);
142 143
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 6fe417429977..e38dfed41d80 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -18,7 +18,7 @@ struct sysdev_class cpu_sysdev_class = {
18}; 18};
19EXPORT_SYMBOL(cpu_sysdev_class); 19EXPORT_SYMBOL(cpu_sysdev_class);
20 20
21static struct sys_device *cpu_sys_devices[NR_CPUS]; 21static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices);
22 22
23#ifdef CONFIG_HOTPLUG_CPU 23#ifdef CONFIG_HOTPLUG_CPU
24static ssize_t show_online(struct sys_device *dev, char *buf) 24static ssize_t show_online(struct sys_device *dev, char *buf)
@@ -68,7 +68,7 @@ void unregister_cpu(struct cpu *cpu)
68 sysdev_remove_file(&cpu->sysdev, &attr_online); 68 sysdev_remove_file(&cpu->sysdev, &attr_online);
69 69
70 sysdev_unregister(&cpu->sysdev); 70 sysdev_unregister(&cpu->sysdev);
71 cpu_sys_devices[logical_cpu] = NULL; 71 per_cpu(cpu_sys_devices, logical_cpu) = NULL;
72 return; 72 return;
73} 73}
74#else /* ... !CONFIG_HOTPLUG_CPU */ 74#else /* ... !CONFIG_HOTPLUG_CPU */
@@ -167,7 +167,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num)
167 if (!error && cpu->hotpluggable) 167 if (!error && cpu->hotpluggable)
168 register_cpu_control(cpu); 168 register_cpu_control(cpu);
169 if (!error) 169 if (!error)
170 cpu_sys_devices[num] = &cpu->sysdev; 170 per_cpu(cpu_sys_devices, num) = &cpu->sysdev;
171 if (!error) 171 if (!error)
172 register_cpu_under_node(num, cpu_to_node(num)); 172 register_cpu_under_node(num, cpu_to_node(num));
173 173
@@ -180,8 +180,8 @@ int __cpuinit register_cpu(struct cpu *cpu, int num)
180 180
181struct sys_device *get_cpu_sysdev(unsigned cpu) 181struct sys_device *get_cpu_sysdev(unsigned cpu)
182{ 182{
183 if (cpu < NR_CPUS) 183 if (cpu < nr_cpu_ids && cpu_possible(cpu))
184 return cpu_sys_devices[cpu]; 184 return per_cpu(cpu_sys_devices, cpu);
185 else 185 else
186 return NULL; 186 return NULL;
187} 187}
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index e539be5750dc..e336b05fe4a7 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -428,13 +428,9 @@ static void __devinit cciss_procinit(int i)
428 proc_cciss = proc_mkdir("driver/cciss", NULL); 428 proc_cciss = proc_mkdir("driver/cciss", NULL);
429 if (!proc_cciss) 429 if (!proc_cciss)
430 return; 430 return;
431 pde = proc_create(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP | 431 pde = proc_create_data(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP |
432 S_IROTH, proc_cciss, 432 S_IROTH, proc_cciss,
433 &cciss_proc_fops); 433 &cciss_proc_fops, hba[i]);
434 if (!pde)
435 return;
436
437 pde->data = hba[i];
438} 434}
439#endif /* CONFIG_PROC_FS */ 435#endif /* CONFIG_PROC_FS */
440 436
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index f49037b744f9..b60d425ce8d1 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -77,6 +77,10 @@ static int power_status;
77module_param(power_status, bool, 0600); 77module_param(power_status, bool, 0600);
78MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k"); 78MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k");
79 79
80static int fan_mult = I8K_FAN_MULT;
81module_param(fan_mult, int, 0);
82MODULE_PARM_DESC(fan_mult, "Factor to multiply fan speed with");
83
80static int i8k_open_fs(struct inode *inode, struct file *file); 84static int i8k_open_fs(struct inode *inode, struct file *file);
81static int i8k_ioctl(struct inode *, struct file *, unsigned int, 85static int i8k_ioctl(struct inode *, struct file *, unsigned int,
82 unsigned long); 86 unsigned long);
@@ -239,7 +243,7 @@ static int i8k_get_fan_speed(int fan)
239 struct smm_regs regs = { .eax = I8K_SMM_GET_SPEED, }; 243 struct smm_regs regs = { .eax = I8K_SMM_GET_SPEED, };
240 244
241 regs.ebx = fan & 0xff; 245 regs.ebx = fan & 0xff;
242 return i8k_smm(&regs) ? : (regs.eax & 0xffff) * I8K_FAN_MULT; 246 return i8k_smm(&regs) ? : (regs.eax & 0xffff) * fan_mult;
243} 247}
244 248
245/* 249/*
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index d83db5d880e0..192961fd7173 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -30,6 +30,8 @@
30#include <linux/miscdevice.h> 30#include <linux/miscdevice.h>
31#include <linux/posix-timers.h> 31#include <linux/posix-timers.h>
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/time.h>
34#include <linux/math64.h>
33 35
34#include <asm/uaccess.h> 36#include <asm/uaccess.h>
35#include <asm/sn/addrs.h> 37#include <asm/sn/addrs.h>
@@ -472,8 +474,8 @@ static int sgi_clock_get(clockid_t clockid, struct timespec *tp)
472 474
473 nsec = rtc_time() * sgi_clock_period 475 nsec = rtc_time() * sgi_clock_period
474 + sgi_clock_offset.tv_nsec; 476 + sgi_clock_offset.tv_nsec;
475 tp->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &tp->tv_nsec) 477 *tp = ns_to_timespec(nsec);
476 + sgi_clock_offset.tv_sec; 478 tp->tv_sec += sgi_clock_offset.tv_sec;
477 return 0; 479 return 0;
478}; 480};
479 481
@@ -481,11 +483,11 @@ static int sgi_clock_set(clockid_t clockid, struct timespec *tp)
481{ 483{
482 484
483 u64 nsec; 485 u64 nsec;
484 u64 rem; 486 u32 rem;
485 487
486 nsec = rtc_time() * sgi_clock_period; 488 nsec = rtc_time() * sgi_clock_period;
487 489
488 sgi_clock_offset.tv_sec = tp->tv_sec - div_long_long_rem(nsec, NSEC_PER_SEC, &rem); 490 sgi_clock_offset.tv_sec = tp->tv_sec - div_u64_rem(nsec, NSEC_PER_SEC, &rem);
489 491
490 if (rem <= tp->tv_nsec) 492 if (rem <= tp->tv_nsec)
491 sgi_clock_offset.tv_nsec = tp->tv_sec - rem; 493 sgi_clock_offset.tv_nsec = tp->tv_sec - rem;
@@ -644,9 +646,6 @@ static int sgi_timer_del(struct k_itimer *timr)
644 return 0; 646 return 0;
645} 647}
646 648
647#define timespec_to_ns(x) ((x).tv_nsec + (x).tv_sec * NSEC_PER_SEC)
648#define ns_to_timespec(ts, nsec) (ts).tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &(ts).tv_nsec)
649
650/* Assumption: it_lock is already held with irq's disabled */ 649/* Assumption: it_lock is already held with irq's disabled */
651static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) 650static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
652{ 651{
@@ -659,9 +658,8 @@ static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
659 return; 658 return;
660 } 659 }
661 660
662 ns_to_timespec(cur_setting->it_interval, timr->it.mmtimer.incr * sgi_clock_period); 661 cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * sgi_clock_period);
663 ns_to_timespec(cur_setting->it_value, (timr->it.mmtimer.expires - rtc_time())* sgi_clock_period); 662 cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - rtc_time()) * sgi_clock_period);
664 return;
665} 663}
666 664
667 665
@@ -679,8 +677,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
679 sgi_timer_get(timr, old_setting); 677 sgi_timer_get(timr, old_setting);
680 678
681 sgi_timer_del(timr); 679 sgi_timer_del(timr);
682 when = timespec_to_ns(new_setting->it_value); 680 when = timespec_to_ns(&new_setting->it_value);
683 period = timespec_to_ns(new_setting->it_interval); 681 period = timespec_to_ns(&new_setting->it_interval);
684 682
685 if (when == 0) 683 if (when == 0)
686 /* Clear timer */ 684 /* Clear timer */
@@ -695,7 +693,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
695 unsigned long now; 693 unsigned long now;
696 694
697 getnstimeofday(&n); 695 getnstimeofday(&n);
698 now = timespec_to_ns(n); 696 now = timespec_to_ns(&n);
699 if (when > now) 697 if (when > now)
700 when -= now; 698 when -= now;
701 else 699 else
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 513b7c2f3e26..ac5080df2565 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -2028,13 +2028,13 @@ static void mgsl_change_params(struct mgsl_struct *info)
2028 */ 2028 */
2029static int mgsl_put_char(struct tty_struct *tty, unsigned char ch) 2029static int mgsl_put_char(struct tty_struct *tty, unsigned char ch)
2030{ 2030{
2031 struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; 2031 struct mgsl_struct *info = tty->driver_data;
2032 unsigned long flags; 2032 unsigned long flags;
2033 int ret; 2033 int ret = 0;
2034 2034
2035 if ( debug_level >= DEBUG_LEVEL_INFO ) { 2035 if (debug_level >= DEBUG_LEVEL_INFO) {
2036 printk( "%s(%d):mgsl_put_char(%d) on %s\n", 2036 printk(KERN_DEBUG "%s(%d):mgsl_put_char(%d) on %s\n",
2037 __FILE__,__LINE__,ch,info->device_name); 2037 __FILE__, __LINE__, ch, info->device_name);
2038 } 2038 }
2039 2039
2040 if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char")) 2040 if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char"))
@@ -2043,9 +2043,9 @@ static int mgsl_put_char(struct tty_struct *tty, unsigned char ch)
2043 if (!tty || !info->xmit_buf) 2043 if (!tty || !info->xmit_buf)
2044 return 0; 2044 return 0;
2045 2045
2046 spin_lock_irqsave(&info->irq_spinlock,flags); 2046 spin_lock_irqsave(&info->irq_spinlock, flags);
2047 2047
2048 if ( (info->params.mode == MGSL_MODE_ASYNC ) || !info->tx_active ) { 2048 if ((info->params.mode == MGSL_MODE_ASYNC ) || !info->tx_active) {
2049 if (info->xmit_cnt < SERIAL_XMIT_SIZE - 1) { 2049 if (info->xmit_cnt < SERIAL_XMIT_SIZE - 1) {
2050 info->xmit_buf[info->xmit_head++] = ch; 2050 info->xmit_buf[info->xmit_head++] = ch;
2051 info->xmit_head &= SERIAL_XMIT_SIZE-1; 2051 info->xmit_head &= SERIAL_XMIT_SIZE-1;
@@ -2053,7 +2053,7 @@ static int mgsl_put_char(struct tty_struct *tty, unsigned char ch)
2053 ret = 1; 2053 ret = 1;
2054 } 2054 }
2055 } 2055 }
2056 spin_unlock_irqrestore(&info->irq_spinlock,flags); 2056 spin_unlock_irqrestore(&info->irq_spinlock, flags);
2057 return ret; 2057 return ret;
2058 2058
2059} /* end of mgsl_put_char() */ 2059} /* end of mgsl_put_char() */
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index 5a99e81d2784..93f916720b13 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -30,6 +30,8 @@ static const struct i2c_device_id pca953x_id[] = {
30 { "pca9537", 4, }, 30 { "pca9537", 4, },
31 { "pca9538", 8, }, 31 { "pca9538", 8, },
32 { "pca9539", 16, }, 32 { "pca9539", 16, },
33 { "pca9555", 16, },
34 { "pca9557", 8, },
33 /* REVISIT several pca955x parts should work here too */ 35 /* REVISIT several pca955x parts should work here too */
34 { } 36 { }
35}; 37};
@@ -193,7 +195,7 @@ static int __devinit pca953x_probe(struct i2c_client *client,
193{ 195{
194 struct pca953x_platform_data *pdata; 196 struct pca953x_platform_data *pdata;
195 struct pca953x_chip *chip; 197 struct pca953x_chip *chip;
196 int ret, i; 198 int ret;
197 199
198 pdata = client->dev.platform_data; 200 pdata = client->dev.platform_data;
199 if (pdata == NULL) 201 if (pdata == NULL)
diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c
index 9587869bdba0..c1009d6f9796 100644
--- a/drivers/hwmon/adt7473.c
+++ b/drivers/hwmon/adt7473.c
@@ -422,18 +422,14 @@ static ssize_t show_volt(struct device *dev, struct device_attribute *devattr,
422 * number in the range -128 to 127, or as an unsigned number that must 422 * number in the range -128 to 127, or as an unsigned number that must
423 * be offset by 64. 423 * be offset by 64.
424 */ 424 */
425static int decode_temp(struct adt7473_data *data, u8 raw) 425static int decode_temp(u8 twos_complement, u8 raw)
426{ 426{
427 if (data->temp_twos_complement) 427 return twos_complement ? (s8)raw : raw - 64;
428 return (s8)raw;
429 return raw - 64;
430} 428}
431 429
432static u8 encode_temp(struct adt7473_data *data, int cooked) 430static u8 encode_temp(u8 twos_complement, int cooked)
433{ 431{
434 if (data->temp_twos_complement) 432 return twos_complement ? cooked & 0xFF : cooked + 64;
435 return (cooked & 0xFF);
436 return cooked + 64;
437} 433}
438 434
439static ssize_t show_temp_min(struct device *dev, 435static ssize_t show_temp_min(struct device *dev,
@@ -442,8 +438,9 @@ static ssize_t show_temp_min(struct device *dev,
442{ 438{
443 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 439 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
444 struct adt7473_data *data = adt7473_update_device(dev); 440 struct adt7473_data *data = adt7473_update_device(dev);
445 return sprintf(buf, "%d\n", 441 return sprintf(buf, "%d\n", 1000 * decode_temp(
446 1000 * decode_temp(data, data->temp_min[attr->index])); 442 data->temp_twos_complement,
443 data->temp_min[attr->index]));
447} 444}
448 445
449static ssize_t set_temp_min(struct device *dev, 446static ssize_t set_temp_min(struct device *dev,
@@ -455,7 +452,7 @@ static ssize_t set_temp_min(struct device *dev,
455 struct i2c_client *client = to_i2c_client(dev); 452 struct i2c_client *client = to_i2c_client(dev);
456 struct adt7473_data *data = i2c_get_clientdata(client); 453 struct adt7473_data *data = i2c_get_clientdata(client);
457 int temp = simple_strtol(buf, NULL, 10) / 1000; 454 int temp = simple_strtol(buf, NULL, 10) / 1000;
458 temp = encode_temp(data, temp); 455 temp = encode_temp(data->temp_twos_complement, temp);
459 456
460 mutex_lock(&data->lock); 457 mutex_lock(&data->lock);
461 data->temp_min[attr->index] = temp; 458 data->temp_min[attr->index] = temp;
@@ -472,8 +469,9 @@ static ssize_t show_temp_max(struct device *dev,
472{ 469{
473 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 470 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
474 struct adt7473_data *data = adt7473_update_device(dev); 471 struct adt7473_data *data = adt7473_update_device(dev);
475 return sprintf(buf, "%d\n", 472 return sprintf(buf, "%d\n", 1000 * decode_temp(
476 1000 * decode_temp(data, data->temp_max[attr->index])); 473 data->temp_twos_complement,
474 data->temp_max[attr->index]));
477} 475}
478 476
479static ssize_t set_temp_max(struct device *dev, 477static ssize_t set_temp_max(struct device *dev,
@@ -485,7 +483,7 @@ static ssize_t set_temp_max(struct device *dev,
485 struct i2c_client *client = to_i2c_client(dev); 483 struct i2c_client *client = to_i2c_client(dev);
486 struct adt7473_data *data = i2c_get_clientdata(client); 484 struct adt7473_data *data = i2c_get_clientdata(client);
487 int temp = simple_strtol(buf, NULL, 10) / 1000; 485 int temp = simple_strtol(buf, NULL, 10) / 1000;
488 temp = encode_temp(data, temp); 486 temp = encode_temp(data->temp_twos_complement, temp);
489 487
490 mutex_lock(&data->lock); 488 mutex_lock(&data->lock);
491 data->temp_max[attr->index] = temp; 489 data->temp_max[attr->index] = temp;
@@ -501,8 +499,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
501{ 499{
502 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 500 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
503 struct adt7473_data *data = adt7473_update_device(dev); 501 struct adt7473_data *data = adt7473_update_device(dev);
504 return sprintf(buf, "%d\n", 502 return sprintf(buf, "%d\n", 1000 * decode_temp(
505 1000 * decode_temp(data, data->temp[attr->index])); 503 data->temp_twos_complement,
504 data->temp[attr->index]));
506} 505}
507 506
508static ssize_t show_fan_min(struct device *dev, 507static ssize_t show_fan_min(struct device *dev,
@@ -671,8 +670,9 @@ static ssize_t show_temp_tmax(struct device *dev,
671{ 670{
672 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 671 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
673 struct adt7473_data *data = adt7473_update_device(dev); 672 struct adt7473_data *data = adt7473_update_device(dev);
674 return sprintf(buf, "%d\n", 673 return sprintf(buf, "%d\n", 1000 * decode_temp(
675 1000 * decode_temp(data, data->temp_tmax[attr->index])); 674 data->temp_twos_complement,
675 data->temp_tmax[attr->index]));
676} 676}
677 677
678static ssize_t set_temp_tmax(struct device *dev, 678static ssize_t set_temp_tmax(struct device *dev,
@@ -684,7 +684,7 @@ static ssize_t set_temp_tmax(struct device *dev,
684 struct i2c_client *client = to_i2c_client(dev); 684 struct i2c_client *client = to_i2c_client(dev);
685 struct adt7473_data *data = i2c_get_clientdata(client); 685 struct adt7473_data *data = i2c_get_clientdata(client);
686 int temp = simple_strtol(buf, NULL, 10) / 1000; 686 int temp = simple_strtol(buf, NULL, 10) / 1000;
687 temp = encode_temp(data, temp); 687 temp = encode_temp(data->temp_twos_complement, temp);
688 688
689 mutex_lock(&data->lock); 689 mutex_lock(&data->lock);
690 data->temp_tmax[attr->index] = temp; 690 data->temp_tmax[attr->index] = temp;
@@ -701,8 +701,9 @@ static ssize_t show_temp_tmin(struct device *dev,
701{ 701{
702 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 702 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
703 struct adt7473_data *data = adt7473_update_device(dev); 703 struct adt7473_data *data = adt7473_update_device(dev);
704 return sprintf(buf, "%d\n", 704 return sprintf(buf, "%d\n", 1000 * decode_temp(
705 1000 * decode_temp(data, data->temp_tmin[attr->index])); 705 data->temp_twos_complement,
706 data->temp_tmin[attr->index]));
706} 707}
707 708
708static ssize_t set_temp_tmin(struct device *dev, 709static ssize_t set_temp_tmin(struct device *dev,
@@ -714,7 +715,7 @@ static ssize_t set_temp_tmin(struct device *dev,
714 struct i2c_client *client = to_i2c_client(dev); 715 struct i2c_client *client = to_i2c_client(dev);
715 struct adt7473_data *data = i2c_get_clientdata(client); 716 struct adt7473_data *data = i2c_get_clientdata(client);
716 int temp = simple_strtol(buf, NULL, 10) / 1000; 717 int temp = simple_strtol(buf, NULL, 10) / 1000;
717 temp = encode_temp(data, temp); 718 temp = encode_temp(data->temp_twos_complement, temp);
718 719
719 mutex_lock(&data->lock); 720 mutex_lock(&data->lock);
720 data->temp_tmin[attr->index] = temp; 721 data->temp_tmin[attr->index] = temp;
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index 84712a22acea..fe2eea4d799b 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -953,12 +953,8 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
953static void asb100_init_client(struct i2c_client *client) 953static void asb100_init_client(struct i2c_client *client)
954{ 954{
955 struct asb100_data *data = i2c_get_clientdata(client); 955 struct asb100_data *data = i2c_get_clientdata(client);
956 int vid = 0;
957 956
958 vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f;
959 vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4;
960 data->vrm = vid_which_vrm(); 957 data->vrm = vid_which_vrm();
961 vid = vid_from_reg(vid, data->vrm);
962 958
963 /* Start monitoring */ 959 /* Start monitoring */
964 asb100_write_value(client, ASB100_REG_CONFIG, 960 asb100_write_value(client, ASB100_REG_CONFIG,
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 115f4090b98e..fa7696905154 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -248,7 +248,7 @@ static int lm75_detach_client(struct i2c_client *client)
248 248
249/* All registers are word-sized, except for the configuration register. 249/* All registers are word-sized, except for the configuration register.
250 LM75 uses a high-byte first convention, which is exactly opposite to 250 LM75 uses a high-byte first convention, which is exactly opposite to
251 the usual practice. */ 251 the SMBus standard. */
252static int lm75_read_value(struct i2c_client *client, u8 reg) 252static int lm75_read_value(struct i2c_client *client, u8 reg)
253{ 253{
254 if (reg == LM75_REG_CONF) 254 if (reg == LM75_REG_CONF)
@@ -257,9 +257,6 @@ static int lm75_read_value(struct i2c_client *client, u8 reg)
257 return swab16(i2c_smbus_read_word_data(client, reg)); 257 return swab16(i2c_smbus_read_word_data(client, reg));
258} 258}
259 259
260/* All registers are word-sized, except for the configuration register.
261 LM75 uses a high-byte first convention, which is exactly opposite to
262 the usual practice. */
263static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) 260static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
264{ 261{
265 if (reg == LM75_REG_CONF) 262 if (reg == LM75_REG_CONF)
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index f61d8f4185b2..eb03544c731c 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -335,11 +335,23 @@ exit:
335static int __init smsc47b397_find(unsigned short *addr) 335static int __init smsc47b397_find(unsigned short *addr)
336{ 336{
337 u8 id, rev; 337 u8 id, rev;
338 char *name;
338 339
339 superio_enter(); 340 superio_enter();
340 id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); 341 id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
341 342
342 if ((id != 0x6f) && (id != 0x81) && (id != 0x85)) { 343 switch(id) {
344 case 0x81:
345 name = "SCH5307-NS";
346 break;
347 case 0x6f:
348 name = "LPC47B397-NC";
349 break;
350 case 0x85:
351 case 0x8c:
352 name = "SCH5317";
353 break;
354 default:
343 superio_exit(); 355 superio_exit();
344 return -ENODEV; 356 return -ENODEV;
345 } 357 }
@@ -352,8 +364,7 @@ static int __init smsc47b397_find(unsigned short *addr)
352 364
353 printk(KERN_INFO DRVNAME ": found SMSC %s " 365 printk(KERN_INFO DRVNAME ": found SMSC %s "
354 "(base address 0x%04x, revision %u)\n", 366 "(base address 0x%04x, revision %u)\n",
355 id == 0x81 ? "SCH5307-NS" : id == 0x85 ? "SCH5317" : 367 name, *addr, rev);
356 "LPC47B397-NC", *addr, rev);
357 368
358 superio_exit(); 369 superio_exit();
359 return 0; 370 return 0;
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index ee35af93b574..ed3c019b78c7 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -1024,10 +1024,9 @@ static struct sensor_device_attribute_2 w83793_vid[] = {
1024 SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0), 1024 SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0),
1025 SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1), 1025 SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1),
1026}; 1026};
1027static DEVICE_ATTR(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm);
1027 1028
1028static struct sensor_device_attribute_2 sda_single_files[] = { 1029static struct sensor_device_attribute_2 sda_single_files[] = {
1029 SENSOR_ATTR_2(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm,
1030 NOT_USED, NOT_USED),
1031 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, 1030 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep,
1032 store_chassis_clear, ALARM_STATUS, 30), 1031 store_chassis_clear, ALARM_STATUS, 30),
1033 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, 1032 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable,
@@ -1080,6 +1079,7 @@ static int w83793_detach_client(struct i2c_client *client)
1080 1079
1081 for (i = 0; i < ARRAY_SIZE(w83793_vid); i++) 1080 for (i = 0; i < ARRAY_SIZE(w83793_vid); i++)
1082 device_remove_file(dev, &w83793_vid[i].dev_attr); 1081 device_remove_file(dev, &w83793_vid[i].dev_attr);
1082 device_remove_file(dev, &dev_attr_vrm);
1083 1083
1084 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) 1084 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++)
1085 device_remove_file(dev, &w83793_left_fan[i].dev_attr); 1085 device_remove_file(dev, &w83793_left_fan[i].dev_attr);
@@ -1282,7 +1282,6 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1282 /* Initialize the chip */ 1282 /* Initialize the chip */
1283 w83793_init_client(client); 1283 w83793_init_client(client);
1284 1284
1285 data->vrm = vid_which_vrm();
1286 /* 1285 /*
1287 Only fan 1-5 has their own input pins, 1286 Only fan 1-5 has their own input pins,
1288 Pwm 1-3 has their own pins 1287 Pwm 1-3 has their own pins
@@ -1293,7 +1292,9 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1293 val = w83793_read_value(client, W83793_REG_FANIN_CTRL); 1292 val = w83793_read_value(client, W83793_REG_FANIN_CTRL);
1294 1293
1295 /* check the function of pins 49-56 */ 1294 /* check the function of pins 49-56 */
1296 if (!(tmp & 0x80)) { 1295 if (tmp & 0x80) {
1296 data->has_vid |= 0x2; /* has VIDB */
1297 } else {
1297 data->has_pwm |= 0x18; /* pwm 4,5 */ 1298 data->has_pwm |= 0x18; /* pwm 4,5 */
1298 if (val & 0x01) { /* fan 6 */ 1299 if (val & 0x01) { /* fan 6 */
1299 data->has_fan |= 0x20; 1300 data->has_fan |= 0x20;
@@ -1309,13 +1310,15 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1309 } 1310 }
1310 } 1311 }
1311 1312
1313 /* check the function of pins 37-40 */
1314 if (!(tmp & 0x29))
1315 data->has_vid |= 0x1; /* has VIDA */
1312 if (0x08 == (tmp & 0x0c)) { 1316 if (0x08 == (tmp & 0x0c)) {
1313 if (val & 0x08) /* fan 9 */ 1317 if (val & 0x08) /* fan 9 */
1314 data->has_fan |= 0x100; 1318 data->has_fan |= 0x100;
1315 if (val & 0x10) /* fan 10 */ 1319 if (val & 0x10) /* fan 10 */
1316 data->has_fan |= 0x200; 1320 data->has_fan |= 0x200;
1317 } 1321 }
1318
1319 if (0x20 == (tmp & 0x30)) { 1322 if (0x20 == (tmp & 0x30)) {
1320 if (val & 0x20) /* fan 11 */ 1323 if (val & 0x20) /* fan 11 */
1321 data->has_fan |= 0x400; 1324 data->has_fan |= 0x400;
@@ -1359,13 +1362,6 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1359 if (tmp & 0x02) 1362 if (tmp & 0x02)
1360 data->has_temp |= 0x20; 1363 data->has_temp |= 0x20;
1361 1364
1362 /* Detect the VID usage and ignore unused input */
1363 tmp = w83793_read_value(client, W83793_REG_MFC);
1364 if (!(tmp & 0x29))
1365 data->has_vid |= 0x1; /* has VIDA */
1366 if (tmp & 0x80)
1367 data->has_vid |= 0x2; /* has VIDB */
1368
1369 /* Register sysfs hooks */ 1365 /* Register sysfs hooks */
1370 for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) { 1366 for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) {
1371 err = device_create_file(dev, 1367 err = device_create_file(dev,
@@ -1381,6 +1377,12 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1381 if (err) 1377 if (err)
1382 goto exit_remove; 1378 goto exit_remove;
1383 } 1379 }
1380 if (data->has_vid) {
1381 data->vrm = vid_which_vrm();
1382 err = device_create_file(dev, &dev_attr_vrm);
1383 if (err)
1384 goto exit_remove;
1385 }
1384 1386
1385 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { 1387 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) {
1386 err = device_create_file(dev, &sda_single_files[i].dev_attr); 1388 err = device_create_file(dev, &sda_single_files[i].dev_attr);
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 77f2d482888b..52e268e25dab 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -301,8 +301,8 @@ static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval)
301 msleep(i); 301 msleep(i);
302 } 302 }
303 303
304 dev_err(&client->dev, "Couldn't read value from register 0x%02x. " 304 dev_err(&client->dev, "Couldn't read value from register 0x%02x.\n",
305 "Please report.\n", reg); 305 reg);
306 return defval; 306 return defval;
307} 307}
308 308
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 877be9922c3d..15906d005b05 100644
--- a/drivers/isdn/hysdn/hysdn_procconf.c
+++ b/drivers/isdn/hysdn/hysdn_procconf.c
@@ -405,7 +405,8 @@ hysdn_procconf_init(void)
405 sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); 405 sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
406 if ((card->procconf = (void *) proc_create(conf_name, 406 if ((card->procconf = (void *) proc_create(conf_name,
407 S_IFREG | S_IRUGO | S_IWUSR, 407 S_IFREG | S_IRUGO | S_IWUSR,
408 hysdn_proc_entry)) != NULL) { 408 hysdn_proc_entry,
409 &conf_fops)) != NULL) {
409 hysdn_proclog_init(card); /* init the log file entry */ 410 hysdn_proclog_init(card); /* init the log file entry */
410 } 411 }
411 card = card->next; /* next entry */ 412 card = card->next; /* next entry */
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index d7a3ea88eddb..32a4f17d35fc 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -67,6 +67,10 @@
67#define FEC_MAX_PORTS 1 67#define FEC_MAX_PORTS 1
68#endif 68#endif
69 69
70#if defined(CONFIG_FADS) || defined(CONFIG_RPXCLASSIC) || defined(CONFIG_M5272)
71#define HAVE_mii_link_interrupt
72#endif
73
70/* 74/*
71 * Define the fixed address of the FEC hardware. 75 * Define the fixed address of the FEC hardware.
72 */ 76 */
@@ -205,7 +209,10 @@ struct fec_enet_private {
205 cbd_t *cur_rx, *cur_tx; /* The next free ring entry */ 209 cbd_t *cur_rx, *cur_tx; /* The next free ring entry */
206 cbd_t *dirty_tx; /* The ring entries to be free()ed. */ 210 cbd_t *dirty_tx; /* The ring entries to be free()ed. */
207 uint tx_full; 211 uint tx_full;
208 spinlock_t lock; 212 /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */
213 spinlock_t hw_lock;
214 /* hold while accessing the mii_list_t() elements */
215 spinlock_t mii_lock;
209 216
210 uint phy_id; 217 uint phy_id;
211 uint phy_id_done; 218 uint phy_id_done;
@@ -309,6 +316,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
309 volatile fec_t *fecp; 316 volatile fec_t *fecp;
310 volatile cbd_t *bdp; 317 volatile cbd_t *bdp;
311 unsigned short status; 318 unsigned short status;
319 unsigned long flags;
312 320
313 fep = netdev_priv(dev); 321 fep = netdev_priv(dev);
314 fecp = (volatile fec_t*)dev->base_addr; 322 fecp = (volatile fec_t*)dev->base_addr;
@@ -318,6 +326,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
318 return 1; 326 return 1;
319 } 327 }
320 328
329 spin_lock_irqsave(&fep->hw_lock, flags);
321 /* Fill in a Tx ring entry */ 330 /* Fill in a Tx ring entry */
322 bdp = fep->cur_tx; 331 bdp = fep->cur_tx;
323 332
@@ -328,6 +337,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
328 * This should not happen, since dev->tbusy should be set. 337 * This should not happen, since dev->tbusy should be set.
329 */ 338 */
330 printk("%s: tx queue full!.\n", dev->name); 339 printk("%s: tx queue full!.\n", dev->name);
340 spin_unlock_irqrestore(&fep->hw_lock, flags);
331 return 1; 341 return 1;
332 } 342 }
333#endif 343#endif
@@ -366,8 +376,6 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
366 flush_dcache_range((unsigned long)skb->data, 376 flush_dcache_range((unsigned long)skb->data,
367 (unsigned long)skb->data + skb->len); 377 (unsigned long)skb->data + skb->len);
368 378
369 spin_lock_irq(&fep->lock);
370
371 /* Send it on its way. Tell FEC it's ready, interrupt when done, 379 /* Send it on its way. Tell FEC it's ready, interrupt when done,
372 * it's the last BD of the frame, and to put the CRC on the end. 380 * it's the last BD of the frame, and to put the CRC on the end.
373 */ 381 */
@@ -396,7 +404,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
396 404
397 fep->cur_tx = (cbd_t *)bdp; 405 fep->cur_tx = (cbd_t *)bdp;
398 406
399 spin_unlock_irq(&fep->lock); 407 spin_unlock_irqrestore(&fep->hw_lock, flags);
400 408
401 return 0; 409 return 0;
402} 410}
@@ -454,19 +462,20 @@ fec_enet_interrupt(int irq, void * dev_id)
454 struct net_device *dev = dev_id; 462 struct net_device *dev = dev_id;
455 volatile fec_t *fecp; 463 volatile fec_t *fecp;
456 uint int_events; 464 uint int_events;
457 int handled = 0; 465 irqreturn_t ret = IRQ_NONE;
458 466
459 fecp = (volatile fec_t*)dev->base_addr; 467 fecp = (volatile fec_t*)dev->base_addr;
460 468
461 /* Get the interrupt events that caused us to be here. 469 /* Get the interrupt events that caused us to be here.
462 */ 470 */
463 while ((int_events = fecp->fec_ievent) != 0) { 471 do {
472 int_events = fecp->fec_ievent;
464 fecp->fec_ievent = int_events; 473 fecp->fec_ievent = int_events;
465 474
466 /* Handle receive event in its own function. 475 /* Handle receive event in its own function.
467 */ 476 */
468 if (int_events & FEC_ENET_RXF) { 477 if (int_events & FEC_ENET_RXF) {
469 handled = 1; 478 ret = IRQ_HANDLED;
470 fec_enet_rx(dev); 479 fec_enet_rx(dev);
471 } 480 }
472 481
@@ -475,17 +484,18 @@ fec_enet_interrupt(int irq, void * dev_id)
475 them as part of the transmit process. 484 them as part of the transmit process.
476 */ 485 */
477 if (int_events & FEC_ENET_TXF) { 486 if (int_events & FEC_ENET_TXF) {
478 handled = 1; 487 ret = IRQ_HANDLED;
479 fec_enet_tx(dev); 488 fec_enet_tx(dev);
480 } 489 }
481 490
482 if (int_events & FEC_ENET_MII) { 491 if (int_events & FEC_ENET_MII) {
483 handled = 1; 492 ret = IRQ_HANDLED;
484 fec_enet_mii(dev); 493 fec_enet_mii(dev);
485 } 494 }
486 495
487 } 496 } while (int_events);
488 return IRQ_RETVAL(handled); 497
498 return ret;
489} 499}
490 500
491 501
@@ -498,7 +508,7 @@ fec_enet_tx(struct net_device *dev)
498 struct sk_buff *skb; 508 struct sk_buff *skb;
499 509
500 fep = netdev_priv(dev); 510 fep = netdev_priv(dev);
501 spin_lock(&fep->lock); 511 spin_lock_irq(&fep->hw_lock);
502 bdp = fep->dirty_tx; 512 bdp = fep->dirty_tx;
503 513
504 while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) { 514 while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) {
@@ -557,7 +567,7 @@ fec_enet_tx(struct net_device *dev)
557 } 567 }
558 } 568 }
559 fep->dirty_tx = (cbd_t *)bdp; 569 fep->dirty_tx = (cbd_t *)bdp;
560 spin_unlock(&fep->lock); 570 spin_unlock_irq(&fep->hw_lock);
561} 571}
562 572
563 573
@@ -584,6 +594,8 @@ fec_enet_rx(struct net_device *dev)
584 fep = netdev_priv(dev); 594 fep = netdev_priv(dev);
585 fecp = (volatile fec_t*)dev->base_addr; 595 fecp = (volatile fec_t*)dev->base_addr;
586 596
597 spin_lock_irq(&fep->hw_lock);
598
587 /* First, grab all of the stats for the incoming packet. 599 /* First, grab all of the stats for the incoming packet.
588 * These get messed up if we get called due to a busy condition. 600 * These get messed up if we get called due to a busy condition.
589 */ 601 */
@@ -689,6 +701,8 @@ while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) {
689 */ 701 */
690 fecp->fec_r_des_active = 0; 702 fecp->fec_r_des_active = 0;
691#endif 703#endif
704
705 spin_unlock_irq(&fep->hw_lock);
692} 706}
693 707
694 708
@@ -702,11 +716,11 @@ fec_enet_mii(struct net_device *dev)
702 uint mii_reg; 716 uint mii_reg;
703 717
704 fep = netdev_priv(dev); 718 fep = netdev_priv(dev);
719 spin_lock_irq(&fep->mii_lock);
720
705 ep = fep->hwp; 721 ep = fep->hwp;
706 mii_reg = ep->fec_mii_data; 722 mii_reg = ep->fec_mii_data;
707 723
708 spin_lock(&fep->lock);
709
710 if ((mip = mii_head) == NULL) { 724 if ((mip = mii_head) == NULL) {
711 printk("MII and no head!\n"); 725 printk("MII and no head!\n");
712 goto unlock; 726 goto unlock;
@@ -723,7 +737,7 @@ fec_enet_mii(struct net_device *dev)
723 ep->fec_mii_data = mip->mii_regval; 737 ep->fec_mii_data = mip->mii_regval;
724 738
725unlock: 739unlock:
726 spin_unlock(&fep->lock); 740 spin_unlock_irq(&fep->mii_lock);
727} 741}
728 742
729static int 743static int
@@ -737,12 +751,11 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
737 /* Add PHY address to register command. 751 /* Add PHY address to register command.
738 */ 752 */
739 fep = netdev_priv(dev); 753 fep = netdev_priv(dev);
740 regval |= fep->phy_addr << 23; 754 spin_lock_irqsave(&fep->mii_lock, flags);
741 755
756 regval |= fep->phy_addr << 23;
742 retval = 0; 757 retval = 0;
743 758
744 spin_lock_irqsave(&fep->lock,flags);
745
746 if ((mip = mii_free) != NULL) { 759 if ((mip = mii_free) != NULL) {
747 mii_free = mip->mii_next; 760 mii_free = mip->mii_next;
748 mip->mii_regval = regval; 761 mip->mii_regval = regval;
@@ -759,9 +772,8 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
759 retval = 1; 772 retval = 1;
760 } 773 }
761 774
762 spin_unlock_irqrestore(&fep->lock,flags); 775 spin_unlock_irqrestore(&fep->mii_lock, flags);
763 776 return retval;
764 return(retval);
765} 777}
766 778
767static void mii_do_cmd(struct net_device *dev, const phy_cmd_t *c) 779static void mii_do_cmd(struct net_device *dev, const phy_cmd_t *c)
@@ -1222,7 +1234,7 @@ static phy_info_t const * const phy_info[] = {
1222}; 1234};
1223 1235
1224/* ------------------------------------------------------------------------- */ 1236/* ------------------------------------------------------------------------- */
1225#if !defined(CONFIG_M532x) 1237#ifdef HAVE_mii_link_interrupt
1226#ifdef CONFIG_RPXCLASSIC 1238#ifdef CONFIG_RPXCLASSIC
1227static void 1239static void
1228mii_link_interrupt(void *dev_id); 1240mii_link_interrupt(void *dev_id);
@@ -1362,18 +1374,8 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1362 unsigned short irq; 1374 unsigned short irq;
1363 } *idp, id[] = { 1375 } *idp, id[] = {
1364 { "fec(TXF)", 23 }, 1376 { "fec(TXF)", 23 },
1365 { "fec(TXB)", 24 },
1366 { "fec(TXFIFO)", 25 },
1367 { "fec(TXCR)", 26 },
1368 { "fec(RXF)", 27 }, 1377 { "fec(RXF)", 27 },
1369 { "fec(RXB)", 28 },
1370 { "fec(MII)", 29 }, 1378 { "fec(MII)", 29 },
1371 { "fec(LC)", 30 },
1372 { "fec(HBERR)", 31 },
1373 { "fec(GRA)", 32 },
1374 { "fec(EBERR)", 33 },
1375 { "fec(BABT)", 34 },
1376 { "fec(BABR)", 35 },
1377 { NULL }, 1379 { NULL },
1378 }; 1380 };
1379 1381
@@ -1533,18 +1535,8 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1533 unsigned short irq; 1535 unsigned short irq;
1534 } *idp, id[] = { 1536 } *idp, id[] = {
1535 { "fec(TXF)", 23 }, 1537 { "fec(TXF)", 23 },
1536 { "fec(TXB)", 24 },
1537 { "fec(TXFIFO)", 25 },
1538 { "fec(TXCR)", 26 },
1539 { "fec(RXF)", 27 }, 1538 { "fec(RXF)", 27 },
1540 { "fec(RXB)", 28 },
1541 { "fec(MII)", 29 }, 1539 { "fec(MII)", 29 },
1542 { "fec(LC)", 30 },
1543 { "fec(HBERR)", 31 },
1544 { "fec(GRA)", 32 },
1545 { "fec(EBERR)", 33 },
1546 { "fec(BABT)", 34 },
1547 { "fec(BABR)", 35 },
1548 { NULL }, 1540 { NULL },
1549 }; 1541 };
1550 1542
@@ -1660,18 +1652,8 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1660 unsigned short irq; 1652 unsigned short irq;
1661 } *idp, id[] = { 1653 } *idp, id[] = {
1662 { "fec(TXF)", 36 }, 1654 { "fec(TXF)", 36 },
1663 { "fec(TXB)", 37 },
1664 { "fec(TXFIFO)", 38 },
1665 { "fec(TXCR)", 39 },
1666 { "fec(RXF)", 40 }, 1655 { "fec(RXF)", 40 },
1667 { "fec(RXB)", 41 },
1668 { "fec(MII)", 42 }, 1656 { "fec(MII)", 42 },
1669 { "fec(LC)", 43 },
1670 { "fec(HBERR)", 44 },
1671 { "fec(GRA)", 45 },
1672 { "fec(EBERR)", 46 },
1673 { "fec(BABT)", 47 },
1674 { "fec(BABR)", 48 },
1675 { NULL }, 1657 { NULL },
1676 }; 1658 };
1677 1659
@@ -2126,6 +2108,7 @@ mii_discover_phy(uint mii_reg, struct net_device *dev)
2126 2108
2127/* This interrupt occurs when the PHY detects a link change. 2109/* This interrupt occurs when the PHY detects a link change.
2128*/ 2110*/
2111#ifdef HAVE_mii_link_interrupt
2129#ifdef CONFIG_RPXCLASSIC 2112#ifdef CONFIG_RPXCLASSIC
2130static void 2113static void
2131mii_link_interrupt(void *dev_id) 2114mii_link_interrupt(void *dev_id)
@@ -2148,6 +2131,7 @@ mii_link_interrupt(int irq, void * dev_id)
2148 2131
2149 return IRQ_HANDLED; 2132 return IRQ_HANDLED;
2150} 2133}
2134#endif
2151 2135
2152static int 2136static int
2153fec_enet_open(struct net_device *dev) 2137fec_enet_open(struct net_device *dev)
@@ -2243,13 +2227,13 @@ static void set_multicast_list(struct net_device *dev)
2243 /* Catch all multicast addresses, so set the 2227 /* Catch all multicast addresses, so set the
2244 * filter to all 1's. 2228 * filter to all 1's.
2245 */ 2229 */
2246 ep->fec_hash_table_high = 0xffffffff; 2230 ep->fec_grp_hash_table_high = 0xffffffff;
2247 ep->fec_hash_table_low = 0xffffffff; 2231 ep->fec_grp_hash_table_low = 0xffffffff;
2248 } else { 2232 } else {
2249 /* Clear filter and add the addresses in hash register. 2233 /* Clear filter and add the addresses in hash register.
2250 */ 2234 */
2251 ep->fec_hash_table_high = 0; 2235 ep->fec_grp_hash_table_high = 0;
2252 ep->fec_hash_table_low = 0; 2236 ep->fec_grp_hash_table_low = 0;
2253 2237
2254 dmi = dev->mc_list; 2238 dmi = dev->mc_list;
2255 2239
@@ -2280,9 +2264,9 @@ static void set_multicast_list(struct net_device *dev)
2280 hash = (crc >> (32 - HASH_BITS)) & 0x3f; 2264 hash = (crc >> (32 - HASH_BITS)) & 0x3f;
2281 2265
2282 if (hash > 31) 2266 if (hash > 31)
2283 ep->fec_hash_table_high |= 1 << (hash - 32); 2267 ep->fec_grp_hash_table_high |= 1 << (hash - 32);
2284 else 2268 else
2285 ep->fec_hash_table_low |= 1 << hash; 2269 ep->fec_grp_hash_table_low |= 1 << hash;
2286 } 2270 }
2287 } 2271 }
2288 } 2272 }
@@ -2332,6 +2316,9 @@ int __init fec_enet_init(struct net_device *dev)
2332 return -ENOMEM; 2316 return -ENOMEM;
2333 } 2317 }
2334 2318
2319 spin_lock_init(&fep->hw_lock);
2320 spin_lock_init(&fep->mii_lock);
2321
2335 /* Create an Ethernet device instance. 2322 /* Create an Ethernet device instance.
2336 */ 2323 */
2337 fecp = (volatile fec_t *) fec_hw[index]; 2324 fecp = (volatile fec_t *) fec_hw[index];
@@ -2430,11 +2417,15 @@ int __init fec_enet_init(struct net_device *dev)
2430 */ 2417 */
2431 fec_request_intrs(dev); 2418 fec_request_intrs(dev);
2432 2419
2433 fecp->fec_hash_table_high = 0; 2420 fecp->fec_grp_hash_table_high = 0;
2434 fecp->fec_hash_table_low = 0; 2421 fecp->fec_grp_hash_table_low = 0;
2435 fecp->fec_r_buff_size = PKT_MAXBLR_SIZE; 2422 fecp->fec_r_buff_size = PKT_MAXBLR_SIZE;
2436 fecp->fec_ecntrl = 2; 2423 fecp->fec_ecntrl = 2;
2437 fecp->fec_r_des_active = 0; 2424 fecp->fec_r_des_active = 0;
2425#ifndef CONFIG_M5272
2426 fecp->fec_hash_table_high = 0;
2427 fecp->fec_hash_table_low = 0;
2428#endif
2438 2429
2439 dev->base_addr = (unsigned long)fecp; 2430 dev->base_addr = (unsigned long)fecp;
2440 2431
@@ -2455,8 +2446,7 @@ int __init fec_enet_init(struct net_device *dev)
2455 2446
2456 /* Clear and enable interrupts */ 2447 /* Clear and enable interrupts */
2457 fecp->fec_ievent = 0xffc00000; 2448 fecp->fec_ievent = 0xffc00000;
2458 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB | 2449 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII);
2459 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2460 2450
2461 /* Queue up command to detect the PHY and initialize the 2451 /* Queue up command to detect the PHY and initialize the
2462 * remainder of the interface. 2452 * remainder of the interface.
@@ -2500,8 +2490,8 @@ fec_restart(struct net_device *dev, int duplex)
2500 2490
2501 /* Reset all multicast. 2491 /* Reset all multicast.
2502 */ 2492 */
2503 fecp->fec_hash_table_high = 0; 2493 fecp->fec_grp_hash_table_high = 0;
2504 fecp->fec_hash_table_low = 0; 2494 fecp->fec_grp_hash_table_low = 0;
2505 2495
2506 /* Set maximum receive buffer size. 2496 /* Set maximum receive buffer size.
2507 */ 2497 */
@@ -2583,8 +2573,7 @@ fec_restart(struct net_device *dev, int duplex)
2583 2573
2584 /* Enable interrupts we wish to service. 2574 /* Enable interrupts we wish to service.
2585 */ 2575 */
2586 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB | 2576 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII);
2587 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2588} 2577}
2589 2578
2590static void 2579static void
@@ -2624,7 +2613,7 @@ fec_stop(struct net_device *dev)
2624static int __init fec_enet_module_init(void) 2613static int __init fec_enet_module_init(void)
2625{ 2614{
2626 struct net_device *dev; 2615 struct net_device *dev;
2627 int i, j, err; 2616 int i, err;
2628 DECLARE_MAC_BUF(mac); 2617 DECLARE_MAC_BUF(mac);
2629 2618
2630 printk("FEC ENET Version 0.2\n"); 2619 printk("FEC ENET Version 0.2\n");
diff --git a/drivers/net/fec.h b/drivers/net/fec.h
index 1d421606984f..292719daceff 100644
--- a/drivers/net/fec.h
+++ b/drivers/net/fec.h
@@ -88,8 +88,8 @@ typedef struct fec {
88 unsigned long fec_reserved7[158]; 88 unsigned long fec_reserved7[158];
89 unsigned long fec_addr_low; /* Low 32bits MAC address */ 89 unsigned long fec_addr_low; /* Low 32bits MAC address */
90 unsigned long fec_addr_high; /* High 16bits MAC address */ 90 unsigned long fec_addr_high; /* High 16bits MAC address */
91 unsigned long fec_hash_table_high; /* High 32bits hash table */ 91 unsigned long fec_grp_hash_table_high;/* High 32bits hash table */
92 unsigned long fec_hash_table_low; /* Low 32bits hash table */ 92 unsigned long fec_grp_hash_table_low; /* Low 32bits hash table */
93 unsigned long fec_r_des_start; /* Receive descriptor ring */ 93 unsigned long fec_r_des_start; /* Receive descriptor ring */
94 unsigned long fec_x_des_start; /* Transmit descriptor ring */ 94 unsigned long fec_x_des_start; /* Transmit descriptor ring */
95 unsigned long fec_r_buff_size; /* Maximum receive buff size */ 95 unsigned long fec_r_buff_size; /* Maximum receive buff size */
diff --git a/drivers/pcmcia/au1000_db1x00.c b/drivers/pcmcia/au1000_db1x00.c
index 74e051535d6c..c78d77fd7e3b 100644
--- a/drivers/pcmcia/au1000_db1x00.c
+++ b/drivers/pcmcia/au1000_db1x00.c
@@ -194,7 +194,7 @@ db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_s
194 default: 194 default:
195 pwr |= SET_VCC_VPP(0,0,sock); 195 pwr |= SET_VCC_VPP(0,0,sock);
196 printk("%s: bad Vcc/Vpp (%d:%d)\n", 196 printk("%s: bad Vcc/Vpp (%d:%d)\n",
197 __FUNCTION__, 197 __func__,
198 state->Vcc, 198 state->Vcc,
199 state->Vpp); 199 state->Vpp);
200 break; 200 break;
@@ -215,7 +215,7 @@ db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_s
215 default: 215 default:
216 pwr |= SET_VCC_VPP(0,0,sock); 216 pwr |= SET_VCC_VPP(0,0,sock);
217 printk("%s: bad Vcc/Vpp (%d:%d)\n", 217 printk("%s: bad Vcc/Vpp (%d:%d)\n",
218 __FUNCTION__, 218 __func__,
219 state->Vcc, 219 state->Vcc,
220 state->Vpp); 220 state->Vpp);
221 break; 221 break;
@@ -224,7 +224,7 @@ db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_s
224 default: /* what's this ? */ 224 default: /* what's this ? */
225 pwr |= SET_VCC_VPP(0,0,sock); 225 pwr |= SET_VCC_VPP(0,0,sock);
226 printk(KERN_ERR "%s: bad Vcc %d\n", 226 printk(KERN_ERR "%s: bad Vcc %d\n",
227 __FUNCTION__, state->Vcc); 227 __func__, state->Vcc);
228 break; 228 break;
229 } 229 }
230 230
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index b693367d38cd..75e8f8505e47 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -41,6 +41,7 @@
41#include <linux/notifier.h> 41#include <linux/notifier.h>
42#include <linux/interrupt.h> 42#include <linux/interrupt.h>
43#include <linux/spinlock.h> 43#include <linux/spinlock.h>
44#include <linux/mutex.h>
44#include <linux/platform_device.h> 45#include <linux/platform_device.h>
45 46
46#include <asm/io.h> 47#include <asm/io.h>
@@ -71,7 +72,7 @@ extern struct au1000_pcmcia_socket au1000_pcmcia_socket[];
71u32 *pcmcia_base_vaddrs[2]; 72u32 *pcmcia_base_vaddrs[2];
72extern const unsigned long mips_io_port_base; 73extern const unsigned long mips_io_port_base;
73 74
74DECLARE_MUTEX(pcmcia_sockets_lock); 75static DEFINE_MUTEX(pcmcia_sockets_lock);
75 76
76static int (*au1x00_pcmcia_hw_init[])(struct device *dev) = { 77static int (*au1x00_pcmcia_hw_init[])(struct device *dev) = {
77 au1x_board_init, 78 au1x_board_init,
@@ -472,7 +473,7 @@ int au1x00_drv_pcmcia_remove(struct device *dev)
472 struct skt_dev_info *sinfo = dev_get_drvdata(dev); 473 struct skt_dev_info *sinfo = dev_get_drvdata(dev);
473 int i; 474 int i;
474 475
475 down(&pcmcia_sockets_lock); 476 mutex_lock(&pcmcia_sockets_lock);
476 dev_set_drvdata(dev, NULL); 477 dev_set_drvdata(dev, NULL);
477 478
478 for (i = 0; i < sinfo->nskt; i++) { 479 for (i = 0; i < sinfo->nskt; i++) {
@@ -488,7 +489,7 @@ int au1x00_drv_pcmcia_remove(struct device *dev)
488 } 489 }
489 490
490 kfree(sinfo); 491 kfree(sinfo);
491 up(&pcmcia_sockets_lock); 492 mutex_unlock(&pcmcia_sockets_lock);
492 return 0; 493 return 0;
493} 494}
494 495
@@ -501,13 +502,13 @@ static int au1x00_drv_pcmcia_probe(struct device *dev)
501{ 502{
502 int i, ret = -ENODEV; 503 int i, ret = -ENODEV;
503 504
504 down(&pcmcia_sockets_lock); 505 mutex_lock(&pcmcia_sockets_lock);
505 for (i=0; i < ARRAY_SIZE(au1x00_pcmcia_hw_init); i++) { 506 for (i=0; i < ARRAY_SIZE(au1x00_pcmcia_hw_init); i++) {
506 ret = au1x00_pcmcia_hw_init[i](dev); 507 ret = au1x00_pcmcia_hw_init[i](dev);
507 if (ret == 0) 508 if (ret == 0)
508 break; 509 break;
509 } 510 }
510 up(&pcmcia_sockets_lock); 511 mutex_unlock(&pcmcia_sockets_lock);
511 return ret; 512 return ret;
512} 513}
513 514
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c
index 86c0808d6a05..157e41423a0a 100644
--- a/drivers/pcmcia/au1000_pb1x00.c
+++ b/drivers/pcmcia/au1000_pb1x00.c
@@ -244,7 +244,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure)
244 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, 244 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,
245 configure->sock); 245 configure->sock);
246 printk("%s: bad Vcc/Vpp (%d:%d)\n", 246 printk("%s: bad Vcc/Vpp (%d:%d)\n",
247 __FUNCTION__, 247 __func__,
248 configure->vcc, 248 configure->vcc,
249 configure->vpp); 249 configure->vpp);
250 break; 250 break;
@@ -272,7 +272,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure)
272 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, 272 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,
273 configure->sock); 273 configure->sock);
274 printk("%s: bad Vcc/Vpp (%d:%d)\n", 274 printk("%s: bad Vcc/Vpp (%d:%d)\n",
275 __FUNCTION__, 275 __func__,
276 configure->vcc, 276 configure->vcc,
277 configure->vpp); 277 configure->vpp);
278 break; 278 break;
@@ -300,7 +300,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure)
300 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, 300 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,
301 configure->sock); 301 configure->sock);
302 printk("%s: bad Vcc/Vpp (%d:%d)\n", 302 printk("%s: bad Vcc/Vpp (%d:%d)\n",
303 __FUNCTION__, 303 __func__,
304 configure->vcc, 304 configure->vcc,
305 configure->vpp); 305 configure->vpp);
306 break; 306 break;
@@ -309,7 +309,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure)
309 default: /* what's this ? */ 309 default: /* what's this ? */
310 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,configure->sock); 310 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,configure->sock);
311 printk(KERN_ERR "%s: bad Vcc %d\n", 311 printk(KERN_ERR "%s: bad Vcc %d\n",
312 __FUNCTION__, configure->vcc); 312 __func__, configure->vcc);
313 break; 313 break;
314 } 314 }
315 315
@@ -353,7 +353,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure)
353 default: 353 default:
354 pcr |= SET_VCC_VPP(0,0); 354 pcr |= SET_VCC_VPP(0,0);
355 printk("%s: bad Vcc/Vpp (%d:%d)\n", 355 printk("%s: bad Vcc/Vpp (%d:%d)\n",
356 __FUNCTION__, 356 __func__,
357 configure->vcc, 357 configure->vcc,
358 configure->vpp); 358 configure->vpp);
359 break; 359 break;
@@ -374,7 +374,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure)
374 default: 374 default:
375 pcr |= SET_VCC_VPP(0,0); 375 pcr |= SET_VCC_VPP(0,0);
376 printk("%s: bad Vcc/Vpp (%d:%d)\n", 376 printk("%s: bad Vcc/Vpp (%d:%d)\n",
377 __FUNCTION__, 377 __func__,
378 configure->vcc, 378 configure->vcc,
379 configure->vpp); 379 configure->vpp);
380 break; 380 break;
@@ -383,7 +383,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure)
383 default: /* what's this ? */ 383 default: /* what's this ? */
384 pcr |= SET_VCC_VPP(0,0); 384 pcr |= SET_VCC_VPP(0,0);
385 printk(KERN_ERR "%s: bad Vcc %d\n", 385 printk(KERN_ERR "%s: bad Vcc %d\n",
386 __FUNCTION__, configure->vcc); 386 __func__, configure->vcc);
387 break; 387 break;
388 } 388 }
389 389
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c
index ce9d5c44a7b5..c78ed5347510 100644
--- a/drivers/pcmcia/au1000_xxs1500.c
+++ b/drivers/pcmcia/au1000_xxs1500.c
@@ -56,7 +56,7 @@
56#define PCMCIA_IRQ AU1000_GPIO_4 56#define PCMCIA_IRQ AU1000_GPIO_4
57 57
58#if 0 58#if 0
59#define DEBUG(x,args...) printk(__FUNCTION__ ": " x,##args) 59#define DEBUG(x, args...) printk(__func__ ": " x, ##args)
60#else 60#else
61#define DEBUG(x,args...) 61#define DEBUG(x,args...)
62#endif 62#endif
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index 714baaeb6da1..fb2f38dc92c5 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -209,7 +209,7 @@ static void cardbus_assign_irqs(struct pci_bus *bus, int irq)
209 } 209 }
210} 210}
211 211
212int cb_alloc(struct pcmcia_socket * s) 212int __ref cb_alloc(struct pcmcia_socket * s)
213{ 213{
214 struct pci_bus *bus = s->cb_dev->subordinate; 214 struct pci_bus *bus = s->cb_dev->subordinate;
215 struct pci_dev *dev; 215 struct pci_dev *dev;
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 5a85871f5ee9..e40775443d04 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1520,7 +1520,7 @@ static void pcmcia_bus_remove_socket(struct device *dev,
1520 1520
1521 1521
1522/* the pcmcia_bus_interface is used to handle pcmcia socket devices */ 1522/* the pcmcia_bus_interface is used to handle pcmcia socket devices */
1523static struct class_interface pcmcia_bus_interface = { 1523static struct class_interface pcmcia_bus_interface __refdata = {
1524 .class = &pcmcia_socket_class, 1524 .class = &pcmcia_socket_class,
1525 .add_dev = &pcmcia_bus_add_socket, 1525 .add_dev = &pcmcia_bus_add_socket,
1526 .remove_dev = &pcmcia_bus_remove_socket, 1526 .remove_dev = &pcmcia_bus_remove_socket,
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index e54ecc580d9e..e13618656ff7 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -53,7 +53,7 @@ static int i82092aa_socket_resume (struct pci_dev *dev)
53} 53}
54#endif 54#endif
55 55
56static struct pci_driver i82092aa_pci_drv = { 56static struct pci_driver i82092aa_pci_driver = {
57 .name = "i82092aa", 57 .name = "i82092aa",
58 .id_table = i82092aa_pci_ids, 58 .id_table = i82092aa_pci_ids,
59 .probe = i82092aa_pci_probe, 59 .probe = i82092aa_pci_probe,
@@ -714,13 +714,13 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
714 714
715static int i82092aa_module_init(void) 715static int i82092aa_module_init(void)
716{ 716{
717 return pci_register_driver(&i82092aa_pci_drv); 717 return pci_register_driver(&i82092aa_pci_driver);
718} 718}
719 719
720static void i82092aa_module_exit(void) 720static void i82092aa_module_exit(void)
721{ 721{
722 enter("i82092aa_module_exit"); 722 enter("i82092aa_module_exit");
723 pci_unregister_driver(&i82092aa_pci_drv); 723 pci_unregister_driver(&i82092aa_pci_driver);
724 if (sockets[0].io_base>0) 724 if (sockets[0].io_base>0)
725 release_region(sockets[0].io_base, 2); 725 release_region(sockets[0].io_base, 2);
726 leave("i82092aa_module_exit"); 726 leave("i82092aa_module_exit");
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index bb6db3a582b2..46314b420765 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -153,7 +153,7 @@ omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
153 153
154static int omap_cf_ss_suspend(struct pcmcia_socket *s) 154static int omap_cf_ss_suspend(struct pcmcia_socket *s)
155{ 155{
156 pr_debug("%s: %s\n", driver_name, __FUNCTION__); 156 pr_debug("%s: %s\n", driver_name, __func__);
157 return omap_cf_set_socket(s, &dead_socket); 157 return omap_cf_set_socket(s, &dead_socket);
158} 158}
159 159
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index abc10fe49bd8..8bed1dab9039 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -778,7 +778,7 @@ static struct pci_device_id pd6729_pci_ids[] = {
778}; 778};
779MODULE_DEVICE_TABLE(pci, pd6729_pci_ids); 779MODULE_DEVICE_TABLE(pci, pd6729_pci_ids);
780 780
781static struct pci_driver pd6729_pci_drv = { 781static struct pci_driver pd6729_pci_driver = {
782 .name = "pd6729", 782 .name = "pd6729",
783 .id_table = pd6729_pci_ids, 783 .id_table = pd6729_pci_ids,
784 .probe = pd6729_pci_probe, 784 .probe = pd6729_pci_probe,
@@ -791,12 +791,12 @@ static struct pci_driver pd6729_pci_drv = {
791 791
792static int pd6729_module_init(void) 792static int pd6729_module_init(void)
793{ 793{
794 return pci_register_driver(&pd6729_pci_drv); 794 return pci_register_driver(&pd6729_pci_driver);
795} 795}
796 796
797static void pd6729_module_exit(void) 797static void pd6729_module_exit(void)
798{ 798{
799 pci_unregister_driver(&pd6729_pci_drv); 799 pci_unregister_driver(&pd6729_pci_driver);
800} 800}
801 801
802module_init(pd6729_module_init); 802module_init(pd6729_module_init);
diff --git a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c
index 4a05802213c8..881ec8a8e389 100644
--- a/drivers/pcmcia/pxa2xx_lubbock.c
+++ b/drivers/pcmcia/pxa2xx_lubbock.c
@@ -87,7 +87,7 @@ lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
87 87
88 default: 88 default:
89 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", 89 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
90 __FUNCTION__, state->Vcc); 90 __func__, state->Vcc);
91 ret = -1; 91 ret = -1;
92 } 92 }
93 93
@@ -104,7 +104,7 @@ lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
104 pa_dwr_set |= GPIO_A0; 104 pa_dwr_set |= GPIO_A0;
105 else { 105 else {
106 printk(KERN_ERR "%s(): unrecognized Vpp %u\n", 106 printk(KERN_ERR "%s(): unrecognized Vpp %u\n",
107 __FUNCTION__, state->Vpp); 107 __func__, state->Vpp);
108 ret = -1; 108 ret = -1;
109 break; 109 break;
110 } 110 }
@@ -128,14 +128,14 @@ lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
128 128
129 default: 129 default:
130 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", 130 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
131 __FUNCTION__, state->Vcc); 131 __func__, state->Vcc);
132 ret = -1; 132 ret = -1;
133 break; 133 break;
134 } 134 }
135 135
136 if (state->Vpp != state->Vcc && state->Vpp != 0) { 136 if (state->Vpp != state->Vcc && state->Vpp != 0) {
137 printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n", 137 printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n",
138 __FUNCTION__, state->Vpp); 138 __func__, state->Vpp);
139 ret = -1; 139 ret = -1;
140 break; 140 break;
141 } 141 }
diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c
index 6fa5eaaab8af..145b85e0f02c 100644
--- a/drivers/pcmcia/pxa2xx_mainstone.c
+++ b/drivers/pcmcia/pxa2xx_mainstone.c
@@ -99,7 +99,7 @@ static int mst_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
99 case 50: power |= MST_PCMCIA_PWR_VCC_50; break; 99 case 50: power |= MST_PCMCIA_PWR_VCC_50; break;
100 default: 100 default:
101 printk(KERN_ERR "%s(): bad Vcc %u\n", 101 printk(KERN_ERR "%s(): bad Vcc %u\n",
102 __FUNCTION__, state->Vcc); 102 __func__, state->Vcc);
103 ret = -1; 103 ret = -1;
104 } 104 }
105 105
@@ -111,7 +111,7 @@ static int mst_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
111 power |= MST_PCMCIA_PWR_VPP_VCC; 111 power |= MST_PCMCIA_PWR_VPP_VCC;
112 } else { 112 } else {
113 printk(KERN_ERR "%s(): bad Vpp %u\n", 113 printk(KERN_ERR "%s(): bad Vpp %u\n",
114 __FUNCTION__, state->Vpp); 114 __func__, state->Vpp);
115 ret = -1; 115 ret = -1;
116 } 116 }
117 } 117 }
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index a8d100707721..0fcf763b9175 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -1045,7 +1045,7 @@ static void __devexit pccard_sysfs_remove_rsrc(struct device *dev,
1045 device_remove_file(dev, *attr); 1045 device_remove_file(dev, *attr);
1046} 1046}
1047 1047
1048static struct class_interface pccard_rsrc_interface = { 1048static struct class_interface pccard_rsrc_interface __refdata = {
1049 .class = &pcmcia_socket_class, 1049 .class = &pcmcia_socket_class,
1050 .add_dev = &pccard_sysfs_add_rsrc, 1050 .add_dev = &pccard_sysfs_add_rsrc,
1051 .remove_dev = __devexit_p(&pccard_sysfs_remove_rsrc), 1051 .remove_dev = __devexit_p(&pccard_sysfs_remove_rsrc),
diff --git a/drivers/pcmcia/sa1100_assabet.c b/drivers/pcmcia/sa1100_assabet.c
index 7c57fdd3c8d7..ce133ce81c10 100644
--- a/drivers/pcmcia/sa1100_assabet.c
+++ b/drivers/pcmcia/sa1100_assabet.c
@@ -66,14 +66,14 @@ assabet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_stat
66 66
67 case 50: 67 case 50:
68 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n", 68 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
69 __FUNCTION__); 69 __func__);
70 70
71 case 33: /* Can only apply 3.3V to the CF slot. */ 71 case 33: /* Can only apply 3.3V to the CF slot. */
72 mask = ASSABET_BCR_CF_PWR; 72 mask = ASSABET_BCR_CF_PWR;
73 break; 73 break;
74 74
75 default: 75 default:
76 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__, 76 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __func__,
77 state->Vcc); 77 state->Vcc);
78 return -1; 78 return -1;
79 } 79 }
diff --git a/drivers/pcmcia/sa1100_badge4.c b/drivers/pcmcia/sa1100_badge4.c
index 62bfc7566ec2..607c3f326eca 100644
--- a/drivers/pcmcia/sa1100_badge4.c
+++ b/drivers/pcmcia/sa1100_badge4.c
@@ -82,14 +82,14 @@ badge4_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state
82 case 0: 82 case 0:
83 if ((state->Vcc != 0) && 83 if ((state->Vcc != 0) &&
84 (state->Vcc != badge4_pcmvcc)) { 84 (state->Vcc != badge4_pcmvcc)) {
85 complain_about_jumpering(__FUNCTION__, "pcmvcc", 85 complain_about_jumpering(__func__, "pcmvcc",
86 badge4_pcmvcc, state->Vcc); 86 badge4_pcmvcc, state->Vcc);
87 // Apply power regardless of the jumpering. 87 // Apply power regardless of the jumpering.
88 // return -1; 88 // return -1;
89 } 89 }
90 if ((state->Vpp != 0) && 90 if ((state->Vpp != 0) &&
91 (state->Vpp != badge4_pcmvpp)) { 91 (state->Vpp != badge4_pcmvpp)) {
92 complain_about_jumpering(__FUNCTION__, "pcmvpp", 92 complain_about_jumpering(__func__, "pcmvpp",
93 badge4_pcmvpp, state->Vpp); 93 badge4_pcmvpp, state->Vpp);
94 return -1; 94 return -1;
95 } 95 }
@@ -98,7 +98,7 @@ badge4_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state
98 case 1: 98 case 1:
99 if ((state->Vcc != 0) && 99 if ((state->Vcc != 0) &&
100 (state->Vcc != badge4_cfvcc)) { 100 (state->Vcc != badge4_cfvcc)) {
101 complain_about_jumpering(__FUNCTION__, "cfvcc", 101 complain_about_jumpering(__func__, "cfvcc",
102 badge4_cfvcc, state->Vcc); 102 badge4_cfvcc, state->Vcc);
103 return -1; 103 return -1;
104 } 104 }
@@ -143,7 +143,7 @@ int pcmcia_badge4_init(struct device *dev)
143 if (machine_is_badge4()) { 143 if (machine_is_badge4()) {
144 printk(KERN_INFO 144 printk(KERN_INFO
145 "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n", 145 "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n",
146 __FUNCTION__, 146 __func__,
147 badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc); 147 badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc);
148 148
149 ret = sa11xx_drv_pcmcia_probe(dev, &badge4_pcmcia_ops, 0, 2); 149 ret = sa11xx_drv_pcmcia_probe(dev, &badge4_pcmcia_ops, 0, 2);
diff --git a/drivers/pcmcia/sa1100_cerf.c b/drivers/pcmcia/sa1100_cerf.c
index 549a1529fe35..7c3951a2675d 100644
--- a/drivers/pcmcia/sa1100_cerf.c
+++ b/drivers/pcmcia/sa1100_cerf.c
@@ -63,7 +63,7 @@ cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
63 63
64 default: 64 default:
65 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", 65 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
66 __FUNCTION__, state->Vcc); 66 __func__, state->Vcc);
67 return -1; 67 return -1;
68 } 68 }
69 69
diff --git a/drivers/pcmcia/sa1100_jornada720.c b/drivers/pcmcia/sa1100_jornada720.c
index 6284c35dabc6..2167e6714d2d 100644
--- a/drivers/pcmcia/sa1100_jornada720.c
+++ b/drivers/pcmcia/sa1100_jornada720.c
@@ -42,7 +42,7 @@ jornada720_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_s
42 unsigned int pa_dwr_mask, pa_dwr_set; 42 unsigned int pa_dwr_mask, pa_dwr_set;
43 int ret; 43 int ret;
44 44
45printk("%s(): config socket %d vcc %d vpp %d\n", __FUNCTION__, 45printk("%s(): config socket %d vcc %d vpp %d\n", __func__,
46 skt->nr, state->Vcc, state->Vpp); 46 skt->nr, state->Vcc, state->Vpp);
47 47
48 switch (skt->nr) { 48 switch (skt->nr) {
@@ -74,7 +74,7 @@ printk("%s(): config socket %d vcc %d vpp %d\n", __FUNCTION__,
74 74
75 if (state->Vpp != state->Vcc && state->Vpp != 0) { 75 if (state->Vpp != state->Vcc && state->Vpp != 0) {
76 printk(KERN_ERR "%s(): slot cannot support VPP %u\n", 76 printk(KERN_ERR "%s(): slot cannot support VPP %u\n",
77 __FUNCTION__, state->Vpp); 77 __func__, state->Vpp);
78 return -1; 78 return -1;
79 } 79 }
80 80
diff --git a/drivers/pcmcia/sa1100_neponset.c b/drivers/pcmcia/sa1100_neponset.c
index 5bc9e9532b9d..687492fcd5b4 100644
--- a/drivers/pcmcia/sa1100_neponset.c
+++ b/drivers/pcmcia/sa1100_neponset.c
@@ -59,7 +59,7 @@ neponset_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_sta
59 ncr_set = NCR_A0VPP; 59 ncr_set = NCR_A0VPP;
60 else { 60 else {
61 printk(KERN_ERR "%s(): unrecognized VPP %u\n", 61 printk(KERN_ERR "%s(): unrecognized VPP %u\n",
62 __FUNCTION__, state->Vpp); 62 __func__, state->Vpp);
63 return -1; 63 return -1;
64 } 64 }
65 break; 65 break;
@@ -71,7 +71,7 @@ neponset_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_sta
71 71
72 if (state->Vpp != state->Vcc && state->Vpp != 0) { 72 if (state->Vpp != state->Vcc && state->Vpp != 0) {
73 printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n", 73 printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n",
74 __FUNCTION__, state->Vpp); 74 __func__, state->Vpp);
75 return -1; 75 return -1;
76 } 76 }
77 break; 77 break;
diff --git a/drivers/pcmcia/sa1100_shannon.c b/drivers/pcmcia/sa1100_shannon.c
index 9456f5478d09..494912fccc0d 100644
--- a/drivers/pcmcia/sa1100_shannon.c
+++ b/drivers/pcmcia/sa1100_shannon.c
@@ -73,19 +73,19 @@ shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
73{ 73{
74 switch (state->Vcc) { 74 switch (state->Vcc) {
75 case 0: /* power off */ 75 case 0: /* power off */
76 printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __FUNCTION__); 76 printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__);
77 break; 77 break;
78 case 50: 78 case 50:
79 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __FUNCTION__); 79 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__);
80 case 33: 80 case 33:
81 break; 81 break;
82 default: 82 default:
83 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", 83 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
84 __FUNCTION__, state->Vcc); 84 __func__, state->Vcc);
85 return -1; 85 return -1;
86 } 86 }
87 87
88 printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __FUNCTION__); 88 printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__);
89 89
90 /* Silently ignore Vpp, output enable, speaker enable. */ 90 /* Silently ignore Vpp, output enable, speaker enable. */
91 91
diff --git a/drivers/pcmcia/sa1100_simpad.c b/drivers/pcmcia/sa1100_simpad.c
index 04d6f7f75f78..42567de894b9 100644
--- a/drivers/pcmcia/sa1100_simpad.c
+++ b/drivers/pcmcia/sa1100_simpad.c
@@ -90,7 +90,7 @@ simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
90 90
91 default: 91 default:
92 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", 92 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
93 __FUNCTION__, state->Vcc); 93 __func__, state->Vcc);
94 clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1); 94 clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
95 local_irq_restore(flags); 95 local_irq_restore(flags);
96 return -1; 96 return -1;
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index aa7779d89752..420a77540f41 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -37,6 +37,7 @@
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/timer.h> 38#include <linux/timer.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/mutex.h>
40#include <linux/interrupt.h> 41#include <linux/interrupt.h>
41#include <linux/irq.h> 42#include <linux/irq.h>
42#include <linux/spinlock.h> 43#include <linux/spinlock.h>
@@ -353,7 +354,7 @@ soc_common_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *m
353 (map->flags&MAP_PREFETCH)?"PREFETCH ":""); 354 (map->flags&MAP_PREFETCH)?"PREFETCH ":"");
354 355
355 if (map->map >= MAX_IO_WIN) { 356 if (map->map >= MAX_IO_WIN) {
356 printk(KERN_ERR "%s(): map (%d) out of range\n", __FUNCTION__, 357 printk(KERN_ERR "%s(): map (%d) out of range\n", __func__,
357 map->map); 358 map->map);
358 return -1; 359 return -1;
359 } 360 }
@@ -578,7 +579,7 @@ EXPORT_SYMBOL(soc_pcmcia_enable_irqs);
578 579
579 580
580LIST_HEAD(soc_pcmcia_sockets); 581LIST_HEAD(soc_pcmcia_sockets);
581DECLARE_MUTEX(soc_pcmcia_sockets_lock); 582static DEFINE_MUTEX(soc_pcmcia_sockets_lock);
582 583
583static const char *skt_names[] = { 584static const char *skt_names[] = {
584 "PCMCIA socket 0", 585 "PCMCIA socket 0",
@@ -601,11 +602,11 @@ soc_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data)
601 struct cpufreq_freqs *freqs = data; 602 struct cpufreq_freqs *freqs = data;
602 int ret = 0; 603 int ret = 0;
603 604
604 down(&soc_pcmcia_sockets_lock); 605 mutex_lock(&soc_pcmcia_sockets_lock);
605 list_for_each_entry(skt, &soc_pcmcia_sockets, node) 606 list_for_each_entry(skt, &soc_pcmcia_sockets, node)
606 if ( skt->ops->frequency_change ) 607 if ( skt->ops->frequency_change )
607 ret += skt->ops->frequency_change(skt, val, freqs); 608 ret += skt->ops->frequency_change(skt, val, freqs);
608 up(&soc_pcmcia_sockets_lock); 609 mutex_unlock(&soc_pcmcia_sockets_lock);
609 610
610 return ret; 611 return ret;
611} 612}
@@ -642,7 +643,7 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops
642 struct soc_pcmcia_socket *skt; 643 struct soc_pcmcia_socket *skt;
643 int ret, i; 644 int ret, i;
644 645
645 down(&soc_pcmcia_sockets_lock); 646 mutex_lock(&soc_pcmcia_sockets_lock);
646 647
647 sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); 648 sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
648 if (!sinfo) { 649 if (!sinfo) {
@@ -782,7 +783,7 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops
782 kfree(sinfo); 783 kfree(sinfo);
783 784
784 out: 785 out:
785 up(&soc_pcmcia_sockets_lock); 786 mutex_unlock(&soc_pcmcia_sockets_lock);
786 return ret; 787 return ret;
787} 788}
788 789
@@ -793,7 +794,7 @@ int soc_common_drv_pcmcia_remove(struct device *dev)
793 794
794 dev_set_drvdata(dev, NULL); 795 dev_set_drvdata(dev, NULL);
795 796
796 down(&soc_pcmcia_sockets_lock); 797 mutex_lock(&soc_pcmcia_sockets_lock);
797 for (i = 0; i < sinfo->nskt; i++) { 798 for (i = 0; i < sinfo->nskt; i++) {
798 struct soc_pcmcia_socket *skt = &sinfo->skt[i]; 799 struct soc_pcmcia_socket *skt = &sinfo->skt[i];
799 800
@@ -818,7 +819,7 @@ int soc_common_drv_pcmcia_remove(struct device *dev)
818 if (list_empty(&soc_pcmcia_sockets)) 819 if (list_empty(&soc_pcmcia_sockets))
819 soc_pcmcia_cpufreq_unregister(); 820 soc_pcmcia_cpufreq_unregister();
820 821
821 up(&soc_pcmcia_sockets_lock); 822 mutex_unlock(&soc_pcmcia_sockets_lock);
822 823
823 kfree(sinfo); 824 kfree(sinfo);
824 825
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h
index 6f14126889b3..1edc1da9d353 100644
--- a/drivers/pcmcia/soc_common.h
+++ b/drivers/pcmcia/soc_common.h
@@ -133,7 +133,6 @@ extern void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *, struct soc_
133 133
134 134
135extern struct list_head soc_pcmcia_sockets; 135extern struct list_head soc_pcmcia_sockets;
136extern struct semaphore soc_pcmcia_sockets_lock;
137 136
138extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr); 137extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr);
139extern int soc_common_drv_pcmcia_remove(struct device *dev); 138extern int soc_common_drv_pcmcia_remove(struct device *dev);
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 2e2c457a0fea..5ff9a4c0447e 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -591,7 +591,8 @@ static void pnpbios_encode_irq(struct pnp_dev *dev, unsigned char *p,
591 p[1] = map & 0xff; 591 p[1] = map & 0xff;
592 p[2] = (map >> 8) & 0xff; 592 p[2] = (map >> 8) & 0xff;
593 593
594 dev_dbg(&dev->dev, " encode irq %d\n", res->start); 594 dev_dbg(&dev->dev, " encode irq %llu\n",
595 (unsigned long long)res->start);
595} 596}
596 597
597static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p, 598static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p,
@@ -602,7 +603,8 @@ static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p,
602 map = 1 << res->start; 603 map = 1 << res->start;
603 p[1] = map & 0xff; 604 p[1] = map & 0xff;
604 605
605 dev_dbg(&dev->dev, " encode dma %d\n", res->start); 606 dev_dbg(&dev->dev, " encode dma %llu\n",
607 (unsigned long long)res->start);
606} 608}
607 609
608static void pnpbios_encode_port(struct pnp_dev *dev, unsigned char *p, 610static void pnpbios_encode_port(struct pnp_dev *dev, unsigned char *p,
diff --git a/drivers/scsi/mvsas.c b/drivers/scsi/mvsas.c
index e55b9037adb2..1dd70d7a4947 100644
--- a/drivers/scsi/mvsas.c
+++ b/drivers/scsi/mvsas.c
@@ -2822,7 +2822,9 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
2822 dev_printk(KERN_DEBUG, &pdev->dev, 2822 dev_printk(KERN_DEBUG, &pdev->dev,
2823 "phy[%d] Get Attached Address 0x%llX ," 2823 "phy[%d] Get Attached Address 0x%llX ,"
2824 " SAS Address 0x%llX\n", 2824 " SAS Address 0x%llX\n",
2825 i, phy->att_dev_sas_addr, phy->dev_sas_addr); 2825 i,
2826 (unsigned long long)phy->att_dev_sas_addr,
2827 (unsigned long long)phy->dev_sas_addr);
2826 dev_printk(KERN_DEBUG, &pdev->dev, 2828 dev_printk(KERN_DEBUG, &pdev->dev,
2827 "Rate = %x , type = %d\n", 2829 "Rate = %x , type = %d\n",
2828 sas_phy->linkrate, phy->phy_type); 2830 sas_phy->linkrate, phy->phy_type);
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index ceab4f73caf1..c57c94c0ffd2 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -8222,7 +8222,7 @@ static void process_waiting_list(struct ncb *np, int sts)
8222#ifdef DEBUG_WAITING_LIST 8222#ifdef DEBUG_WAITING_LIST
8223 if (waiting_list) printk("%s: waiting_list=%lx processing sts=%d\n", ncr_name(np), (u_long) waiting_list, sts); 8223 if (waiting_list) printk("%s: waiting_list=%lx processing sts=%d\n", ncr_name(np), (u_long) waiting_list, sts);
8224#endif 8224#endif
8225 while (wcmd = waiting_list) { 8225 while ((wcmd = waiting_list) != NULL) {
8226 waiting_list = (struct scsi_cmnd *) wcmd->next_wcmd; 8226 waiting_list = (struct scsi_cmnd *) wcmd->next_wcmd;
8227 wcmd->next_wcmd = NULL; 8227 wcmd->next_wcmd = NULL;
8228 if (sts == DID_OK) { 8228 if (sts == DID_OK) {
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index ea41f2626458..a1ca9b7bf2d5 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2271,7 +2271,8 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
2271 } 2271 }
2272 2272
2273 if (up->port.flags & UPF_IOREMAP) { 2273 if (up->port.flags & UPF_IOREMAP) {
2274 up->port.membase = ioremap(up->port.mapbase, size); 2274 up->port.membase = ioremap_nocache(up->port.mapbase,
2275 size);
2275 if (!up->port.membase) { 2276 if (!up->port.membase) {
2276 release_mem_region(up->port.mapbase, size); 2277 release_mem_region(up->port.mapbase, size);
2277 ret = -ENOMEM; 2278 ret = -ENOMEM;
diff --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
index cd898704ba4f..f279745e9fef 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/serial/8250_early.c
@@ -153,7 +153,7 @@ static int __init parse_options(struct early_serial8250_device *device,
153 (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE); 153 (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE);
154 port->membase += port->mapbase & ~PAGE_MASK; 154 port->membase += port->mapbase & ~PAGE_MASK;
155#else 155#else
156 port->membase = ioremap(port->mapbase, 64); 156 port->membase = ioremap_nocache(port->mapbase, 64);
157 if (!port->membase) { 157 if (!port->membase) {
158 printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n", 158 printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n",
159 __func__, 159 __func__,
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 6e57382b9137..53fa19cf2f06 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -86,7 +86,7 @@ setup_port(struct serial_private *priv, struct uart_port *port,
86 len = pci_resource_len(dev, bar); 86 len = pci_resource_len(dev, bar);
87 87
88 if (!priv->remapped_bar[bar]) 88 if (!priv->remapped_bar[bar])
89 priv->remapped_bar[bar] = ioremap(base, len); 89 priv->remapped_bar[bar] = ioremap_nocache(base, len);
90 if (!priv->remapped_bar[bar]) 90 if (!priv->remapped_bar[bar])
91 return -ENOMEM; 91 return -ENOMEM;
92 92
@@ -270,7 +270,7 @@ static int pci_plx9050_init(struct pci_dev *dev)
270 /* 270 /*
271 * enable/disable interrupts 271 * enable/disable interrupts
272 */ 272 */
273 p = ioremap(pci_resource_start(dev, 0), 0x80); 273 p = ioremap_nocache(pci_resource_start(dev, 0), 0x80);
274 if (p == NULL) 274 if (p == NULL)
275 return -ENOMEM; 275 return -ENOMEM;
276 writel(irq_config, p + 0x4c); 276 writel(irq_config, p + 0x4c);
@@ -294,7 +294,7 @@ static void __devexit pci_plx9050_exit(struct pci_dev *dev)
294 /* 294 /*
295 * disable interrupts 295 * disable interrupts
296 */ 296 */
297 p = ioremap(pci_resource_start(dev, 0), 0x80); 297 p = ioremap_nocache(pci_resource_start(dev, 0), 0x80);
298 if (p != NULL) { 298 if (p != NULL) {
299 writel(0, p + 0x4c); 299 writel(0, p + 0x4c);
300 300
@@ -341,7 +341,8 @@ static int sbs_init(struct pci_dev *dev)
341{ 341{
342 u8 __iomem *p; 342 u8 __iomem *p;
343 343
344 p = ioremap(pci_resource_start(dev, 0), pci_resource_len(dev, 0)); 344 p = ioremap_nocache(pci_resource_start(dev, 0),
345 pci_resource_len(dev, 0));
345 346
346 if (p == NULL) 347 if (p == NULL)
347 return -ENOMEM; 348 return -ENOMEM;
@@ -365,7 +366,8 @@ static void __devexit sbs_exit(struct pci_dev *dev)
365{ 366{
366 u8 __iomem *p; 367 u8 __iomem *p;
367 368
368 p = ioremap(pci_resource_start(dev, 0), pci_resource_len(dev, 0)); 369 p = ioremap_nocache(pci_resource_start(dev, 0),
370 pci_resource_len(dev, 0));
369 /* FIXME: What if resource_len < OCT_REG_CR_OFF */ 371 /* FIXME: What if resource_len < OCT_REG_CR_OFF */
370 if (p != NULL) 372 if (p != NULL)
371 writeb(0, p + OCT_REG_CR_OFF); 373 writeb(0, p + OCT_REG_CR_OFF);
@@ -419,7 +421,7 @@ static int pci_siig10x_init(struct pci_dev *dev)
419 break; 421 break;
420 } 422 }
421 423
422 p = ioremap(pci_resource_start(dev, 0), 0x80); 424 p = ioremap_nocache(pci_resource_start(dev, 0), 0x80);
423 if (p == NULL) 425 if (p == NULL)
424 return -ENOMEM; 426 return -ENOMEM;
425 427
diff --git a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
index 12c934a1f274..8871aaa3dba6 100644
--- a/drivers/serial/jsm/jsm.h
+++ b/drivers/serial/jsm/jsm.h
@@ -373,6 +373,7 @@ struct neo_uart_struct {
373#define PCI_DEVICE_NEO_2DB9PRI_PCI_NAME "Neo 2 - DB9 Universal PCI - Powered Ring Indicator" 373#define PCI_DEVICE_NEO_2DB9PRI_PCI_NAME "Neo 2 - DB9 Universal PCI - Powered Ring Indicator"
374#define PCI_DEVICE_NEO_2RJ45_PCI_NAME "Neo 2 - RJ45 Universal PCI" 374#define PCI_DEVICE_NEO_2RJ45_PCI_NAME "Neo 2 - RJ45 Universal PCI"
375#define PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME "Neo 2 - RJ45 Universal PCI - Powered Ring Indicator" 375#define PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME "Neo 2 - RJ45 Universal PCI - Powered Ring Indicator"
376#define PCIE_DEVICE_NEO_IBM_PCI_NAME "Neo 4 - PCI Express - IBM"
376 377
377/* 378/*
378 * Our Global Variables. 379 * Our Global Variables.
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
index 6767ee381cd1..338cf8a08b43 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/serial/jsm/jsm_driver.c
@@ -82,7 +82,10 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
82 /* store the info for the board we've found */ 82 /* store the info for the board we've found */
83 brd->boardnum = adapter_count++; 83 brd->boardnum = adapter_count++;
84 brd->pci_dev = pdev; 84 brd->pci_dev = pdev;
85 brd->maxports = 2; 85 if (pdev->device == PCIE_DEVICE_ID_NEO_4_IBM)
86 brd->maxports = 4;
87 else
88 brd->maxports = 2;
86 89
87 spin_lock_init(&brd->bd_lock); 90 spin_lock_init(&brd->bd_lock);
88 spin_lock_init(&brd->bd_intr_lock); 91 spin_lock_init(&brd->bd_intr_lock);
@@ -208,6 +211,7 @@ static struct pci_device_id jsm_pci_tbl[] = {
208 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2DB9PRI), 0, 0, 1 }, 211 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2DB9PRI), 0, 0, 1 },
209 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45), 0, 0, 2 }, 212 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45), 0, 0, 2 },
210 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45PRI), 0, 0, 3 }, 213 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45PRI), 0, 0, 3 },
214 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCIE_DEVICE_ID_NEO_4_IBM), 0, 0, 4 },
211 { 0, } 215 { 0, }
212}; 216};
213MODULE_DEVICE_TABLE(pci, jsm_pci_tbl); 217MODULE_DEVICE_TABLE(pci, jsm_pci_tbl);
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index a9ac1fdb3094..7fea3cf4588a 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -608,6 +608,7 @@ static void pump_transfers(unsigned long data)
608 u8 width; 608 u8 width;
609 u16 cr, dma_width, dma_config; 609 u16 cr, dma_width, dma_config;
610 u32 tranf_success = 1; 610 u32 tranf_success = 1;
611 u8 full_duplex = 0;
611 612
612 /* Get current state information */ 613 /* Get current state information */
613 message = drv_data->cur_msg; 614 message = drv_data->cur_msg;
@@ -658,6 +659,7 @@ static void pump_transfers(unsigned long data)
658 } 659 }
659 660
660 if (transfer->rx_buf != NULL) { 661 if (transfer->rx_buf != NULL) {
662 full_duplex = transfer->tx_buf != NULL;
661 drv_data->rx = transfer->rx_buf; 663 drv_data->rx = transfer->rx_buf;
662 drv_data->rx_end = drv_data->rx + transfer->len; 664 drv_data->rx_end = drv_data->rx + transfer->len;
663 dev_dbg(&drv_data->pdev->dev, "rx_buf is %p, rx_end is %p\n", 665 dev_dbg(&drv_data->pdev->dev, "rx_buf is %p, rx_end is %p\n",
@@ -740,7 +742,8 @@ static void pump_transfers(unsigned long data)
740 * successful use different way to r/w according to 742 * successful use different way to r/w according to
741 * drv_data->cur_chip->enable_dma 743 * drv_data->cur_chip->enable_dma
742 */ 744 */
743 if (drv_data->cur_chip->enable_dma && drv_data->len > 6) { 745 if (!full_duplex && drv_data->cur_chip->enable_dma
746 && drv_data->len > 6) {
744 747
745 disable_dma(drv_data->dma_channel); 748 disable_dma(drv_data->dma_channel);
746 clear_dma_irqstat(drv_data->dma_channel); 749 clear_dma_irqstat(drv_data->dma_channel);
@@ -828,7 +831,7 @@ static void pump_transfers(unsigned long data)
828 /* IO mode write then read */ 831 /* IO mode write then read */
829 dev_dbg(&drv_data->pdev->dev, "doing IO transfer\n"); 832 dev_dbg(&drv_data->pdev->dev, "doing IO transfer\n");
830 833
831 if (drv_data->tx != NULL && drv_data->rx != NULL) { 834 if (full_duplex) {
832 /* full duplex mode */ 835 /* full duplex mode */
833 BUG_ON((drv_data->tx_end - drv_data->tx) != 836 BUG_ON((drv_data->tx_end - drv_data->tx) !=
834 (drv_data->rx_end - drv_data->rx)); 837 (drv_data->rx_end - drv_data->rx));
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 34bfb7dd7764..0885cc357a37 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -125,10 +125,10 @@ static int s3c24xx_spi_setupxfer(struct spi_device *spi,
125 /* is clk = pclk / (2 * (pre+1)), or is it 125 /* is clk = pclk / (2 * (pre+1)), or is it
126 * clk = (pclk * 2) / ( pre + 1) */ 126 * clk = (pclk * 2) / ( pre + 1) */
127 127
128 div = (div / 2) - 1; 128 div /= 2;
129 129
130 if (div < 0) 130 if (div > 0)
131 div = 1; 131 div -= 1;
132 132
133 if (div > 255) 133 if (div > 255)
134 div = 255; 134 div = 255;
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index d96e5c14a9ca..894fee54d4d8 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -73,8 +73,8 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
73 status = 0; 73 status = 0;
74done: 74done:
75 DPRINTK("returning = %d", status); 75 DPRINTK("returning = %d", status);
76 mntput(mnt);
77 dput(dentry); 76 dput(dentry);
77 mntput(mnt);
78 return status; 78 return status;
79} 79}
80 80
@@ -333,7 +333,7 @@ static struct dentry *autofs4_expire_indirect(struct super_block *sb,
333 /* Can we expire this guy */ 333 /* Can we expire this guy */
334 if (autofs4_can_expire(dentry, timeout, do_now)) { 334 if (autofs4_can_expire(dentry, timeout, do_now)) {
335 expired = dentry; 335 expired = dentry;
336 break; 336 goto found;
337 } 337 }
338 goto next; 338 goto next;
339 } 339 }
@@ -352,7 +352,7 @@ static struct dentry *autofs4_expire_indirect(struct super_block *sb,
352 inf->flags |= AUTOFS_INF_EXPIRING; 352 inf->flags |= AUTOFS_INF_EXPIRING;
353 spin_unlock(&sbi->fs_lock); 353 spin_unlock(&sbi->fs_lock);
354 expired = dentry; 354 expired = dentry;
355 break; 355 goto found;
356 } 356 }
357 spin_unlock(&sbi->fs_lock); 357 spin_unlock(&sbi->fs_lock);
358 /* 358 /*
@@ -363,7 +363,7 @@ static struct dentry *autofs4_expire_indirect(struct super_block *sb,
363 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now); 363 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);
364 if (expired) { 364 if (expired) {
365 dput(dentry); 365 dput(dentry);
366 break; 366 goto found;
367 } 367 }
368 } 368 }
369next: 369next:
@@ -371,18 +371,16 @@ next:
371 spin_lock(&dcache_lock); 371 spin_lock(&dcache_lock);
372 next = next->next; 372 next = next->next;
373 } 373 }
374
375 if (expired) {
376 DPRINTK("returning %p %.*s",
377 expired, (int)expired->d_name.len, expired->d_name.name);
378 spin_lock(&dcache_lock);
379 list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child);
380 spin_unlock(&dcache_lock);
381 return expired;
382 }
383 spin_unlock(&dcache_lock); 374 spin_unlock(&dcache_lock);
384
385 return NULL; 375 return NULL;
376
377found:
378 DPRINTK("returning %p %.*s",
379 expired, (int)expired->d_name.len, expired->d_name.name);
380 spin_lock(&dcache_lock);
381 list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child);
382 spin_unlock(&dcache_lock);
383 return expired;
386} 384}
387 385
388/* Perform an expiry operation */ 386/* Perform an expiry operation */
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index aa4c5ff8a40d..edf5b6bddb52 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -146,17 +146,17 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
146 146
147 if (d_mountpoint(dentry)) { 147 if (d_mountpoint(dentry)) {
148 struct file *fp = NULL; 148 struct file *fp = NULL;
149 struct vfsmount *fp_mnt = mntget(mnt); 149 struct path fp_path = { .dentry = dentry, .mnt = mnt };
150 struct dentry *fp_dentry = dget(dentry);
151 150
152 if (!autofs4_follow_mount(&fp_mnt, &fp_dentry)) { 151 path_get(&fp_path);
153 dput(fp_dentry); 152
154 mntput(fp_mnt); 153 if (!autofs4_follow_mount(&fp_path.mnt, &fp_path.dentry)) {
154 path_put(&fp_path);
155 dcache_dir_close(inode, file); 155 dcache_dir_close(inode, file);
156 goto out; 156 goto out;
157 } 157 }
158 158
159 fp = dentry_open(fp_dentry, fp_mnt, file->f_flags); 159 fp = dentry_open(fp_path.dentry, fp_path.mnt, file->f_flags);
160 status = PTR_ERR(fp); 160 status = PTR_ERR(fp);
161 if (IS_ERR(fp)) { 161 if (IS_ERR(fp)) {
162 dcache_dir_close(inode, file); 162 dcache_dir_close(inode, file);
@@ -242,7 +242,8 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags)
242{ 242{
243 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 243 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
244 struct autofs_info *ino = autofs4_dentry_ino(dentry); 244 struct autofs_info *ino = autofs4_dentry_ino(dentry);
245 int status = 0; 245 struct dentry *new;
246 int status;
246 247
247 /* Block on any pending expiry here; invalidate the dentry 248 /* Block on any pending expiry here; invalidate the dentry
248 when expiration is done to trigger mount request with a new 249 when expiration is done to trigger mount request with a new
@@ -318,7 +319,28 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags)
318 spin_lock(&dentry->d_lock); 319 spin_lock(&dentry->d_lock);
319 dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; 320 dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
320 spin_unlock(&dentry->d_lock); 321 spin_unlock(&dentry->d_lock);
321 return status; 322
323 /*
324 * The dentry that is passed in from lookup may not be the one
325 * we end up using, as mkdir can create a new one. If this
326 * happens, and another process tries the lookup at the same time,
327 * it will set the PENDING flag on this new dentry, but add itself
328 * to our waitq. Then, if after the lookup succeeds, the first
329 * process that requested the mount performs another lookup of the
330 * same directory, it will show up as still pending! So, we need
331 * to redo the lookup here and clear pending on that dentry.
332 */
333 if (d_unhashed(dentry)) {
334 new = d_lookup(dentry->d_parent, &dentry->d_name);
335 if (new) {
336 spin_lock(&new->d_lock);
337 new->d_flags &= ~DCACHE_AUTOFS_PENDING;
338 spin_unlock(&new->d_lock);
339 dput(new);
340 }
341 }
342
343 return 0;
322} 344}
323 345
324/* For autofs direct mounts the follow link triggers the mount */ 346/* For autofs direct mounts the follow link triggers the mount */
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 1fe28e4754c2..75e5955c3f6d 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -171,7 +171,7 @@ static int autofs4_getpath(struct autofs_sb_info *sbi,
171 for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent) 171 for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent)
172 len += tmp->d_name.len + 1; 172 len += tmp->d_name.len + 1;
173 173
174 if (--len > NAME_MAX) { 174 if (!len || --len > NAME_MAX) {
175 spin_unlock(&dcache_lock); 175 spin_unlock(&dcache_lock);
176 return 0; 176 return 0;
177 } 177 }
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 9ced35b00686..f28cf8b46f80 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -934,7 +934,7 @@ static int fuse_get_user_pages(struct fuse_req *req, const char __user *buf,
934 934
935 nbytes = min(nbytes, (unsigned) FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT); 935 nbytes = min(nbytes, (unsigned) FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT);
936 npages = (nbytes + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; 936 npages = (nbytes + offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
937 npages = min(max(npages, 1), FUSE_MAX_PAGES_PER_REQ); 937 npages = clamp(npages, 1, FUSE_MAX_PAGES_PER_REQ);
938 down_read(&current->mm->mmap_sem); 938 down_read(&current->mm->mmap_sem);
939 npages = get_user_pages(current, current->mm, user_addr, npages, write, 939 npages = get_user_pages(current, current->mm, user_addr, npages, write,
940 0, req->pages, NULL); 940 0, req->pages, NULL);
diff --git a/fs/utimes.c b/fs/utimes.c
index a2bef77dc9c9..af059d5cb485 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -40,9 +40,14 @@ asmlinkage long sys_utime(char __user *filename, struct utimbuf __user *times)
40 40
41#endif 41#endif
42 42
43static bool nsec_special(long nsec)
44{
45 return nsec == UTIME_OMIT || nsec == UTIME_NOW;
46}
47
43static bool nsec_valid(long nsec) 48static bool nsec_valid(long nsec)
44{ 49{
45 if (nsec == UTIME_OMIT || nsec == UTIME_NOW) 50 if (nsec_special(nsec))
46 return true; 51 return true;
47 52
48 return nsec >= 0 && nsec <= 999999999; 53 return nsec >= 0 && nsec <= 999999999;
@@ -119,7 +124,15 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags
119 newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; 124 newattrs.ia_mtime.tv_nsec = times[1].tv_nsec;
120 newattrs.ia_valid |= ATTR_MTIME_SET; 125 newattrs.ia_valid |= ATTR_MTIME_SET;
121 } 126 }
122 } else { 127 }
128
129 /*
130 * If times is NULL or both times are either UTIME_OMIT or
131 * UTIME_NOW, then need to check permissions, because
132 * inode_change_ok() won't do it.
133 */
134 if (!times || (nsec_special(times[0].tv_nsec) &&
135 nsec_special(times[1].tv_nsec))) {
123 error = -EACCES; 136 error = -EACCES;
124 if (IS_IMMUTABLE(inode)) 137 if (IS_IMMUTABLE(inode))
125 goto mnt_drop_write_and_out; 138 goto mnt_drop_write_and_out;
diff --git a/include/asm-arm/div64.h b/include/asm-arm/div64.h
index 0b5f881c3d85..5001390be958 100644
--- a/include/asm-arm/div64.h
+++ b/include/asm-arm/div64.h
@@ -224,6 +224,4 @@
224 224
225#endif 225#endif
226 226
227extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
228
229#endif 227#endif
diff --git a/include/asm-frv/unaligned.h b/include/asm-frv/unaligned.h
index 64ccc736f2d8..839a2fbffa0f 100644
--- a/include/asm-frv/unaligned.h
+++ b/include/asm-frv/unaligned.h
@@ -9,8 +9,8 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#ifndef _ASM_FRV_UNALIGNED_H 12#ifndef _ASM_UNALIGNED_H
13#define _ASM_FRV_UNALIGNED_H 13#define _ASM_UNALIGNED_H
14 14
15#include <linux/unaligned/le_byteshift.h> 15#include <linux/unaligned/le_byteshift.h>
16#include <linux/unaligned/be_byteshift.h> 16#include <linux/unaligned/be_byteshift.h>
@@ -19,4 +19,4 @@
19#define get_unaligned __get_unaligned_be 19#define get_unaligned __get_unaligned_be
20#define put_unaligned __put_unaligned_be 20#define put_unaligned __put_unaligned_be
21 21
22#endif /* _ASM_FRV_UNALIGNED_H */ 22#endif /* _ASM_UNALIGNED_H */
diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
index a4a49370793c..8f4e3193342e 100644
--- a/include/asm-generic/div64.h
+++ b/include/asm-generic/div64.h
@@ -30,11 +30,6 @@
30 __rem; \ 30 __rem; \
31 }) 31 })
32 32
33static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
34{
35 return dividend / divisor;
36}
37
38#elif BITS_PER_LONG == 32 33#elif BITS_PER_LONG == 32
39 34
40extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); 35extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
@@ -54,8 +49,6 @@ extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
54 __rem; \ 49 __rem; \
55 }) 50 })
56 51
57extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
58
59#else /* BITS_PER_LONG == ?? */ 52#else /* BITS_PER_LONG == ?? */
60 53
61# error do_div() does not yet support the C64 54# error do_div() does not yet support the C64
diff --git a/include/asm-ia64/dmi.h b/include/asm-ia64/dmi.h
index f3efaa229525..00eb1b130b63 100644
--- a/include/asm-ia64/dmi.h
+++ b/include/asm-ia64/dmi.h
@@ -3,4 +3,9 @@
3 3
4#include <asm/io.h> 4#include <asm/io.h>
5 5
6/* Use normal IO mappings for DMI */
7#define dmi_ioremap ioremap
8#define dmi_iounmap(x,l) iounmap(x)
9#define dmi_alloc(l) kmalloc(l, GFP_ATOMIC)
10
6#endif 11#endif
diff --git a/include/asm-ia64/io.h b/include/asm-ia64/io.h
index 4ebed77aa472..260a85ac9d6a 100644
--- a/include/asm-ia64/io.h
+++ b/include/asm-ia64/io.h
@@ -423,11 +423,6 @@ extern void __iomem * ioremap(unsigned long offset, unsigned long size);
423extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); 423extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
424extern void iounmap (volatile void __iomem *addr); 424extern void iounmap (volatile void __iomem *addr);
425 425
426/* Use normal IO mappings for DMI */
427#define dmi_ioremap ioremap
428#define dmi_iounmap(x,l) iounmap(x)
429#define dmi_alloc(l) kmalloc(l, GFP_ATOMIC)
430
431/* 426/*
432 * String version of IO memory access ops: 427 * String version of IO memory access ops:
433 */ 428 */
diff --git a/include/asm-m68k/div64.h b/include/asm-m68k/div64.h
index 33caad1628d4..8243c931b5c0 100644
--- a/include/asm-m68k/div64.h
+++ b/include/asm-m68k/div64.h
@@ -25,5 +25,4 @@
25 __rem; \ 25 __rem; \
26}) 26})
27 27
28extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
29#endif /* _M68K_DIV64_H */ 28#endif /* _M68K_DIV64_H */
diff --git a/include/asm-m68knommu/dma.h b/include/asm-m68knommu/dma.h
index 3f20419c633a..939a02056217 100644
--- a/include/asm-m68knommu/dma.h
+++ b/include/asm-m68knommu/dma.h
@@ -35,7 +35,8 @@
35/* 35/*
36 * Set number of channels of DMA on ColdFire for different implementations. 36 * Set number of channels of DMA on ColdFire for different implementations.
37 */ 37 */
38#if defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) 38#if defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) || \
39 defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x)
39#define MAX_M68K_DMA_CHANNELS 4 40#define MAX_M68K_DMA_CHANNELS 4
40#elif defined(CONFIG_M5272) 41#elif defined(CONFIG_M5272)
41#define MAX_M68K_DMA_CHANNELS 1 42#define MAX_M68K_DMA_CHANNELS 1
diff --git a/include/asm-m68knommu/param.h b/include/asm-m68knommu/param.h
index 96c451018324..6044397adb64 100644
--- a/include/asm-m68knommu/param.h
+++ b/include/asm-m68knommu/param.h
@@ -1,13 +1,16 @@
1#ifndef _M68KNOMMU_PARAM_H 1#ifndef _M68KNOMMU_PARAM_H
2#define _M68KNOMMU_PARAM_H 2#define _M68KNOMMU_PARAM_H
3 3
4#define HZ CONFIG_HZ
5
6#ifdef __KERNEL__ 4#ifdef __KERNEL__
5#define HZ CONFIG_HZ
7#define USER_HZ HZ 6#define USER_HZ HZ
8#define CLOCKS_PER_SEC (USER_HZ) 7#define CLOCKS_PER_SEC (USER_HZ)
9#endif 8#endif
10 9
10#ifndef HZ
11#define HZ 100
12#endif
13
11#define EXEC_PAGESIZE 4096 14#define EXEC_PAGESIZE 4096
12 15
13#ifndef NOGROUP 16#ifndef NOGROUP
diff --git a/include/asm-mips/div64.h b/include/asm-mips/div64.h
index 716371bd0980..d1d699105c11 100644
--- a/include/asm-mips/div64.h
+++ b/include/asm-mips/div64.h
@@ -82,7 +82,6 @@
82 (n) = __quot; \ 82 (n) = __quot; \
83 __mod; }) 83 __mod; })
84 84
85extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
86#endif /* (_MIPS_SZLONG == 32) */ 85#endif /* (_MIPS_SZLONG == 32) */
87 86
88#if (_MIPS_SZLONG == 64) 87#if (_MIPS_SZLONG == 64)
@@ -106,11 +105,6 @@ extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
106 (n) = __quot; \ 105 (n) = __quot; \
107 __mod; }) 106 __mod; })
108 107
109static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
110{
111 return dividend / divisor;
112}
113
114#endif /* (_MIPS_SZLONG == 64) */ 108#endif /* (_MIPS_SZLONG == 64) */
115 109
116#endif /* _ASM_DIV64_H */ 110#endif /* _ASM_DIV64_H */
diff --git a/include/asm-mn10300/div64.h b/include/asm-mn10300/div64.h
index bf9c515a998c..3a8329b3e869 100644
--- a/include/asm-mn10300/div64.h
+++ b/include/asm-mn10300/div64.h
@@ -97,7 +97,4 @@ signed __muldiv64s(signed val, signed mult, signed div)
97 return result; 97 return result;
98} 98}
99 99
100extern __attribute__((const))
101uint64_t div64_64(uint64_t dividend, uint64_t divisor);
102
103#endif /* _ASM_DIV64 */ 100#endif /* _ASM_DIV64 */
diff --git a/include/asm-um/div64.h b/include/asm-um/div64.h
index 7b73b2cd5b34..1e17f7409cab 100644
--- a/include/asm-um/div64.h
+++ b/include/asm-um/div64.h
@@ -3,5 +3,4 @@
3 3
4#include "asm/arch/div64.h" 4#include "asm/arch/div64.h"
5 5
6extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
7#endif 6#endif
diff --git a/include/asm-x86/div64.h b/include/asm-x86/div64.h
index 0dbf8bf3ef0a..9a2d644c08ef 100644
--- a/include/asm-x86/div64.h
+++ b/include/asm-x86/div64.h
@@ -33,25 +33,25 @@
33 __mod; \ 33 __mod; \
34}) 34})
35 35
36/* 36static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
37 * (long)X = ((long long)divs) / (long)div
38 * (long)rem = ((long long)divs) % (long)div
39 *
40 * Warning, this will do an exception if X overflows.
41 */
42#define div_long_long_rem(a, b, c) div_ll_X_l_rem(a, b, c)
43
44static inline long div_ll_X_l_rem(long long divs, long div, long *rem)
45{ 37{
46 long dum2; 38 union {
47 asm("divl %2":"=a"(dum2), "=d"(*rem) 39 u64 v64;
48 : "rm"(div), "A"(divs)); 40 u32 v32[2];
49 41 } d = { dividend };
50 return dum2; 42 u32 upper;
51 43
44 upper = d.v32[1];
45 d.v32[1] = 0;
46 if (upper >= divisor) {
47 d.v32[1] = upper / divisor;
48 upper %= divisor;
49 }
50 asm ("divl %2" : "=a" (d.v32[0]), "=d" (*remainder) :
51 "rm" (divisor), "0" (d.v32[0]), "1" (upper));
52 return d.v64;
52} 53}
53 54#define div_u64_rem div_u64_rem
54extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
55 55
56#else 56#else
57# include <asm-generic/div64.h> 57# include <asm-generic/div64.h>
diff --git a/include/asm-x86/dmi.h b/include/asm-x86/dmi.h
index 1241e6ad1935..4edf7514a750 100644
--- a/include/asm-x86/dmi.h
+++ b/include/asm-x86/dmi.h
@@ -27,6 +27,7 @@ static inline void *dmi_alloc(unsigned len)
27 27
28#endif 28#endif
29 29
30/* Use early IO mappings for DMI because it's initialized early */
30#define dmi_ioremap early_ioremap 31#define dmi_ioremap early_ioremap
31#define dmi_iounmap early_iounmap 32#define dmi_iounmap early_iounmap
32 33
diff --git a/include/asm-x86/io_32.h b/include/asm-x86/io_32.h
index 6e73467a4fb1..049e81e797a0 100644
--- a/include/asm-x86/io_32.h
+++ b/include/asm-x86/io_32.h
@@ -133,11 +133,6 @@ extern void *early_ioremap(unsigned long offset, unsigned long size);
133extern void early_iounmap(void *addr, unsigned long size); 133extern void early_iounmap(void *addr, unsigned long size);
134extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); 134extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
135 135
136/* Use early IO mappings for DMI because it's initialized early */
137#define dmi_ioremap early_ioremap
138#define dmi_iounmap early_iounmap
139#define dmi_alloc alloc_bootmem
140
141/* 136/*
142 * ISA I/O bus memory addresses are 1:1 with the physical address. 137 * ISA I/O bus memory addresses are 1:1 with the physical address.
143 */ 138 */
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 224658b8d806..833d208c25d6 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -57,10 +57,14 @@ static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num,
57 struct scatterlist *sg2) 57 struct scatterlist *sg2)
58{ 58{
59 sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0); 59 sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0);
60 sg1[num - 1].page_link &= ~0x02;
60} 61}
61 62
62static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) 63static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
63{ 64{
65 if (sg_is_last(sg))
66 return NULL;
67
64 return (++sg)->length ? sg : (void *)sg_page(sg); 68 return (++sg)->length ? sg : (void *)sg_page(sg);
65} 69}
66 70
diff --git a/include/linux/calc64.h b/include/linux/calc64.h
deleted file mode 100644
index ebf4b8f38d88..000000000000
--- a/include/linux/calc64.h
+++ /dev/null
@@ -1,49 +0,0 @@
1#ifndef _LINUX_CALC64_H
2#define _LINUX_CALC64_H
3
4#include <linux/types.h>
5#include <asm/div64.h>
6
7/*
8 * This is a generic macro which is used when the architecture
9 * specific div64.h does not provide a optimized one.
10 *
11 * The 64bit dividend is divided by the divisor (data type long), the
12 * result is returned and the remainder stored in the variable
13 * referenced by remainder (data type long *). In contrast to the
14 * do_div macro the dividend is kept intact.
15 */
16#ifndef div_long_long_rem
17#define div_long_long_rem(dividend, divisor, remainder) \
18 do_div_llr((dividend), divisor, remainder)
19
20static inline unsigned long do_div_llr(const long long dividend,
21 const long divisor, long *remainder)
22{
23 u64 result = dividend;
24
25 *(remainder) = do_div(result, divisor);
26 return (unsigned long) result;
27}
28#endif
29
30/*
31 * Sign aware variation of the above. On some architectures a
32 * negative dividend leads to an divide overflow exception, which
33 * is avoided by the sign check.
34 */
35static inline long div_long_long_rem_signed(const long long dividend,
36 const long divisor, long *remainder)
37{
38 long res;
39
40 if (unlikely(dividend < 0)) {
41 res = -div_long_long_rem(-dividend, divisor, remainder);
42 *remainder = -(*remainder);
43 } else
44 res = div_long_long_rem(dividend, divisor, remainder);
45
46 return res;
47}
48
49#endif
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 35094479ca55..55e434feec99 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -93,6 +93,8 @@ struct clocksource {
93#endif 93#endif
94}; 94};
95 95
96extern struct clocksource *clock; /* current clocksource */
97
96/* 98/*
97 * Clock source flags bits:: 99 * Clock source flags bits::
98 */ 100 */
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 8fa7857e153b..cf8d11cad5ae 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -65,10 +65,11 @@ struct compat_timex {
65 compat_long_t calcnt; 65 compat_long_t calcnt;
66 compat_long_t errcnt; 66 compat_long_t errcnt;
67 compat_long_t stbcnt; 67 compat_long_t stbcnt;
68 compat_int_t tai;
68 69
69 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; 70 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
70 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; 71 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
71 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; 72 compat_int_t :32; compat_int_t :32; compat_int_t :32;
72}; 73};
73 74
74#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) 75#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 33ef710dac24..abb6ac639e8e 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -1,7 +1,7 @@
1#ifndef _LINUX_JIFFIES_H 1#ifndef _LINUX_JIFFIES_H
2#define _LINUX_JIFFIES_H 2#define _LINUX_JIFFIES_H
3 3
4#include <linux/calc64.h> 4#include <linux/math64.h>
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/time.h> 7#include <linux/time.h>
diff --git a/include/linux/math64.h b/include/linux/math64.h
new file mode 100644
index 000000000000..c1a5f81501ff
--- /dev/null
+++ b/include/linux/math64.h
@@ -0,0 +1,84 @@
1#ifndef _LINUX_MATH64_H
2#define _LINUX_MATH64_H
3
4#include <linux/types.h>
5#include <asm/div64.h>
6
7#if BITS_PER_LONG == 64
8
9/**
10 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
11 *
12 * This is commonly provided by 32bit archs to provide an optimized 64bit
13 * divide.
14 */
15static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
16{
17 *remainder = dividend % divisor;
18 return dividend / divisor;
19}
20
21/**
22 * div_s64_rem - signed 64bit divide with 32bit divisor with remainder
23 */
24static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
25{
26 *remainder = dividend % divisor;
27 return dividend / divisor;
28}
29
30/**
31 * div64_u64 - unsigned 64bit divide with 64bit divisor
32 */
33static inline u64 div64_u64(u64 dividend, u64 divisor)
34{
35 return dividend / divisor;
36}
37
38#elif BITS_PER_LONG == 32
39
40#ifndef div_u64_rem
41static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
42{
43 *remainder = do_div(dividend, divisor);
44 return dividend;
45}
46#endif
47
48#ifndef div_s64_rem
49extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder);
50#endif
51
52#ifndef div64_u64
53extern u64 div64_u64(u64 dividend, u64 divisor);
54#endif
55
56#endif /* BITS_PER_LONG */
57
58/**
59 * div_u64 - unsigned 64bit divide with 32bit divisor
60 *
61 * This is the most common 64bit divide and should be used if possible,
62 * as many 32bit archs can optimize this variant better than a full 64bit
63 * divide.
64 */
65#ifndef div_u64
66static inline u64 div_u64(u64 dividend, u32 divisor)
67{
68 u32 remainder;
69 return div_u64_rem(dividend, divisor, &remainder);
70}
71#endif
72
73/**
74 * div_s64 - signed 64bit divide with 32bit divisor
75 */
76#ifndef div_s64
77static inline s64 div_s64(s64 dividend, s32 divisor)
78{
79 s32 remainder;
80 return div_s64_rem(dividend, divisor, &remainder);
81}
82#endif
83
84#endif /* _LINUX_MATH64_H */
diff --git a/include/linux/module.h b/include/linux/module.h
index 819c4e889bf1..3e03b1acbc94 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -190,7 +190,7 @@ void *__symbol_get_gpl(const char *symbol);
190 extern typeof(sym) sym; \ 190 extern typeof(sym) sym; \
191 __CRC_SYMBOL(sym, sec) \ 191 __CRC_SYMBOL(sym, sec) \
192 static const char __kstrtab_##sym[] \ 192 static const char __kstrtab_##sym[] \
193 __attribute__((section("__ksymtab_strings"))) \ 193 __attribute__((section("__ksymtab_strings"), aligned(1))) \
194 = MODULE_SYMBOL_PREFIX #sym; \ 194 = MODULE_SYMBOL_PREFIX #sym; \
195 static const struct kernel_symbol __ksymtab_##sym \ 195 static const struct kernel_symbol __ksymtab_##sym \
196 __used \ 196 __used \
@@ -229,23 +229,6 @@ enum module_state
229 MODULE_STATE_GOING, 229 MODULE_STATE_GOING,
230}; 230};
231 231
232/* Similar stuff for section attributes. */
233struct module_sect_attr
234{
235 struct module_attribute mattr;
236 char *name;
237 unsigned long address;
238};
239
240struct module_sect_attrs
241{
242 struct attribute_group grp;
243 int nsections;
244 struct module_sect_attr attrs[0];
245};
246
247struct module_param_attrs;
248
249struct module 232struct module
250{ 233{
251 enum module_state state; 234 enum module_state state;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index e5a53daf17f1..cf6dbd759395 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1429,6 +1429,7 @@
1429#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9 1429#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9
1430#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA 1430#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA
1431#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB 1431#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB
1432#define PCIE_DEVICE_ID_NEO_4_IBM 0x00F4
1432 1433
1433#define PCI_VENDOR_ID_XIRCOM 0x115d 1434#define PCI_VENDOR_ID_XIRCOM 0x115d
1434#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101 1435#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 52e49dce6584..dcddfb200947 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -347,6 +347,9 @@ struct quota_info {
347 ((type) == USRQUOTA ? (sb_dqopt(sb)->flags & DQUOT_USR_SUSPENDED) : \ 347 ((type) == USRQUOTA ? (sb_dqopt(sb)->flags & DQUOT_USR_SUSPENDED) : \
348 (sb_dqopt(sb)->flags & DQUOT_GRP_SUSPENDED)) 348 (sb_dqopt(sb)->flags & DQUOT_GRP_SUSPENDED))
349 349
350#define sb_any_quota_suspended(sb) (sb_has_quota_suspended(sb, USRQUOTA) | \
351 sb_has_quota_suspended(sb, GRPQUOTA))
352
350int register_quota_format(struct quota_format_type *fmt); 353int register_quota_format(struct quota_format_type *fmt);
351void unregister_quota_format(struct quota_format_type *fmt); 354void unregister_quota_format(struct quota_format_type *fmt);
352 355
diff --git a/include/linux/string.h b/include/linux/string.h
index c5d3fcad7b57..efdc44593b52 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -109,5 +109,7 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp);
109extern char **argv_split(gfp_t gfp, const char *str, int *argcp); 109extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
110extern void argv_free(char **argv); 110extern void argv_free(char **argv);
111 111
112extern bool sysfs_streq(const char *s1, const char *s2);
113
112#endif 114#endif
113#endif /* _LINUX_STRING_H_ */ 115#endif /* _LINUX_STRING_H_ */
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 7858eac40aa7..27bad59dae79 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -196,6 +196,12 @@ static inline int sysfs_update_group(struct kobject *kobj,
196 return 0; 196 return 0;
197} 197}
198 198
199static inline int sysfs_update_group(struct kobject *kobj,
200 const struct attribute_group *grp)
201{
202 return 0;
203}
204
199static inline void sysfs_remove_group(struct kobject *kobj, 205static inline void sysfs_remove_group(struct kobject *kobj,
200 const struct attribute_group *grp) 206 const struct attribute_group *grp)
201{ 207{
diff --git a/include/linux/timex.h b/include/linux/timex.h
index 8ea3e71ba7fa..fc6035d29d56 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -58,6 +58,8 @@
58 58
59#include <asm/param.h> 59#include <asm/param.h>
60 60
61#define NTP_API 4 /* NTP API version */
62
61/* 63/*
62 * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen 64 * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
63 * for a slightly underdamped convergence characteristic. SHIFT_KH 65 * for a slightly underdamped convergence characteristic. SHIFT_KH
@@ -74,24 +76,22 @@
74#define MAXTC 10 /* maximum time constant (shift) */ 76#define MAXTC 10 /* maximum time constant (shift) */
75 77
76/* 78/*
77 * The SHIFT_UPDATE define establishes the decimal point of the
78 * time_offset variable which represents the current offset with
79 * respect to standard time.
80 *
81 * SHIFT_USEC defines the scaling (shift) of the time_freq and 79 * SHIFT_USEC defines the scaling (shift) of the time_freq and
82 * time_tolerance variables, which represent the current frequency 80 * time_tolerance variables, which represent the current frequency
83 * offset and maximum frequency tolerance. 81 * offset and maximum frequency tolerance.
84 */ 82 */
85#define SHIFT_UPDATE (SHIFT_HZ + 1) /* time offset scale (shift) */
86#define SHIFT_USEC 16 /* frequency offset scale (shift) */ 83#define SHIFT_USEC 16 /* frequency offset scale (shift) */
87#define SHIFT_NSEC 12 /* kernel frequency offset scale */ 84#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
88 85#define PPM_SCALE_INV_SHIFT 20
89#define MAXPHASE 512000L /* max phase error (us) */ 86#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
90#define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */ 87 PPM_SCALE + 1)
91#define MAXFREQ_NSEC (512000L << SHIFT_NSEC) /* max frequency error (ppb) */ 88
89#define MAXPHASE 500000000l /* max phase error (ns) */
90#define MAXFREQ 500000 /* max frequency error (ns/s) */
91#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
92#define MINSEC 256 /* min interval between updates (s) */ 92#define MINSEC 256 /* min interval between updates (s) */
93#define MAXSEC 2048 /* max interval between updates (s) */ 93#define MAXSEC 2048 /* max interval between updates (s) */
94#define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */ 94#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
95 95
96/* 96/*
97 * syscall interface - used (mainly by NTP daemon) 97 * syscall interface - used (mainly by NTP daemon)
@@ -121,9 +121,11 @@ struct timex {
121 long errcnt; /* calibration errors (ro) */ 121 long errcnt; /* calibration errors (ro) */
122 long stbcnt; /* stability limit exceeded (ro) */ 122 long stbcnt; /* stability limit exceeded (ro) */
123 123
124 int tai; /* TAI offset (ro) */
125
124 int :32; int :32; int :32; int :32; 126 int :32; int :32; int :32; int :32;
125 int :32; int :32; int :32; int :32; 127 int :32; int :32; int :32; int :32;
126 int :32; int :32; int :32; int :32; 128 int :32; int :32; int :32;
127}; 129};
128 130
129/* 131/*
@@ -135,6 +137,9 @@ struct timex {
135#define ADJ_ESTERROR 0x0008 /* estimated time error */ 137#define ADJ_ESTERROR 0x0008 /* estimated time error */
136#define ADJ_STATUS 0x0010 /* clock status */ 138#define ADJ_STATUS 0x0010 /* clock status */
137#define ADJ_TIMECONST 0x0020 /* pll time constant */ 139#define ADJ_TIMECONST 0x0020 /* pll time constant */
140#define ADJ_TAI 0x0080 /* set TAI offset */
141#define ADJ_MICRO 0x1000 /* select microsecond resolution */
142#define ADJ_NANO 0x2000 /* select nanosecond resolution */
138#define ADJ_TICK 0x4000 /* tick value */ 143#define ADJ_TICK 0x4000 /* tick value */
139#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ 144#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
140#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ 145#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
@@ -146,8 +151,6 @@ struct timex {
146#define MOD_ESTERROR ADJ_ESTERROR 151#define MOD_ESTERROR ADJ_ESTERROR
147#define MOD_STATUS ADJ_STATUS 152#define MOD_STATUS ADJ_STATUS
148#define MOD_TIMECONST ADJ_TIMECONST 153#define MOD_TIMECONST ADJ_TIMECONST
149#define MOD_CLKB ADJ_TICK
150#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */
151 154
152 155
153/* 156/*
@@ -169,9 +172,13 @@ struct timex {
169#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ 172#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
170 173
171#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ 174#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
175#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */
176#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */
177#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */
172 178
179/* read-only bits */
173#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ 180#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
174 STA_PPSERROR | STA_CLOCKERR) /* read-only bits */ 181 STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
175 182
176/* 183/*
177 * Clock states (time_state) 184 * Clock states (time_state)
@@ -203,10 +210,9 @@ extern int time_status; /* clock synchronization status bits */
203extern long time_maxerror; /* maximum error */ 210extern long time_maxerror; /* maximum error */
204extern long time_esterror; /* estimated error */ 211extern long time_esterror; /* estimated error */
205 212
206extern long time_freq; /* frequency offset (scaled ppm) */
207
208extern long time_adjust; /* The amount of adjtime left */ 213extern long time_adjust; /* The amount of adjtime left */
209 214
215extern void ntp_init(void);
210extern void ntp_clear(void); 216extern void ntp_clear(void);
211 217
212/** 218/**
@@ -225,7 +231,7 @@ static inline int ntp_synced(void)
225 __x < 0 ? -(-__x >> __s) : __x >> __s; \ 231 __x < 0 ? -(-__x >> __s) : __x >> __s; \
226}) 232})
227 233
228#define TICK_LENGTH_SHIFT 32 234#define NTP_SCALE_SHIFT 32
229 235
230#ifdef CONFIG_NO_HZ 236#ifdef CONFIG_NO_HZ
231#define NTP_INTERVAL_FREQ (2) 237#define NTP_INTERVAL_FREQ (2)
@@ -234,8 +240,8 @@ static inline int ntp_synced(void)
234#endif 240#endif
235#define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) 241#define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ)
236 242
237/* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */ 243/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
238extern u64 current_tick_length(void); 244extern u64 tick_length;
239 245
240extern void second_overflow(void); 246extern void second_overflow(void);
241extern void update_ntp_one_tick(void); 247extern void update_ntp_one_tick(void);
diff --git a/kernel/compat.c b/kernel/compat.c
index 4a856a3643bb..32c254a8ab9a 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -955,7 +955,8 @@ asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp)
955 __put_user(txc.jitcnt, &utp->jitcnt) || 955 __put_user(txc.jitcnt, &utp->jitcnt) ||
956 __put_user(txc.calcnt, &utp->calcnt) || 956 __put_user(txc.calcnt, &utp->calcnt) ||
957 __put_user(txc.errcnt, &utp->errcnt) || 957 __put_user(txc.errcnt, &utp->errcnt) ||
958 __put_user(txc.stbcnt, &utp->stbcnt)) 958 __put_user(txc.stbcnt, &utp->stbcnt) ||
959 __put_user(txc.tai, &utp->tai))
959 ret = -EFAULT; 960 ret = -EFAULT;
960 961
961 return ret; 962 return ret;
diff --git a/kernel/kexec.c b/kernel/kexec.c
index cb85c79989b4..1c5fcacbcf33 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1217,7 +1217,7 @@ static int __init parse_crashkernel_mem(char *cmdline,
1217 } 1217 }
1218 1218
1219 /* match ? */ 1219 /* match ? */
1220 if (system_ram >= start && system_ram <= end) { 1220 if (system_ram >= start && system_ram < end) {
1221 *crash_size = size; 1221 *crash_size = size;
1222 break; 1222 break;
1223 } 1223 }
diff --git a/kernel/module.c b/kernel/module.c
index 8d6cccc6c3cf..8674a390a2e8 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -164,131 +164,140 @@ static const struct kernel_symbol *lookup_symbol(const char *name,
164 return NULL; 164 return NULL;
165} 165}
166 166
167static void printk_unused_warning(const char *name) 167static bool always_ok(bool gplok, bool warn, const char *name)
168{ 168{
169 printk(KERN_WARNING "Symbol %s is marked as UNUSED, " 169 return true;
170 "however this module is using it.\n", name);
171 printk(KERN_WARNING "This symbol will go away in the future.\n");
172 printk(KERN_WARNING "Please evalute if this is the right api to use, "
173 "and if it really is, submit a report the linux kernel "
174 "mailinglist together with submitting your code for "
175 "inclusion.\n");
176} 170}
177 171
178/* Find a symbol, return value, crc and module which owns it */ 172static bool printk_unused_warning(bool gplok, bool warn, const char *name)
179static unsigned long __find_symbol(const char *name,
180 struct module **owner,
181 const unsigned long **crc,
182 int gplok)
183{ 173{
184 struct module *mod; 174 if (warn) {
185 const struct kernel_symbol *ks; 175 printk(KERN_WARNING "Symbol %s is marked as UNUSED, "
186 176 "however this module is using it.\n", name);
187 /* Core kernel first. */ 177 printk(KERN_WARNING
188 *owner = NULL; 178 "This symbol will go away in the future.\n");
189 ks = lookup_symbol(name, __start___ksymtab, __stop___ksymtab); 179 printk(KERN_WARNING
190 if (ks) { 180 "Please evalute if this is the right api to use and if "
191 *crc = symversion(__start___kcrctab, (ks - __start___ksymtab)); 181 "it really is, submit a report the linux kernel "
192 return ks->value; 182 "mailinglist together with submitting your code for "
183 "inclusion.\n");
193 } 184 }
194 if (gplok) { 185 return true;
195 ks = lookup_symbol(name, __start___ksymtab_gpl, 186}
196 __stop___ksymtab_gpl); 187
197 if (ks) { 188static bool gpl_only_unused_warning(bool gplok, bool warn, const char *name)
198 *crc = symversion(__start___kcrctab_gpl, 189{
199 (ks - __start___ksymtab_gpl)); 190 if (!gplok)
200 return ks->value; 191 return false;
201 } 192 return printk_unused_warning(gplok, warn, name);
202 } 193}
203 ks = lookup_symbol(name, __start___ksymtab_gpl_future, 194
204 __stop___ksymtab_gpl_future); 195static bool gpl_only(bool gplok, bool warn, const char *name)
205 if (ks) { 196{
206 if (!gplok) { 197 return gplok;
207 printk(KERN_WARNING "Symbol %s is being used " 198}
208 "by a non-GPL module, which will not " 199
209 "be allowed in the future\n", name); 200static bool warn_if_not_gpl(bool gplok, bool warn, const char *name)
210 printk(KERN_WARNING "Please see the file " 201{
211 "Documentation/feature-removal-schedule.txt " 202 if (!gplok && warn) {
212 "in the kernel source tree for more " 203 printk(KERN_WARNING "Symbol %s is being used "
213 "details.\n"); 204 "by a non-GPL module, which will not "
214 } 205 "be allowed in the future\n", name);
215 *crc = symversion(__start___kcrctab_gpl_future, 206 printk(KERN_WARNING "Please see the file "
216 (ks - __start___ksymtab_gpl_future)); 207 "Documentation/feature-removal-schedule.txt "
217 return ks->value; 208 "in the kernel source tree for more details.\n");
218 } 209 }
210 return true;
211}
219 212
220 ks = lookup_symbol(name, __start___ksymtab_unused, 213struct symsearch {
221 __stop___ksymtab_unused); 214 const struct kernel_symbol *start, *stop;
222 if (ks) { 215 const unsigned long *crcs;
223 printk_unused_warning(name); 216 bool (*check)(bool gplok, bool warn, const char *name);
224 *crc = symversion(__start___kcrctab_unused, 217};
225 (ks - __start___ksymtab_unused)); 218
226 return ks->value; 219/* Look through this array of symbol tables for a symbol match which
220 * passes the check function. */
221static const struct kernel_symbol *search_symarrays(const struct symsearch *arr,
222 unsigned int num,
223 const char *name,
224 bool gplok,
225 bool warn,
226 const unsigned long **crc)
227{
228 unsigned int i;
229 const struct kernel_symbol *ks;
230
231 for (i = 0; i < num; i++) {
232 ks = lookup_symbol(name, arr[i].start, arr[i].stop);
233 if (!ks || !arr[i].check(gplok, warn, name))
234 continue;
235
236 if (crc)
237 *crc = symversion(arr[i].crcs, ks - arr[i].start);
238 return ks;
227 } 239 }
240 return NULL;
241}
242
243/* Find a symbol, return value, (optional) crc and (optional) module
244 * which owns it */
245static unsigned long find_symbol(const char *name,
246 struct module **owner,
247 const unsigned long **crc,
248 bool gplok,
249 bool warn)
250{
251 struct module *mod;
252 const struct kernel_symbol *ks;
253 const struct symsearch arr[] = {
254 { __start___ksymtab, __stop___ksymtab, __start___kcrctab,
255 always_ok },
256 { __start___ksymtab_gpl, __stop___ksymtab_gpl,
257 __start___kcrctab_gpl, gpl_only },
258 { __start___ksymtab_gpl_future, __stop___ksymtab_gpl_future,
259 __start___kcrctab_gpl_future, warn_if_not_gpl },
260 { __start___ksymtab_unused, __stop___ksymtab_unused,
261 __start___kcrctab_unused, printk_unused_warning },
262 { __start___ksymtab_unused_gpl, __stop___ksymtab_unused_gpl,
263 __start___kcrctab_unused_gpl, gpl_only_unused_warning },
264 };
228 265
229 if (gplok) 266 /* Core kernel first. */
230 ks = lookup_symbol(name, __start___ksymtab_unused_gpl, 267 ks = search_symarrays(arr, ARRAY_SIZE(arr), name, gplok, warn, crc);
231 __stop___ksymtab_unused_gpl);
232 if (ks) { 268 if (ks) {
233 printk_unused_warning(name); 269 if (owner)
234 *crc = symversion(__start___kcrctab_unused_gpl, 270 *owner = NULL;
235 (ks - __start___ksymtab_unused_gpl));
236 return ks->value; 271 return ks->value;
237 } 272 }
238 273
239 /* Now try modules. */ 274 /* Now try modules. */
240 list_for_each_entry(mod, &modules, list) { 275 list_for_each_entry(mod, &modules, list) {
241 *owner = mod; 276 struct symsearch arr[] = {
242 ks = lookup_symbol(name, mod->syms, mod->syms + mod->num_syms); 277 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
243 if (ks) { 278 always_ok },
244 *crc = symversion(mod->crcs, (ks - mod->syms)); 279 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
245 return ks->value; 280 mod->gpl_crcs, gpl_only },
246 } 281 { mod->gpl_future_syms,
247 282 mod->gpl_future_syms + mod->num_gpl_future_syms,
248 if (gplok) { 283 mod->gpl_future_crcs, warn_if_not_gpl },
249 ks = lookup_symbol(name, mod->gpl_syms, 284 { mod->unused_syms,
250 mod->gpl_syms + mod->num_gpl_syms); 285 mod->unused_syms + mod->num_unused_syms,
251 if (ks) { 286 mod->unused_crcs, printk_unused_warning },
252 *crc = symversion(mod->gpl_crcs, 287 { mod->unused_gpl_syms,
253 (ks - mod->gpl_syms)); 288 mod->unused_gpl_syms + mod->num_unused_gpl_syms,
254 return ks->value; 289 mod->unused_gpl_crcs, gpl_only_unused_warning },
255 } 290 };
256 } 291
257 ks = lookup_symbol(name, mod->unused_syms, mod->unused_syms + mod->num_unused_syms); 292 ks = search_symarrays(arr, ARRAY_SIZE(arr),
293 name, gplok, warn, crc);
258 if (ks) { 294 if (ks) {
259 printk_unused_warning(name); 295 if (owner)
260 *crc = symversion(mod->unused_crcs, (ks - mod->unused_syms)); 296 *owner = mod;
261 return ks->value;
262 }
263
264 if (gplok) {
265 ks = lookup_symbol(name, mod->unused_gpl_syms,
266 mod->unused_gpl_syms + mod->num_unused_gpl_syms);
267 if (ks) {
268 printk_unused_warning(name);
269 *crc = symversion(mod->unused_gpl_crcs,
270 (ks - mod->unused_gpl_syms));
271 return ks->value;
272 }
273 }
274 ks = lookup_symbol(name, mod->gpl_future_syms,
275 (mod->gpl_future_syms +
276 mod->num_gpl_future_syms));
277 if (ks) {
278 if (!gplok) {
279 printk(KERN_WARNING "Symbol %s is being used "
280 "by a non-GPL module, which will not "
281 "be allowed in the future\n", name);
282 printk(KERN_WARNING "Please see the file "
283 "Documentation/feature-removal-schedule.txt "
284 "in the kernel source tree for more "
285 "details.\n");
286 }
287 *crc = symversion(mod->gpl_future_crcs,
288 (ks - mod->gpl_future_syms));
289 return ks->value; 297 return ks->value;
290 } 298 }
291 } 299 }
300
292 DEBUGP("Failed to find symbol %s\n", name); 301 DEBUGP("Failed to find symbol %s\n", name);
293 return -ENOENT; 302 return -ENOENT;
294} 303}
@@ -736,12 +745,13 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
736 if (!forced && module_refcount(mod) != 0) 745 if (!forced && module_refcount(mod) != 0)
737 wait_for_zero_refcount(mod); 746 wait_for_zero_refcount(mod);
738 747
748 mutex_unlock(&module_mutex);
739 /* Final destruction now noone is using it. */ 749 /* Final destruction now noone is using it. */
740 if (mod->exit != NULL) { 750 if (mod->exit != NULL)
741 mutex_unlock(&module_mutex);
742 mod->exit(); 751 mod->exit();
743 mutex_lock(&module_mutex); 752 blocking_notifier_call_chain(&module_notify_list,
744 } 753 MODULE_STATE_GOING, mod);
754 mutex_lock(&module_mutex);
745 /* Store the name of the last unloaded module for diagnostic purposes */ 755 /* Store the name of the last unloaded module for diagnostic purposes */
746 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); 756 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
747 free_module(mod); 757 free_module(mod);
@@ -777,10 +787,9 @@ static void print_unload_info(struct seq_file *m, struct module *mod)
777void __symbol_put(const char *symbol) 787void __symbol_put(const char *symbol)
778{ 788{
779 struct module *owner; 789 struct module *owner;
780 const unsigned long *crc;
781 790
782 preempt_disable(); 791 preempt_disable();
783 if (IS_ERR_VALUE(__find_symbol(symbol, &owner, &crc, 1))) 792 if (IS_ERR_VALUE(find_symbol(symbol, &owner, NULL, true, false)))
784 BUG(); 793 BUG();
785 module_put(owner); 794 module_put(owner);
786 preempt_enable(); 795 preempt_enable();
@@ -924,13 +933,10 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
924 struct module *mod) 933 struct module *mod)
925{ 934{
926 const unsigned long *crc; 935 const unsigned long *crc;
927 struct module *owner;
928 936
929 if (IS_ERR_VALUE(__find_symbol("struct_module", 937 if (IS_ERR_VALUE(find_symbol("struct_module", NULL, &crc, true, false)))
930 &owner, &crc, 1)))
931 BUG(); 938 BUG();
932 return check_version(sechdrs, versindex, "struct_module", mod, 939 return check_version(sechdrs, versindex, "struct_module", mod, crc);
933 crc);
934} 940}
935 941
936/* First part is kernel version, which we ignore. */ 942/* First part is kernel version, which we ignore. */
@@ -974,8 +980,8 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
974 unsigned long ret; 980 unsigned long ret;
975 const unsigned long *crc; 981 const unsigned long *crc;
976 982
977 ret = __find_symbol(name, &owner, &crc, 983 ret = find_symbol(name, &owner, &crc,
978 !(mod->taints & TAINT_PROPRIETARY_MODULE)); 984 !(mod->taints & TAINT_PROPRIETARY_MODULE), true);
979 if (!IS_ERR_VALUE(ret)) { 985 if (!IS_ERR_VALUE(ret)) {
980 /* use_module can fail due to OOM, 986 /* use_module can fail due to OOM,
981 or module initialization or unloading */ 987 or module initialization or unloading */
@@ -991,6 +997,20 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
991 * J. Corbet <corbet@lwn.net> 997 * J. Corbet <corbet@lwn.net>
992 */ 998 */
993#if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS) 999#if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS)
1000struct module_sect_attr
1001{
1002 struct module_attribute mattr;
1003 char *name;
1004 unsigned long address;
1005};
1006
1007struct module_sect_attrs
1008{
1009 struct attribute_group grp;
1010 unsigned int nsections;
1011 struct module_sect_attr attrs[0];
1012};
1013
994static ssize_t module_sect_show(struct module_attribute *mattr, 1014static ssize_t module_sect_show(struct module_attribute *mattr,
995 struct module *mod, char *buf) 1015 struct module *mod, char *buf)
996{ 1016{
@@ -1001,7 +1021,7 @@ static ssize_t module_sect_show(struct module_attribute *mattr,
1001 1021
1002static void free_sect_attrs(struct module_sect_attrs *sect_attrs) 1022static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
1003{ 1023{
1004 int section; 1024 unsigned int section;
1005 1025
1006 for (section = 0; section < sect_attrs->nsections; section++) 1026 for (section = 0; section < sect_attrs->nsections; section++)
1007 kfree(sect_attrs->attrs[section].name); 1027 kfree(sect_attrs->attrs[section].name);
@@ -1362,10 +1382,9 @@ void *__symbol_get(const char *symbol)
1362{ 1382{
1363 struct module *owner; 1383 struct module *owner;
1364 unsigned long value; 1384 unsigned long value;
1365 const unsigned long *crc;
1366 1385
1367 preempt_disable(); 1386 preempt_disable();
1368 value = __find_symbol(symbol, &owner, &crc, 1); 1387 value = find_symbol(symbol, &owner, NULL, true, true);
1369 if (IS_ERR_VALUE(value)) 1388 if (IS_ERR_VALUE(value))
1370 value = 0; 1389 value = 0;
1371 else if (strong_try_module_get(owner)) 1390 else if (strong_try_module_get(owner))
@@ -1382,33 +1401,33 @@ EXPORT_SYMBOL_GPL(__symbol_get);
1382 */ 1401 */
1383static int verify_export_symbols(struct module *mod) 1402static int verify_export_symbols(struct module *mod)
1384{ 1403{
1385 const char *name = NULL; 1404 unsigned int i;
1386 unsigned long i, ret = 0;
1387 struct module *owner; 1405 struct module *owner;
1388 const unsigned long *crc; 1406 const struct kernel_symbol *s;
1389 1407 struct {
1390 for (i = 0; i < mod->num_syms; i++) 1408 const struct kernel_symbol *sym;
1391 if (!IS_ERR_VALUE(__find_symbol(mod->syms[i].name, 1409 unsigned int num;
1392 &owner, &crc, 1))) { 1410 } arr[] = {
1393 name = mod->syms[i].name; 1411 { mod->syms, mod->num_syms },
1394 ret = -ENOEXEC; 1412 { mod->gpl_syms, mod->num_gpl_syms },
1395 goto dup; 1413 { mod->gpl_future_syms, mod->num_gpl_future_syms },
1396 } 1414 { mod->unused_syms, mod->num_unused_syms },
1415 { mod->unused_gpl_syms, mod->num_unused_gpl_syms },
1416 };
1397 1417
1398 for (i = 0; i < mod->num_gpl_syms; i++) 1418 for (i = 0; i < ARRAY_SIZE(arr); i++) {
1399 if (!IS_ERR_VALUE(__find_symbol(mod->gpl_syms[i].name, 1419 for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
1400 &owner, &crc, 1))) { 1420 if (!IS_ERR_VALUE(find_symbol(s->name, &owner,
1401 name = mod->gpl_syms[i].name; 1421 NULL, true, false))) {
1402 ret = -ENOEXEC; 1422 printk(KERN_ERR
1403 goto dup; 1423 "%s: exports duplicate symbol %s"
1424 " (owned by %s)\n",
1425 mod->name, s->name, module_name(owner));
1426 return -ENOEXEC;
1427 }
1404 } 1428 }
1405 1429 }
1406dup: 1430 return 0;
1407 if (ret)
1408 printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
1409 mod->name, name, module_name(owner));
1410
1411 return ret;
1412} 1431}
1413 1432
1414/* Change all symbols so that st_value encodes the pointer directly. */ 1433/* Change all symbols so that st_value encodes the pointer directly. */
@@ -1814,8 +1833,9 @@ static struct module *load_module(void __user *umod,
1814 unwindex = find_sec(hdr, sechdrs, secstrings, ARCH_UNWIND_SECTION_NAME); 1833 unwindex = find_sec(hdr, sechdrs, secstrings, ARCH_UNWIND_SECTION_NAME);
1815#endif 1834#endif
1816 1835
1817 /* Don't keep modinfo section */ 1836 /* Don't keep modinfo and version sections. */
1818 sechdrs[infoindex].sh_flags &= ~(unsigned long)SHF_ALLOC; 1837 sechdrs[infoindex].sh_flags &= ~(unsigned long)SHF_ALLOC;
1838 sechdrs[versindex].sh_flags &= ~(unsigned long)SHF_ALLOC;
1819#ifdef CONFIG_KALLSYMS 1839#ifdef CONFIG_KALLSYMS
1820 /* Keep symbol and string tables for decoding later. */ 1840 /* Keep symbol and string tables for decoding later. */
1821 sechdrs[symindex].sh_flags |= SHF_ALLOC; 1841 sechdrs[symindex].sh_flags |= SHF_ALLOC;
@@ -1977,7 +1997,8 @@ static struct module *load_module(void __user *umod,
1977 mod->unused_crcs = (void *)sechdrs[unusedcrcindex].sh_addr; 1997 mod->unused_crcs = (void *)sechdrs[unusedcrcindex].sh_addr;
1978 mod->unused_gpl_syms = (void *)sechdrs[unusedgplindex].sh_addr; 1998 mod->unused_gpl_syms = (void *)sechdrs[unusedgplindex].sh_addr;
1979 if (unusedgplcrcindex) 1999 if (unusedgplcrcindex)
1980 mod->unused_crcs = (void *)sechdrs[unusedgplcrcindex].sh_addr; 2000 mod->unused_gpl_crcs
2001 = (void *)sechdrs[unusedgplcrcindex].sh_addr;
1981 2002
1982#ifdef CONFIG_MODVERSIONS 2003#ifdef CONFIG_MODVERSIONS
1983 if ((mod->num_syms && !crcindex) || 2004 if ((mod->num_syms && !crcindex) ||
@@ -2171,6 +2192,8 @@ sys_init_module(void __user *umod,
2171 mod->state = MODULE_STATE_GOING; 2192 mod->state = MODULE_STATE_GOING;
2172 synchronize_sched(); 2193 synchronize_sched();
2173 module_put(mod); 2194 module_put(mod);
2195 blocking_notifier_call_chain(&module_notify_list,
2196 MODULE_STATE_GOING, mod);
2174 mutex_lock(&module_mutex); 2197 mutex_lock(&module_mutex);
2175 free_module(mod); 2198 free_module(mod);
2176 mutex_unlock(&module_mutex); 2199 mutex_unlock(&module_mutex);
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index ae5c6c147c4b..f1525ad06cb3 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -4,8 +4,9 @@
4 4
5#include <linux/sched.h> 5#include <linux/sched.h>
6#include <linux/posix-timers.h> 6#include <linux/posix-timers.h>
7#include <asm/uaccess.h>
8#include <linux/errno.h> 7#include <linux/errno.h>
8#include <linux/math64.h>
9#include <asm/uaccess.h>
9 10
10static int check_clock(const clockid_t which_clock) 11static int check_clock(const clockid_t which_clock)
11{ 12{
@@ -47,12 +48,10 @@ static void sample_to_timespec(const clockid_t which_clock,
47 union cpu_time_count cpu, 48 union cpu_time_count cpu,
48 struct timespec *tp) 49 struct timespec *tp)
49{ 50{
50 if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) { 51 if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED)
51 tp->tv_sec = div_long_long_rem(cpu.sched, 52 *tp = ns_to_timespec(cpu.sched);
52 NSEC_PER_SEC, &tp->tv_nsec); 53 else
53 } else {
54 cputime_to_timespec(cpu.cpu, tp); 54 cputime_to_timespec(cpu.cpu, tp);
55 }
56} 55}
57 56
58static inline int cpu_time_before(const clockid_t which_clock, 57static inline int cpu_time_before(const clockid_t which_clock,
diff --git a/kernel/sched.c b/kernel/sched.c
index e2f7f5acc807..34bcc5bc120e 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -8025,7 +8025,7 @@ static void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
8025 8025
8026 se->my_q = cfs_rq; 8026 se->my_q = cfs_rq;
8027 se->load.weight = tg->shares; 8027 se->load.weight = tg->shares;
8028 se->load.inv_weight = div64_64(1ULL<<32, se->load.weight); 8028 se->load.inv_weight = div64_u64(1ULL<<32, se->load.weight);
8029 se->parent = parent; 8029 se->parent = parent;
8030} 8030}
8031#endif 8031#endif
@@ -8692,7 +8692,7 @@ static void __set_se_shares(struct sched_entity *se, unsigned long shares)
8692 dequeue_entity(cfs_rq, se, 0); 8692 dequeue_entity(cfs_rq, se, 0);
8693 8693
8694 se->load.weight = shares; 8694 se->load.weight = shares;
8695 se->load.inv_weight = div64_64((1ULL<<32), shares); 8695 se->load.inv_weight = div64_u64((1ULL<<32), shares);
8696 8696
8697 if (on_rq) 8697 if (on_rq)
8698 enqueue_entity(cfs_rq, se, 0); 8698 enqueue_entity(cfs_rq, se, 0);
@@ -8787,7 +8787,7 @@ static unsigned long to_ratio(u64 period, u64 runtime)
8787 if (runtime == RUNTIME_INF) 8787 if (runtime == RUNTIME_INF)
8788 return 1ULL << 16; 8788 return 1ULL << 16;
8789 8789
8790 return div64_64(runtime << 16, period); 8790 return div64_u64(runtime << 16, period);
8791} 8791}
8792 8792
8793#ifdef CONFIG_CGROUP_SCHED 8793#ifdef CONFIG_CGROUP_SCHED
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 8a9498e7c831..6b4a12558e88 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -357,8 +357,8 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
357 357
358 avg_per_cpu = p->se.sum_exec_runtime; 358 avg_per_cpu = p->se.sum_exec_runtime;
359 if (p->se.nr_migrations) { 359 if (p->se.nr_migrations) {
360 avg_per_cpu = div64_64(avg_per_cpu, 360 avg_per_cpu = div64_u64(avg_per_cpu,
361 p->se.nr_migrations); 361 p->se.nr_migrations);
362 } else { 362 } else {
363 avg_per_cpu = -1LL; 363 avg_per_cpu = -1LL;
364 } 364 }
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 3c44956ee7e2..36e061740047 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -589,16 +589,20 @@ static void takeover_tasklets(unsigned int cpu)
589 local_irq_disable(); 589 local_irq_disable();
590 590
591 /* Find end, append list for that CPU. */ 591 /* Find end, append list for that CPU. */
592 *__get_cpu_var(tasklet_vec).tail = per_cpu(tasklet_vec, cpu).head; 592 if (&per_cpu(tasklet_vec, cpu).head != per_cpu(tasklet_vec, cpu).tail) {
593 __get_cpu_var(tasklet_vec).tail = per_cpu(tasklet_vec, cpu).tail; 593 *(__get_cpu_var(tasklet_vec).tail) = per_cpu(tasklet_vec, cpu).head;
594 per_cpu(tasklet_vec, cpu).head = NULL; 594 __get_cpu_var(tasklet_vec).tail = per_cpu(tasklet_vec, cpu).tail;
595 per_cpu(tasklet_vec, cpu).tail = &per_cpu(tasklet_vec, cpu).head; 595 per_cpu(tasklet_vec, cpu).head = NULL;
596 per_cpu(tasklet_vec, cpu).tail = &per_cpu(tasklet_vec, cpu).head;
597 }
596 raise_softirq_irqoff(TASKLET_SOFTIRQ); 598 raise_softirq_irqoff(TASKLET_SOFTIRQ);
597 599
598 *__get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).head; 600 if (&per_cpu(tasklet_hi_vec, cpu).head != per_cpu(tasklet_hi_vec, cpu).tail) {
599 __get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).tail; 601 *__get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).head;
600 per_cpu(tasklet_hi_vec, cpu).head = NULL; 602 __get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).tail;
601 per_cpu(tasklet_hi_vec, cpu).tail = &per_cpu(tasklet_hi_vec, cpu).head; 603 per_cpu(tasklet_hi_vec, cpu).head = NULL;
604 per_cpu(tasklet_hi_vec, cpu).tail = &per_cpu(tasklet_hi_vec, cpu).head;
605 }
602 raise_softirq_irqoff(HI_SOFTIRQ); 606 raise_softirq_irqoff(HI_SOFTIRQ);
603 607
604 local_irq_enable(); 608 local_irq_enable();
diff --git a/kernel/time.c b/kernel/time.c
index 86729042e4cd..cbe0d5a222ff 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -36,6 +36,7 @@
36#include <linux/security.h> 36#include <linux/security.h>
37#include <linux/fs.h> 37#include <linux/fs.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/math64.h>
39 40
40#include <asm/uaccess.h> 41#include <asm/uaccess.h>
41#include <asm/unistd.h> 42#include <asm/unistd.h>
@@ -391,13 +392,17 @@ EXPORT_SYMBOL(set_normalized_timespec);
391struct timespec ns_to_timespec(const s64 nsec) 392struct timespec ns_to_timespec(const s64 nsec)
392{ 393{
393 struct timespec ts; 394 struct timespec ts;
395 s32 rem;
394 396
395 if (!nsec) 397 if (!nsec)
396 return (struct timespec) {0, 0}; 398 return (struct timespec) {0, 0};
397 399
398 ts.tv_sec = div_long_long_rem_signed(nsec, NSEC_PER_SEC, &ts.tv_nsec); 400 ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem);
399 if (unlikely(nsec < 0)) 401 if (unlikely(rem < 0)) {
400 set_normalized_timespec(&ts, ts.tv_sec, ts.tv_nsec); 402 ts.tv_sec--;
403 rem += NSEC_PER_SEC;
404 }
405 ts.tv_nsec = rem;
401 406
402 return ts; 407 return ts;
403} 408}
@@ -527,8 +532,10 @@ jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
527 * Convert jiffies to nanoseconds and separate with 532 * Convert jiffies to nanoseconds and separate with
528 * one divide. 533 * one divide.
529 */ 534 */
530 u64 nsec = (u64)jiffies * TICK_NSEC; 535 u32 rem;
531 value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_nsec); 536 value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC,
537 NSEC_PER_SEC, &rem);
538 value->tv_nsec = rem;
532} 539}
533EXPORT_SYMBOL(jiffies_to_timespec); 540EXPORT_SYMBOL(jiffies_to_timespec);
534 541
@@ -566,12 +573,11 @@ void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)
566 * Convert jiffies to nanoseconds and separate with 573 * Convert jiffies to nanoseconds and separate with
567 * one divide. 574 * one divide.
568 */ 575 */
569 u64 nsec = (u64)jiffies * TICK_NSEC; 576 u32 rem;
570 long tv_usec;
571 577
572 value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &tv_usec); 578 value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC,
573 tv_usec /= NSEC_PER_USEC; 579 NSEC_PER_SEC, &rem);
574 value->tv_usec = tv_usec; 580 value->tv_usec = rem / NSEC_PER_USEC;
575} 581}
576EXPORT_SYMBOL(jiffies_to_timeval); 582EXPORT_SYMBOL(jiffies_to_timeval);
577 583
@@ -587,9 +593,7 @@ clock_t jiffies_to_clock_t(long x)
587 return x / (HZ / USER_HZ); 593 return x / (HZ / USER_HZ);
588# endif 594# endif
589#else 595#else
590 u64 tmp = (u64)x * TICK_NSEC; 596 return div_u64((u64)x * TICK_NSEC, NSEC_PER_SEC / USER_HZ);
591 do_div(tmp, (NSEC_PER_SEC / USER_HZ));
592 return (long)tmp;
593#endif 597#endif
594} 598}
595EXPORT_SYMBOL(jiffies_to_clock_t); 599EXPORT_SYMBOL(jiffies_to_clock_t);
@@ -601,16 +605,12 @@ unsigned long clock_t_to_jiffies(unsigned long x)
601 return ~0UL; 605 return ~0UL;
602 return x * (HZ / USER_HZ); 606 return x * (HZ / USER_HZ);
603#else 607#else
604 u64 jif;
605
606 /* Don't worry about loss of precision here .. */ 608 /* Don't worry about loss of precision here .. */
607 if (x >= ~0UL / HZ * USER_HZ) 609 if (x >= ~0UL / HZ * USER_HZ)
608 return ~0UL; 610 return ~0UL;
609 611
610 /* .. but do try to contain it here */ 612 /* .. but do try to contain it here */
611 jif = x * (u64) HZ; 613 return div_u64((u64)x * HZ, USER_HZ);
612 do_div(jif, USER_HZ);
613 return jif;
614#endif 614#endif
615} 615}
616EXPORT_SYMBOL(clock_t_to_jiffies); 616EXPORT_SYMBOL(clock_t_to_jiffies);
@@ -619,10 +619,9 @@ u64 jiffies_64_to_clock_t(u64 x)
619{ 619{
620#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0 620#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
621# if HZ < USER_HZ 621# if HZ < USER_HZ
622 x *= USER_HZ; 622 x = div_u64(x * USER_HZ, HZ);
623 do_div(x, HZ);
624# elif HZ > USER_HZ 623# elif HZ > USER_HZ
625 do_div(x, HZ / USER_HZ); 624 x = div_u64(x, HZ / USER_HZ);
626# else 625# else
627 /* Nothing to do */ 626 /* Nothing to do */
628# endif 627# endif
@@ -632,8 +631,7 @@ u64 jiffies_64_to_clock_t(u64 x)
632 * but even this doesn't overflow in hundreds of years 631 * but even this doesn't overflow in hundreds of years
633 * in 64 bits, so.. 632 * in 64 bits, so..
634 */ 633 */
635 x *= TICK_NSEC; 634 x = div_u64(x * TICK_NSEC, (NSEC_PER_SEC / USER_HZ));
636 do_div(x, (NSEC_PER_SEC / USER_HZ));
637#endif 635#endif
638 return x; 636 return x;
639} 637}
@@ -642,21 +640,17 @@ EXPORT_SYMBOL(jiffies_64_to_clock_t);
642u64 nsec_to_clock_t(u64 x) 640u64 nsec_to_clock_t(u64 x)
643{ 641{
644#if (NSEC_PER_SEC % USER_HZ) == 0 642#if (NSEC_PER_SEC % USER_HZ) == 0
645 do_div(x, (NSEC_PER_SEC / USER_HZ)); 643 return div_u64(x, NSEC_PER_SEC / USER_HZ);
646#elif (USER_HZ % 512) == 0 644#elif (USER_HZ % 512) == 0
647 x *= USER_HZ/512; 645 return div_u64(x * USER_HZ / 512, NSEC_PER_SEC / 512);
648 do_div(x, (NSEC_PER_SEC / 512));
649#else 646#else
650 /* 647 /*
651 * max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024, 648 * max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024,
652 * overflow after 64.99 years. 649 * overflow after 64.99 years.
653 * exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ... 650 * exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ...
654 */ 651 */
655 x *= 9; 652 return div_u64(x * 9, (9ull * NSEC_PER_SEC + (USER_HZ / 2)) / USER_HZ);
656 do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (USER_HZ/2)) /
657 USER_HZ));
658#endif 653#endif
659 return x;
660} 654}
661 655
662#if (BITS_PER_LONG < 64) 656#if (BITS_PER_LONG < 64)
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 5fd9b9469770..5125ddd8196b 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -15,7 +15,8 @@
15#include <linux/jiffies.h> 15#include <linux/jiffies.h>
16#include <linux/hrtimer.h> 16#include <linux/hrtimer.h>
17#include <linux/capability.h> 17#include <linux/capability.h>
18#include <asm/div64.h> 18#include <linux/math64.h>
19#include <linux/clocksource.h>
19#include <asm/timex.h> 20#include <asm/timex.h>
20 21
21/* 22/*
@@ -23,11 +24,14 @@
23 */ 24 */
24unsigned long tick_usec = TICK_USEC; /* USER_HZ period (usec) */ 25unsigned long tick_usec = TICK_USEC; /* USER_HZ period (usec) */
25unsigned long tick_nsec; /* ACTHZ period (nsec) */ 26unsigned long tick_nsec; /* ACTHZ period (nsec) */
26static u64 tick_length, tick_length_base; 27u64 tick_length;
28static u64 tick_length_base;
29
30static struct hrtimer leap_timer;
27 31
28#define MAX_TICKADJ 500 /* microsecs */ 32#define MAX_TICKADJ 500 /* microsecs */
29#define MAX_TICKADJ_SCALED (((u64)(MAX_TICKADJ * NSEC_PER_USEC) << \ 33#define MAX_TICKADJ_SCALED (((u64)(MAX_TICKADJ * NSEC_PER_USEC) << \
30 TICK_LENGTH_SHIFT) / NTP_INTERVAL_FREQ) 34 NTP_SCALE_SHIFT) / NTP_INTERVAL_FREQ)
31 35
32/* 36/*
33 * phase-lock loop variables 37 * phase-lock loop variables
@@ -35,11 +39,12 @@ static u64 tick_length, tick_length_base;
35/* TIME_ERROR prevents overwriting the CMOS clock */ 39/* TIME_ERROR prevents overwriting the CMOS clock */
36static int time_state = TIME_OK; /* clock synchronization status */ 40static int time_state = TIME_OK; /* clock synchronization status */
37int time_status = STA_UNSYNC; /* clock status bits */ 41int time_status = STA_UNSYNC; /* clock status bits */
38static s64 time_offset; /* time adjustment (ns) */ 42static long time_tai; /* TAI offset (s) */
43static s64 time_offset; /* time adjustment (ns) */
39static long time_constant = 2; /* pll time constant */ 44static long time_constant = 2; /* pll time constant */
40long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */ 45long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */
41long time_esterror = NTP_PHASE_LIMIT; /* estimated error (us) */ 46long time_esterror = NTP_PHASE_LIMIT; /* estimated error (us) */
42long time_freq; /* frequency offset (scaled ppm)*/ 47static s64 time_freq; /* frequency offset (scaled ns/s)*/
43static long time_reftime; /* time at last adjustment (s) */ 48static long time_reftime; /* time at last adjustment (s) */
44long time_adjust; 49long time_adjust;
45static long ntp_tick_adj; 50static long ntp_tick_adj;
@@ -47,16 +52,56 @@ static long ntp_tick_adj;
47static void ntp_update_frequency(void) 52static void ntp_update_frequency(void)
48{ 53{
49 u64 second_length = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ) 54 u64 second_length = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ)
50 << TICK_LENGTH_SHIFT; 55 << NTP_SCALE_SHIFT;
51 second_length += (s64)ntp_tick_adj << TICK_LENGTH_SHIFT; 56 second_length += (s64)ntp_tick_adj << NTP_SCALE_SHIFT;
52 second_length += (s64)time_freq << (TICK_LENGTH_SHIFT - SHIFT_NSEC); 57 second_length += time_freq;
53 58
54 tick_length_base = second_length; 59 tick_length_base = second_length;
55 60
56 do_div(second_length, HZ); 61 tick_nsec = div_u64(second_length, HZ) >> NTP_SCALE_SHIFT;
57 tick_nsec = second_length >> TICK_LENGTH_SHIFT; 62 tick_length_base = div_u64(tick_length_base, NTP_INTERVAL_FREQ);
63}
64
65static void ntp_update_offset(long offset)
66{
67 long mtemp;
68 s64 freq_adj;
69
70 if (!(time_status & STA_PLL))
71 return;
58 72
59 do_div(tick_length_base, NTP_INTERVAL_FREQ); 73 if (!(time_status & STA_NANO))
74 offset *= NSEC_PER_USEC;
75
76 /*
77 * Scale the phase adjustment and
78 * clamp to the operating range.
79 */
80 offset = min(offset, MAXPHASE);
81 offset = max(offset, -MAXPHASE);
82
83 /*
84 * Select how the frequency is to be controlled
85 * and in which mode (PLL or FLL).
86 */
87 if (time_status & STA_FREQHOLD || time_reftime == 0)
88 time_reftime = xtime.tv_sec;
89 mtemp = xtime.tv_sec - time_reftime;
90 time_reftime = xtime.tv_sec;
91
92 freq_adj = (s64)offset * mtemp;
93 freq_adj <<= NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant);
94 time_status &= ~STA_MODE;
95 if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > MAXSEC)) {
96 freq_adj += div_s64((s64)offset << (NTP_SCALE_SHIFT - SHIFT_FLL),
97 mtemp);
98 time_status |= STA_MODE;
99 }
100 freq_adj += time_freq;
101 freq_adj = min(freq_adj, MAXFREQ_SCALED);
102 time_freq = max(freq_adj, -MAXFREQ_SCALED);
103
104 time_offset = div_s64((s64)offset << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
60} 105}
61 106
62/** 107/**
@@ -78,62 +123,70 @@ void ntp_clear(void)
78} 123}
79 124
80/* 125/*
81 * this routine handles the overflow of the microsecond field 126 * Leap second processing. If in leap-insert state at the end of the
82 * 127 * day, the system clock is set back one second; if in leap-delete
83 * The tricky bits of code to handle the accurate clock support 128 * state, the system clock is set ahead one second.
84 * were provided by Dave Mills (Mills@UDEL.EDU) of NTP fame.
85 * They were originally developed for SUN and DEC kernels.
86 * All the kudos should go to Dave for this stuff.
87 */ 129 */
88void second_overflow(void) 130static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
89{ 131{
90 long time_adj; 132 enum hrtimer_restart res = HRTIMER_NORESTART;
91 133
92 /* Bump the maxerror field */ 134 write_seqlock_irq(&xtime_lock);
93 time_maxerror += MAXFREQ >> SHIFT_USEC;
94 if (time_maxerror > NTP_PHASE_LIMIT) {
95 time_maxerror = NTP_PHASE_LIMIT;
96 time_status |= STA_UNSYNC;
97 }
98 135
99 /*
100 * Leap second processing. If in leap-insert state at the end of the
101 * day, the system clock is set back one second; if in leap-delete
102 * state, the system clock is set ahead one second. The microtime()
103 * routine or external clock driver will insure that reported time is
104 * always monotonic. The ugly divides should be replaced.
105 */
106 switch (time_state) { 136 switch (time_state) {
107 case TIME_OK: 137 case TIME_OK:
108 if (time_status & STA_INS)
109 time_state = TIME_INS;
110 else if (time_status & STA_DEL)
111 time_state = TIME_DEL;
112 break; 138 break;
113 case TIME_INS: 139 case TIME_INS:
114 if (xtime.tv_sec % 86400 == 0) { 140 xtime.tv_sec--;
115 xtime.tv_sec--; 141 wall_to_monotonic.tv_sec++;
116 wall_to_monotonic.tv_sec++; 142 time_state = TIME_OOP;
117 time_state = TIME_OOP; 143 printk(KERN_NOTICE "Clock: "
118 printk(KERN_NOTICE "Clock: inserting leap second " 144 "inserting leap second 23:59:60 UTC\n");
119 "23:59:60 UTC\n"); 145 leap_timer.expires = ktime_add_ns(leap_timer.expires,
120 } 146 NSEC_PER_SEC);
147 res = HRTIMER_RESTART;
121 break; 148 break;
122 case TIME_DEL: 149 case TIME_DEL:
123 if ((xtime.tv_sec + 1) % 86400 == 0) { 150 xtime.tv_sec++;
124 xtime.tv_sec++; 151 time_tai--;
125 wall_to_monotonic.tv_sec--; 152 wall_to_monotonic.tv_sec--;
126 time_state = TIME_WAIT; 153 time_state = TIME_WAIT;
127 printk(KERN_NOTICE "Clock: deleting leap second " 154 printk(KERN_NOTICE "Clock: "
128 "23:59:59 UTC\n"); 155 "deleting leap second 23:59:59 UTC\n");
129 }
130 break; 156 break;
131 case TIME_OOP: 157 case TIME_OOP:
158 time_tai++;
132 time_state = TIME_WAIT; 159 time_state = TIME_WAIT;
133 break; 160 /* fall through */
134 case TIME_WAIT: 161 case TIME_WAIT:
135 if (!(time_status & (STA_INS | STA_DEL))) 162 if (!(time_status & (STA_INS | STA_DEL)))
136 time_state = TIME_OK; 163 time_state = TIME_OK;
164 break;
165 }
166 update_vsyscall(&xtime, clock);
167
168 write_sequnlock_irq(&xtime_lock);
169
170 return res;
171}
172
173/*
174 * this routine handles the overflow of the microsecond field
175 *
176 * The tricky bits of code to handle the accurate clock support
177 * were provided by Dave Mills (Mills@UDEL.EDU) of NTP fame.
178 * They were originally developed for SUN and DEC kernels.
179 * All the kudos should go to Dave for this stuff.
180 */
181void second_overflow(void)
182{
183 s64 time_adj;
184
185 /* Bump the maxerror field */
186 time_maxerror += MAXFREQ / NSEC_PER_USEC;
187 if (time_maxerror > NTP_PHASE_LIMIT) {
188 time_maxerror = NTP_PHASE_LIMIT;
189 time_status |= STA_UNSYNC;
137 } 190 }
138 191
139 /* 192 /*
@@ -143,7 +196,7 @@ void second_overflow(void)
143 tick_length = tick_length_base; 196 tick_length = tick_length_base;
144 time_adj = shift_right(time_offset, SHIFT_PLL + time_constant); 197 time_adj = shift_right(time_offset, SHIFT_PLL + time_constant);
145 time_offset -= time_adj; 198 time_offset -= time_adj;
146 tick_length += (s64)time_adj << (TICK_LENGTH_SHIFT - SHIFT_UPDATE); 199 tick_length += time_adj;
147 200
148 if (unlikely(time_adjust)) { 201 if (unlikely(time_adjust)) {
149 if (time_adjust > MAX_TICKADJ) { 202 if (time_adjust > MAX_TICKADJ) {
@@ -154,25 +207,12 @@ void second_overflow(void)
154 tick_length -= MAX_TICKADJ_SCALED; 207 tick_length -= MAX_TICKADJ_SCALED;
155 } else { 208 } else {
156 tick_length += (s64)(time_adjust * NSEC_PER_USEC / 209 tick_length += (s64)(time_adjust * NSEC_PER_USEC /
157 NTP_INTERVAL_FREQ) << TICK_LENGTH_SHIFT; 210 NTP_INTERVAL_FREQ) << NTP_SCALE_SHIFT;
158 time_adjust = 0; 211 time_adjust = 0;
159 } 212 }
160 } 213 }
161} 214}
162 215
163/*
164 * Return how long ticks are at the moment, that is, how much time
165 * update_wall_time_one_tick will add to xtime next time we call it
166 * (assuming no calls to do_adjtimex in the meantime).
167 * The return value is in fixed-point nanoseconds shifted by the
168 * specified number of bits to the right of the binary point.
169 * This function has no side-effects.
170 */
171u64 current_tick_length(void)
172{
173 return tick_length;
174}
175
176#ifdef CONFIG_GENERIC_CMOS_UPDATE 216#ifdef CONFIG_GENERIC_CMOS_UPDATE
177 217
178/* Disable the cmos update - used by virtualization and embedded */ 218/* Disable the cmos update - used by virtualization and embedded */
@@ -236,8 +276,8 @@ static inline void notify_cmos_timer(void) { }
236 */ 276 */
237int do_adjtimex(struct timex *txc) 277int do_adjtimex(struct timex *txc)
238{ 278{
239 long mtemp, save_adjust, rem; 279 struct timespec ts;
240 s64 freq_adj, temp64; 280 long save_adjust, sec;
241 int result; 281 int result;
242 282
243 /* In order to modify anything, you gotta be super-user! */ 283 /* In order to modify anything, you gotta be super-user! */
@@ -247,147 +287,132 @@ int do_adjtimex(struct timex *txc)
247 /* Now we validate the data before disabling interrupts */ 287 /* Now we validate the data before disabling interrupts */
248 288
249 if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT) { 289 if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT) {
250 /* singleshot must not be used with any other mode bits */ 290 /* singleshot must not be used with any other mode bits */
251 if (txc->modes != ADJ_OFFSET_SINGLESHOT && 291 if (txc->modes & ~ADJ_OFFSET_SS_READ)
252 txc->modes != ADJ_OFFSET_SS_READ)
253 return -EINVAL; 292 return -EINVAL;
254 } 293 }
255 294
256 if (txc->modes != ADJ_OFFSET_SINGLESHOT && (txc->modes & ADJ_OFFSET))
257 /* adjustment Offset limited to +- .512 seconds */
258 if (txc->offset <= - MAXPHASE || txc->offset >= MAXPHASE )
259 return -EINVAL;
260
261 /* if the quartz is off by more than 10% something is VERY wrong ! */ 295 /* if the quartz is off by more than 10% something is VERY wrong ! */
262 if (txc->modes & ADJ_TICK) 296 if (txc->modes & ADJ_TICK)
263 if (txc->tick < 900000/USER_HZ || 297 if (txc->tick < 900000/USER_HZ ||
264 txc->tick > 1100000/USER_HZ) 298 txc->tick > 1100000/USER_HZ)
265 return -EINVAL; 299 return -EINVAL;
266 300
301 if (time_state != TIME_OK && txc->modes & ADJ_STATUS)
302 hrtimer_cancel(&leap_timer);
303 getnstimeofday(&ts);
304
267 write_seqlock_irq(&xtime_lock); 305 write_seqlock_irq(&xtime_lock);
268 result = time_state; /* mostly `TIME_OK' */
269 306
270 /* Save for later - semantics of adjtime is to return old value */ 307 /* Save for later - semantics of adjtime is to return old value */
271 save_adjust = time_adjust; 308 save_adjust = time_adjust;
272 309
273#if 0 /* STA_CLOCKERR is never set yet */
274 time_status &= ~STA_CLOCKERR; /* reset STA_CLOCKERR */
275#endif
276 /* If there are input parameters, then process them */ 310 /* If there are input parameters, then process them */
277 if (txc->modes) 311 if (txc->modes) {
278 { 312 if (txc->modes & ADJ_STATUS) {
279 if (txc->modes & ADJ_STATUS) /* only set allowed bits */ 313 if ((time_status & STA_PLL) &&
280 time_status = (txc->status & ~STA_RONLY) | 314 !(txc->status & STA_PLL)) {
281 (time_status & STA_RONLY); 315 time_state = TIME_OK;
282 316 time_status = STA_UNSYNC;
283 if (txc->modes & ADJ_FREQUENCY) { /* p. 22 */ 317 }
284 if (txc->freq > MAXFREQ || txc->freq < -MAXFREQ) { 318 /* only set allowed bits */
285 result = -EINVAL; 319 time_status &= STA_RONLY;
286 goto leave; 320 time_status |= txc->status & ~STA_RONLY;
287 } 321
288 time_freq = ((s64)txc->freq * NSEC_PER_USEC) 322 switch (time_state) {
289 >> (SHIFT_USEC - SHIFT_NSEC); 323 case TIME_OK:
290 } 324 start_timer:
291 325 sec = ts.tv_sec;
292 if (txc->modes & ADJ_MAXERROR) { 326 if (time_status & STA_INS) {
293 if (txc->maxerror < 0 || txc->maxerror >= NTP_PHASE_LIMIT) { 327 time_state = TIME_INS;
294 result = -EINVAL; 328 sec += 86400 - sec % 86400;
295 goto leave; 329 hrtimer_start(&leap_timer, ktime_set(sec, 0), HRTIMER_MODE_ABS);
330 } else if (time_status & STA_DEL) {
331 time_state = TIME_DEL;
332 sec += 86400 - (sec + 1) % 86400;
333 hrtimer_start(&leap_timer, ktime_set(sec, 0), HRTIMER_MODE_ABS);
334 }
335 break;
336 case TIME_INS:
337 case TIME_DEL:
338 time_state = TIME_OK;
339 goto start_timer;
340 break;
341 case TIME_WAIT:
342 if (!(time_status & (STA_INS | STA_DEL)))
343 time_state = TIME_OK;
344 break;
345 case TIME_OOP:
346 hrtimer_restart(&leap_timer);
347 break;
348 }
296 } 349 }
297 time_maxerror = txc->maxerror;
298 }
299 350
300 if (txc->modes & ADJ_ESTERROR) { 351 if (txc->modes & ADJ_NANO)
301 if (txc->esterror < 0 || txc->esterror >= NTP_PHASE_LIMIT) { 352 time_status |= STA_NANO;
302 result = -EINVAL; 353 if (txc->modes & ADJ_MICRO)
303 goto leave; 354 time_status &= ~STA_NANO;
355
356 if (txc->modes & ADJ_FREQUENCY) {
357 time_freq = (s64)txc->freq * PPM_SCALE;
358 time_freq = min(time_freq, MAXFREQ_SCALED);
359 time_freq = max(time_freq, -MAXFREQ_SCALED);
304 } 360 }
305 time_esterror = txc->esterror;
306 }
307 361
308 if (txc->modes & ADJ_TIMECONST) { /* p. 24 */ 362 if (txc->modes & ADJ_MAXERROR)
309 if (txc->constant < 0) { /* NTP v4 uses values > 6 */ 363 time_maxerror = txc->maxerror;
310 result = -EINVAL; 364 if (txc->modes & ADJ_ESTERROR)
311 goto leave; 365 time_esterror = txc->esterror;
366
367 if (txc->modes & ADJ_TIMECONST) {
368 time_constant = txc->constant;
369 if (!(time_status & STA_NANO))
370 time_constant += 4;
371 time_constant = min(time_constant, (long)MAXTC);
372 time_constant = max(time_constant, 0l);
312 } 373 }
313 time_constant = min(txc->constant + 4, (long)MAXTC);
314 }
315 374
316 if (txc->modes & ADJ_OFFSET) { /* values checked earlier */ 375 if (txc->modes & ADJ_TAI && txc->constant > 0)
317 if (txc->modes == ADJ_OFFSET_SINGLESHOT) { 376 time_tai = txc->constant;
318 /* adjtime() is independent from ntp_adjtime() */ 377
319 time_adjust = txc->offset; 378 if (txc->modes & ADJ_OFFSET) {
379 if (txc->modes == ADJ_OFFSET_SINGLESHOT)
380 /* adjtime() is independent from ntp_adjtime() */
381 time_adjust = txc->offset;
382 else
383 ntp_update_offset(txc->offset);
320 } 384 }
321 else if (time_status & STA_PLL) { 385 if (txc->modes & ADJ_TICK)
322 time_offset = txc->offset * NSEC_PER_USEC; 386 tick_usec = txc->tick;
323 387
324 /* 388 if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET))
325 * Scale the phase adjustment and 389 ntp_update_frequency();
326 * clamp to the operating range. 390 }
327 */ 391
328 time_offset = min(time_offset, (s64)MAXPHASE * NSEC_PER_USEC); 392 result = time_state; /* mostly `TIME_OK' */
329 time_offset = max(time_offset, (s64)-MAXPHASE * NSEC_PER_USEC); 393 if (time_status & (STA_UNSYNC|STA_CLOCKERR))
330
331 /*
332 * Select whether the frequency is to be controlled
333 * and in which mode (PLL or FLL). Clamp to the operating
334 * range. Ugly multiply/divide should be replaced someday.
335 */
336
337 if (time_status & STA_FREQHOLD || time_reftime == 0)
338 time_reftime = xtime.tv_sec;
339 mtemp = xtime.tv_sec - time_reftime;
340 time_reftime = xtime.tv_sec;
341
342 freq_adj = time_offset * mtemp;
343 freq_adj = shift_right(freq_adj, time_constant * 2 +
344 (SHIFT_PLL + 2) * 2 - SHIFT_NSEC);
345 if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > MAXSEC)) {
346 u64 utemp64;
347 temp64 = time_offset << (SHIFT_NSEC - SHIFT_FLL);
348 if (time_offset < 0) {
349 utemp64 = -temp64;
350 do_div(utemp64, mtemp);
351 freq_adj -= utemp64;
352 } else {
353 utemp64 = temp64;
354 do_div(utemp64, mtemp);
355 freq_adj += utemp64;
356 }
357 }
358 freq_adj += time_freq;
359 freq_adj = min(freq_adj, (s64)MAXFREQ_NSEC);
360 time_freq = max(freq_adj, (s64)-MAXFREQ_NSEC);
361 time_offset = div_long_long_rem_signed(time_offset,
362 NTP_INTERVAL_FREQ,
363 &rem);
364 time_offset <<= SHIFT_UPDATE;
365 } /* STA_PLL */
366 } /* txc->modes & ADJ_OFFSET */
367 if (txc->modes & ADJ_TICK)
368 tick_usec = txc->tick;
369
370 if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET))
371 ntp_update_frequency();
372 } /* txc->modes */
373leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0)
374 result = TIME_ERROR; 394 result = TIME_ERROR;
375 395
376 if ((txc->modes == ADJ_OFFSET_SINGLESHOT) || 396 if ((txc->modes == ADJ_OFFSET_SINGLESHOT) ||
377 (txc->modes == ADJ_OFFSET_SS_READ)) 397 (txc->modes == ADJ_OFFSET_SS_READ))
378 txc->offset = save_adjust; 398 txc->offset = save_adjust;
379 else 399 else {
380 txc->offset = ((long)shift_right(time_offset, SHIFT_UPDATE)) * 400 txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
381 NTP_INTERVAL_FREQ / 1000; 401 NTP_SCALE_SHIFT);
382 txc->freq = (time_freq / NSEC_PER_USEC) << 402 if (!(time_status & STA_NANO))
383 (SHIFT_USEC - SHIFT_NSEC); 403 txc->offset /= NSEC_PER_USEC;
404 }
405 txc->freq = shift_right((s32)(time_freq >> PPM_SCALE_INV_SHIFT) *
406 (s64)PPM_SCALE_INV,
407 NTP_SCALE_SHIFT);
384 txc->maxerror = time_maxerror; 408 txc->maxerror = time_maxerror;
385 txc->esterror = time_esterror; 409 txc->esterror = time_esterror;
386 txc->status = time_status; 410 txc->status = time_status;
387 txc->constant = time_constant; 411 txc->constant = time_constant;
388 txc->precision = 1; 412 txc->precision = 1;
389 txc->tolerance = MAXFREQ; 413 txc->tolerance = MAXFREQ_SCALED / PPM_SCALE;
390 txc->tick = tick_usec; 414 txc->tick = tick_usec;
415 txc->tai = time_tai;
391 416
392 /* PPS is not implemented, so these are zero */ 417 /* PPS is not implemented, so these are zero */
393 txc->ppsfreq = 0; 418 txc->ppsfreq = 0;
@@ -399,9 +424,15 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0)
399 txc->errcnt = 0; 424 txc->errcnt = 0;
400 txc->stbcnt = 0; 425 txc->stbcnt = 0;
401 write_sequnlock_irq(&xtime_lock); 426 write_sequnlock_irq(&xtime_lock);
402 do_gettimeofday(&txc->time); 427
428 txc->time.tv_sec = ts.tv_sec;
429 txc->time.tv_usec = ts.tv_nsec;
430 if (!(time_status & STA_NANO))
431 txc->time.tv_usec /= NSEC_PER_USEC;
432
403 notify_cmos_timer(); 433 notify_cmos_timer();
404 return(result); 434
435 return result;
405} 436}
406 437
407static int __init ntp_tick_adj_setup(char *str) 438static int __init ntp_tick_adj_setup(char *str)
@@ -411,3 +442,10 @@ static int __init ntp_tick_adj_setup(char *str)
411} 442}
412 443
413__setup("ntp_tick_adj=", ntp_tick_adj_setup); 444__setup("ntp_tick_adj=", ntp_tick_adj_setup);
445
446void __init ntp_init(void)
447{
448 ntp_clear();
449 hrtimer_init(&leap_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
450 leap_timer.function = ntp_leap_second;
451}
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 2d6087c7cf98..e91c29f961c9 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -53,7 +53,7 @@ void update_xtime_cache(u64 nsec)
53 timespec_add_ns(&xtime_cache, nsec); 53 timespec_add_ns(&xtime_cache, nsec);
54} 54}
55 55
56static struct clocksource *clock; /* pointer to current clocksource */ 56struct clocksource *clock;
57 57
58 58
59#ifdef CONFIG_GENERIC_TIME 59#ifdef CONFIG_GENERIC_TIME
@@ -246,7 +246,7 @@ void __init timekeeping_init(void)
246 246
247 write_seqlock_irqsave(&xtime_lock, flags); 247 write_seqlock_irqsave(&xtime_lock, flags);
248 248
249 ntp_clear(); 249 ntp_init();
250 250
251 clock = clocksource_get_next(); 251 clock = clocksource_get_next();
252 clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH); 252 clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
@@ -371,7 +371,7 @@ static __always_inline int clocksource_bigadjust(s64 error, s64 *interval,
371 * here. This is tuned so that an error of about 1 msec is adjusted 371 * here. This is tuned so that an error of about 1 msec is adjusted
372 * within about 1 sec (or 2^20 nsec in 2^SHIFT_HZ ticks). 372 * within about 1 sec (or 2^20 nsec in 2^SHIFT_HZ ticks).
373 */ 373 */
374 error2 = clock->error >> (TICK_LENGTH_SHIFT + 22 - 2 * SHIFT_HZ); 374 error2 = clock->error >> (NTP_SCALE_SHIFT + 22 - 2 * SHIFT_HZ);
375 error2 = abs(error2); 375 error2 = abs(error2);
376 for (look_ahead = 0; error2 > 0; look_ahead++) 376 for (look_ahead = 0; error2 > 0; look_ahead++)
377 error2 >>= 2; 377 error2 >>= 2;
@@ -380,8 +380,7 @@ static __always_inline int clocksource_bigadjust(s64 error, s64 *interval,
380 * Now calculate the error in (1 << look_ahead) ticks, but first 380 * Now calculate the error in (1 << look_ahead) ticks, but first
381 * remove the single look ahead already included in the error. 381 * remove the single look ahead already included in the error.
382 */ 382 */
383 tick_error = current_tick_length() >> 383 tick_error = tick_length >> (NTP_SCALE_SHIFT - clock->shift + 1);
384 (TICK_LENGTH_SHIFT - clock->shift + 1);
385 tick_error -= clock->xtime_interval >> 1; 384 tick_error -= clock->xtime_interval >> 1;
386 error = ((error - tick_error) >> look_ahead) + tick_error; 385 error = ((error - tick_error) >> look_ahead) + tick_error;
387 386
@@ -412,7 +411,7 @@ static void clocksource_adjust(s64 offset)
412 s64 error, interval = clock->cycle_interval; 411 s64 error, interval = clock->cycle_interval;
413 int adj; 412 int adj;
414 413
415 error = clock->error >> (TICK_LENGTH_SHIFT - clock->shift - 1); 414 error = clock->error >> (NTP_SCALE_SHIFT - clock->shift - 1);
416 if (error > interval) { 415 if (error > interval) {
417 error >>= 2; 416 error >>= 2;
418 if (likely(error <= interval)) 417 if (likely(error <= interval))
@@ -434,7 +433,7 @@ static void clocksource_adjust(s64 offset)
434 clock->xtime_interval += interval; 433 clock->xtime_interval += interval;
435 clock->xtime_nsec -= offset; 434 clock->xtime_nsec -= offset;
436 clock->error -= (interval - offset) << 435 clock->error -= (interval - offset) <<
437 (TICK_LENGTH_SHIFT - clock->shift); 436 (NTP_SCALE_SHIFT - clock->shift);
438} 437}
439 438
440/** 439/**
@@ -473,8 +472,8 @@ void update_wall_time(void)
473 } 472 }
474 473
475 /* accumulate error between NTP and clock interval */ 474 /* accumulate error between NTP and clock interval */
476 clock->error += current_tick_length(); 475 clock->error += tick_length;
477 clock->error -= clock->xtime_interval << (TICK_LENGTH_SHIFT - clock->shift); 476 clock->error -= clock->xtime_interval << (NTP_SCALE_SHIFT - clock->shift);
478 } 477 }
479 478
480 /* correct the clock when NTP error is too big */ 479 /* correct the clock when NTP error is too big */
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 721093a22561..29fc39f1029c 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -195,7 +195,6 @@ static void delayed_work_timer_fn(unsigned long __data)
195int queue_delayed_work(struct workqueue_struct *wq, 195int queue_delayed_work(struct workqueue_struct *wq,
196 struct delayed_work *dwork, unsigned long delay) 196 struct delayed_work *dwork, unsigned long delay)
197{ 197{
198 timer_stats_timer_set_start_info(&dwork->timer);
199 if (delay == 0) 198 if (delay == 0)
200 return queue_work(wq, &dwork->work); 199 return queue_work(wq, &dwork->work);
201 200
@@ -219,11 +218,12 @@ int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
219 struct timer_list *timer = &dwork->timer; 218 struct timer_list *timer = &dwork->timer;
220 struct work_struct *work = &dwork->work; 219 struct work_struct *work = &dwork->work;
221 220
222 timer_stats_timer_set_start_info(&dwork->timer);
223 if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) { 221 if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) {
224 BUG_ON(timer_pending(timer)); 222 BUG_ON(timer_pending(timer));
225 BUG_ON(!list_empty(&work->entry)); 223 BUG_ON(!list_empty(&work->entry));
226 224
225 timer_stats_timer_set_start_info(&dwork->timer);
226
227 /* This stores cwq for the moment, for the timer_fn */ 227 /* This stores cwq for the moment, for the timer_fn */
228 set_wq_data(work, wq_per_cpu(wq, raw_smp_processor_id())); 228 set_wq_data(work, wq_per_cpu(wq, raw_smp_processor_id()));
229 timer->expires = jiffies + delay; 229 timer->expires = jiffies + delay;
@@ -564,7 +564,6 @@ EXPORT_SYMBOL(schedule_work);
564int schedule_delayed_work(struct delayed_work *dwork, 564int schedule_delayed_work(struct delayed_work *dwork,
565 unsigned long delay) 565 unsigned long delay)
566{ 566{
567 timer_stats_timer_set_start_info(&dwork->timer);
568 return queue_delayed_work(keventd_wq, dwork, delay); 567 return queue_delayed_work(keventd_wq, dwork, delay);
569} 568}
570EXPORT_SYMBOL(schedule_delayed_work); 569EXPORT_SYMBOL(schedule_delayed_work);
@@ -581,7 +580,6 @@ EXPORT_SYMBOL(schedule_delayed_work);
581int schedule_delayed_work_on(int cpu, 580int schedule_delayed_work_on(int cpu,
582 struct delayed_work *dwork, unsigned long delay) 581 struct delayed_work *dwork, unsigned long delay)
583{ 582{
584 timer_stats_timer_set_start_info(&dwork->timer);
585 return queue_delayed_work_on(cpu, keventd_wq, dwork, delay); 583 return queue_delayed_work_on(cpu, keventd_wq, dwork, delay);
586} 584}
587EXPORT_SYMBOL(schedule_delayed_work_on); 585EXPORT_SYMBOL(schedule_delayed_work_on);
diff --git a/lib/div64.c b/lib/div64.c
index b71cf93c529a..bb5bd0c0f030 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -16,9 +16,8 @@
16 * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S. 16 * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S.
17 */ 17 */
18 18
19#include <linux/types.h>
20#include <linux/module.h> 19#include <linux/module.h>
21#include <asm/div64.h> 20#include <linux/math64.h>
22 21
23/* Not needed on 64bit architectures */ 22/* Not needed on 64bit architectures */
24#if BITS_PER_LONG == 32 23#if BITS_PER_LONG == 32
@@ -58,10 +57,31 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
58 57
59EXPORT_SYMBOL(__div64_32); 58EXPORT_SYMBOL(__div64_32);
60 59
60#ifndef div_s64_rem
61s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
62{
63 u64 quotient;
64
65 if (dividend < 0) {
66 quotient = div_u64_rem(-dividend, abs(divisor), (u32 *)remainder);
67 *remainder = -*remainder;
68 if (divisor > 0)
69 quotient = -quotient;
70 } else {
71 quotient = div_u64_rem(dividend, abs(divisor), (u32 *)remainder);
72 if (divisor < 0)
73 quotient = -quotient;
74 }
75 return quotient;
76}
77EXPORT_SYMBOL(div_s64_rem);
78#endif
79
61/* 64bit divisor, dividend and result. dynamic precision */ 80/* 64bit divisor, dividend and result. dynamic precision */
62uint64_t div64_64(uint64_t dividend, uint64_t divisor) 81#ifndef div64_u64
82u64 div64_u64(u64 dividend, u64 divisor)
63{ 83{
64 uint32_t high, d; 84 u32 high, d;
65 85
66 high = divisor >> 32; 86 high = divisor >> 32;
67 if (high) { 87 if (high) {
@@ -72,10 +92,9 @@ uint64_t div64_64(uint64_t dividend, uint64_t divisor)
72 } else 92 } else
73 d = divisor; 93 d = divisor;
74 94
75 do_div(dividend, d); 95 return div_u64(dividend, d);
76
77 return dividend;
78} 96}
79EXPORT_SYMBOL(div64_64); 97EXPORT_SYMBOL(div64_u64);
98#endif
80 99
81#endif /* BITS_PER_LONG == 32 */ 100#endif /* BITS_PER_LONG == 32 */
diff --git a/lib/idr.c b/lib/idr.c
index 8368c81fcb7d..7a02e173f027 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -385,8 +385,8 @@ void idr_remove(struct idr *idp, int id)
385 while (idp->id_free_cnt >= IDR_FREE_MAX) { 385 while (idp->id_free_cnt >= IDR_FREE_MAX) {
386 p = alloc_layer(idp); 386 p = alloc_layer(idp);
387 kmem_cache_free(idr_layer_cache, p); 387 kmem_cache_free(idr_layer_cache, p);
388 return;
389 } 388 }
389 return;
390} 390}
391EXPORT_SYMBOL(idr_remove); 391EXPORT_SYMBOL(idr_remove);
392 392
diff --git a/lib/string.c b/lib/string.c
index 5efafed3d6b6..b19b87af65a3 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -493,6 +493,33 @@ char *strsep(char **s, const char *ct)
493EXPORT_SYMBOL(strsep); 493EXPORT_SYMBOL(strsep);
494#endif 494#endif
495 495
496/**
497 * sysfs_streq - return true if strings are equal, modulo trailing newline
498 * @s1: one string
499 * @s2: another string
500 *
501 * This routine returns true iff two strings are equal, treating both
502 * NUL and newline-then-NUL as equivalent string terminations. It's
503 * geared for use with sysfs input strings, which generally terminate
504 * with newlines but are compared against values without newlines.
505 */
506bool sysfs_streq(const char *s1, const char *s2)
507{
508 while (*s1 && *s1 == *s2) {
509 s1++;
510 s2++;
511 }
512
513 if (*s1 == *s2)
514 return true;
515 if (!*s1 && *s2 == '\n' && !s2[1])
516 return true;
517 if (*s1 == '\n' && !s1[1] && !*s2)
518 return true;
519 return false;
520}
521EXPORT_SYMBOL(sysfs_streq);
522
496#ifndef __HAVE_ARCH_MEMSET 523#ifndef __HAVE_ARCH_MEMSET
497/** 524/**
498 * memset - Fill a region of memory with the given value 525 * memset - Fill a region of memory with the given value
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 33add96cd5fb..e46451e1d9b7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -48,6 +48,8 @@ enum mem_cgroup_stat_index {
48 */ 48 */
49 MEM_CGROUP_STAT_CACHE, /* # of pages charged as cache */ 49 MEM_CGROUP_STAT_CACHE, /* # of pages charged as cache */
50 MEM_CGROUP_STAT_RSS, /* # of pages charged as rss */ 50 MEM_CGROUP_STAT_RSS, /* # of pages charged as rss */
51 MEM_CGROUP_STAT_PGPGIN_COUNT, /* # of pages paged in */
52 MEM_CGROUP_STAT_PGPGOUT_COUNT, /* # of pages paged out */
51 53
52 MEM_CGROUP_STAT_NSTATS, 54 MEM_CGROUP_STAT_NSTATS,
53}; 55};
@@ -199,6 +201,13 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem, int flags,
199 __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_CACHE, val); 201 __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_CACHE, val);
200 else 202 else
201 __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_RSS, val); 203 __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_RSS, val);
204
205 if (charge)
206 __mem_cgroup_stat_add_safe(stat,
207 MEM_CGROUP_STAT_PGPGIN_COUNT, 1);
208 else
209 __mem_cgroup_stat_add_safe(stat,
210 MEM_CGROUP_STAT_PGPGOUT_COUNT, 1);
202} 211}
203 212
204static struct mem_cgroup_per_zone * 213static struct mem_cgroup_per_zone *
@@ -884,6 +893,8 @@ static const struct mem_cgroup_stat_desc {
884} mem_cgroup_stat_desc[] = { 893} mem_cgroup_stat_desc[] = {
885 [MEM_CGROUP_STAT_CACHE] = { "cache", PAGE_SIZE, }, 894 [MEM_CGROUP_STAT_CACHE] = { "cache", PAGE_SIZE, },
886 [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, }, 895 [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, },
896 [MEM_CGROUP_STAT_PGPGIN_COUNT] = {"pgpgin", 1, },
897 [MEM_CGROUP_STAT_PGPGOUT_COUNT] = {"pgpgout", 1, },
887}; 898};
888 899
889static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft, 900static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
diff --git a/mm/slub.c b/mm/slub.c
index 70db2897c1ea..32b62623846a 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -22,6 +22,7 @@
22#include <linux/debugobjects.h> 22#include <linux/debugobjects.h>
23#include <linux/kallsyms.h> 23#include <linux/kallsyms.h>
24#include <linux/memory.h> 24#include <linux/memory.h>
25#include <linux/math64.h>
25 26
26/* 27/*
27 * Lock order: 28 * Lock order:
@@ -3621,12 +3622,10 @@ static int list_locations(struct kmem_cache *s, char *buf,
3621 len += sprintf(buf + len, "<not-available>"); 3622 len += sprintf(buf + len, "<not-available>");
3622 3623
3623 if (l->sum_time != l->min_time) { 3624 if (l->sum_time != l->min_time) {
3624 unsigned long remainder;
3625
3626 len += sprintf(buf + len, " age=%ld/%ld/%ld", 3625 len += sprintf(buf + len, " age=%ld/%ld/%ld",
3627 l->min_time, 3626 l->min_time,
3628 div_long_long_rem(l->sum_time, l->count, &remainder), 3627 (long)div_u64(l->sum_time, l->count),
3629 l->max_time); 3628 l->max_time);
3630 } else 3629 } else
3631 len += sprintf(buf + len, " age=%ld", 3630 len += sprintf(buf + len, " age=%ld",
3632 l->min_time); 3631 l->min_time);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 2a39cf128aba..6e45b0f3d125 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -547,6 +547,7 @@ void *__vmalloc_area(struct vm_struct *area, gfp_t gfp_mask, pgprot_t prot)
547 * @gfp_mask: flags for the page level allocator 547 * @gfp_mask: flags for the page level allocator
548 * @prot: protection mask for the allocated pages 548 * @prot: protection mask for the allocated pages
549 * @node: node to use for allocation or -1 549 * @node: node to use for allocation or -1
550 * @caller: caller's return address
550 * 551 *
551 * Allocate enough pages to cover @size from the page level 552 * Allocate enough pages to cover @size from the page level
552 * allocator with @gfp_mask flags. Map them into contiguous 553 * allocator with @gfp_mask flags. Map them into contiguous
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index eb5b9854c8c7..4a1221e5e8ee 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -15,8 +15,8 @@
15 15
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/math64.h>
18#include <net/tcp.h> 19#include <net/tcp.h>
19#include <asm/div64.h>
20 20
21#define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation 21#define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation
22 * max_cwnd = snd_cwnd * beta 22 * max_cwnd = snd_cwnd * beta
@@ -128,7 +128,7 @@ static u32 cubic_root(u64 a)
128 * x = ( 2 * x + a / x ) / 3 128 * x = ( 2 * x + a / x ) / 3
129 * k+1 k k 129 * k+1 k k
130 */ 130 */
131 x = (2 * x + (u32)div64_64(a, (u64)x * (u64)(x - 1))); 131 x = (2 * x + (u32)div64_u64(a, (u64)x * (u64)(x - 1)));
132 x = ((x * 341) >> 10); 132 x = ((x * 341) >> 10);
133 return x; 133 return x;
134} 134}
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index b15e7e2fa143..d7e8983cd37f 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -4,12 +4,11 @@
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/bitops.h> 5#include <linux/bitops.h>
6#include <linux/skbuff.h> 6#include <linux/skbuff.h>
7#include <linux/math64.h>
7#include <linux/netfilter/x_tables.h> 8#include <linux/netfilter/x_tables.h>
8#include <linux/netfilter/xt_connbytes.h> 9#include <linux/netfilter/xt_connbytes.h>
9#include <net/netfilter/nf_conntrack.h> 10#include <net/netfilter/nf_conntrack.h>
10 11
11#include <asm/div64.h>
12
13MODULE_LICENSE("GPL"); 12MODULE_LICENSE("GPL");
14MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); 13MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
15MODULE_DESCRIPTION("Xtables: Number of packets/bytes per connection matching"); 14MODULE_DESCRIPTION("Xtables: Number of packets/bytes per connection matching");
@@ -82,7 +81,7 @@ connbytes_mt(const struct sk_buff *skb, const struct net_device *in,
82 break; 81 break;
83 } 82 }
84 if (pkts != 0) 83 if (pkts != 0)
85 what = div64_64(bytes, pkts); 84 what = div64_u64(bytes, pkts);
86 break; 85 break;
87 } 86 }
88 87