aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/connector/cn_test.c4
-rw-r--r--arch/arm/Kconfig10
-rw-r--r--arch/arm/boot/compressed/misc.c6
-rw-r--r--arch/arm/common/scoop.c6
-rw-r--r--arch/arm/kernel/armksyms.c4
-rw-r--r--arch/arm/kernel/entry-armv.S7
-rw-r--r--arch/arm/kernel/irq.c3
-rw-r--r--arch/arm/kernel/smp.c42
-rw-r--r--arch/arm/mach-pxa/corgi.c48
-rw-r--r--arch/arm/mach-pxa/poodle.c32
-rw-r--r--arch/arm/mach-pxa/spitz.c95
-rw-r--r--arch/arm/mach-pxa/time.c8
-rw-r--r--arch/arm/mach-pxa/tosa.c152
-rw-r--r--arch/arm/mach-realview/core.c5
-rw-r--r--arch/arm/mach-realview/platsmp.c10
-rw-r--r--arch/arm/mach-s3c2410/Kconfig8
-rw-r--r--arch/arm/mach-s3c2410/mach-bast.c73
-rw-r--r--arch/arm/mach-s3c2410/mach-vr1000.c56
-rw-r--r--arch/arm/mach-sa1100/time.c8
-rw-r--r--arch/sparc64/mm/fault.c2
-rw-r--r--drivers/bluetooth/bpa10x.c4
-rw-r--r--drivers/bluetooth/hci_usb.c7
-rw-r--r--drivers/net/Kconfig13
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/irda/donauboe.c14
-rw-r--r--drivers/net/ppp_async.c17
-rw-r--r--drivers/net/ppp_generic.c88
-rw-r--r--drivers/net/ppp_mppe.c724
-rw-r--r--drivers/net/ppp_mppe.h86
-rw-r--r--drivers/pcmcia/pxa2xx_sharpsl.c140
-rw-r--r--drivers/sbus/char/openprom.c3
-rw-r--r--drivers/video/amba-clcd.c2
-rw-r--r--fs/exec.c10
-rw-r--r--include/asm-arm/arch-s3c2410/uncompress.h22
-rw-r--r--include/asm-arm/hardirq.h1
-rw-r--r--include/asm-arm/hardware/scoop.h10
-rw-r--r--include/asm-arm/smp.h54
-rw-r--r--include/linux/if_ppp.h7
-rw-r--r--include/linux/ppp-comp.h9
-rw-r--r--include/net/bluetooth/bluetooth.h4
-rw-r--r--include/net/bluetooth/hci.h116
-rw-r--r--include/net/bluetooth/hci_core.h9
-rw-r--r--include/net/bluetooth/rfcomm.h2
-rw-r--r--include/net/ipv6.h67
-rw-r--r--include/net/sock.h20
-rw-r--r--net/802/p8023.c3
-rw-r--r--net/ax25/af_ax25.c6
-rw-r--r--net/ax25/ax25_in.c6
-rw-r--r--net/ax25/ax25_route.c19
-rw-r--r--net/bluetooth/af_bluetooth.c12
-rw-r--r--net/bluetooth/hci_core.c2
-rw-r--r--net/bluetooth/hci_event.c6
-rw-r--r--net/bluetooth/hci_sock.c2
-rw-r--r--net/bluetooth/hci_sysfs.c4
-rw-r--r--net/bluetooth/hidp/core.c4
-rw-r--r--net/bluetooth/l2cap.c98
-rw-r--r--net/bluetooth/rfcomm/core.c124
-rw-r--r--net/bluetooth/rfcomm/sock.c90
-rw-r--r--net/bluetooth/sco.c92
-rw-r--r--net/core/dev_mcast.c3
-rw-r--r--net/core/sock.c3
-rw-r--r--net/dccp/ipv4.c6
-rw-r--r--net/dccp/proto.c3
-rw-r--r--net/decnet/dn_table.c14
-rw-r--r--net/ethernet/pe2.c3
-rw-r--r--net/ipv4/af_inet.c3
-rw-r--r--net/ipv4/fib_frontend.c3
-rw-r--r--net/ipv4/ip_options.c3
-rw-r--r--net/ipv4/ip_output.c15
-rw-r--r--net/ipv4/ip_sockglue.c12
-rw-r--r--net/ipv4/ipvs/ip_vs_app.c6
-rw-r--r--net/ipv4/ipvs/ip_vs_core.c7
-rw-r--r--net/ipv4/multipath_wrandom.c10
-rw-r--r--net/ipv4/netfilter/ip_nat_snmp_basic.c3
-rw-r--r--net/ipv4/tcp_ipv4.c3
-rw-r--r--net/ipv6/addrconf.c433
-rw-r--r--net/ipv6/ip6_fib.c54
-rw-r--r--net/ipv6/ip6_output.c15
-rw-r--r--net/ipv6/ip6_tunnel.c6
-rw-r--r--net/ipv6/ipcomp6.c3
-rw-r--r--net/ipv6/ipv6_sockglue.c3
-rw-r--r--net/ipv6/ipv6_syms.c2
-rw-r--r--net/irda/discovery.c3
-rw-r--r--net/irda/irias_object.c16
-rw-r--r--net/rose/rose_route.c6
-rw-r--r--net/sched/cls_fw.c3
-rw-r--r--net/sched/cls_route.c3
-rw-r--r--net/sched/cls_rsvp.h3
-rw-r--r--net/sched/cls_tcindex.c9
-rw-r--r--net/sched/cls_u32.c4
-rw-r--r--net/sched/em_meta.c3
-rw-r--r--net/sched/ematch.c5
-rw-r--r--net/sctp/associola.c4
-rw-r--r--net/sctp/sm_make_chunk.c6
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_seal.c2
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_unseal.c2
-rw-r--r--net/sunrpc/auth_gss/gss_mech_switch.c3
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_seal.c3
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_token.c3
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_unseal.c6
-rw-r--r--net/sunrpc/svc.c9
-rw-r--r--net/sunrpc/xdr.c3
-rw-r--r--net/wanrouter/af_wanpipe.c20
-rw-r--r--net/wanrouter/wanmain.c12
-rw-r--r--net/xfrm/xfrm_state.c12
105 files changed, 2176 insertions, 1054 deletions
diff --git a/Documentation/connector/cn_test.c b/Documentation/connector/cn_test.c
index b7de82e9c0e0..3e73231695b3 100644
--- a/Documentation/connector/cn_test.c
+++ b/Documentation/connector/cn_test.c
@@ -25,7 +25,7 @@
25#include <linux/skbuff.h> 25#include <linux/skbuff.h>
26#include <linux/timer.h> 26#include <linux/timer.h>
27 27
28#include "connector.h" 28#include <linux/connector.h>
29 29
30static struct cb_id cn_test_id = { 0x123, 0x456 }; 30static struct cb_id cn_test_id = { 0x123, 0x456 };
31static char cn_test_name[] = "cn_test"; 31static char cn_test_name[] = "cn_test";
@@ -104,7 +104,7 @@ static int cn_test_want_notify(void)
104 req->first = cn_test_id.val + 20; 104 req->first = cn_test_id.val + 20;
105 req->range = 10; 105 req->range = 10;
106 106
107 NETLINK_CB(skb).dst_groups = ctl->group; 107 NETLINK_CB(skb).dst_group = ctl->group;
108 //netlink_broadcast(nls, skb, 0, ctl->group, GFP_ATOMIC); 108 //netlink_broadcast(nls, skb, 0, ctl->group, GFP_ATOMIC);
109 netlink_unicast(nls, skb, 0, 0); 109 netlink_unicast(nls, skb, 0, 0);
110 110
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 91d5ef3397be..3bfef0934c9d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -356,6 +356,16 @@ config HOTPLUG_CPU
356 Say Y here to experiment with turning CPUs off and on. CPUs 356 Say Y here to experiment with turning CPUs off and on. CPUs
357 can be controlled through /sys/devices/system/cpu. 357 can be controlled through /sys/devices/system/cpu.
358 358
359config LOCAL_TIMERS
360 bool "Use local timer interrupts"
361 depends on SMP && n
362 default y
363 help
364 Enable support for local timers on SMP platforms, rather then the
365 legacy IPI broadcast method. Local timers allows the system
366 accounting to be spread across the timer interval, preventing a
367 "thundering herd" at every timer tick.
368
359config PREEMPT 369config PREEMPT
360 bool "Preemptible Kernel (EXPERIMENTAL)" 370 bool "Preemptible Kernel (EXPERIMENTAL)"
361 depends on EXPERIMENTAL 371 depends on EXPERIMENTAL
diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c
index 50f13eec6cd7..5ab94584baee 100644
--- a/arch/arm/boot/compressed/misc.c
+++ b/arch/arm/boot/compressed/misc.c
@@ -283,8 +283,14 @@ void flush_window(void)
283 putstr("."); 283 putstr(".");
284} 284}
285 285
286#ifndef arch_error
287#define arch_error(x)
288#endif
289
286static void error(char *x) 290static void error(char *x)
287{ 291{
292 arch_error(x);
293
288 putstr("\n\n"); 294 putstr("\n\n");
289 putstr(x); 295 putstr(x);
290 putstr("\n\n -- System halted"); 296 putstr("\n\n -- System halted");
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
index bb4eff614413..c7fdf390cef9 100644
--- a/arch/arm/common/scoop.c
+++ b/arch/arm/common/scoop.c
@@ -19,12 +19,6 @@
19 19
20#define SCOOP_REG(d,adr) (*(volatile unsigned short*)(d +(adr))) 20#define SCOOP_REG(d,adr) (*(volatile unsigned short*)(d +(adr)))
21 21
22/* PCMCIA to Scoop linkage structures for pxa2xx_sharpsl.c
23 There is no easy way to link multiple scoop devices into one
24 single entity for the pxa2xx_pcmcia device */
25int scoop_num;
26struct scoop_pcmcia_dev *scoop_devs;
27
28struct scoop_dev { 22struct scoop_dev {
29 void *base; 23 void *base;
30 spinlock_t scoop_lock; 24 spinlock_t scoop_lock;
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index 7b17a87a3311..7a3261f0bf79 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -9,6 +9,7 @@
9 */ 9 */
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/cryptohash.h>
12#include <linux/delay.h> 13#include <linux/delay.h>
13#include <linux/in6.h> 14#include <linux/in6.h>
14#include <linux/syscalls.h> 15#include <linux/syscalls.h>
@@ -126,6 +127,9 @@ EXPORT_SYMBOL(__put_user_2);
126EXPORT_SYMBOL(__put_user_4); 127EXPORT_SYMBOL(__put_user_4);
127EXPORT_SYMBOL(__put_user_8); 128EXPORT_SYMBOL(__put_user_8);
128 129
130 /* crypto hash */
131EXPORT_SYMBOL(sha_transform);
132
129 /* gcc lib functions */ 133 /* gcc lib functions */
130EXPORT_SYMBOL(__ashldi3); 134EXPORT_SYMBOL(__ashldi3);
131EXPORT_SYMBOL(__ashrdi3); 135EXPORT_SYMBOL(__ashrdi3);
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index a511ec5b11a3..d9fb819bf7cc 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -47,6 +47,13 @@
47 movne r0, sp 47 movne r0, sp
48 adrne lr, 1b 48 adrne lr, 1b
49 bne do_IPI 49 bne do_IPI
50
51#ifdef CONFIG_LOCAL_TIMERS
52 test_for_ltirq r0, r6, r5, lr
53 movne r0, sp
54 adrne lr, 1b
55 bne do_local_timer
56#endif
50#endif 57#endif
51 58
52 .endm 59 .endm
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 9def4404e1f2..d7099dbbb879 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -264,6 +264,7 @@ unlock:
264#endif 264#endif
265#ifdef CONFIG_SMP 265#ifdef CONFIG_SMP
266 show_ipi_list(p); 266 show_ipi_list(p);
267 show_local_irqs(p);
267#endif 268#endif
268 seq_printf(p, "Err: %10lu\n", irq_err_count); 269 seq_printf(p, "Err: %10lu\n", irq_err_count);
269 } 270 }
@@ -995,7 +996,7 @@ void __init init_irq_proc(void)
995 struct proc_dir_entry *dir; 996 struct proc_dir_entry *dir;
996 int irq; 997 int irq;
997 998
998 dir = proc_mkdir("irq", 0); 999 dir = proc_mkdir("irq", NULL);
999 if (!dir) 1000 if (!dir)
1000 return; 1001 return;
1001 1002
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index edb5a406922f..77e2e9ca89fa 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -142,7 +142,7 @@ int __cpuinit __cpu_up(unsigned int cpu)
142 ret = -EIO; 142 ret = -EIO;
143 } 143 }
144 144
145 secondary_data.stack = 0; 145 secondary_data.stack = NULL;
146 secondary_data.pgdir = 0; 146 secondary_data.pgdir = 0;
147 147
148 *pmd_offset(pgd, PHYS_OFFSET) = __pmd(0); 148 *pmd_offset(pgd, PHYS_OFFSET) = __pmd(0);
@@ -185,6 +185,11 @@ int __cpuexit __cpu_disable(void)
185 migrate_irqs(); 185 migrate_irqs();
186 186
187 /* 187 /*
188 * Stop the local timer for this CPU.
189 */
190 local_timer_stop(cpu);
191
192 /*
188 * Flush user cache and TLB mappings, and then remove this CPU 193 * Flush user cache and TLB mappings, and then remove this CPU
189 * from the vm mask set of all processes. 194 * from the vm mask set of all processes.
190 */ 195 */
@@ -290,6 +295,11 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
290 cpu_set(cpu, cpu_online_map); 295 cpu_set(cpu, cpu_online_map);
291 296
292 /* 297 /*
298 * Setup local timer for this CPU.
299 */
300 local_timer_setup(cpu);
301
302 /*
293 * OK, it's off to the idle thread for us 303 * OK, it's off to the idle thread for us
294 */ 304 */
295 cpu_idle(); 305 cpu_idle();
@@ -359,8 +369,8 @@ static void send_ipi_message(cpumask_t callmap, enum ipi_msg_type msg)
359 * You must not call this function with disabled interrupts, from a 369 * You must not call this function with disabled interrupts, from a
360 * hardware interrupt handler, nor from a bottom half handler. 370 * hardware interrupt handler, nor from a bottom half handler.
361 */ 371 */
362int smp_call_function_on_cpu(void (*func)(void *info), void *info, int retry, 372static int smp_call_function_on_cpu(void (*func)(void *info), void *info,
363 int wait, cpumask_t callmap) 373 int retry, int wait, cpumask_t callmap)
364{ 374{
365 struct smp_call_struct data; 375 struct smp_call_struct data;
366 unsigned long timeout; 376 unsigned long timeout;
@@ -454,6 +464,18 @@ void show_ipi_list(struct seq_file *p)
454 seq_putc(p, '\n'); 464 seq_putc(p, '\n');
455} 465}
456 466
467void show_local_irqs(struct seq_file *p)
468{
469 unsigned int cpu;
470
471 seq_printf(p, "LOC: ");
472
473 for_each_present_cpu(cpu)
474 seq_printf(p, "%10u ", irq_stat[cpu].local_timer_irqs);
475
476 seq_putc(p, '\n');
477}
478
457static void ipi_timer(struct pt_regs *regs) 479static void ipi_timer(struct pt_regs *regs)
458{ 480{
459 int user = user_mode(regs); 481 int user = user_mode(regs);
@@ -464,6 +486,18 @@ static void ipi_timer(struct pt_regs *regs)
464 irq_exit(); 486 irq_exit();
465} 487}
466 488
489#ifdef CONFIG_LOCAL_TIMERS
490asmlinkage void do_local_timer(struct pt_regs *regs)
491{
492 int cpu = smp_processor_id();
493
494 if (local_timer_ack()) {
495 irq_stat[cpu].local_timer_irqs++;
496 ipi_timer(regs);
497 }
498}
499#endif
500
467/* 501/*
468 * ipi_call_function - handle IPI from smp_call_function() 502 * ipi_call_function - handle IPI from smp_call_function()
469 * 503 *
@@ -515,7 +549,7 @@ static void ipi_cpu_stop(unsigned int cpu)
515 * 549 *
516 * Bit 0 - Inter-processor function call 550 * Bit 0 - Inter-processor function call
517 */ 551 */
518void do_IPI(struct pt_regs *regs) 552asmlinkage void do_IPI(struct pt_regs *regs)
519{ 553{
520 unsigned int cpu = smp_processor_id(); 554 unsigned int cpu = smp_processor_id();
521 struct ipi_data *ipi = &per_cpu(ipi_data, cpu); 555 struct ipi_data *ipi = &per_cpu(ipi_data, cpu);
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index eb5f6d744a4a..100fb31b5156 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -62,6 +62,37 @@ static struct scoop_config corgi_scoop_setup = {
62 .io_out = CORGI_SCOOP_IO_OUT, 62 .io_out = CORGI_SCOOP_IO_OUT,
63}; 63};
64 64
65struct platform_device corgiscoop_device = {
66 .name = "sharp-scoop",
67 .id = -1,
68 .dev = {
69 .platform_data = &corgi_scoop_setup,
70 },
71 .num_resources = ARRAY_SIZE(corgi_scoop_resources),
72 .resource = corgi_scoop_resources,
73};
74
75static void corgi_pcmcia_init(void)
76{
77 /* Setup default state of GPIO outputs
78 before we enable them as outputs. */
79 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
80 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
81 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
82 GPIO_bit(GPIO53_nPCE_2);
83
84 pxa_gpio_mode(GPIO48_nPOE_MD);
85 pxa_gpio_mode(GPIO49_nPWE_MD);
86 pxa_gpio_mode(GPIO50_nPIOR_MD);
87 pxa_gpio_mode(GPIO51_nPIOW_MD);
88 pxa_gpio_mode(GPIO55_nPREG_MD);
89 pxa_gpio_mode(GPIO56_nPWAIT_MD);
90 pxa_gpio_mode(GPIO57_nIOIS16_MD);
91 pxa_gpio_mode(GPIO52_nPCE_1_MD);
92 pxa_gpio_mode(GPIO53_nPCE_2_MD);
93 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
94}
95
65static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = { 96static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
66{ 97{
67 .dev = &corgiscoop_device.dev, 98 .dev = &corgiscoop_device.dev,
@@ -71,16 +102,14 @@ static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
71}, 102},
72}; 103};
73 104
74struct platform_device corgiscoop_device = { 105static struct scoop_pcmcia_config corgi_pcmcia_config = {
75 .name = "sharp-scoop", 106 .devs = &corgi_pcmcia_scoop[0],
76 .id = -1, 107 .num_devs = 1,
77 .dev = { 108 .pcmcia_init = corgi_pcmcia_init,
78 .platform_data = &corgi_scoop_setup,
79 },
80 .num_resources = ARRAY_SIZE(corgi_scoop_resources),
81 .resource = corgi_scoop_resources,
82}; 109};
83 110
111EXPORT_SYMBOL(corgiscoop_device);
112
84 113
85/* 114/*
86 * Corgi SSP Device 115 * Corgi SSP Device
@@ -294,8 +323,7 @@ static void __init corgi_init(void)
294 pxa_set_mci_info(&corgi_mci_platform_data); 323 pxa_set_mci_info(&corgi_mci_platform_data);
295 pxa_set_ficp_info(&corgi_ficp_platform_data); 324 pxa_set_ficp_info(&corgi_ficp_platform_data);
296 325
297 scoop_num = 1; 326 platform_scoop_config = &corgi_pcmcia_config;
298 scoop_devs = &corgi_pcmcia_scoop[0];
299 327
300 platform_add_devices(devices, ARRAY_SIZE(devices)); 328 platform_add_devices(devices, ARRAY_SIZE(devices));
301} 329}
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index ad6a13f95a62..eef3de26ad37 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -65,6 +65,27 @@ struct platform_device poodle_scoop_device = {
65 .resource = poodle_scoop_resources, 65 .resource = poodle_scoop_resources,
66}; 66};
67 67
68static void poodle_pcmcia_init(void)
69{
70 /* Setup default state of GPIO outputs
71 before we enable them as outputs. */
72 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
73 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
74 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
75 GPIO_bit(GPIO53_nPCE_2);
76
77 pxa_gpio_mode(GPIO48_nPOE_MD);
78 pxa_gpio_mode(GPIO49_nPWE_MD);
79 pxa_gpio_mode(GPIO50_nPIOR_MD);
80 pxa_gpio_mode(GPIO51_nPIOW_MD);
81 pxa_gpio_mode(GPIO55_nPREG_MD);
82 pxa_gpio_mode(GPIO56_nPWAIT_MD);
83 pxa_gpio_mode(GPIO57_nIOIS16_MD);
84 pxa_gpio_mode(GPIO52_nPCE_1_MD);
85 pxa_gpio_mode(GPIO53_nPCE_2_MD);
86 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
87}
88
68static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = { 89static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
69{ 90{
70 .dev = &poodle_scoop_device.dev, 91 .dev = &poodle_scoop_device.dev,
@@ -74,6 +95,14 @@ static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
74}, 95},
75}; 96};
76 97
98static struct scoop_pcmcia_config poodle_pcmcia_config = {
99 .devs = &poodle_pcmcia_scoop[0],
100 .num_devs = 1,
101 .pcmcia_init = poodle_pcmcia_init,
102};
103
104EXPORT_SYMBOL(poodle_scoop_device);
105
77 106
78/* LoCoMo device */ 107/* LoCoMo device */
79static struct resource locomo_resources[] = { 108static struct resource locomo_resources[] = {
@@ -268,8 +297,7 @@ static void __init poodle_init(void)
268 pxa_set_mci_info(&poodle_mci_platform_data); 297 pxa_set_mci_info(&poodle_mci_platform_data);
269 pxa_set_ficp_info(&poodle_ficp_platform_data); 298 pxa_set_ficp_info(&poodle_ficp_platform_data);
270 299
271 scoop_num = 1; 300 platform_scoop_config = &poodle_pcmcia_config;
272 scoop_devs = &poodle_pcmcia_scoop[0];
273 301
274 ret = platform_add_devices(devices, ARRAY_SIZE(devices)); 302 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
275 if (ret) { 303 if (ret) {
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 6c6878cd2207..4e9a699ee428 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -104,6 +104,66 @@ struct platform_device spitzscoop2_device = {
104 .resource = spitz_scoop2_resources, 104 .resource = spitz_scoop2_resources,
105}; 105};
106 106
107#define SPITZ_PWR_SD 0x01
108#define SPITZ_PWR_CF 0x02
109
110/* Power control is shared with between one of the CF slots and SD */
111static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
112{
113 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
114
115 if (new_cpr & 0x0007) {
116 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
117 if (!(cpr & 0x0002) && !(cpr & 0x0004))
118 mdelay(5);
119 if (device == SPITZ_PWR_CF)
120 cpr |= 0x0002;
121 if (device == SPITZ_PWR_SD)
122 cpr |= 0x0004;
123 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
124 } else {
125 if (device == SPITZ_PWR_CF)
126 cpr &= ~0x0002;
127 if (device == SPITZ_PWR_SD)
128 cpr &= ~0x0004;
129 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
130 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
131 mdelay(1);
132 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
133 }
134 }
135}
136
137static void spitz_pcmcia_init(void)
138{
139 /* Setup default state of GPIO outputs
140 before we enable them as outputs. */
141 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
142 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
143 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO54_nPCE_2);
144 GPSR(GPIO85_nPCE_1) = GPIO_bit(GPIO85_nPCE_1);
145
146 pxa_gpio_mode(GPIO48_nPOE_MD);
147 pxa_gpio_mode(GPIO49_nPWE_MD);
148 pxa_gpio_mode(GPIO50_nPIOR_MD);
149 pxa_gpio_mode(GPIO51_nPIOW_MD);
150 pxa_gpio_mode(GPIO55_nPREG_MD);
151 pxa_gpio_mode(GPIO56_nPWAIT_MD);
152 pxa_gpio_mode(GPIO57_nIOIS16_MD);
153 pxa_gpio_mode(GPIO85_nPCE_1_MD);
154 pxa_gpio_mode(GPIO54_nPCE_2_MD);
155 pxa_gpio_mode(GPIO104_pSKTSEL_MD);
156}
157
158static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
159{
160 /* Only need to override behaviour for slot 0 */
161 if (nr == 0)
162 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
163 else
164 write_scoop_reg(scoop, SCOOP_CPR, cpr);
165}
166
107static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = { 167static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
108{ 168{
109 .dev = &spitzscoop_device.dev, 169 .dev = &spitzscoop_device.dev,
@@ -117,6 +177,16 @@ static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
117}, 177},
118}; 178};
119 179
180static struct scoop_pcmcia_config spitz_pcmcia_config = {
181 .devs = &spitz_pcmcia_scoop[0],
182 .num_devs = 2,
183 .pcmcia_init = spitz_pcmcia_init,
184 .power_ctrl = spitz_pcmcia_pwr,
185};
186
187EXPORT_SYMBOL(spitzscoop_device);
188EXPORT_SYMBOL(spitzscoop2_device);
189
120 190
121/* 191/*
122 * Spitz SSP Device 192 * Spitz SSP Device
@@ -235,27 +305,14 @@ static int spitz_mci_init(struct device *dev, irqreturn_t (*spitz_detect_int)(in
235 return 0; 305 return 0;
236} 306}
237 307
238/* Power control is shared with one of the CF slots so we have a mess */
239static void spitz_mci_setpower(struct device *dev, unsigned int vdd) 308static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
240{ 309{
241 struct pxamci_platform_data* p_d = dev->platform_data; 310 struct pxamci_platform_data* p_d = dev->platform_data;
242 311
243 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR); 312 if (( 1 << vdd) & p_d->ocr_mask)
244 313 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
245 if (( 1 << vdd) & p_d->ocr_mask) { 314 else
246 /* printk(KERN_DEBUG "%s: on\n", __FUNCTION__); */ 315 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
247 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
248 mdelay(2);
249 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | 0x04);
250 } else {
251 /* printk(KERN_DEBUG "%s: off\n", __FUNCTION__); */
252 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr & ~0x04);
253
254 if (!(cpr | 0x02)) {
255 mdelay(1);
256 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
257 }
258 }
259} 316}
260 317
261static int spitz_mci_get_ro(struct device *dev) 318static int spitz_mci_get_ro(struct device *dev)
@@ -351,8 +408,8 @@ static void __init common_init(void)
351 408
352static void __init spitz_init(void) 409static void __init spitz_init(void)
353{ 410{
354 scoop_num = 2; 411 platform_scoop_config = &spitz_pcmcia_config;
355 scoop_devs = &spitz_pcmcia_scoop[0]; 412
356 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity; 413 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
357 414
358 common_init(); 415 common_init();
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
index 7dad3f1465e0..b9b2057349eb 100644
--- a/arch/arm/mach-pxa/time.c
+++ b/arch/arm/mach-pxa/time.c
@@ -132,11 +132,13 @@ static void __init pxa_timer_init(void)
132 tv.tv_sec = pxa_get_rtc_time(); 132 tv.tv_sec = pxa_get_rtc_time();
133 do_settimeofday(&tv); 133 do_settimeofday(&tv);
134 134
135 OSMR0 = 0; /* set initial match at 0 */ 135 OIER = 0; /* disable any timer interrupts */
136 OSCR = LATCH*2; /* push OSCR out of the way */
137 OSMR0 = LATCH; /* set initial match */
136 OSSR = 0xf; /* clear status on all timers */ 138 OSSR = 0xf; /* clear status on all timers */
137 setup_irq(IRQ_OST0, &pxa_timer_irq); 139 setup_irq(IRQ_OST0, &pxa_timer_irq);
138 OIER |= OIER_E0; /* enable match on timer 0 to cause interrupts */ 140 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */
139 OSCR = 0; /* initialize free-running timer, force first match */ 141 OSCR = 0; /* initialize free-running timer */
140} 142}
141 143
142#ifdef CONFIG_NO_IDLE_HZ 144#ifdef CONFIG_NO_IDLE_HZ
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 400609f8b6a8..c312054dfb88 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -98,6 +98,9 @@ struct platform_device tosascoop_jc_device = {
98 .resource = tosa_scoop_jc_resources, 98 .resource = tosa_scoop_jc_resources,
99}; 99};
100 100
101/*
102 * PCMCIA
103 */
101static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = { 104static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
102{ 105{
103 .dev = &tosascoop_device.dev, 106 .dev = &tosascoop_device.dev,
@@ -111,16 +114,155 @@ static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
111}, 114},
112}; 115};
113 116
117static void tosa_pcmcia_init(void)
118{
119 /* Setup default state of GPIO outputs
120 before we enable them as outputs. */
121 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
122 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
123 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
124 GPIO_bit(GPIO53_nPCE_2);
125
126 pxa_gpio_mode(GPIO48_nPOE_MD);
127 pxa_gpio_mode(GPIO49_nPWE_MD);
128 pxa_gpio_mode(GPIO50_nPIOR_MD);
129 pxa_gpio_mode(GPIO51_nPIOW_MD);
130 pxa_gpio_mode(GPIO55_nPREG_MD);
131 pxa_gpio_mode(GPIO56_nPWAIT_MD);
132 pxa_gpio_mode(GPIO57_nIOIS16_MD);
133 pxa_gpio_mode(GPIO52_nPCE_1_MD);
134 pxa_gpio_mode(GPIO53_nPCE_2_MD);
135 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
136}
137
138static struct scoop_pcmcia_config tosa_pcmcia_config = {
139 .devs = &tosa_pcmcia_scoop[0],
140 .num_devs = 2,
141 .pcmcia_init = tosa_pcmcia_init,
142};
143
144/*
145 * USB Device Controller
146 */
147static void tosa_udc_command(int cmd)
148{
149 switch(cmd) {
150 case PXA2XX_UDC_CMD_CONNECT:
151 set_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
152 break;
153 case PXA2XX_UDC_CMD_DISCONNECT:
154 reset_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
155 break;
156 }
157}
158
159static int tosa_udc_is_connected(void)
160{
161 return ((GPLR(TOSA_GPIO_USB_IN) & GPIO_bit(TOSA_GPIO_USB_IN)) == 0);
162}
163
164
165static struct pxa2xx_udc_mach_info udc_info __initdata = {
166 .udc_command = tosa_udc_command,
167 .udc_is_connected = tosa_udc_is_connected,
168};
169
170/*
171 * MMC/SD Device
172 */
173static struct pxamci_platform_data tosa_mci_platform_data;
174
175static int tosa_mci_init(struct device *dev, irqreturn_t (*tosa_detect_int)(int, void *, struct pt_regs *), void *data)
176{
177 int err;
178
179 /* setup GPIO for PXA25x MMC controller */
180 pxa_gpio_mode(GPIO6_MMCCLK_MD);
181 pxa_gpio_mode(GPIO8_MMCCS0_MD);
182 pxa_gpio_mode(TOSA_GPIO_nSD_DETECT | GPIO_IN);
183
184 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
185
186 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int, SA_INTERRUPT,
187 "MMC/SD card detect", data);
188 if (err) {
189 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
190 return -1;
191 }
192
193 set_irq_type(TOSA_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
194
195 return 0;
196}
197
198static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
199{
200 struct pxamci_platform_data* p_d = dev->platform_data;
201
202 if (( 1 << vdd) & p_d->ocr_mask) {
203 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
204 } else {
205 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
206 }
207}
208
209static int tosa_mci_get_ro(struct device *dev)
210{
211 return (read_scoop_reg(&tosascoop_device.dev, SCOOP_GPWR)&TOSA_SCOOP_SD_WP);
212}
213
214static void tosa_mci_exit(struct device *dev, void *data)
215{
216 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
217}
218
219static struct pxamci_platform_data tosa_mci_platform_data = {
220 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
221 .init = tosa_mci_init,
222 .get_ro = tosa_mci_get_ro,
223 .setpower = tosa_mci_setpower,
224 .exit = tosa_mci_exit,
225};
226
227/*
228 * Irda
229 */
230static void tosa_irda_transceiver_mode(struct device *dev, int mode)
231{
232 if (mode & IR_OFF) {
233 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
234 pxa_gpio_mode(GPIO47_STTXD|GPIO_DFLT_LOW);
235 pxa_gpio_mode(GPIO47_STTXD|GPIO_OUT);
236 } else {
237 pxa_gpio_mode(GPIO47_STTXD_MD);
238 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
239 }
240}
241
242static struct pxaficp_platform_data tosa_ficp_platform_data = {
243 .transceiver_cap = IR_SIRMODE | IR_OFF,
244 .transceiver_mode = tosa_irda_transceiver_mode,
245};
246
247/*
248 * Tosa Keyboard
249 */
250static struct platform_device tosakbd_device = {
251 .name = "tosa-keyboard",
252 .id = -1,
253};
114 254
115static struct platform_device *devices[] __initdata = { 255static struct platform_device *devices[] __initdata = {
116 &tosascoop_device, 256 &tosascoop_device,
117 &tosascoop_jc_device, 257 &tosascoop_jc_device,
258 &tosakbd_device,
118}; 259};
119 260
120static void __init tosa_init(void) 261static void __init tosa_init(void)
121{ 262{
122 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_IN); 263 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_IN);
123 pxa_gpio_mode(TOSA_GPIO_TC6393_INT | GPIO_IN); 264 pxa_gpio_mode(TOSA_GPIO_TC6393_INT | GPIO_IN);
265 pxa_gpio_mode(TOSA_GPIO_USB_IN | GPIO_IN);
124 266
125 /* setup sleep mode values */ 267 /* setup sleep mode values */
126 PWER = 0x00000002; 268 PWER = 0x00000002;
@@ -131,13 +273,15 @@ static void __init tosa_init(void)
131 PGSR2 = 0x00014000; 273 PGSR2 = 0x00014000;
132 PCFR |= PCFR_OPDE; 274 PCFR |= PCFR_OPDE;
133 275
134 // enable batt_fault 276 /* enable batt_fault */
135 PMCR = 0x01; 277 PMCR = 0x01;
136 278
137 platform_add_devices(devices, ARRAY_SIZE(devices)); 279 pxa_set_mci_info(&tosa_mci_platform_data);
280 pxa_set_udc_info(&udc_info);
281 pxa_set_ficp_info(&tosa_ficp_platform_data);
282 platform_scoop_config = &tosa_pcmcia_config;
138 283
139 scoop_num = 2; 284 platform_add_devices(devices, ARRAY_SIZE(devices));
140 scoop_devs = &tosa_pcmcia_scoop[0];
141} 285}
142 286
143static void __init fixup_tosa(struct machine_desc *desc, 287static void __init fixup_tosa(struct machine_desc *desc,
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 482eb512ebe8..4ea60d8b6e36 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -550,6 +550,11 @@ static irqreturn_t realview_timer_interrupt(int irq, void *dev_id, struct pt_reg
550 550
551 timer_tick(regs); 551 timer_tick(regs);
552 552
553#ifdef CONFIG_SMP
554 smp_send_timer();
555 update_process_times(user_mode(regs));
556#endif
557
553 write_sequnlock(&xtime_lock); 558 write_sequnlock(&xtime_lock);
554 559
555 return IRQ_HANDLED; 560 return IRQ_HANDLED;
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index 9844644d0fb5..09b35f62247a 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -32,7 +32,7 @@ static unsigned int __init get_core_count(void)
32{ 32{
33 unsigned int ncores; 33 unsigned int ncores;
34 34
35 ncores = __raw_readl(IO_ADDRESS(REALVIEW_MPCORE_SCU_BASE) + SCU_CONFIG); 35 ncores = __raw_readl(__io_address(REALVIEW_MPCORE_SCU_BASE) + SCU_CONFIG);
36 36
37 return (ncores & 0x03) + 1; 37 return (ncores & 0x03) + 1;
38} 38}
@@ -133,12 +133,12 @@ static void __init poke_milo(void)
133#if 1 133#if 1
134#define REALVIEW_SYS_FLAGSS_OFFSET 0x30 134#define REALVIEW_SYS_FLAGSS_OFFSET 0x30
135 __raw_writel(virt_to_phys(realview_secondary_startup), 135 __raw_writel(virt_to_phys(realview_secondary_startup),
136 (IO_ADDRESS(REALVIEW_SYS_BASE) + 136 __io_address(REALVIEW_SYS_BASE) +
137 REALVIEW_SYS_FLAGSS_OFFSET)); 137 REALVIEW_SYS_FLAGSS_OFFSET);
138#define REALVIEW_SYS_FLAGSC_OFFSET 0x34 138#define REALVIEW_SYS_FLAGSC_OFFSET 0x34
139 __raw_writel(3, 139 __raw_writel(3,
140 (IO_ADDRESS(REALVIEW_SYS_BASE) + 140 __io_address(REALVIEW_SYS_BASE) +
141 REALVIEW_SYS_FLAGSC_OFFSET)); 141 REALVIEW_SYS_FLAGSC_OFFSET);
142#endif 142#endif
143 143
144 mb(); 144 mb();
diff --git a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig
index c796bcdd6158..0b9d7ca49ec1 100644
--- a/arch/arm/mach-s3c2410/Kconfig
+++ b/arch/arm/mach-s3c2410/Kconfig
@@ -121,6 +121,14 @@ config S3C2410_BOOT_WATCHDOG
121 system resets depends on the value of PCLK. The timeout on an 121 system resets depends on the value of PCLK. The timeout on an
122 200MHz s3c2410 should be about 30 seconds. 122 200MHz s3c2410 should be about 30 seconds.
123 123
124config S3C2410_BOOT_ERROR_RESET
125 bool "S3C2410 Reboot on decompression error"
126 depends on ARCH_S3C2410
127 help
128 Say y here to use the watchdog to reset the system if the
129 kernel decompressor detects an error during decompression.
130
131
124comment "S3C2410 Setup" 132comment "S3C2410 Setup"
125 133
126config S3C2410_DMA 134config S3C2410_DMA
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
index 0b71c896bbd1..1be2567a7486 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c2410/mach-bast.c
@@ -89,32 +89,63 @@
89 89
90/* macros to modify the physical addresses for io space */ 90/* macros to modify the physical addresses for io space */
91 91
92#define PA_CS2(item) ((item) + S3C2410_CS2) 92#define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
93#define PA_CS3(item) ((item) + S3C2410_CS3) 93#define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
94#define PA_CS4(item) ((item) + S3C2410_CS4) 94#define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
95#define PA_CS5(item) ((item) + S3C2410_CS5) 95#define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
96 96
97static struct map_desc bast_iodesc[] __initdata = { 97static struct map_desc bast_iodesc[] __initdata = {
98 /* ISA IO areas */ 98 /* ISA IO areas */
99 99 {
100 { (u32)S3C24XX_VA_ISA_BYTE, PA_CS2(BAST_PA_ISAIO), SZ_16M, MT_DEVICE }, 100 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
101 { (u32)S3C24XX_VA_ISA_WORD, PA_CS3(BAST_PA_ISAIO), SZ_16M, MT_DEVICE }, 101 .pfn = PA_CS2(BAST_PA_ISAIO),
102 102 .length = SZ_16M,
103 /* we could possibly compress the next set down into a set of smaller tables 103 .type = MT_DEVICE,
104 * pagetables, but that would mean using an L2 section, and it still means 104 }, {
105 * we cannot actually feed the same register to an LDR due to 16K spacing 105 .virtual = (u32)S3C24XX_VA_ISA_WORD,
106 */ 106 .pfn = PA_CS3(BAST_PA_ISAIO),
107 107 .length = SZ_16M,
108 .type = MT_DEVICE,
109 },
108 /* bast CPLD control registers, and external interrupt controls */ 110 /* bast CPLD control registers, and external interrupt controls */
109 { (u32)BAST_VA_CTRL1, BAST_PA_CTRL1, SZ_1M, MT_DEVICE }, 111 {
110 { (u32)BAST_VA_CTRL2, BAST_PA_CTRL2, SZ_1M, MT_DEVICE }, 112 .virtual = (u32)BAST_VA_CTRL1,
111 { (u32)BAST_VA_CTRL3, BAST_PA_CTRL3, SZ_1M, MT_DEVICE }, 113 .pfn = __phys_to_pfn(BAST_PA_CTRL1),
112 { (u32)BAST_VA_CTRL4, BAST_PA_CTRL4, SZ_1M, MT_DEVICE }, 114 .length = SZ_1M,
113 115 .type = MT_DEVICE,
116 }, {
117 .virtual = (u32)BAST_VA_CTRL2,
118 .pfn = __phys_to_pfn(BAST_PA_CTRL2),
119 .length = SZ_1M,
120 .type = MT_DEVICE,
121 }, {
122 .virtual = (u32)BAST_VA_CTRL3,
123 .pfn = __phys_to_pfn(BAST_PA_CTRL3),
124 .length = SZ_1M,
125 .type = MT_DEVICE,
126 }, {
127 .virtual = (u32)BAST_VA_CTRL4,
128 .pfn = __phys_to_pfn(BAST_PA_CTRL4),
129 .length = SZ_1M,
130 .type = MT_DEVICE,
131 },
114 /* PC104 IRQ mux */ 132 /* PC104 IRQ mux */
115 { (u32)BAST_VA_PC104_IRQREQ, BAST_PA_PC104_IRQREQ, SZ_1M, MT_DEVICE }, 133 {
116 { (u32)BAST_VA_PC104_IRQRAW, BAST_PA_PC104_IRQRAW, SZ_1M, MT_DEVICE }, 134 .virtual = (u32)BAST_VA_PC104_IRQREQ,
117 { (u32)BAST_VA_PC104_IRQMASK, BAST_PA_PC104_IRQMASK, SZ_1M, MT_DEVICE }, 135 .pfn = __phys_to_pfn(BAST_PA_PC104_IRQREQ),
136 .length = SZ_1M,
137 .type = MT_DEVICE,
138 }, {
139 .virtual = (u32)BAST_VA_PC104_IRQRAW,
140 .pfn = __phys_to_pfn(BAST_PA_PC104_IRQRAW),
141 .length = SZ_1M,
142 .type = MT_DEVICE,
143 }, {
144 .virtual = (u32)BAST_VA_PC104_IRQMASK,
145 .pfn = __phys_to_pfn(BAST_PA_PC104_IRQMASK),
146 .length = SZ_1M,
147 .type = MT_DEVICE,
148 },
118 149
119 /* peripheral space... one for each of fast/slow/byte/16bit */ 150 /* peripheral space... one for each of fast/slow/byte/16bit */
120 /* note, ide is only decoded in word space, even though some registers 151 /* note, ide is only decoded in word space, even though some registers
diff --git a/arch/arm/mach-s3c2410/mach-vr1000.c b/arch/arm/mach-s3c2410/mach-vr1000.c
index 46b259673c18..ae7e099bf6c8 100644
--- a/arch/arm/mach-s3c2410/mach-vr1000.c
+++ b/arch/arm/mach-s3c2410/mach-vr1000.c
@@ -74,27 +74,47 @@
74 74
75/* macros to modify the physical addresses for io space */ 75/* macros to modify the physical addresses for io space */
76 76
77#define PA_CS2(item) ((item) + S3C2410_CS2) 77#define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
78#define PA_CS3(item) ((item) + S3C2410_CS3) 78#define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
79#define PA_CS4(item) ((item) + S3C2410_CS4) 79#define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
80#define PA_CS5(item) ((item) + S3C2410_CS5) 80#define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
81 81
82static struct map_desc vr1000_iodesc[] __initdata = { 82static struct map_desc vr1000_iodesc[] __initdata = {
83 /* ISA IO areas */ 83 /* ISA IO areas */
84 84 {
85 { (u32)S3C24XX_VA_ISA_BYTE, PA_CS2(BAST_PA_ISAIO), SZ_16M, MT_DEVICE }, 85 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
86 { (u32)S3C24XX_VA_ISA_WORD, PA_CS3(BAST_PA_ISAIO), SZ_16M, MT_DEVICE }, 86 .pfn = PA_CS2(BAST_PA_ISAIO),
87 87 .length = SZ_16M,
88 /* we could possibly compress the next set down into a set of smaller tables 88 .type = MT_DEVICE,
89 * pagetables, but that would mean using an L2 section, and it still means 89 }, {
90 * we cannot actually feed the same register to an LDR due to 16K spacing 90 .virtual = (u32)S3C24XX_VA_ISA_WORD,
91 */ 91 .pfn = PA_CS3(BAST_PA_ISAIO),
92 92 .length = SZ_16M,
93 /* bast CPLD control registers, and external interrupt controls */ 93 .type = MT_DEVICE,
94 { (u32)VR1000_VA_CTRL1, VR1000_PA_CTRL1, SZ_1M, MT_DEVICE }, 94 },
95 { (u32)VR1000_VA_CTRL2, VR1000_PA_CTRL2, SZ_1M, MT_DEVICE }, 95
96 { (u32)VR1000_VA_CTRL3, VR1000_PA_CTRL3, SZ_1M, MT_DEVICE }, 96 /* CPLD control registers, and external interrupt controls */
97 { (u32)VR1000_VA_CTRL4, VR1000_PA_CTRL4, SZ_1M, MT_DEVICE }, 97 {
98 .virtual = (u32)VR1000_VA_CTRL1,
99 .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
100 .length = SZ_1M,
101 .type = MT_DEVICE,
102 }, {
103 .virtual = (u32)VR1000_VA_CTRL2,
104 .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
105 .length = SZ_1M,
106 .type = MT_DEVICE,
107 }, {
108 .virtual = (u32)VR1000_VA_CTRL3,
109 .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
110 .length = SZ_1M,
111 .type = MT_DEVICE,
112 }, {
113 .virtual = (u32)VR1000_VA_CTRL4,
114 .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
115 .length = SZ_1M,
116 .type = MT_DEVICE,
117 },
98 118
99 /* peripheral space... one for each of fast/slow/byte/16bit */ 119 /* peripheral space... one for each of fast/slow/byte/16bit */
100 /* note, ide is only decoded in word space, even though some registers 120 /* note, ide is only decoded in word space, even though some registers
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c
index 47e0420623fc..e4b435e634e4 100644
--- a/arch/arm/mach-sa1100/time.c
+++ b/arch/arm/mach-sa1100/time.c
@@ -124,11 +124,13 @@ static void __init sa1100_timer_init(void)
124 tv.tv_sec = sa1100_get_rtc_time(); 124 tv.tv_sec = sa1100_get_rtc_time();
125 do_settimeofday(&tv); 125 do_settimeofday(&tv);
126 126
127 OSMR0 = 0; /* set initial match at 0 */ 127 OIER = 0; /* disable any timer interrupts */
128 OSCR = LATCH*2; /* push OSCR out of the way */
129 OSMR0 = LATCH; /* set initial match */
128 OSSR = 0xf; /* clear status on all timers */ 130 OSSR = 0xf; /* clear status on all timers */
129 setup_irq(IRQ_OST0, &sa1100_timer_irq); 131 setup_irq(IRQ_OST0, &sa1100_timer_irq);
130 OIER |= OIER_E0; /* enable match on timer 0 to cause interrupts */ 132 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */
131 OSCR = 0; /* initialize free-running timer, force first match */ 133 OSCR = 0; /* initialize free-running timer */
132} 134}
133 135
134#ifdef CONFIG_NO_IDLE_HZ 136#ifdef CONFIG_NO_IDLE_HZ
diff --git a/arch/sparc64/mm/fault.c b/arch/sparc64/mm/fault.c
index 31fbc67719a1..3be278d916db 100644
--- a/arch/sparc64/mm/fault.c
+++ b/arch/sparc64/mm/fault.c
@@ -109,7 +109,7 @@ static void bad_kernel_pc(struct pt_regs *regs)
109 * this. Additionally, to prevent kswapd from ripping ptes from 109 * this. Additionally, to prevent kswapd from ripping ptes from
110 * under us, raise interrupts around the time that we look at the 110 * under us, raise interrupts around the time that we look at the
111 * pte, kswapd will have to wait to get his smp ipi response from 111 * pte, kswapd will have to wait to get his smp ipi response from
112 * us. This saves us having to get page_table_lock. 112 * us. vmtruncate likewise. This saves us having to get pte lock.
113 */ 113 */
114static unsigned int get_user_insn(unsigned long tpc) 114static unsigned int get_user_insn(unsigned long tpc)
115{ 115{
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index ecbeb7eaba8e..394796315adc 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -84,8 +84,8 @@ struct bpa10x_data {
84 84
85struct hci_vendor_hdr { 85struct hci_vendor_hdr {
86 __u8 type; 86 __u8 type;
87 __u16 snum; 87 __le16 snum;
88 __u16 dlen; 88 __le16 dlen;
89} __attribute__ ((packed)); 89} __attribute__ ((packed));
90 90
91static void bpa10x_recv_bulk(struct bpa10x_data *data, unsigned char *buf, int count) 91static void bpa10x_recv_bulk(struct bpa10x_data *data, unsigned char *buf, int count)
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index f510b25b2c59..057cb2b6e6d1 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -65,6 +65,7 @@
65#endif 65#endif
66 66
67static int ignore = 0; 67static int ignore = 0;
68static int ignore_dga = 0;
68static int ignore_csr = 0; 69static int ignore_csr = 0;
69static int ignore_sniffer = 0; 70static int ignore_sniffer = 0;
70static int reset = 0; 71static int reset = 0;
@@ -841,6 +842,9 @@ static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id
841 if (ignore || id->driver_info & HCI_IGNORE) 842 if (ignore || id->driver_info & HCI_IGNORE)
842 return -ENODEV; 843 return -ENODEV;
843 844
845 if (ignore_dga && id->driver_info & HCI_DIGIANSWER)
846 return -ENODEV;
847
844 if (ignore_csr && id->driver_info & HCI_CSR) 848 if (ignore_csr && id->driver_info & HCI_CSR)
845 return -ENODEV; 849 return -ENODEV;
846 850
@@ -1070,6 +1074,9 @@ module_exit(hci_usb_exit);
1070module_param(ignore, bool, 0644); 1074module_param(ignore, bool, 0644);
1071MODULE_PARM_DESC(ignore, "Ignore devices from the matching table"); 1075MODULE_PARM_DESC(ignore, "Ignore devices from the matching table");
1072 1076
1077module_param(ignore_dga, bool, 0644);
1078MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001");
1079
1073module_param(ignore_csr, bool, 0644); 1080module_param(ignore_csr, bool, 0644);
1074MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001"); 1081MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001");
1075 1082
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 1958d9e16a3a..24f1691b84f9 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2523,6 +2523,19 @@ config PPP_BSDCOMP
2523 module; it is called bsd_comp and will show up in the directory 2523 module; it is called bsd_comp and will show up in the directory
2524 modules once you have said "make modules". If unsure, say N. 2524 modules once you have said "make modules". If unsure, say N.
2525 2525
2526config PPP_MPPE
2527 tristate "PPP MPPE compression (encryption) (EXPERIMENTAL)"
2528 depends on PPP && EXPERIMENTAL
2529 select CRYPTO
2530 select CRYPTO_SHA1
2531 select CRYPTO_ARC4
2532 ---help---
2533 Support for the MPPE Encryption protocol, as employed by the
2534 Microsoft Point-to-Point Tunneling Protocol.
2535
2536 See http://pptpclient.sourceforge.net/ for information on
2537 configuring PPTP clients and servers to utilize this method.
2538
2526config PPPOE 2539config PPPOE
2527 tristate "PPP over Ethernet (EXPERIMENTAL)" 2540 tristate "PPP over Ethernet (EXPERIMENTAL)"
2528 depends on EXPERIMENTAL && PPP 2541 depends on EXPERIMENTAL && PPP
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 7c313cb341b8..4cffd34442aa 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -112,6 +112,7 @@ obj-$(CONFIG_PPP_ASYNC) += ppp_async.o
112obj-$(CONFIG_PPP_SYNC_TTY) += ppp_synctty.o 112obj-$(CONFIG_PPP_SYNC_TTY) += ppp_synctty.o
113obj-$(CONFIG_PPP_DEFLATE) += ppp_deflate.o 113obj-$(CONFIG_PPP_DEFLATE) += ppp_deflate.o
114obj-$(CONFIG_PPP_BSDCOMP) += bsd_comp.o 114obj-$(CONFIG_PPP_BSDCOMP) += bsd_comp.o
115obj-$(CONFIG_PPP_MPPE) += ppp_mppe.o
115obj-$(CONFIG_PPPOE) += pppox.o pppoe.o 116obj-$(CONFIG_PPPOE) += pppox.o pppoe.o
116 117
117obj-$(CONFIG_SLIP) += slip.o 118obj-$(CONFIG_SLIP) += slip.o
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 0282771b1cbb..3137592d60c0 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -1459,8 +1459,10 @@ toshoboe_net_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1459 */ 1459 */
1460 IRDA_DEBUG (1, "%s(BANDWIDTH), %s, (%X/%ld\n", __FUNCTION__ 1460 IRDA_DEBUG (1, "%s(BANDWIDTH), %s, (%X/%ld\n", __FUNCTION__
1461 ,dev->name, INB (OBOE_STATUS), irq->ifr_baudrate ); 1461 ,dev->name, INB (OBOE_STATUS), irq->ifr_baudrate );
1462 if (!in_interrupt () && !capable (CAP_NET_ADMIN)) 1462 if (!in_interrupt () && !capable (CAP_NET_ADMIN)) {
1463 return -EPERM; 1463 ret = -EPERM;
1464 goto out;
1465 }
1464 1466
1465 /* self->speed=irq->ifr_baudrate; */ 1467 /* self->speed=irq->ifr_baudrate; */
1466 /* toshoboe_setbaud(self); */ 1468 /* toshoboe_setbaud(self); */
@@ -1470,8 +1472,10 @@ toshoboe_net_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1470 case SIOCSMEDIABUSY: /* Set media busy */ 1472 case SIOCSMEDIABUSY: /* Set media busy */
1471 IRDA_DEBUG (1, "%s(MEDIABUSY), %s, (%X/%x)\n", __FUNCTION__ 1473 IRDA_DEBUG (1, "%s(MEDIABUSY), %s, (%X/%x)\n", __FUNCTION__
1472 ,dev->name, INB (OBOE_STATUS), capable (CAP_NET_ADMIN) ); 1474 ,dev->name, INB (OBOE_STATUS), capable (CAP_NET_ADMIN) );
1473 if (!capable (CAP_NET_ADMIN)) 1475 if (!capable (CAP_NET_ADMIN)) {
1474 return -EPERM; 1476 ret = -EPERM;
1477 goto out;
1478 }
1475 irda_device_set_media_busy (self->netdev, TRUE); 1479 irda_device_set_media_busy (self->netdev, TRUE);
1476 break; 1480 break;
1477 case SIOCGRECEIVING: /* Check if we are receiving right now */ 1481 case SIOCGRECEIVING: /* Check if we are receiving right now */
@@ -1483,7 +1487,7 @@ toshoboe_net_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1483 IRDA_DEBUG (1, "%s(?), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd); 1487 IRDA_DEBUG (1, "%s(?), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd);
1484 ret = -EOPNOTSUPP; 1488 ret = -EOPNOTSUPP;
1485 } 1489 }
1486 1490out:
1487 spin_unlock_irqrestore(&self->spinlock, flags); 1491 spin_unlock_irqrestore(&self->spinlock, flags);
1488 return ret; 1492 return ret;
1489 1493
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index 59e8183c639e..400f652282d7 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -31,6 +31,7 @@
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <asm/uaccess.h> 33#include <asm/uaccess.h>
34#include <asm/string.h>
34 35
35#define PPP_VERSION "2.4.2" 36#define PPP_VERSION "2.4.2"
36 37
@@ -835,8 +836,11 @@ process_input_packet(struct asyncppp *ap)
835 err: 836 err:
836 /* frame had an error, remember that, reset SC_TOSS & SC_ESCAPE */ 837 /* frame had an error, remember that, reset SC_TOSS & SC_ESCAPE */
837 ap->state = SC_PREV_ERROR; 838 ap->state = SC_PREV_ERROR;
838 if (skb) 839 if (skb) {
840 /* make skb appear as freshly allocated */
839 skb_trim(skb, 0); 841 skb_trim(skb, 0);
842 skb_reserve(skb, - skb_headroom(skb));
843 }
840} 844}
841 845
842/* Called when the tty driver has data for us. Runs parallel with the 846/* Called when the tty driver has data for us. Runs parallel with the
@@ -889,10 +893,17 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
889 skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2); 893 skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2);
890 if (skb == 0) 894 if (skb == 0)
891 goto nomem; 895 goto nomem;
892 /* Try to get the payload 4-byte aligned */ 896 ap->rpkt = skb;
897 }
898 if (skb->len == 0) {
899 /* Try to get the payload 4-byte aligned.
900 * This should match the
901 * PPP_ALLSTATIONS/PPP_UI/compressed tests in
902 * process_input_packet, but we do not have
903 * enough chars here to test buf[1] and buf[2].
904 */
893 if (buf[0] != PPP_ALLSTATIONS) 905 if (buf[0] != PPP_ALLSTATIONS)
894 skb_reserve(skb, 2 + (buf[0] & 1)); 906 skb_reserve(skb, 2 + (buf[0] & 1));
895 ap->rpkt = skb;
896 } 907 }
897 if (n > skb_tailroom(skb)) { 908 if (n > skb_tailroom(skb)) {
898 /* packet overflowed MRU */ 909 /* packet overflowed MRU */
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index d3c9958b00d0..50430f79f8cf 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -137,13 +137,14 @@ struct ppp {
137 137
138/* 138/*
139 * Bits in flags: SC_NO_TCP_CCID, SC_CCP_OPEN, SC_CCP_UP, SC_LOOP_TRAFFIC, 139 * Bits in flags: SC_NO_TCP_CCID, SC_CCP_OPEN, SC_CCP_UP, SC_LOOP_TRAFFIC,
140 * SC_MULTILINK, SC_MP_SHORTSEQ, SC_MP_XSHORTSEQ, SC_COMP_TCP, SC_REJ_COMP_TCP. 140 * SC_MULTILINK, SC_MP_SHORTSEQ, SC_MP_XSHORTSEQ, SC_COMP_TCP, SC_REJ_COMP_TCP,
141 * SC_MUST_COMP
141 * Bits in rstate: SC_DECOMP_RUN, SC_DC_ERROR, SC_DC_FERROR. 142 * Bits in rstate: SC_DECOMP_RUN, SC_DC_ERROR, SC_DC_FERROR.
142 * Bits in xstate: SC_COMP_RUN 143 * Bits in xstate: SC_COMP_RUN
143 */ 144 */
144#define SC_FLAG_BITS (SC_NO_TCP_CCID|SC_CCP_OPEN|SC_CCP_UP|SC_LOOP_TRAFFIC \ 145#define SC_FLAG_BITS (SC_NO_TCP_CCID|SC_CCP_OPEN|SC_CCP_UP|SC_LOOP_TRAFFIC \
145 |SC_MULTILINK|SC_MP_SHORTSEQ|SC_MP_XSHORTSEQ \ 146 |SC_MULTILINK|SC_MP_SHORTSEQ|SC_MP_XSHORTSEQ \
146 |SC_COMP_TCP|SC_REJ_COMP_TCP) 147 |SC_COMP_TCP|SC_REJ_COMP_TCP|SC_MUST_COMP)
147 148
148/* 149/*
149 * Private data structure for each channel. 150 * Private data structure for each channel.
@@ -1027,6 +1028,56 @@ ppp_xmit_process(struct ppp *ppp)
1027 ppp_xmit_unlock(ppp); 1028 ppp_xmit_unlock(ppp);
1028} 1029}
1029 1030
1031static inline struct sk_buff *
1032pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
1033{
1034 struct sk_buff *new_skb;
1035 int len;
1036 int new_skb_size = ppp->dev->mtu +
1037 ppp->xcomp->comp_extra + ppp->dev->hard_header_len;
1038 int compressor_skb_size = ppp->dev->mtu +
1039 ppp->xcomp->comp_extra + PPP_HDRLEN;
1040 new_skb = alloc_skb(new_skb_size, GFP_ATOMIC);
1041 if (!new_skb) {
1042 if (net_ratelimit())
1043 printk(KERN_ERR "PPP: no memory (comp pkt)\n");
1044 return NULL;
1045 }
1046 if (ppp->dev->hard_header_len > PPP_HDRLEN)
1047 skb_reserve(new_skb,
1048 ppp->dev->hard_header_len - PPP_HDRLEN);
1049
1050 /* compressor still expects A/C bytes in hdr */
1051 len = ppp->xcomp->compress(ppp->xc_state, skb->data - 2,
1052 new_skb->data, skb->len + 2,
1053 compressor_skb_size);
1054 if (len > 0 && (ppp->flags & SC_CCP_UP)) {
1055 kfree_skb(skb);
1056 skb = new_skb;
1057 skb_put(skb, len);
1058 skb_pull(skb, 2); /* pull off A/C bytes */
1059 } else if (len == 0) {
1060 /* didn't compress, or CCP not up yet */
1061 kfree_skb(new_skb);
1062 new_skb = skb;
1063 } else {
1064 /*
1065 * (len < 0)
1066 * MPPE requires that we do not send unencrypted
1067 * frames. The compressor will return -1 if we
1068 * should drop the frame. We cannot simply test
1069 * the compress_proto because MPPE and MPPC share
1070 * the same number.
1071 */
1072 if (net_ratelimit())
1073 printk(KERN_ERR "ppp: compressor dropped pkt\n");
1074 kfree_skb(skb);
1075 kfree_skb(new_skb);
1076 new_skb = NULL;
1077 }
1078 return new_skb;
1079}
1080
1030/* 1081/*
1031 * Compress and send a frame. 1082 * Compress and send a frame.
1032 * The caller should have locked the xmit path, 1083 * The caller should have locked the xmit path,
@@ -1113,29 +1164,14 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
1113 /* try to do packet compression */ 1164 /* try to do packet compression */
1114 if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state != 0 1165 if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state != 0
1115 && proto != PPP_LCP && proto != PPP_CCP) { 1166 && proto != PPP_LCP && proto != PPP_CCP) {
1116 new_skb = alloc_skb(ppp->dev->mtu + ppp->dev->hard_header_len, 1167 if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) {
1117 GFP_ATOMIC); 1168 if (net_ratelimit())
1118 if (new_skb == 0) { 1169 printk(KERN_ERR "ppp: compression required but down - pkt dropped.\n");
1119 printk(KERN_ERR "PPP: no memory (comp pkt)\n");
1120 goto drop; 1170 goto drop;
1121 } 1171 }
1122 if (ppp->dev->hard_header_len > PPP_HDRLEN) 1172 skb = pad_compress_skb(ppp, skb);
1123 skb_reserve(new_skb, 1173 if (!skb)
1124 ppp->dev->hard_header_len - PPP_HDRLEN); 1174 goto drop;
1125
1126 /* compressor still expects A/C bytes in hdr */
1127 len = ppp->xcomp->compress(ppp->xc_state, skb->data - 2,
1128 new_skb->data, skb->len + 2,
1129 ppp->dev->mtu + PPP_HDRLEN);
1130 if (len > 0 && (ppp->flags & SC_CCP_UP)) {
1131 kfree_skb(skb);
1132 skb = new_skb;
1133 skb_put(skb, len);
1134 skb_pull(skb, 2); /* pull off A/C bytes */
1135 } else {
1136 /* didn't compress, or CCP not up yet */
1137 kfree_skb(new_skb);
1138 }
1139 } 1175 }
1140 1176
1141 /* 1177 /*
@@ -1155,7 +1191,8 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
1155 return; 1191 return;
1156 1192
1157 drop: 1193 drop:
1158 kfree_skb(skb); 1194 if (skb)
1195 kfree_skb(skb);
1159 ++ppp->stats.tx_errors; 1196 ++ppp->stats.tx_errors;
1160} 1197}
1161 1198
@@ -1552,6 +1589,9 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1552 && (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0) 1589 && (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0)
1553 skb = ppp_decompress_frame(ppp, skb); 1590 skb = ppp_decompress_frame(ppp, skb);
1554 1591
1592 if (ppp->flags & SC_MUST_COMP && ppp->rstate & SC_DC_FERROR)
1593 goto err;
1594
1555 proto = PPP_PROTO(skb); 1595 proto = PPP_PROTO(skb);
1556 switch (proto) { 1596 switch (proto) {
1557 case PPP_VJC_COMP: 1597 case PPP_VJC_COMP:
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c
new file mode 100644
index 000000000000..1985d1b57c45
--- /dev/null
+++ b/drivers/net/ppp_mppe.c
@@ -0,0 +1,724 @@
1/*
2 * ppp_mppe.c - interface MPPE to the PPP code.
3 * This version is for use with Linux kernel 2.6.14+
4 *
5 * By Frank Cusack <fcusack@fcusack.com>.
6 * Copyright (c) 2002,2003,2004 Google, Inc.
7 * All rights reserved.
8 *
9 * License:
10 * Permission to use, copy, modify, and distribute this software and its
11 * documentation is hereby granted, provided that the above copyright
12 * notice appears in all copies. This software is provided without any
13 * warranty, express or implied.
14 *
15 * ALTERNATIVELY, provided that this notice is retained in full, this product
16 * may be distributed under the terms of the GNU General Public License (GPL),
17 * in which case the provisions of the GPL apply INSTEAD OF those given above.
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 *
33 *
34 * Changelog:
35 * 08/12/05 - Matt Domsch <Matt_Domsch@dell.com>
36 * Only need extra skb padding on transmit, not receive.
37 * 06/18/04 - Matt Domsch <Matt_Domsch@dell.com>, Oleg Makarenko <mole@quadra.ru>
38 * Use Linux kernel 2.6 arc4 and sha1 routines rather than
39 * providing our own.
40 * 2/15/04 - TS: added #include <version.h> and testing for Kernel
41 * version before using
42 * MOD_DEC_USAGE_COUNT/MOD_INC_USAGE_COUNT which are
43 * deprecated in 2.6
44 */
45
46#include <linux/config.h>
47#include <linux/module.h>
48#include <linux/kernel.h>
49#include <linux/version.h>
50#include <linux/init.h>
51#include <linux/types.h>
52#include <linux/slab.h>
53#include <linux/string.h>
54#include <linux/crypto.h>
55#include <linux/mm.h>
56#include <linux/ppp_defs.h>
57#include <linux/ppp-comp.h>
58#include <asm/scatterlist.h>
59
60#include "ppp_mppe.h"
61
62MODULE_AUTHOR("Frank Cusack <fcusack@fcusack.com>");
63MODULE_DESCRIPTION("Point-to-Point Protocol Microsoft Point-to-Point Encryption support");
64MODULE_LICENSE("Dual BSD/GPL");
65MODULE_ALIAS("ppp-compress-" __stringify(CI_MPPE));
66MODULE_VERSION("1.0.2");
67
68static void
69setup_sg(struct scatterlist *sg, const void *address, unsigned int length)
70{
71 sg[0].page = virt_to_page(address);
72 sg[0].offset = offset_in_page(address);
73 sg[0].length = length;
74}
75
76#define SHA1_PAD_SIZE 40
77
78/*
79 * kernel crypto API needs its arguments to be in kmalloc'd memory, not in the module
80 * static data area. That means sha_pad needs to be kmalloc'd.
81 */
82
83struct sha_pad {
84 unsigned char sha_pad1[SHA1_PAD_SIZE];
85 unsigned char sha_pad2[SHA1_PAD_SIZE];
86};
87static struct sha_pad *sha_pad;
88
89static inline void sha_pad_init(struct sha_pad *shapad)
90{
91 memset(shapad->sha_pad1, 0x00, sizeof(shapad->sha_pad1));
92 memset(shapad->sha_pad2, 0xF2, sizeof(shapad->sha_pad2));
93}
94
95/*
96 * State for an MPPE (de)compressor.
97 */
98struct ppp_mppe_state {
99 struct crypto_tfm *arc4;
100 struct crypto_tfm *sha1;
101 unsigned char *sha1_digest;
102 unsigned char master_key[MPPE_MAX_KEY_LEN];
103 unsigned char session_key[MPPE_MAX_KEY_LEN];
104 unsigned keylen; /* key length in bytes */
105 /* NB: 128-bit == 16, 40-bit == 8! */
106 /* If we want to support 56-bit, */
107 /* the unit has to change to bits */
108 unsigned char bits; /* MPPE control bits */
109 unsigned ccount; /* 12-bit coherency count (seqno) */
110 unsigned stateful; /* stateful mode flag */
111 int discard; /* stateful mode packet loss flag */
112 int sanity_errors; /* take down LCP if too many */
113 int unit;
114 int debug;
115 struct compstat stats;
116};
117
118/* struct ppp_mppe_state.bits definitions */
119#define MPPE_BIT_A 0x80 /* Encryption table were (re)inititalized */
120#define MPPE_BIT_B 0x40 /* MPPC only (not implemented) */
121#define MPPE_BIT_C 0x20 /* MPPC only (not implemented) */
122#define MPPE_BIT_D 0x10 /* This is an encrypted frame */
123
124#define MPPE_BIT_FLUSHED MPPE_BIT_A
125#define MPPE_BIT_ENCRYPTED MPPE_BIT_D
126
127#define MPPE_BITS(p) ((p)[4] & 0xf0)
128#define MPPE_CCOUNT(p) ((((p)[4] & 0x0f) << 8) + (p)[5])
129#define MPPE_CCOUNT_SPACE 0x1000 /* The size of the ccount space */
130
131#define MPPE_OVHD 2 /* MPPE overhead/packet */
132#define SANITY_MAX 1600 /* Max bogon factor we will tolerate */
133
134/*
135 * Key Derivation, from RFC 3078, RFC 3079.
136 * Equivalent to Get_Key() for MS-CHAP as described in RFC 3079.
137 */
138static void get_new_key_from_sha(struct ppp_mppe_state * state, unsigned char *InterimKey)
139{
140 struct scatterlist sg[4];
141
142 setup_sg(&sg[0], state->master_key, state->keylen);
143 setup_sg(&sg[1], sha_pad->sha_pad1, sizeof(sha_pad->sha_pad1));
144 setup_sg(&sg[2], state->session_key, state->keylen);
145 setup_sg(&sg[3], sha_pad->sha_pad2, sizeof(sha_pad->sha_pad2));
146
147 crypto_digest_digest (state->sha1, sg, 4, state->sha1_digest);
148
149 memcpy(InterimKey, state->sha1_digest, state->keylen);
150}
151
152/*
153 * Perform the MPPE rekey algorithm, from RFC 3078, sec. 7.3.
154 * Well, not what's written there, but rather what they meant.
155 */
156static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
157{
158 unsigned char InterimKey[MPPE_MAX_KEY_LEN];
159 struct scatterlist sg_in[1], sg_out[1];
160
161 get_new_key_from_sha(state, InterimKey);
162 if (!initial_key) {
163 crypto_cipher_setkey(state->arc4, InterimKey, state->keylen);
164 setup_sg(sg_in, InterimKey, state->keylen);
165 setup_sg(sg_out, state->session_key, state->keylen);
166 if (crypto_cipher_encrypt(state->arc4, sg_out, sg_in,
167 state->keylen) != 0) {
168 printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n");
169 }
170 } else {
171 memcpy(state->session_key, InterimKey, state->keylen);
172 }
173 if (state->keylen == 8) {
174 /* See RFC 3078 */
175 state->session_key[0] = 0xd1;
176 state->session_key[1] = 0x26;
177 state->session_key[2] = 0x9e;
178 }
179 crypto_cipher_setkey(state->arc4, state->session_key, state->keylen);
180}
181
182/*
183 * Allocate space for a (de)compressor.
184 */
185static void *mppe_alloc(unsigned char *options, int optlen)
186{
187 struct ppp_mppe_state *state;
188 unsigned int digestsize;
189
190 if (optlen != CILEN_MPPE + sizeof(state->master_key)
191 || options[0] != CI_MPPE || options[1] != CILEN_MPPE)
192 goto out;
193
194 state = (struct ppp_mppe_state *) kmalloc(sizeof(*state), GFP_KERNEL);
195 if (state == NULL)
196 goto out;
197
198 memset(state, 0, sizeof(*state));
199
200 state->arc4 = crypto_alloc_tfm("arc4", 0);
201 if (!state->arc4)
202 goto out_free;
203
204 state->sha1 = crypto_alloc_tfm("sha1", 0);
205 if (!state->sha1)
206 goto out_free;
207
208 digestsize = crypto_tfm_alg_digestsize(state->sha1);
209 if (digestsize < MPPE_MAX_KEY_LEN)
210 goto out_free;
211
212 state->sha1_digest = kmalloc(digestsize, GFP_KERNEL);
213 if (!state->sha1_digest)
214 goto out_free;
215
216 /* Save keys. */
217 memcpy(state->master_key, &options[CILEN_MPPE],
218 sizeof(state->master_key));
219 memcpy(state->session_key, state->master_key,
220 sizeof(state->master_key));
221
222 /*
223 * We defer initial key generation until mppe_init(), as mppe_alloc()
224 * is called frequently during negotiation.
225 */
226
227 return (void *)state;
228
229 out_free:
230 if (state->sha1_digest)
231 kfree(state->sha1_digest);
232 if (state->sha1)
233 crypto_free_tfm(state->sha1);
234 if (state->arc4)
235 crypto_free_tfm(state->arc4);
236 kfree(state);
237 out:
238 return NULL;
239}
240
241/*
242 * Deallocate space for a (de)compressor.
243 */
244static void mppe_free(void *arg)
245{
246 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
247 if (state) {
248 if (state->sha1_digest)
249 kfree(state->sha1_digest);
250 if (state->sha1)
251 crypto_free_tfm(state->sha1);
252 if (state->arc4)
253 crypto_free_tfm(state->arc4);
254 kfree(state);
255 }
256}
257
258/*
259 * Initialize (de)compressor state.
260 */
261static int
262mppe_init(void *arg, unsigned char *options, int optlen, int unit, int debug,
263 const char *debugstr)
264{
265 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
266 unsigned char mppe_opts;
267
268 if (optlen != CILEN_MPPE
269 || options[0] != CI_MPPE || options[1] != CILEN_MPPE)
270 return 0;
271
272 MPPE_CI_TO_OPTS(&options[2], mppe_opts);
273 if (mppe_opts & MPPE_OPT_128)
274 state->keylen = 16;
275 else if (mppe_opts & MPPE_OPT_40)
276 state->keylen = 8;
277 else {
278 printk(KERN_WARNING "%s[%d]: unknown key length\n", debugstr,
279 unit);
280 return 0;
281 }
282 if (mppe_opts & MPPE_OPT_STATEFUL)
283 state->stateful = 1;
284
285 /* Generate the initial session key. */
286 mppe_rekey(state, 1);
287
288 if (debug) {
289 int i;
290 char mkey[sizeof(state->master_key) * 2 + 1];
291 char skey[sizeof(state->session_key) * 2 + 1];
292
293 printk(KERN_DEBUG "%s[%d]: initialized with %d-bit %s mode\n",
294 debugstr, unit, (state->keylen == 16) ? 128 : 40,
295 (state->stateful) ? "stateful" : "stateless");
296
297 for (i = 0; i < sizeof(state->master_key); i++)
298 sprintf(mkey + i * 2, "%02x", state->master_key[i]);
299 for (i = 0; i < sizeof(state->session_key); i++)
300 sprintf(skey + i * 2, "%02x", state->session_key[i]);
301 printk(KERN_DEBUG
302 "%s[%d]: keys: master: %s initial session: %s\n",
303 debugstr, unit, mkey, skey);
304 }
305
306 /*
307 * Initialize the coherency count. The initial value is not specified
308 * in RFC 3078, but we can make a reasonable assumption that it will
309 * start at 0. Setting it to the max here makes the comp/decomp code
310 * do the right thing (determined through experiment).
311 */
312 state->ccount = MPPE_CCOUNT_SPACE - 1;
313
314 /*
315 * Note that even though we have initialized the key table, we don't
316 * set the FLUSHED bit. This is contrary to RFC 3078, sec. 3.1.
317 */
318 state->bits = MPPE_BIT_ENCRYPTED;
319
320 state->unit = unit;
321 state->debug = debug;
322
323 return 1;
324}
325
326static int
327mppe_comp_init(void *arg, unsigned char *options, int optlen, int unit,
328 int hdrlen, int debug)
329{
330 /* ARGSUSED */
331 return mppe_init(arg, options, optlen, unit, debug, "mppe_comp_init");
332}
333
334/*
335 * We received a CCP Reset-Request (actually, we are sending a Reset-Ack),
336 * tell the compressor to rekey. Note that we MUST NOT rekey for
337 * every CCP Reset-Request; we only rekey on the next xmit packet.
338 * We might get multiple CCP Reset-Requests if our CCP Reset-Ack is lost.
339 * So, rekeying for every CCP Reset-Request is broken as the peer will not
340 * know how many times we've rekeyed. (If we rekey and THEN get another
341 * CCP Reset-Request, we must rekey again.)
342 */
343static void mppe_comp_reset(void *arg)
344{
345 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
346
347 state->bits |= MPPE_BIT_FLUSHED;
348}
349
350/*
351 * Compress (encrypt) a packet.
352 * It's strange to call this a compressor, since the output is always
353 * MPPE_OVHD + 2 bytes larger than the input.
354 */
355static int
356mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf,
357 int isize, int osize)
358{
359 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
360 int proto;
361 struct scatterlist sg_in[1], sg_out[1];
362
363 /*
364 * Check that the protocol is in the range we handle.
365 */
366 proto = PPP_PROTOCOL(ibuf);
367 if (proto < 0x0021 || proto > 0x00fa)
368 return 0;
369
370 /* Make sure we have enough room to generate an encrypted packet. */
371 if (osize < isize + MPPE_OVHD + 2) {
372 /* Drop the packet if we should encrypt it, but can't. */
373 printk(KERN_DEBUG "mppe_compress[%d]: osize too small! "
374 "(have: %d need: %d)\n", state->unit,
375 osize, osize + MPPE_OVHD + 2);
376 return -1;
377 }
378
379 osize = isize + MPPE_OVHD + 2;
380
381 /*
382 * Copy over the PPP header and set control bits.
383 */
384 obuf[0] = PPP_ADDRESS(ibuf);
385 obuf[1] = PPP_CONTROL(ibuf);
386 obuf[2] = PPP_COMP >> 8; /* isize + MPPE_OVHD + 1 */
387 obuf[3] = PPP_COMP; /* isize + MPPE_OVHD + 2 */
388 obuf += PPP_HDRLEN;
389
390 state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE;
391 if (state->debug >= 7)
392 printk(KERN_DEBUG "mppe_compress[%d]: ccount %d\n", state->unit,
393 state->ccount);
394 obuf[0] = state->ccount >> 8;
395 obuf[1] = state->ccount & 0xff;
396
397 if (!state->stateful || /* stateless mode */
398 ((state->ccount & 0xff) == 0xff) || /* "flag" packet */
399 (state->bits & MPPE_BIT_FLUSHED)) { /* CCP Reset-Request */
400 /* We must rekey */
401 if (state->debug && state->stateful)
402 printk(KERN_DEBUG "mppe_compress[%d]: rekeying\n",
403 state->unit);
404 mppe_rekey(state, 0);
405 state->bits |= MPPE_BIT_FLUSHED;
406 }
407 obuf[0] |= state->bits;
408 state->bits &= ~MPPE_BIT_FLUSHED; /* reset for next xmit */
409
410 obuf += MPPE_OVHD;
411 ibuf += 2; /* skip to proto field */
412 isize -= 2;
413
414 /* Encrypt packet */
415 setup_sg(sg_in, ibuf, isize);
416 setup_sg(sg_out, obuf, osize);
417 if (crypto_cipher_encrypt(state->arc4, sg_out, sg_in, isize) != 0) {
418 printk(KERN_DEBUG "crypto_cypher_encrypt failed\n");
419 return -1;
420 }
421
422 state->stats.unc_bytes += isize;
423 state->stats.unc_packets++;
424 state->stats.comp_bytes += osize;
425 state->stats.comp_packets++;
426
427 return osize;
428}
429
430/*
431 * Since every frame grows by MPPE_OVHD + 2 bytes, this is always going
432 * to look bad ... and the longer the link is up the worse it will get.
433 */
434static void mppe_comp_stats(void *arg, struct compstat *stats)
435{
436 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
437
438 *stats = state->stats;
439}
440
441static int
442mppe_decomp_init(void *arg, unsigned char *options, int optlen, int unit,
443 int hdrlen, int mru, int debug)
444{
445 /* ARGSUSED */
446 return mppe_init(arg, options, optlen, unit, debug, "mppe_decomp_init");
447}
448
449/*
450 * We received a CCP Reset-Ack. Just ignore it.
451 */
452static void mppe_decomp_reset(void *arg)
453{
454 /* ARGSUSED */
455 return;
456}
457
458/*
459 * Decompress (decrypt) an MPPE packet.
460 */
461static int
462mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
463 int osize)
464{
465 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
466 unsigned ccount;
467 int flushed = MPPE_BITS(ibuf) & MPPE_BIT_FLUSHED;
468 int sanity = 0;
469 struct scatterlist sg_in[1], sg_out[1];
470
471 if (isize <= PPP_HDRLEN + MPPE_OVHD) {
472 if (state->debug)
473 printk(KERN_DEBUG
474 "mppe_decompress[%d]: short pkt (%d)\n",
475 state->unit, isize);
476 return DECOMP_ERROR;
477 }
478
479 /*
480 * Make sure we have enough room to decrypt the packet.
481 * Note that for our test we only subtract 1 byte whereas in
482 * mppe_compress() we added 2 bytes (+MPPE_OVHD);
483 * this is to account for possible PFC.
484 */
485 if (osize < isize - MPPE_OVHD - 1) {
486 printk(KERN_DEBUG "mppe_decompress[%d]: osize too small! "
487 "(have: %d need: %d)\n", state->unit,
488 osize, isize - MPPE_OVHD - 1);
489 return DECOMP_ERROR;
490 }
491 osize = isize - MPPE_OVHD - 2; /* assume no PFC */
492
493 ccount = MPPE_CCOUNT(ibuf);
494 if (state->debug >= 7)
495 printk(KERN_DEBUG "mppe_decompress[%d]: ccount %d\n",
496 state->unit, ccount);
497
498 /* sanity checks -- terminate with extreme prejudice */
499 if (!(MPPE_BITS(ibuf) & MPPE_BIT_ENCRYPTED)) {
500 printk(KERN_DEBUG
501 "mppe_decompress[%d]: ENCRYPTED bit not set!\n",
502 state->unit);
503 state->sanity_errors += 100;
504 sanity = 1;
505 }
506 if (!state->stateful && !flushed) {
507 printk(KERN_DEBUG "mppe_decompress[%d]: FLUSHED bit not set in "
508 "stateless mode!\n", state->unit);
509 state->sanity_errors += 100;
510 sanity = 1;
511 }
512 if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) {
513 printk(KERN_DEBUG "mppe_decompress[%d]: FLUSHED bit not set on "
514 "flag packet!\n", state->unit);
515 state->sanity_errors += 100;
516 sanity = 1;
517 }
518
519 if (sanity) {
520 if (state->sanity_errors < SANITY_MAX)
521 return DECOMP_ERROR;
522 else
523 /*
524 * Take LCP down if the peer is sending too many bogons.
525 * We don't want to do this for a single or just a few
526 * instances since it could just be due to packet corruption.
527 */
528 return DECOMP_FATALERROR;
529 }
530
531 /*
532 * Check the coherency count.
533 */
534
535 if (!state->stateful) {
536 /* RFC 3078, sec 8.1. Rekey for every packet. */
537 while (state->ccount != ccount) {
538 mppe_rekey(state, 0);
539 state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE;
540 }
541 } else {
542 /* RFC 3078, sec 8.2. */
543 if (!state->discard) {
544 /* normal state */
545 state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE;
546 if (ccount != state->ccount) {
547 /*
548 * (ccount > state->ccount)
549 * Packet loss detected, enter the discard state.
550 * Signal the peer to rekey (by sending a CCP Reset-Request).
551 */
552 state->discard = 1;
553 return DECOMP_ERROR;
554 }
555 } else {
556 /* discard state */
557 if (!flushed) {
558 /* ccp.c will be silent (no additional CCP Reset-Requests). */
559 return DECOMP_ERROR;
560 } else {
561 /* Rekey for every missed "flag" packet. */
562 while ((ccount & ~0xff) !=
563 (state->ccount & ~0xff)) {
564 mppe_rekey(state, 0);
565 state->ccount =
566 (state->ccount +
567 256) % MPPE_CCOUNT_SPACE;
568 }
569
570 /* reset */
571 state->discard = 0;
572 state->ccount = ccount;
573 /*
574 * Another problem with RFC 3078 here. It implies that the
575 * peer need not send a Reset-Ack packet. But RFC 1962
576 * requires it. Hopefully, M$ does send a Reset-Ack; even
577 * though it isn't required for MPPE synchronization, it is
578 * required to reset CCP state.
579 */
580 }
581 }
582 if (flushed)
583 mppe_rekey(state, 0);
584 }
585
586 /*
587 * Fill in the first part of the PPP header. The protocol field
588 * comes from the decrypted data.
589 */
590 obuf[0] = PPP_ADDRESS(ibuf); /* +1 */
591 obuf[1] = PPP_CONTROL(ibuf); /* +1 */
592 obuf += 2;
593 ibuf += PPP_HDRLEN + MPPE_OVHD;
594 isize -= PPP_HDRLEN + MPPE_OVHD; /* -6 */
595 /* net osize: isize-4 */
596
597 /*
598 * Decrypt the first byte in order to check if it is
599 * a compressed or uncompressed protocol field.
600 */
601 setup_sg(sg_in, ibuf, 1);
602 setup_sg(sg_out, obuf, 1);
603 if (crypto_cipher_decrypt(state->arc4, sg_out, sg_in, 1) != 0) {
604 printk(KERN_DEBUG "crypto_cypher_decrypt failed\n");
605 return DECOMP_ERROR;
606 }
607
608 /*
609 * Do PFC decompression.
610 * This would be nicer if we were given the actual sk_buff
611 * instead of a char *.
612 */
613 if ((obuf[0] & 0x01) != 0) {
614 obuf[1] = obuf[0];
615 obuf[0] = 0;
616 obuf++;
617 osize++;
618 }
619
620 /* And finally, decrypt the rest of the packet. */
621 setup_sg(sg_in, ibuf + 1, isize - 1);
622 setup_sg(sg_out, obuf + 1, osize - 1);
623 if (crypto_cipher_decrypt(state->arc4, sg_out, sg_in, isize - 1) != 0) {
624 printk(KERN_DEBUG "crypto_cypher_decrypt failed\n");
625 return DECOMP_ERROR;
626 }
627
628 state->stats.unc_bytes += osize;
629 state->stats.unc_packets++;
630 state->stats.comp_bytes += isize;
631 state->stats.comp_packets++;
632
633 /* good packet credit */
634 state->sanity_errors >>= 1;
635
636 return osize;
637}
638
639/*
640 * Incompressible data has arrived (this should never happen!).
641 * We should probably drop the link if the protocol is in the range
642 * of what should be encrypted. At the least, we should drop this
643 * packet. (How to do this?)
644 */
645static void mppe_incomp(void *arg, unsigned char *ibuf, int icnt)
646{
647 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
648
649 if (state->debug &&
650 (PPP_PROTOCOL(ibuf) >= 0x0021 && PPP_PROTOCOL(ibuf) <= 0x00fa))
651 printk(KERN_DEBUG
652 "mppe_incomp[%d]: incompressible (unencrypted) data! "
653 "(proto %04x)\n", state->unit, PPP_PROTOCOL(ibuf));
654
655 state->stats.inc_bytes += icnt;
656 state->stats.inc_packets++;
657 state->stats.unc_bytes += icnt;
658 state->stats.unc_packets++;
659}
660
661/*************************************************************
662 * Module interface table
663 *************************************************************/
664
665/*
666 * Procedures exported to if_ppp.c.
667 */
668static struct compressor ppp_mppe = {
669 .compress_proto = CI_MPPE,
670 .comp_alloc = mppe_alloc,
671 .comp_free = mppe_free,
672 .comp_init = mppe_comp_init,
673 .comp_reset = mppe_comp_reset,
674 .compress = mppe_compress,
675 .comp_stat = mppe_comp_stats,
676 .decomp_alloc = mppe_alloc,
677 .decomp_free = mppe_free,
678 .decomp_init = mppe_decomp_init,
679 .decomp_reset = mppe_decomp_reset,
680 .decompress = mppe_decompress,
681 .incomp = mppe_incomp,
682 .decomp_stat = mppe_comp_stats,
683 .owner = THIS_MODULE,
684 .comp_extra = MPPE_PAD,
685};
686
687/*
688 * ppp_mppe_init()
689 *
690 * Prior to allowing load, try to load the arc4 and sha1 crypto
691 * libraries. The actual use will be allocated later, but
692 * this way the module will fail to insmod if they aren't available.
693 */
694
695static int __init ppp_mppe_init(void)
696{
697 int answer;
698 if (!(crypto_alg_available("arc4", 0) &&
699 crypto_alg_available("sha1", 0)))
700 return -ENODEV;
701
702 sha_pad = kmalloc(sizeof(struct sha_pad), GFP_KERNEL);
703 if (!sha_pad)
704 return -ENOMEM;
705 sha_pad_init(sha_pad);
706
707 answer = ppp_register_compressor(&ppp_mppe);
708
709 if (answer == 0)
710 printk(KERN_INFO "PPP MPPE Compression module registered\n");
711 else
712 kfree(sha_pad);
713
714 return answer;
715}
716
717static void __exit ppp_mppe_cleanup(void)
718{
719 ppp_unregister_compressor(&ppp_mppe);
720 kfree(sha_pad);
721}
722
723module_init(ppp_mppe_init);
724module_exit(ppp_mppe_cleanup);
diff --git a/drivers/net/ppp_mppe.h b/drivers/net/ppp_mppe.h
new file mode 100644
index 000000000000..7a14e058c668
--- /dev/null
+++ b/drivers/net/ppp_mppe.h
@@ -0,0 +1,86 @@
1#define MPPE_PAD 4 /* MPPE growth per frame */
2#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */
3
4/* option bits for ccp_options.mppe */
5#define MPPE_OPT_40 0x01 /* 40 bit */
6#define MPPE_OPT_128 0x02 /* 128 bit */
7#define MPPE_OPT_STATEFUL 0x04 /* stateful mode */
8/* unsupported opts */
9#define MPPE_OPT_56 0x08 /* 56 bit */
10#define MPPE_OPT_MPPC 0x10 /* MPPC compression */
11#define MPPE_OPT_D 0x20 /* Unknown */
12#define MPPE_OPT_UNSUPPORTED (MPPE_OPT_56|MPPE_OPT_MPPC|MPPE_OPT_D)
13#define MPPE_OPT_UNKNOWN 0x40 /* Bits !defined in RFC 3078 were set */
14
15/*
16 * This is not nice ... the alternative is a bitfield struct though.
17 * And unfortunately, we cannot share the same bits for the option
18 * names above since C and H are the same bit. We could do a u_int32
19 * but then we have to do a htonl() all the time and/or we still need
20 * to know which octet is which.
21 */
22#define MPPE_C_BIT 0x01 /* MPPC */
23#define MPPE_D_BIT 0x10 /* Obsolete, usage unknown */
24#define MPPE_L_BIT 0x20 /* 40-bit */
25#define MPPE_S_BIT 0x40 /* 128-bit */
26#define MPPE_M_BIT 0x80 /* 56-bit, not supported */
27#define MPPE_H_BIT 0x01 /* Stateless (in a different byte) */
28
29/* Does not include H bit; used for least significant octet only. */
30#define MPPE_ALL_BITS (MPPE_D_BIT|MPPE_L_BIT|MPPE_S_BIT|MPPE_M_BIT|MPPE_H_BIT)
31
32/* Build a CI from mppe opts (see RFC 3078) */
33#define MPPE_OPTS_TO_CI(opts, ci) \
34 do { \
35 u_char *ptr = ci; /* u_char[4] */ \
36 \
37 /* H bit */ \
38 if (opts & MPPE_OPT_STATEFUL) \
39 *ptr++ = 0x0; \
40 else \
41 *ptr++ = MPPE_H_BIT; \
42 *ptr++ = 0; \
43 *ptr++ = 0; \
44 \
45 /* S,L bits */ \
46 *ptr = 0; \
47 if (opts & MPPE_OPT_128) \
48 *ptr |= MPPE_S_BIT; \
49 if (opts & MPPE_OPT_40) \
50 *ptr |= MPPE_L_BIT; \
51 /* M,D,C bits not supported */ \
52 } while (/* CONSTCOND */ 0)
53
54/* The reverse of the above */
55#define MPPE_CI_TO_OPTS(ci, opts) \
56 do { \
57 u_char *ptr = ci; /* u_char[4] */ \
58 \
59 opts = 0; \
60 \
61 /* H bit */ \
62 if (!(ptr[0] & MPPE_H_BIT)) \
63 opts |= MPPE_OPT_STATEFUL; \
64 \
65 /* S,L bits */ \
66 if (ptr[3] & MPPE_S_BIT) \
67 opts |= MPPE_OPT_128; \
68 if (ptr[3] & MPPE_L_BIT) \
69 opts |= MPPE_OPT_40; \
70 \
71 /* M,D,C bits */ \
72 if (ptr[3] & MPPE_M_BIT) \
73 opts |= MPPE_OPT_56; \
74 if (ptr[3] & MPPE_D_BIT) \
75 opts |= MPPE_OPT_D; \
76 if (ptr[3] & MPPE_C_BIT) \
77 opts |= MPPE_OPT_MPPC; \
78 \
79 /* Other bits */ \
80 if (ptr[0] & ~MPPE_H_BIT) \
81 opts |= MPPE_OPT_UNKNOWN; \
82 if (ptr[1] || ptr[2]) \
83 opts |= MPPE_OPT_UNKNOWN; \
84 if (ptr[3] & ~MPPE_ALL_BITS) \
85 opts |= MPPE_OPT_UNKNOWN; \
86 } while (/* CONSTCOND */ 0)
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
index fe5ea36e7de3..56c58831e80e 100644
--- a/drivers/pcmcia/pxa2xx_sharpsl.c
+++ b/drivers/pcmcia/pxa2xx_sharpsl.c
@@ -22,16 +22,20 @@
22#include <asm/hardware.h> 22#include <asm/hardware.h>
23#include <asm/irq.h> 23#include <asm/irq.h>
24#include <asm/hardware/scoop.h> 24#include <asm/hardware/scoop.h>
25#ifdef CONFIG_SA1100_COLLIE
26#include <asm/arch-sa1100/collie.h>
27#else
28#include <asm/arch-pxa/pxa-regs.h>
29#endif
30 25
31#include "soc_common.h" 26#include "soc_common.h"
32 27
33#define NO_KEEP_VS 0x0001 28#define NO_KEEP_VS 0x0001
34 29
30/* PCMCIA to Scoop linkage
31
32 There is no easy way to link multiple scoop devices into one
33 single entity for the pxa2xx_pcmcia device so this structure
34 is used which is setup by the platform code
35*/
36struct scoop_pcmcia_config *platform_scoop_config;
37#define SCOOP_DEV platform_scoop_config->devs
38
35static void sharpsl_pcmcia_init_reset(struct scoop_pcmcia_dev *scoopdev) 39static void sharpsl_pcmcia_init_reset(struct scoop_pcmcia_dev *scoopdev)
36{ 40{
37 reset_scoop(scoopdev->dev); 41 reset_scoop(scoopdev->dev);
@@ -43,38 +47,16 @@ static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
43{ 47{
44 int ret; 48 int ret;
45 49
46#ifndef CONFIG_SA1100_COLLIE 50 if (platform_scoop_config->pcmcia_init)
47 /* 51 platform_scoop_config->pcmcia_init();
48 * Setup default state of GPIO outputs
49 * before we enable them as outputs.
50 */
51 GPSR(GPIO48_nPOE) =
52 GPIO_bit(GPIO48_nPOE) |
53 GPIO_bit(GPIO49_nPWE) |
54 GPIO_bit(GPIO50_nPIOR) |
55 GPIO_bit(GPIO51_nPIOW) |
56 GPIO_bit(GPIO52_nPCE_1) |
57 GPIO_bit(GPIO53_nPCE_2);
58
59 pxa_gpio_mode(GPIO48_nPOE_MD);
60 pxa_gpio_mode(GPIO49_nPWE_MD);
61 pxa_gpio_mode(GPIO50_nPIOR_MD);
62 pxa_gpio_mode(GPIO51_nPIOW_MD);
63 pxa_gpio_mode(GPIO52_nPCE_1_MD);
64 pxa_gpio_mode(GPIO53_nPCE_2_MD);
65 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
66 pxa_gpio_mode(GPIO55_nPREG_MD);
67 pxa_gpio_mode(GPIO56_nPWAIT_MD);
68 pxa_gpio_mode(GPIO57_nIOIS16_MD);
69#endif
70 52
71 /* Register interrupts */ 53 /* Register interrupts */
72 if (scoop_devs[skt->nr].cd_irq >= 0) { 54 if (SCOOP_DEV[skt->nr].cd_irq >= 0) {
73 struct pcmcia_irqs cd_irq; 55 struct pcmcia_irqs cd_irq;
74 56
75 cd_irq.sock = skt->nr; 57 cd_irq.sock = skt->nr;
76 cd_irq.irq = scoop_devs[skt->nr].cd_irq; 58 cd_irq.irq = SCOOP_DEV[skt->nr].cd_irq;
77 cd_irq.str = scoop_devs[skt->nr].cd_irq_str; 59 cd_irq.str = SCOOP_DEV[skt->nr].cd_irq_str;
78 ret = soc_pcmcia_request_irqs(skt, &cd_irq, 1); 60 ret = soc_pcmcia_request_irqs(skt, &cd_irq, 1);
79 61
80 if (ret) { 62 if (ret) {
@@ -83,19 +65,19 @@ static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
83 } 65 }
84 } 66 }
85 67
86 skt->irq = scoop_devs[skt->nr].irq; 68 skt->irq = SCOOP_DEV[skt->nr].irq;
87 69
88 return 0; 70 return 0;
89} 71}
90 72
91static void sharpsl_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) 73static void sharpsl_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
92{ 74{
93 if (scoop_devs[skt->nr].cd_irq >= 0) { 75 if (SCOOP_DEV[skt->nr].cd_irq >= 0) {
94 struct pcmcia_irqs cd_irq; 76 struct pcmcia_irqs cd_irq;
95 77
96 cd_irq.sock = skt->nr; 78 cd_irq.sock = skt->nr;
97 cd_irq.irq = scoop_devs[skt->nr].cd_irq; 79 cd_irq.irq = SCOOP_DEV[skt->nr].cd_irq;
98 cd_irq.str = scoop_devs[skt->nr].cd_irq_str; 80 cd_irq.str = SCOOP_DEV[skt->nr].cd_irq_str;
99 soc_pcmcia_free_irqs(skt, &cd_irq, 1); 81 soc_pcmcia_free_irqs(skt, &cd_irq, 1);
100 } 82 }
101} 83}
@@ -105,9 +87,9 @@ static void sharpsl_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
105 struct pcmcia_state *state) 87 struct pcmcia_state *state)
106{ 88{
107 unsigned short cpr, csr; 89 unsigned short cpr, csr;
108 struct device *scoop = scoop_devs[skt->nr].dev; 90 struct device *scoop = SCOOP_DEV[skt->nr].dev;
109 91
110 cpr = read_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_CPR); 92 cpr = read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR);
111 93
112 write_scoop_reg(scoop, SCOOP_IRM, 0x00FF); 94 write_scoop_reg(scoop, SCOOP_IRM, 0x00FF);
113 write_scoop_reg(scoop, SCOOP_ISR, 0x0000); 95 write_scoop_reg(scoop, SCOOP_ISR, 0x0000);
@@ -116,21 +98,25 @@ static void sharpsl_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
116 if (csr & 0x0004) { 98 if (csr & 0x0004) {
117 /* card eject */ 99 /* card eject */
118 write_scoop_reg(scoop, SCOOP_CDR, 0x0000); 100 write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
119 scoop_devs[skt->nr].keep_vs = NO_KEEP_VS; 101 SCOOP_DEV[skt->nr].keep_vs = NO_KEEP_VS;
120 } 102 }
121 else if (!(scoop_devs[skt->nr].keep_vs & NO_KEEP_VS)) { 103 else if (!(SCOOP_DEV[skt->nr].keep_vs & NO_KEEP_VS)) {
122 /* keep vs1,vs2 */ 104 /* keep vs1,vs2 */
123 write_scoop_reg(scoop, SCOOP_CDR, 0x0000); 105 write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
124 csr |= scoop_devs[skt->nr].keep_vs; 106 csr |= SCOOP_DEV[skt->nr].keep_vs;
125 } 107 }
126 else if (cpr & 0x0003) { 108 else if (cpr & 0x0003) {
127 /* power on */ 109 /* power on */
128 write_scoop_reg(scoop, SCOOP_CDR, 0x0000); 110 write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
129 scoop_devs[skt->nr].keep_vs = (csr & 0x00C0); 111 SCOOP_DEV[skt->nr].keep_vs = (csr & 0x00C0);
130 } 112 }
131 else { 113 else {
132 /* card detect */ 114 /* card detect */
133 write_scoop_reg(scoop, SCOOP_CDR, 0x0002); 115 if ((machine_is_spitz() || machine_is_borzoi()) && skt->nr == 1) {
116 write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
117 } else {
118 write_scoop_reg(scoop, SCOOP_CDR, 0x0002);
119 }
134 } 120 }
135 121
136 state->detect = (csr & 0x0004) ? 0 : 1; 122 state->detect = (csr & 0x0004) ? 0 : 1;
@@ -144,7 +130,6 @@ static void sharpsl_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
144 if ((cpr & 0x0080) && ((cpr & 0x8040) != 0x8040)) { 130 if ((cpr & 0x0080) && ((cpr & 0x8040) != 0x8040)) {
145 printk(KERN_ERR "sharpsl_pcmcia_socket_state(): CPR=%04X, Low voltage!\n", cpr); 131 printk(KERN_ERR "sharpsl_pcmcia_socket_state(): CPR=%04X, Low voltage!\n", cpr);
146 } 132 }
147
148} 133}
149 134
150 135
@@ -152,7 +137,7 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
152 const socket_state_t *state) 137 const socket_state_t *state)
153{ 138{
154 unsigned long flags; 139 unsigned long flags;
155 struct device *scoop = scoop_devs[skt->nr].dev; 140 struct device *scoop = SCOOP_DEV[skt->nr].dev;
156 141
157 unsigned short cpr, ncpr, ccr, nccr, mcr, nmcr, imr, nimr; 142 unsigned short cpr, ncpr, ccr, nccr, mcr, nmcr, imr, nimr;
158 143
@@ -177,8 +162,13 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
177 nccr = (ccr = read_scoop_reg(scoop, SCOOP_CCR)) & ~0x0080; 162 nccr = (ccr = read_scoop_reg(scoop, SCOOP_CCR)) & ~0x0080;
178 nimr = (imr = read_scoop_reg(scoop, SCOOP_IMR)) & ~0x003E; 163 nimr = (imr = read_scoop_reg(scoop, SCOOP_IMR)) & ~0x003E;
179 164
180 ncpr |= (state->Vcc == 33) ? 0x0001 : 165 if ((machine_is_spitz() || machine_is_borzoi() || machine_is_akita()) && skt->nr == 0) {
181 (state->Vcc == 50) ? 0x0002 : 0; 166 ncpr |= (state->Vcc == 33) ? 0x0002 :
167 (state->Vcc == 50) ? 0x0002 : 0;
168 } else {
169 ncpr |= (state->Vcc == 33) ? 0x0001 :
170 (state->Vcc == 50) ? 0x0002 : 0;
171 }
182 nmcr |= (state->flags&SS_IOCARD) ? 0x0010 : 0; 172 nmcr |= (state->flags&SS_IOCARD) ? 0x0010 : 0;
183 ncpr |= (state->flags&SS_OUTPUT_ENA) ? 0x0080 : 0; 173 ncpr |= (state->flags&SS_OUTPUT_ENA) ? 0x0080 : 0;
184 nccr |= (state->flags&SS_RESET)? 0x0080: 0; 174 nccr |= (state->flags&SS_RESET)? 0x0080: 0;
@@ -190,18 +180,22 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
190 ((skt->status&SS_WRPROT) ? 0x0008 : 0); 180 ((skt->status&SS_WRPROT) ? 0x0008 : 0);
191 181
192 if (!(ncpr & 0x0003)) { 182 if (!(ncpr & 0x0003)) {
193 scoop_devs[skt->nr].keep_rd = 0; 183 SCOOP_DEV[skt->nr].keep_rd = 0;
194 } else if (!scoop_devs[skt->nr].keep_rd) { 184 } else if (!SCOOP_DEV[skt->nr].keep_rd) {
195 if (nccr & 0x0080) 185 if (nccr & 0x0080)
196 scoop_devs[skt->nr].keep_rd = 1; 186 SCOOP_DEV[skt->nr].keep_rd = 1;
197 else 187 else
198 nccr |= 0x0080; 188 nccr |= 0x0080;
199 } 189 }
200 190
201 if (mcr != nmcr) 191 if (mcr != nmcr)
202 write_scoop_reg(scoop, SCOOP_MCR, nmcr); 192 write_scoop_reg(scoop, SCOOP_MCR, nmcr);
203 if (cpr != ncpr) 193 if (cpr != ncpr) {
204 write_scoop_reg(scoop, SCOOP_CPR, ncpr); 194 if (platform_scoop_config->power_ctrl)
195 platform_scoop_config->power_ctrl(scoop, ncpr , skt->nr);
196 else
197 write_scoop_reg(scoop, SCOOP_CPR, ncpr);
198 }
205 if (ccr != nccr) 199 if (ccr != nccr)
206 write_scoop_reg(scoop, SCOOP_CCR, nccr); 200 write_scoop_reg(scoop, SCOOP_CCR, nccr);
207 if (imr != nimr) 201 if (imr != nimr)
@@ -214,43 +208,43 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
214 208
215static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt) 209static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
216{ 210{
217 sharpsl_pcmcia_init_reset(&scoop_devs[skt->nr]); 211 sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]);
218 212
219 /* Enable interrupt */ 213 /* Enable interrupt */
220 write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_IMR, 0x00C0); 214 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_IMR, 0x00C0);
221 write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_MCR, 0x0101); 215 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_MCR, 0x0101);
222 scoop_devs[skt->nr].keep_vs = NO_KEEP_VS; 216 SCOOP_DEV[skt->nr].keep_vs = NO_KEEP_VS;
223 217
224 if (machine_is_collie()) 218 if (machine_is_collie())
225 /* We need to disable SS_OUTPUT_ENA here. */ 219 /* We need to disable SS_OUTPUT_ENA here. */
226 write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_CPR, read_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_CPR) & ~0x0080); 220 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080);
227} 221}
228 222
229static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) 223static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
230{ 224{
231 /* CF_BUS_OFF */ 225 /* CF_BUS_OFF */
232 sharpsl_pcmcia_init_reset(&scoop_devs[skt->nr]); 226 sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]);
233 227
234 if (machine_is_collie()) 228 if (machine_is_collie())
235 /* We need to disable SS_OUTPUT_ENA here. */ 229 /* We need to disable SS_OUTPUT_ENA here. */
236 write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_CPR, read_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_CPR) & ~0x0080); 230 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080);
237} 231}
238 232
239static struct pcmcia_low_level sharpsl_pcmcia_ops = { 233static struct pcmcia_low_level sharpsl_pcmcia_ops = {
240 .owner = THIS_MODULE, 234 .owner = THIS_MODULE,
241 .hw_init = sharpsl_pcmcia_hw_init, 235 .hw_init = sharpsl_pcmcia_hw_init,
242 .hw_shutdown = sharpsl_pcmcia_hw_shutdown, 236 .hw_shutdown = sharpsl_pcmcia_hw_shutdown,
243 .socket_state = sharpsl_pcmcia_socket_state, 237 .socket_state = sharpsl_pcmcia_socket_state,
244 .configure_socket = sharpsl_pcmcia_configure_socket, 238 .configure_socket = sharpsl_pcmcia_configure_socket,
245 .socket_init = sharpsl_pcmcia_socket_init, 239 .socket_init = sharpsl_pcmcia_socket_init,
246 .socket_suspend = sharpsl_pcmcia_socket_suspend, 240 .socket_suspend = sharpsl_pcmcia_socket_suspend,
247 .first = 0, 241 .first = 0,
248 .nr = 0, 242 .nr = 0,
249}; 243};
250 244
251static struct platform_device *sharpsl_pcmcia_device;
252
253#ifdef CONFIG_SA1100_COLLIE 245#ifdef CONFIG_SA1100_COLLIE
246#include "sa11xx_base.h"
247
254int __init pcmcia_collie_init(struct device *dev) 248int __init pcmcia_collie_init(struct device *dev)
255{ 249{
256 int ret = -ENODEV; 250 int ret = -ENODEV;
@@ -263,11 +257,13 @@ int __init pcmcia_collie_init(struct device *dev)
263 257
264#else 258#else
265 259
260static struct platform_device *sharpsl_pcmcia_device;
261
266static int __init sharpsl_pcmcia_init(void) 262static int __init sharpsl_pcmcia_init(void)
267{ 263{
268 int ret; 264 int ret;
269 265
270 sharpsl_pcmcia_ops.nr=scoop_num; 266 sharpsl_pcmcia_ops.nr=platform_scoop_config->num_devs;
271 sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL); 267 sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL);
272 if (!sharpsl_pcmcia_device) 268 if (!sharpsl_pcmcia_device)
273 return -ENOMEM; 269 return -ENOMEM;
@@ -275,7 +271,7 @@ static int __init sharpsl_pcmcia_init(void)
275 memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device)); 271 memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device));
276 sharpsl_pcmcia_device->name = "pxa2xx-pcmcia"; 272 sharpsl_pcmcia_device->name = "pxa2xx-pcmcia";
277 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; 273 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
278 sharpsl_pcmcia_device->dev.parent=scoop_devs[0].dev; 274 sharpsl_pcmcia_device->dev.parent=platform_scoop_config->devs[0].dev;
279 275
280 ret = platform_device_register(sharpsl_pcmcia_device); 276 ret = platform_device_register(sharpsl_pcmcia_device);
281 if (ret) 277 if (ret)
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index 5028ac214326..383a95f34a0d 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -596,6 +596,8 @@ static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
596 lock_kernel(); 596 lock_kernel();
597 break; 597 break;
598 } 598 }
599
600 return rval;
599} 601}
600 602
601static int openprom_open(struct inode * inode, struct file * file) 603static int openprom_open(struct inode * inode, struct file * file)
@@ -623,6 +625,7 @@ static struct file_operations openprom_fops = {
623 .owner = THIS_MODULE, 625 .owner = THIS_MODULE,
624 .llseek = no_llseek, 626 .llseek = no_llseek,
625 .ioctl = openprom_ioctl, 627 .ioctl = openprom_ioctl,
628 .compat_ioctl = openprom_compat_ioctl,
626 .open = openprom_open, 629 .open = openprom_open,
627 .release = openprom_release, 630 .release = openprom_release,
628}; 631};
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index 467a1d7ebbde..a3c2c45e29e0 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -518,7 +518,7 @@ static struct amba_driver clcd_driver = {
518 .id_table = clcdfb_id_table, 518 .id_table = clcdfb_id_table,
519}; 519};
520 520
521int __init amba_clcdfb_init(void) 521static int __init amba_clcdfb_init(void)
522{ 522{
523 if (fb_get_options("ambafb", NULL)) 523 if (fb_get_options("ambafb", NULL))
524 return -ENODEV; 524 return -ENODEV;
diff --git a/fs/exec.c b/fs/exec.c
index cd6c574557dc..5a4e3acc2e9f 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -590,6 +590,7 @@ static inline int de_thread(struct task_struct *tsk)
590 struct signal_struct *sig = tsk->signal; 590 struct signal_struct *sig = tsk->signal;
591 struct sighand_struct *newsighand, *oldsighand = tsk->sighand; 591 struct sighand_struct *newsighand, *oldsighand = tsk->sighand;
592 spinlock_t *lock = &oldsighand->siglock; 592 spinlock_t *lock = &oldsighand->siglock;
593 struct task_struct *leader = NULL;
593 int count; 594 int count;
594 595
595 /* 596 /*
@@ -665,7 +666,7 @@ static inline int de_thread(struct task_struct *tsk)
665 * and to assume its PID: 666 * and to assume its PID:
666 */ 667 */
667 if (!thread_group_leader(current)) { 668 if (!thread_group_leader(current)) {
668 struct task_struct *leader = current->group_leader, *parent; 669 struct task_struct *parent;
669 struct dentry *proc_dentry1, *proc_dentry2; 670 struct dentry *proc_dentry1, *proc_dentry2;
670 unsigned long exit_state, ptrace; 671 unsigned long exit_state, ptrace;
671 672
@@ -674,6 +675,7 @@ static inline int de_thread(struct task_struct *tsk)
674 * It should already be zombie at this point, most 675 * It should already be zombie at this point, most
675 * of the time. 676 * of the time.
676 */ 677 */
678 leader = current->group_leader;
677 while (leader->exit_state != EXIT_ZOMBIE) 679 while (leader->exit_state != EXIT_ZOMBIE)
678 yield(); 680 yield();
679 681
@@ -733,7 +735,6 @@ static inline int de_thread(struct task_struct *tsk)
733 proc_pid_flush(proc_dentry2); 735 proc_pid_flush(proc_dentry2);
734 736
735 BUG_ON(exit_state != EXIT_ZOMBIE); 737 BUG_ON(exit_state != EXIT_ZOMBIE);
736 release_task(leader);
737 } 738 }
738 739
739 /* 740 /*
@@ -743,8 +744,11 @@ static inline int de_thread(struct task_struct *tsk)
743 sig->flags = 0; 744 sig->flags = 0;
744 745
745no_thread_group: 746no_thread_group:
746 BUG_ON(atomic_read(&sig->count) != 1);
747 exit_itimers(sig); 747 exit_itimers(sig);
748 if (leader)
749 release_task(leader);
750
751 BUG_ON(atomic_read(&sig->count) != 1);
748 752
749 if (atomic_read(&oldsighand->count) == 1) { 753 if (atomic_read(&oldsighand->count) == 1) {
750 /* 754 /*
diff --git a/include/asm-arm/arch-s3c2410/uncompress.h b/include/asm-arm/arch-s3c2410/uncompress.h
index d7a4a8354fa9..ddd1578a7ee0 100644
--- a/include/asm-arm/arch-s3c2410/uncompress.h
+++ b/include/asm-arm/arch-s3c2410/uncompress.h
@@ -116,6 +116,8 @@ putstr(const char *ptr)
116 } 116 }
117} 117}
118 118
119#define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
120
119/* CONFIG_S3C2410_BOOT_WATCHDOG 121/* CONFIG_S3C2410_BOOT_WATCHDOG
120 * 122 *
121 * Simple boot-time watchdog setup, to reboot the system if there is 123 * Simple boot-time watchdog setup, to reboot the system if there is
@@ -126,8 +128,6 @@ putstr(const char *ptr)
126 128
127#define WDOG_COUNT (0xff00) 129#define WDOG_COUNT (0xff00)
128 130
129#define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
130
131static inline void arch_decomp_wdog(void) 131static inline void arch_decomp_wdog(void)
132{ 132{
133 __raw_writel(WDOG_COUNT, S3C2410_WTCNT); 133 __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
@@ -145,6 +145,24 @@ static void arch_decomp_wdog_start(void)
145#define arch_decomp_wdog() 145#define arch_decomp_wdog()
146#endif 146#endif
147 147
148#ifdef CONFIG_S3C2410_BOOT_ERROR_RESET
149
150static void arch_decomp_error(const char *x)
151{
152 putstr("\n\n");
153 putstr(x);
154 putstr("\n\n -- System resetting\n");
155
156 __raw_writel(0x4000, S3C2410_WTDAT);
157 __raw_writel(0x4000, S3C2410_WTCNT);
158 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
159
160 while(1);
161}
162
163#define arch_error arch_decomp_error
164#endif
165
148static void error(char *err); 166static void error(char *err);
149 167
150static void 168static void
diff --git a/include/asm-arm/hardirq.h b/include/asm-arm/hardirq.h
index e5ccb6b8ff83..1cbb173bf5b1 100644
--- a/include/asm-arm/hardirq.h
+++ b/include/asm-arm/hardirq.h
@@ -8,6 +8,7 @@
8 8
9typedef struct { 9typedef struct {
10 unsigned int __softirq_pending; 10 unsigned int __softirq_pending;
11 unsigned int local_timer_irqs;
11} ____cacheline_aligned irq_cpustat_t; 12} ____cacheline_aligned irq_cpustat_t;
12 13
13#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ 14#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
diff --git a/include/asm-arm/hardware/scoop.h b/include/asm-arm/hardware/scoop.h
index a8f1013930e3..d37bf7443264 100644
--- a/include/asm-arm/hardware/scoop.h
+++ b/include/asm-arm/hardware/scoop.h
@@ -52,8 +52,14 @@ struct scoop_pcmcia_dev {
52 unsigned char keep_rd; 52 unsigned char keep_rd;
53}; 53};
54 54
55extern int scoop_num; 55struct scoop_pcmcia_config {
56extern struct scoop_pcmcia_dev *scoop_devs; 56 struct scoop_pcmcia_dev *devs;
57 int num_devs;
58 void (*pcmcia_init)(void);
59 void (*power_ctrl)(struct device *scoop, unsigned short cpr, int nr);
60};
61
62extern struct scoop_pcmcia_config *platform_scoop_config;
57 63
58void reset_scoop(struct device *dev); 64void reset_scoop(struct device *dev);
59unsigned short set_scoop_gpio(struct device *dev, unsigned short bit); 65unsigned short set_scoop_gpio(struct device *dev, unsigned short bit);
diff --git a/include/asm-arm/smp.h b/include/asm-arm/smp.h
index 551cd3c3093c..5a72e50ca9fc 100644
--- a/include/asm-arm/smp.h
+++ b/include/asm-arm/smp.h
@@ -37,6 +37,11 @@ struct seq_file;
37extern void show_ipi_list(struct seq_file *p); 37extern void show_ipi_list(struct seq_file *p);
38 38
39/* 39/*
40 * Called from assembly code, this handles an IPI.
41 */
42asmlinkage void do_IPI(struct pt_regs *regs);
43
44/*
40 * Move global data into per-processor storage. 45 * Move global data into per-processor storage.
41 */ 46 */
42extern void smp_store_cpu_info(unsigned int cpuid); 47extern void smp_store_cpu_info(unsigned int cpuid);
@@ -47,12 +52,23 @@ extern void smp_store_cpu_info(unsigned int cpuid);
47extern void smp_cross_call(cpumask_t callmap); 52extern void smp_cross_call(cpumask_t callmap);
48 53
49/* 54/*
55 * Broadcast a timer interrupt to the other CPUs.
56 */
57extern void smp_send_timer(void);
58
59/*
50 * Boot a secondary CPU, and assign it the specified idle task. 60 * Boot a secondary CPU, and assign it the specified idle task.
51 * This also gives us the initial stack to use for this CPU. 61 * This also gives us the initial stack to use for this CPU.
52 */ 62 */
53extern int boot_secondary(unsigned int cpu, struct task_struct *); 63extern int boot_secondary(unsigned int cpu, struct task_struct *);
54 64
55/* 65/*
66 * Called from platform specific assembly code, this is the
67 * secondary CPU entry point.
68 */
69asmlinkage void secondary_start_kernel(void);
70
71/*
56 * Perform platform specific initialisation of the specified CPU. 72 * Perform platform specific initialisation of the specified CPU.
57 */ 73 */
58extern void platform_secondary_init(unsigned int cpu); 74extern void platform_secondary_init(unsigned int cpu);
@@ -76,4 +92,42 @@ extern void platform_cpu_die(unsigned int cpu);
76extern int platform_cpu_kill(unsigned int cpu); 92extern int platform_cpu_kill(unsigned int cpu);
77extern void platform_cpu_enable(unsigned int cpu); 93extern void platform_cpu_enable(unsigned int cpu);
78 94
95#ifdef CONFIG_LOCAL_TIMERS
96/*
97 * Setup a local timer interrupt for a CPU.
98 */
99extern void local_timer_setup(unsigned int cpu);
100
101/*
102 * Stop a local timer interrupt.
103 */
104extern void local_timer_stop(unsigned int cpu);
105
106/*
107 * Platform provides this to acknowledge a local timer IRQ
108 */
109extern int local_timer_ack(void);
110
111#else
112
113static inline void local_timer_setup(unsigned int cpu)
114{
115}
116
117static inline void local_timer_stop(unsigned int cpu)
118{
119}
120
121#endif
122
123/*
124 * show local interrupt info
125 */
126extern void show_local_irqs(struct seq_file *);
127
128/*
129 * Called from assembly, this is the local timer IRQ handler
130 */
131asmlinkage void do_local_timer(struct pt_regs *);
132
79#endif /* ifndef __ASM_ARM_SMP_H */ 133#endif /* ifndef __ASM_ARM_SMP_H */
diff --git a/include/linux/if_ppp.h b/include/linux/if_ppp.h
index 572aff7daa21..768372f07caa 100644
--- a/include/linux/if_ppp.h
+++ b/include/linux/if_ppp.h
@@ -21,7 +21,7 @@
21 */ 21 */
22 22
23/* 23/*
24 * ==FILEVERSION 20000724== 24 * ==FILEVERSION 20050812==
25 * 25 *
26 * NOTE TO MAINTAINERS: 26 * NOTE TO MAINTAINERS:
27 * If you modify this file at all, please set the above date. 27 * If you modify this file at all, please set the above date.
@@ -35,6 +35,8 @@
35#ifndef _IF_PPP_H_ 35#ifndef _IF_PPP_H_
36#define _IF_PPP_H_ 36#define _IF_PPP_H_
37 37
38#include <linux/compiler.h>
39
38/* 40/*
39 * Packet sizes 41 * Packet sizes
40 */ 42 */
@@ -70,7 +72,8 @@
70#define SC_LOG_RAWIN 0x00080000 /* log all chars received */ 72#define SC_LOG_RAWIN 0x00080000 /* log all chars received */
71#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ 73#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */
72#define SC_SYNC 0x00200000 /* synchronous serial mode */ 74#define SC_SYNC 0x00200000 /* synchronous serial mode */
73#define SC_MASK 0x0f200fff /* bits that user can change */ 75#define SC_MUST_COMP 0x00400000 /* no uncompressed packets may be sent or received */
76#define SC_MASK 0x0f600fff /* bits that user can change */
74 77
75/* state bits */ 78/* state bits */
76#define SC_XMIT_BUSY 0x10000000 /* (used by isdn_ppp?) */ 79#define SC_XMIT_BUSY 0x10000000 /* (used by isdn_ppp?) */
diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
index 7227e653b3be..e86a7a5cf355 100644
--- a/include/linux/ppp-comp.h
+++ b/include/linux/ppp-comp.h
@@ -111,6 +111,8 @@ struct compressor {
111 111
112 /* Used in locking compressor modules */ 112 /* Used in locking compressor modules */
113 struct module *owner; 113 struct module *owner;
114 /* Extra skb space needed by the compressor algorithm */
115 unsigned int comp_extra;
114}; 116};
115 117
116/* 118/*
@@ -191,6 +193,13 @@ struct compressor {
191#define DEFLATE_CHK_SEQUENCE 0 193#define DEFLATE_CHK_SEQUENCE 0
192 194
193/* 195/*
196 * Definitions for MPPE.
197 */
198
199#define CI_MPPE 18 /* config option for MPPE */
200#define CILEN_MPPE 6 /* length of config option */
201
202/*
194 * Definitions for other, as yet unsupported, compression methods. 203 * Definitions for other, as yet unsupported, compression methods.
195 */ 204 */
196 205
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index e42d728b1620..911ceb5cd263 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -57,8 +57,6 @@
57#define BT_DBG(fmt, arg...) printk(KERN_INFO "%s: " fmt "\n" , __FUNCTION__ , ## arg) 57#define BT_DBG(fmt, arg...) printk(KERN_INFO "%s: " fmt "\n" , __FUNCTION__ , ## arg)
58#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __FUNCTION__ , ## arg) 58#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __FUNCTION__ , ## arg)
59 59
60extern struct proc_dir_entry *proc_bt;
61
62/* Connection and socket states */ 60/* Connection and socket states */
63enum { 61enum {
64 BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ 62 BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
@@ -177,4 +175,6 @@ extern int hci_sock_cleanup(void);
177extern int bt_sysfs_init(void); 175extern int bt_sysfs_init(void);
178extern void bt_sysfs_cleanup(void); 176extern void bt_sysfs_cleanup(void);
179 177
178extern struct class bt_class;
179
180#endif /* __BLUETOOTH_H */ 180#endif /* __BLUETOOTH_H */
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index fa2d12b0579b..b06a2d2f63d2 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -184,10 +184,10 @@ enum {
184struct hci_rp_read_loc_version { 184struct hci_rp_read_loc_version {
185 __u8 status; 185 __u8 status;
186 __u8 hci_ver; 186 __u8 hci_ver;
187 __u16 hci_rev; 187 __le16 hci_rev;
188 __u8 lmp_ver; 188 __u8 lmp_ver;
189 __u16 manufacturer; 189 __le16 manufacturer;
190 __u16 lmp_subver; 190 __le16 lmp_subver;
191} __attribute__ ((packed)); 191} __attribute__ ((packed));
192 192
193#define OCF_READ_LOCAL_FEATURES 0x0003 193#define OCF_READ_LOCAL_FEATURES 0x0003
@@ -199,10 +199,10 @@ struct hci_rp_read_loc_features {
199#define OCF_READ_BUFFER_SIZE 0x0005 199#define OCF_READ_BUFFER_SIZE 0x0005
200struct hci_rp_read_buffer_size { 200struct hci_rp_read_buffer_size {
201 __u8 status; 201 __u8 status;
202 __u16 acl_mtu; 202 __le16 acl_mtu;
203 __u8 sco_mtu; 203 __u8 sco_mtu;
204 __u16 acl_max_pkt; 204 __le16 acl_max_pkt;
205 __u16 sco_max_pkt; 205 __le16 sco_max_pkt;
206} __attribute__ ((packed)); 206} __attribute__ ((packed));
207 207
208#define OCF_READ_BD_ADDR 0x0009 208#define OCF_READ_BD_ADDR 0x0009
@@ -267,21 +267,21 @@ struct hci_cp_write_dev_class {
267 267
268#define OCF_READ_VOICE_SETTING 0x0025 268#define OCF_READ_VOICE_SETTING 0x0025
269struct hci_rp_read_voice_setting { 269struct hci_rp_read_voice_setting {
270 __u8 status; 270 __u8 status;
271 __u16 voice_setting; 271 __le16 voice_setting;
272} __attribute__ ((packed)); 272} __attribute__ ((packed));
273 273
274#define OCF_WRITE_VOICE_SETTING 0x0026 274#define OCF_WRITE_VOICE_SETTING 0x0026
275struct hci_cp_write_voice_setting { 275struct hci_cp_write_voice_setting {
276 __u16 voice_setting; 276 __le16 voice_setting;
277} __attribute__ ((packed)); 277} __attribute__ ((packed));
278 278
279#define OCF_HOST_BUFFER_SIZE 0x0033 279#define OCF_HOST_BUFFER_SIZE 0x0033
280struct hci_cp_host_buffer_size { 280struct hci_cp_host_buffer_size {
281 __u16 acl_mtu; 281 __le16 acl_mtu;
282 __u8 sco_mtu; 282 __u8 sco_mtu;
283 __u16 acl_max_pkt; 283 __le16 acl_max_pkt;
284 __u16 sco_max_pkt; 284 __le16 sco_max_pkt;
285} __attribute__ ((packed)); 285} __attribute__ ((packed));
286 286
287/* Link Control */ 287/* Link Control */
@@ -289,10 +289,10 @@ struct hci_cp_host_buffer_size {
289#define OCF_CREATE_CONN 0x0005 289#define OCF_CREATE_CONN 0x0005
290struct hci_cp_create_conn { 290struct hci_cp_create_conn {
291 bdaddr_t bdaddr; 291 bdaddr_t bdaddr;
292 __u16 pkt_type; 292 __le16 pkt_type;
293 __u8 pscan_rep_mode; 293 __u8 pscan_rep_mode;
294 __u8 pscan_mode; 294 __u8 pscan_mode;
295 __u16 clock_offset; 295 __le16 clock_offset;
296 __u8 role_switch; 296 __u8 role_switch;
297} __attribute__ ((packed)); 297} __attribute__ ((packed));
298 298
@@ -310,14 +310,14 @@ struct hci_cp_reject_conn_req {
310 310
311#define OCF_DISCONNECT 0x0006 311#define OCF_DISCONNECT 0x0006
312struct hci_cp_disconnect { 312struct hci_cp_disconnect {
313 __u16 handle; 313 __le16 handle;
314 __u8 reason; 314 __u8 reason;
315} __attribute__ ((packed)); 315} __attribute__ ((packed));
316 316
317#define OCF_ADD_SCO 0x0007 317#define OCF_ADD_SCO 0x0007
318struct hci_cp_add_sco { 318struct hci_cp_add_sco {
319 __u16 handle; 319 __le16 handle;
320 __u16 pkt_type; 320 __le16 pkt_type;
321} __attribute__ ((packed)); 321} __attribute__ ((packed));
322 322
323#define OCF_INQUIRY 0x0001 323#define OCF_INQUIRY 0x0001
@@ -354,56 +354,56 @@ struct hci_cp_pin_code_neg_reply {
354 354
355#define OCF_CHANGE_CONN_PTYPE 0x000F 355#define OCF_CHANGE_CONN_PTYPE 0x000F
356struct hci_cp_change_conn_ptype { 356struct hci_cp_change_conn_ptype {
357 __u16 handle; 357 __le16 handle;
358 __u16 pkt_type; 358 __le16 pkt_type;
359} __attribute__ ((packed)); 359} __attribute__ ((packed));
360 360
361#define OCF_AUTH_REQUESTED 0x0011 361#define OCF_AUTH_REQUESTED 0x0011
362struct hci_cp_auth_requested { 362struct hci_cp_auth_requested {
363 __u16 handle; 363 __le16 handle;
364} __attribute__ ((packed)); 364} __attribute__ ((packed));
365 365
366#define OCF_SET_CONN_ENCRYPT 0x0013 366#define OCF_SET_CONN_ENCRYPT 0x0013
367struct hci_cp_set_conn_encrypt { 367struct hci_cp_set_conn_encrypt {
368 __u16 handle; 368 __le16 handle;
369 __u8 encrypt; 369 __u8 encrypt;
370} __attribute__ ((packed)); 370} __attribute__ ((packed));
371 371
372#define OCF_CHANGE_CONN_LINK_KEY 0x0015 372#define OCF_CHANGE_CONN_LINK_KEY 0x0015
373struct hci_cp_change_conn_link_key { 373struct hci_cp_change_conn_link_key {
374 __u16 handle; 374 __le16 handle;
375} __attribute__ ((packed)); 375} __attribute__ ((packed));
376 376
377#define OCF_READ_REMOTE_FEATURES 0x001B 377#define OCF_READ_REMOTE_FEATURES 0x001B
378struct hci_cp_read_rmt_features { 378struct hci_cp_read_rmt_features {
379 __u16 handle; 379 __le16 handle;
380} __attribute__ ((packed)); 380} __attribute__ ((packed));
381 381
382#define OCF_READ_REMOTE_VERSION 0x001D 382#define OCF_READ_REMOTE_VERSION 0x001D
383struct hci_cp_read_rmt_version { 383struct hci_cp_read_rmt_version {
384 __u16 handle; 384 __le16 handle;
385} __attribute__ ((packed)); 385} __attribute__ ((packed));
386 386
387/* Link Policy */ 387/* Link Policy */
388#define OGF_LINK_POLICY 0x02 388#define OGF_LINK_POLICY 0x02
389#define OCF_ROLE_DISCOVERY 0x0009 389#define OCF_ROLE_DISCOVERY 0x0009
390struct hci_cp_role_discovery { 390struct hci_cp_role_discovery {
391 __u16 handle; 391 __le16 handle;
392} __attribute__ ((packed)); 392} __attribute__ ((packed));
393struct hci_rp_role_discovery { 393struct hci_rp_role_discovery {
394 __u8 status; 394 __u8 status;
395 __u16 handle; 395 __le16 handle;
396 __u8 role; 396 __u8 role;
397} __attribute__ ((packed)); 397} __attribute__ ((packed));
398 398
399#define OCF_READ_LINK_POLICY 0x000C 399#define OCF_READ_LINK_POLICY 0x000C
400struct hci_cp_read_link_policy { 400struct hci_cp_read_link_policy {
401 __u16 handle; 401 __le16 handle;
402} __attribute__ ((packed)); 402} __attribute__ ((packed));
403struct hci_rp_read_link_policy { 403struct hci_rp_read_link_policy {
404 __u8 status; 404 __u8 status;
405 __u16 handle; 405 __le16 handle;
406 __u16 policy; 406 __le16 policy;
407} __attribute__ ((packed)); 407} __attribute__ ((packed));
408 408
409#define OCF_SWITCH_ROLE 0x000B 409#define OCF_SWITCH_ROLE 0x000B
@@ -414,12 +414,12 @@ struct hci_cp_switch_role {
414 414
415#define OCF_WRITE_LINK_POLICY 0x000D 415#define OCF_WRITE_LINK_POLICY 0x000D
416struct hci_cp_write_link_policy { 416struct hci_cp_write_link_policy {
417 __u16 handle; 417 __le16 handle;
418 __u16 policy; 418 __le16 policy;
419} __attribute__ ((packed)); 419} __attribute__ ((packed));
420struct hci_rp_write_link_policy { 420struct hci_rp_write_link_policy {
421 __u8 status; 421 __u8 status;
422 __u16 handle; 422 __le16 handle;
423} __attribute__ ((packed)); 423} __attribute__ ((packed));
424 424
425/* Status params */ 425/* Status params */
@@ -441,7 +441,7 @@ struct inquiry_info {
441 __u8 pscan_period_mode; 441 __u8 pscan_period_mode;
442 __u8 pscan_mode; 442 __u8 pscan_mode;
443 __u8 dev_class[3]; 443 __u8 dev_class[3];
444 __u16 clock_offset; 444 __le16 clock_offset;
445} __attribute__ ((packed)); 445} __attribute__ ((packed));
446 446
447#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22 447#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
@@ -450,7 +450,7 @@ struct inquiry_info_with_rssi {
450 __u8 pscan_rep_mode; 450 __u8 pscan_rep_mode;
451 __u8 pscan_period_mode; 451 __u8 pscan_period_mode;
452 __u8 dev_class[3]; 452 __u8 dev_class[3];
453 __u16 clock_offset; 453 __le16 clock_offset;
454 __s8 rssi; 454 __s8 rssi;
455} __attribute__ ((packed)); 455} __attribute__ ((packed));
456struct inquiry_info_with_rssi_and_pscan_mode { 456struct inquiry_info_with_rssi_and_pscan_mode {
@@ -459,7 +459,7 @@ struct inquiry_info_with_rssi_and_pscan_mode {
459 __u8 pscan_period_mode; 459 __u8 pscan_period_mode;
460 __u8 pscan_mode; 460 __u8 pscan_mode;
461 __u8 dev_class[3]; 461 __u8 dev_class[3];
462 __u16 clock_offset; 462 __le16 clock_offset;
463 __s8 rssi; 463 __s8 rssi;
464} __attribute__ ((packed)); 464} __attribute__ ((packed));
465 465
@@ -469,7 +469,7 @@ struct extended_inquiry_info {
469 __u8 pscan_rep_mode; 469 __u8 pscan_rep_mode;
470 __u8 pscan_period_mode; 470 __u8 pscan_period_mode;
471 __u8 dev_class[3]; 471 __u8 dev_class[3];
472 __u16 clock_offset; 472 __le16 clock_offset;
473 __s8 rssi; 473 __s8 rssi;
474 __u8 data[240]; 474 __u8 data[240];
475} __attribute__ ((packed)); 475} __attribute__ ((packed));
@@ -477,7 +477,7 @@ struct extended_inquiry_info {
477#define HCI_EV_CONN_COMPLETE 0x03 477#define HCI_EV_CONN_COMPLETE 0x03
478struct hci_ev_conn_complete { 478struct hci_ev_conn_complete {
479 __u8 status; 479 __u8 status;
480 __u16 handle; 480 __le16 handle;
481 bdaddr_t bdaddr; 481 bdaddr_t bdaddr;
482 __u8 link_type; 482 __u8 link_type;
483 __u8 encr_mode; 483 __u8 encr_mode;
@@ -493,27 +493,27 @@ struct hci_ev_conn_request {
493#define HCI_EV_DISCONN_COMPLETE 0x05 493#define HCI_EV_DISCONN_COMPLETE 0x05
494struct hci_ev_disconn_complete { 494struct hci_ev_disconn_complete {
495 __u8 status; 495 __u8 status;
496 __u16 handle; 496 __le16 handle;
497 __u8 reason; 497 __u8 reason;
498} __attribute__ ((packed)); 498} __attribute__ ((packed));
499 499
500#define HCI_EV_AUTH_COMPLETE 0x06 500#define HCI_EV_AUTH_COMPLETE 0x06
501struct hci_ev_auth_complete { 501struct hci_ev_auth_complete {
502 __u8 status; 502 __u8 status;
503 __u16 handle; 503 __le16 handle;
504} __attribute__ ((packed)); 504} __attribute__ ((packed));
505 505
506#define HCI_EV_ENCRYPT_CHANGE 0x08 506#define HCI_EV_ENCRYPT_CHANGE 0x08
507struct hci_ev_encrypt_change { 507struct hci_ev_encrypt_change {
508 __u8 status; 508 __u8 status;
509 __u16 handle; 509 __le16 handle;
510 __u8 encrypt; 510 __u8 encrypt;
511} __attribute__ ((packed)); 511} __attribute__ ((packed));
512 512
513#define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09 513#define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09
514struct hci_ev_change_conn_link_key_complete { 514struct hci_ev_change_conn_link_key_complete {
515 __u8 status; 515 __u8 status;
516 __u16 handle; 516 __le16 handle;
517} __attribute__ ((packed)); 517} __attribute__ ((packed));
518 518
519#define HCI_EV_QOS_SETUP_COMPLETE 0x0D 519#define HCI_EV_QOS_SETUP_COMPLETE 0x0D
@@ -526,21 +526,21 @@ struct hci_qos {
526} __attribute__ ((packed)); 526} __attribute__ ((packed));
527struct hci_ev_qos_setup_complete { 527struct hci_ev_qos_setup_complete {
528 __u8 status; 528 __u8 status;
529 __u16 handle; 529 __le16 handle;
530 struct hci_qos qos; 530 struct hci_qos qos;
531} __attribute__ ((packed)); 531} __attribute__ ((packed));
532 532
533#define HCI_EV_CMD_COMPLETE 0x0E 533#define HCI_EV_CMD_COMPLETE 0x0E
534struct hci_ev_cmd_complete { 534struct hci_ev_cmd_complete {
535 __u8 ncmd; 535 __u8 ncmd;
536 __u16 opcode; 536 __le16 opcode;
537} __attribute__ ((packed)); 537} __attribute__ ((packed));
538 538
539#define HCI_EV_CMD_STATUS 0x0F 539#define HCI_EV_CMD_STATUS 0x0F
540struct hci_ev_cmd_status { 540struct hci_ev_cmd_status {
541 __u8 status; 541 __u8 status;
542 __u8 ncmd; 542 __u8 ncmd;
543 __u16 opcode; 543 __le16 opcode;
544} __attribute__ ((packed)); 544} __attribute__ ((packed));
545 545
546#define HCI_EV_NUM_COMP_PKTS 0x13 546#define HCI_EV_NUM_COMP_PKTS 0x13
@@ -559,9 +559,9 @@ struct hci_ev_role_change {
559#define HCI_EV_MODE_CHANGE 0x14 559#define HCI_EV_MODE_CHANGE 0x14
560struct hci_ev_mode_change { 560struct hci_ev_mode_change {
561 __u8 status; 561 __u8 status;
562 __u16 handle; 562 __le16 handle;
563 __u8 mode; 563 __u8 mode;
564 __u16 interval; 564 __le16 interval;
565} __attribute__ ((packed)); 565} __attribute__ ((packed));
566 566
567#define HCI_EV_PIN_CODE_REQ 0x16 567#define HCI_EV_PIN_CODE_REQ 0x16
@@ -584,24 +584,24 @@ struct hci_ev_link_key_notify {
584#define HCI_EV_RMT_FEATURES 0x0B 584#define HCI_EV_RMT_FEATURES 0x0B
585struct hci_ev_rmt_features { 585struct hci_ev_rmt_features {
586 __u8 status; 586 __u8 status;
587 __u16 handle; 587 __le16 handle;
588 __u8 features[8]; 588 __u8 features[8];
589} __attribute__ ((packed)); 589} __attribute__ ((packed));
590 590
591#define HCI_EV_RMT_VERSION 0x0C 591#define HCI_EV_RMT_VERSION 0x0C
592struct hci_ev_rmt_version { 592struct hci_ev_rmt_version {
593 __u8 status; 593 __u8 status;
594 __u16 handle; 594 __le16 handle;
595 __u8 lmp_ver; 595 __u8 lmp_ver;
596 __u16 manufacturer; 596 __le16 manufacturer;
597 __u16 lmp_subver; 597 __le16 lmp_subver;
598} __attribute__ ((packed)); 598} __attribute__ ((packed));
599 599
600#define HCI_EV_CLOCK_OFFSET 0x01C 600#define HCI_EV_CLOCK_OFFSET 0x01C
601struct hci_ev_clock_offset { 601struct hci_ev_clock_offset {
602 __u8 status; 602 __u8 status;
603 __u16 handle; 603 __le16 handle;
604 __u16 clock_offset; 604 __le16 clock_offset;
605} __attribute__ ((packed)); 605} __attribute__ ((packed));
606 606
607#define HCI_EV_PSCAN_REP_MODE 0x20 607#define HCI_EV_PSCAN_REP_MODE 0x20
@@ -638,7 +638,7 @@ struct hci_ev_si_security {
638#define HCI_SCO_HDR_SIZE 3 638#define HCI_SCO_HDR_SIZE 3
639 639
640struct hci_command_hdr { 640struct hci_command_hdr {
641 __u16 opcode; /* OCF & OGF */ 641 __le16 opcode; /* OCF & OGF */
642 __u8 plen; 642 __u8 plen;
643} __attribute__ ((packed)); 643} __attribute__ ((packed));
644 644
@@ -648,22 +648,22 @@ struct hci_event_hdr {
648} __attribute__ ((packed)); 648} __attribute__ ((packed));
649 649
650struct hci_acl_hdr { 650struct hci_acl_hdr {
651 __u16 handle; /* Handle & Flags(PB, BC) */ 651 __le16 handle; /* Handle & Flags(PB, BC) */
652 __u16 dlen; 652 __le16 dlen;
653} __attribute__ ((packed)); 653} __attribute__ ((packed));
654 654
655struct hci_sco_hdr { 655struct hci_sco_hdr {
656 __u16 handle; 656 __le16 handle;
657 __u8 dlen; 657 __u8 dlen;
658} __attribute__ ((packed)); 658} __attribute__ ((packed));
659 659
660/* Command opcode pack/unpack */ 660/* Command opcode pack/unpack */
661#define hci_opcode_pack(ogf, ocf) (__u16)((ocf & 0x03ff)|(ogf << 10)) 661#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
662#define hci_opcode_ogf(op) (op >> 10) 662#define hci_opcode_ogf(op) (op >> 10)
663#define hci_opcode_ocf(op) (op & 0x03ff) 663#define hci_opcode_ocf(op) (op & 0x03ff)
664 664
665/* ACL handle and flags pack/unpack */ 665/* ACL handle and flags pack/unpack */
666#define hci_handle_pack(h, f) (__u16)((h & 0x0fff)|(f << 12)) 666#define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))
667#define hci_handle(h) (h & 0x0fff) 667#define hci_handle(h) (h & 0x0fff)
668#define hci_flags(h) (h >> 12) 668#define hci_flags(h) (h >> 12)
669 669
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 7f933f302078..bb9f81dc8723 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -25,7 +25,6 @@
25#ifndef __HCI_CORE_H 25#ifndef __HCI_CORE_H
26#define __HCI_CORE_H 26#define __HCI_CORE_H
27 27
28#include <linux/proc_fs.h>
29#include <net/bluetooth/hci.h> 28#include <net/bluetooth/hci.h>
30 29
31/* HCI upper protocols */ 30/* HCI upper protocols */
@@ -34,8 +33,6 @@
34 33
35#define HCI_INIT_TIMEOUT (HZ * 10) 34#define HCI_INIT_TIMEOUT (HZ * 10)
36 35
37extern struct proc_dir_entry *proc_bt_hci;
38
39/* HCI Core structures */ 36/* HCI Core structures */
40 37
41struct inquiry_data { 38struct inquiry_data {
@@ -44,7 +41,7 @@ struct inquiry_data {
44 __u8 pscan_period_mode; 41 __u8 pscan_period_mode;
45 __u8 pscan_mode; 42 __u8 pscan_mode;
46 __u8 dev_class[3]; 43 __u8 dev_class[3];
47 __u16 clock_offset; 44 __le16 clock_offset;
48 __s8 rssi; 45 __s8 rssi;
49}; 46};
50 47
@@ -126,10 +123,6 @@ struct hci_dev {
126 123
127 atomic_t promisc; 124 atomic_t promisc;
128 125
129#ifdef CONFIG_PROC_FS
130 struct proc_dir_entry *proc;
131#endif
132
133 struct class_device class_dev; 126 struct class_device class_dev;
134 127
135 struct module *owner; 128 struct module *owner;
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
index e656be7c001a..bbfac86734ec 100644
--- a/include/net/bluetooth/rfcomm.h
+++ b/include/net/bluetooth/rfcomm.h
@@ -351,6 +351,4 @@ int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
351int rfcomm_init_ttys(void); 351int rfcomm_init_ttys(void);
352void rfcomm_cleanup_ttys(void); 352void rfcomm_cleanup_ttys(void);
353 353
354extern struct proc_dir_entry *proc_bt_rfcomm;
355
356#endif /* __RFCOMM_H */ 354#endif /* __RFCOMM_H */
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 65ec86678a08..6addb4d464d6 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -252,12 +252,25 @@ typedef int (*inet_getfrag_t) (const void *data,
252 char *, 252 char *,
253 unsigned int, unsigned int); 253 unsigned int, unsigned int);
254 254
255 255extern int __ipv6_addr_type(const struct in6_addr *addr);
256extern int ipv6_addr_type(const struct in6_addr *addr); 256static inline int ipv6_addr_type(const struct in6_addr *addr)
257{
258 return __ipv6_addr_type(addr) & 0xffff;
259}
257 260
258static inline int ipv6_addr_scope(const struct in6_addr *addr) 261static inline int ipv6_addr_scope(const struct in6_addr *addr)
259{ 262{
260 return ipv6_addr_type(addr) & IPV6_ADDR_SCOPE_MASK; 263 return __ipv6_addr_type(addr) & IPV6_ADDR_SCOPE_MASK;
264}
265
266static inline int __ipv6_addr_src_scope(int type)
267{
268 return (type == IPV6_ADDR_ANY ? __IPV6_ADDR_SCOPE_INVALID : (type >> 16));
269}
270
271static inline int ipv6_addr_src_scope(const struct in6_addr *addr)
272{
273 return __ipv6_addr_src_scope(__ipv6_addr_type(addr));
261} 274}
262 275
263static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2) 276static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2)
@@ -341,6 +354,54 @@ static inline int ipv6_addr_any(const struct in6_addr *a)
341} 354}
342 355
343/* 356/*
357 * find the first different bit between two addresses
358 * length of address must be a multiple of 32bits
359 */
360static inline int __ipv6_addr_diff(const void *token1, const void *token2, int addrlen)
361{
362 const __u32 *a1 = token1, *a2 = token2;
363 int i;
364
365 addrlen >>= 2;
366
367 for (i = 0; i < addrlen; i++) {
368 __u32 xb = a1[i] ^ a2[i];
369 if (xb) {
370 int j = 31;
371
372 xb = ntohl(xb);
373 while ((xb & (1 << j)) == 0)
374 j--;
375
376 return (i * 32 + 31 - j);
377 }
378 }
379
380 /*
381 * we should *never* get to this point since that
382 * would mean the addrs are equal
383 *
384 * However, we do get to it 8) And exacly, when
385 * addresses are equal 8)
386 *
387 * ip route add 1111::/128 via ...
388 * ip route add 1111::/64 via ...
389 * and we are here.
390 *
391 * Ideally, this function should stop comparison
392 * at prefix length. It does not, but it is still OK,
393 * if returned value is greater than prefix length.
394 * --ANK (980803)
395 */
396 return (addrlen << 5);
397}
398
399static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_addr *a2)
400{
401 return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
402}
403
404/*
344 * Prototypes exported by ipv6 405 * Prototypes exported by ipv6
345 */ 406 */
346 407
diff --git a/include/net/sock.h b/include/net/sock.h
index e0498bd36004..ff13c4cc287a 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -461,16 +461,16 @@ static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb)
461} 461}
462 462
463/* The per-socket spinlock must be held here. */ 463/* The per-socket spinlock must be held here. */
464#define sk_add_backlog(__sk, __skb) \ 464static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb)
465do { if (!(__sk)->sk_backlog.tail) { \ 465{
466 (__sk)->sk_backlog.head = \ 466 if (!sk->sk_backlog.tail) {
467 (__sk)->sk_backlog.tail = (__skb); \ 467 sk->sk_backlog.head = sk->sk_backlog.tail = skb;
468 } else { \ 468 } else {
469 ((__sk)->sk_backlog.tail)->next = (__skb); \ 469 sk->sk_backlog.tail->next = skb;
470 (__sk)->sk_backlog.tail = (__skb); \ 470 sk->sk_backlog.tail = skb;
471 } \ 471 }
472 (__skb)->next = NULL; \ 472 skb->next = NULL;
473} while(0) 473}
474 474
475#define sk_wait_event(__sk, __timeo, __condition) \ 475#define sk_wait_event(__sk, __timeo, __condition) \
476({ int rc; \ 476({ int rc; \
diff --git a/net/802/p8023.c b/net/802/p8023.c
index 6368d3dce444..d23e906456eb 100644
--- a/net/802/p8023.c
+++ b/net/802/p8023.c
@@ -54,8 +54,7 @@ struct datalink_proto *make_8023_client(void)
54 */ 54 */
55void destroy_8023_client(struct datalink_proto *dl) 55void destroy_8023_client(struct datalink_proto *dl)
56{ 56{
57 if (dl) 57 kfree(dl);
58 kfree(dl);
59} 58}
60 59
61EXPORT_SYMBOL(destroy_8023_client); 60EXPORT_SYMBOL(destroy_8023_client);
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 8e37e71e34ff..1b683f302657 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -1138,10 +1138,8 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
1138 sk->sk_state = TCP_CLOSE; 1138 sk->sk_state = TCP_CLOSE;
1139 sock->state = SS_UNCONNECTED; 1139 sock->state = SS_UNCONNECTED;
1140 1140
1141 if (ax25->digipeat != NULL) { 1141 kfree(ax25->digipeat);
1142 kfree(ax25->digipeat); 1142 ax25->digipeat = NULL;
1143 ax25->digipeat = NULL;
1144 }
1145 1143
1146 /* 1144 /*
1147 * Handle digi-peaters to be used. 1145 * Handle digi-peaters to be used.
diff --git a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c
index 73cfc3411c46..4cf87540fb3a 100644
--- a/net/ax25/ax25_in.c
+++ b/net/ax25/ax25_in.c
@@ -401,10 +401,8 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
401 } 401 }
402 402
403 if (dp.ndigi == 0) { 403 if (dp.ndigi == 0) {
404 if (ax25->digipeat != NULL) { 404 kfree(ax25->digipeat);
405 kfree(ax25->digipeat); 405 ax25->digipeat = NULL;
406 ax25->digipeat = NULL;
407 }
408 } else { 406 } else {
409 /* Reverse the source SABM's path */ 407 /* Reverse the source SABM's path */
410 memcpy(ax25->digipeat, &reverse_dp, sizeof(ax25_digi)); 408 memcpy(ax25->digipeat, &reverse_dp, sizeof(ax25_digi));
diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
index 26b77d972220..b1e945bd6ed3 100644
--- a/net/ax25/ax25_route.c
+++ b/net/ax25/ax25_route.c
@@ -54,15 +54,13 @@ void ax25_rt_device_down(struct net_device *dev)
54 if (s->dev == dev) { 54 if (s->dev == dev) {
55 if (ax25_route_list == s) { 55 if (ax25_route_list == s) {
56 ax25_route_list = s->next; 56 ax25_route_list = s->next;
57 if (s->digipeat != NULL) 57 kfree(s->digipeat);
58 kfree(s->digipeat);
59 kfree(s); 58 kfree(s);
60 } else { 59 } else {
61 for (t = ax25_route_list; t != NULL; t = t->next) { 60 for (t = ax25_route_list; t != NULL; t = t->next) {
62 if (t->next == s) { 61 if (t->next == s) {
63 t->next = s->next; 62 t->next = s->next;
64 if (s->digipeat != NULL) 63 kfree(s->digipeat);
65 kfree(s->digipeat);
66 kfree(s); 64 kfree(s);
67 break; 65 break;
68 } 66 }
@@ -90,10 +88,8 @@ static int ax25_rt_add(struct ax25_routes_struct *route)
90 while (ax25_rt != NULL) { 88 while (ax25_rt != NULL) {
91 if (ax25cmp(&ax25_rt->callsign, &route->dest_addr) == 0 && 89 if (ax25cmp(&ax25_rt->callsign, &route->dest_addr) == 0 &&
92 ax25_rt->dev == ax25_dev->dev) { 90 ax25_rt->dev == ax25_dev->dev) {
93 if (ax25_rt->digipeat != NULL) { 91 kfree(ax25_rt->digipeat);
94 kfree(ax25_rt->digipeat); 92 ax25_rt->digipeat = NULL;
95 ax25_rt->digipeat = NULL;
96 }
97 if (route->digi_count != 0) { 93 if (route->digi_count != 0) {
98 if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { 94 if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
99 write_unlock(&ax25_route_lock); 95 write_unlock(&ax25_route_lock);
@@ -145,8 +141,7 @@ static int ax25_rt_add(struct ax25_routes_struct *route)
145static void ax25_rt_destroy(ax25_route *ax25_rt) 141static void ax25_rt_destroy(ax25_route *ax25_rt)
146{ 142{
147 if (atomic_read(&ax25_rt->ref) == 0) { 143 if (atomic_read(&ax25_rt->ref) == 0) {
148 if (ax25_rt->digipeat != NULL) 144 kfree(ax25_rt->digipeat);
149 kfree(ax25_rt->digipeat);
150 kfree(ax25_rt); 145 kfree(ax25_rt);
151 return; 146 return;
152 } 147 }
@@ -530,9 +525,7 @@ void __exit ax25_rt_free(void)
530 s = ax25_rt; 525 s = ax25_rt;
531 ax25_rt = ax25_rt->next; 526 ax25_rt = ax25_rt->next;
532 527
533 if (s->digipeat != NULL) 528 kfree(s->digipeat);
534 kfree(s->digipeat);
535
536 kfree(s); 529 kfree(s);
537 } 530 }
538 write_unlock(&ax25_route_lock); 531 write_unlock(&ax25_route_lock);
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 03532062a46a..ea616e3fc98e 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -36,7 +36,6 @@
36#include <linux/skbuff.h> 36#include <linux/skbuff.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/poll.h> 38#include <linux/poll.h>
39#include <linux/proc_fs.h>
40#include <net/sock.h> 39#include <net/sock.h>
41 40
42#if defined(CONFIG_KMOD) 41#if defined(CONFIG_KMOD)
@@ -50,10 +49,7 @@
50#define BT_DBG(D...) 49#define BT_DBG(D...)
51#endif 50#endif
52 51
53#define VERSION "2.7" 52#define VERSION "2.8"
54
55struct proc_dir_entry *proc_bt;
56EXPORT_SYMBOL(proc_bt);
57 53
58/* Bluetooth sockets */ 54/* Bluetooth sockets */
59#define BT_MAX_PROTO 8 55#define BT_MAX_PROTO 8
@@ -312,10 +308,6 @@ static int __init bt_init(void)
312{ 308{
313 BT_INFO("Core ver %s", VERSION); 309 BT_INFO("Core ver %s", VERSION);
314 310
315 proc_bt = proc_mkdir("bluetooth", NULL);
316 if (proc_bt)
317 proc_bt->owner = THIS_MODULE;
318
319 sock_register(&bt_sock_family_ops); 311 sock_register(&bt_sock_family_ops);
320 312
321 BT_INFO("HCI device and connection manager initialized"); 313 BT_INFO("HCI device and connection manager initialized");
@@ -334,8 +326,6 @@ static void __exit bt_exit(void)
334 bt_sysfs_cleanup(); 326 bt_sysfs_cleanup();
335 327
336 sock_unregister(PF_BLUETOOTH); 328 sock_unregister(PF_BLUETOOTH);
337
338 remove_proc_entry("bluetooth", NULL);
339} 329}
340 330
341subsys_initcall(bt_init); 331subsys_initcall(bt_init);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index cf0df1c8c933..9106354c781e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -183,7 +183,7 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt)
183static void hci_init_req(struct hci_dev *hdev, unsigned long opt) 183static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
184{ 184{
185 struct sk_buff *skb; 185 struct sk_buff *skb;
186 __u16 param; 186 __le16 param;
187 187
188 BT_DBG("%s %ld", hdev->name, opt); 188 BT_DBG("%s %ld", hdev->name, opt);
189 189
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index b61b4e8e36fd..eb64555d1fb3 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -242,7 +242,7 @@ static void hci_cc_host_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb
242 break; 242 break;
243 243
244 status = *((__u8 *) skb->data); 244 status = *((__u8 *) skb->data);
245 setting = __le16_to_cpu(get_unaligned((__u16 *) sent)); 245 setting = __le16_to_cpu(get_unaligned((__le16 *) sent));
246 246
247 if (!status && hdev->voice_setting != setting) { 247 if (!status && hdev->voice_setting != setting) {
248 hdev->voice_setting = setting; 248 hdev->voice_setting = setting;
@@ -728,7 +728,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
728static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb) 728static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
729{ 729{
730 struct hci_ev_num_comp_pkts *ev = (struct hci_ev_num_comp_pkts *) skb->data; 730 struct hci_ev_num_comp_pkts *ev = (struct hci_ev_num_comp_pkts *) skb->data;
731 __u16 *ptr; 731 __le16 *ptr;
732 int i; 732 int i;
733 733
734 skb_pull(skb, sizeof(*ev)); 734 skb_pull(skb, sizeof(*ev));
@@ -742,7 +742,7 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
742 742
743 tasklet_disable(&hdev->tx_task); 743 tasklet_disable(&hdev->tx_task);
744 744
745 for (i = 0, ptr = (__u16 *) skb->data; i < ev->num_hndl; i++) { 745 for (i = 0, ptr = (__le16 *) skb->data; i < ev->num_hndl; i++) {
746 struct hci_conn *conn; 746 struct hci_conn *conn;
747 __u16 handle, count; 747 __u16 handle, count;
748 748
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 799e448750ad..1d6d0a15c099 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -416,7 +416,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
416 skb->dev = (void *) hdev; 416 skb->dev = (void *) hdev;
417 417
418 if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { 418 if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {
419 u16 opcode = __le16_to_cpu(get_unaligned((u16 *)skb->data)); 419 u16 opcode = __le16_to_cpu(get_unaligned((__le16 *) skb->data));
420 u16 ogf = hci_opcode_ogf(opcode); 420 u16 ogf = hci_opcode_ogf(opcode);
421 u16 ocf = hci_opcode_ocf(opcode); 421 u16 ocf = hci_opcode_ocf(opcode);
422 422
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 7856bc26accb..bd7568ac87fc 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -103,7 +103,7 @@ static void bt_release(struct class_device *cdev)
103 kfree(hdev); 103 kfree(hdev);
104} 104}
105 105
106static struct class bt_class = { 106struct class bt_class = {
107 .name = "bluetooth", 107 .name = "bluetooth",
108 .release = bt_release, 108 .release = bt_release,
109#ifdef CONFIG_HOTPLUG 109#ifdef CONFIG_HOTPLUG
@@ -111,6 +111,8 @@ static struct class bt_class = {
111#endif 111#endif
112}; 112};
113 113
114EXPORT_SYMBOL_GPL(bt_class);
115
114int hci_register_sysfs(struct hci_dev *hdev) 116int hci_register_sysfs(struct hci_dev *hdev)
115{ 117{
116 struct class_device *cdev = &hdev->class_dev; 118 struct class_device *cdev = &hdev->class_dev;
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 860444a7fc0f..cdb9cfafd960 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -660,9 +660,7 @@ unlink:
660failed: 660failed:
661 up_write(&hidp_session_sem); 661 up_write(&hidp_session_sem);
662 662
663 if (session->input) 663 kfree(session->input);
664 kfree(session->input);
665
666 kfree(session); 664 kfree(session);
667 return err; 665 return err;
668} 666}
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 59b2dd36baa7..e3bb11ca4235 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -38,9 +38,8 @@
38#include <linux/interrupt.h> 38#include <linux/interrupt.h>
39#include <linux/socket.h> 39#include <linux/socket.h>
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/proc_fs.h>
42#include <linux/seq_file.h>
43#include <linux/list.h> 41#include <linux/list.h>
42#include <linux/device.h>
44#include <net/sock.h> 43#include <net/sock.h>
45 44
46#include <asm/system.h> 45#include <asm/system.h>
@@ -56,7 +55,7 @@
56#define BT_DBG(D...) 55#define BT_DBG(D...)
57#endif 56#endif
58 57
59#define VERSION "2.7" 58#define VERSION "2.8"
60 59
61static struct proto_ops l2cap_sock_ops; 60static struct proto_ops l2cap_sock_ops;
62 61
@@ -2137,94 +2136,29 @@ drop:
2137 return 0; 2136 return 0;
2138} 2137}
2139 2138
2140/* ---- Proc fs support ---- */ 2139static ssize_t l2cap_sysfs_show(struct class *dev, char *buf)
2141#ifdef CONFIG_PROC_FS
2142static void *l2cap_seq_start(struct seq_file *seq, loff_t *pos)
2143{ 2140{
2144 struct sock *sk; 2141 struct sock *sk;
2145 struct hlist_node *node; 2142 struct hlist_node *node;
2146 loff_t l = *pos; 2143 char *str = buf;
2147 2144
2148 read_lock_bh(&l2cap_sk_list.lock); 2145 read_lock_bh(&l2cap_sk_list.lock);
2149 2146
2150 sk_for_each(sk, node, &l2cap_sk_list.head) 2147 sk_for_each(sk, node, &l2cap_sk_list.head) {
2151 if (!l--) 2148 struct l2cap_pinfo *pi = l2cap_pi(sk);
2152 goto found;
2153 sk = NULL;
2154found:
2155 return sk;
2156}
2157 2149
2158static void *l2cap_seq_next(struct seq_file *seq, void *e, loff_t *pos) 2150 str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d 0x%x\n",
2159{ 2151 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
2160 (*pos)++; 2152 sk->sk_state, pi->psm, pi->scid, pi->dcid, pi->imtu,
2161 return sk_next(e); 2153 pi->omtu, pi->link_mode);
2162} 2154 }
2163 2155
2164static void l2cap_seq_stop(struct seq_file *seq, void *e)
2165{
2166 read_unlock_bh(&l2cap_sk_list.lock); 2156 read_unlock_bh(&l2cap_sk_list.lock);
2167}
2168 2157
2169static int l2cap_seq_show(struct seq_file *seq, void *e) 2158 return (str - buf);
2170{
2171 struct sock *sk = e;
2172 struct l2cap_pinfo *pi = l2cap_pi(sk);
2173
2174 seq_printf(seq, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d 0x%x\n",
2175 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
2176 sk->sk_state, pi->psm, pi->scid, pi->dcid, pi->imtu,
2177 pi->omtu, pi->link_mode);
2178 return 0;
2179} 2159}
2180 2160
2181static struct seq_operations l2cap_seq_ops = { 2161static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL);
2182 .start = l2cap_seq_start,
2183 .next = l2cap_seq_next,
2184 .stop = l2cap_seq_stop,
2185 .show = l2cap_seq_show
2186};
2187
2188static int l2cap_seq_open(struct inode *inode, struct file *file)
2189{
2190 return seq_open(file, &l2cap_seq_ops);
2191}
2192
2193static struct file_operations l2cap_seq_fops = {
2194 .owner = THIS_MODULE,
2195 .open = l2cap_seq_open,
2196 .read = seq_read,
2197 .llseek = seq_lseek,
2198 .release = seq_release,
2199};
2200
2201static int __init l2cap_proc_init(void)
2202{
2203 struct proc_dir_entry *p = create_proc_entry("l2cap", S_IRUGO, proc_bt);
2204 if (!p)
2205 return -ENOMEM;
2206 p->owner = THIS_MODULE;
2207 p->proc_fops = &l2cap_seq_fops;
2208 return 0;
2209}
2210
2211static void __exit l2cap_proc_cleanup(void)
2212{
2213 remove_proc_entry("l2cap", proc_bt);
2214}
2215
2216#else /* CONFIG_PROC_FS */
2217
2218static int __init l2cap_proc_init(void)
2219{
2220 return 0;
2221}
2222
2223static void __exit l2cap_proc_cleanup(void)
2224{
2225 return;
2226}
2227#endif /* CONFIG_PROC_FS */
2228 2162
2229static struct proto_ops l2cap_sock_ops = { 2163static struct proto_ops l2cap_sock_ops = {
2230 .family = PF_BLUETOOTH, 2164 .family = PF_BLUETOOTH,
@@ -2266,7 +2200,7 @@ static struct hci_proto l2cap_hci_proto = {
2266static int __init l2cap_init(void) 2200static int __init l2cap_init(void)
2267{ 2201{
2268 int err; 2202 int err;
2269 2203
2270 err = proto_register(&l2cap_proto, 0); 2204 err = proto_register(&l2cap_proto, 0);
2271 if (err < 0) 2205 if (err < 0)
2272 return err; 2206 return err;
@@ -2284,7 +2218,7 @@ static int __init l2cap_init(void)
2284 goto error; 2218 goto error;
2285 } 2219 }
2286 2220
2287 l2cap_proc_init(); 2221 class_create_file(&bt_class, &class_attr_l2cap);
2288 2222
2289 BT_INFO("L2CAP ver %s", VERSION); 2223 BT_INFO("L2CAP ver %s", VERSION);
2290 BT_INFO("L2CAP socket layer initialized"); 2224 BT_INFO("L2CAP socket layer initialized");
@@ -2298,7 +2232,7 @@ error:
2298 2232
2299static void __exit l2cap_exit(void) 2233static void __exit l2cap_exit(void)
2300{ 2234{
2301 l2cap_proc_cleanup(); 2235 class_remove_file(&bt_class, &class_attr_l2cap);
2302 2236
2303 if (bt_sock_unregister(BTPROTO_L2CAP) < 0) 2237 if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
2304 BT_ERR("L2CAP socket unregistration failed"); 2238 BT_ERR("L2CAP socket unregistration failed");
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index c3d56ead840c..0d89d6434136 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -35,9 +35,8 @@
35#include <linux/signal.h> 35#include <linux/signal.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/wait.h> 37#include <linux/wait.h>
38#include <linux/device.h>
38#include <linux/net.h> 39#include <linux/net.h>
39#include <linux/proc_fs.h>
40#include <linux/seq_file.h>
41#include <net/sock.h> 40#include <net/sock.h>
42#include <asm/uaccess.h> 41#include <asm/uaccess.h>
43#include <asm/unaligned.h> 42#include <asm/unaligned.h>
@@ -47,17 +46,13 @@
47#include <net/bluetooth/l2cap.h> 46#include <net/bluetooth/l2cap.h>
48#include <net/bluetooth/rfcomm.h> 47#include <net/bluetooth/rfcomm.h>
49 48
50#define VERSION "1.5" 49#define VERSION "1.6"
51 50
52#ifndef CONFIG_BT_RFCOMM_DEBUG 51#ifndef CONFIG_BT_RFCOMM_DEBUG
53#undef BT_DBG 52#undef BT_DBG
54#define BT_DBG(D...) 53#define BT_DBG(D...)
55#endif 54#endif
56 55
57#ifdef CONFIG_PROC_FS
58struct proc_dir_entry *proc_bt_rfcomm;
59#endif
60
61static struct task_struct *rfcomm_thread; 56static struct task_struct *rfcomm_thread;
62 57
63static DECLARE_MUTEX(rfcomm_sem); 58static DECLARE_MUTEX(rfcomm_sem);
@@ -2001,117 +1996,32 @@ static struct hci_cb rfcomm_cb = {
2001 .encrypt_cfm = rfcomm_encrypt_cfm 1996 .encrypt_cfm = rfcomm_encrypt_cfm
2002}; 1997};
2003 1998
2004/* ---- Proc fs support ---- */ 1999static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, char *buf)
2005#ifdef CONFIG_PROC_FS
2006static void *rfcomm_seq_start(struct seq_file *seq, loff_t *pos)
2007{ 2000{
2008 struct rfcomm_session *s; 2001 struct rfcomm_session *s;
2009 struct list_head *pp, *p; 2002 struct list_head *pp, *p;
2010 loff_t l = *pos; 2003 char *str = buf;
2011 2004
2012 rfcomm_lock(); 2005 rfcomm_lock();
2013 2006
2014 list_for_each(p, &session_list) { 2007 list_for_each(p, &session_list) {
2015 s = list_entry(p, struct rfcomm_session, list); 2008 s = list_entry(p, struct rfcomm_session, list);
2016 list_for_each(pp, &s->dlcs) 2009 list_for_each(pp, &s->dlcs) {
2017 if (!l--) { 2010 struct sock *sk = s->sock->sk;
2018 seq->private = s; 2011 struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list);
2019 return pp;
2020 }
2021 }
2022 return NULL;
2023}
2024 2012
2025static void *rfcomm_seq_next(struct seq_file *seq, void *e, loff_t *pos) 2013 str += sprintf(str, "%s %s %ld %d %d %d %d\n",
2026{ 2014 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
2027 struct rfcomm_session *s = seq->private; 2015 d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits);
2028 struct list_head *pp, *p = e;
2029 (*pos)++;
2030
2031 if (p->next != &s->dlcs)
2032 return p->next;
2033
2034 list_for_each(p, &session_list) {
2035 s = list_entry(p, struct rfcomm_session, list);
2036 __list_for_each(pp, &s->dlcs) {
2037 seq->private = s;
2038 return pp;
2039 } 2016 }
2040 } 2017 }
2041 return NULL;
2042}
2043 2018
2044static void rfcomm_seq_stop(struct seq_file *seq, void *e)
2045{
2046 rfcomm_unlock(); 2019 rfcomm_unlock();
2047}
2048
2049static int rfcomm_seq_show(struct seq_file *seq, void *e)
2050{
2051 struct rfcomm_session *s = seq->private;
2052 struct sock *sk = s->sock->sk;
2053 struct rfcomm_dlc *d = list_entry(e, struct rfcomm_dlc, list);
2054
2055 seq_printf(seq, "%s %s %ld %d %d %d %d\n",
2056 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
2057 d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits);
2058 return 0;
2059}
2060
2061static struct seq_operations rfcomm_seq_ops = {
2062 .start = rfcomm_seq_start,
2063 .next = rfcomm_seq_next,
2064 .stop = rfcomm_seq_stop,
2065 .show = rfcomm_seq_show
2066};
2067
2068static int rfcomm_seq_open(struct inode *inode, struct file *file)
2069{
2070 return seq_open(file, &rfcomm_seq_ops);
2071}
2072
2073static struct file_operations rfcomm_seq_fops = {
2074 .owner = THIS_MODULE,
2075 .open = rfcomm_seq_open,
2076 .read = seq_read,
2077 .llseek = seq_lseek,
2078 .release = seq_release,
2079};
2080
2081static int __init rfcomm_proc_init(void)
2082{
2083 struct proc_dir_entry *p;
2084
2085 proc_bt_rfcomm = proc_mkdir("rfcomm", proc_bt);
2086 if (proc_bt_rfcomm) {
2087 proc_bt_rfcomm->owner = THIS_MODULE;
2088
2089 p = create_proc_entry("dlc", S_IRUGO, proc_bt_rfcomm);
2090 if (p)
2091 p->proc_fops = &rfcomm_seq_fops;
2092 }
2093 return 0;
2094}
2095
2096static void __exit rfcomm_proc_cleanup(void)
2097{
2098 remove_proc_entry("dlc", proc_bt_rfcomm);
2099 2020
2100 remove_proc_entry("rfcomm", proc_bt); 2021 return (str - buf);
2101} 2022}
2102 2023
2103#else /* CONFIG_PROC_FS */ 2024static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL);
2104
2105static int __init rfcomm_proc_init(void)
2106{
2107 return 0;
2108}
2109
2110static void __exit rfcomm_proc_cleanup(void)
2111{
2112 return;
2113}
2114#endif /* CONFIG_PROC_FS */
2115 2025
2116/* ---- Initialization ---- */ 2026/* ---- Initialization ---- */
2117static int __init rfcomm_init(void) 2027static int __init rfcomm_init(void)
@@ -2122,9 +2032,7 @@ static int __init rfcomm_init(void)
2122 2032
2123 kernel_thread(rfcomm_run, NULL, CLONE_KERNEL); 2033 kernel_thread(rfcomm_run, NULL, CLONE_KERNEL);
2124 2034
2125 BT_INFO("RFCOMM ver %s", VERSION); 2035 class_create_file(&bt_class, &class_attr_rfcomm_dlc);
2126
2127 rfcomm_proc_init();
2128 2036
2129 rfcomm_init_sockets(); 2037 rfcomm_init_sockets();
2130 2038
@@ -2132,11 +2040,15 @@ static int __init rfcomm_init(void)
2132 rfcomm_init_ttys(); 2040 rfcomm_init_ttys();
2133#endif 2041#endif
2134 2042
2043 BT_INFO("RFCOMM ver %s", VERSION);
2044
2135 return 0; 2045 return 0;
2136} 2046}
2137 2047
2138static void __exit rfcomm_exit(void) 2048static void __exit rfcomm_exit(void)
2139{ 2049{
2050 class_remove_file(&bt_class, &class_attr_rfcomm_dlc);
2051
2140 hci_unregister_cb(&rfcomm_cb); 2052 hci_unregister_cb(&rfcomm_cb);
2141 2053
2142 /* Terminate working thread. 2054 /* Terminate working thread.
@@ -2153,8 +2065,6 @@ static void __exit rfcomm_exit(void)
2153#endif 2065#endif
2154 2066
2155 rfcomm_cleanup_sockets(); 2067 rfcomm_cleanup_sockets();
2156
2157 rfcomm_proc_cleanup();
2158} 2068}
2159 2069
2160module_init(rfcomm_init); 2070module_init(rfcomm_init);
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index a2b30f0aedb7..6c34261b232e 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -42,8 +42,7 @@
42#include <linux/socket.h> 42#include <linux/socket.h>
43#include <linux/skbuff.h> 43#include <linux/skbuff.h>
44#include <linux/list.h> 44#include <linux/list.h>
45#include <linux/proc_fs.h> 45#include <linux/device.h>
46#include <linux/seq_file.h>
47#include <net/sock.h> 46#include <net/sock.h>
48 47
49#include <asm/system.h> 48#include <asm/system.h>
@@ -887,89 +886,26 @@ done:
887 return result; 886 return result;
888} 887}
889 888
890/* ---- Proc fs support ---- */ 889static ssize_t rfcomm_sock_sysfs_show(struct class *dev, char *buf)
891#ifdef CONFIG_PROC_FS
892static void *rfcomm_seq_start(struct seq_file *seq, loff_t *pos)
893{ 890{
894 struct sock *sk; 891 struct sock *sk;
895 struct hlist_node *node; 892 struct hlist_node *node;
896 loff_t l = *pos; 893 char *str = buf;
897 894
898 read_lock_bh(&rfcomm_sk_list.lock); 895 read_lock_bh(&rfcomm_sk_list.lock);
899 896
900 sk_for_each(sk, node, &rfcomm_sk_list.head) 897 sk_for_each(sk, node, &rfcomm_sk_list.head) {
901 if (!l--) 898 str += sprintf(str, "%s %s %d %d\n",
902 return sk; 899 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
903 return NULL; 900 sk->sk_state, rfcomm_pi(sk)->channel);
904} 901 }
905
906static void *rfcomm_seq_next(struct seq_file *seq, void *e, loff_t *pos)
907{
908 struct sock *sk = e;
909 (*pos)++;
910 return sk_next(sk);
911}
912 902
913static void rfcomm_seq_stop(struct seq_file *seq, void *e)
914{
915 read_unlock_bh(&rfcomm_sk_list.lock); 903 read_unlock_bh(&rfcomm_sk_list.lock);
916}
917 904
918static int rfcomm_seq_show(struct seq_file *seq, void *e) 905 return (str - buf);
919{
920 struct sock *sk = e;
921 seq_printf(seq, "%s %s %d %d\n",
922 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
923 sk->sk_state, rfcomm_pi(sk)->channel);
924 return 0;
925}
926
927static struct seq_operations rfcomm_seq_ops = {
928 .start = rfcomm_seq_start,
929 .next = rfcomm_seq_next,
930 .stop = rfcomm_seq_stop,
931 .show = rfcomm_seq_show
932};
933
934static int rfcomm_seq_open(struct inode *inode, struct file *file)
935{
936 return seq_open(file, &rfcomm_seq_ops);
937} 906}
938 907
939static struct file_operations rfcomm_seq_fops = { 908static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL);
940 .owner = THIS_MODULE,
941 .open = rfcomm_seq_open,
942 .read = seq_read,
943 .llseek = seq_lseek,
944 .release = seq_release,
945};
946
947static int __init rfcomm_sock_proc_init(void)
948{
949 struct proc_dir_entry *p = create_proc_entry("sock", S_IRUGO, proc_bt_rfcomm);
950 if (!p)
951 return -ENOMEM;
952 p->proc_fops = &rfcomm_seq_fops;
953 return 0;
954}
955
956static void __exit rfcomm_sock_proc_cleanup(void)
957{
958 remove_proc_entry("sock", proc_bt_rfcomm);
959}
960
961#else /* CONFIG_PROC_FS */
962
963static int __init rfcomm_sock_proc_init(void)
964{
965 return 0;
966}
967
968static void __exit rfcomm_sock_proc_cleanup(void)
969{
970 return;
971}
972#endif /* CONFIG_PROC_FS */
973 909
974static struct proto_ops rfcomm_sock_ops = { 910static struct proto_ops rfcomm_sock_ops = {
975 .family = PF_BLUETOOTH, 911 .family = PF_BLUETOOTH,
@@ -997,7 +933,7 @@ static struct net_proto_family rfcomm_sock_family_ops = {
997 .create = rfcomm_sock_create 933 .create = rfcomm_sock_create
998}; 934};
999 935
1000int __init rfcomm_init_sockets(void) 936int __init rfcomm_init_sockets(void)
1001{ 937{
1002 int err; 938 int err;
1003 939
@@ -1009,7 +945,7 @@ int __init rfcomm_init_sockets(void)
1009 if (err < 0) 945 if (err < 0)
1010 goto error; 946 goto error;
1011 947
1012 rfcomm_sock_proc_init(); 948 class_create_file(&bt_class, &class_attr_rfcomm);
1013 949
1014 BT_INFO("RFCOMM socket layer initialized"); 950 BT_INFO("RFCOMM socket layer initialized");
1015 951
@@ -1023,7 +959,7 @@ error:
1023 959
1024void __exit rfcomm_cleanup_sockets(void) 960void __exit rfcomm_cleanup_sockets(void)
1025{ 961{
1026 rfcomm_sock_proc_cleanup(); 962 class_remove_file(&bt_class, &class_attr_rfcomm);
1027 963
1028 if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) 964 if (bt_sock_unregister(BTPROTO_RFCOMM) < 0)
1029 BT_ERR("RFCOMM socket layer unregistration failed"); 965 BT_ERR("RFCOMM socket layer unregistration failed");
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 997e42df115c..9cb00dc6c08c 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -38,8 +38,7 @@
38#include <linux/interrupt.h> 38#include <linux/interrupt.h>
39#include <linux/socket.h> 39#include <linux/socket.h>
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/proc_fs.h> 41#include <linux/device.h>
42#include <linux/seq_file.h>
43#include <linux/list.h> 42#include <linux/list.h>
44#include <net/sock.h> 43#include <net/sock.h>
45 44
@@ -55,7 +54,7 @@
55#define BT_DBG(D...) 54#define BT_DBG(D...)
56#endif 55#endif
57 56
58#define VERSION "0.4" 57#define VERSION "0.5"
59 58
60static struct proto_ops sco_sock_ops; 59static struct proto_ops sco_sock_ops;
61 60
@@ -893,91 +892,26 @@ drop:
893 return 0; 892 return 0;
894} 893}
895 894
896/* ---- Proc fs support ---- */ 895static ssize_t sco_sysfs_show(struct class *dev, char *buf)
897#ifdef CONFIG_PROC_FS
898static void *sco_seq_start(struct seq_file *seq, loff_t *pos)
899{ 896{
900 struct sock *sk; 897 struct sock *sk;
901 struct hlist_node *node; 898 struct hlist_node *node;
902 loff_t l = *pos; 899 char *str = buf;
903 900
904 read_lock_bh(&sco_sk_list.lock); 901 read_lock_bh(&sco_sk_list.lock);
905 902
906 sk_for_each(sk, node, &sco_sk_list.head) 903 sk_for_each(sk, node, &sco_sk_list.head) {
907 if (!l--) 904 str += sprintf(str, "%s %s %d\n",
908 goto found; 905 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
909 sk = NULL; 906 sk->sk_state);
910found: 907 }
911 return sk;
912}
913
914static void *sco_seq_next(struct seq_file *seq, void *e, loff_t *pos)
915{
916 struct sock *sk = e;
917 (*pos)++;
918 return sk_next(sk);
919}
920 908
921static void sco_seq_stop(struct seq_file *seq, void *e)
922{
923 read_unlock_bh(&sco_sk_list.lock); 909 read_unlock_bh(&sco_sk_list.lock);
924}
925
926static int sco_seq_show(struct seq_file *seq, void *e)
927{
928 struct sock *sk = e;
929 seq_printf(seq, "%s %s %d\n",
930 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), sk->sk_state);
931 return 0;
932}
933 910
934static struct seq_operations sco_seq_ops = { 911 return (str - buf);
935 .start = sco_seq_start,
936 .next = sco_seq_next,
937 .stop = sco_seq_stop,
938 .show = sco_seq_show
939};
940
941static int sco_seq_open(struct inode *inode, struct file *file)
942{
943 return seq_open(file, &sco_seq_ops);
944} 912}
945 913
946static struct file_operations sco_seq_fops = { 914static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL);
947 .owner = THIS_MODULE,
948 .open = sco_seq_open,
949 .read = seq_read,
950 .llseek = seq_lseek,
951 .release = seq_release,
952};
953
954static int __init sco_proc_init(void)
955{
956 struct proc_dir_entry *p = create_proc_entry("sco", S_IRUGO, proc_bt);
957 if (!p)
958 return -ENOMEM;
959 p->owner = THIS_MODULE;
960 p->proc_fops = &sco_seq_fops;
961 return 0;
962}
963
964static void __exit sco_proc_cleanup(void)
965{
966 remove_proc_entry("sco", proc_bt);
967}
968
969#else /* CONFIG_PROC_FS */
970
971static int __init sco_proc_init(void)
972{
973 return 0;
974}
975
976static void __exit sco_proc_cleanup(void)
977{
978 return;
979}
980#endif /* CONFIG_PROC_FS */
981 915
982static struct proto_ops sco_sock_ops = { 916static struct proto_ops sco_sock_ops = {
983 .family = PF_BLUETOOTH, 917 .family = PF_BLUETOOTH,
@@ -1035,7 +969,7 @@ static int __init sco_init(void)
1035 goto error; 969 goto error;
1036 } 970 }
1037 971
1038 sco_proc_init(); 972 class_create_file(&bt_class, &class_attr_sco);
1039 973
1040 BT_INFO("SCO (Voice Link) ver %s", VERSION); 974 BT_INFO("SCO (Voice Link) ver %s", VERSION);
1041 BT_INFO("SCO socket layer initialized"); 975 BT_INFO("SCO socket layer initialized");
@@ -1049,7 +983,7 @@ error:
1049 983
1050static void __exit sco_exit(void) 984static void __exit sco_exit(void)
1051{ 985{
1052 sco_proc_cleanup(); 986 class_remove_file(&bt_class, &class_attr_sco);
1053 987
1054 if (bt_sock_unregister(BTPROTO_SCO) < 0) 988 if (bt_sock_unregister(BTPROTO_SCO) < 0)
1055 BT_ERR("SCO socket unregistration failed"); 989 BT_ERR("SCO socket unregistration failed");
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c
index db098ff3cd6a..cb530eef0e39 100644
--- a/net/core/dev_mcast.c
+++ b/net/core/dev_mcast.c
@@ -194,8 +194,7 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
194 194
195done: 195done:
196 spin_unlock_bh(&dev->xmit_lock); 196 spin_unlock_bh(&dev->xmit_lock);
197 if (dmi1) 197 kfree(dmi1);
198 kfree(dmi1);
199 return err; 198 return err;
200} 199}
201 200
diff --git a/net/core/sock.c b/net/core/sock.c
index 9602ceb3bac9..13cc3be4f056 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1242,8 +1242,7 @@ static void sock_def_write_space(struct sock *sk)
1242 1242
1243static void sock_def_destruct(struct sock *sk) 1243static void sock_def_destruct(struct sock *sk)
1244{ 1244{
1245 if (sk->sk_protinfo) 1245 kfree(sk->sk_protinfo);
1246 kfree(sk->sk_protinfo);
1247} 1246}
1248 1247
1249void sk_send_sigurg(struct sock *sk) 1248void sk_send_sigurg(struct sock *sk)
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 4b9bc81ae1a3..ca03521112c5 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -1263,10 +1263,8 @@ static int dccp_v4_destroy_sock(struct sock *sk)
1263 if (inet_csk(sk)->icsk_bind_hash != NULL) 1263 if (inet_csk(sk)->icsk_bind_hash != NULL)
1264 inet_put_port(&dccp_hashinfo, sk); 1264 inet_put_port(&dccp_hashinfo, sk);
1265 1265
1266 if (dp->dccps_service_list != NULL) { 1266 kfree(dp->dccps_service_list);
1267 kfree(dp->dccps_service_list); 1267 dp->dccps_service_list = NULL;
1268 dp->dccps_service_list = NULL;
1269 }
1270 1268
1271 ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk); 1269 ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk);
1272 ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk); 1270 ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk);
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index a021c3422f67..e0ace7cbb996 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -238,8 +238,7 @@ static int dccp_setsockopt_service(struct sock *sk, const u32 service,
238 lock_sock(sk); 238 lock_sock(sk);
239 dp->dccps_service = service; 239 dp->dccps_service = service;
240 240
241 if (dp->dccps_service_list != NULL) 241 kfree(dp->dccps_service_list);
242 kfree(dp->dccps_service_list);
243 242
244 dp->dccps_service_list = sl; 243 dp->dccps_service_list = sl;
245 release_sock(sk); 244 release_sock(sk);
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
index eeba56f99323..6f8b5658cb4e 100644
--- a/net/decnet/dn_table.c
+++ b/net/decnet/dn_table.c
@@ -784,16 +784,14 @@ struct dn_fib_table *dn_fib_get_table(int n, int create)
784 784
785static void dn_fib_del_tree(int n) 785static void dn_fib_del_tree(int n)
786{ 786{
787 struct dn_fib_table *t; 787 struct dn_fib_table *t;
788 788
789 write_lock(&dn_fib_tables_lock); 789 write_lock(&dn_fib_tables_lock);
790 t = dn_fib_tables[n]; 790 t = dn_fib_tables[n];
791 dn_fib_tables[n] = NULL; 791 dn_fib_tables[n] = NULL;
792 write_unlock(&dn_fib_tables_lock); 792 write_unlock(&dn_fib_tables_lock);
793 793
794 if (t) { 794 kfree(t);
795 kfree(t);
796 }
797} 795}
798 796
799struct dn_fib_table *dn_fib_empty_table(void) 797struct dn_fib_table *dn_fib_empty_table(void)
diff --git a/net/ethernet/pe2.c b/net/ethernet/pe2.c
index 98a494be6039..9d57b4fb6440 100644
--- a/net/ethernet/pe2.c
+++ b/net/ethernet/pe2.c
@@ -32,8 +32,7 @@ struct datalink_proto *make_EII_client(void)
32 32
33void destroy_EII_client(struct datalink_proto *dl) 33void destroy_EII_client(struct datalink_proto *dl)
34{ 34{
35 if (dl) 35 kfree(dl);
36 kfree(dl);
37} 36}
38 37
39EXPORT_SYMBOL(destroy_EII_client); 38EXPORT_SYMBOL(destroy_EII_client);
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index a9d84f93442c..eaa150c33b04 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -147,8 +147,7 @@ void inet_sock_destruct(struct sock *sk)
147 BUG_TRAP(!sk->sk_wmem_queued); 147 BUG_TRAP(!sk->sk_wmem_queued);
148 BUG_TRAP(!sk->sk_forward_alloc); 148 BUG_TRAP(!sk->sk_forward_alloc);
149 149
150 if (inet->opt) 150 kfree(inet->opt);
151 kfree(inet->opt);
152 dst_release(sk->sk_dst_cache); 151 dst_release(sk->sk_dst_cache);
153 sk_refcnt_debug_dec(sk); 152 sk_refcnt_debug_dec(sk);
154} 153}
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 990633c09dfe..2267c1fad879 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -266,8 +266,7 @@ int ip_rt_ioctl(unsigned int cmd, void __user *arg)
266 if (tb) 266 if (tb)
267 err = tb->tb_insert(tb, &req.rtm, &rta, &req.nlh, NULL); 267 err = tb->tb_insert(tb, &req.rtm, &rta, &req.nlh, NULL);
268 } 268 }
269 if (rta.rta_mx) 269 kfree(rta.rta_mx);
270 kfree(rta.rta_mx);
271 } 270 }
272 rtnl_unlock(); 271 rtnl_unlock();
273 return err; 272 return err;
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index bce4e875193b..dbe12da8d8b3 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -510,8 +510,7 @@ static int ip_options_get_finish(struct ip_options **optp,
510 kfree(opt); 510 kfree(opt);
511 return -EINVAL; 511 return -EINVAL;
512 } 512 }
513 if (*optp) 513 kfree(*optp);
514 kfree(*optp);
515 *optp = opt; 514 *optp = opt;
516 return 0; 515 return 0;
517} 516}
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 17758234a3e3..11c2f68254f0 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -353,7 +353,8 @@ packet_routed:
353 ip_options_build(skb, opt, inet->daddr, rt, 0); 353 ip_options_build(skb, opt, inet->daddr, rt, 0);
354 } 354 }
355 355
356 ip_select_ident_more(iph, &rt->u.dst, sk, skb_shinfo(skb)->tso_segs); 356 ip_select_ident_more(iph, &rt->u.dst, sk,
357 (skb_shinfo(skb)->tso_segs ?: 1) - 1);
357 358
358 /* Add an IP checksum. */ 359 /* Add an IP checksum. */
359 ip_send_check(iph); 360 ip_send_check(iph);
@@ -1262,10 +1263,8 @@ int ip_push_pending_frames(struct sock *sk)
1262 1263
1263out: 1264out:
1264 inet->cork.flags &= ~IPCORK_OPT; 1265 inet->cork.flags &= ~IPCORK_OPT;
1265 if (inet->cork.opt) { 1266 kfree(inet->cork.opt);
1266 kfree(inet->cork.opt); 1267 inet->cork.opt = NULL;
1267 inet->cork.opt = NULL;
1268 }
1269 if (inet->cork.rt) { 1268 if (inet->cork.rt) {
1270 ip_rt_put(inet->cork.rt); 1269 ip_rt_put(inet->cork.rt);
1271 inet->cork.rt = NULL; 1270 inet->cork.rt = NULL;
@@ -1289,10 +1288,8 @@ void ip_flush_pending_frames(struct sock *sk)
1289 kfree_skb(skb); 1288 kfree_skb(skb);
1290 1289
1291 inet->cork.flags &= ~IPCORK_OPT; 1290 inet->cork.flags &= ~IPCORK_OPT;
1292 if (inet->cork.opt) { 1291 kfree(inet->cork.opt);
1293 kfree(inet->cork.opt); 1292 inet->cork.opt = NULL;
1294 inet->cork.opt = NULL;
1295 }
1296 if (inet->cork.rt) { 1293 if (inet->cork.rt) {
1297 ip_rt_put(inet->cork.rt); 1294 ip_rt_put(inet->cork.rt);
1298 inet->cork.rt = NULL; 1295 inet->cork.rt = NULL;
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 2f0b47da5b37..4f2d87257309 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -202,8 +202,7 @@ int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct s
202 if (ra->sk == sk) { 202 if (ra->sk == sk) {
203 if (on) { 203 if (on) {
204 write_unlock_bh(&ip_ra_lock); 204 write_unlock_bh(&ip_ra_lock);
205 if (new_ra) 205 kfree(new_ra);
206 kfree(new_ra);
207 return -EADDRINUSE; 206 return -EADDRINUSE;
208 } 207 }
209 *rap = ra->next; 208 *rap = ra->next;
@@ -446,8 +445,7 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
446#endif 445#endif
447 } 446 }
448 opt = xchg(&inet->opt, opt); 447 opt = xchg(&inet->opt, opt);
449 if (opt) 448 kfree(opt);
450 kfree(opt);
451 break; 449 break;
452 } 450 }
453 case IP_PKTINFO: 451 case IP_PKTINFO:
@@ -828,10 +826,8 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
828 826
829 err = ip_mc_msfilter(sk, msf, ifindex); 827 err = ip_mc_msfilter(sk, msf, ifindex);
830mc_msf_out: 828mc_msf_out:
831 if (msf) 829 kfree(msf);
832 kfree(msf); 830 kfree(gsf);
833 if (gsf)
834 kfree(gsf);
835 break; 831 break;
836 } 832 }
837 case IP_ROUTER_ALERT: 833 case IP_ROUTER_ALERT:
diff --git a/net/ipv4/ipvs/ip_vs_app.c b/net/ipv4/ipvs/ip_vs_app.c
index fc6f95aaa969..d7eb680101c2 100644
--- a/net/ipv4/ipvs/ip_vs_app.c
+++ b/net/ipv4/ipvs/ip_vs_app.c
@@ -110,8 +110,7 @@ ip_vs_app_inc_new(struct ip_vs_app *app, __u16 proto, __u16 port)
110 return 0; 110 return 0;
111 111
112 out: 112 out:
113 if (inc->timeout_table) 113 kfree(inc->timeout_table);
114 kfree(inc->timeout_table);
115 kfree(inc); 114 kfree(inc);
116 return ret; 115 return ret;
117} 116}
@@ -136,8 +135,7 @@ ip_vs_app_inc_release(struct ip_vs_app *inc)
136 135
137 list_del(&inc->a_list); 136 list_del(&inc->a_list);
138 137
139 if (inc->timeout_table != NULL) 138 kfree(inc->timeout_table);
140 kfree(inc->timeout_table);
141 kfree(inc); 139 kfree(inc);
142} 140}
143 141
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c
index 981cc3244ef2..1a0843cd58a9 100644
--- a/net/ipv4/ipvs/ip_vs_core.c
+++ b/net/ipv4/ipvs/ip_vs_core.c
@@ -1009,11 +1009,10 @@ ip_vs_in(unsigned int hooknum, struct sk_buff **pskb,
1009 if (sysctl_ip_vs_expire_nodest_conn) { 1009 if (sysctl_ip_vs_expire_nodest_conn) {
1010 /* try to expire the connection immediately */ 1010 /* try to expire the connection immediately */
1011 ip_vs_conn_expire_now(cp); 1011 ip_vs_conn_expire_now(cp);
1012 } else {
1013 /* don't restart its timer, and silently
1014 drop the packet. */
1015 __ip_vs_conn_put(cp);
1016 } 1012 }
1013 /* don't restart its timer, and silently
1014 drop the packet. */
1015 __ip_vs_conn_put(cp);
1017 return NF_DROP; 1016 return NF_DROP;
1018 } 1017 }
1019 1018
diff --git a/net/ipv4/multipath_wrandom.c b/net/ipv4/multipath_wrandom.c
index bd7d75b6abe0..d34a9fa608e0 100644
--- a/net/ipv4/multipath_wrandom.c
+++ b/net/ipv4/multipath_wrandom.c
@@ -207,16 +207,12 @@ static void wrandom_select_route(const struct flowi *flp,
207 decision = mpc->rt; 207 decision = mpc->rt;
208 208
209 last_power = mpc->power; 209 last_power = mpc->power;
210 if (last_mpc) 210 kfree(last_mpc);
211 kfree(last_mpc);
212
213 last_mpc = mpc; 211 last_mpc = mpc;
214 } 212 }
215 213
216 if (last_mpc) { 214 /* concurrent __multipath_flush may lead to !last_mpc */
217 /* concurrent __multipath_flush may lead to !last_mpc */ 215 kfree(last_mpc);
218 kfree(last_mpc);
219 }
220 216
221 decision->u.dst.__use++; 217 decision->u.dst.__use++;
222 *rp = decision; 218 *rp = decision;
diff --git a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c
index 93b2c5111bb2..8acb7ed40b47 100644
--- a/net/ipv4/netfilter/ip_nat_snmp_basic.c
+++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c
@@ -1161,8 +1161,7 @@ static int snmp_parse_mangle(unsigned char *msg,
1161 1161
1162 if (!snmp_object_decode(&ctx, obj)) { 1162 if (!snmp_object_decode(&ctx, obj)) {
1163 if (*obj) { 1163 if (*obj) {
1164 if ((*obj)->id) 1164 kfree((*obj)->id);
1165 kfree((*obj)->id);
1166 kfree(*obj); 1165 kfree(*obj);
1167 } 1166 }
1168 kfree(obj); 1167 kfree(obj);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 49d67cd75edd..634dabb558fd 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -823,8 +823,7 @@ out:
823 */ 823 */
824static void tcp_v4_reqsk_destructor(struct request_sock *req) 824static void tcp_v4_reqsk_destructor(struct request_sock *req)
825{ 825{
826 if (inet_rsk(req)->opt) 826 kfree(inet_rsk(req)->opt);
827 kfree(inet_rsk(req)->opt);
828} 827}
829 828
830static inline void syn_flood_warning(struct sk_buff *skb) 829static inline void syn_flood_warning(struct sk_buff *skb)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 2c5f57299d63..b7a5f51238b3 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -35,6 +35,9 @@
35 * YOSHIFUJI Hideaki @USAGI : ARCnet support 35 * YOSHIFUJI Hideaki @USAGI : ARCnet support
36 * YOSHIFUJI Hideaki @USAGI : convert /proc/net/if_inet6 to 36 * YOSHIFUJI Hideaki @USAGI : convert /proc/net/if_inet6 to
37 * seq_file. 37 * seq_file.
38 * YOSHIFUJI Hideaki @USAGI : improved source address
39 * selection; consider scope,
40 * status etc.
38 */ 41 */
39 42
40#include <linux/config.h> 43#include <linux/config.h>
@@ -193,46 +196,51 @@ const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
193#endif 196#endif
194const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; 197const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
195 198
196int ipv6_addr_type(const struct in6_addr *addr) 199#define IPV6_ADDR_SCOPE_TYPE(scope) ((scope) << 16)
200
201static inline unsigned ipv6_addr_scope2type(unsigned scope)
202{
203 switch(scope) {
204 case IPV6_ADDR_SCOPE_NODELOCAL:
205 return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_NODELOCAL) |
206 IPV6_ADDR_LOOPBACK);
207 case IPV6_ADDR_SCOPE_LINKLOCAL:
208 return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL) |
209 IPV6_ADDR_LINKLOCAL);
210 case IPV6_ADDR_SCOPE_SITELOCAL:
211 return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL) |
212 IPV6_ADDR_SITELOCAL);
213 }
214 return IPV6_ADDR_SCOPE_TYPE(scope);
215}
216
217int __ipv6_addr_type(const struct in6_addr *addr)
197{ 218{
198 int type;
199 u32 st; 219 u32 st;
200 220
201 st = addr->s6_addr32[0]; 221 st = addr->s6_addr32[0];
202 222
203 if ((st & htonl(0xFF000000)) == htonl(0xFF000000)) {
204 type = IPV6_ADDR_MULTICAST;
205
206 switch((st & htonl(0x00FF0000))) {
207 case __constant_htonl(0x00010000):
208 type |= IPV6_ADDR_LOOPBACK;
209 break;
210
211 case __constant_htonl(0x00020000):
212 type |= IPV6_ADDR_LINKLOCAL;
213 break;
214
215 case __constant_htonl(0x00050000):
216 type |= IPV6_ADDR_SITELOCAL;
217 break;
218 };
219 return type;
220 }
221
222 type = IPV6_ADDR_UNICAST;
223
224 /* Consider all addresses with the first three bits different of 223 /* Consider all addresses with the first three bits different of
225 000 and 111 as finished. 224 000 and 111 as unicasts.
226 */ 225 */
227 if ((st & htonl(0xE0000000)) != htonl(0x00000000) && 226 if ((st & htonl(0xE0000000)) != htonl(0x00000000) &&
228 (st & htonl(0xE0000000)) != htonl(0xE0000000)) 227 (st & htonl(0xE0000000)) != htonl(0xE0000000))
229 return type; 228 return (IPV6_ADDR_UNICAST |
230 229 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));
231 if ((st & htonl(0xFFC00000)) == htonl(0xFE800000)) 230
232 return (IPV6_ADDR_LINKLOCAL | type); 231 if ((st & htonl(0xFF000000)) == htonl(0xFF000000)) {
232 /* multicast */
233 /* addr-select 3.1 */
234 return (IPV6_ADDR_MULTICAST |
235 ipv6_addr_scope2type(IPV6_ADDR_MC_SCOPE(addr)));
236 }
233 237
238 if ((st & htonl(0xFFC00000)) == htonl(0xFE800000))
239 return (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_UNICAST |
240 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL)); /* addr-select 3.1 */
234 if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000)) 241 if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000))
235 return (IPV6_ADDR_SITELOCAL | type); 242 return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST |
243 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL)); /* addr-select 3.1 */
236 244
237 if ((addr->s6_addr32[0] | addr->s6_addr32[1]) == 0) { 245 if ((addr->s6_addr32[0] | addr->s6_addr32[1]) == 0) {
238 if (addr->s6_addr32[2] == 0) { 246 if (addr->s6_addr32[2] == 0) {
@@ -240,24 +248,20 @@ int ipv6_addr_type(const struct in6_addr *addr)
240 return IPV6_ADDR_ANY; 248 return IPV6_ADDR_ANY;
241 249
242 if (addr->s6_addr32[3] == htonl(0x00000001)) 250 if (addr->s6_addr32[3] == htonl(0x00000001))
243 return (IPV6_ADDR_LOOPBACK | type); 251 return (IPV6_ADDR_LOOPBACK | IPV6_ADDR_UNICAST |
252 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL)); /* addr-select 3.4 */
244 253
245 return (IPV6_ADDR_COMPATv4 | type); 254 return (IPV6_ADDR_COMPATv4 | IPV6_ADDR_UNICAST |
255 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.3 */
246 } 256 }
247 257
248 if (addr->s6_addr32[2] == htonl(0x0000ffff)) 258 if (addr->s6_addr32[2] == htonl(0x0000ffff))
249 return IPV6_ADDR_MAPPED; 259 return (IPV6_ADDR_MAPPED |
260 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.3 */
250 } 261 }
251 262
252 st &= htonl(0xFF000000); 263 return (IPV6_ADDR_RESERVED |
253 if (st == 0) 264 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.4 */
254 return IPV6_ADDR_RESERVED;
255 st &= htonl(0xFE000000);
256 if (st == htonl(0x02000000))
257 return IPV6_ADDR_RESERVED; /* for NSAP */
258 if (st == htonl(0x04000000))
259 return IPV6_ADDR_RESERVED; /* for IPX */
260 return type;
261} 265}
262 266
263static void addrconf_del_timer(struct inet6_ifaddr *ifp) 267static void addrconf_del_timer(struct inet6_ifaddr *ifp)
@@ -805,138 +809,274 @@ out:
805#endif 809#endif
806 810
807/* 811/*
808 * Choose an appropriate source address 812 * Choose an appropriate source address (RFC3484)
809 * should do:
810 * i) get an address with an appropriate scope
811 * ii) see if there is a specific route for the destination and use
812 * an address of the attached interface
813 * iii) don't use deprecated addresses
814 */ 813 */
815static int inline ipv6_saddr_pref(const struct inet6_ifaddr *ifp, u8 invpref) 814struct ipv6_saddr_score {
815 int addr_type;
816 unsigned int attrs;
817 int matchlen;
818 unsigned int scope;
819 unsigned int rule;
820};
821
822#define IPV6_SADDR_SCORE_LOCAL 0x0001
823#define IPV6_SADDR_SCORE_PREFERRED 0x0004
824#define IPV6_SADDR_SCORE_HOA 0x0008
825#define IPV6_SADDR_SCORE_OIF 0x0010
826#define IPV6_SADDR_SCORE_LABEL 0x0020
827#define IPV6_SADDR_SCORE_PRIVACY 0x0040
828
829static int inline ipv6_saddr_preferred(int type)
816{ 830{
817 int pref; 831 if (type & (IPV6_ADDR_MAPPED|IPV6_ADDR_COMPATv4|
818 pref = ifp->flags&IFA_F_DEPRECATED ? 0 : 2; 832 IPV6_ADDR_LOOPBACK|IPV6_ADDR_RESERVED))
819#ifdef CONFIG_IPV6_PRIVACY 833 return 1;
820 pref |= (ifp->flags^invpref)&IFA_F_TEMPORARY ? 0 : 1; 834 return 0;
821#endif
822 return pref;
823} 835}
824 836
825#ifdef CONFIG_IPV6_PRIVACY 837/* static matching label */
826#define IPV6_GET_SADDR_MAXSCORE(score) ((score) == 3) 838static int inline ipv6_saddr_label(const struct in6_addr *addr, int type)
827#else 839{
828#define IPV6_GET_SADDR_MAXSCORE(score) (score) 840 /*
829#endif 841 * prefix (longest match) label
842 * -----------------------------
843 * ::1/128 0
844 * ::/0 1
845 * 2002::/16 2
846 * ::/96 3
847 * ::ffff:0:0/96 4
848 */
849 if (type & IPV6_ADDR_LOOPBACK)
850 return 0;
851 else if (type & IPV6_ADDR_COMPATv4)
852 return 3;
853 else if (type & IPV6_ADDR_MAPPED)
854 return 4;
855 else if (addr->s6_addr16[0] == htons(0x2002))
856 return 2;
857 return 1;
858}
830 859
831int ipv6_dev_get_saddr(struct net_device *dev, 860int ipv6_dev_get_saddr(struct net_device *daddr_dev,
832 struct in6_addr *daddr, struct in6_addr *saddr) 861 struct in6_addr *daddr, struct in6_addr *saddr)
833{ 862{
834 struct inet6_ifaddr *ifp = NULL; 863 struct ipv6_saddr_score hiscore;
835 struct inet6_ifaddr *match = NULL; 864 struct inet6_ifaddr *ifa_result = NULL;
836 struct inet6_dev *idev; 865 int daddr_type = __ipv6_addr_type(daddr);
837 int scope; 866 int daddr_scope = __ipv6_addr_src_scope(daddr_type);
838 int err; 867 u32 daddr_label = ipv6_saddr_label(daddr, daddr_type);
839 int hiscore = -1, score; 868 struct net_device *dev;
840 869
841 scope = ipv6_addr_scope(daddr); 870 memset(&hiscore, 0, sizeof(hiscore));
842 871
843 /* 872 read_lock(&dev_base_lock);
844 * known dev 873 read_lock(&addrconf_lock);
845 * search dev and walk through dev addresses
846 */
847 874
848 if (dev) { 875 for (dev = dev_base; dev; dev=dev->next) {
849 if (dev->flags & IFF_LOOPBACK) 876 struct inet6_dev *idev;
850 scope = IFA_HOST; 877 struct inet6_ifaddr *ifa;
878
879 /* Rule 0: Candidate Source Address (section 4)
880 * - multicast and link-local destination address,
881 * the set of candidate source address MUST only
882 * include addresses assigned to interfaces
883 * belonging to the same link as the outgoing
884 * interface.
885 * (- For site-local destination addresses, the
886 * set of candidate source addresses MUST only
887 * include addresses assigned to interfaces
888 * belonging to the same site as the outgoing
889 * interface.)
890 */
891 if ((daddr_type & IPV6_ADDR_MULTICAST ||
892 daddr_scope <= IPV6_ADDR_SCOPE_LINKLOCAL) &&
893 daddr_dev && dev != daddr_dev)
894 continue;
851 895
852 read_lock(&addrconf_lock);
853 idev = __in6_dev_get(dev); 896 idev = __in6_dev_get(dev);
854 if (idev) { 897 if (!idev)
855 read_lock_bh(&idev->lock); 898 continue;
856 for (ifp=idev->addr_list; ifp; ifp=ifp->if_next) {
857 if (ifp->scope == scope) {
858 if (ifp->flags&IFA_F_TENTATIVE)
859 continue;
860#ifdef CONFIG_IPV6_PRIVACY
861 score = ipv6_saddr_pref(ifp, idev->cnf.use_tempaddr > 1 ? IFA_F_TEMPORARY : 0);
862#else
863 score = ipv6_saddr_pref(ifp, 0);
864#endif
865 if (score <= hiscore)
866 continue;
867 899
868 if (match) 900 read_lock_bh(&idev->lock);
869 in6_ifa_put(match); 901 for (ifa = idev->addr_list; ifa; ifa = ifa->if_next) {
870 match = ifp; 902 struct ipv6_saddr_score score;
871 hiscore = score;
872 in6_ifa_hold(ifp);
873 903
874 if (IPV6_GET_SADDR_MAXSCORE(score)) { 904 score.addr_type = __ipv6_addr_type(&ifa->addr);
875 read_unlock_bh(&idev->lock); 905
876 read_unlock(&addrconf_lock); 906 /* Rule 0: Candidate Source Address (section 4)
877 goto out; 907 * - In any case, anycast addresses, multicast
878 } 908 * addresses, and the unspecified address MUST
909 * NOT be included in a candidate set.
910 */
911 if (unlikely(score.addr_type == IPV6_ADDR_ANY ||
912 score.addr_type & IPV6_ADDR_MULTICAST)) {
913 LIMIT_NETDEBUG(KERN_DEBUG
914 "ADDRCONF: unspecified / multicast address"
915 "assigned as unicast address on %s",
916 dev->name);
917 continue;
918 }
919
920 score.attrs = 0;
921 score.matchlen = 0;
922 score.scope = 0;
923 score.rule = 0;
924
925 if (ifa_result == NULL) {
926 /* record it if the first available entry */
927 goto record_it;
928 }
929
930 /* Rule 1: Prefer same address */
931 if (hiscore.rule < 1) {
932 if (ipv6_addr_equal(&ifa_result->addr, daddr))
933 hiscore.attrs |= IPV6_SADDR_SCORE_LOCAL;
934 hiscore.rule++;
935 }
936 if (ipv6_addr_equal(&ifa->addr, daddr)) {
937 score.attrs |= IPV6_SADDR_SCORE_LOCAL;
938 if (!(hiscore.attrs & IPV6_SADDR_SCORE_LOCAL)) {
939 score.rule = 1;
940 goto record_it;
879 } 941 }
942 } else {
943 if (hiscore.attrs & IPV6_SADDR_SCORE_LOCAL)
944 continue;
880 } 945 }
881 read_unlock_bh(&idev->lock);
882 }
883 read_unlock(&addrconf_lock);
884 }
885 946
886 if (scope == IFA_LINK) 947 /* Rule 2: Prefer appropriate scope */
887 goto out; 948 if (hiscore.rule < 2) {
949 hiscore.scope = __ipv6_addr_src_scope(hiscore.addr_type);
950 hiscore.rule++;
951 }
952 score.scope = __ipv6_addr_src_scope(score.addr_type);
953 if (hiscore.scope < score.scope) {
954 if (hiscore.scope < daddr_scope) {
955 score.rule = 2;
956 goto record_it;
957 } else
958 continue;
959 } else if (score.scope < hiscore.scope) {
960 if (score.scope < daddr_scope)
961 continue;
962 else {
963 score.rule = 2;
964 goto record_it;
965 }
966 }
888 967
889 /* 968 /* Rule 3: Avoid deprecated address */
890 * dev == NULL or search failed for specified dev 969 if (hiscore.rule < 3) {
891 */ 970 if (ipv6_saddr_preferred(hiscore.addr_type) ||
971 !(ifa_result->flags & IFA_F_DEPRECATED))
972 hiscore.attrs |= IPV6_SADDR_SCORE_PREFERRED;
973 hiscore.rule++;
974 }
975 if (ipv6_saddr_preferred(score.addr_type) ||
976 !(ifa->flags & IFA_F_DEPRECATED)) {
977 score.attrs |= IPV6_SADDR_SCORE_PREFERRED;
978 if (!(hiscore.attrs & IPV6_SADDR_SCORE_PREFERRED)) {
979 score.rule = 3;
980 goto record_it;
981 }
982 } else {
983 if (hiscore.attrs & IPV6_SADDR_SCORE_PREFERRED)
984 continue;
985 }
892 986
893 read_lock(&dev_base_lock); 987 /* Rule 4: Prefer home address -- not implemented yet */
894 read_lock(&addrconf_lock);
895 for (dev = dev_base; dev; dev=dev->next) {
896 idev = __in6_dev_get(dev);
897 if (idev) {
898 read_lock_bh(&idev->lock);
899 for (ifp=idev->addr_list; ifp; ifp=ifp->if_next) {
900 if (ifp->scope == scope) {
901 if (ifp->flags&IFA_F_TENTATIVE)
902 continue;
903#ifdef CONFIG_IPV6_PRIVACY
904 score = ipv6_saddr_pref(ifp, idev->cnf.use_tempaddr > 1 ? IFA_F_TEMPORARY : 0);
905#else
906 score = ipv6_saddr_pref(ifp, 0);
907#endif
908 if (score <= hiscore)
909 continue;
910 988
911 if (match) 989 /* Rule 5: Prefer outgoing interface */
912 in6_ifa_put(match); 990 if (hiscore.rule < 5) {
913 match = ifp; 991 if (daddr_dev == NULL ||
914 hiscore = score; 992 daddr_dev == ifa_result->idev->dev)
915 in6_ifa_hold(ifp); 993 hiscore.attrs |= IPV6_SADDR_SCORE_OIF;
994 hiscore.rule++;
995 }
996 if (daddr_dev == NULL ||
997 daddr_dev == ifa->idev->dev) {
998 score.attrs |= IPV6_SADDR_SCORE_OIF;
999 if (!(hiscore.attrs & IPV6_SADDR_SCORE_OIF)) {
1000 score.rule = 5;
1001 goto record_it;
1002 }
1003 } else {
1004 if (hiscore.attrs & IPV6_SADDR_SCORE_OIF)
1005 continue;
1006 }
916 1007
917 if (IPV6_GET_SADDR_MAXSCORE(score)) { 1008 /* Rule 6: Prefer matching label */
918 read_unlock_bh(&idev->lock); 1009 if (hiscore.rule < 6) {
919 goto out_unlock_base; 1010 if (ipv6_saddr_label(&ifa_result->addr, hiscore.addr_type) == daddr_label)
920 } 1011 hiscore.attrs |= IPV6_SADDR_SCORE_LABEL;
1012 hiscore.rule++;
1013 }
1014 if (ipv6_saddr_label(&ifa->addr, score.addr_type) == daddr_label) {
1015 score.attrs |= IPV6_SADDR_SCORE_LABEL;
1016 if (!(hiscore.attrs & IPV6_SADDR_SCORE_LABEL)) {
1017 score.rule = 6;
1018 goto record_it;
1019 }
1020 } else {
1021 if (hiscore.attrs & IPV6_SADDR_SCORE_LABEL)
1022 continue;
1023 }
1024
1025 /* Rule 7: Prefer public address
1026 * Note: prefer temprary address if use_tempaddr >= 2
1027 */
1028 if (hiscore.rule < 7) {
1029 if ((!(ifa_result->flags & IFA_F_TEMPORARY)) ^
1030 (ifa_result->idev->cnf.use_tempaddr >= 2))
1031 hiscore.attrs |= IPV6_SADDR_SCORE_PRIVACY;
1032 hiscore.rule++;
1033 }
1034 if ((!(ifa->flags & IFA_F_TEMPORARY)) ^
1035 (ifa->idev->cnf.use_tempaddr >= 2)) {
1036 score.attrs |= IPV6_SADDR_SCORE_PRIVACY;
1037 if (!(hiscore.attrs & IPV6_SADDR_SCORE_PRIVACY)) {
1038 score.rule = 7;
1039 goto record_it;
921 } 1040 }
1041 } else {
1042 if (hiscore.attrs & IPV6_SADDR_SCORE_PRIVACY)
1043 continue;
922 } 1044 }
923 read_unlock_bh(&idev->lock); 1045
1046 /* Rule 8: Use longest matching prefix */
1047 if (hiscore.rule < 8)
1048 hiscore.matchlen = ipv6_addr_diff(&ifa_result->addr, daddr);
1049 score.rule++;
1050 score.matchlen = ipv6_addr_diff(&ifa->addr, daddr);
1051 if (score.matchlen > hiscore.matchlen) {
1052 score.rule = 8;
1053 goto record_it;
1054 }
1055#if 0
1056 else if (score.matchlen < hiscore.matchlen)
1057 continue;
1058#endif
1059
1060 /* Final Rule: choose first available one */
1061 continue;
1062record_it:
1063 if (ifa_result)
1064 in6_ifa_put(ifa_result);
1065 in6_ifa_hold(ifa);
1066 ifa_result = ifa;
1067 hiscore = score;
924 } 1068 }
1069 read_unlock_bh(&idev->lock);
925 } 1070 }
926
927out_unlock_base:
928 read_unlock(&addrconf_lock); 1071 read_unlock(&addrconf_lock);
929 read_unlock(&dev_base_lock); 1072 read_unlock(&dev_base_lock);
930 1073
931out: 1074 if (!ifa_result)
932 err = -EADDRNOTAVAIL; 1075 return -EADDRNOTAVAIL;
933 if (match) { 1076
934 ipv6_addr_copy(saddr, &match->addr); 1077 ipv6_addr_copy(saddr, &ifa_result->addr);
935 err = 0; 1078 in6_ifa_put(ifa_result);
936 in6_ifa_put(match); 1079 return 0;
937 }
938
939 return err;
940} 1080}
941 1081
942 1082
@@ -2950,8 +3090,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
2950 3090
2951nlmsg_failure: 3091nlmsg_failure:
2952rtattr_failure: 3092rtattr_failure:
2953 if (array) 3093 kfree(array);
2954 kfree(array);
2955 skb_trim(skb, b - skb->data); 3094 skb_trim(skb, b - skb->data);
2956 return -1; 3095 return -1;
2957} 3096}
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 4fcc5a7acf6e..1bf6d9a769e6 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -127,56 +127,6 @@ static __inline__ int addr_bit_set(void *token, int fn_bit)
127 return htonl(1 << ((~fn_bit)&0x1F)) & addr[fn_bit>>5]; 127 return htonl(1 << ((~fn_bit)&0x1F)) & addr[fn_bit>>5];
128} 128}
129 129
130/*
131 * find the first different bit between two addresses
132 * length of address must be a multiple of 32bits
133 */
134
135static __inline__ int addr_diff(void *token1, void *token2, int addrlen)
136{
137 __u32 *a1 = token1;
138 __u32 *a2 = token2;
139 int i;
140
141 addrlen >>= 2;
142
143 for (i = 0; i < addrlen; i++) {
144 __u32 xb;
145
146 xb = a1[i] ^ a2[i];
147
148 if (xb) {
149 int j = 31;
150
151 xb = ntohl(xb);
152
153 while ((xb & (1 << j)) == 0)
154 j--;
155
156 return (i * 32 + 31 - j);
157 }
158 }
159
160 /*
161 * we should *never* get to this point since that
162 * would mean the addrs are equal
163 *
164 * However, we do get to it 8) And exacly, when
165 * addresses are equal 8)
166 *
167 * ip route add 1111::/128 via ...
168 * ip route add 1111::/64 via ...
169 * and we are here.
170 *
171 * Ideally, this function should stop comparison
172 * at prefix length. It does not, but it is still OK,
173 * if returned value is greater than prefix length.
174 * --ANK (980803)
175 */
176
177 return addrlen<<5;
178}
179
180static __inline__ struct fib6_node * node_alloc(void) 130static __inline__ struct fib6_node * node_alloc(void)
181{ 131{
182 struct fib6_node *fn; 132 struct fib6_node *fn;
@@ -296,11 +246,11 @@ insert_above:
296 246
297 /* find 1st bit in difference between the 2 addrs. 247 /* find 1st bit in difference between the 2 addrs.
298 248
299 See comment in addr_diff: bit may be an invalid value, 249 See comment in __ipv6_addr_diff: bit may be an invalid value,
300 but if it is >= plen, the value is ignored in any case. 250 but if it is >= plen, the value is ignored in any case.
301 */ 251 */
302 252
303 bit = addr_diff(addr, &key->addr, addrlen); 253 bit = __ipv6_addr_diff(addr, &key->addr, addrlen);
304 254
305 /* 255 /*
306 * (intermediate)[in] 256 * (intermediate)[in]
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 614296a920c6..dbd9767b32e4 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -587,8 +587,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
587 skb->next = NULL; 587 skb->next = NULL;
588 } 588 }
589 589
590 if (tmp_hdr) 590 kfree(tmp_hdr);
591 kfree(tmp_hdr);
592 591
593 if (err == 0) { 592 if (err == 0) {
594 IP6_INC_STATS(IPSTATS_MIB_FRAGOKS); 593 IP6_INC_STATS(IPSTATS_MIB_FRAGOKS);
@@ -1186,10 +1185,8 @@ int ip6_push_pending_frames(struct sock *sk)
1186 1185
1187out: 1186out:
1188 inet->cork.flags &= ~IPCORK_OPT; 1187 inet->cork.flags &= ~IPCORK_OPT;
1189 if (np->cork.opt) { 1188 kfree(np->cork.opt);
1190 kfree(np->cork.opt); 1189 np->cork.opt = NULL;
1191 np->cork.opt = NULL;
1192 }
1193 if (np->cork.rt) { 1190 if (np->cork.rt) {
1194 dst_release(&np->cork.rt->u.dst); 1191 dst_release(&np->cork.rt->u.dst);
1195 np->cork.rt = NULL; 1192 np->cork.rt = NULL;
@@ -1214,10 +1211,8 @@ void ip6_flush_pending_frames(struct sock *sk)
1214 1211
1215 inet->cork.flags &= ~IPCORK_OPT; 1212 inet->cork.flags &= ~IPCORK_OPT;
1216 1213
1217 if (np->cork.opt) { 1214 kfree(np->cork.opt);
1218 kfree(np->cork.opt); 1215 np->cork.opt = NULL;
1219 np->cork.opt = NULL;
1220 }
1221 if (np->cork.rt) { 1216 if (np->cork.rt) {
1222 dst_release(&np->cork.rt->u.dst); 1217 dst_release(&np->cork.rt->u.dst);
1223 np->cork.rt = NULL; 1218 np->cork.rt = NULL;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index cf94372d1af3..e6b0e3954c02 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -756,8 +756,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
756 } 756 }
757 ip6_tnl_dst_store(t, dst); 757 ip6_tnl_dst_store(t, dst);
758 758
759 if (opt) 759 kfree(opt);
760 kfree(opt);
761 760
762 t->recursion--; 761 t->recursion--;
763 return 0; 762 return 0;
@@ -766,8 +765,7 @@ tx_err_link_failure:
766 dst_link_failure(skb); 765 dst_link_failure(skb);
767tx_err_dst_release: 766tx_err_dst_release:
768 dst_release(dst); 767 dst_release(dst);
769 if (opt) 768 kfree(opt);
770 kfree(opt);
771tx_err: 769tx_err:
772 stats->tx_errors++; 770 stats->tx_errors++;
773 stats->tx_dropped++; 771 stats->tx_dropped++;
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 85bfbc69b2c3..55917fb17094 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -130,8 +130,7 @@ static int ipcomp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, s
130out_put_cpu: 130out_put_cpu:
131 put_cpu(); 131 put_cpu();
132out: 132out:
133 if (tmp_hdr) 133 kfree(tmp_hdr);
134 kfree(tmp_hdr);
135 if (err) 134 if (err)
136 goto error_out; 135 goto error_out;
137 return nexthdr; 136 return nexthdr;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 8567873d0dd8..003fd99ff597 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -80,8 +80,7 @@ int ip6_ra_control(struct sock *sk, int sel, void (*destructor)(struct sock *))
80 if (ra->sk == sk) { 80 if (ra->sk == sk) {
81 if (sel>=0) { 81 if (sel>=0) {
82 write_unlock_bh(&ip6_ra_lock); 82 write_unlock_bh(&ip6_ra_lock);
83 if (new_ra) 83 kfree(new_ra);
84 kfree(new_ra);
85 return -EADDRINUSE; 84 return -EADDRINUSE;
86 } 85 }
87 86
diff --git a/net/ipv6/ipv6_syms.c b/net/ipv6/ipv6_syms.c
index 37a4a99c9fe9..16482785bdfd 100644
--- a/net/ipv6/ipv6_syms.c
+++ b/net/ipv6/ipv6_syms.c
@@ -7,7 +7,7 @@
7#include <net/ip6_route.h> 7#include <net/ip6_route.h>
8#include <net/xfrm.h> 8#include <net/xfrm.h>
9 9
10EXPORT_SYMBOL(ipv6_addr_type); 10EXPORT_SYMBOL(__ipv6_addr_type);
11EXPORT_SYMBOL(icmpv6_send); 11EXPORT_SYMBOL(icmpv6_send);
12EXPORT_SYMBOL(icmpv6_statistics); 12EXPORT_SYMBOL(icmpv6_statistics);
13EXPORT_SYMBOL(icmpv6_err_convert); 13EXPORT_SYMBOL(icmpv6_err_convert);
diff --git a/net/irda/discovery.c b/net/irda/discovery.c
index c4ba5fa1446a..3fefc822c1c0 100644
--- a/net/irda/discovery.c
+++ b/net/irda/discovery.c
@@ -194,8 +194,7 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force)
194 194
195 /* Remove it from the log */ 195 /* Remove it from the log */
196 curr = hashbin_remove_this(log, (irda_queue_t *) curr); 196 curr = hashbin_remove_this(log, (irda_queue_t *) curr);
197 if (curr) 197 kfree(curr);
198 kfree(curr);
199 } 198 }
200 } 199 }
201 200
diff --git a/net/irda/irias_object.c b/net/irda/irias_object.c
index 6fec428b4512..75f2666e8630 100644
--- a/net/irda/irias_object.c
+++ b/net/irda/irias_object.c
@@ -122,8 +122,7 @@ static void __irias_delete_attrib(struct ias_attrib *attrib)
122 IRDA_ASSERT(attrib != NULL, return;); 122 IRDA_ASSERT(attrib != NULL, return;);
123 IRDA_ASSERT(attrib->magic == IAS_ATTRIB_MAGIC, return;); 123 IRDA_ASSERT(attrib->magic == IAS_ATTRIB_MAGIC, return;);
124 124
125 if (attrib->name) 125 kfree(attrib->name);
126 kfree(attrib->name);
127 126
128 irias_delete_value(attrib->value); 127 irias_delete_value(attrib->value);
129 attrib->magic = ~IAS_ATTRIB_MAGIC; 128 attrib->magic = ~IAS_ATTRIB_MAGIC;
@@ -136,8 +135,7 @@ void __irias_delete_object(struct ias_object *obj)
136 IRDA_ASSERT(obj != NULL, return;); 135 IRDA_ASSERT(obj != NULL, return;);
137 IRDA_ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;); 136 IRDA_ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;);
138 137
139 if (obj->name) 138 kfree(obj->name);
140 kfree(obj->name);
141 139
142 hashbin_delete(obj->attribs, (FREE_FUNC) __irias_delete_attrib); 140 hashbin_delete(obj->attribs, (FREE_FUNC) __irias_delete_attrib);
143 141
@@ -562,14 +560,12 @@ void irias_delete_value(struct ias_value *value)
562 /* No need to deallocate */ 560 /* No need to deallocate */
563 break; 561 break;
564 case IAS_STRING: 562 case IAS_STRING:
565 /* If string, deallocate string */ 563 /* Deallocate string */
566 if (value->t.string != NULL) 564 kfree(value->t.string);
567 kfree(value->t.string);
568 break; 565 break;
569 case IAS_OCT_SEQ: 566 case IAS_OCT_SEQ:
570 /* If byte stream, deallocate byte stream */ 567 /* Deallocate byte stream */
571 if (value->t.oct_seq != NULL) 568 kfree(value->t.oct_seq);
572 kfree(value->t.oct_seq);
573 break; 569 break;
574 default: 570 default:
575 IRDA_DEBUG(0, "%s(), Unknown value type!\n", __FUNCTION__); 571 IRDA_DEBUG(0, "%s(), Unknown value type!\n", __FUNCTION__);
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index b18fe5043019..8631b65a7312 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -240,8 +240,7 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh)
240 if ((s = rose_neigh_list) == rose_neigh) { 240 if ((s = rose_neigh_list) == rose_neigh) {
241 rose_neigh_list = rose_neigh->next; 241 rose_neigh_list = rose_neigh->next;
242 spin_unlock_bh(&rose_neigh_list_lock); 242 spin_unlock_bh(&rose_neigh_list_lock);
243 if (rose_neigh->digipeat != NULL) 243 kfree(rose_neigh->digipeat);
244 kfree(rose_neigh->digipeat);
245 kfree(rose_neigh); 244 kfree(rose_neigh);
246 return; 245 return;
247 } 246 }
@@ -250,8 +249,7 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh)
250 if (s->next == rose_neigh) { 249 if (s->next == rose_neigh) {
251 s->next = rose_neigh->next; 250 s->next = rose_neigh->next;
252 spin_unlock_bh(&rose_neigh_list_lock); 251 spin_unlock_bh(&rose_neigh_list_lock);
253 if (rose_neigh->digipeat != NULL) 252 kfree(rose_neigh->digipeat);
254 kfree(rose_neigh->digipeat);
255 kfree(rose_neigh); 253 kfree(rose_neigh);
256 return; 254 return;
257 } 255 }
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index 29d8b9a4d162..75470486e405 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -298,8 +298,7 @@ static int fw_change(struct tcf_proto *tp, unsigned long base,
298 return 0; 298 return 0;
299 299
300errout: 300errout:
301 if (f) 301 kfree(f);
302 kfree(f);
303 return err; 302 return err;
304} 303}
305 304
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
index 02996ac05c75..520ff716dab2 100644
--- a/net/sched/cls_route.c
+++ b/net/sched/cls_route.c
@@ -525,8 +525,7 @@ reinsert:
525 return 0; 525 return 0;
526 526
527errout: 527errout:
528 if (f) 528 kfree(f);
529 kfree(f);
530 return err; 529 return err;
531} 530}
532 531
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h
index 006168d69376..572f06be3b02 100644
--- a/net/sched/cls_rsvp.h
+++ b/net/sched/cls_rsvp.h
@@ -555,8 +555,7 @@ insert:
555 goto insert; 555 goto insert;
556 556
557errout: 557errout:
558 if (f) 558 kfree(f);
559 kfree(f);
560errout2: 559errout2:
561 tcf_exts_destroy(tp, &e); 560 tcf_exts_destroy(tp, &e);
562 return err; 561 return err;
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 404d9d83a7fa..9f921174c8ab 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -194,8 +194,7 @@ found:
194 } 194 }
195 tcf_unbind_filter(tp, &r->res); 195 tcf_unbind_filter(tp, &r->res);
196 tcf_exts_destroy(tp, &r->exts); 196 tcf_exts_destroy(tp, &r->exts);
197 if (f) 197 kfree(f);
198 kfree(f);
199 return 0; 198 return 0;
200} 199}
201 200
@@ -442,10 +441,8 @@ static void tcindex_destroy(struct tcf_proto *tp)
442 walker.skip = 0; 441 walker.skip = 0;
443 walker.fn = &tcindex_destroy_element; 442 walker.fn = &tcindex_destroy_element;
444 tcindex_walk(tp,&walker); 443 tcindex_walk(tp,&walker);
445 if (p->perfect) 444 kfree(p->perfect);
446 kfree(p->perfect); 445 kfree(p->h);
447 if (p->h)
448 kfree(p->h);
449 kfree(p); 446 kfree(p);
450 tp->root = NULL; 447 tp->root = NULL;
451} 448}
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 364b87d86455..2b670479dde1 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -347,7 +347,7 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n)
347 if (n->ht_down) 347 if (n->ht_down)
348 n->ht_down->refcnt--; 348 n->ht_down->refcnt--;
349#ifdef CONFIG_CLS_U32_PERF 349#ifdef CONFIG_CLS_U32_PERF
350 if (n && (NULL != n->pf)) 350 if (n)
351 kfree(n->pf); 351 kfree(n->pf);
352#endif 352#endif
353 kfree(n); 353 kfree(n);
@@ -680,7 +680,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
680 return 0; 680 return 0;
681 } 681 }
682#ifdef CONFIG_CLS_U32_PERF 682#ifdef CONFIG_CLS_U32_PERF
683 if (n && (NULL != n->pf)) 683 if (n)
684 kfree(n->pf); 684 kfree(n->pf);
685#endif 685#endif
686 kfree(n); 686 kfree(n);
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index cf68a59fdc5a..700844d49d79 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -561,8 +561,7 @@ static int meta_var_change(struct meta_value *dst, struct rtattr *rta)
561 561
562static void meta_var_destroy(struct meta_value *v) 562static void meta_var_destroy(struct meta_value *v)
563{ 563{
564 if (v->val) 564 kfree((void *) v->val);
565 kfree((void *) v->val);
566} 565}
567 566
568static void meta_var_apply_extras(struct meta_value *v, 567static void meta_var_apply_extras(struct meta_value *v,
diff --git a/net/sched/ematch.c b/net/sched/ematch.c
index ebfe2e7d21bd..64b047c65568 100644
--- a/net/sched/ematch.c
+++ b/net/sched/ematch.c
@@ -298,6 +298,11 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct rtattr *rta,
298 struct tcf_ematch_tree_hdr *tree_hdr; 298 struct tcf_ematch_tree_hdr *tree_hdr;
299 struct tcf_ematch *em; 299 struct tcf_ematch *em;
300 300
301 if (!rta) {
302 memset(tree, 0, sizeof(*tree));
303 return 0;
304 }
305
301 if (rtattr_parse_nested(tb, TCA_EMATCH_TREE_MAX, rta) < 0) 306 if (rtattr_parse_nested(tb, TCA_EMATCH_TREE_MAX, rta) < 0)
302 goto errout; 307 goto errout;
303 308
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 12b0f582a66b..8c8ddf7f9b61 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -344,9 +344,7 @@ void sctp_association_free(struct sctp_association *asoc)
344 } 344 }
345 345
346 /* Free peer's cached cookie. */ 346 /* Free peer's cached cookie. */
347 if (asoc->peer.cookie) { 347 kfree(asoc->peer.cookie);
348 kfree(asoc->peer.cookie);
349 }
350 348
351 /* Release the transport structures. */ 349 /* Release the transport structures. */
352 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { 350 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 660c61bdf164..f9573eba5c7a 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -254,8 +254,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
254 aiparam.adaption_ind = htonl(sp->adaption_ind); 254 aiparam.adaption_ind = htonl(sp->adaption_ind);
255 sctp_addto_chunk(retval, sizeof(aiparam), &aiparam); 255 sctp_addto_chunk(retval, sizeof(aiparam), &aiparam);
256nodata: 256nodata:
257 if (addrs.v) 257 kfree(addrs.v);
258 kfree(addrs.v);
259 return retval; 258 return retval;
260} 259}
261 260
@@ -347,8 +346,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
347nomem_chunk: 346nomem_chunk:
348 kfree(cookie); 347 kfree(cookie);
349nomem_cookie: 348nomem_cookie:
350 if (addrs.v) 349 kfree(addrs.v);
351 kfree(addrs.v);
352 return retval; 350 return retval;
353} 351}
354 352
diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c
index 13f8ae979454..d0dfdfd5e79e 100644
--- a/net/sunrpc/auth_gss/gss_krb5_seal.c
+++ b/net/sunrpc/auth_gss/gss_krb5_seal.c
@@ -143,6 +143,6 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
143 143
144 return ((ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE); 144 return ((ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE);
145out_err: 145out_err:
146 if (md5cksum.data) kfree(md5cksum.data); 146 kfree(md5cksum.data);
147 return GSS_S_FAILURE; 147 return GSS_S_FAILURE;
148} 148}
diff --git a/net/sunrpc/auth_gss/gss_krb5_unseal.c b/net/sunrpc/auth_gss/gss_krb5_unseal.c
index 2030475d98ed..db055fd7d778 100644
--- a/net/sunrpc/auth_gss/gss_krb5_unseal.c
+++ b/net/sunrpc/auth_gss/gss_krb5_unseal.c
@@ -176,6 +176,6 @@ gss_verify_mic_kerberos(struct gss_ctx *gss_ctx,
176 176
177 ret = GSS_S_COMPLETE; 177 ret = GSS_S_COMPLETE;
178out: 178out:
179 if (md5cksum.data) kfree(md5cksum.data); 179 kfree(md5cksum.data);
180 return ret; 180 return ret;
181} 181}
diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c
index b048bf672da2..f8bac6ccd524 100644
--- a/net/sunrpc/auth_gss/gss_mech_switch.c
+++ b/net/sunrpc/auth_gss/gss_mech_switch.c
@@ -60,8 +60,7 @@ gss_mech_free(struct gss_api_mech *gm)
60 60
61 for (i = 0; i < gm->gm_pf_num; i++) { 61 for (i = 0; i < gm->gm_pf_num; i++) {
62 pf = &gm->gm_pfs[i]; 62 pf = &gm->gm_pfs[i];
63 if (pf->auth_domain_name) 63 kfree(pf->auth_domain_name);
64 kfree(pf->auth_domain_name);
65 pf->auth_domain_name = NULL; 64 pf->auth_domain_name = NULL;
66 } 65 }
67} 66}
diff --git a/net/sunrpc/auth_gss/gss_spkm3_seal.c b/net/sunrpc/auth_gss/gss_spkm3_seal.c
index 148201e929d0..d1e12b25d6e2 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_seal.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_seal.c
@@ -122,8 +122,7 @@ spkm3_make_token(struct spkm3_ctx *ctx,
122 122
123 return GSS_S_COMPLETE; 123 return GSS_S_COMPLETE;
124out_err: 124out_err:
125 if (md5cksum.data) 125 kfree(md5cksum.data);
126 kfree(md5cksum.data);
127 token->data = NULL; 126 token->data = NULL;
128 token->len = 0; 127 token->len = 0;
129 return GSS_S_FAILURE; 128 return GSS_S_FAILURE;
diff --git a/net/sunrpc/auth_gss/gss_spkm3_token.c b/net/sunrpc/auth_gss/gss_spkm3_token.c
index 46c08a0710f6..1f824578d773 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_token.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_token.c
@@ -259,8 +259,7 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck
259 259
260 ret = GSS_S_COMPLETE; 260 ret = GSS_S_COMPLETE;
261out: 261out:
262 if (spkm3_ctx_id.data) 262 kfree(spkm3_ctx_id.data);
263 kfree(spkm3_ctx_id.data);
264 return ret; 263 return ret;
265} 264}
266 265
diff --git a/net/sunrpc/auth_gss/gss_spkm3_unseal.c b/net/sunrpc/auth_gss/gss_spkm3_unseal.c
index c3c0d9586103..241d5b30dfcb 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_unseal.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_unseal.c
@@ -120,9 +120,7 @@ spkm3_read_token(struct spkm3_ctx *ctx,
120 /* XXX: need to add expiration and sequencing */ 120 /* XXX: need to add expiration and sequencing */
121 ret = GSS_S_COMPLETE; 121 ret = GSS_S_COMPLETE;
122out: 122out:
123 if (md5cksum.data) 123 kfree(md5cksum.data);
124 kfree(md5cksum.data); 124 kfree(wire_cksum.data);
125 if (wire_cksum.data)
126 kfree(wire_cksum.data);
127 return ret; 125 return ret;
128} 126}
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 5a220b2bb376..e4296c8b861e 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -196,12 +196,9 @@ svc_exit_thread(struct svc_rqst *rqstp)
196 struct svc_serv *serv = rqstp->rq_server; 196 struct svc_serv *serv = rqstp->rq_server;
197 197
198 svc_release_buffer(rqstp); 198 svc_release_buffer(rqstp);
199 if (rqstp->rq_resp) 199 kfree(rqstp->rq_resp);
200 kfree(rqstp->rq_resp); 200 kfree(rqstp->rq_argp);
201 if (rqstp->rq_argp) 201 kfree(rqstp->rq_auth_data);
202 kfree(rqstp->rq_argp);
203 if (rqstp->rq_auth_data)
204 kfree(rqstp->rq_auth_data);
205 kfree(rqstp); 202 kfree(rqstp);
206 203
207 /* Release the server */ 204 /* Release the server */
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 32df43372ee9..aaf08cdd19f0 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -992,8 +992,7 @@ xdr_xcode_array2(struct xdr_buf *buf, unsigned int base,
992 err = 0; 992 err = 0;
993 993
994out: 994out:
995 if (elem) 995 kfree(elem);
996 kfree(elem);
997 if (ppages) 996 if (ppages)
998 kunmap(*ppages); 997 kunmap(*ppages);
999 return err; 998 return err;
diff --git a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c
index 596cb96e5f47..59fec59b2132 100644
--- a/net/wanrouter/af_wanpipe.c
+++ b/net/wanrouter/af_wanpipe.c
@@ -1099,7 +1099,7 @@ static void release_driver(struct sock *sk)
1099 sock_reset_flag(sk, SOCK_ZAPPED); 1099 sock_reset_flag(sk, SOCK_ZAPPED);
1100 wp = wp_sk(sk); 1100 wp = wp_sk(sk);
1101 1101
1102 if (wp && wp->mbox) { 1102 if (wp) {
1103 kfree(wp->mbox); 1103 kfree(wp->mbox);
1104 wp->mbox = NULL; 1104 wp->mbox = NULL;
1105 } 1105 }
@@ -1186,10 +1186,8 @@ static void wanpipe_kill_sock_timer (unsigned long data)
1186 return; 1186 return;
1187 } 1187 }
1188 1188
1189 if (wp_sk(sk)) { 1189 kfree(wp_sk(sk));
1190 kfree(wp_sk(sk)); 1190 wp_sk(sk) = NULL;
1191 wp_sk(sk) = NULL;
1192 }
1193 1191
1194 if (atomic_read(&sk->sk_refcnt) != 1) { 1192 if (atomic_read(&sk->sk_refcnt) != 1) {
1195 atomic_set(&sk->sk_refcnt, 1); 1193 atomic_set(&sk->sk_refcnt, 1);
@@ -1219,10 +1217,8 @@ static void wanpipe_kill_sock_accept (struct sock *sk)
1219 sk->sk_socket = NULL; 1217 sk->sk_socket = NULL;
1220 1218
1221 1219
1222 if (wp_sk(sk)) { 1220 kfree(wp_sk(sk));
1223 kfree(wp_sk(sk)); 1221 wp_sk(sk) = NULL;
1224 wp_sk(sk) = NULL;
1225 }
1226 1222
1227 if (atomic_read(&sk->sk_refcnt) != 1) { 1223 if (atomic_read(&sk->sk_refcnt) != 1) {
1228 atomic_set(&sk->sk_refcnt, 1); 1224 atomic_set(&sk->sk_refcnt, 1);
@@ -1243,10 +1239,8 @@ static void wanpipe_kill_sock_irq (struct sock *sk)
1243 1239
1244 sk->sk_socket = NULL; 1240 sk->sk_socket = NULL;
1245 1241
1246 if (wp_sk(sk)) { 1242 kfree(wp_sk(sk));
1247 kfree(wp_sk(sk)); 1243 wp_sk(sk) = NULL;
1248 wp_sk(sk) = NULL;
1249 }
1250 1244
1251 if (atomic_read(&sk->sk_refcnt) != 1) { 1245 if (atomic_read(&sk->sk_refcnt) != 1) {
1252 atomic_set(&sk->sk_refcnt, 1); 1246 atomic_set(&sk->sk_refcnt, 1);
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
index 13b650ad22e2..bcf7b3faa76a 100644
--- a/net/wanrouter/wanmain.c
+++ b/net/wanrouter/wanmain.c
@@ -714,10 +714,8 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
714 } 714 }
715 715
716 /* This code has moved from del_if() function */ 716 /* This code has moved from del_if() function */
717 if (dev->priv) { 717 kfree(dev->priv);
718 kfree(dev->priv); 718 dev->priv = NULL;
719 dev->priv = NULL;
720 }
721 719
722#ifdef CONFIG_WANPIPE_MULTPPP 720#ifdef CONFIG_WANPIPE_MULTPPP
723 if (cnf->config_id == WANCONFIG_MPPP) 721 if (cnf->config_id == WANCONFIG_MPPP)
@@ -851,10 +849,8 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name)
851 849
852 /* Due to new interface linking method using dev->priv, 850 /* Due to new interface linking method using dev->priv,
853 * this code has moved from del_if() function.*/ 851 * this code has moved from del_if() function.*/
854 if (dev->priv){ 852 kfree(dev->priv);
855 kfree(dev->priv); 853 dev->priv=NULL;
856 dev->priv=NULL;
857 }
858 854
859 unregister_netdev(dev); 855 unregister_netdev(dev);
860 856
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 8b9a4747417d..7cf48aa6c95b 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -62,14 +62,10 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x)
62{ 62{
63 if (del_timer(&x->timer)) 63 if (del_timer(&x->timer))
64 BUG(); 64 BUG();
65 if (x->aalg) 65 kfree(x->aalg);
66 kfree(x->aalg); 66 kfree(x->ealg);
67 if (x->ealg) 67 kfree(x->calg);
68 kfree(x->ealg); 68 kfree(x->encap);
69 if (x->calg)
70 kfree(x->calg);
71 if (x->encap)
72 kfree(x->encap);
73 if (x->type) { 69 if (x->type) {
74 x->type->destructor(x); 70 x->type->destructor(x);
75 xfrm_put_type(x->type); 71 xfrm_put_type(x->type);