aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig1
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/processor_core.c15
-rw-r--r--drivers/acpi/processor_idle.c50
-rw-r--r--drivers/acpi/processor_thermal.c38
-rw-r--r--drivers/acpi/scan.c2
-rw-r--r--drivers/acpi/thermal.c163
-rw-r--r--drivers/acpi/video.c2
-rw-r--r--drivers/atm/Kconfig7
-rw-r--r--drivers/atm/Makefile1
-rw-r--r--drivers/atm/adummy.c168
-rw-r--r--drivers/atm/atmdev_init.c54
-rw-r--r--drivers/atm/atmtcp.c20
-rw-r--r--drivers/atm/lanai.c102
-rw-r--r--drivers/char/drm/drm_context.c5
-rw-r--r--drivers/char/mem.c2
-rw-r--r--drivers/cpufreq/cpufreq.c12
-rw-r--r--drivers/hwmon/w83792d.c25
-rw-r--r--drivers/infiniband/core/user_mad.c41
-rw-r--r--drivers/infiniband/core/uverbs.h11
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c90
-rw-r--r--drivers/infiniband/core/uverbs_main.c21
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c34
-rw-r--r--drivers/infiniband/hw/mthca/mthca_wqe.h3
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c11
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c10
-rw-r--r--drivers/md/md.c4
-rw-r--r--drivers/md/raid1.c8
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c2
-rw-r--r--drivers/md/raid6main.c27
-rw-r--r--drivers/media/dvb/b2c2/flexcop-hw-filter.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c69
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c31
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c18
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c2
-rw-r--r--drivers/media/dvb/frontends/cx22702.c2
-rw-r--r--drivers/media/dvb/frontends/cx22702.h2
-rw-r--r--drivers/media/dvb/frontends/nxt200x.c2
-rw-r--r--drivers/media/dvb/frontends/ves1820.c14
-rw-r--r--drivers/media/dvb/ttpci/Kconfig1
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c1
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c2
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c2
-rw-r--r--drivers/media/dvb/ttpci/budget.c2
-rw-r--r--drivers/media/dvb/ttpci/ttpci-eeprom.c1
-rw-r--r--drivers/media/video/Kconfig5
-rw-r--r--drivers/media/video/bttv-cards.c6
-rw-r--r--drivers/media/video/bttv-driver.c67
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c38
-rw-r--r--drivers/media/video/cx25840/cx25840.h9
-rw-r--r--drivers/media/video/cx88/Kconfig20
-rw-r--r--drivers/media/video/cx88/Makefile27
-rw-r--r--drivers/media/video/cx88/cx88-cards.c43
-rw-r--r--drivers/media/video/cx88/cx88-core.c35
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c28
-rw-r--r--drivers/media/video/cx88/cx88.h4
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c6
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c2
-rw-r--r--drivers/media/video/ir-kbd-i2c.c2
-rw-r--r--drivers/media/video/saa7115.c14
-rw-r--r--drivers/media/video/saa711x.c2
-rw-r--r--drivers/media/video/saa7127.c6
-rw-r--r--drivers/media/video/saa7134/Kconfig12
-rw-r--r--drivers/media/video/saa7134/Makefile19
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c36
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c25
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c81
-rw-r--r--drivers/media/video/saa7134/saa7134.h4
-rw-r--r--drivers/media/video/tveeprom.c64
-rw-r--r--drivers/media/video/video-buf.c9
-rw-r--r--drivers/media/video/videodev.c26
-rw-r--r--drivers/message/fusion/mptbase.c6
-rw-r--r--drivers/message/fusion/mptbase.h2
-rw-r--r--drivers/mmc/mmc.c2
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c10
-rw-r--r--drivers/mtd/chips/cfi_probe.c8
-rw-r--r--drivers/mtd/chips/sharp.c123
-rw-r--r--drivers/mtd/devices/block2mtd.c6
-rw-r--r--drivers/mtd/devices/ms02-nv.c6
-rw-r--r--drivers/mtd/ftl.c6
-rw-r--r--drivers/mtd/maps/Kconfig6
-rw-r--r--drivers/mtd/maps/Makefile1
-rw-r--r--drivers/mtd/maps/ixp4xx.c78
-rw-r--r--drivers/mtd/maps/nettel.c4
-rw-r--r--drivers/mtd/maps/pci.c4
-rw-r--r--drivers/mtd/maps/physmap.c3
-rw-r--r--drivers/mtd/maps/sc520cdp.c4
-rw-r--r--drivers/mtd/nand/nandsim.c2
-rw-r--r--drivers/mtd/rfd_ftl.c6
-rw-r--r--drivers/net/b44.c13
-rw-r--r--drivers/net/e1000/e1000_main.c14
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c38
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.h2
-rw-r--r--drivers/net/jazzsonic.c4
-rw-r--r--drivers/net/mipsnet.h30
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c32
-rw-r--r--drivers/net/sk98lin/Makefile5
-rw-r--r--drivers/net/sk98lin/h/skdrv2nd.h4
-rw-r--r--drivers/net/sk98lin/skcsum.c871
-rw-r--r--drivers/net/sk98lin/skethtool.c2
-rw-r--r--drivers/net/sk98lin/skge.c174
-rw-r--r--drivers/net/skge.c4
-rw-r--r--drivers/net/wireless/airo.c4
-rw-r--r--drivers/net/wireless/orinoco.c3
-rw-r--r--drivers/pcmcia/m32r_cfc.c3
-rw-r--r--drivers/scsi/megaraid.c29
-rw-r--r--drivers/serial/8250.c2
-rw-r--r--drivers/serial/8250_pci.c2
-rw-r--r--drivers/serial/serial_core.c2
-rw-r--r--drivers/serial/serial_cs.c6
-rw-r--r--drivers/usb/atm/cxacru.c3
-rw-r--r--drivers/usb/atm/usbatm.c4
-rw-r--r--drivers/usb/core/hcd-pci.c3
-rw-r--r--drivers/usb/core/hcd.c15
-rw-r--r--drivers/usb/core/hcd.h7
-rw-r--r--drivers/usb/host/ehci-pci.c46
-rw-r--r--drivers/usb/host/ehci-q.c24
-rw-r--r--drivers/usb/host/ehci-sched.c18
-rw-r--r--drivers/usb/host/ohci-hcd.c6
-rw-r--r--drivers/usb/host/ohci-hub.c24
-rw-r--r--drivers/usb/host/ohci-pci.c27
-rw-r--r--drivers/usb/host/uhci-hcd.c6
-rw-r--r--drivers/video/Kconfig13
-rw-r--r--drivers/video/cirrusfb.c15
-rw-r--r--drivers/video/console/fbcon_ccw.c2
-rw-r--r--drivers/video/console/fbcon_rotate.h13
130 files changed, 1500 insertions, 1933 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index fe1e8126fbae..fce21c257523 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -197,7 +197,6 @@ config ACPI_ASUS
197config ACPI_IBM 197config ACPI_IBM
198 tristate "IBM ThinkPad Laptop Extras" 198 tristate "IBM ThinkPad Laptop Extras"
199 depends on X86 199 depends on X86
200 default y
201 ---help--- 200 ---help---
202 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds 201 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds
203 support for Fn-Fx key combinations, Bluetooth control, video 202 support for Fn-Fx key combinations, Bluetooth control, video
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index a18243488c66..5984b4f6715a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -16,7 +16,7 @@ EXTRA_CFLAGS += $(ACPI_CFLAGS)
16# ACPI Boot-Time Table Parsing 16# ACPI Boot-Time Table Parsing
17# 17#
18obj-y += tables.o 18obj-y += tables.o
19obj-y += blacklist.o 19obj-$(CONFIG_X86) += blacklist.o
20 20
21# 21#
22# ACPI Core Subsystem (Interpreter) 22# ACPI Core Subsystem (Interpreter)
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 421792562642..0c561c571f29 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -543,6 +543,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
543 return_VALUE(0); 543 return_VALUE(0);
544} 544}
545 545
546static void *processor_device_array[NR_CPUS];
547
546static int acpi_processor_start(struct acpi_device *device) 548static int acpi_processor_start(struct acpi_device *device)
547{ 549{
548 int result = 0; 550 int result = 0;
@@ -561,6 +563,19 @@ static int acpi_processor_start(struct acpi_device *device)
561 563
562 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0)); 564 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
563 565
566 /*
567 * Buggy BIOS check
568 * ACPI id of processors can be reported wrongly by the BIOS.
569 * Don't trust it blindly
570 */
571 if (processor_device_array[pr->id] != NULL &&
572 processor_device_array[pr->id] != (void *)device) {
573 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "BIOS reporting wrong ACPI id"
574 "for the processor\n"));
575 return_VALUE(-ENODEV);
576 }
577 processor_device_array[pr->id] = (void *)device;
578
564 processors[pr->id] = pr; 579 processors[pr->id] = pr;
565 580
566 result = acpi_processor_add_fs(device); 581 result = acpi_processor_add_fs(device);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 70d8a6ec0920..acd875e0caca 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -169,15 +169,11 @@ acpi_processor_power_activate(struct acpi_processor *pr,
169 169
170static void acpi_safe_halt(void) 170static void acpi_safe_halt(void)
171{ 171{
172 int polling = test_thread_flag(TIF_POLLING_NRFLAG); 172 clear_thread_flag(TIF_POLLING_NRFLAG);
173 if (polling) { 173 smp_mb__after_clear_bit();
174 clear_thread_flag(TIF_POLLING_NRFLAG);
175 smp_mb__after_clear_bit();
176 }
177 if (!need_resched()) 174 if (!need_resched())
178 safe_halt(); 175 safe_halt();
179 if (polling) 176 set_thread_flag(TIF_POLLING_NRFLAG);
180 set_thread_flag(TIF_POLLING_NRFLAG);
181} 177}
182 178
183static atomic_t c3_cpu_count; 179static atomic_t c3_cpu_count;
@@ -280,11 +276,30 @@ static void acpi_processor_idle(void)
280 276
281 cx->usage++; 277 cx->usage++;
282 278
279#ifdef CONFIG_HOTPLUG_CPU
280 /*
281 * Check for P_LVL2_UP flag before entering C2 and above on
282 * an SMP system. We do it here instead of doing it at _CST/P_LVL
283 * detection phase, to work cleanly with logical CPU hotplug.
284 */
285 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
286 !pr->flags.has_cst && acpi_fadt.plvl2_up)
287 cx->type = ACPI_STATE_C1;
288#endif
283 /* 289 /*
284 * Sleep: 290 * Sleep:
285 * ------ 291 * ------
286 * Invoke the current Cx state to put the processor to sleep. 292 * Invoke the current Cx state to put the processor to sleep.
287 */ 293 */
294 if (cx->type == ACPI_STATE_C2 || cx->type == ACPI_STATE_C3) {
295 clear_thread_flag(TIF_POLLING_NRFLAG);
296 smp_mb__after_clear_bit();
297 if (need_resched()) {
298 set_thread_flag(TIF_POLLING_NRFLAG);
299 return;
300 }
301 }
302
288 switch (cx->type) { 303 switch (cx->type) {
289 304
290 case ACPI_STATE_C1: 305 case ACPI_STATE_C1:
@@ -317,6 +332,7 @@ static void acpi_processor_idle(void)
317 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 332 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
318 /* Re-enable interrupts */ 333 /* Re-enable interrupts */
319 local_irq_enable(); 334 local_irq_enable();
335 set_thread_flag(TIF_POLLING_NRFLAG);
320 /* Compute time (ticks) that we were actually asleep */ 336 /* Compute time (ticks) that we were actually asleep */
321 sleep_ticks = 337 sleep_ticks =
322 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; 338 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
@@ -356,6 +372,7 @@ static void acpi_processor_idle(void)
356 372
357 /* Re-enable interrupts */ 373 /* Re-enable interrupts */
358 local_irq_enable(); 374 local_irq_enable();
375 set_thread_flag(TIF_POLLING_NRFLAG);
359 /* Compute time (ticks) that we were actually asleep */ 376 /* Compute time (ticks) that we were actually asleep */
360 sleep_ticks = 377 sleep_ticks =
361 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; 378 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
@@ -534,6 +551,15 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
534 pr->power.states[ACPI_STATE_C0].valid = 1; 551 pr->power.states[ACPI_STATE_C0].valid = 1;
535 pr->power.states[ACPI_STATE_C1].valid = 1; 552 pr->power.states[ACPI_STATE_C1].valid = 1;
536 553
554#ifndef CONFIG_HOTPLUG_CPU
555 /*
556 * Check for P_LVL2_UP flag before entering C2 and above on
557 * an SMP system.
558 */
559 if ((num_online_cpus() > 1) && acpi_fadt.plvl2_up)
560 return_VALUE(-ENODEV);
561#endif
562
537 /* determine C2 and C3 address from pblk */ 563 /* determine C2 and C3 address from pblk */
538 pr->power.states[ACPI_STATE_C2].address = pr->pblk + 4; 564 pr->power.states[ACPI_STATE_C2].address = pr->pblk + 4;
539 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5; 565 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5;
@@ -690,7 +716,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
690 716
691 /* Validate number of power states discovered */ 717 /* Validate number of power states discovered */
692 if (pr->power.count < 2) 718 if (pr->power.count < 2)
693 status = -ENODEV; 719 status = -EFAULT;
694 720
695 end: 721 end:
696 acpi_os_free(buffer.pointer); 722 acpi_os_free(buffer.pointer);
@@ -841,11 +867,11 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
841 * this function */ 867 * this function */
842 868
843 result = acpi_processor_get_power_info_cst(pr); 869 result = acpi_processor_get_power_info_cst(pr);
844 if ((result) || (acpi_processor_power_verify(pr) < 2)) { 870 if (result == -ENODEV)
845 result = acpi_processor_get_power_info_fadt(pr); 871 result = acpi_processor_get_power_info_fadt(pr);
846 if ((result) || (acpi_processor_power_verify(pr) < 2)) 872
847 result = acpi_processor_get_power_info_default_c1(pr); 873 if ((result) || (acpi_processor_power_verify(pr) < 2))
848 } 874 result = acpi_processor_get_power_info_default_c1(pr);
849 875
850 /* 876 /*
851 * Set Default Policy 877 * Set Default Policy
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 37528c3b64b0..f37584015324 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -101,9 +101,7 @@ static unsigned int acpi_thermal_cpufreq_is_init = 0;
101static int cpu_has_cpufreq(unsigned int cpu) 101static int cpu_has_cpufreq(unsigned int cpu)
102{ 102{
103 struct cpufreq_policy policy; 103 struct cpufreq_policy policy;
104 if (!acpi_thermal_cpufreq_is_init) 104 if (!acpi_thermal_cpufreq_is_init || cpufreq_get_policy(&policy, cpu))
105 return -ENODEV;
106 if (!cpufreq_get_policy(&policy, cpu))
107 return -ENODEV; 105 return -ENODEV;
108 return 0; 106 return 0;
109} 107}
@@ -127,13 +125,13 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
127 if (!cpu_has_cpufreq(cpu)) 125 if (!cpu_has_cpufreq(cpu))
128 return -ENODEV; 126 return -ENODEV;
129 127
130 if (cpufreq_thermal_reduction_pctg[cpu] >= 20) { 128 if (cpufreq_thermal_reduction_pctg[cpu] > 20)
131 cpufreq_thermal_reduction_pctg[cpu] -= 20; 129 cpufreq_thermal_reduction_pctg[cpu] -= 20;
132 cpufreq_update_policy(cpu); 130 else
133 return 0; 131 cpufreq_thermal_reduction_pctg[cpu] = 0;
134 } 132 cpufreq_update_policy(cpu);
135 133 /* We reached max freq again and can leave passive mode */
136 return -ERANGE; 134 return !cpufreq_thermal_reduction_pctg[cpu];
137} 135}
138 136
139static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb, 137static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
@@ -200,7 +198,7 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
200 int result = 0; 198 int result = 0;
201 struct acpi_processor *pr = NULL; 199 struct acpi_processor *pr = NULL;
202 struct acpi_device *device = NULL; 200 struct acpi_device *device = NULL;
203 int tx = 0; 201 int tx = 0, max_tx_px = 0;
204 202
205 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit"); 203 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
206 204
@@ -259,19 +257,27 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
259 /* if going down: T-states first, P-states later */ 257 /* if going down: T-states first, P-states later */
260 258
261 if (pr->flags.throttling) { 259 if (pr->flags.throttling) {
262 if (tx == 0) 260 if (tx == 0) {
261 max_tx_px = 1;
263 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 262 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
264 "At minimum throttling state\n")); 263 "At minimum throttling state\n"));
265 else { 264 } else {
266 tx--; 265 tx--;
267 goto end; 266 goto end;
268 } 267 }
269 } 268 }
270 269
271 result = acpi_thermal_cpufreq_decrease(pr->id); 270 result = acpi_thermal_cpufreq_decrease(pr->id);
272 if (result == -ERANGE) 271 if (result) {
272 /*
273 * We only could get -ERANGE, 1 or 0.
274 * In the first two cases we reached max freq again.
275 */
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 276 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
274 "At minimum performance state\n")); 277 "At minimum performance state\n"));
278 max_tx_px = 1;
279 } else
280 max_tx_px = 0;
275 281
276 break; 282 break;
277 } 283 }
@@ -290,8 +296,10 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
290 pr->limit.thermal.px, pr->limit.thermal.tx)); 296 pr->limit.thermal.px, pr->limit.thermal.tx));
291 } else 297 } else
292 result = 0; 298 result = 0;
293 299 if (max_tx_px)
294 return_VALUE(result); 300 return_VALUE(1);
301 else
302 return_VALUE(result);
295} 303}
296 304
297int acpi_processor_get_limit_info(struct acpi_processor *pr) 305int acpi_processor_get_limit_info(struct acpi_processor *pr)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 23e2c6968a11..31218e1d2a18 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1110,7 +1110,7 @@ acpi_add_single_object(struct acpi_device **child,
1110 * 1110 *
1111 * TBD: Assumes LDM provides driver hot-plug capability. 1111 * TBD: Assumes LDM provides driver hot-plug capability.
1112 */ 1112 */
1113 result = acpi_bus_find_driver(device); 1113 acpi_bus_find_driver(device);
1114 1114
1115 end: 1115 end:
1116 if (!result) 1116 if (!result)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index a24847c08f7f..19f3ea48475e 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -72,7 +72,7 @@
72#define _COMPONENT ACPI_THERMAL_COMPONENT 72#define _COMPONENT ACPI_THERMAL_COMPONENT
73ACPI_MODULE_NAME("acpi_thermal") 73ACPI_MODULE_NAME("acpi_thermal")
74 74
75 MODULE_AUTHOR("Paul Diefenbaugh"); 75MODULE_AUTHOR("Paul Diefenbaugh");
76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); 76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME);
77MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
78 78
@@ -517,9 +517,9 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
517 return_VALUE(0); 517 return_VALUE(0);
518} 518}
519 519
520static int acpi_thermal_passive(struct acpi_thermal *tz) 520static void acpi_thermal_passive(struct acpi_thermal *tz)
521{ 521{
522 int result = 0; 522 int result = 1;
523 struct acpi_thermal_passive *passive = NULL; 523 struct acpi_thermal_passive *passive = NULL;
524 int trend = 0; 524 int trend = 0;
525 int i = 0; 525 int i = 0;
@@ -527,7 +527,7 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
527 ACPI_FUNCTION_TRACE("acpi_thermal_passive"); 527 ACPI_FUNCTION_TRACE("acpi_thermal_passive");
528 528
529 if (!tz || !tz->trips.passive.flags.valid) 529 if (!tz || !tz->trips.passive.flags.valid)
530 return_VALUE(-EINVAL); 530 return;
531 531
532 passive = &(tz->trips.passive); 532 passive = &(tz->trips.passive);
533 533
@@ -547,7 +547,7 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
547 trend, passive->tc1, tz->temperature, 547 trend, passive->tc1, tz->temperature,
548 tz->last_temperature, passive->tc2, 548 tz->last_temperature, passive->tc2,
549 tz->temperature, passive->temperature)); 549 tz->temperature, passive->temperature));
550 tz->trips.passive.flags.enabled = 1; 550 passive->flags.enabled = 1;
551 /* Heating up? */ 551 /* Heating up? */
552 if (trend > 0) 552 if (trend > 0)
553 for (i = 0; i < passive->devices.count; i++) 553 for (i = 0; i < passive->devices.count; i++)
@@ -556,12 +556,32 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
556 handles[i], 556 handles[i],
557 ACPI_PROCESSOR_LIMIT_INCREMENT); 557 ACPI_PROCESSOR_LIMIT_INCREMENT);
558 /* Cooling off? */ 558 /* Cooling off? */
559 else if (trend < 0) 559 else if (trend < 0) {
560 for (i = 0; i < passive->devices.count; i++) 560 for (i = 0; i < passive->devices.count; i++)
561 acpi_processor_set_thermal_limit(passive-> 561 /*
562 devices. 562 * assume that we are on highest
563 handles[i], 563 * freq/lowest thrott and can leave
564 ACPI_PROCESSOR_LIMIT_DECREMENT); 564 * passive mode, even in error case
565 */
566 if (!acpi_processor_set_thermal_limit
567 (passive->devices.handles[i],
568 ACPI_PROCESSOR_LIMIT_DECREMENT))
569 result = 0;
570 /*
571 * Leave cooling mode, even if the temp might
572 * higher than trip point This is because some
573 * machines might have long thermal polling
574 * frequencies (tsp) defined. We will fall back
575 * into passive mode in next cycle (probably quicker)
576 */
577 if (result) {
578 passive->flags.enabled = 0;
579 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
580 "Disabling passive cooling, still above threshold,"
581 " but we are cooling down\n"));
582 }
583 }
584 return;
565 } 585 }
566 586
567 /* 587 /*
@@ -571,23 +591,21 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
571 * and avoid thrashing around the passive trip point. Note that we 591 * and avoid thrashing around the passive trip point. Note that we
572 * assume symmetry. 592 * assume symmetry.
573 */ 593 */
574 else if (tz->trips.passive.flags.enabled) { 594 if (!passive->flags.enabled)
575 for (i = 0; i < passive->devices.count; i++) 595 return;
576 result = 596 for (i = 0; i < passive->devices.count; i++)
577 acpi_processor_set_thermal_limit(passive->devices. 597 if (!acpi_processor_set_thermal_limit
578 handles[i], 598 (passive->devices.handles[i],
579 ACPI_PROCESSOR_LIMIT_DECREMENT); 599 ACPI_PROCESSOR_LIMIT_DECREMENT))
580 if (result == 1) { 600 result = 0;
581 tz->trips.passive.flags.enabled = 0; 601 if (result) {
582 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 602 passive->flags.enabled = 0;
583 "Disabling passive cooling (zone is cool)\n")); 603 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
584 } 604 "Disabling passive cooling (zone is cool)\n"));
585 } 605 }
586
587 return_VALUE(0);
588} 606}
589 607
590static int acpi_thermal_active(struct acpi_thermal *tz) 608static void acpi_thermal_active(struct acpi_thermal *tz)
591{ 609{
592 int result = 0; 610 int result = 0;
593 struct acpi_thermal_active *active = NULL; 611 struct acpi_thermal_active *active = NULL;
@@ -598,74 +616,66 @@ static int acpi_thermal_active(struct acpi_thermal *tz)
598 ACPI_FUNCTION_TRACE("acpi_thermal_active"); 616 ACPI_FUNCTION_TRACE("acpi_thermal_active");
599 617
600 if (!tz) 618 if (!tz)
601 return_VALUE(-EINVAL); 619 return;
602 620
603 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { 621 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
604
605 active = &(tz->trips.active[i]); 622 active = &(tz->trips.active[i]);
606 if (!active || !active->flags.valid) 623 if (!active || !active->flags.valid)
607 break; 624 break;
608
609 /*
610 * Above Threshold?
611 * ----------------
612 * If not already enabled, turn ON all cooling devices
613 * associated with this active threshold.
614 */
615 if (tz->temperature >= active->temperature) { 625 if (tz->temperature >= active->temperature) {
626 /*
627 * Above Threshold?
628 * ----------------
629 * If not already enabled, turn ON all cooling devices
630 * associated with this active threshold.
631 */
616 if (active->temperature > maxtemp) 632 if (active->temperature > maxtemp)
617 tz->state.active_index = i, maxtemp = 633 tz->state.active_index = i;
618 active->temperature; 634 maxtemp = active->temperature;
619 if (!active->flags.enabled) { 635 if (active->flags.enabled)
620 for (j = 0; j < active->devices.count; j++) { 636 continue;
621 result =
622 acpi_bus_set_power(active->devices.
623 handles[j],
624 ACPI_STATE_D0);
625 if (result) {
626 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
627 "Unable to turn cooling device [%p] 'on'\n",
628 active->
629 devices.
630 handles[j]));
631 continue;
632 }
633 active->flags.enabled = 1;
634 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
635 "Cooling device [%p] now 'on'\n",
636 active->devices.
637 handles[j]));
638 }
639 }
640 }
641 /*
642 * Below Threshold?
643 * ----------------
644 * Turn OFF all cooling devices associated with this
645 * threshold.
646 */
647 else if (active->flags.enabled) {
648 for (j = 0; j < active->devices.count; j++) { 637 for (j = 0; j < active->devices.count; j++) {
649 result = 638 result =
650 acpi_bus_set_power(active->devices. 639 acpi_bus_set_power(active->devices.
651 handles[j], 640 handles[j],
652 ACPI_STATE_D3); 641 ACPI_STATE_D0);
653 if (result) { 642 if (result) {
654 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 643 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
655 "Unable to turn cooling device [%p] 'off'\n", 644 "Unable to turn cooling device [%p] 'on'\n",
656 active->devices. 645 active->devices.
657 handles[j])); 646 handles[j]));
658 continue; 647 continue;
659 } 648 }
660 active->flags.enabled = 0; 649 active->flags.enabled = 1;
661 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 650 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
662 "Cooling device [%p] now 'off'\n", 651 "Cooling device [%p] now 'on'\n",
663 active->devices.handles[j])); 652 active->devices.handles[j]));
664 } 653 }
654 continue;
655 }
656 if (!active->flags.enabled)
657 continue;
658 /*
659 * Below Threshold?
660 * ----------------
661 * Turn OFF all cooling devices associated with this
662 * threshold.
663 */
664 for (j = 0; j < active->devices.count; j++) {
665 result = acpi_bus_set_power(active->devices.handles[j],
666 ACPI_STATE_D3);
667 if (result) {
668 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
669 "Unable to turn cooling device [%p] 'off'\n",
670 active->devices.handles[j]));
671 continue;
672 }
673 active->flags.enabled = 0;
674 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
675 "Cooling device [%p] now 'off'\n",
676 active->devices.handles[j]));
665 } 677 }
666 } 678 }
667
668 return_VALUE(0);
669} 679}
670 680
671static void acpi_thermal_check(void *context); 681static void acpi_thermal_check(void *context);
@@ -744,15 +754,12 @@ static void acpi_thermal_check(void *data)
744 * Again, separated from the above two to allow independent policy 754 * Again, separated from the above two to allow independent policy
745 * decisions. 755 * decisions.
746 */ 756 */
747 if (tz->trips.critical.flags.enabled) 757 tz->state.critical = tz->trips.critical.flags.enabled;
748 tz->state.critical = 1; 758 tz->state.hot = tz->trips.hot.flags.enabled;
749 if (tz->trips.hot.flags.enabled) 759 tz->state.passive = tz->trips.passive.flags.enabled;
750 tz->state.hot = 1; 760 tz->state.active = 0;
751 if (tz->trips.passive.flags.enabled)
752 tz->state.passive = 1;
753 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) 761 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
754 if (tz->trips.active[i].flags.enabled) 762 tz->state.active |= tz->trips.active[i].flags.enabled;
755 tz->state.active = 1;
756 763
757 /* 764 /*
758 * Calculate Sleep Time 765 * Calculate Sleep Time
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index f051b151580d..d10668f14699 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -812,7 +812,7 @@ acpi_video_device_write_brightness(struct file *file,
812 812
813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness"); 813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
814 814
815 if (!dev || count + 1 > sizeof str) 815 if (!dev || !dev->brightness || count + 1 > sizeof str)
816 return_VALUE(-EINVAL); 816 return_VALUE(-EINVAL);
817 817
818 if (copy_from_user(str, buffer, count)) 818 if (copy_from_user(str, buffer, count))
diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig
index 489de81ea609..01a9f1cb7743 100644
--- a/drivers/atm/Kconfig
+++ b/drivers/atm/Kconfig
@@ -5,6 +5,13 @@
5menu "ATM drivers" 5menu "ATM drivers"
6 depends on NETDEVICES && ATM 6 depends on NETDEVICES && ATM
7 7
8config ATM_DUMMY
9 tristate "Dummy ATM driver"
10 depends on ATM
11 help
12 Dummy ATM driver. Useful for proxy signalling, testing,
13 and development. If unsure, say N.
14
8config ATM_TCP 15config ATM_TCP
9 tristate "ATM over TCP" 16 tristate "ATM over TCP"
10 depends on INET && ATM 17 depends on INET && ATM
diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile
index 5b77188527a9..b5077ce8cb40 100644
--- a/drivers/atm/Makefile
+++ b/drivers/atm/Makefile
@@ -31,6 +31,7 @@ ifeq ($(CONFIG_ATM_IDT77252_USE_SUNI),y)
31 obj-$(CONFIG_ATM_IDT77252) += suni.o 31 obj-$(CONFIG_ATM_IDT77252) += suni.o
32endif 32endif
33 33
34obj-$(CONFIG_ATM_DUMMY) += adummy.o
34obj-$(CONFIG_ATM_TCP) += atmtcp.o 35obj-$(CONFIG_ATM_TCP) += atmtcp.o
35obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o 36obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o
36obj-$(CONFIG_ATM_LANAI) += lanai.o 37obj-$(CONFIG_ATM_LANAI) += lanai.o
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
new file mode 100644
index 000000000000..d15c194be44a
--- /dev/null
+++ b/drivers/atm/adummy.c
@@ -0,0 +1,168 @@
1/*
2 * adummy.c: a dummy ATM driver
3 */
4
5#include <linux/config.h>
6#include <linux/module.h>
7#include <linux/version.h>
8#include <linux/kernel.h>
9#include <linux/skbuff.h>
10#include <linux/pci.h>
11#include <linux/errno.h>
12#include <linux/types.h>
13#include <linux/string.h>
14#include <linux/delay.h>
15#include <linux/init.h>
16#include <linux/mm.h>
17#include <linux/sched.h>
18#include <linux/timer.h>
19#include <linux/interrupt.h>
20#include <asm/io.h>
21#include <asm/byteorder.h>
22#include <asm/uaccess.h>
23
24#include <linux/atmdev.h>
25#include <linux/atm.h>
26#include <linux/sonet.h>
27
28/* version definition */
29
30#define DRV_VERSION "1.0"
31
32#define DEV_LABEL "adummy"
33
34#define ADUMMY_DEV(dev) ((struct adummy_dev *) (dev)->dev_data)
35
36struct adummy_dev {
37 struct atm_dev *atm_dev;
38
39 struct list_head entry;
40};
41
42/* globals */
43
44static LIST_HEAD(adummy_devs);
45
46static int __init
47adummy_start(struct atm_dev *dev)
48{
49 dev->ci_range.vpi_bits = 4;
50 dev->ci_range.vci_bits = 12;
51
52 return 0;
53}
54
55static int
56adummy_open(struct atm_vcc *vcc)
57{
58 short vpi = vcc->vpi;
59 int vci = vcc->vci;
60
61 if (vci == ATM_VCI_UNSPEC || vpi == ATM_VPI_UNSPEC)
62 return 0;
63
64 set_bit(ATM_VF_ADDR, &vcc->flags);
65 set_bit(ATM_VF_READY, &vcc->flags);
66
67 return 0;
68}
69
70static void
71adummy_close(struct atm_vcc *vcc)
72{
73 clear_bit(ATM_VF_READY, &vcc->flags);
74 clear_bit(ATM_VF_ADDR, &vcc->flags);
75}
76
77static int
78adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
79{
80 if (vcc->pop)
81 vcc->pop(vcc, skb);
82 else
83 dev_kfree_skb_any(skb);
84 atomic_inc(&vcc->stats->tx);
85
86 return 0;
87}
88
89static int
90adummy_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
91{
92 int left = *pos;
93
94 if (!left--)
95 return sprintf(page, "version %s\n", DRV_VERSION);
96
97 return 0;
98}
99
100static struct atmdev_ops adummy_ops =
101{
102 .open = adummy_open,
103 .close = adummy_close,
104 .send = adummy_send,
105 .proc_read = adummy_proc_read,
106 .owner = THIS_MODULE
107};
108
109static int __init adummy_init(void)
110{
111 struct atm_dev *atm_dev;
112 struct adummy_dev *adummy_dev;
113 int err = 0;
114
115 printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
116
117 adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
118 GFP_KERNEL);
119 if (!adummy_dev) {
120 printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
121 err = -ENOMEM;
122 goto out;
123 }
124 memset(adummy_dev, 0, sizeof(struct adummy_dev));
125
126 atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, 0);
127 if (!atm_dev) {
128 printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
129 err = -ENODEV;
130 goto out_kfree;
131 }
132
133 adummy_dev->atm_dev = atm_dev;
134 atm_dev->dev_data = adummy_dev;
135
136 if (adummy_start(atm_dev)) {
137 printk(KERN_ERR DEV_LABEL ": adummy_start() failed\n");
138 err = -ENODEV;
139 goto out_unregister;
140 }
141
142 list_add(&adummy_dev->entry, &adummy_devs);
143out:
144 return err;
145
146out_unregister:
147 atm_dev_deregister(atm_dev);
148out_kfree:
149 kfree(adummy_dev);
150 goto out;
151}
152
153static void __exit adummy_cleanup(void)
154{
155 struct adummy_dev *adummy_dev, *next;
156
157 list_for_each_entry_safe(adummy_dev, next, &adummy_devs, entry) {
158 atm_dev_deregister(adummy_dev->atm_dev);
159 kfree(adummy_dev);
160 }
161}
162
163module_init(adummy_init);
164module_exit(adummy_cleanup);
165
166MODULE_AUTHOR("chas williams <chas@cmf.nrl.navy.mil>");
167MODULE_DESCRIPTION("dummy ATM driver");
168MODULE_LICENSE("GPL");
diff --git a/drivers/atm/atmdev_init.c b/drivers/atm/atmdev_init.c
deleted file mode 100644
index 0e09e5c28e3f..000000000000
--- a/drivers/atm/atmdev_init.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/* drivers/atm/atmdev_init.c - ATM device driver initialization */
2
3/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#include <linux/config.h>
7#include <linux/init.h>
8
9
10#ifdef CONFIG_ATM_ZATM
11extern int zatm_detect(void);
12#endif
13#ifdef CONFIG_ATM_AMBASSADOR
14extern int amb_detect(void);
15#endif
16#ifdef CONFIG_ATM_HORIZON
17extern int hrz_detect(void);
18#endif
19#ifdef CONFIG_ATM_FORE200E
20extern int fore200e_detect(void);
21#endif
22#ifdef CONFIG_ATM_LANAI
23extern int lanai_detect(void);
24#endif
25
26
27/*
28 * For historical reasons, atmdev_init returns the number of devices found.
29 * Note that some detections may not go via atmdev_init (e.g. eni.c), so this
30 * number is meaningless.
31 */
32
33int __init atmdev_init(void)
34{
35 int devs;
36
37 devs = 0;
38#ifdef CONFIG_ATM_ZATM
39 devs += zatm_detect();
40#endif
41#ifdef CONFIG_ATM_AMBASSADOR
42 devs += amb_detect();
43#endif
44#ifdef CONFIG_ATM_HORIZON
45 devs += hrz_detect();
46#endif
47#ifdef CONFIG_ATM_FORE200E
48 devs += fore200e_detect();
49#endif
50#ifdef CONFIG_ATM_LANAI
51 devs += lanai_detect();
52#endif
53 return devs;
54}
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
index 57f1810fdccd..fc518d85543d 100644
--- a/drivers/atm/atmtcp.c
+++ b/drivers/atm/atmtcp.c
@@ -246,10 +246,6 @@ static void atmtcp_c_close(struct atm_vcc *vcc)
246{ 246{
247 struct atm_dev *atmtcp_dev; 247 struct atm_dev *atmtcp_dev;
248 struct atmtcp_dev_data *dev_data; 248 struct atmtcp_dev_data *dev_data;
249 struct sock *s;
250 struct hlist_node *node;
251 struct atm_vcc *walk;
252 int i;
253 249
254 atmtcp_dev = (struct atm_dev *) vcc->dev_data; 250 atmtcp_dev = (struct atm_dev *) vcc->dev_data;
255 dev_data = PRIV(atmtcp_dev); 251 dev_data = PRIV(atmtcp_dev);
@@ -257,20 +253,8 @@ static void atmtcp_c_close(struct atm_vcc *vcc)
257 if (dev_data->persist) return; 253 if (dev_data->persist) return;
258 atmtcp_dev->dev_data = NULL; 254 atmtcp_dev->dev_data = NULL;
259 kfree(dev_data); 255 kfree(dev_data);
260 shutdown_atm_dev(atmtcp_dev); 256 atm_dev_deregister(atmtcp_dev);
261 vcc->dev_data = NULL; 257 vcc->dev_data = NULL;
262 read_lock(&vcc_sklist_lock);
263 for(i = 0; i < VCC_HTABLE_SIZE; ++i) {
264 struct hlist_head *head = &vcc_hash[i];
265
266 sk_for_each(s, node, head) {
267 walk = atm_sk(s);
268 if (walk->dev != atmtcp_dev)
269 continue;
270 wake_up(s->sk_sleep);
271 }
272 }
273 read_unlock(&vcc_sklist_lock);
274 module_put(THIS_MODULE); 258 module_put(THIS_MODULE);
275} 259}
276 260
@@ -450,7 +434,7 @@ static int atmtcp_remove_persistent(int itf)
450 if (PRIV(dev)->vcc) return 0; 434 if (PRIV(dev)->vcc) return 0;
451 kfree(dev_data); 435 kfree(dev_data);
452 atm_dev_put(dev); 436 atm_dev_put(dev);
453 shutdown_atm_dev(dev); 437 atm_dev_deregister(dev);
454 return 0; 438 return 0;
455} 439}
456 440
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 51ec14787293..69f4c7ce9a63 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -39,7 +39,7 @@
39 * o lanai_change_qos() isn't written yet 39 * o lanai_change_qos() isn't written yet
40 * 40 *
41 * o There aren't any ioctl's yet -- I'd like to eventually support 41 * o There aren't any ioctl's yet -- I'd like to eventually support
42 * setting loopback and LED modes that way. (see lanai_ioctl) 42 * setting loopback and LED modes that way.
43 * 43 *
44 * o If the segmentation engine or DMA gets shut down we should restart 44 * o If the segmentation engine or DMA gets shut down we should restart
45 * card as per section 17.0i. (see lanai_reset) 45 * card as per section 17.0i. (see lanai_reset)
@@ -305,7 +305,7 @@ struct lanai_dev {
305 * vci with their bit set 305 * vci with their bit set
306 */ 306 */
307static void vci_bitfield_iterate(struct lanai_dev *lanai, 307static void vci_bitfield_iterate(struct lanai_dev *lanai,
308 /*const*/ unsigned long *lp, 308 const unsigned long *lp,
309 void (*func)(struct lanai_dev *,vci_t vci)) 309 void (*func)(struct lanai_dev *,vci_t vci))
310{ 310{
311 vci_t vci = find_first_bit(lp, NUM_VCI); 311 vci_t vci = find_first_bit(lp, NUM_VCI);
@@ -951,7 +951,7 @@ static int __devinit eeprom_read(struct lanai_dev *lanai)
951/* read a big-endian 4-byte value out of eeprom */ 951/* read a big-endian 4-byte value out of eeprom */
952static inline u32 eeprom_be4(const struct lanai_dev *lanai, int address) 952static inline u32 eeprom_be4(const struct lanai_dev *lanai, int address)
953{ 953{
954 return be32_to_cpup((u32 *) (&lanai->eeprom[address])); 954 return be32_to_cpup((const u32 *) &lanai->eeprom[address]);
955} 955}
956 956
957/* Checksum/validate EEPROM contents */ 957/* Checksum/validate EEPROM contents */
@@ -1160,7 +1160,7 @@ static inline int vcc_tx_space(const struct lanai_vcc *lvcc, int endptr)
1160} 1160}
1161 1161
1162/* test if VCC is currently backlogged */ 1162/* test if VCC is currently backlogged */
1163static inline int vcc_is_backlogged(/*const*/ struct lanai_vcc *lvcc) 1163static inline int vcc_is_backlogged(const struct lanai_vcc *lvcc)
1164{ 1164{
1165 return !skb_queue_empty(&lvcc->tx.backlog); 1165 return !skb_queue_empty(&lvcc->tx.backlog);
1166} 1166}
@@ -1395,7 +1395,8 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
1395{ 1395{
1396 int size; 1396 int size;
1397 struct sk_buff *skb; 1397 struct sk_buff *skb;
1398 /*const*/ u32 *x, *end = &lvcc->rx.buf.start[endptr * 4]; 1398 const u32 *x;
1399 u32 *end = &lvcc->rx.buf.start[endptr * 4];
1399 int n = ((unsigned long) end) - ((unsigned long) lvcc->rx.buf.ptr); 1400 int n = ((unsigned long) end) - ((unsigned long) lvcc->rx.buf.ptr);
1400 if (n < 0) 1401 if (n < 0)
1401 n += lanai_buf_size(&lvcc->rx.buf); 1402 n += lanai_buf_size(&lvcc->rx.buf);
@@ -2111,7 +2112,7 @@ static int lanai_normalize_ci(struct lanai_dev *lanai,
2111 * shifted by that much as we compute 2112 * shifted by that much as we compute
2112 * 2113 *
2113 */ 2114 */
2114static int pcr_to_cbricg(/*const*/ struct atm_qos *qos) 2115static int pcr_to_cbricg(const struct atm_qos *qos)
2115{ 2116{
2116 int rounddown = 0; /* 1 = Round PCR down, i.e. round ICG _up_ */ 2117 int rounddown = 0; /* 1 = Round PCR down, i.e. round ICG _up_ */
2117 int x, icg, pcr = atm_pcr_goal(&qos->txtp); 2118 int x, icg, pcr = atm_pcr_goal(&qos->txtp);
@@ -2434,93 +2435,6 @@ static int lanai_open(struct atm_vcc *atmvcc)
2434 return result; 2435 return result;
2435} 2436}
2436 2437
2437#if 0
2438/* ioctl operations for card */
2439/* NOTE: these are all DEBUGGING ONLY currently */
2440static int lanai_ioctl(struct atm_dev *atmdev, unsigned int cmd, void __user *arg)
2441{
2442 int result = 0;
2443 struct lanai_dev *lanai = (struct lanai_dev *) atmdev->dev_data;
2444 switch(cmd) {
2445 case 2106275:
2446 shutdown_atm_dev(atmdev);
2447 return 0;
2448 case 2200000: {
2449 unsigned long flags;
2450 spin_lock_irqsave(&lanai->servicelock, flags);
2451 run_service(lanai);
2452 spin_unlock_irqrestore(&lanai->servicelock, flags);
2453 return 0; }
2454 case 2200002:
2455 get_statistics(lanai);
2456 return 0;
2457 case 2200003: {
2458 unsigned int i;
2459 for (i = 0; i <= 0x5C ; i += 4) {
2460 if (i==0x48) /* Write-only butt reg */
2461 continue;
2462 printk(KERN_CRIT DEV_LABEL " 0x%02X: "
2463 "0x%08X\n", i,
2464 (unsigned int) readl(lanai->base + i));
2465 barrier(); mb();
2466 pcistatus_check(lanai, 0);
2467 barrier(); mb();
2468 }
2469 return 0; }
2470 case 2200004: {
2471 u8 b;
2472 u16 w;
2473 u32 dw;
2474 struct pci_dev *pci = lanai->pci;
2475 (void) pci_read_config_word(pci, PCI_VENDOR_ID, &w);
2476 DPRINTK("vendor = 0x%X\n", (unsigned int) w);
2477 (void) pci_read_config_word(pci, PCI_DEVICE_ID, &w);
2478 DPRINTK("device = 0x%X\n", (unsigned int) w);
2479 (void) pci_read_config_word(pci, PCI_COMMAND, &w);
2480 DPRINTK("command = 0x%X\n", (unsigned int) w);
2481 (void) pci_read_config_word(pci, PCI_STATUS, &w);
2482 DPRINTK("status = 0x%X\n", (unsigned int) w);
2483 (void) pci_read_config_dword(pci,
2484 PCI_CLASS_REVISION, &dw);
2485 DPRINTK("class/revision = 0x%X\n", (unsigned int) dw);
2486 (void) pci_read_config_byte(pci,
2487 PCI_CACHE_LINE_SIZE, &b);
2488 DPRINTK("cache line size = 0x%X\n", (unsigned int) b);
2489 (void) pci_read_config_byte(pci, PCI_LATENCY_TIMER, &b);
2490 DPRINTK("latency = %d (0x%X)\n",
2491 (int) b, (unsigned int) b);
2492 (void) pci_read_config_byte(pci, PCI_HEADER_TYPE, &b);
2493 DPRINTK("header type = 0x%X\n", (unsigned int) b);
2494 (void) pci_read_config_byte(pci, PCI_BIST, &b);
2495 DPRINTK("bist = 0x%X\n", (unsigned int) b);
2496 /* skipping a few here */
2497 (void) pci_read_config_byte(pci,
2498 PCI_INTERRUPT_LINE, &b);
2499 DPRINTK("pci_int_line = 0x%X\n", (unsigned int) b);
2500 (void) pci_read_config_byte(pci,
2501 PCI_INTERRUPT_PIN, &b);
2502 DPRINTK("pci_int_pin = 0x%X\n", (unsigned int) b);
2503 (void) pci_read_config_byte(pci, PCI_MIN_GNT, &b);
2504 DPRINTK("min_gnt = 0x%X\n", (unsigned int) b);
2505 (void) pci_read_config_byte(pci, PCI_MAX_LAT, &b);
2506 DPRINTK("max_lat = 0x%X\n", (unsigned int) b); }
2507 return 0;
2508#ifdef USE_POWERDOWN
2509 case 2200005:
2510 DPRINTK("Coming out of powerdown\n");
2511 lanai->conf1 &= ~CONFIG1_POWERDOWN;
2512 conf1_write(lanai);
2513 return 0;
2514#endif
2515 default:
2516 result = -ENOIOCTLCMD;
2517 }
2518 return result;
2519}
2520#else /* !0 */
2521#define lanai_ioctl NULL
2522#endif /* 0 */
2523
2524static int lanai_send(struct atm_vcc *atmvcc, struct sk_buff *skb) 2438static int lanai_send(struct atm_vcc *atmvcc, struct sk_buff *skb)
2525{ 2439{
2526 struct lanai_vcc *lvcc = (struct lanai_vcc *) atmvcc->dev_data; 2440 struct lanai_vcc *lvcc = (struct lanai_vcc *) atmvcc->dev_data;
@@ -2678,7 +2592,6 @@ static const struct atmdev_ops ops = {
2678 .dev_close = lanai_dev_close, 2592 .dev_close = lanai_dev_close,
2679 .open = lanai_open, 2593 .open = lanai_open,
2680 .close = lanai_close, 2594 .close = lanai_close,
2681 .ioctl = lanai_ioctl,
2682 .getsockopt = NULL, 2595 .getsockopt = NULL,
2683 .setsockopt = NULL, 2596 .setsockopt = NULL,
2684 .send = lanai_send, 2597 .send = lanai_send,
@@ -2760,6 +2673,7 @@ static void __exit lanai_module_exit(void)
2760 * gone, so there isn't much to do 2673 * gone, so there isn't much to do
2761 */ 2674 */
2762 DPRINTK("cleanup_module()\n"); 2675 DPRINTK("cleanup_module()\n");
2676 pci_unregister_driver(&lanai_driver);
2763} 2677}
2764 2678
2765module_init(lanai_module_init); 2679module_init(lanai_module_init);
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index bdd168d88f49..bd958d69a2ac 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -432,7 +432,10 @@ int drm_addctx(struct inode *inode, struct file *filp,
432 432
433 if (ctx.handle != DRM_KERNEL_CONTEXT) { 433 if (ctx.handle != DRM_KERNEL_CONTEXT) {
434 if (dev->driver->context_ctor) 434 if (dev->driver->context_ctor)
435 dev->driver->context_ctor(dev, ctx.handle); 435 if (!dev->driver->context_ctor(dev, ctx.handle)) {
436 DRM_DEBUG( "Running out of ctxs or memory.\n");
437 return -ENOMEM;
438 }
436 } 439 }
437 440
438 ctx_entry = drm_alloc(sizeof(*ctx_entry), DRM_MEM_CTXLIST); 441 ctx_entry = drm_alloc(sizeof(*ctx_entry), DRM_MEM_CTXLIST);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 29c3b631445a..91dd669273e0 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -591,7 +591,7 @@ static inline size_t read_zero_pagealigned(char __user * buf, size_t size)
591 591
592 if (vma->vm_start > addr || (vma->vm_flags & VM_WRITE) == 0) 592 if (vma->vm_start > addr || (vma->vm_flags & VM_WRITE) == 0)
593 goto out_up; 593 goto out_up;
594 if (vma->vm_flags & (VM_SHARED | VM_HUGETLB | VM_UNPAGED)) 594 if (vma->vm_flags & (VM_SHARED | VM_HUGETLB))
595 break; 595 break;
596 count = vma->vm_end - addr; 596 count = vma->vm_end - addr;
597 if (count > size) 597 if (count > size)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 1c0f62d0f938..815902c2c856 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1113,21 +1113,13 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1113{ 1113{
1114 int retval = -EINVAL; 1114 int retval = -EINVAL;
1115 1115
1116 /* 1116 lock_cpu_hotplug();
1117 * If we are already in context of hotplug thread, we dont need to
1118 * acquire the hotplug lock. Otherwise acquire cpucontrol to prevent
1119 * hotplug from removing this cpu that we are working on.
1120 */
1121 if (!current_in_cpu_hotplug())
1122 lock_cpu_hotplug();
1123
1124 dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu, 1117 dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu,
1125 target_freq, relation); 1118 target_freq, relation);
1126 if (cpu_online(policy->cpu) && cpufreq_driver->target) 1119 if (cpu_online(policy->cpu) && cpufreq_driver->target)
1127 retval = cpufreq_driver->target(policy, target_freq, relation); 1120 retval = cpufreq_driver->target(policy, target_freq, relation);
1128 1121
1129 if (!current_in_cpu_hotplug()) 1122 unlock_cpu_hotplug();
1130 unlock_cpu_hotplug();
1131 1123
1132 return retval; 1124 return retval;
1133} 1125}
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 4be59dbb78c4..1ba072630361 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -193,6 +193,7 @@ static const u8 W83792D_REG_LEVELS[3][4] = {
193 0xE2 } /* (bit3-0) SmartFanII: Fan3 Level 3 */ 193 0xE2 } /* (bit3-0) SmartFanII: Fan3 Level 3 */
194}; 194};
195 195
196#define W83792D_REG_GPIO_EN 0x1A
196#define W83792D_REG_CONFIG 0x40 197#define W83792D_REG_CONFIG 0x40
197#define W83792D_REG_VID_FANDIV 0x47 198#define W83792D_REG_VID_FANDIV 0x47
198#define W83792D_REG_CHIPID 0x49 199#define W83792D_REG_CHIPID 0x49
@@ -257,7 +258,7 @@ DIV_TO_REG(long val)
257{ 258{
258 int i; 259 int i;
259 val = SENSORS_LIMIT(val, 1, 128) >> 1; 260 val = SENSORS_LIMIT(val, 1, 128) >> 1;
260 for (i = 0; i < 6; i++) { 261 for (i = 0; i < 7; i++) {
261 if (val == 0) 262 if (val == 0)
262 break; 263 break;
263 val >>= 1; 264 val >>= 1;
@@ -1282,8 +1283,8 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
1282 w83792d_init_client(new_client); 1283 w83792d_init_client(new_client);
1283 1284
1284 /* A few vars need to be filled upon startup */ 1285 /* A few vars need to be filled upon startup */
1285 for (i = 1; i <= 7; i++) { 1286 for (i = 0; i < 7; i++) {
1286 data->fan_min[i - 1] = w83792d_read_value(new_client, 1287 data->fan_min[i] = w83792d_read_value(new_client,
1287 W83792D_REG_FAN_MIN[i]); 1288 W83792D_REG_FAN_MIN[i]);
1288 } 1289 }
1289 1290
@@ -1306,10 +1307,20 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
1306 device_create_file_fan(new_client, 1); 1307 device_create_file_fan(new_client, 1);
1307 device_create_file_fan(new_client, 2); 1308 device_create_file_fan(new_client, 2);
1308 device_create_file_fan(new_client, 3); 1309 device_create_file_fan(new_client, 3);
1309 device_create_file_fan(new_client, 4); 1310
1310 device_create_file_fan(new_client, 5); 1311 /* Read GPIO enable register to check if pins for fan 4,5 are used as
1311 device_create_file_fan(new_client, 6); 1312 GPIO */
1312 device_create_file_fan(new_client, 7); 1313 val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN);
1314 if (!(val1 & 0x40))
1315 device_create_file_fan(new_client, 4);
1316 if (!(val1 & 0x20))
1317 device_create_file_fan(new_client, 5);
1318
1319 val1 = w83792d_read_value(new_client, W83792D_REG_PIN);
1320 if (val1 & 0x40)
1321 device_create_file_fan(new_client, 6);
1322 if (val1 & 0x04)
1323 device_create_file_fan(new_client, 7);
1313 1324
1314 device_create_file_temp1(new_client); /* Temp1 */ 1325 device_create_file_temp1(new_client); /* Temp1 */
1315 device_create_file_temp_add(new_client, 2); /* Temp2 */ 1326 device_create_file_temp_add(new_client, 2); /* Temp2 */
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index e73f81c22381..eb7f52537ccc 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -310,7 +310,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
310 u8 method; 310 u8 method;
311 __be64 *tid; 311 __be64 *tid;
312 int ret, length, hdr_len, copy_offset; 312 int ret, length, hdr_len, copy_offset;
313 int rmpp_active = 0; 313 int rmpp_active, has_rmpp_header;
314 314
315 if (count < sizeof (struct ib_user_mad) + IB_MGMT_RMPP_HDR) 315 if (count < sizeof (struct ib_user_mad) + IB_MGMT_RMPP_HDR)
316 return -EINVAL; 316 return -EINVAL;
@@ -360,28 +360,31 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
360 } 360 }
361 361
362 rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data; 362 rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
363 if (ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE) { 363 if (rmpp_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
364 /* RMPP active */ 364 hdr_len = IB_MGMT_SA_HDR;
365 if (!agent->rmpp_version) {
366 ret = -EINVAL;
367 goto err_ah;
368 }
369
370 /* Validate that the management class can support RMPP */
371 if (rmpp_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
372 hdr_len = IB_MGMT_SA_HDR;
373 } else if ((rmpp_mad->mad_hdr.mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
374 (rmpp_mad->mad_hdr.mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END)) {
375 hdr_len = IB_MGMT_VENDOR_HDR;
376 } else {
377 ret = -EINVAL;
378 goto err_ah;
379 }
380 rmpp_active = 1;
381 copy_offset = IB_MGMT_RMPP_HDR; 365 copy_offset = IB_MGMT_RMPP_HDR;
366 has_rmpp_header = 1;
367 } else if (rmpp_mad->mad_hdr.mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START &&
368 rmpp_mad->mad_hdr.mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END) {
369 hdr_len = IB_MGMT_VENDOR_HDR;
370 copy_offset = IB_MGMT_RMPP_HDR;
371 has_rmpp_header = 1;
382 } else { 372 } else {
383 hdr_len = IB_MGMT_MAD_HDR; 373 hdr_len = IB_MGMT_MAD_HDR;
384 copy_offset = IB_MGMT_MAD_HDR; 374 copy_offset = IB_MGMT_MAD_HDR;
375 has_rmpp_header = 0;
376 }
377
378 if (has_rmpp_header)
379 rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
380 IB_MGMT_RMPP_FLAG_ACTIVE;
381 else
382 rmpp_active = 0;
383
384 /* Validate that the management class can support RMPP */
385 if (rmpp_active && !agent->rmpp_version) {
386 ret = -EINVAL;
387 goto err_ah;
385 } 388 }
386 389
387 packet->msg = ib_create_send_mad(agent, 390 packet->msg = ib_create_send_mad(agent,
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index ecb830127865..7114e3fbab00 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -105,12 +105,23 @@ struct ib_uverbs_event {
105 u32 *counter; 105 u32 *counter;
106}; 106};
107 107
108struct ib_uverbs_mcast_entry {
109 struct list_head list;
110 union ib_gid gid;
111 u16 lid;
112};
113
108struct ib_uevent_object { 114struct ib_uevent_object {
109 struct ib_uobject uobject; 115 struct ib_uobject uobject;
110 struct list_head event_list; 116 struct list_head event_list;
111 u32 events_reported; 117 u32 events_reported;
112}; 118};
113 119
120struct ib_uqp_object {
121 struct ib_uevent_object uevent;
122 struct list_head mcast_list;
123};
124
114struct ib_ucq_object { 125struct ib_ucq_object {
115 struct ib_uobject uobject; 126 struct ib_uobject uobject;
116 struct ib_uverbs_file *uverbs_file; 127 struct ib_uverbs_file *uverbs_file;
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index ed45da892b1c..a57d021d435a 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -815,7 +815,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
815 struct ib_uverbs_create_qp cmd; 815 struct ib_uverbs_create_qp cmd;
816 struct ib_uverbs_create_qp_resp resp; 816 struct ib_uverbs_create_qp_resp resp;
817 struct ib_udata udata; 817 struct ib_udata udata;
818 struct ib_uevent_object *uobj; 818 struct ib_uqp_object *uobj;
819 struct ib_pd *pd; 819 struct ib_pd *pd;
820 struct ib_cq *scq, *rcq; 820 struct ib_cq *scq, *rcq;
821 struct ib_srq *srq; 821 struct ib_srq *srq;
@@ -866,10 +866,11 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
866 attr.cap.max_recv_sge = cmd.max_recv_sge; 866 attr.cap.max_recv_sge = cmd.max_recv_sge;
867 attr.cap.max_inline_data = cmd.max_inline_data; 867 attr.cap.max_inline_data = cmd.max_inline_data;
868 868
869 uobj->uobject.user_handle = cmd.user_handle; 869 uobj->uevent.uobject.user_handle = cmd.user_handle;
870 uobj->uobject.context = file->ucontext; 870 uobj->uevent.uobject.context = file->ucontext;
871 uobj->events_reported = 0; 871 uobj->uevent.events_reported = 0;
872 INIT_LIST_HEAD(&uobj->event_list); 872 INIT_LIST_HEAD(&uobj->uevent.event_list);
873 INIT_LIST_HEAD(&uobj->mcast_list);
873 874
874 qp = pd->device->create_qp(pd, &attr, &udata); 875 qp = pd->device->create_qp(pd, &attr, &udata);
875 if (IS_ERR(qp)) { 876 if (IS_ERR(qp)) {
@@ -882,7 +883,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
882 qp->send_cq = attr.send_cq; 883 qp->send_cq = attr.send_cq;
883 qp->recv_cq = attr.recv_cq; 884 qp->recv_cq = attr.recv_cq;
884 qp->srq = attr.srq; 885 qp->srq = attr.srq;
885 qp->uobject = &uobj->uobject; 886 qp->uobject = &uobj->uevent.uobject;
886 qp->event_handler = attr.event_handler; 887 qp->event_handler = attr.event_handler;
887 qp->qp_context = attr.qp_context; 888 qp->qp_context = attr.qp_context;
888 qp->qp_type = attr.qp_type; 889 qp->qp_type = attr.qp_type;
@@ -901,14 +902,14 @@ retry:
901 goto err_destroy; 902 goto err_destroy;
902 } 903 }
903 904
904 ret = idr_get_new(&ib_uverbs_qp_idr, qp, &uobj->uobject.id); 905 ret = idr_get_new(&ib_uverbs_qp_idr, qp, &uobj->uevent.uobject.id);
905 906
906 if (ret == -EAGAIN) 907 if (ret == -EAGAIN)
907 goto retry; 908 goto retry;
908 if (ret) 909 if (ret)
909 goto err_destroy; 910 goto err_destroy;
910 911
911 resp.qp_handle = uobj->uobject.id; 912 resp.qp_handle = uobj->uevent.uobject.id;
912 resp.max_recv_sge = attr.cap.max_recv_sge; 913 resp.max_recv_sge = attr.cap.max_recv_sge;
913 resp.max_send_sge = attr.cap.max_send_sge; 914 resp.max_send_sge = attr.cap.max_send_sge;
914 resp.max_recv_wr = attr.cap.max_recv_wr; 915 resp.max_recv_wr = attr.cap.max_recv_wr;
@@ -922,7 +923,7 @@ retry:
922 } 923 }
923 924
924 down(&file->mutex); 925 down(&file->mutex);
925 list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list); 926 list_add_tail(&uobj->uevent.uobject.list, &file->ucontext->qp_list);
926 up(&file->mutex); 927 up(&file->mutex);
927 928
928 up(&ib_uverbs_idr_mutex); 929 up(&ib_uverbs_idr_mutex);
@@ -930,7 +931,7 @@ retry:
930 return in_len; 931 return in_len;
931 932
932err_idr: 933err_idr:
933 idr_remove(&ib_uverbs_qp_idr, uobj->uobject.id); 934 idr_remove(&ib_uverbs_qp_idr, uobj->uevent.uobject.id);
934 935
935err_destroy: 936err_destroy:
936 ib_destroy_qp(qp); 937 ib_destroy_qp(qp);
@@ -1032,7 +1033,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1032 struct ib_uverbs_destroy_qp cmd; 1033 struct ib_uverbs_destroy_qp cmd;
1033 struct ib_uverbs_destroy_qp_resp resp; 1034 struct ib_uverbs_destroy_qp_resp resp;
1034 struct ib_qp *qp; 1035 struct ib_qp *qp;
1035 struct ib_uevent_object *uobj; 1036 struct ib_uqp_object *uobj;
1036 int ret = -EINVAL; 1037 int ret = -EINVAL;
1037 1038
1038 if (copy_from_user(&cmd, buf, sizeof cmd)) 1039 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1046,7 +1047,12 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1046 if (!qp || qp->uobject->context != file->ucontext) 1047 if (!qp || qp->uobject->context != file->ucontext)
1047 goto out; 1048 goto out;
1048 1049
1049 uobj = container_of(qp->uobject, struct ib_uevent_object, uobject); 1050 uobj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
1051
1052 if (!list_empty(&uobj->mcast_list)) {
1053 ret = -EBUSY;
1054 goto out;
1055 }
1050 1056
1051 ret = ib_destroy_qp(qp); 1057 ret = ib_destroy_qp(qp);
1052 if (ret) 1058 if (ret)
@@ -1055,12 +1061,12 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1055 idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); 1061 idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle);
1056 1062
1057 down(&file->mutex); 1063 down(&file->mutex);
1058 list_del(&uobj->uobject.list); 1064 list_del(&uobj->uevent.uobject.list);
1059 up(&file->mutex); 1065 up(&file->mutex);
1060 1066
1061 ib_uverbs_release_uevent(file, uobj); 1067 ib_uverbs_release_uevent(file, &uobj->uevent);
1062 1068
1063 resp.events_reported = uobj->events_reported; 1069 resp.events_reported = uobj->uevent.events_reported;
1064 1070
1065 kfree(uobj); 1071 kfree(uobj);
1066 1072
@@ -1542,6 +1548,8 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
1542{ 1548{
1543 struct ib_uverbs_attach_mcast cmd; 1549 struct ib_uverbs_attach_mcast cmd;
1544 struct ib_qp *qp; 1550 struct ib_qp *qp;
1551 struct ib_uqp_object *uobj;
1552 struct ib_uverbs_mcast_entry *mcast;
1545 int ret = -EINVAL; 1553 int ret = -EINVAL;
1546 1554
1547 if (copy_from_user(&cmd, buf, sizeof cmd)) 1555 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1550,9 +1558,36 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
1550 down(&ib_uverbs_idr_mutex); 1558 down(&ib_uverbs_idr_mutex);
1551 1559
1552 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); 1560 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1553 if (qp && qp->uobject->context == file->ucontext) 1561 if (!qp || qp->uobject->context != file->ucontext)
1554 ret = ib_attach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid); 1562 goto out;
1563
1564 uobj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
1565
1566 list_for_each_entry(mcast, &uobj->mcast_list, list)
1567 if (cmd.mlid == mcast->lid &&
1568 !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
1569 ret = 0;
1570 goto out;
1571 }
1555 1572
1573 mcast = kmalloc(sizeof *mcast, GFP_KERNEL);
1574 if (!mcast) {
1575 ret = -ENOMEM;
1576 goto out;
1577 }
1578
1579 mcast->lid = cmd.mlid;
1580 memcpy(mcast->gid.raw, cmd.gid, sizeof mcast->gid.raw);
1581
1582 ret = ib_attach_mcast(qp, &mcast->gid, cmd.mlid);
1583 if (!ret) {
1584 uobj = container_of(qp->uobject, struct ib_uqp_object,
1585 uevent.uobject);
1586 list_add_tail(&mcast->list, &uobj->mcast_list);
1587 } else
1588 kfree(mcast);
1589
1590out:
1556 up(&ib_uverbs_idr_mutex); 1591 up(&ib_uverbs_idr_mutex);
1557 1592
1558 return ret ? ret : in_len; 1593 return ret ? ret : in_len;
@@ -1563,7 +1598,9 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
1563 int out_len) 1598 int out_len)
1564{ 1599{
1565 struct ib_uverbs_detach_mcast cmd; 1600 struct ib_uverbs_detach_mcast cmd;
1601 struct ib_uqp_object *uobj;
1566 struct ib_qp *qp; 1602 struct ib_qp *qp;
1603 struct ib_uverbs_mcast_entry *mcast;
1567 int ret = -EINVAL; 1604 int ret = -EINVAL;
1568 1605
1569 if (copy_from_user(&cmd, buf, sizeof cmd)) 1606 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1572,9 +1609,24 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
1572 down(&ib_uverbs_idr_mutex); 1609 down(&ib_uverbs_idr_mutex);
1573 1610
1574 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); 1611 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1575 if (qp && qp->uobject->context == file->ucontext) 1612 if (!qp || qp->uobject->context != file->ucontext)
1576 ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid); 1613 goto out;
1614
1615 ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
1616 if (ret)
1617 goto out;
1577 1618
1619 uobj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
1620
1621 list_for_each_entry(mcast, &uobj->mcast_list, list)
1622 if (cmd.mlid == mcast->lid &&
1623 !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
1624 list_del(&mcast->list);
1625 kfree(mcast);
1626 break;
1627 }
1628
1629out:
1578 up(&ib_uverbs_idr_mutex); 1630 up(&ib_uverbs_idr_mutex);
1579 1631
1580 return ret ? ret : in_len; 1632 return ret ? ret : in_len;
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index de6581d7cb8d..81737bd6faea 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -160,6 +160,18 @@ void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
160 spin_unlock_irq(&file->async_file->lock); 160 spin_unlock_irq(&file->async_file->lock);
161} 161}
162 162
163static void ib_uverbs_detach_umcast(struct ib_qp *qp,
164 struct ib_uqp_object *uobj)
165{
166 struct ib_uverbs_mcast_entry *mcast, *tmp;
167
168 list_for_each_entry_safe(mcast, tmp, &uobj->mcast_list, list) {
169 ib_detach_mcast(qp, &mcast->gid, mcast->lid);
170 list_del(&mcast->list);
171 kfree(mcast);
172 }
173}
174
163static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file, 175static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
164 struct ib_ucontext *context) 176 struct ib_ucontext *context)
165{ 177{
@@ -180,13 +192,14 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
180 192
181 list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) { 193 list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) {
182 struct ib_qp *qp = idr_find(&ib_uverbs_qp_idr, uobj->id); 194 struct ib_qp *qp = idr_find(&ib_uverbs_qp_idr, uobj->id);
183 struct ib_uevent_object *uevent = 195 struct ib_uqp_object *uqp =
184 container_of(uobj, struct ib_uevent_object, uobject); 196 container_of(uobj, struct ib_uqp_object, uevent.uobject);
185 idr_remove(&ib_uverbs_qp_idr, uobj->id); 197 idr_remove(&ib_uverbs_qp_idr, uobj->id);
198 ib_uverbs_detach_umcast(qp, uqp);
186 ib_destroy_qp(qp); 199 ib_destroy_qp(qp);
187 list_del(&uobj->list); 200 list_del(&uobj->list);
188 ib_uverbs_release_uevent(file, uevent); 201 ib_uverbs_release_uevent(file, &uqp->uevent);
189 kfree(uevent); 202 kfree(uqp);
190 } 203 }
191 204
192 list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) { 205 list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) {
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index dd4e13303e96..7450550db736 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -871,7 +871,10 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
871 qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); 871 qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
872 872
873 mthca_wq_init(&qp->sq); 873 mthca_wq_init(&qp->sq);
874 qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
875
874 mthca_wq_init(&qp->rq); 876 mthca_wq_init(&qp->rq);
877 qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
875 878
876 if (mthca_is_memfree(dev)) { 879 if (mthca_is_memfree(dev)) {
877 *qp->sq.db = 0; 880 *qp->sq.db = 0;
@@ -1819,6 +1822,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1819{ 1822{
1820 struct mthca_dev *dev = to_mdev(ibqp->device); 1823 struct mthca_dev *dev = to_mdev(ibqp->device);
1821 struct mthca_qp *qp = to_mqp(ibqp); 1824 struct mthca_qp *qp = to_mqp(ibqp);
1825 __be32 doorbell[2];
1822 void *wqe; 1826 void *wqe;
1823 void *prev_wqe; 1827 void *prev_wqe;
1824 unsigned long flags; 1828 unsigned long flags;
@@ -1838,6 +1842,34 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1838 ind = qp->sq.head & (qp->sq.max - 1); 1842 ind = qp->sq.head & (qp->sq.max - 1);
1839 1843
1840 for (nreq = 0; wr; ++nreq, wr = wr->next) { 1844 for (nreq = 0; wr; ++nreq, wr = wr->next) {
1845 if (unlikely(nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB)) {
1846 nreq = 0;
1847
1848 doorbell[0] = cpu_to_be32((MTHCA_ARBEL_MAX_WQES_PER_SEND_DB << 24) |
1849 ((qp->sq.head & 0xffff) << 8) |
1850 f0 | op0);
1851 doorbell[1] = cpu_to_be32((qp->qpn << 8) | size0);
1852
1853 qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB;
1854 size0 = 0;
1855
1856 /*
1857 * Make sure that descriptors are written before
1858 * doorbell record.
1859 */
1860 wmb();
1861 *qp->sq.db = cpu_to_be32(qp->sq.head & 0xffff);
1862
1863 /*
1864 * Make sure doorbell record is written before we
1865 * write MMIO send doorbell.
1866 */
1867 wmb();
1868 mthca_write64(doorbell,
1869 dev->kar + MTHCA_SEND_DOORBELL,
1870 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
1871 }
1872
1841 if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) { 1873 if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) {
1842 mthca_err(dev, "SQ %06x full (%u head, %u tail," 1874 mthca_err(dev, "SQ %06x full (%u head, %u tail,"
1843 " %d max, %d nreq)\n", qp->qpn, 1875 " %d max, %d nreq)\n", qp->qpn,
@@ -2014,8 +2046,6 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
2014 2046
2015out: 2047out:
2016 if (likely(nreq)) { 2048 if (likely(nreq)) {
2017 __be32 doorbell[2];
2018
2019 doorbell[0] = cpu_to_be32((nreq << 24) | 2049 doorbell[0] = cpu_to_be32((nreq << 24) |
2020 ((qp->sq.head & 0xffff) << 8) | 2050 ((qp->sq.head & 0xffff) << 8) |
2021 f0 | op0); 2051 f0 | op0);
diff --git a/drivers/infiniband/hw/mthca/mthca_wqe.h b/drivers/infiniband/hw/mthca/mthca_wqe.h
index 73f1c0b9021e..e7d2c1e86199 100644
--- a/drivers/infiniband/hw/mthca/mthca_wqe.h
+++ b/drivers/infiniband/hw/mthca/mthca_wqe.h
@@ -50,7 +50,8 @@ enum {
50 50
51enum { 51enum {
52 MTHCA_INVAL_LKEY = 0x100, 52 MTHCA_INVAL_LKEY = 0x100,
53 MTHCA_TAVOR_MAX_WQES_PER_RECV_DB = 256 53 MTHCA_TAVOR_MAX_WQES_PER_RECV_DB = 256,
54 MTHCA_ARBEL_MAX_WQES_PER_SEND_DB = 255
54}; 55};
55 56
56struct mthca_next_seg { 57struct mthca_next_seg {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 54ef2fea530f..23885801b6d2 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -608,9 +608,13 @@ void ipoib_ib_dev_flush(void *_dev)
608 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) 608 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
609 ipoib_ib_dev_up(dev); 609 ipoib_ib_dev_up(dev);
610 610
611 down(&priv->vlan_mutex);
612
611 /* Flush any child interfaces too */ 613 /* Flush any child interfaces too */
612 list_for_each_entry(cpriv, &priv->child_intfs, list) 614 list_for_each_entry(cpriv, &priv->child_intfs, list)
613 ipoib_ib_dev_flush(&cpriv->dev); 615 ipoib_ib_dev_flush(&cpriv->dev);
616
617 up(&priv->vlan_mutex);
614} 618}
615 619
616void ipoib_ib_dev_cleanup(struct net_device *dev) 620void ipoib_ib_dev_cleanup(struct net_device *dev)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 2fa30751f362..475d98fa9e26 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -94,8 +94,10 @@ int ipoib_open(struct net_device *dev)
94 if (ipoib_ib_dev_open(dev)) 94 if (ipoib_ib_dev_open(dev))
95 return -EINVAL; 95 return -EINVAL;
96 96
97 if (ipoib_ib_dev_up(dev)) 97 if (ipoib_ib_dev_up(dev)) {
98 ipoib_ib_dev_stop(dev);
98 return -EINVAL; 99 return -EINVAL;
100 }
99 101
100 if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) { 102 if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
101 struct ipoib_dev_priv *cpriv; 103 struct ipoib_dev_priv *cpriv;
@@ -398,9 +400,9 @@ static void path_rec_completion(int status,
398 while ((skb = __skb_dequeue(&neigh->queue))) 400 while ((skb = __skb_dequeue(&neigh->queue)))
399 __skb_queue_tail(&skqueue, skb); 401 __skb_queue_tail(&skqueue, skb);
400 } 402 }
401 } else 403 }
402 path->query = NULL;
403 404
405 path->query = NULL;
404 complete(&path->done); 406 complete(&path->done);
405 407
406 spin_unlock_irqrestore(&priv->lock, flags); 408 spin_unlock_irqrestore(&priv->lock, flags);
@@ -428,7 +430,6 @@ static struct ipoib_path *path_rec_create(struct net_device *dev,
428 skb_queue_head_init(&path->queue); 430 skb_queue_head_init(&path->queue);
429 431
430 INIT_LIST_HEAD(&path->neigh_list); 432 INIT_LIST_HEAD(&path->neigh_list);
431 init_completion(&path->done);
432 433
433 memcpy(path->pathrec.dgid.raw, gid->raw, sizeof (union ib_gid)); 434 memcpy(path->pathrec.dgid.raw, gid->raw, sizeof (union ib_gid));
434 path->pathrec.sgid = priv->local_gid; 435 path->pathrec.sgid = priv->local_gid;
@@ -446,6 +447,8 @@ static int path_rec_start(struct net_device *dev,
446 ipoib_dbg(priv, "Start path record lookup for " IPOIB_GID_FMT "\n", 447 ipoib_dbg(priv, "Start path record lookup for " IPOIB_GID_FMT "\n",
447 IPOIB_GID_ARG(path->pathrec.dgid)); 448 IPOIB_GID_ARG(path->pathrec.dgid));
448 449
450 init_completion(&path->done);
451
449 path->query_id = 452 path->query_id =
450 ib_sa_path_rec_get(priv->ca, priv->port, 453 ib_sa_path_rec_get(priv->ca, priv->port,
451 &path->pathrec, 454 &path->pathrec,
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index c33ed87f9dff..ef3ee035bbc8 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -135,20 +135,14 @@ static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev,
135 if (!mcast) 135 if (!mcast)
136 return NULL; 136 return NULL;
137 137
138 init_completion(&mcast->done);
139
140 mcast->dev = dev; 138 mcast->dev = dev;
141 mcast->created = jiffies; 139 mcast->created = jiffies;
142 mcast->backoff = 1; 140 mcast->backoff = 1;
143 mcast->logcount = 0;
144 141
145 INIT_LIST_HEAD(&mcast->list); 142 INIT_LIST_HEAD(&mcast->list);
146 INIT_LIST_HEAD(&mcast->neigh_list); 143 INIT_LIST_HEAD(&mcast->neigh_list);
147 skb_queue_head_init(&mcast->pkt_queue); 144 skb_queue_head_init(&mcast->pkt_queue);
148 145
149 mcast->ah = NULL;
150 mcast->query = NULL;
151
152 return mcast; 146 return mcast;
153} 147}
154 148
@@ -350,6 +344,8 @@ static int ipoib_mcast_sendonly_join(struct ipoib_mcast *mcast)
350 rec.port_gid = priv->local_gid; 344 rec.port_gid = priv->local_gid;
351 rec.pkey = cpu_to_be16(priv->pkey); 345 rec.pkey = cpu_to_be16(priv->pkey);
352 346
347 init_completion(&mcast->done);
348
353 ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec, 349 ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec,
354 IB_SA_MCMEMBER_REC_MGID | 350 IB_SA_MCMEMBER_REC_MGID |
355 IB_SA_MCMEMBER_REC_PORT_GID | 351 IB_SA_MCMEMBER_REC_PORT_GID |
@@ -469,6 +465,8 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast,
469 rec.traffic_class = priv->broadcast->mcmember.traffic_class; 465 rec.traffic_class = priv->broadcast->mcmember.traffic_class;
470 } 466 }
471 467
468 init_completion(&mcast->done);
469
472 ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec, comp_mask, 470 ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec, comp_mask,
473 mcast->backoff * 1000, GFP_ATOMIC, 471 mcast->backoff * 1000, GFP_ATOMIC,
474 ipoib_mcast_join_complete, 472 ipoib_mcast_join_complete,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 78c7418478d6..cd12fca73b0d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1028,7 +1028,6 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1028 mddev->size = le64_to_cpu(sb->size)/2; 1028 mddev->size = le64_to_cpu(sb->size)/2;
1029 mddev->events = le64_to_cpu(sb->events); 1029 mddev->events = le64_to_cpu(sb->events);
1030 mddev->bitmap_offset = 0; 1030 mddev->bitmap_offset = 0;
1031 mddev->default_bitmap_offset = 0;
1032 mddev->default_bitmap_offset = 1024; 1031 mddev->default_bitmap_offset = 1024;
1033 1032
1034 mddev->recovery_cp = le64_to_cpu(sb->resync_offset); 1033 mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
@@ -2932,6 +2931,9 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
2932 2931
2933 mddev->sb_dirty = 1; 2932 mddev->sb_dirty = 1;
2934 2933
2934 mddev->default_bitmap_offset = MD_SB_BYTES >> 9;
2935 mddev->bitmap_offset = 0;
2936
2935 /* 2937 /*
2936 * Generate a 128 bit UUID 2938 * Generate a 128 bit UUID
2937 */ 2939 */
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 2da9d3ba902d..3066c587b539 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -953,9 +953,6 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
953 int mirror = 0; 953 int mirror = 0;
954 mirror_info_t *p; 954 mirror_info_t *p;
955 955
956 if (rdev->saved_raid_disk >= 0 &&
957 conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
958 mirror = rdev->saved_raid_disk;
959 for (mirror=0; mirror < mddev->raid_disks; mirror++) 956 for (mirror=0; mirror < mddev->raid_disks; mirror++)
960 if ( !(p=conf->mirrors+mirror)->rdev) { 957 if ( !(p=conf->mirrors+mirror)->rdev) {
961 958
@@ -972,7 +969,10 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
972 p->head_position = 0; 969 p->head_position = 0;
973 rdev->raid_disk = mirror; 970 rdev->raid_disk = mirror;
974 found = 1; 971 found = 1;
975 if (rdev->saved_raid_disk != mirror) 972 /* As all devices are equivalent, we don't need a full recovery
973 * if this was recently any drive of the array
974 */
975 if (rdev->saved_raid_disk < 0)
976 conf->fullsync = 1; 976 conf->fullsync = 1;
977 rcu_assign_pointer(p->rdev, rdev); 977 rcu_assign_pointer(p->rdev, rdev);
978 break; 978 break;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 867f06ae33d9..713dc9c2c730 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -552,7 +552,11 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
552 !test_bit(In_sync, &rdev->flags)) 552 !test_bit(In_sync, &rdev->flags))
553 continue; 553 continue;
554 554
555 if (!atomic_read(&rdev->nr_pending)) { 555 /* This optimisation is debatable, and completely destroys
556 * sequential read speed for 'far copies' arrays. So only
557 * keep it for 'near' arrays, and review those later.
558 */
559 if (conf->near_copies > 1 && !atomic_read(&rdev->nr_pending)) {
556 disk = ndisk; 560 disk = ndisk;
557 slot = nslot; 561 slot = nslot;
558 break; 562 break;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e2a40283e323..36d5f8ac8265 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1704,7 +1704,9 @@ static void raid5d (mddev_t *mddev)
1704 1704
1705 if (conf->seq_flush - conf->seq_write > 0) { 1705 if (conf->seq_flush - conf->seq_write > 0) {
1706 int seq = conf->seq_flush; 1706 int seq = conf->seq_flush;
1707 spin_unlock_irq(&conf->device_lock);
1707 bitmap_unplug(mddev->bitmap); 1708 bitmap_unplug(mddev->bitmap);
1709 spin_lock_irq(&conf->device_lock);
1708 conf->seq_write = seq; 1710 conf->seq_write = seq;
1709 activate_bit_delay(conf); 1711 activate_bit_delay(conf);
1710 } 1712 }
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index eae5a35629c5..0000d162d198 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -1702,6 +1702,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1702 int data_disks = raid_disks - 2; 1702 int data_disks = raid_disks - 2;
1703 sector_t max_sector = mddev->size << 1; 1703 sector_t max_sector = mddev->size << 1;
1704 int sync_blocks; 1704 int sync_blocks;
1705 int still_degraded = 0;
1706 int i;
1705 1707
1706 if (sector_nr >= max_sector) { 1708 if (sector_nr >= max_sector) {
1707 /* just being told to finish up .. nothing much to do */ 1709 /* just being told to finish up .. nothing much to do */
@@ -1710,7 +1712,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1710 if (mddev->curr_resync < max_sector) /* aborted */ 1712 if (mddev->curr_resync < max_sector) /* aborted */
1711 bitmap_end_sync(mddev->bitmap, mddev->curr_resync, 1713 bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
1712 &sync_blocks, 1); 1714 &sync_blocks, 1);
1713 else /* compelted sync */ 1715 else /* completed sync */
1714 conf->fullsync = 0; 1716 conf->fullsync = 0;
1715 bitmap_close_sync(mddev->bitmap); 1717 bitmap_close_sync(mddev->bitmap);
1716 1718
@@ -1748,7 +1750,16 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1748 */ 1750 */
1749 schedule_timeout_uninterruptible(1); 1751 schedule_timeout_uninterruptible(1);
1750 } 1752 }
1751 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 0); 1753 /* Need to check if array will still be degraded after recovery/resync
1754 * We don't need to check the 'failed' flag as when that gets set,
1755 * recovery aborts.
1756 */
1757 for (i=0; i<mddev->raid_disks; i++)
1758 if (conf->disks[i].rdev == NULL)
1759 still_degraded = 1;
1760
1761 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded);
1762
1752 spin_lock(&sh->lock); 1763 spin_lock(&sh->lock);
1753 set_bit(STRIPE_SYNCING, &sh->state); 1764 set_bit(STRIPE_SYNCING, &sh->state);
1754 clear_bit(STRIPE_INSYNC, &sh->state); 1765 clear_bit(STRIPE_INSYNC, &sh->state);
@@ -1784,7 +1795,9 @@ static void raid6d (mddev_t *mddev)
1784 1795
1785 if (conf->seq_flush - conf->seq_write > 0) { 1796 if (conf->seq_flush - conf->seq_write > 0) {
1786 int seq = conf->seq_flush; 1797 int seq = conf->seq_flush;
1798 spin_unlock_irq(&conf->device_lock);
1787 bitmap_unplug(mddev->bitmap); 1799 bitmap_unplug(mddev->bitmap);
1800 spin_lock_irq(&conf->device_lock);
1788 conf->seq_write = seq; 1801 conf->seq_write = seq;
1789 activate_bit_delay(conf); 1802 activate_bit_delay(conf);
1790 } 1803 }
@@ -2145,9 +2158,15 @@ static int raid6_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
2145 /* no point adding a device */ 2158 /* no point adding a device */
2146 return 0; 2159 return 0;
2147 /* 2160 /*
2148 * find the disk ... 2161 * find the disk ... but prefer rdev->saved_raid_disk
2162 * if possible.
2149 */ 2163 */
2150 for (disk=0; disk < mddev->raid_disks; disk++) 2164 if (rdev->saved_raid_disk >= 0 &&
2165 conf->disks[rdev->saved_raid_disk].rdev == NULL)
2166 disk = rdev->saved_raid_disk;
2167 else
2168 disk = 0;
2169 for ( ; disk < mddev->raid_disks; disk++)
2151 if ((p=conf->disks + disk)->rdev == NULL) { 2170 if ((p=conf->disks + disk)->rdev == NULL) {
2152 clear_bit(In_sync, &rdev->flags); 2171 clear_bit(In_sync, &rdev->flags);
2153 rdev->raid_disk = disk; 2172 rdev->raid_disk = disk;
diff --git a/drivers/media/dvb/b2c2/flexcop-hw-filter.c b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
index 75cf237196eb..b386cc66c6b3 100644
--- a/drivers/media/dvb/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
@@ -19,7 +19,7 @@ void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
19 flexcop_set_ibi_value(ctrl_208,SMC_Enable_sig,onoff); 19 flexcop_set_ibi_value(ctrl_208,SMC_Enable_sig,onoff);
20} 20}
21 21
22void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff) 22static void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff)
23{ 23{
24 flexcop_set_ibi_value(ctrl_208,Null_filter_sig,onoff); 24 flexcop_set_ibi_value(ctrl_208,Null_filter_sig,onoff);
25} 25}
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 2aa767f9bd7d..cb2e7d6ba283 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -35,7 +35,7 @@
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/rwsem.h> 38#include <linux/spinlock.h>
39#include <linux/sched.h> 39#include <linux/sched.h>
40 40
41#include "dvb_ca_en50221.h" 41#include "dvb_ca_en50221.h"
@@ -111,9 +111,6 @@ struct dvb_ca_slot {
111 /* size of the buffer to use when talking to the CAM */ 111 /* size of the buffer to use when talking to the CAM */
112 int link_buf_size; 112 int link_buf_size;
113 113
114 /* semaphore for syncing access to slot structure */
115 struct rw_semaphore sem;
116
117 /* buffer for incoming packets */ 114 /* buffer for incoming packets */
118 struct dvb_ringbuffer rx_buffer; 115 struct dvb_ringbuffer rx_buffer;
119 116
@@ -602,14 +599,11 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
602 if (ebuf == NULL) { 599 if (ebuf == NULL) {
603 int buf_free; 600 int buf_free;
604 601
605 down_read(&ca->slot_info[slot].sem);
606 if (ca->slot_info[slot].rx_buffer.data == NULL) { 602 if (ca->slot_info[slot].rx_buffer.data == NULL) {
607 up_read(&ca->slot_info[slot].sem);
608 status = -EIO; 603 status = -EIO;
609 goto exit; 604 goto exit;
610 } 605 }
611 buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer); 606 buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer);
612 up_read(&ca->slot_info[slot].sem);
613 607
614 if (buf_free < (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) { 608 if (buf_free < (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) {
615 status = -EAGAIN; 609 status = -EAGAIN;
@@ -680,14 +674,11 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
680 674
681 /* OK, add it to the receive buffer, or copy into external buffer if supplied */ 675 /* OK, add it to the receive buffer, or copy into external buffer if supplied */
682 if (ebuf == NULL) { 676 if (ebuf == NULL) {
683 down_read(&ca->slot_info[slot].sem);
684 if (ca->slot_info[slot].rx_buffer.data == NULL) { 677 if (ca->slot_info[slot].rx_buffer.data == NULL) {
685 up_read(&ca->slot_info[slot].sem);
686 status = -EIO; 678 status = -EIO;
687 goto exit; 679 goto exit;
688 } 680 }
689 dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read); 681 dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read);
690 up_read(&ca->slot_info[slot].sem);
691 } else { 682 } else {
692 memcpy(ebuf, buf, bytes_read); 683 memcpy(ebuf, buf, bytes_read);
693 } 684 }
@@ -802,12 +793,8 @@ static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
802{ 793{
803 dprintk("%s\n", __FUNCTION__); 794 dprintk("%s\n", __FUNCTION__);
804 795
805 down_write(&ca->slot_info[slot].sem);
806 ca->pub->slot_shutdown(ca->pub, slot); 796 ca->pub->slot_shutdown(ca->pub, slot);
807 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; 797 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
808 vfree(ca->slot_info[slot].rx_buffer.data);
809 ca->slot_info[slot].rx_buffer.data = NULL;
810 up_write(&ca->slot_info[slot].sem);
811 798
812 /* need to wake up all processes to check if they're now 799 /* need to wake up all processes to check if they're now
813 trying to write to a defunct CAM */ 800 trying to write to a defunct CAM */
@@ -893,7 +880,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
893 880
894 case DVB_CA_SLOTSTATE_RUNNING: 881 case DVB_CA_SLOTSTATE_RUNNING:
895 if (ca->open) 882 if (ca->open)
896 dvb_ca_en50221_read_data(ca, slot, NULL, 0); 883 dvb_ca_en50221_thread_wakeup(ca);
897 break; 884 break;
898 } 885 }
899} 886}
@@ -1127,16 +1114,16 @@ static int dvb_ca_en50221_thread(void *data)
1127 break; 1114 break;
1128 } 1115 }
1129 1116
1130 rxbuf = vmalloc(RX_BUFFER_SIZE); 1117 if (ca->slot_info[slot].rx_buffer.data == NULL) {
1131 if (rxbuf == NULL) { 1118 rxbuf = vmalloc(RX_BUFFER_SIZE);
1132 printk("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n", ca->dvbdev->adapter->num); 1119 if (rxbuf == NULL) {
1133 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1120 printk("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n", ca->dvbdev->adapter->num);
1134 dvb_ca_en50221_thread_update_delay(ca); 1121 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1135 break; 1122 dvb_ca_en50221_thread_update_delay(ca);
1123 break;
1124 }
1125 dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
1136 } 1126 }
1137 down_write(&ca->slot_info[slot].sem);
1138 dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
1139 up_write(&ca->slot_info[slot].sem);
1140 1127
1141 ca->pub->slot_ts_enable(ca->pub, slot); 1128 ca->pub->slot_ts_enable(ca->pub, slot);
1142 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING; 1129 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING;
@@ -1148,11 +1135,7 @@ static int dvb_ca_en50221_thread(void *data)
1148 if (!ca->open) 1135 if (!ca->open)
1149 continue; 1136 continue;
1150 1137
1151 // no need to poll if the CAM supports IRQs 1138 // poll slots for data
1152 if (ca->slot_info[slot].da_irq_supported)
1153 break;
1154
1155 // poll mode
1156 pktcount = 0; 1139 pktcount = 0;
1157 while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) { 1140 while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) {
1158 if (!ca->open) 1141 if (!ca->open)
@@ -1367,12 +1350,13 @@ exit:
1367/** 1350/**
1368 * Condition for waking up in dvb_ca_en50221_io_read_condition 1351 * Condition for waking up in dvb_ca_en50221_io_read_condition
1369 */ 1352 */
1370static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *result, int *_slot) 1353static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
1354 int *result, int *_slot)
1371{ 1355{
1372 int slot; 1356 int slot;
1373 int slot_count = 0; 1357 int slot_count = 0;
1374 int idx; 1358 int idx;
1375 int fraglen; 1359 size_t fraglen;
1376 int connection_id = -1; 1360 int connection_id = -1;
1377 int found = 0; 1361 int found = 0;
1378 u8 hdr[2]; 1362 u8 hdr[2];
@@ -1382,10 +1366,7 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *resu
1382 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) 1366 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING)
1383 goto nextslot; 1367 goto nextslot;
1384 1368
1385 down_read(&ca->slot_info[slot].sem);
1386
1387 if (ca->slot_info[slot].rx_buffer.data == NULL) { 1369 if (ca->slot_info[slot].rx_buffer.data == NULL) {
1388 up_read(&ca->slot_info[slot].sem);
1389 return 0; 1370 return 0;
1390 } 1371 }
1391 1372
@@ -1403,10 +1384,7 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *resu
1403 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen); 1384 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen);
1404 } 1385 }
1405 1386
1406 if (!found) 1387nextslot:
1407 up_read(&ca->slot_info[slot].sem);
1408
1409 nextslot:
1410 slot = (slot + 1) % ca->slot_count; 1388 slot = (slot + 1) % ca->slot_count;
1411 slot_count++; 1389 slot_count++;
1412 } 1390 }
@@ -1511,8 +1489,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
1511 goto exit; 1489 goto exit;
1512 status = pktlen; 1490 status = pktlen;
1513 1491
1514 exit: 1492exit:
1515 up_read(&ca->slot_info[slot].sem);
1516 return status; 1493 return status;
1517} 1494}
1518 1495
@@ -1544,11 +1521,11 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
1544 for (i = 0; i < ca->slot_count; i++) { 1521 for (i = 0; i < ca->slot_count; i++) {
1545 1522
1546 if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) { 1523 if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) {
1547 down_write(&ca->slot_info[i].sem);
1548 if (ca->slot_info[i].rx_buffer.data != NULL) { 1524 if (ca->slot_info[i].rx_buffer.data != NULL) {
1525 /* it is safe to call this here without locks because
1526 * ca->open == 0. Data is not read in this case */
1549 dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer); 1527 dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer);
1550 } 1528 }
1551 up_write(&ca->slot_info[i].sem);
1552 } 1529 }
1553 } 1530 }
1554 1531
@@ -1607,7 +1584,6 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
1607 dprintk("%s\n", __FUNCTION__); 1584 dprintk("%s\n", __FUNCTION__);
1608 1585
1609 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { 1586 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
1610 up_read(&ca->slot_info[slot].sem);
1611 mask |= POLLIN; 1587 mask |= POLLIN;
1612 } 1588 }
1613 1589
@@ -1619,7 +1595,6 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
1619 poll_wait(file, &ca->wait_queue, wait); 1595 poll_wait(file, &ca->wait_queue, wait);
1620 1596
1621 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { 1597 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
1622 up_read(&ca->slot_info[slot].sem);
1623 mask |= POLLIN; 1598 mask |= POLLIN;
1624 } 1599 }
1625 1600
@@ -1709,7 +1684,6 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1709 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE; 1684 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE;
1710 atomic_set(&ca->slot_info[i].camchange_count, 0); 1685 atomic_set(&ca->slot_info[i].camchange_count, 0);
1711 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED; 1686 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
1712 init_rwsem(&ca->slot_info[i].sem);
1713 } 1687 }
1714 1688
1715 if (signal_pending(current)) { 1689 if (signal_pending(current)) {
@@ -1729,7 +1703,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1729 ca->thread_pid = ret; 1703 ca->thread_pid = ret;
1730 return 0; 1704 return 0;
1731 1705
1732 error: 1706error:
1733 if (ca != NULL) { 1707 if (ca != NULL) {
1734 if (ca->dvbdev != NULL) 1708 if (ca->dvbdev != NULL)
1735 dvb_unregister_device(ca->dvbdev); 1709 dvb_unregister_device(ca->dvbdev);
@@ -1771,6 +1745,9 @@ void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)
1771 1745
1772 for (i = 0; i < ca->slot_count; i++) { 1746 for (i = 0; i < ca->slot_count; i++) {
1773 dvb_ca_en50221_slot_shutdown(ca, i); 1747 dvb_ca_en50221_slot_shutdown(ca, i);
1748 if (ca->slot_info[i].rx_buffer.data != NULL) {
1749 vfree(ca->slot_info[i].rx_buffer.data);
1750 }
1774 } 1751 }
1775 kfree(ca->slot_info); 1752 kfree(ca->slot_info);
1776 dvb_unregister_device(ca->dvbdev); 1753 dvb_unregister_device(ca->dvbdev);
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 87935490bfb2..df536bd2e103 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -151,6 +151,8 @@ struct dvb_net_priv {
151 unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */ 151 unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */
152 int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */ 152 int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */
153 unsigned long ts_count; /* Current ts cell counter. */ 153 unsigned long ts_count; /* Current ts cell counter. */
154
155 struct semaphore mutex;
154}; 156};
155 157
156 158
@@ -881,12 +883,13 @@ static int dvb_net_filter_sec_set(struct net_device *dev,
881 883
882static int dvb_net_feed_start(struct net_device *dev) 884static int dvb_net_feed_start(struct net_device *dev)
883{ 885{
884 int ret, i; 886 int ret = 0, i;
885 struct dvb_net_priv *priv = dev->priv; 887 struct dvb_net_priv *priv = dev->priv;
886 struct dmx_demux *demux = priv->demux; 888 struct dmx_demux *demux = priv->demux;
887 unsigned char *mac = (unsigned char *) dev->dev_addr; 889 unsigned char *mac = (unsigned char *) dev->dev_addr;
888 890
889 dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode); 891 dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode);
892 down(&priv->mutex);
890 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0]) 893 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
891 printk("%s: BUG %d\n", __FUNCTION__, __LINE__); 894 printk("%s: BUG %d\n", __FUNCTION__, __LINE__);
892 895
@@ -900,7 +903,7 @@ static int dvb_net_feed_start(struct net_device *dev)
900 dvb_net_sec_callback); 903 dvb_net_sec_callback);
901 if (ret<0) { 904 if (ret<0) {
902 printk("%s: could not allocate section feed\n", dev->name); 905 printk("%s: could not allocate section feed\n", dev->name);
903 return ret; 906 goto error;
904 } 907 }
905 908
906 ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1); 909 ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1);
@@ -909,7 +912,7 @@ static int dvb_net_feed_start(struct net_device *dev)
909 printk("%s: could not set section feed\n", dev->name); 912 printk("%s: could not set section feed\n", dev->name);
910 priv->demux->release_section_feed(priv->demux, priv->secfeed); 913 priv->demux->release_section_feed(priv->demux, priv->secfeed);
911 priv->secfeed=NULL; 914 priv->secfeed=NULL;
912 return ret; 915 goto error;
913 } 916 }
914 917
915 if (priv->rx_mode != RX_MODE_PROMISC) { 918 if (priv->rx_mode != RX_MODE_PROMISC) {
@@ -948,7 +951,7 @@ static int dvb_net_feed_start(struct net_device *dev)
948 ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback); 951 ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback);
949 if (ret < 0) { 952 if (ret < 0) {
950 printk("%s: could not allocate ts feed\n", dev->name); 953 printk("%s: could not allocate ts feed\n", dev->name);
951 return ret; 954 goto error;
952 } 955 }
953 956
954 /* Set netdevice pointer for ts decaps callback. */ 957 /* Set netdevice pointer for ts decaps callback. */
@@ -962,23 +965,26 @@ static int dvb_net_feed_start(struct net_device *dev)
962 printk("%s: could not set ts feed\n", dev->name); 965 printk("%s: could not set ts feed\n", dev->name);
963 priv->demux->release_ts_feed(priv->demux, priv->tsfeed); 966 priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
964 priv->tsfeed = NULL; 967 priv->tsfeed = NULL;
965 return ret; 968 goto error;
966 } 969 }
967 970
968 dprintk("%s: start filtering\n", __FUNCTION__); 971 dprintk("%s: start filtering\n", __FUNCTION__);
969 priv->tsfeed->start_filtering(priv->tsfeed); 972 priv->tsfeed->start_filtering(priv->tsfeed);
970 } else 973 } else
971 return -EINVAL; 974 ret = -EINVAL;
972 975
973 return 0; 976error:
977 up(&priv->mutex);
978 return ret;
974} 979}
975 980
976static int dvb_net_feed_stop(struct net_device *dev) 981static int dvb_net_feed_stop(struct net_device *dev)
977{ 982{
978 struct dvb_net_priv *priv = dev->priv; 983 struct dvb_net_priv *priv = dev->priv;
979 int i; 984 int i, ret = 0;
980 985
981 dprintk("%s\n", __FUNCTION__); 986 dprintk("%s\n", __FUNCTION__);
987 down(&priv->mutex);
982 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { 988 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) {
983 if (priv->secfeed) { 989 if (priv->secfeed) {
984 if (priv->secfeed->is_filtering) { 990 if (priv->secfeed->is_filtering) {
@@ -1019,8 +1025,9 @@ static int dvb_net_feed_stop(struct net_device *dev)
1019 else 1025 else
1020 printk("%s: no ts feed to stop\n", dev->name); 1026 printk("%s: no ts feed to stop\n", dev->name);
1021 } else 1027 } else
1022 return -EINVAL; 1028 ret = -EINVAL;
1023 return 0; 1029 up(&priv->mutex);
1030 return ret;
1024} 1031}
1025 1032
1026 1033
@@ -1044,8 +1051,8 @@ static void wq_set_multicast_list (void *data)
1044 struct dvb_net_priv *priv = dev->priv; 1051 struct dvb_net_priv *priv = dev->priv;
1045 1052
1046 dvb_net_feed_stop(dev); 1053 dvb_net_feed_stop(dev);
1047
1048 priv->rx_mode = RX_MODE_UNI; 1054 priv->rx_mode = RX_MODE_UNI;
1055 spin_lock_bh(&dev->xmit_lock);
1049 1056
1050 if (dev->flags & IFF_PROMISC) { 1057 if (dev->flags & IFF_PROMISC) {
1051 dprintk("%s: promiscuous mode\n", dev->name); 1058 dprintk("%s: promiscuous mode\n", dev->name);
@@ -1070,6 +1077,7 @@ static void wq_set_multicast_list (void *data)
1070 } 1077 }
1071 } 1078 }
1072 1079
1080 spin_unlock_bh(&dev->xmit_lock);
1073 dvb_net_feed_start(dev); 1081 dvb_net_feed_start(dev);
1074} 1082}
1075 1083
@@ -1200,6 +1208,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1200 1208
1201 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net); 1209 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
1202 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net); 1210 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);
1211 init_MUTEX(&priv->mutex);
1203 1212
1204 net->base_addr = pid; 1213 net->base_addr = pid;
1205 1214
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c
index 49f541d9a042..8c7beffb045f 100644
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ b/drivers/media/dvb/dvb-usb/a800.c
@@ -65,7 +65,7 @@ static struct dvb_usb_rc_key a800_rc_keys[] = {
65 65
66}; 66};
67 67
68int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 68static int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
69{ 69{
70 u8 key[5]; 70 u8 key[5];
71 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0), 71 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 00b946419b40..269d899da488 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -21,9 +21,9 @@ MODULE_LICENSE("GPL");
21int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) 21int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff)
22{ 22{
23 if (d->priv != NULL) { 23 if (d->priv != NULL) {
24 struct dib_fe_xfer_ops *ops = d->priv; 24 struct dibusb_state *st = d->priv;
25 if (ops->fifo_ctrl != NULL) 25 if (st->ops.fifo_ctrl != NULL)
26 if (ops->fifo_ctrl(d->fe,onoff)) { 26 if (st->ops.fifo_ctrl(d->fe,onoff)) {
27 err("error while controlling the fifo of the demod."); 27 err("error while controlling the fifo of the demod.");
28 return -ENODEV; 28 return -ENODEV;
29 } 29 }
@@ -35,9 +35,9 @@ EXPORT_SYMBOL(dibusb_streaming_ctrl);
35int dibusb_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) 35int dibusb_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff)
36{ 36{
37 if (d->priv != NULL) { 37 if (d->priv != NULL) {
38 struct dib_fe_xfer_ops *ops = d->priv; 38 struct dibusb_state *st = d->priv;
39 if (d->pid_filtering && ops->pid_ctrl != NULL) 39 if (st->ops.pid_ctrl != NULL)
40 ops->pid_ctrl(d->fe,index,pid,onoff); 40 st->ops.pid_ctrl(d->fe,index,pid,onoff);
41 } 41 }
42 return 0; 42 return 0;
43} 43}
@@ -46,9 +46,9 @@ EXPORT_SYMBOL(dibusb_pid_filter);
46int dibusb_pid_filter_ctrl(struct dvb_usb_device *d, int onoff) 46int dibusb_pid_filter_ctrl(struct dvb_usb_device *d, int onoff)
47{ 47{
48 if (d->priv != NULL) { 48 if (d->priv != NULL) {
49 struct dib_fe_xfer_ops *ops = d->priv; 49 struct dibusb_state *st = d->priv;
50 if (ops->pid_parse != NULL) 50 if (st->ops.pid_parse != NULL)
51 if (ops->pid_parse(d->fe,onoff) < 0) 51 if (st->ops.pid_parse(d->fe,onoff) < 0)
52 err("could not handle pid_parser"); 52 err("could not handle pid_parser");
53 } 53 }
54 return 0; 54 return 0;
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index 74545f82eff1..f98e306a5759 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -148,7 +148,7 @@ static struct dvb_usb_rc_key digitv_rc_keys[] = {
148}; 148};
149 149
150/* TODO is it really the NEC protocol ? */ 150/* TODO is it really the NEC protocol ? */
151int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 151static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
152{ 152{
153 u8 key[5]; 153 u8 key[5];
154 154
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index a902059812a2..dd8e0b94edba 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -23,7 +23,7 @@ module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644);
23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0)."); 23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0).");
24 24
25/* general initialization functions */ 25/* general initialization functions */
26int dvb_usb_exit(struct dvb_usb_device *d) 26static int dvb_usb_exit(struct dvb_usb_device *d)
27{ 27{
28 deb_info("state before exiting everything: %x\n",d->state); 28 deb_info("state before exiting everything: %x\n",d->state);
29 dvb_usb_remote_exit(d); 29 dvb_usb_remote_exit(d);
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index 9f639297a9f2..d9a8ede14b45 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -7,7 +7,7 @@
7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH 7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH
8 Holger Waechtler <holger@convergence.de> 8 Holger Waechtler <holger@convergence.de>
9 9
10 Copyright (C) 2004 Steven Toth <steve@toth.demon.co.uk> 10 Copyright (C) 2004 Steven Toth <stoth@hauppauge.com>
11 11
12 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by 13 it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index 11f86806756e..1f250885d2ce 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -7,7 +7,7 @@
7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH 7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH
8 Holger Waechtler <holger@convergence.de> 8 Holger Waechtler <holger@convergence.de>
9 9
10 Copyright (C) 2004 Steven Toth <steve@toth.demon.co.uk> 10 Copyright (C) 2004 Steven Toth <stoth@hauppauge.com>
11 11
12 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by 13 it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c
index bad0933eb714..84b62881cea7 100644
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ b/drivers/media/dvb/frontends/nxt200x.c
@@ -44,6 +44,8 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/moduleparam.h> 46#include <linux/moduleparam.h>
47#include <linux/slab.h>
48#include <linux/string.h>
47 49
48#include "dvb_frontend.h" 50#include "dvb_frontend.h"
49#include "dvb-pll.h" 51#include "dvb-pll.h"
diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
index c6d276618e86..ad8647a3c85e 100644
--- a/drivers/media/dvb/frontends/ves1820.c
+++ b/drivers/media/dvb/frontends/ves1820.c
@@ -140,25 +140,25 @@ static int ves1820_set_symbolrate(struct ves1820_state *state, u32 symbolrate)
140 /* yeuch! */ 140 /* yeuch! */
141 fpxin = state->config->xin * 10; 141 fpxin = state->config->xin * 10;
142 fptmp = fpxin; do_div(fptmp, 123); 142 fptmp = fpxin; do_div(fptmp, 123);
143 if (symbolrate < fptmp); 143 if (symbolrate < fptmp)
144 SFIL = 1; 144 SFIL = 1;
145 fptmp = fpxin; do_div(fptmp, 160); 145 fptmp = fpxin; do_div(fptmp, 160);
146 if (symbolrate < fptmp); 146 if (symbolrate < fptmp)
147 SFIL = 0; 147 SFIL = 0;
148 fptmp = fpxin; do_div(fptmp, 246); 148 fptmp = fpxin; do_div(fptmp, 246);
149 if (symbolrate < fptmp); 149 if (symbolrate < fptmp)
150 SFIL = 1; 150 SFIL = 1;
151 fptmp = fpxin; do_div(fptmp, 320); 151 fptmp = fpxin; do_div(fptmp, 320);
152 if (symbolrate < fptmp); 152 if (symbolrate < fptmp)
153 SFIL = 0; 153 SFIL = 0;
154 fptmp = fpxin; do_div(fptmp, 492); 154 fptmp = fpxin; do_div(fptmp, 492);
155 if (symbolrate < fptmp); 155 if (symbolrate < fptmp)
156 SFIL = 1; 156 SFIL = 1;
157 fptmp = fpxin; do_div(fptmp, 640); 157 fptmp = fpxin; do_div(fptmp, 640);
158 if (symbolrate < fptmp); 158 if (symbolrate < fptmp)
159 SFIL = 0; 159 SFIL = 0;
160 fptmp = fpxin; do_div(fptmp, 984); 160 fptmp = fpxin; do_div(fptmp, 984);
161 if (symbolrate < fptmp); 161 if (symbolrate < fptmp)
162 SFIL = 1; 162 SFIL = 1;
163 163
164 fin = state->config->xin >> 4; 164 fin = state->config->xin >> 4;
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index d8bf65877897..fa5034a9ecf5 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -81,6 +81,7 @@ config DVB_BUDGET_CI
81 tristate "Budget cards with onboard CI connector" 81 tristate "Budget cards with onboard CI connector"
82 depends on DVB_CORE && PCI 82 depends on DVB_CORE && PCI
83 select VIDEO_SAA7146 83 select VIDEO_SAA7146
84 select DVB_STV0297
84 select DVB_STV0299 85 select DVB_STV0299
85 select DVB_TDA1004X 86 select DVB_TDA1004X
86 help 87 help
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index c3801e328fe9..6079e8865d5b 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -40,6 +40,7 @@
40 40
41#include "av7110.h" 41#include "av7110.h"
42#include "av7110_hw.h" 42#include "av7110_hw.h"
43#include "av7110_ca.h"
43 44
44 45
45void CI_handle(struct av7110 *av7110, u8 *data, u16 len) 46void CI_handle(struct av7110 *av7110, u8 *data, u16 len)
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index aa75dc03a0b3..9f51bae7194c 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -1020,6 +1020,8 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
1020 1020
1021static struct saa7146_extension budget_extension = { 1021static struct saa7146_extension budget_extension = {
1022 .name = "budget_av", 1022 .name = "budget_av",
1023 .flags = SAA7146_I2C_SHORT_DELAY,
1024
1023 .pci_tbl = pci_tbl, 1025 .pci_tbl = pci_tbl,
1024 1026
1025 .module = THIS_MODULE, 1027 .module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 75fb92d60998..b9b3cd9c0369 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -1166,7 +1166,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
1166 1166
1167static struct saa7146_extension budget_extension = { 1167static struct saa7146_extension budget_extension = {
1168 .name = "budget_ci dvb\0", 1168 .name = "budget_ci dvb\0",
1169 .flags = 0, 1169 .flags = SAA7146_I2C_SHORT_DELAY,
1170 1170
1171 .module = THIS_MODULE, 1171 .module = THIS_MODULE,
1172 .pci_tbl = &pci_tbl[0], 1172 .pci_tbl = &pci_tbl[0],
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 4fd8bbc47037..bc4ce7559cbe 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -738,7 +738,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
738 738
739static struct saa7146_extension budget_extension = { 739static struct saa7146_extension budget_extension = {
740 .name = "budget dvb\0", 740 .name = "budget dvb\0",
741 .flags = 0, 741 .flags = SAA7146_I2C_SHORT_DELAY,
742 742
743 .module = THIS_MODULE, 743 .module = THIS_MODULE,
744 .pci_tbl = pci_tbl, 744 .pci_tbl = pci_tbl,
diff --git a/drivers/media/dvb/ttpci/ttpci-eeprom.c b/drivers/media/dvb/ttpci/ttpci-eeprom.c
index e9a8457b0727..ac79ef178c05 100644
--- a/drivers/media/dvb/ttpci/ttpci-eeprom.c
+++ b/drivers/media/dvb/ttpci/ttpci-eeprom.c
@@ -37,6 +37,7 @@
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39 39
40#include "ttpci-eeprom.h"
40 41
41#if 1 42#if 1
42#define dprintk(x...) do { printk(x); } while (0) 43#define dprintk(x...) do { printk(x); } while (0)
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 1a3b3c7e5e99..cc4a723e24db 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -26,15 +26,12 @@ config VIDEO_BT848
26 module will be called bttv. 26 module will be called bttv.
27 27
28config VIDEO_BT848_DVB 28config VIDEO_BT848_DVB
29 tristate "DVB/ATSC Support for bt878 based TV cards" 29 bool "DVB/ATSC Support for bt878 based TV cards"
30 depends on VIDEO_BT848 && DVB_CORE 30 depends on VIDEO_BT848 && DVB_CORE
31 select DVB_BT8XX 31 select DVB_BT8XX
32 ---help--- 32 ---help---
33 This adds support for DVB/ATSC cards based on the BT878 chip. 33 This adds support for DVB/ATSC cards based on the BT878 chip.
34 34
35 To compile this driver as a module, choose M here: the
36 module will be called dvb-bt8xx.
37
38config VIDEO_SAA6588 35config VIDEO_SAA6588
39 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards" 36 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards"
40 depends on VIDEO_DEV && I2C && VIDEO_BT848 37 depends on VIDEO_DEV && I2C && VIDEO_BT848
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
index e31ebb11c468..012be639aa18 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bttv-cards.c
@@ -2904,7 +2904,7 @@ void __devinit bttv_idcard(struct bttv *btv)
2904 */ 2904 */
2905 2905
2906/* Some Modular Technology cards have an eeprom, but no subsystem ID */ 2906/* Some Modular Technology cards have an eeprom, but no subsystem ID */
2907void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256]) 2907static void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256])
2908{ 2908{
2909 int type = -1; 2909 int type = -1;
2910 2910
@@ -3879,7 +3879,7 @@ static void __devinit init_PXC200(struct bttv *btv)
3879 * error. ERROR_CPLD_Check_Failed. 3879 * error. ERROR_CPLD_Check_Failed.
3880 */ 3880 */
3881/* ----------------------------------------------------------------------- */ 3881/* ----------------------------------------------------------------------- */
3882void 3882static void
3883init_RTV24 (struct bttv *btv) 3883init_RTV24 (struct bttv *btv)
3884{ 3884{
3885 uint32_t dataRead = 0; 3885 uint32_t dataRead = 0;
@@ -4103,7 +4103,7 @@ void tea5757_set_freq(struct bttv *btv, unsigned short freq)
4103/* ----------------------------------------------------------------------- */ 4103/* ----------------------------------------------------------------------- */
4104/* winview */ 4104/* winview */
4105 4105
4106void winview_audio(struct bttv *btv, struct video_audio *v, int set) 4106static void winview_audio(struct bttv *btv, struct video_audio *v, int set)
4107{ 4107{
4108 /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */ 4108 /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */
4109 int bits_out, loops, vol, data; 4109 int bits_out, loops, vol, data;
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index 709099f03bd2..3c58a2a68906 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -1720,7 +1720,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1720 memset(i,0,sizeof(*i)); 1720 memset(i,0,sizeof(*i));
1721 i->index = n; 1721 i->index = n;
1722 i->type = V4L2_INPUT_TYPE_CAMERA; 1722 i->type = V4L2_INPUT_TYPE_CAMERA;
1723 i->audioset = 1; 1723 i->audioset = 0;
1724 if (i->index == bttv_tvcards[btv->c.type].tuner) { 1724 if (i->index == bttv_tvcards[btv->c.type].tuner) {
1725 sprintf(i->name, "Television"); 1725 sprintf(i->name, "Television");
1726 i->type = V4L2_INPUT_TYPE_TUNER; 1726 i->type = V4L2_INPUT_TYPE_TUNER;
@@ -1771,12 +1771,20 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1771 memset(t,0,sizeof(*t)); 1771 memset(t,0,sizeof(*t));
1772 strcpy(t->name, "Television"); 1772 strcpy(t->name, "Television");
1773 t->type = V4L2_TUNER_ANALOG_TV; 1773 t->type = V4L2_TUNER_ANALOG_TV;
1774 t->rangehigh = 0xffffffffUL;
1775 t->capability = V4L2_TUNER_CAP_NORM; 1774 t->capability = V4L2_TUNER_CAP_NORM;
1776 t->rxsubchans = V4L2_TUNER_SUB_MONO; 1775 t->rxsubchans = V4L2_TUNER_SUB_MONO;
1777 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC) 1776 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
1778 t->signal = 0xffff; 1777 t->signal = 0xffff;
1779 { 1778 {
1779 struct video_tuner tuner;
1780
1781 memset(&tuner, 0, sizeof (tuner));
1782 tuner.rangehigh = 0xffffffffUL;
1783 bttv_call_i2c_clients(btv, VIDIOCGTUNER, &tuner);
1784 t->rangelow = tuner.rangelow;
1785 t->rangehigh = tuner.rangehigh;
1786 }
1787 {
1780 /* Hmmm ... */ 1788 /* Hmmm ... */
1781 struct video_audio va; 1789 struct video_audio va;
1782 memset(&va, 0, sizeof(struct video_audio)); 1790 memset(&va, 0, sizeof(struct video_audio));
@@ -1853,7 +1861,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1853 } 1861 }
1854 case VIDIOC_LOG_STATUS: 1862 case VIDIOC_LOG_STATUS:
1855 { 1863 {
1856 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, 0); 1864 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, NULL);
1857 return 0; 1865 return 0;
1858 } 1866 }
1859 1867
@@ -2029,19 +2037,33 @@ static int bttv_switch_type(struct bttv_fh *fh, enum v4l2_buf_type type)
2029 return 0; 2037 return 0;
2030} 2038}
2031 2039
2040static void
2041pix_format_set_size (struct v4l2_pix_format * f,
2042 const struct bttv_format * fmt,
2043 unsigned int width,
2044 unsigned int height)
2045{
2046 f->width = width;
2047 f->height = height;
2048
2049 if (fmt->flags & FORMAT_FLAGS_PLANAR) {
2050 f->bytesperline = width; /* Y plane */
2051 f->sizeimage = (width * height * fmt->depth) >> 3;
2052 } else {
2053 f->bytesperline = (width * fmt->depth) >> 3;
2054 f->sizeimage = height * f->bytesperline;
2055 }
2056}
2057
2032static int bttv_g_fmt(struct bttv_fh *fh, struct v4l2_format *f) 2058static int bttv_g_fmt(struct bttv_fh *fh, struct v4l2_format *f)
2033{ 2059{
2034 switch (f->type) { 2060 switch (f->type) {
2035 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 2061 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
2036 memset(&f->fmt.pix,0,sizeof(struct v4l2_pix_format)); 2062 memset(&f->fmt.pix,0,sizeof(struct v4l2_pix_format));
2037 f->fmt.pix.width = fh->width; 2063 pix_format_set_size (&f->fmt.pix, fh->fmt,
2038 f->fmt.pix.height = fh->height; 2064 fh->width, fh->height);
2039 f->fmt.pix.field = fh->cap.field; 2065 f->fmt.pix.field = fh->cap.field;
2040 f->fmt.pix.pixelformat = fh->fmt->fourcc; 2066 f->fmt.pix.pixelformat = fh->fmt->fourcc;
2041 f->fmt.pix.bytesperline =
2042 (f->fmt.pix.width * fh->fmt->depth) >> 3;
2043 f->fmt.pix.sizeimage =
2044 f->fmt.pix.height * f->fmt.pix.bytesperline;
2045 return 0; 2067 return 0;
2046 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 2068 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
2047 memset(&f->fmt.win,0,sizeof(struct v4l2_window)); 2069 memset(&f->fmt.win,0,sizeof(struct v4l2_window));
@@ -2106,11 +2128,9 @@ static int bttv_try_fmt(struct bttv_fh *fh, struct bttv *btv,
2106 f->fmt.pix.width = maxw; 2128 f->fmt.pix.width = maxw;
2107 if (f->fmt.pix.height > maxh) 2129 if (f->fmt.pix.height > maxh)
2108 f->fmt.pix.height = maxh; 2130 f->fmt.pix.height = maxh;
2109 f->fmt.pix.width &= ~0x03; 2131 pix_format_set_size (&f->fmt.pix, fmt,
2110 f->fmt.pix.bytesperline = 2132 f->fmt.pix.width & ~3,
2111 (f->fmt.pix.width * fmt->depth) >> 3; 2133 f->fmt.pix.height);
2112 f->fmt.pix.sizeimage =
2113 f->fmt.pix.height * f->fmt.pix.bytesperline;
2114 2134
2115 return 0; 2135 return 0;
2116 } 2136 }
@@ -2278,6 +2298,15 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2278 retval = -EINVAL; 2298 retval = -EINVAL;
2279 goto fh_unlock_and_return; 2299 goto fh_unlock_and_return;
2280 } 2300 }
2301 if (fmt->flags & FORMAT_FLAGS_RAW) {
2302 /* VIDIOCMCAPTURE uses gbufsize, not RAW_BPL *
2303 RAW_LINES * 2. F1 is stored at offset 0, F2
2304 at buffer size / 2. */
2305 fh->width = RAW_BPL;
2306 fh->height = gbufsize / RAW_BPL;
2307 btv->init.width = RAW_BPL;
2308 btv->init.height = gbufsize / RAW_BPL;
2309 }
2281 fh->ovfmt = fmt; 2310 fh->ovfmt = fmt;
2282 fh->fmt = fmt; 2311 fh->fmt = fmt;
2283 btv->init.ovfmt = fmt; 2312 btv->init.ovfmt = fmt;
@@ -2589,9 +2618,11 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2589 2618
2590 if (0 == v4l2) 2619 if (0 == v4l2)
2591 return -EINVAL; 2620 return -EINVAL;
2592 strcpy(cap->driver,"bttv"); 2621 memset(cap, 0, sizeof (*cap));
2593 strlcpy(cap->card,btv->video_dev->name,sizeof(cap->card)); 2622 strlcpy(cap->driver, "bttv", sizeof (cap->driver));
2594 sprintf(cap->bus_info,"PCI:%s",pci_name(btv->c.pci)); 2623 strlcpy(cap->card, btv->video_dev->name, sizeof (cap->card));
2624 snprintf(cap->bus_info, sizeof (cap->bus_info),
2625 "PCI:%s", pci_name(btv->c.pci));
2595 cap->version = BTTV_VERSION_CODE; 2626 cap->version = BTTV_VERSION_CODE;
2596 cap->capabilities = 2627 cap->capabilities =
2597 V4L2_CAP_VIDEO_CAPTURE | 2628 V4L2_CAP_VIDEO_CAPTURE |
@@ -2952,6 +2983,8 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
2952 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; 2983 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
2953 field = videobuf_next_field(&fh->cap); 2984 field = videobuf_next_field(&fh->cap);
2954 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { 2985 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
2986 kfree (fh->cap.read_buf);
2987 fh->cap.read_buf = NULL;
2955 up(&fh->cap.lock); 2988 up(&fh->cap.lock);
2956 return POLLERR; 2989 return POLLERR;
2957 } 2990 }
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index f6afeec499c5..aea3f038cff6 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -208,8 +208,11 @@ static void cx25840_initialize(struct i2c_client *client, int loadfw)
208 208
209static void input_change(struct i2c_client *client) 209static void input_change(struct i2c_client *client)
210{ 210{
211 struct cx25840_state *state = i2c_get_clientdata(client);
211 v4l2_std_id std = cx25840_get_v4lstd(client); 212 v4l2_std_id std = cx25840_get_v4lstd(client);
212 213
214 /* Note: perhaps V4L2_STD_PAL_M should be handled as V4L2_STD_NTSC
215 instead of V4L2_STD_PAL. Someone needs to test this. */
213 if (std & V4L2_STD_PAL) { 216 if (std & V4L2_STD_PAL) {
214 /* Follow tuner change procedure for PAL */ 217 /* Follow tuner change procedure for PAL */
215 cx25840_write(client, 0x808, 0xff); 218 cx25840_write(client, 0x808, 0xff);
@@ -220,7 +223,32 @@ static void input_change(struct i2c_client *client)
220 cx25840_write(client, 0x80b, 0x10); 223 cx25840_write(client, 0x80b, 0x10);
221 } else if (std & V4L2_STD_NTSC) { 224 } else if (std & V4L2_STD_NTSC) {
222 /* NTSC */ 225 /* NTSC */
223 cx25840_write(client, 0x808, 0xf6); 226 if (state->cardtype == CARDTYPE_PVR150_WORKAROUND) {
227 /* Certain Hauppauge PVR150 models have a hardware bug
228 that causes audio to drop out. For these models the
229 audio standard must be set explicitly.
230 To be precise: it affects cards with tuner models
231 85, 99 and 112 (model numbers from tveeprom). */
232 if (std == V4L2_STD_NTSC_M_JP) {
233 /* Japan uses EIAJ audio standard */
234 cx25840_write(client, 0x808, 0x2f);
235 } else {
236 /* Others use the BTSC audio standard */
237 cx25840_write(client, 0x808, 0x1f);
238 }
239 /* South Korea uses the A2-M (aka Zweiton M) audio
240 standard, and should set 0x808 to 0x3f, but I don't
241 know how to detect this. */
242 } else if (std == V4L2_STD_NTSC_M_JP) {
243 /* Japan uses EIAJ audio standard */
244 cx25840_write(client, 0x808, 0xf7);
245 } else {
246 /* Others use the BTSC audio standard */
247 cx25840_write(client, 0x808, 0xf6);
248 }
249 /* South Korea uses the A2-M (aka Zweiton M) audio standard,
250 and should set 0x808 to 0xf8, but I don't know how to
251 detect this. */
224 cx25840_write(client, 0x80b, 0x00); 252 cx25840_write(client, 0x80b, 0x00);
225 } 253 }
226 254
@@ -241,7 +269,8 @@ static int set_input(struct i2c_client *client, enum cx25840_input input)
241 case CX25840_TUNER: 269 case CX25840_TUNER:
242 cx25840_dbg("now setting Tuner input\n"); 270 cx25840_dbg("now setting Tuner input\n");
243 271
244 if (state->cardtype == CARDTYPE_PVR150) { 272 if (state->cardtype == CARDTYPE_PVR150 ||
273 state->cardtype == CARDTYPE_PVR150_WORKAROUND) {
245 /* CH_SEL_ADC2=1 */ 274 /* CH_SEL_ADC2=1 */
246 cx25840_and_or(client, 0x102, ~0x2, 0x02); 275 cx25840_and_or(client, 0x102, ~0x2, 0x02);
247 } 276 }
@@ -363,6 +392,7 @@ static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
363 case CX25840_CID_CARDTYPE: 392 case CX25840_CID_CARDTYPE:
364 switch (ctrl->value) { 393 switch (ctrl->value) {
365 case CARDTYPE_PVR150: 394 case CARDTYPE_PVR150:
395 case CARDTYPE_PVR150_WORKAROUND:
366 case CARDTYPE_PG600: 396 case CARDTYPE_PG600:
367 state->cardtype = ctrl->value; 397 state->cardtype = ctrl->value;
368 break; 398 break;
@@ -714,7 +744,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
714 744
715/* ----------------------------------------------------------------------- */ 745/* ----------------------------------------------------------------------- */
716 746
717struct i2c_driver i2c_driver_cx25840; 747static struct i2c_driver i2c_driver_cx25840;
718 748
719static int cx25840_detect_client(struct i2c_adapter *adapter, int address, 749static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
720 int kind) 750 int kind)
@@ -807,7 +837,7 @@ static int cx25840_detach_client(struct i2c_client *client)
807 837
808/* ----------------------------------------------------------------------- */ 838/* ----------------------------------------------------------------------- */
809 839
810struct i2c_driver i2c_driver_cx25840 = { 840static struct i2c_driver i2c_driver_cx25840 = {
811 .name = "cx25840", 841 .name = "cx25840",
812 842
813 .id = I2C_DRIVERID_CX25840, 843 .id = I2C_DRIVERID_CX25840,
diff --git a/drivers/media/video/cx25840/cx25840.h b/drivers/media/video/cx25840/cx25840.h
index 5c3f0639fb77..4932ed1c9b19 100644
--- a/drivers/media/video/cx25840/cx25840.h
+++ b/drivers/media/video/cx25840/cx25840.h
@@ -40,9 +40,16 @@ extern int cx25840_debug;
40 40
41#define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0) 41#define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0)
42 42
43/* The CARDTYPE_PVR150_WORKAROUND cardtype activates a workaround for a
44 hardware bug that is present in PVR150 (and possible PVR500) cards that
45 have certain NTSC tuners (tveeprom model numbers 85, 99 and 112). The
46 audio autodetect fails on some channels for these models and the workaround
47 is to select the audio standard explicitly. Many thanks to Hauppauge for
48 providing this information. */
43enum cx25840_cardtype { 49enum cx25840_cardtype {
44 CARDTYPE_PVR150, 50 CARDTYPE_PVR150,
45 CARDTYPE_PG600 51 CARDTYPE_PG600,
52 CARDTYPE_PVR150_WORKAROUND,
46}; 53};
47 54
48enum cx25840_input { 55enum cx25840_input {
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index 41818b6205b3..85ba4106dc79 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -46,8 +46,8 @@ config VIDEO_CX88_DVB_ALL_FRONTENDS
46 If you are unsure, choose Y. 46 If you are unsure, choose Y.
47 47
48config VIDEO_CX88_DVB_MT352 48config VIDEO_CX88_DVB_MT352
49 tristate "Zarlink MT352 DVB-T Support" 49 bool "Zarlink MT352 DVB-T Support"
50 default m 50 default y
51 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 51 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
52 select DVB_MT352 52 select DVB_MT352
53 ---help--- 53 ---help---
@@ -55,8 +55,8 @@ config VIDEO_CX88_DVB_MT352
55 Connexant 2388x chip and the MT352 demodulator. 55 Connexant 2388x chip and the MT352 demodulator.
56 56
57config VIDEO_CX88_DVB_OR51132 57config VIDEO_CX88_DVB_OR51132
58 tristate "OR51132 ATSC Support" 58 bool "OR51132 ATSC Support"
59 default m 59 default y
60 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 60 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
61 select DVB_OR51132 61 select DVB_OR51132
62 ---help--- 62 ---help---
@@ -64,8 +64,8 @@ config VIDEO_CX88_DVB_OR51132
64 Connexant 2388x chip and the OR51132 demodulator. 64 Connexant 2388x chip and the OR51132 demodulator.
65 65
66config VIDEO_CX88_DVB_CX22702 66config VIDEO_CX88_DVB_CX22702
67 tristate "Conexant CX22702 DVB-T Support" 67 bool "Conexant CX22702 DVB-T Support"
68 default m 68 default y
69 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 69 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
70 select DVB_CX22702 70 select DVB_CX22702
71 ---help--- 71 ---help---
@@ -73,8 +73,8 @@ config VIDEO_CX88_DVB_CX22702
73 Connexant 2388x chip and the CX22702 demodulator. 73 Connexant 2388x chip and the CX22702 demodulator.
74 74
75config VIDEO_CX88_DVB_LGDT330X 75config VIDEO_CX88_DVB_LGDT330X
76 tristate "LG Electronics DT3302/DT3303 ATSC Support" 76 bool "LG Electronics DT3302/DT3303 ATSC Support"
77 default m 77 default y
78 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 78 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
79 select DVB_LGDT330X 79 select DVB_LGDT330X
80 ---help--- 80 ---help---
@@ -82,8 +82,8 @@ config VIDEO_CX88_DVB_LGDT330X
82 Connexant 2388x chip and the LGDT3302/LGDT3303 demodulator. 82 Connexant 2388x chip and the LGDT3302/LGDT3303 demodulator.
83 83
84config VIDEO_CX88_DVB_NXT200X 84config VIDEO_CX88_DVB_NXT200X
85 tristate "NXT2002/NXT2004 ATSC Support" 85 bool "NXT2002/NXT2004 ATSC Support"
86 default m 86 default y
87 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 87 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
88 select DVB_NXT200X 88 select DVB_NXT200X
89 ---help--- 89 ---help---
diff --git a/drivers/media/video/cx88/Makefile b/drivers/media/video/cx88/Makefile
index 0df40b773454..54401b02b7ce 100644
--- a/drivers/media/video/cx88/Makefile
+++ b/drivers/media/video/cx88/Makefile
@@ -9,21 +9,12 @@ obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o
9EXTRA_CFLAGS += -I$(src)/.. 9EXTRA_CFLAGS += -I$(src)/..
10EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core 10EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
11EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends 11EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends
12ifneq ($(CONFIG_VIDEO_BUF_DVB),n) 12
13 EXTRA_CFLAGS += -DHAVE_VIDEO_BUF_DVB=1 13extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1
14endif 14extra-cflags-$(CONFIG_DVB_CX22702) += -DHAVE_CX22702=1
15ifneq ($(CONFIG_DVB_CX22702),n) 15extra-cflags-$(CONFIG_DVB_OR51132) += -DHAVE_OR51132=1
16 EXTRA_CFLAGS += -DHAVE_CX22702=1 16extra-cflags-$(CONFIG_DVB_LGDT330X) += -DHAVE_LGDT330X=1
17endif 17extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
18ifneq ($(CONFIG_DVB_OR51132),n) 18extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1
19 EXTRA_CFLAGS += -DHAVE_OR51132=1 19
20endif 20EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m)
21ifneq ($(CONFIG_DVB_LGDT330X),n)
22 EXTRA_CFLAGS += -DHAVE_LGDT330X=1
23endif
24ifneq ($(CONFIG_DVB_MT352),n)
25 EXTRA_CFLAGS += -DHAVE_MT352=1
26endif
27ifneq ($(CONFIG_DVB_NXT200X),n)
28 EXTRA_CFLAGS += -DHAVE_NXT200X=1
29endif
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index f2268631b7c0..24651661630a 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1083,41 +1083,28 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
1083 tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data); 1083 tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data);
1084 core->tuner_type = tv.tuner_type; 1084 core->tuner_type = tv.tuner_type;
1085 core->has_radio = tv.has_radio; 1085 core->has_radio = tv.has_radio;
1086}
1087
1088static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
1089{
1090 int model;
1091 int tuner;
1092 1086
1093 /* Make sure we support the board model */ 1087 /* Make sure we support the board model */
1094 model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c]; 1088 switch (tv.model)
1095 switch(model) { 1089 {
1096 case 90002: 1090 case 90002: /* Nova-T-PCI (9002) */
1097 case 90500: 1091 case 92001: /* Nova-S-Plus (Video and IR) */
1098 case 90501: 1092 case 92002: /* Nova-S-Plus (Video and IR) */
1093 case 90003: /* Nova-T-PCI (9002 No RF out) */
1094 case 90500: /* Nova-T-PCI (oem) */
1095 case 90501: /* Nova-T-PCI (oem/IR) */
1096 case 92000: /* Nova-SE2 (OEM, No Video or IR) */
1097
1099 /* known */ 1098 /* known */
1100 break; 1099 break;
1101 default: 1100 default:
1102 printk("%s: warning: unknown hauppauge model #%d\n", 1101 printk("%s: warning: unknown hauppauge model #%d\n",
1103 core->name, model); 1102 core->name, tv.model);
1104 break; 1103 break;
1105 } 1104 }
1106 1105
1107 /* Make sure we support the tuner */ 1106 printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
1108 tuner = ee[0x2d]; 1107 core->name, tv.model);
1109 switch(tuner) {
1110 case 0x4B: /* dtt 7595 */
1111 case 0x4C: /* dtt 7592 */
1112 break;
1113 default:
1114 printk("%s: error: unknown hauppauge tuner 0x%02x\n",
1115 core->name, tuner);
1116 return -ENODEV;
1117 }
1118 printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%d\n",
1119 core->name, model, tuner);
1120 return 0;
1121} 1108}
1122 1109
1123/* ----------------------------------------------------------------------- */ 1110/* ----------------------------------------------------------------------- */
@@ -1201,7 +1188,7 @@ void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
1201 1188
1202void cx88_card_setup(struct cx88_core *core) 1189void cx88_card_setup(struct cx88_core *core)
1203{ 1190{
1204 static u8 eeprom[128]; 1191 static u8 eeprom[256];
1205 1192
1206 if (0 == core->i2c_rc) { 1193 if (0 == core->i2c_rc) {
1207 core->i2c_client.addr = 0xa0 >> 1; 1194 core->i2c_client.addr = 0xa0 >> 1;
@@ -1224,7 +1211,7 @@ void cx88_card_setup(struct cx88_core *core)
1224 break; 1211 break;
1225 case CX88_BOARD_HAUPPAUGE_DVB_T1: 1212 case CX88_BOARD_HAUPPAUGE_DVB_T1:
1226 if (0 == core->i2c_rc) 1213 if (0 == core->i2c_rc)
1227 hauppauge_eeprom_dvb(core,eeprom); 1214 hauppauge_eeprom(core,eeprom);
1228 break; 1215 break;
1229 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 1216 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
1230 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 1217 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index eb806af17182..bb6eb54e19ce 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -837,6 +837,29 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
837 return -1; 837 return -1;
838} 838}
839 839
840int cx88_start_audio_dma(struct cx88_core *core)
841{
842 /* setup fifo + format */
843 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
844 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
845
846 cx_write(MO_AUDD_LNGTH, 128); /* fifo bpl size */
847 cx_write(MO_AUDR_LNGTH, 128); /* fifo bpl size */
848
849 /* start dma */
850 cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */
851
852 return 0;
853}
854
855int cx88_stop_audio_dma(struct cx88_core *core)
856{
857 /* stop dma */
858 cx_write(MO_AUD_DMACNTRL, 0x0000);
859
860 return 0;
861}
862
840static int set_tvaudio(struct cx88_core *core) 863static int set_tvaudio(struct cx88_core *core)
841{ 864{
842 struct cx88_tvnorm *norm = core->tvnorm; 865 struct cx88_tvnorm *norm = core->tvnorm;
@@ -877,12 +900,16 @@ static int set_tvaudio(struct cx88_core *core)
877 cx88_set_tvaudio(core); 900 cx88_set_tvaudio(core);
878 /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */ 901 /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */
879 902
880 cx_write(MO_AUDD_LNGTH, 128); /* fifo size */ 903/*
881 cx_write(MO_AUDR_LNGTH, 128); /* fifo size */ 904 This should be needed only on cx88-alsa. It seems that some cx88 chips have
882 cx_write(MO_AUD_DMACNTRL, 0x03); /* need audio fifo */ 905 bugs and does require DMA enabled for it to work.
906 */
907 cx88_start_audio_dma(core);
883 return 0; 908 return 0;
884} 909}
885 910
911
912
886int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) 913int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
887{ 914{
888 u32 fsc8; 915 u32 fsc8;
@@ -1204,6 +1231,8 @@ EXPORT_SYMBOL(cx88_set_scale);
1204EXPORT_SYMBOL(cx88_vdev_init); 1231EXPORT_SYMBOL(cx88_vdev_init);
1205EXPORT_SYMBOL(cx88_core_get); 1232EXPORT_SYMBOL(cx88_core_get);
1206EXPORT_SYMBOL(cx88_core_put); 1233EXPORT_SYMBOL(cx88_core_put);
1234EXPORT_SYMBOL(cx88_start_audio_dma);
1235EXPORT_SYMBOL(cx88_stop_audio_dma);
1207 1236
1208/* 1237/*
1209 * Local variables: 1238 * Local variables:
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 6d9bec1c583b..a1b120c8a9b5 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -119,13 +119,10 @@ static void set_audio_registers(struct cx88_core *core, const struct rlist *l)
119 119
120static void set_audio_start(struct cx88_core *core, u32 mode) 120static void set_audio_start(struct cx88_core *core, u32 mode)
121{ 121{
122 // mute 122 /* mute */
123 cx_write(AUD_VOL_CTL, (1 << 6)); 123 cx_write(AUD_VOL_CTL, (1 << 6));
124 124
125 // start programming 125 /* start programming */
126 cx_write(MO_AUD_DMACNTRL, 0x0000);
127 msleep(100);
128 //cx_write(AUD_CTL, 0x0000);
129 cx_write(AUD_INIT, mode); 126 cx_write(AUD_INIT, mode);
130 cx_write(AUD_INIT_LD, 0x0001); 127 cx_write(AUD_INIT_LD, 0x0001);
131 cx_write(AUD_SOFT_RESET, 0x0001); 128 cx_write(AUD_SOFT_RESET, 0x0001);
@@ -135,17 +132,21 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
135{ 132{
136 u32 volume; 133 u32 volume;
137 134
135 /* restart dma; This avoids buzz in NICAM and is good in others */
136 cx88_stop_audio_dma(core);
137 cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
138 cx88_start_audio_dma(core);
139
138 if (cx88_boards[core->board].blackbird) { 140 if (cx88_boards[core->board].blackbird) {
139 // sets sound input from external adc 141 /* sets sound input from external adc */
140 cx_set(AUD_CTL, EN_I2SIN_ENABLE); 142 cx_set(AUD_CTL, EN_I2SIN_ENABLE);
141 //cx_write(AUD_I2SINPUTCNTL, 0);
142 cx_write(AUD_I2SINPUTCNTL, 4); 143 cx_write(AUD_I2SINPUTCNTL, 4);
143 cx_write(AUD_BAUDRATE, 1); 144 cx_write(AUD_BAUDRATE, 1);
144 // 'pass-thru mode': this enables the i2s output to the mpeg encoder 145 /* 'pass-thru mode': this enables the i2s output to the mpeg encoder */
145 cx_set(AUD_CTL, EN_I2SOUT_ENABLE); 146 cx_set(AUD_CTL, EN_I2SOUT_ENABLE);
146 cx_write(AUD_I2SOUTPUTCNTL, 1); 147 cx_write(AUD_I2SOUTPUTCNTL, 1);
147 cx_write(AUD_I2SCNTL, 0); 148 cx_write(AUD_I2SCNTL, 0);
148 //cx_write(AUD_APB_IN_RATE_ADJ, 0); 149 /* cx_write(AUD_APB_IN_RATE_ADJ, 0); */
149 } else { 150 } else {
150 ctl |= EN_DAC_ENABLE; 151 ctl |= EN_DAC_ENABLE;
151 cx_write(AUD_CTL, ctl); 152 cx_write(AUD_CTL, ctl);
@@ -153,7 +154,6 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
153 154
154 /* finish programming */ 155 /* finish programming */
155 cx_write(AUD_SOFT_RESET, 0x0000); 156 cx_write(AUD_SOFT_RESET, 0x0000);
156 cx_write(MO_AUD_DMACNTRL, 0x0003);
157 157
158 /* unmute */ 158 /* unmute */
159 volume = cx_sread(SHADOW_AUD_VOL_CTL); 159 volume = cx_sread(SHADOW_AUD_VOL_CTL);
@@ -313,7 +313,6 @@ static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode)
313 {AUD_RATE_ADJ3, 0x00000100}, 313 {AUD_RATE_ADJ3, 0x00000100},
314 {AUD_RATE_ADJ4, 0x00000400}, 314 {AUD_RATE_ADJ4, 0x00000400},
315 {AUD_RATE_ADJ5, 0x00001000}, 315 {AUD_RATE_ADJ5, 0x00001000},
316 //{ AUD_DMD_RA_DDS, 0x00c0d5ce },
317 {AUD_ERRLOGPERIOD_R, 0x00000fff}, 316 {AUD_ERRLOGPERIOD_R, 0x00000fff},
318 {AUD_ERRINTRPTTHSHLD1_R, 0x000003ff}, 317 {AUD_ERRINTRPTTHSHLD1_R, 0x000003ff},
319 {AUD_ERRINTRPTTHSHLD2_R, 0x000000ff}, 318 {AUD_ERRINTRPTTHSHLD2_R, 0x000000ff},
@@ -351,12 +350,12 @@ static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode)
351 set_audio_registers(core, nicam_l); 350 set_audio_registers(core, nicam_l);
352 break; 351 break;
353 case WW_I: 352 case WW_I:
354 dprintk("%s PAL-I NICAM (status: devel)\n", __FUNCTION__); 353 dprintk("%s PAL-I NICAM (status: known-good)\n", __FUNCTION__);
355 set_audio_registers(core, nicam_bgdki_common); 354 set_audio_registers(core, nicam_bgdki_common);
356 set_audio_registers(core, nicam_i); 355 set_audio_registers(core, nicam_i);
357 break; 356 break;
358 default: 357 default:
359 dprintk("%s PAL-BGDK NICAM (status: unknown)\n", __FUNCTION__); 358 dprintk("%s PAL-BGDK NICAM (status: known-good)\n", __FUNCTION__);
360 set_audio_registers(core, nicam_bgdki_common); 359 set_audio_registers(core, nicam_bgdki_common);
361 set_audio_registers(core, nicam_default); 360 set_audio_registers(core, nicam_default);
362 break; 361 break;
@@ -715,8 +714,7 @@ int cx88_detect_nicam(struct cx88_core *core)
715 /* if bit1=1 then nicam is detected */ 714 /* if bit1=1 then nicam is detected */
716 j += ((cx_read(AUD_NICAM_STATUS2) & 0x02) >> 1); 715 j += ((cx_read(AUD_NICAM_STATUS2) & 0x02) >> 1);
717 716
718 /* 3x detected: absolutly sure now */ 717 if (j == 1) {
719 if (j == 3) {
720 dprintk("nicam is detected.\n"); 718 dprintk("nicam is detected.\n");
721 return 1; 719 return 1;
722 } 720 }
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index b19d3a9e2298..27fb080fd7aa 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -491,6 +491,10 @@ extern struct cx88_core* cx88_core_get(struct pci_dev *pci);
491extern void cx88_core_put(struct cx88_core *core, 491extern void cx88_core_put(struct cx88_core *core,
492 struct pci_dev *pci); 492 struct pci_dev *pci);
493 493
494extern int cx88_start_audio_dma(struct cx88_core *core);
495extern int cx88_stop_audio_dma(struct cx88_core *core);
496
497
494/* ----------------------------------------------------------- */ 498/* ----------------------------------------------------------- */
495/* cx88-vbi.c */ 499/* cx88-vbi.c */
496 500
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index d54bc0127484..9f6e5e5355a1 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -32,7 +32,7 @@
32 32
33/* #define ENABLE_DEBUG_ISOC_FRAMES */ 33/* #define ENABLE_DEBUG_ISOC_FRAMES */
34 34
35unsigned int core_debug; 35static unsigned int core_debug;
36module_param(core_debug,int,0644); 36module_param(core_debug,int,0644);
37MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); 37MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
38 38
@@ -41,7 +41,7 @@ MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
41 printk(KERN_INFO "%s %s :"fmt, \ 41 printk(KERN_INFO "%s %s :"fmt, \
42 dev->name, __FUNCTION__ , ##arg); } while (0) 42 dev->name, __FUNCTION__ , ##arg); } while (0)
43 43
44unsigned int reg_debug; 44static unsigned int reg_debug;
45module_param(reg_debug,int,0644); 45module_param(reg_debug,int,0644);
46MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]"); 46MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]");
47 47
@@ -50,7 +50,7 @@ MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]");
50 printk(KERN_INFO "%s %s :"fmt, \ 50 printk(KERN_INFO "%s %s :"fmt, \
51 dev->name, __FUNCTION__ , ##arg); } while (0) 51 dev->name, __FUNCTION__ , ##arg); } while (0)
52 52
53unsigned int isoc_debug; 53static unsigned int isoc_debug;
54module_param(isoc_debug,int,0644); 54module_param(isoc_debug,int,0644);
55MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]"); 55MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]");
56 56
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 57c1826b928e..abec32c175aa 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -226,7 +226,7 @@ static int em28xx_config(struct em28xx *dev)
226 * em28xx_config_i2c() 226 * em28xx_config_i2c()
227 * configure i2c attached devices 227 * configure i2c attached devices
228 */ 228 */
229void em28xx_config_i2c(struct em28xx *dev) 229static void em28xx_config_i2c(struct em28xx *dev)
230{ 230{
231 struct v4l2_frequency f; 231 struct v4l2_frequency f;
232 struct video_decoder_init em28xx_vdi = {.data = NULL }; 232 struct video_decoder_init em28xx_vdi = {.data = NULL };
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 801c736e9328..124c502ea1f3 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -278,7 +278,7 @@ static int ir_probe(struct i2c_adapter *adap);
278 278
279static struct i2c_driver driver = { 279static struct i2c_driver driver = {
280 .name = "ir remote kbd driver", 280 .name = "ir remote kbd driver",
281 .id = I2C_DRIVERID_EXP3, /* FIXME */ 281 .id = I2C_DRIVERID_I2C_IR,
282 .flags = I2C_DF_NOTIFY, 282 .flags = I2C_DF_NOTIFY,
283 .attach_adapter = ir_probe, 283 .attach_adapter = ir_probe,
284 .detach_client = ir_detach, 284 .detach_client = ir_detach,
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 0235cef07b31..e717e30d8187 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -771,17 +771,19 @@ static v4l2_std_id saa7115_get_v4lstd(struct i2c_client *client)
771 771
772static void saa7115_log_status(struct i2c_client *client) 772static void saa7115_log_status(struct i2c_client *client)
773{ 773{
774 static const char * const audclk_freq_strs[] = {
775 "44.1 kHz",
776 "48 kHz",
777 "32 kHz"
778 };
779 struct saa7115_state *state = i2c_get_clientdata(client); 774 struct saa7115_state *state = i2c_get_clientdata(client);
775 char *audfreq = "undefined";
780 int reg1e, reg1f; 776 int reg1e, reg1f;
781 int signalOk; 777 int signalOk;
782 int vcr; 778 int vcr;
783 779
784 saa7115_info("Audio frequency: %s\n", audclk_freq_strs[state->audclk_freq]); 780 switch (state->audclk_freq) {
781 case V4L2_AUDCLK_32_KHZ: audfreq = "32 kHz"; break;
782 case V4L2_AUDCLK_441_KHZ: audfreq = "44.1 kHz"; break;
783 case V4L2_AUDCLK_48_KHZ: audfreq = "48 kHz"; break;
784 }
785
786 saa7115_info("Audio frequency: %s\n", audfreq);
785 if (client->name[6] == '4') { 787 if (client->name[6] == '4') {
786 /* status for the saa7114 */ 788 /* status for the saa7114 */
787 reg1f = saa7115_read(client, 0x1f); 789 reg1f = saa7115_read(client, 0x1f);
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c
index 25b30f352d84..59e13fdea780 100644
--- a/drivers/media/video/saa711x.c
+++ b/drivers/media/video/saa711x.c
@@ -323,7 +323,7 @@ saa711x_command (struct i2c_client *client,
323 323
324 case VIDEO_MODE_SECAM: 324 case VIDEO_MODE_SECAM:
325 saa711x_write(client, 0x08, 325 saa711x_write(client, 0x08,
326 (decoder->reg[0x0e] & 0x3f) | 0x00); 326 (decoder->reg[0x08] & 0x3f) | 0x00);
327 saa711x_write(client, 0x0e, 327 saa711x_write(client, 0x0e,
328 (decoder->reg[0x0e] & 0x8f) | 0x50); 328 (decoder->reg[0x0e] & 0x8f) | 0x50);
329 break; 329 break;
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index 843431f10e3b..3428e1ed0032 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -223,7 +223,7 @@ static const struct i2c_reg_value saa7127_init_config_60hz[] = {
223}; 223};
224 224
225#define SAA7127_50HZ_DAC_CONTROL 0x02 225#define SAA7127_50HZ_DAC_CONTROL 0x02
226struct i2c_reg_value saa7127_init_config_50hz[] = { 226static struct i2c_reg_value saa7127_init_config_50hz[] = {
227 { SAA7127_REG_BURST_START, 0x21 }, 227 { SAA7127_REG_BURST_START, 0x21 },
228 /* BURST_END is also used as a chip ID in saa7127_detect_client */ 228 /* BURST_END is also used as a chip ID in saa7127_detect_client */
229 { SAA7127_REG_BURST_END, 0x1d }, 229 { SAA7127_REG_BURST_END, 0x1d },
@@ -696,7 +696,7 @@ static int saa7127_command(struct i2c_client *client,
696 696
697/* ----------------------------------------------------------------------- */ 697/* ----------------------------------------------------------------------- */
698 698
699struct i2c_driver i2c_driver_saa7127; 699static struct i2c_driver i2c_driver_saa7127;
700 700
701/* ----------------------------------------------------------------------- */ 701/* ----------------------------------------------------------------------- */
702 702
@@ -818,7 +818,7 @@ static int saa7127_detach(struct i2c_client *client)
818 818
819/* ----------------------------------------------------------------------- */ 819/* ----------------------------------------------------------------------- */
820 820
821struct i2c_driver i2c_driver_saa7127 = { 821static struct i2c_driver i2c_driver_saa7127 = {
822 .name = "saa7127", 822 .name = "saa7127",
823 .id = I2C_DRIVERID_SAA7127, 823 .id = I2C_DRIVERID_SAA7127,
824 .flags = I2C_DF_NOTIFY, 824 .flags = I2C_DF_NOTIFY,
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 7bdeabe638ca..c512c4411b38 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -42,8 +42,8 @@ config VIDEO_SAA7134_DVB_ALL_FRONTENDS
42 If you are unsure, choose Y. 42 If you are unsure, choose Y.
43 43
44config VIDEO_SAA7134_DVB_MT352 44config VIDEO_SAA7134_DVB_MT352
45 tristate "Zarlink MT352 DVB-T Support" 45 bool "Zarlink MT352 DVB-T Support"
46 default m 46 default y
47 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS 47 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS
48 select DVB_MT352 48 select DVB_MT352
49 ---help--- 49 ---help---
@@ -51,8 +51,8 @@ config VIDEO_SAA7134_DVB_MT352
51 Philips saa7134 chip and the MT352 demodulator. 51 Philips saa7134 chip and the MT352 demodulator.
52 52
53config VIDEO_SAA7134_DVB_TDA1004X 53config VIDEO_SAA7134_DVB_TDA1004X
54 tristate "Phillips TDA10045H/TDA10046H DVB-T Support" 54 bool "Phillips TDA10045H/TDA10046H DVB-T Support"
55 default m 55 default y
56 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS 56 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS
57 select DVB_TDA1004X 57 select DVB_TDA1004X
58 ---help--- 58 ---help---
@@ -60,8 +60,8 @@ config VIDEO_SAA7134_DVB_TDA1004X
60 Philips saa7134 chip and the TDA10045H/TDA10046H demodulator. 60 Philips saa7134 chip and the TDA10045H/TDA10046H demodulator.
61 61
62config VIDEO_SAA7134_DVB_NXT200X 62config VIDEO_SAA7134_DVB_NXT200X
63 tristate "NXT2002/NXT2004 ATSC Support" 63 bool "NXT2002/NXT2004 ATSC Support"
64 default m 64 default y
65 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS 65 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS
66 select DVB_NXT200X 66 select DVB_NXT200X
67 ---help--- 67 ---help---
diff --git a/drivers/media/video/saa7134/Makefile b/drivers/media/video/saa7134/Makefile
index 4226b61cc613..134f83a96218 100644
--- a/drivers/media/video/saa7134/Makefile
+++ b/drivers/media/video/saa7134/Makefile
@@ -11,15 +11,10 @@ obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o
11EXTRA_CFLAGS += -I$(src)/.. 11EXTRA_CFLAGS += -I$(src)/..
12EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core 12EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
13EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends 13EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends
14ifneq ($(CONFIG_VIDEO_BUF_DVB),n) 14
15 EXTRA_CFLAGS += -DHAVE_VIDEO_BUF_DVB=1 15extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1
16endif 16extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
17ifneq ($(CONFIG_DVB_MT352),n) 17extra-cflags-$(CONFIG_DVB_TDA1004X) += -DHAVE_TDA1004X=1
18 EXTRA_CFLAGS += -DHAVE_MT352=1 18extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1
19endif 19
20ifneq ($(CONFIG_DVB_TDA1004X),n) 20EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m)
21 EXTRA_CFLAGS += -DHAVE_TDA1004X=1
22endif
23ifneq ($(CONFIG_DVB_NXT200X),n)
24 EXTRA_CFLAGS += -DHAVE_NXT200X=1
25endif
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index 5707c666660b..263c6e2e3e8e 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -58,8 +58,6 @@ static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
58module_param_array(index, int, NULL, 0444); 58module_param_array(index, int, NULL, 0444);
59MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); 59MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s).");
60 60
61int position;
62
63#define dprintk(fmt, arg...) if (debug) \ 61#define dprintk(fmt, arg...) if (debug) \
64 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) 62 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg)
65 63
@@ -140,7 +138,8 @@ static void saa7134_dma_start(struct saa7134_dev *dev)
140 * 138 *
141 */ 139 */
142 140
143void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) 141static void saa7134_irq_alsa_done(struct saa7134_dev *dev,
142 unsigned long status)
144{ 143{
145 int next_blk, reg = 0; 144 int next_blk, reg = 0;
146 145
@@ -881,7 +880,7 @@ static void snd_saa7134_free(snd_card_t * card)
881 * 880 *
882 */ 881 */
883 882
884int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum) 883static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
885{ 884{
886 885
887 snd_card_t *card; 886 snd_card_t *card;
@@ -945,6 +944,8 @@ int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
945 sprintf(card->longname, "%s at 0x%lx irq %d", 944 sprintf(card->longname, "%s at 0x%lx irq %d",
946 chip->dev->name, chip->iobase, chip->irq); 945 chip->dev->name, chip->iobase, chip->irq);
947 946
947 printk(KERN_INFO "%s/alsa: %s registered as card %d\n",dev->name,card->longname,index[devnum]);
948
948 if ((err = snd_card_register(card)) == 0) { 949 if ((err = snd_card_register(card)) == 0) {
949 snd_saa7134_cards[devnum] = card; 950 snd_saa7134_cards[devnum] = card;
950 return 0; 951 return 0;
@@ -955,6 +956,22 @@ __nodev:
955 return err; 956 return err;
956} 957}
957 958
959
960static int alsa_device_init(struct saa7134_dev *dev)
961{
962 dev->dmasound.priv_data = dev;
963 alsa_card_saa7134_create(dev,dev->nr);
964 return 1;
965}
966
967static int alsa_device_exit(struct saa7134_dev *dev)
968{
969
970 snd_card_free(snd_saa7134_cards[dev->nr]);
971 snd_saa7134_cards[dev->nr] = NULL;
972 return 1;
973}
974
958/* 975/*
959 * Module initializer 976 * Module initializer
960 * 977 *
@@ -968,22 +985,21 @@ static int saa7134_alsa_init(void)
968 struct saa7134_dev *dev = NULL; 985 struct saa7134_dev *dev = NULL;
969 struct list_head *list; 986 struct list_head *list;
970 987
971 position = 0;
972
973 printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n"); 988 printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
974 989
975 list_for_each(list,&saa7134_devlist) { 990 list_for_each(list,&saa7134_devlist) {
976 dev = list_entry(list, struct saa7134_dev, devlist); 991 dev = list_entry(list, struct saa7134_dev, devlist);
977 if (dev->dmasound.priv_data == NULL) { 992 if (dev->dmasound.priv_data == NULL) {
978 dev->dmasound.priv_data = dev; 993 alsa_device_init(dev);
979 alsa_card_saa7134_create(dev,position);
980 position++;
981 } else { 994 } else {
982 printk(KERN_ERR "saa7134 ALSA: DMA sound is being handled by OSS. ignoring %s\n",dev->name); 995 printk(KERN_ERR "saa7134 ALSA: DMA sound is being handled by OSS. ignoring %s\n",dev->name);
983 return -EBUSY; 996 return -EBUSY;
984 } 997 }
985 } 998 }
986 999
1000 dmasound_init = alsa_device_init;
1001 dmasound_exit = alsa_device_exit;
1002
987 if (dev == NULL) 1003 if (dev == NULL)
988 printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n"); 1004 printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n");
989 1005
@@ -994,7 +1010,7 @@ static int saa7134_alsa_init(void)
994 * Module destructor 1010 * Module destructor
995 */ 1011 */
996 1012
997void saa7134_alsa_exit(void) 1013static void saa7134_alsa_exit(void)
998{ 1014{
999 int idx; 1015 int idx;
1000 1016
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 4275d2ddb864..1a093bf176f3 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -88,6 +88,9 @@ LIST_HEAD(saa7134_devlist);
88static LIST_HEAD(mops_list); 88static LIST_HEAD(mops_list);
89static unsigned int saa7134_devcount; 89static unsigned int saa7134_devcount;
90 90
91int (*dmasound_init)(struct saa7134_dev *dev);
92int (*dmasound_exit)(struct saa7134_dev *dev);
93
91#define dprintk(fmt, arg...) if (core_debug) \ 94#define dprintk(fmt, arg...) if (core_debug) \
92 printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg) 95 printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
93 96
@@ -184,8 +187,7 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
184/* ----------------------------------------------------------- */ 187/* ----------------------------------------------------------- */
185/* delayed request_module */ 188/* delayed request_module */
186 189
187#ifdef CONFIG_MODULES 190#if defined(CONFIG_MODULES) && defined(MODULE)
188
189static int need_empress; 191static int need_empress;
190static int need_dvb; 192static int need_dvb;
191static int need_alsa; 193static int need_alsa;
@@ -234,9 +236,7 @@ static void request_module_depend(char *name, int *flag)
234} 236}
235 237
236#else 238#else
237
238#define request_module_depend(name,flag) 239#define request_module_depend(name,flag)
239
240#endif /* CONFIG_MODULES */ 240#endif /* CONFIG_MODULES */
241 241
242/* ------------------------------------------------------------------ */ 242/* ------------------------------------------------------------------ */
@@ -1017,6 +1017,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1017 /* check for signal */ 1017 /* check for signal */
1018 saa7134_irq_video_intl(dev); 1018 saa7134_irq_video_intl(dev);
1019 1019
1020 if (dmasound_init && !dev->dmasound.priv_data) {
1021 dmasound_init(dev);
1022 }
1023
1020 return 0; 1024 return 0;
1021 1025
1022 fail4: 1026 fail4:
@@ -1040,6 +1044,11 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1040 struct list_head *item; 1044 struct list_head *item;
1041 struct saa7134_mpeg_ops *mops; 1045 struct saa7134_mpeg_ops *mops;
1042 1046
1047 /* Release DMA sound modules if present */
1048 if (dmasound_exit && dev->dmasound.priv_data) {
1049 dmasound_exit(dev);
1050 }
1051
1043 /* debugging ... */ 1052 /* debugging ... */
1044 if (irq_debug) { 1053 if (irq_debug) {
1045 u32 report = saa_readl(SAA7134_IRQ_REPORT); 1054 u32 report = saa_readl(SAA7134_IRQ_REPORT);
@@ -1071,6 +1080,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1071 saa7134_i2c_unregister(dev); 1080 saa7134_i2c_unregister(dev);
1072 saa7134_unregister_video(dev); 1081 saa7134_unregister_video(dev);
1073 1082
1083
1074 /* the DMA sound modules should be unloaded before reaching 1084 /* the DMA sound modules should be unloaded before reaching
1075 this, but just in case they are still present... */ 1085 this, but just in case they are still present... */
1076 if (dev->dmasound.priv_data != NULL) { 1086 if (dev->dmasound.priv_data != NULL) {
@@ -1078,6 +1088,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1078 dev->dmasound.priv_data = NULL; 1088 dev->dmasound.priv_data = NULL;
1079 } 1089 }
1080 1090
1091
1081 /* release resources */ 1092 /* release resources */
1082 free_irq(pci_dev->irq, dev); 1093 free_irq(pci_dev->irq, dev);
1083 iounmap(dev->lmmio); 1094 iounmap(dev->lmmio);
@@ -1149,10 +1160,10 @@ static int saa7134_init(void)
1149 1160
1150static void saa7134_fini(void) 1161static void saa7134_fini(void)
1151{ 1162{
1152#ifdef CONFIG_MODULES 1163#if defined(CONFIG_MODULES) && defined(MODULE)
1153 if (pending_registered) 1164 if (pending_registered)
1154 unregister_module_notifier(&pending_notifier); 1165 unregister_module_notifier(&pending_notifier);
1155#endif 1166#endif /* CONFIG_MODULES */
1156 pci_unregister_driver(&saa7134_pci_driver); 1167 pci_unregister_driver(&saa7134_pci_driver);
1157} 1168}
1158 1169
@@ -1168,6 +1179,8 @@ EXPORT_SYMBOL(saa7134_boards);
1168 1179
1169/* ----------------- for the DMA sound modules --------------- */ 1180/* ----------------- for the DMA sound modules --------------- */
1170 1181
1182EXPORT_SYMBOL(dmasound_init);
1183EXPORT_SYMBOL(dmasound_exit);
1171EXPORT_SYMBOL(saa7134_pgtable_free); 1184EXPORT_SYMBOL(saa7134_pgtable_free);
1172EXPORT_SYMBOL(saa7134_pgtable_build); 1185EXPORT_SYMBOL(saa7134_pgtable_build);
1173EXPORT_SYMBOL(saa7134_pgtable_alloc); 1186EXPORT_SYMBOL(saa7134_pgtable_alloc);
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index fd9ed11ab1e2..5a579194e455 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -899,26 +899,26 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
899 spin_unlock(&dev->slock); 899 spin_unlock(&dev->slock);
900} 900}
901 901
902int saa7134_dsp_create(struct saa7134_dev *dev) 902static int saa7134_dsp_create(struct saa7134_dev *dev)
903{ 903{
904 int err; 904 int err;
905 905
906 err = dev->dmasound.minor_dsp = 906 err = dev->dmasound.minor_dsp =
907 register_sound_dsp(&saa7134_dsp_fops, 907 register_sound_dsp(&saa7134_dsp_fops,
908 dsp_nr[dev->nr]); 908 dsp_nr[dev->nr]);
909 if (err < 0) { 909 if (err < 0) {
910 goto fail; 910 goto fail;
911 } 911 }
912 printk(KERN_INFO "%s: registered device dsp%d\n", 912 printk(KERN_INFO "%s: registered device dsp%d\n",
913 dev->name,dev->dmasound.minor_dsp >> 4); 913 dev->name,dev->dmasound.minor_dsp >> 4);
914 914
915 err = dev->dmasound.minor_mixer = 915 err = dev->dmasound.minor_mixer =
916 register_sound_mixer(&saa7134_mixer_fops, 916 register_sound_mixer(&saa7134_mixer_fops,
917 mixer_nr[dev->nr]); 917 mixer_nr[dev->nr]);
918 if (err < 0) 918 if (err < 0)
919 goto fail; 919 goto fail;
920 printk(KERN_INFO "%s: registered device mixer%d\n", 920 printk(KERN_INFO "%s: registered device mixer%d\n",
921 dev->name,dev->dmasound.minor_mixer >> 4); 921 dev->name,dev->dmasound.minor_mixer >> 4);
922 922
923 return 0; 923 return 0;
924 924
@@ -929,6 +929,31 @@ fail:
929 929
930} 930}
931 931
932static int oss_device_init(struct saa7134_dev *dev)
933{
934 dev->dmasound.priv_data = dev;
935 saa7134_oss_init1(dev);
936 saa7134_dsp_create(dev);
937 return 1;
938}
939
940static int oss_device_exit(struct saa7134_dev *dev)
941{
942
943 unregister_sound_mixer(dev->dmasound.minor_mixer);
944 unregister_sound_dsp(dev->dmasound.minor_dsp);
945
946 saa7134_oss_fini(dev);
947
948 if (dev->pci->irq > 0) {
949 synchronize_irq(dev->pci->irq);
950 free_irq(dev->pci->irq,&dev->dmasound);
951 }
952
953 dev->dmasound.priv_data = NULL;
954 return 1;
955}
956
932static int saa7134_oss_init(void) 957static int saa7134_oss_init(void)
933{ 958{
934 struct saa7134_dev *dev = NULL; 959 struct saa7134_dev *dev = NULL;
@@ -939,9 +964,7 @@ static int saa7134_oss_init(void)
939 list_for_each(list,&saa7134_devlist) { 964 list_for_each(list,&saa7134_devlist) {
940 dev = list_entry(list, struct saa7134_dev, devlist); 965 dev = list_entry(list, struct saa7134_dev, devlist);
941 if (dev->dmasound.priv_data == NULL) { 966 if (dev->dmasound.priv_data == NULL) {
942 dev->dmasound.priv_data = dev; 967 oss_device_init(dev);
943 saa7134_oss_init1(dev);
944 saa7134_dsp_create(dev);
945 } else { 968 } else {
946 printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name); 969 printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name);
947 return -EBUSY; 970 return -EBUSY;
@@ -951,11 +974,14 @@ static int saa7134_oss_init(void)
951 if (dev == NULL) 974 if (dev == NULL)
952 printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n"); 975 printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n");
953 976
977 dmasound_init = oss_device_init;
978 dmasound_exit = oss_device_exit;
979
954 return 0; 980 return 0;
955 981
956} 982}
957 983
958void saa7134_oss_exit(void) 984static void saa7134_oss_exit(void)
959{ 985{
960 struct saa7134_dev *dev = NULL; 986 struct saa7134_dev *dev = NULL;
961 struct list_head *list; 987 struct list_head *list;
@@ -967,18 +993,7 @@ void saa7134_oss_exit(void)
967 if (!dev->dmasound.minor_dsp) 993 if (!dev->dmasound.minor_dsp)
968 continue; 994 continue;
969 995
970 unregister_sound_mixer(dev->dmasound.minor_mixer); 996 oss_device_exit(dev);
971 unregister_sound_dsp(dev->dmasound.minor_dsp);
972
973 saa7134_oss_fini(dev);
974
975 if (dev->pci->irq > 0) {
976 synchronize_irq(dev->pci->irq);
977 free_irq(dev->pci->irq,&dev->dmasound);
978 }
979
980 dev->dmasound.priv_data = NULL;
981
982 } 997 }
983 998
984 printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n"); 999 printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n");
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 244e1973081c..add49db1ad41 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -571,6 +571,10 @@ void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf);
571 571
572int saa7134_set_dmabits(struct saa7134_dev *dev); 572int saa7134_set_dmabits(struct saa7134_dev *dev);
573 573
574extern int (*dmasound_init)(struct saa7134_dev *dev);
575extern int (*dmasound_exit)(struct saa7134_dev *dev);
576
577
574/* ----------------------------------------------------------- */ 578/* ----------------------------------------------------------- */
575/* saa7134-cards.c */ 579/* saa7134-cards.c */
576 580
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 72e8741e8b59..d95aecebbda3 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -81,7 +81,7 @@ hauppauge_tuner_fmt[] =
81 { 0x00000010, " PAL(I)" }, 81 { 0x00000010, " PAL(I)" },
82 { 0x00400000, " SECAM(L/L')" }, 82 { 0x00400000, " SECAM(L/L')" },
83 { 0x00000e00, " PAL(D/K)" }, 83 { 0x00000e00, " PAL(D/K)" },
84 { 0x03000000, " ATSC Digital" }, 84 { 0x03000000, " ATSC/DVB Digital" },
85}; 85};
86 86
87/* This is the full list of possible tuners. Many thanks to Hauppauge for 87/* This is the full list of possible tuners. Many thanks to Hauppauge for
@@ -209,13 +209,27 @@ hauppauge_tuner[] =
209 { TUNER_ABSENT, "Philips FMD1216ME"}, 209 { TUNER_ABSENT, "Philips FMD1216ME"},
210 { TUNER_TEA5767, "Philips TEA5768HL FM Radio"}, 210 { TUNER_TEA5767, "Philips TEA5768HL FM Radio"},
211 { TUNER_ABSENT, "Panasonic ENV57H12D5"}, 211 { TUNER_ABSENT, "Panasonic ENV57H12D5"},
212 { TUNER_ABSENT, "TCL MFNM05-4"}, 212 { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05-4"},
213 { TUNER_ABSENT, "TCL MNM05-4"}, 213 { TUNER_ABSENT, "TCL MNM05-4"},
214 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MPE05-2"}, 214 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MPE05-2"},
215 { TUNER_ABSENT, "TCL MQNM05-4"}, 215 { TUNER_ABSENT, "TCL MQNM05-4"},
216 { TUNER_ABSENT, "LG TAPC-W701D"}, 216 { TUNER_ABSENT, "LG TAPC-W701D"},
217 { TUNER_ABSENT, "TCL 9886P-WM"}, 217 { TUNER_ABSENT, "TCL 9886P-WM"},
218 { TUNER_ABSENT, "TCL 1676NM-WM"}, 218 { TUNER_ABSENT, "TCL 1676NM-WM"},
219 /* 110-119 */
220 { TUNER_ABSENT, "Thompson DTT75105"},
221 { TUNER_ABSENT, "Conexant_CX24109"},
222 { TUNER_ABSENT, "TCL M2523_5N_E"},
223 { TUNER_ABSENT, "TCL M2523_3DB_E"},
224 { TUNER_ABSENT, "Philips 8275A"},
225 { TUNER_ABSENT, "Microtune MT2060"},
226 { TUNER_ABSENT, "Philips FM1236 MK5"},
227 { TUNER_ABSENT, "Philips FM1216ME MK5"},
228 { TUNER_ABSENT, "TCL M2523_3DI_E"},
229 { TUNER_ABSENT, "Samsung THPD5222FG30A"},
230 /* 120-129 */
231 { TUNER_ABSENT, "Xceive XC3028"},
232 { TUNER_ABSENT, "Philips FQ1216LME MK5"},
219}; 233};
220 234
221static struct HAUPPAUGE_AUDIOIC 235static struct HAUPPAUGE_AUDIOIC
@@ -325,6 +339,7 @@ static int hasRadioTuner(int tunerType)
325 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM: 339 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM:
326 case 89: //PNPEnv_TUNER_TCL_MFPE05_2: 340 case 89: //PNPEnv_TUNER_TCL_MFPE05_2:
327 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4: 341 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4:
342 case 105:
328 return 1; 343 return 1;
329 } 344 }
330 return 0; 345 return 0;
@@ -368,10 +383,15 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
368 memset(tvee, 0, sizeof(*tvee)); 383 memset(tvee, 0, sizeof(*tvee));
369 done = len = beenhere = 0; 384 done = len = beenhere = 0;
370 385
371 /* Hack for processing eeprom for em28xx */ 386 /* Hack for processing eeprom for em28xx and cx 2388x*/
372 if ((eeprom_data[0]==0x1a)&&(eeprom_data[1]==0xeb)&& 387 if ((eeprom_data[0] == 0x1a) && (eeprom_data[1] == 0xeb) &&
373 (eeprom_data[2]==0x67)&&(eeprom_data[3]==0x95)) 388 (eeprom_data[2] == 0x67) && (eeprom_data[3] == 0x95))
374 start=0xa0; 389 start=0xa0; /* Generic em28xx offset */
390 else if (((eeprom_data[0] & 0xf0) == 0x10) &&
391 (eeprom_data[1] == 0x00) &&
392 (eeprom_data[2] == 0x00) &&
393 (eeprom_data[8] == 0x84))
394 start=8; /* Generic cx2388x offset */
375 else 395 else
376 start=0; 396 start=0;
377 397
@@ -448,6 +468,17 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
448 eeprom_data[i+5] + 468 eeprom_data[i+5] +
449 (eeprom_data[i+6] << 8) + 469 (eeprom_data[i+6] << 8) +
450 (eeprom_data[i+7] << 16); 470 (eeprom_data[i+7] << 16);
471
472 if ( (eeprom_data[i + 8] && 0xf0) &&
473 (tvee->serial_number < 0xffffff) ) {
474 tvee->MAC_address[0] = 0x00;
475 tvee->MAC_address[1] = 0x0D;
476 tvee->MAC_address[2] = 0xFE;
477 tvee->MAC_address[3] = eeprom_data[i + 7];
478 tvee->MAC_address[4] = eeprom_data[i + 6];
479 tvee->MAC_address[5] = eeprom_data[i + 5];
480 tvee->has_MAC_address = 1;
481 }
451 break; 482 break;
452 483
453 case 0x05: 484 case 0x05:
@@ -466,11 +497,14 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
466 case 0x06: 497 case 0x06:
467 /* tag 'ModelRev' */ 498 /* tag 'ModelRev' */
468 tvee->model = 499 tvee->model =
469 eeprom_data[i+1] + 500 eeprom_data[i + 1] +
470 (eeprom_data[i+2] << 8); 501 (eeprom_data[i + 2] << 8) +
471 tvee->revision = eeprom_data[i+5] + 502 (eeprom_data[i + 3] << 16) +
472 (eeprom_data[i+6] << 8) + 503 (eeprom_data[i + 4] << 24);
473 (eeprom_data[i+7] << 16); 504 tvee->revision =
505 eeprom_data[i +5 ] +
506 (eeprom_data[i + 6] << 8) +
507 (eeprom_data[i + 7] << 16);
474 break; 508 break;
475 509
476 case 0x07: 510 case 0x07:
@@ -563,6 +597,8 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
563 t_name2 = "unknown"; 597 t_name2 = "unknown";
564 } 598 }
565 599
600 tvee->tuner_hauppauge_model = tuner1;
601 tvee->tuner2_hauppauge_model = tuner2;
566 tvee->tuner_formats = 0; 602 tvee->tuner_formats = 0;
567 tvee->tuner2_formats = 0; 603 tvee->tuner2_formats = 0;
568 for (i = j = 0; i < 8; i++) { 604 for (i = j = 0; i < 8; i++) {
@@ -578,6 +614,12 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
578 614
579 tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n", 615 tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n",
580 tvee->model, tvee->rev_str, tvee->serial_number); 616 tvee->model, tvee->rev_str, tvee->serial_number);
617 if (tvee->has_MAC_address == 1) {
618 tveeprom_info("MAC address is %02X-%02X-%02X-%02X-%02X-%02X\n",
619 tvee->MAC_address[0], tvee->MAC_address[1],
620 tvee->MAC_address[2], tvee->MAC_address[3],
621 tvee->MAC_address[4], tvee->MAC_address[5]);
622 }
581 tveeprom_info("tuner model is %s (idx %d, type %d)\n", 623 tveeprom_info("tuner model is %s (idx %d, type %d)\n",
582 t_name1, tuner1, tvee->tuner_type); 624 t_name1, tuner1, tvee->tuner_type);
583 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", 625 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n",
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index acfd3a103f35..9a6bf287e26a 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -753,10 +753,9 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
753 int retval; 753 int retval;
754 754
755 /* setup stuff */ 755 /* setup stuff */
756 retval = -ENOMEM;
757 q->read_buf = videobuf_alloc(q->msize); 756 q->read_buf = videobuf_alloc(q->msize);
758 if (NULL == q->read_buf) 757 if (NULL == q->read_buf)
759 goto done; 758 return -ENOMEM;
760 759
761 q->read_buf->memory = V4L2_MEMORY_USERPTR; 760 q->read_buf->memory = V4L2_MEMORY_USERPTR;
762 q->read_buf->baddr = (unsigned long)data; 761 q->read_buf->baddr = (unsigned long)data;
@@ -817,10 +816,14 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
817 if (NULL == q->read_buf) 816 if (NULL == q->read_buf)
818 goto done; 817 goto done;
819 q->read_buf->memory = V4L2_MEMORY_USERPTR; 818 q->read_buf->memory = V4L2_MEMORY_USERPTR;
819 q->read_buf->bsize = count; /* preferred size */
820 field = videobuf_next_field(q); 820 field = videobuf_next_field(q);
821 retval = q->ops->buf_prepare(q,q->read_buf,field); 821 retval = q->ops->buf_prepare(q,q->read_buf,field);
822 if (0 != retval) 822 if (0 != retval) {
823 kfree (q->read_buf);
824 q->read_buf = NULL;
823 goto done; 825 goto done;
826 }
824 spin_lock_irqsave(q->irqlock,flags); 827 spin_lock_irqsave(q->irqlock,flags);
825 q->ops->buf_queue(q,q->read_buf); 828 q->ops->buf_queue(q,q->read_buf);
826 spin_unlock_irqrestore(q->irqlock,flags); 829 spin_unlock_irqrestore(q->irqlock,flags);
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 83c49f9610d0..6de5b0094b82 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -76,14 +76,14 @@ static void video_release(struct class_device *cd)
76} 76}
77 77
78static struct class video_class = { 78static struct class video_class = {
79 .name = VIDEO_NAME, 79 .name = VIDEO_NAME,
80 .release = video_release, 80 .release = video_release,
81}; 81};
82 82
83/* 83/*
84 * Active devices 84 * Active devices
85 */ 85 */
86 86
87static struct video_device *video_device[VIDEO_NUM_DEVICES]; 87static struct video_device *video_device[VIDEO_NUM_DEVICES];
88static DECLARE_MUTEX(videodev_lock); 88static DECLARE_MUTEX(videodev_lock);
89 89
@@ -101,7 +101,7 @@ static int video_open(struct inode *inode, struct file *file)
101 int err = 0; 101 int err = 0;
102 struct video_device *vfl; 102 struct video_device *vfl;
103 struct file_operations *old_fops; 103 struct file_operations *old_fops;
104 104
105 if(minor>=VIDEO_NUM_DEVICES) 105 if(minor>=VIDEO_NUM_DEVICES)
106 return -ENODEV; 106 return -ENODEV;
107 down(&videodev_lock); 107 down(&videodev_lock);
@@ -189,7 +189,7 @@ video_usercopy(struct inode *inode, struct file *file,
189 return -ENOMEM; 189 return -ENOMEM;
190 parg = mbuf; 190 parg = mbuf;
191 } 191 }
192 192
193 err = -EFAULT; 193 err = -EFAULT;
194 if (_IOC_DIR(cmd) & _IOC_WRITE) 194 if (_IOC_DIR(cmd) & _IOC_WRITE)
195 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) 195 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
@@ -240,7 +240,7 @@ int video_exclusive_open(struct inode *inode, struct file *file)
240int video_exclusive_release(struct inode *inode, struct file *file) 240int video_exclusive_release(struct inode *inode, struct file *file)
241{ 241{
242 struct video_device *vfl = video_devdata(file); 242 struct video_device *vfl = video_devdata(file);
243 243
244 vfl->users--; 244 vfl->users--;
245 return 0; 245 return 0;
246} 246}
@@ -253,7 +253,7 @@ static struct file_operations video_fops;
253 * @type: type of device to register 253 * @type: type of device to register
254 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ... 254 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
255 * -1 == first free) 255 * -1 == first free)
256 * 256 *
257 * The registration code assigns minor numbers based on the type 257 * The registration code assigns minor numbers based on the type
258 * requested. -ENFILE is returned in all the device slots for this 258 * requested. -ENFILE is returned in all the device slots for this
259 * category are full. If not then the minor field is set and the 259 * category are full. If not then the minor field is set and the
@@ -269,7 +269,7 @@ static struct file_operations video_fops;
269 * 269 *
270 * %VFL_TYPE_VBI - Vertical blank data (undecoded) 270 * %VFL_TYPE_VBI - Vertical blank data (undecoded)
271 * 271 *
272 * %VFL_TYPE_RADIO - A radio card 272 * %VFL_TYPE_RADIO - A radio card
273 */ 273 */
274 274
275int video_register_device(struct video_device *vfd, int type, int nr) 275int video_register_device(struct video_device *vfd, int type, int nr)
@@ -278,7 +278,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
278 int base; 278 int base;
279 int end; 279 int end;
280 char *name_base; 280 char *name_base;
281 281
282 switch(type) 282 switch(type)
283 { 283 {
284 case VFL_TYPE_GRABBER: 284 case VFL_TYPE_GRABBER:
@@ -293,7 +293,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
293 break; 293 break;
294 case VFL_TYPE_VBI: 294 case VFL_TYPE_VBI:
295 base=224; 295 base=224;
296 end=240; 296 end=256;
297 name_base = "vbi"; 297 name_base = "vbi";
298 break; 298 break;
299 case VFL_TYPE_RADIO: 299 case VFL_TYPE_RADIO:
@@ -334,7 +334,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
334 init_MUTEX(&vfd->lock); 334 init_MUTEX(&vfd->lock);
335 335
336 /* sysfs class */ 336 /* sysfs class */
337 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev)); 337 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
338 if (vfd->dev) 338 if (vfd->dev)
339 vfd->class_dev.dev = vfd->dev; 339 vfd->class_dev.dev = vfd->dev;
340 vfd->class_dev.class = &video_class; 340 vfd->class_dev.class = &video_class;
@@ -360,7 +360,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
360 * This unregisters the passed device and deassigns the minor 360 * This unregisters the passed device and deassigns the minor
361 * number. Future open calls will be met with errors. 361 * number. Future open calls will be met with errors.
362 */ 362 */
363 363
364void video_unregister_device(struct video_device *vfd) 364void video_unregister_device(struct video_device *vfd)
365{ 365{
366 down(&videodev_lock); 366 down(&videodev_lock);
@@ -384,7 +384,7 @@ static struct file_operations video_fops=
384/* 384/*
385 * Initialise video for linux 385 * Initialise video for linux
386 */ 386 */
387 387
388static int __init videodev_init(void) 388static int __init videodev_init(void)
389{ 389{
390 int ret; 390 int ret;
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index cabf35373cfd..4262a22adc22 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -91,9 +91,9 @@ static int mfcounter = 0;
91 * Public data... 91 * Public data...
92 */ 92 */
93int mpt_lan_index = -1; 93int mpt_lan_index = -1;
94static int mpt_stm_index = -1; 94int mpt_stm_index = -1;
95 95
96static struct proc_dir_entry *mpt_proc_root_dir; 96struct proc_dir_entry *mpt_proc_root_dir;
97 97
98#define WHOINIT_UNKNOWN 0xAA 98#define WHOINIT_UNKNOWN 0xAA
99 99
@@ -6330,6 +6330,7 @@ EXPORT_SYMBOL(mpt_resume);
6330EXPORT_SYMBOL(mpt_suspend); 6330EXPORT_SYMBOL(mpt_suspend);
6331#endif 6331#endif
6332EXPORT_SYMBOL(ioc_list); 6332EXPORT_SYMBOL(ioc_list);
6333EXPORT_SYMBOL(mpt_proc_root_dir);
6333EXPORT_SYMBOL(mpt_register); 6334EXPORT_SYMBOL(mpt_register);
6334EXPORT_SYMBOL(mpt_deregister); 6335EXPORT_SYMBOL(mpt_deregister);
6335EXPORT_SYMBOL(mpt_event_register); 6336EXPORT_SYMBOL(mpt_event_register);
@@ -6347,6 +6348,7 @@ EXPORT_SYMBOL(mpt_verify_adapter);
6347EXPORT_SYMBOL(mpt_GetIocState); 6348EXPORT_SYMBOL(mpt_GetIocState);
6348EXPORT_SYMBOL(mpt_print_ioc_summary); 6349EXPORT_SYMBOL(mpt_print_ioc_summary);
6349EXPORT_SYMBOL(mpt_lan_index); 6350EXPORT_SYMBOL(mpt_lan_index);
6351EXPORT_SYMBOL(mpt_stm_index);
6350EXPORT_SYMBOL(mpt_HardResetHandler); 6352EXPORT_SYMBOL(mpt_HardResetHandler);
6351EXPORT_SYMBOL(mpt_config); 6353EXPORT_SYMBOL(mpt_config);
6352EXPORT_SYMBOL(mpt_toolbox); 6354EXPORT_SYMBOL(mpt_toolbox);
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index a564ae36a2c2..bac8eb4186d2 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -1009,8 +1009,10 @@ extern int mpt_alt_ioc_wait(MPT_ADAPTER *ioc);
1009 * Public data decl's... 1009 * Public data decl's...
1010 */ 1010 */
1011extern struct list_head ioc_list; 1011extern struct list_head ioc_list;
1012extern struct proc_dir_entry *mpt_proc_root_dir;
1012 1013
1013extern int mpt_lan_index; /* needed by mptlan.c */ 1014extern int mpt_lan_index; /* needed by mptlan.c */
1015extern int mpt_stm_index; /* needed by mptstm.c */
1014 1016
1015/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1017/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1016#endif /* } __KERNEL__ */ 1018#endif /* } __KERNEL__ */
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index da528390acf8..d336a1d65dc7 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -816,7 +816,7 @@ static void mmc_discover_cards(struct mmc_host *host)
816 816
817 cmd.opcode = SD_SEND_RELATIVE_ADDR; 817 cmd.opcode = SD_SEND_RELATIVE_ADDR;
818 cmd.arg = 0; 818 cmd.arg = 0;
819 cmd.flags = MMC_RSP_R1; 819 cmd.flags = MMC_RSP_R6;
820 820
821 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 821 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
822 if (err != MMC_ERR_NONE) 822 if (err != MMC_ERR_NONE)
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 143f01a4c170..69c04945591f 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0001.c,v 1.185 2005/11/07 11:14:22 gleixner Exp $ 7 * $Id: cfi_cmdset_0001.c,v 1.186 2005/11/23 22:07:52 nico Exp $
8 * 8 *
9 * 9 *
10 * 10/10/2000 Nicolas Pitre <nico@cam.org> 10 * 10/10/2000 Nicolas Pitre <nico@cam.org>
@@ -644,9 +644,8 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
644 * 644 *
645 * - contension arbitration is handled in the owner's context. 645 * - contension arbitration is handled in the owner's context.
646 * 646 *
647 * The 'shared' struct can be read when its lock is taken. 647 * The 'shared' struct can be read and/or written only when
648 * However any writes to it can only be made when the current 648 * its lock is taken.
649 * owner's lock is also held.
650 */ 649 */
651 struct flchip_shared *shared = chip->priv; 650 struct flchip_shared *shared = chip->priv;
652 struct flchip *contender; 651 struct flchip *contender;
@@ -675,14 +674,13 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
675 } 674 }
676 timeo = jiffies + HZ; 675 timeo = jiffies + HZ;
677 spin_lock(&shared->lock); 676 spin_lock(&shared->lock);
677 spin_unlock(contender->mutex);
678 } 678 }
679 679
680 /* We now own it */ 680 /* We now own it */
681 shared->writing = chip; 681 shared->writing = chip;
682 if (mode == FL_ERASING) 682 if (mode == FL_ERASING)
683 shared->erasing = chip; 683 shared->erasing = chip;
684 if (contender && contender != chip)
685 spin_unlock(contender->mutex);
686 spin_unlock(&shared->lock); 684 spin_unlock(&shared->lock);
687 } 685 }
688 686
diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c
index 90eb30e06b7c..e636aa86bc24 100644
--- a/drivers/mtd/chips/cfi_probe.c
+++ b/drivers/mtd/chips/cfi_probe.c
@@ -1,7 +1,7 @@
1/* 1/*
2 Common Flash Interface probe code. 2 Common Flash Interface probe code.
3 (C) 2000 Red Hat. GPL'd. 3 (C) 2000 Red Hat. GPL'd.
4 $Id: cfi_probe.c,v 1.84 2005/11/07 11:14:23 gleixner Exp $ 4 $Id: cfi_probe.c,v 1.86 2005/11/29 14:48:31 gleixner Exp $
5*/ 5*/
6 6
7#include <linux/config.h> 7#include <linux/config.h>
@@ -230,8 +230,8 @@ static int __xipram cfi_chip_setup(struct map_info *map,
230 cfi_send_gen_cmd(0xaa, 0x555, base, map, cfi, cfi->device_type, NULL); 230 cfi_send_gen_cmd(0xaa, 0x555, base, map, cfi, cfi->device_type, NULL);
231 cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL); 231 cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL);
232 cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL); 232 cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL);
233 cfi->mfr = cfi_read_query(map, base); 233 cfi->mfr = cfi_read_query16(map, base);
234 cfi->id = cfi_read_query(map, base + ofs_factor); 234 cfi->id = cfi_read_query16(map, base + ofs_factor);
235 235
236 /* Put it back into Read Mode */ 236 /* Put it back into Read Mode */
237 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); 237 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
@@ -426,7 +426,7 @@ static struct mtd_chip_driver cfi_chipdrv = {
426 .module = THIS_MODULE 426 .module = THIS_MODULE
427}; 427};
428 428
429int __init cfi_probe_init(void) 429static int __init cfi_probe_init(void)
430{ 430{
431 register_mtd_chip_driver(&cfi_chipdrv); 431 register_mtd_chip_driver(&cfi_chipdrv);
432 return 0; 432 return 0;
diff --git a/drivers/mtd/chips/sharp.c b/drivers/mtd/chips/sharp.c
index 2d26bdef82d5..36f61a6a766e 100644
--- a/drivers/mtd/chips/sharp.c
+++ b/drivers/mtd/chips/sharp.c
@@ -4,7 +4,7 @@
4 * Copyright 2000,2001 David A. Schleef <ds@schleef.org> 4 * Copyright 2000,2001 David A. Schleef <ds@schleef.org>
5 * 2000,2001 Lineo, Inc. 5 * 2000,2001 Lineo, Inc.
6 * 6 *
7 * $Id: sharp.c,v 1.16 2005/11/07 11:14:23 gleixner Exp $ 7 * $Id: sharp.c,v 1.17 2005/11/29 14:28:28 gleixner Exp $
8 * 8 *
9 * Devices supported: 9 * Devices supported:
10 * LH28F016SCT Symmetrical block flash memory, 2Mx8 10 * LH28F016SCT Symmetrical block flash memory, 2Mx8
@@ -160,22 +160,28 @@ struct mtd_info *sharp_probe(struct map_info *map)
160 return mtd; 160 return mtd;
161} 161}
162 162
163static inline void sharp_send_cmd(struct map_info *map, unsigned long cmd, unsigned long adr)
164{
165 map_word map_cmd;
166 map_cmd.x[0] = cmd;
167 map_write(map, map_cmd, adr);
168}
169
163static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd) 170static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
164{ 171{
165 unsigned long tmp; 172 map_word tmp, read0, read4;
166 unsigned long base = 0; 173 unsigned long base = 0;
167 u32 read0, read4;
168 int width = 4; 174 int width = 4;
169 175
170 tmp = map_read32(map, base+0); 176 tmp = map_read(map, base+0);
171 177
172 map_write32(map, CMD_READ_ID, base+0); 178 sharp_send_cmd(map, CMD_READ_ID, base+0);
173 179
174 read0=map_read32(map, base+0); 180 read0 = map_read(map, base+0);
175 read4=map_read32(map, base+4); 181 read4 = map_read(map, base+4);
176 if(read0 == 0x89898989){ 182 if(read0.x[0] == 0x89898989){
177 printk("Looks like sharp flash\n"); 183 printk("Looks like sharp flash\n");
178 switch(read4){ 184 switch(read4.x[0]){
179 case 0xaaaaaaaa: 185 case 0xaaaaaaaa:
180 case 0xa0a0a0a0: 186 case 0xa0a0a0a0:
181 /* aa - LH28F016SCT-L95 2Mx8, 32 64k blocks*/ 187 /* aa - LH28F016SCT-L95 2Mx8, 32 64k blocks*/
@@ -197,16 +203,16 @@ static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
197 return width; 203 return width;
198#endif 204#endif
199 default: 205 default:
200 printk("Sort-of looks like sharp flash, 0x%08x 0x%08x\n", 206 printk("Sort-of looks like sharp flash, 0x%08lx 0x%08lx\n",
201 read0,read4); 207 read0.x[0], read4.x[0]);
202 } 208 }
203 }else if((map_read32(map, base+0) == CMD_READ_ID)){ 209 }else if((map_read(map, base+0).x[0] == CMD_READ_ID)){
204 /* RAM, probably */ 210 /* RAM, probably */
205 printk("Looks like RAM\n"); 211 printk("Looks like RAM\n");
206 map_write32(map, tmp, base+0); 212 map_write(map, tmp, base+0);
207 }else{ 213 }else{
208 printk("Doesn't look like sharp flash, 0x%08x 0x%08x\n", 214 printk("Doesn't look like sharp flash, 0x%08lx 0x%08lx\n",
209 read0,read4); 215 read0.x[0], read4.x[0]);
210 } 216 }
211 217
212 return 0; 218 return 0;
@@ -215,7 +221,8 @@ static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
215/* This function returns with the chip->mutex lock held. */ 221/* This function returns with the chip->mutex lock held. */
216static int sharp_wait(struct map_info *map, struct flchip *chip) 222static int sharp_wait(struct map_info *map, struct flchip *chip)
217{ 223{
218 int status, i; 224 int i;
225 map_word status;
219 unsigned long timeo = jiffies + HZ; 226 unsigned long timeo = jiffies + HZ;
220 DECLARE_WAITQUEUE(wait, current); 227 DECLARE_WAITQUEUE(wait, current);
221 int adr = 0; 228 int adr = 0;
@@ -225,12 +232,12 @@ retry:
225 232
226 switch(chip->state){ 233 switch(chip->state){
227 case FL_READY: 234 case FL_READY:
228 map_write32(map,CMD_READ_STATUS,adr); 235 sharp_send_cmd(map, CMD_READ_STATUS, adr);
229 chip->state = FL_STATUS; 236 chip->state = FL_STATUS;
230 case FL_STATUS: 237 case FL_STATUS:
231 for(i=0;i<100;i++){ 238 for(i=0;i<100;i++){
232 status = map_read32(map,adr); 239 status = map_read(map, adr);
233 if((status & SR_READY)==SR_READY) 240 if((status.x[0] & SR_READY)==SR_READY)
234 break; 241 break;
235 udelay(1); 242 udelay(1);
236 } 243 }
@@ -254,7 +261,7 @@ retry:
254 goto retry; 261 goto retry;
255 } 262 }
256 263
257 map_write32(map,CMD_RESET, adr); 264 sharp_send_cmd(map, CMD_RESET, adr);
258 265
259 chip->state = FL_READY; 266 chip->state = FL_READY;
260 267
@@ -351,37 +358,39 @@ static int sharp_write_oneword(struct map_info *map, struct flchip *chip,
351 int timeo; 358 int timeo;
352 int try; 359 int try;
353 int i; 360 int i;
354 int status = 0; 361 map_word data, status;
355 362
363 status.x[0] = 0;
356 ret = sharp_wait(map,chip); 364 ret = sharp_wait(map,chip);
357 365
358 for(try=0;try<10;try++){ 366 for(try=0;try<10;try++){
359 map_write32(map,CMD_BYTE_WRITE,adr); 367 sharp_send_cmd(map, CMD_BYTE_WRITE, adr);
360 /* cpu_to_le32 -> hack to fix the writel be->le conversion */ 368 /* cpu_to_le32 -> hack to fix the writel be->le conversion */
361 map_write32(map,cpu_to_le32(datum),adr); 369 data.x[0] = cpu_to_le32(datum);
370 map_write(map, data, adr);
362 371
363 chip->state = FL_WRITING; 372 chip->state = FL_WRITING;
364 373
365 timeo = jiffies + (HZ/2); 374 timeo = jiffies + (HZ/2);
366 375
367 map_write32(map,CMD_READ_STATUS,adr); 376 sharp_send_cmd(map, CMD_READ_STATUS, adr);
368 for(i=0;i<100;i++){ 377 for(i=0;i<100;i++){
369 status = map_read32(map,adr); 378 status = map_read(map, adr);
370 if((status & SR_READY)==SR_READY) 379 if((status.x[0] & SR_READY) == SR_READY)
371 break; 380 break;
372 } 381 }
373 if(i==100){ 382 if(i==100){
374 printk("sharp: timed out writing\n"); 383 printk("sharp: timed out writing\n");
375 } 384 }
376 385
377 if(!(status&SR_ERRORS)) 386 if(!(status.x[0] & SR_ERRORS))
378 break; 387 break;
379 388
380 printk("sharp: error writing byte at addr=%08lx status=%08x\n",adr,status); 389 printk("sharp: error writing byte at addr=%08lx status=%08lx\n", adr, status.x[0]);
381 390
382 map_write32(map,CMD_CLEAR_STATUS,adr); 391 sharp_send_cmd(map, CMD_CLEAR_STATUS, adr);
383 } 392 }
384 map_write32(map,CMD_RESET,adr); 393 sharp_send_cmd(map, CMD_RESET, adr);
385 chip->state = FL_READY; 394 chip->state = FL_READY;
386 395
387 wake_up(&chip->wq); 396 wake_up(&chip->wq);
@@ -434,18 +443,18 @@ static int sharp_do_wait_for_ready(struct map_info *map, struct flchip *chip,
434{ 443{
435 int ret; 444 int ret;
436 unsigned long timeo; 445 unsigned long timeo;
437 int status; 446 map_word status;
438 DECLARE_WAITQUEUE(wait, current); 447 DECLARE_WAITQUEUE(wait, current);
439 448
440 map_write32(map,CMD_READ_STATUS,adr); 449 sharp_send_cmd(map, CMD_READ_STATUS, adr);
441 status = map_read32(map,adr); 450 status = map_read(map, adr);
442 451
443 timeo = jiffies + HZ; 452 timeo = jiffies + HZ;
444 453
445 while(time_before(jiffies, timeo)){ 454 while(time_before(jiffies, timeo)){
446 map_write32(map,CMD_READ_STATUS,adr); 455 sharp_send_cmd(map, CMD_READ_STATUS, adr);
447 status = map_read32(map,adr); 456 status = map_read(map, adr);
448 if((status & SR_READY)==SR_READY){ 457 if((status.x[0] & SR_READY)==SR_READY){
449 ret = 0; 458 ret = 0;
450 goto out; 459 goto out;
451 } 460 }
@@ -476,7 +485,7 @@ static int sharp_erase_oneblock(struct map_info *map, struct flchip *chip,
476{ 485{
477 int ret; 486 int ret;
478 //int timeo; 487 //int timeo;
479 int status; 488 map_word status;
480 //int i; 489 //int i;
481 490
482//printk("sharp_erase_oneblock()\n"); 491//printk("sharp_erase_oneblock()\n");
@@ -486,26 +495,26 @@ static int sharp_erase_oneblock(struct map_info *map, struct flchip *chip,
486 sharp_unlock_oneblock(map,chip,adr); 495 sharp_unlock_oneblock(map,chip,adr);
487#endif 496#endif
488 497
489 map_write32(map,CMD_BLOCK_ERASE_1,adr); 498 sharp_send_cmd(map, CMD_BLOCK_ERASE_1, adr);
490 map_write32(map,CMD_BLOCK_ERASE_2,adr); 499 sharp_send_cmd(map, CMD_BLOCK_ERASE_2, adr);
491 500
492 chip->state = FL_ERASING; 501 chip->state = FL_ERASING;
493 502
494 ret = sharp_do_wait_for_ready(map,chip,adr); 503 ret = sharp_do_wait_for_ready(map,chip,adr);
495 if(ret<0)return ret; 504 if(ret<0)return ret;
496 505
497 map_write32(map,CMD_READ_STATUS,adr); 506 sharp_send_cmd(map, CMD_READ_STATUS, adr);
498 status = map_read32(map,adr); 507 status = map_read(map, adr);
499 508
500 if(!(status&SR_ERRORS)){ 509 if(!(status.x[0] & SR_ERRORS)){
501 map_write32(map,CMD_RESET,adr); 510 sharp_send_cmd(map, CMD_RESET, adr);
502 chip->state = FL_READY; 511 chip->state = FL_READY;
503 //spin_unlock_bh(chip->mutex); 512 //spin_unlock_bh(chip->mutex);
504 return 0; 513 return 0;
505 } 514 }
506 515
507 printk("sharp: error erasing block at addr=%08lx status=%08x\n",adr,status); 516 printk("sharp: error erasing block at addr=%08lx status=%08lx\n", adr, status.x[0]);
508 map_write32(map,CMD_CLEAR_STATUS,adr); 517 sharp_send_cmd(map, CMD_CLEAR_STATUS, adr);
509 518
510 //spin_unlock_bh(chip->mutex); 519 //spin_unlock_bh(chip->mutex);
511 520
@@ -517,20 +526,20 @@ static void sharp_unlock_oneblock(struct map_info *map, struct flchip *chip,
517 unsigned long adr) 526 unsigned long adr)
518{ 527{
519 int i; 528 int i;
520 int status; 529 map_word status;
521 530
522 map_write32(map,CMD_CLEAR_BLOCK_LOCKS_1,adr); 531 sharp_send_cmd(map, CMD_CLEAR_BLOCK_LOCKS_1, adr);
523 map_write32(map,CMD_CLEAR_BLOCK_LOCKS_2,adr); 532 sharp_send_cmd(map, CMD_CLEAR_BLOCK_LOCKS_2, adr);
524 533
525 udelay(100); 534 udelay(100);
526 535
527 status = map_read32(map,adr); 536 status = map_read(map, adr);
528 printk("status=%08x\n",status); 537 printk("status=%08lx\n", status.x[0]);
529 538
530 for(i=0;i<1000;i++){ 539 for(i=0;i<1000;i++){
531 //map_write32(map,CMD_READ_STATUS,adr); 540 //sharp_send_cmd(map, CMD_READ_STATUS, adr);
532 status = map_read32(map,adr); 541 status = map_read(map, adr);
533 if((status & SR_READY)==SR_READY) 542 if((status.x[0] & SR_READY) == SR_READY)
534 break; 543 break;
535 udelay(100); 544 udelay(100);
536 } 545 }
@@ -538,14 +547,14 @@ static void sharp_unlock_oneblock(struct map_info *map, struct flchip *chip,
538 printk("sharp: timed out unlocking block\n"); 547 printk("sharp: timed out unlocking block\n");
539 } 548 }
540 549
541 if(!(status&SR_ERRORS)){ 550 if(!(status.x[0] & SR_ERRORS)){
542 map_write32(map,CMD_RESET,adr); 551 sharp_send_cmd(map, CMD_RESET, adr);
543 chip->state = FL_READY; 552 chip->state = FL_READY;
544 return; 553 return;
545 } 554 }
546 555
547 printk("sharp: error unlocking block at addr=%08lx status=%08x\n",adr,status); 556 printk("sharp: error unlocking block at addr=%08lx status=%08lx\n", adr, status.x[0]);
548 map_write32(map,CMD_CLEAR_STATUS,adr); 557 sharp_send_cmd(map, CMD_CLEAR_STATUS, adr);
549} 558}
550#endif 559#endif
551 560
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 0aaa0ced9aba..7ff403b2a0a0 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: block2mtd.c,v 1.29 2005/11/07 11:14:24 gleixner Exp $ 2 * $Id: block2mtd.c,v 1.30 2005/11/29 14:48:32 gleixner Exp $
3 * 3 *
4 * block2mtd.c - create an mtd from a block device 4 * block2mtd.c - create an mtd from a block device
5 * 5 *
@@ -19,7 +19,7 @@
19#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
20#include <linux/buffer_head.h> 20#include <linux/buffer_head.h>
21 21
22#define VERSION "$Revision: 1.29 $" 22#define VERSION "$Revision: 1.30 $"
23 23
24 24
25#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args) 25#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
@@ -40,7 +40,7 @@ static LIST_HEAD(blkmtd_device_list);
40 40
41 41
42#define PAGE_READAHEAD 64 42#define PAGE_READAHEAD 64
43void cache_readahead(struct address_space *mapping, int index) 43static void cache_readahead(struct address_space *mapping, int index)
44{ 44{
45 filler_t *filler = (filler_t*)mapping->a_ops->readpage; 45 filler_t *filler = (filler_t*)mapping->a_ops->readpage;
46 int i, pagei; 46 int i, pagei;
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c
index f5026cee087f..0ff2e4378244 100644
--- a/drivers/mtd/devices/ms02-nv.c
+++ b/drivers/mtd/devices/ms02-nv.c
@@ -6,7 +6,7 @@
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
8 * 8 *
9 * $Id: ms02-nv.c,v 1.10 2005/06/20 12:24:41 macro Exp $ 9 * $Id: ms02-nv.c,v 1.11 2005/11/14 13:41:47 macro Exp $
10 */ 10 */
11 11
12#include <linux/init.h> 12#include <linux/init.h>
@@ -293,13 +293,13 @@ static int __init ms02nv_init(void)
293 293
294 switch (mips_machtype) { 294 switch (mips_machtype) {
295 case MACH_DS5000_200: 295 case MACH_DS5000_200:
296 csr = (volatile u32 *)KN02_CSR_BASE; 296 csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE + KN02_CSR);
297 if (*csr & KN02_CSR_BNK32M) 297 if (*csr & KN02_CSR_BNK32M)
298 stride = 2; 298 stride = 2;
299 break; 299 break;
300 case MACH_DS5000_2X0: 300 case MACH_DS5000_2X0:
301 case MACH_DS5900: 301 case MACH_DS5900:
302 csr = (volatile u32 *)KN03_MCR_BASE; 302 csr = (volatile u32 *)CKSEG1ADDR(KN03_SLOT_BASE + IOASIC_MCR);
303 if (*csr & KN03_MCR_BNK32M) 303 if (*csr & KN03_MCR_BNK32M)
304 stride = 2; 304 stride = 2;
305 break; 305 break;
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index de7e231d6d18..8a878b34eca0 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -1,5 +1,5 @@
1/* This version ported to the Linux-MTD system by dwmw2@infradead.org 1/* This version ported to the Linux-MTD system by dwmw2@infradead.org
2 * $Id: ftl.c,v 1.58 2005/11/07 11:14:19 gleixner Exp $ 2 * $Id: ftl.c,v 1.59 2005/11/29 14:48:31 gleixner Exp $
3 * 3 *
4 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br> 4 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups 5 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups
@@ -1084,9 +1084,9 @@ struct mtd_blktrans_ops ftl_tr = {
1084 .owner = THIS_MODULE, 1084 .owner = THIS_MODULE,
1085}; 1085};
1086 1086
1087int init_ftl(void) 1087static int init_ftl(void)
1088{ 1088{
1089 DEBUG(0, "$Id: ftl.c,v 1.58 2005/11/07 11:14:19 gleixner Exp $\n"); 1089 DEBUG(0, "$Id: ftl.c,v 1.59 2005/11/29 14:48:31 gleixner Exp $\n");
1090 1090
1091 return register_mtd_blktrans(&ftl_tr); 1091 return register_mtd_blktrans(&ftl_tr);
1092} 1092}
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 846a533323a8..452ccd5037c3 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -538,12 +538,6 @@ config MTD_MPC1211
538 This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02). 538 This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02).
539 If you have such a board, say 'Y'. 539 If you have such a board, say 'Y'.
540 540
541config MTD_PQ2FADS
542 tristate "JEDEC flash SIMM mapped on PQ2FADS and 8272ADS boards"
543 depends on (ADS8272 || PQ2FADS) && MTD_PARTITIONS && MTD_JEDECPROBE && MTD_PHYSMAP && MTD_CFI_GEOMETRY && MTD_CFI_INTELEXT
544 help
545 This enables access to flash SIMM on PQ2FADS-like boards
546
547config MTD_OMAP_NOR 541config MTD_OMAP_NOR
548 tristate "TI OMAP board mappings" 542 tristate "TI OMAP board mappings"
549 depends on MTD_CFI && ARCH_OMAP 543 depends on MTD_CFI && ARCH_OMAP
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 7d9e940a1dcd..2f7e254912f0 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -70,6 +70,5 @@ obj-$(CONFIG_MTD_DMV182) += dmv182.o
70obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o 70obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o
71obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o 71obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o
72obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o 72obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
73obj-$(CONFIG_MTD_PQ2FADS) += pq2fads.o
74obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o 73obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
75obj-$(CONFIG_MTD_TQM834x) += tqm834x.o 74obj-$(CONFIG_MTD_TQM834x) += tqm834x.o
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index a59f8027903c..986c58628390 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ixp4xx.c,v 1.12 2005/11/07 11:14:27 gleixner Exp $ 2 * $Id: ixp4xx.c,v 1.13 2005/11/16 16:23:21 dvrabel Exp $
3 * 3 *
4 * drivers/mtd/maps/ixp4xx.c 4 * drivers/mtd/maps/ixp4xx.c
5 * 5 *
@@ -34,10 +34,55 @@
34 34
35#include <linux/reboot.h> 35#include <linux/reboot.h>
36 36
37/*
38 * Read/write a 16 bit word from flash address 'addr'.
39 *
40 * When the cpu is in little-endian mode it swizzles the address lines
41 * ('address coherency') so we need to undo the swizzling to ensure commands
42 * and the like end up on the correct flash address.
43 *
44 * To further complicate matters, due to the way the expansion bus controller
45 * handles 32 bit reads, the byte stream ABCD is stored on the flash as:
46 * D15 D0
47 * +---+---+
48 * | A | B | 0
49 * +---+---+
50 * | C | D | 2
51 * +---+---+
52 * This means that on LE systems each 16 bit word must be swapped. Note that
53 * this requires CONFIG_MTD_CFI_BE_BYTE_SWAP to be enabled to 'unswap' the CFI
54 * data and other flash commands which are always in D7-D0.
55 */
37#ifndef __ARMEB__ 56#ifndef __ARMEB__
57#ifndef CONFIG_MTD_CFI_BE_BYTE_SWAP
58# error CONFIG_MTD_CFI_BE_BYTE_SWAP required
59#endif
60
61static inline u16 flash_read16(void __iomem *addr)
62{
63 return be16_to_cpu(__raw_readw((void __iomem *)((unsigned long)addr ^ 0x2)));
64}
65
66static inline void flash_write16(u16 d, void __iomem *addr)
67{
68 __raw_writew(cpu_to_be16(d), (void __iomem *)((unsigned long)addr ^ 0x2));
69}
70
38#define BYTE0(h) ((h) & 0xFF) 71#define BYTE0(h) ((h) & 0xFF)
39#define BYTE1(h) (((h) >> 8) & 0xFF) 72#define BYTE1(h) (((h) >> 8) & 0xFF)
73
40#else 74#else
75
76static inline u16 flash_read16(const void __iomem *addr)
77{
78 return __raw_readw(addr);
79}
80
81static inline void flash_write16(u16 d, void __iomem *addr)
82{
83 __raw_writew(d, addr);
84}
85
41#define BYTE0(h) (((h) >> 8) & 0xFF) 86#define BYTE0(h) (((h) >> 8) & 0xFF)
42#define BYTE1(h) ((h) & 0xFF) 87#define BYTE1(h) ((h) & 0xFF)
43#endif 88#endif
@@ -45,7 +90,7 @@
45static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs) 90static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs)
46{ 91{
47 map_word val; 92 map_word val;
48 val.x[0] = le16_to_cpu(readw(map->virt + ofs)); 93 val.x[0] = flash_read16(map->virt + ofs);
49 return val; 94 return val;
50} 95}
51 96
@@ -57,19 +102,28 @@ static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs)
57static void ixp4xx_copy_from(struct map_info *map, void *to, 102static void ixp4xx_copy_from(struct map_info *map, void *to,
58 unsigned long from, ssize_t len) 103 unsigned long from, ssize_t len)
59{ 104{
60 int i;
61 u8 *dest = (u8 *) to; 105 u8 *dest = (u8 *) to;
62 void __iomem *src = map->virt + from; 106 void __iomem *src = map->virt + from;
63 u16 data;
64 107
65 for (i = 0; i < (len / 2); i++) { 108 if (len <= 0)
66 data = le16_to_cpu(readw(src + 2*i)); 109 return;
67 dest[i * 2] = BYTE0(data); 110
68 dest[i * 2 + 1] = BYTE1(data); 111 if (from & 1) {
112 *dest++ = BYTE1(flash_read16(src));
113 src++;
114 --len;
69 } 115 }
70 116
71 if (len & 1) 117 while (len >= 2) {
72 dest[len - 1] = BYTE0(le16_to_cpu(readw(src + 2*i))); 118 u16 data = flash_read16(src);
119 *dest++ = BYTE0(data);
120 *dest++ = BYTE1(data);
121 src += 2;
122 len -= 2;
123 }
124
125 if (len > 0)
126 *dest++ = BYTE0(flash_read16(src));
73} 127}
74 128
75/* 129/*
@@ -79,7 +133,7 @@ static void ixp4xx_copy_from(struct map_info *map, void *to,
79static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr) 133static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr)
80{ 134{
81 if (!(adr & 1)) 135 if (!(adr & 1))
82 writew(cpu_to_le16(d.x[0]), map->virt + adr); 136 flash_write16(d.x[0], map->virt + adr);
83} 137}
84 138
85/* 139/*
@@ -87,7 +141,7 @@ static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long
87 */ 141 */
88static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr) 142static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr)
89{ 143{
90 writew(cpu_to_le16(d.x[0]), map->virt + adr); 144 flash_write16(d.x[0], map->virt + adr);
91} 145}
92 146
93struct ixp4xx_flash_info { 147struct ixp4xx_flash_info {
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
index f00ee7e54dba..632eb2aa968f 100644
--- a/drivers/mtd/maps/nettel.c
+++ b/drivers/mtd/maps/nettel.c
@@ -6,7 +6,7 @@
6 * (C) Copyright 2000-2001, Greg Ungerer (gerg@snapgear.com) 6 * (C) Copyright 2000-2001, Greg Ungerer (gerg@snapgear.com)
7 * (C) Copyright 2001-2002, SnapGear (www.snapgear.com) 7 * (C) Copyright 2001-2002, SnapGear (www.snapgear.com)
8 * 8 *
9 * $Id: nettel.c,v 1.11 2005/11/07 11:14:27 gleixner Exp $ 9 * $Id: nettel.c,v 1.12 2005/11/29 14:30:00 gleixner Exp $
10 */ 10 */
11 11
12/****************************************************************************/ 12/****************************************************************************/
@@ -479,7 +479,7 @@ void __exit nettel_cleanup(void)
479 } 479 }
480 if (nettel_intel_map.virt) { 480 if (nettel_intel_map.virt) {
481 iounmap(nettel_intel_map.virt); 481 iounmap(nettel_intel_map.virt);
482 nettel_intel_map.virt = 0; 482 nettel_intel_map.virt = NULL;
483 } 483 }
484#endif 484#endif
485} 485}
diff --git a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c
index 8b3570b09095..21822c2edbe4 100644
--- a/drivers/mtd/maps/pci.c
+++ b/drivers/mtd/maps/pci.c
@@ -7,7 +7,7 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * $Id: pci.c,v 1.13 2005/11/07 11:14:27 gleixner Exp $ 10 * $Id: pci.c,v 1.14 2005/11/17 08:20:27 dwmw2 Exp $
11 * 11 *
12 * Generic PCI memory map driver. We support the following boards: 12 * Generic PCI memory map driver. We support the following boards:
13 * - Intel IQ80310 ATU. 13 * - Intel IQ80310 ATU.
@@ -102,7 +102,7 @@ static void mtd_pci_copyto(struct map_info *_map, unsigned long to, const void *
102 memcpy_toio(map->base + map->translate(map, to), from, len); 102 memcpy_toio(map->base + map->translate(map, to), from, len);
103} 103}
104 104
105static struct map_info mtd_pci_map = { 105static const struct map_info mtd_pci_map = {
106 .phys = NO_XIP, 106 .phys = NO_XIP,
107 .copy_from = mtd_pci_copyfrom, 107 .copy_from = mtd_pci_copyfrom,
108 .copy_to = mtd_pci_copyto, 108 .copy_to = mtd_pci_copyto,
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 9ee760f97bc6..f49ebc3c4606 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: physmap.c,v 1.38 2005/11/07 11:14:28 gleixner Exp $ 2 * $Id: physmap.c,v 1.39 2005/11/29 14:49:36 gleixner Exp $
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * 5 *
@@ -19,6 +19,7 @@
19#include <linux/mtd/map.h> 19#include <linux/mtd/map.h>
20#include <linux/config.h> 20#include <linux/config.h>
21#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
22#include <linux/mtd/physmap.h>
22 23
23static struct mtd_info *mymtd; 24static struct mtd_info *mymtd;
24 25
diff --git a/drivers/mtd/maps/sc520cdp.c b/drivers/mtd/maps/sc520cdp.c
index 6fb9f3c57aab..ed92afadd8a9 100644
--- a/drivers/mtd/maps/sc520cdp.c
+++ b/drivers/mtd/maps/sc520cdp.c
@@ -16,7 +16,7 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 * 18 *
19 * $Id: sc520cdp.c,v 1.22 2005/11/07 11:14:28 gleixner Exp $ 19 * $Id: sc520cdp.c,v 1.23 2005/11/17 08:20:27 dwmw2 Exp $
20 * 20 *
21 * 21 *
22 * The SC520CDP is an evaluation board for the Elan SC520 processor available 22 * The SC520CDP is an evaluation board for the Elan SC520 processor available
@@ -164,7 +164,7 @@ struct sc520_par_table
164 unsigned long default_address; 164 unsigned long default_address;
165}; 165};
166 166
167static struct sc520_par_table par_table[NUM_FLASH_BANKS] = 167static const struct sc520_par_table par_table[NUM_FLASH_BANKS] =
168{ 168{
169 { /* Flash Bank #0: selected by ROMCS0 */ 169 { /* Flash Bank #0: selected by ROMCS0 */
170 SC520_PAR_ROMCS0, 170 SC520_PAR_ROMCS0,
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index de4500395300..a0af92cc7efd 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -1486,7 +1486,7 @@ ns_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
1486/* 1486/*
1487 * Module initialization function 1487 * Module initialization function
1488 */ 1488 */
1489int __init ns_init_module(void) 1489static int __init ns_init_module(void)
1490{ 1490{
1491 struct nand_chip *chip; 1491 struct nand_chip *chip;
1492 struct nandsim *nand; 1492 struct nandsim *nand;
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index 0ab8d29caeea..20ce212638fc 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -30,11 +30,9 @@ MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit s
30 30
31#define PREFIX "rfd_ftl: " 31#define PREFIX "rfd_ftl: "
32 32
33/* Major device # for FTL device */ 33/* This major has been assigned by device@lanana.org */
34
35/* A request for this major has been sent to device@lanana.org */
36#ifndef RFD_FTL_MAJOR 34#ifndef RFD_FTL_MAJOR
37#define RFD_FTL_MAJOR 95 35#define RFD_FTL_MAJOR 256
38#endif 36#endif
39 37
40/* Maximum number of partitions in an FTL region */ 38/* Maximum number of partitions in an FTL region */
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index c53848f787eb..7aa49b974dc5 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -28,8 +28,8 @@
28 28
29#define DRV_MODULE_NAME "b44" 29#define DRV_MODULE_NAME "b44"
30#define PFX DRV_MODULE_NAME ": " 30#define PFX DRV_MODULE_NAME ": "
31#define DRV_MODULE_VERSION "0.96" 31#define DRV_MODULE_VERSION "0.97"
32#define DRV_MODULE_RELDATE "Nov 8, 2005" 32#define DRV_MODULE_RELDATE "Nov 30, 2005"
33 33
34#define B44_DEF_MSG_ENABLE \ 34#define B44_DEF_MSG_ENABLE \
35 (NETIF_MSG_DRV | \ 35 (NETIF_MSG_DRV | \
@@ -1417,6 +1417,7 @@ static int b44_open(struct net_device *dev)
1417 add_timer(&bp->timer); 1417 add_timer(&bp->timer);
1418 1418
1419 b44_enable_ints(bp); 1419 b44_enable_ints(bp);
1420 netif_start_queue(dev);
1420out: 1421out:
1421 return err; 1422 return err;
1422} 1423}
@@ -1837,12 +1838,15 @@ static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1837{ 1838{
1838 struct mii_ioctl_data *data = if_mii(ifr); 1839 struct mii_ioctl_data *data = if_mii(ifr);
1839 struct b44 *bp = netdev_priv(dev); 1840 struct b44 *bp = netdev_priv(dev);
1840 int err; 1841 int err = -EINVAL;
1842
1843 if (!netif_running(dev))
1844 goto out;
1841 1845
1842 spin_lock_irq(&bp->lock); 1846 spin_lock_irq(&bp->lock);
1843 err = generic_mii_ioctl(&bp->mii_if, data, cmd, NULL); 1847 err = generic_mii_ioctl(&bp->mii_if, data, cmd, NULL);
1844 spin_unlock_irq(&bp->lock); 1848 spin_unlock_irq(&bp->lock);
1845 1849out:
1846 return err; 1850 return err;
1847} 1851}
1848 1852
@@ -2113,6 +2117,7 @@ static int b44_resume(struct pci_dev *pdev)
2113 add_timer(&bp->timer); 2117 add_timer(&bp->timer);
2114 2118
2115 b44_enable_ints(bp); 2119 b44_enable_ints(bp);
2120 netif_wake_queue(dev);
2116 return 0; 2121 return 0;
2117} 2122}
2118 2123
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 8b207f0e139e..e0ae248b4313 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2621,19 +2621,7 @@ e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
2621 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) ) 2621 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
2622 return 0; 2622 return 0;
2623 } 2623 }
2624 if(htons(ETH_P_IP) == skb->protocol) { 2624 if ((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
2625 const struct iphdr *ip = skb->nh.iph;
2626 if(IPPROTO_UDP == ip->protocol) {
2627 struct udphdr *udp = (struct udphdr *)(skb->h.uh);
2628 if(ntohs(udp->dest) == 67) {
2629 offset = (uint8_t *)udp + 8 - skb->data;
2630 length = skb->len - offset;
2631
2632 return e1000_mng_write_dhcp_info(hw,
2633 (uint8_t *)udp + 8, length);
2634 }
2635 }
2636 } else if((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
2637 struct ethhdr *eth = (struct ethhdr *) skb->data; 2625 struct ethhdr *eth = (struct ethhdr *) skb->data;
2638 if((htons(ETH_P_IP) == eth->h_proto)) { 2626 if((htons(ETH_P_IP) == eth->h_proto)) {
2639 const struct iphdr *ip = 2627 const struct iphdr *ip =
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index eb7d69478715..1da8a66f91e1 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -65,7 +65,7 @@
65 */ 65 */
66 66
67#define DRV_NAME "emac" 67#define DRV_NAME "emac"
68#define DRV_VERSION "3.53" 68#define DRV_VERSION "3.54"
69#define DRV_DESC "PPC 4xx OCP EMAC driver" 69#define DRV_DESC "PPC 4xx OCP EMAC driver"
70 70
71MODULE_DESCRIPTION(DRV_DESC); 71MODULE_DESCRIPTION(DRV_DESC);
@@ -158,6 +158,14 @@ static inline void emac_report_timeout_error(struct ocp_enet_private *dev,
158#define PHY_POLL_LINK_ON HZ 158#define PHY_POLL_LINK_ON HZ
159#define PHY_POLL_LINK_OFF (HZ / 5) 159#define PHY_POLL_LINK_OFF (HZ / 5)
160 160
161/* Graceful stop timeouts in us.
162 * We should allow up to 1 frame time (full-duplex, ignoring collisions)
163 */
164#define STOP_TIMEOUT_10 1230
165#define STOP_TIMEOUT_100 124
166#define STOP_TIMEOUT_1000 13
167#define STOP_TIMEOUT_1000_JUMBO 73
168
161/* Please, keep in sync with struct ibm_emac_stats/ibm_emac_error_stats */ 169/* Please, keep in sync with struct ibm_emac_stats/ibm_emac_error_stats */
162static const char emac_stats_keys[EMAC_ETHTOOL_STATS_COUNT][ETH_GSTRING_LEN] = { 170static const char emac_stats_keys[EMAC_ETHTOOL_STATS_COUNT][ETH_GSTRING_LEN] = {
163 "rx_packets", "rx_bytes", "tx_packets", "tx_bytes", "rx_packets_csum", 171 "rx_packets", "rx_bytes", "tx_packets", "tx_bytes", "rx_packets_csum",
@@ -222,10 +230,12 @@ static void emac_tx_disable(struct ocp_enet_private *dev)
222 230
223 r = in_be32(&p->mr0); 231 r = in_be32(&p->mr0);
224 if (r & EMAC_MR0_TXE) { 232 if (r & EMAC_MR0_TXE) {
225 int n = 300; 233 int n = dev->stop_timeout;
226 out_be32(&p->mr0, r & ~EMAC_MR0_TXE); 234 out_be32(&p->mr0, r & ~EMAC_MR0_TXE);
227 while (!(in_be32(&p->mr0) & EMAC_MR0_TXI) && n) 235 while (!(in_be32(&p->mr0) & EMAC_MR0_TXI) && n) {
236 udelay(1);
228 --n; 237 --n;
238 }
229 if (unlikely(!n)) 239 if (unlikely(!n))
230 emac_report_timeout_error(dev, "TX disable timeout"); 240 emac_report_timeout_error(dev, "TX disable timeout");
231 } 241 }
@@ -248,9 +258,11 @@ static void emac_rx_enable(struct ocp_enet_private *dev)
248 if (!(r & EMAC_MR0_RXE)) { 258 if (!(r & EMAC_MR0_RXE)) {
249 if (unlikely(!(r & EMAC_MR0_RXI))) { 259 if (unlikely(!(r & EMAC_MR0_RXI))) {
250 /* Wait if previous async disable is still in progress */ 260 /* Wait if previous async disable is still in progress */
251 int n = 100; 261 int n = dev->stop_timeout;
252 while (!(r = in_be32(&p->mr0) & EMAC_MR0_RXI) && n) 262 while (!(r = in_be32(&p->mr0) & EMAC_MR0_RXI) && n) {
263 udelay(1);
253 --n; 264 --n;
265 }
254 if (unlikely(!n)) 266 if (unlikely(!n))
255 emac_report_timeout_error(dev, 267 emac_report_timeout_error(dev,
256 "RX disable timeout"); 268 "RX disable timeout");
@@ -273,10 +285,12 @@ static void emac_rx_disable(struct ocp_enet_private *dev)
273 285
274 r = in_be32(&p->mr0); 286 r = in_be32(&p->mr0);
275 if (r & EMAC_MR0_RXE) { 287 if (r & EMAC_MR0_RXE) {
276 int n = 300; 288 int n = dev->stop_timeout;
277 out_be32(&p->mr0, r & ~EMAC_MR0_RXE); 289 out_be32(&p->mr0, r & ~EMAC_MR0_RXE);
278 while (!(in_be32(&p->mr0) & EMAC_MR0_RXI) && n) 290 while (!(in_be32(&p->mr0) & EMAC_MR0_RXI) && n) {
291 udelay(1);
279 --n; 292 --n;
293 }
280 if (unlikely(!n)) 294 if (unlikely(!n))
281 emac_report_timeout_error(dev, "RX disable timeout"); 295 emac_report_timeout_error(dev, "RX disable timeout");
282 } 296 }
@@ -395,6 +409,7 @@ static int emac_configure(struct ocp_enet_private *dev)
395 r = EMAC_MR1_BASE(emac_opb_mhz()) | EMAC_MR1_VLE | EMAC_MR1_IST; 409 r = EMAC_MR1_BASE(emac_opb_mhz()) | EMAC_MR1_VLE | EMAC_MR1_IST;
396 if (dev->phy.duplex == DUPLEX_FULL) 410 if (dev->phy.duplex == DUPLEX_FULL)
397 r |= EMAC_MR1_FDE; 411 r |= EMAC_MR1_FDE;
412 dev->stop_timeout = STOP_TIMEOUT_10;
398 switch (dev->phy.speed) { 413 switch (dev->phy.speed) {
399 case SPEED_1000: 414 case SPEED_1000:
400 if (emac_phy_gpcs(dev->phy.mode)) { 415 if (emac_phy_gpcs(dev->phy.mode)) {
@@ -409,12 +424,16 @@ static int emac_configure(struct ocp_enet_private *dev)
409 r |= EMAC_MR1_MF_1000; 424 r |= EMAC_MR1_MF_1000;
410 r |= EMAC_MR1_RFS_16K; 425 r |= EMAC_MR1_RFS_16K;
411 gige = 1; 426 gige = 1;
412 427
413 if (dev->ndev->mtu > ETH_DATA_LEN) 428 if (dev->ndev->mtu > ETH_DATA_LEN) {
414 r |= EMAC_MR1_JPSM; 429 r |= EMAC_MR1_JPSM;
430 dev->stop_timeout = STOP_TIMEOUT_1000_JUMBO;
431 } else
432 dev->stop_timeout = STOP_TIMEOUT_1000;
415 break; 433 break;
416 case SPEED_100: 434 case SPEED_100:
417 r |= EMAC_MR1_MF_100; 435 r |= EMAC_MR1_MF_100;
436 dev->stop_timeout = STOP_TIMEOUT_100;
418 /* Fall through */ 437 /* Fall through */
419 default: 438 default:
420 r |= EMAC_MR1_RFS_4K; 439 r |= EMAC_MR1_RFS_4K;
@@ -2048,6 +2067,7 @@ static int __init emac_probe(struct ocp_device *ocpdev)
2048 dev->phy.duplex = DUPLEX_FULL; 2067 dev->phy.duplex = DUPLEX_FULL;
2049 dev->phy.autoneg = AUTONEG_DISABLE; 2068 dev->phy.autoneg = AUTONEG_DISABLE;
2050 dev->phy.pause = dev->phy.asym_pause = 0; 2069 dev->phy.pause = dev->phy.asym_pause = 0;
2070 dev->stop_timeout = STOP_TIMEOUT_100;
2051 init_timer(&dev->link_timer); 2071 init_timer(&dev->link_timer);
2052 dev->link_timer.function = emac_link_timer; 2072 dev->link_timer.function = emac_link_timer;
2053 dev->link_timer.data = (unsigned long)dev; 2073 dev->link_timer.data = (unsigned long)dev;
diff --git a/drivers/net/ibm_emac/ibm_emac_core.h b/drivers/net/ibm_emac/ibm_emac_core.h
index e9b44d030ac3..911abbaf471b 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.h
+++ b/drivers/net/ibm_emac/ibm_emac_core.h
@@ -189,6 +189,8 @@ struct ocp_enet_private {
189 struct timer_list link_timer; 189 struct timer_list link_timer;
190 int reset_failed; 190 int reset_failed;
191 191
192 int stop_timeout; /* in us */
193
192 struct ibm_emac_error_stats estats; 194 struct ibm_emac_error_stats estats;
193 struct net_device_stats nstats; 195 struct net_device_stats nstats;
194 196
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index b039bd89ceb9..272d331d29cd 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -296,7 +296,7 @@ static int __init jazz_sonic_init_module(void)
296 } 296 }
297 297
298 jazz_sonic_device = platform_device_alloc(jazz_sonic_string, 0); 298 jazz_sonic_device = platform_device_alloc(jazz_sonic_string, 0);
299 if (!jazz_sonnic_device) 299 if (!jazz_sonic_device)
300 goto out_unregister; 300 goto out_unregister;
301 301
302 if (platform_device_add(jazz_sonic_device)) { 302 if (platform_device_add(jazz_sonic_device)) {
@@ -307,7 +307,7 @@ static int __init jazz_sonic_init_module(void)
307 return 0; 307 return 0;
308 308
309out_unregister: 309out_unregister:
310 driver_unregister(&jazz_sonic_driver); 310 platform_driver_unregister(&jazz_sonic_driver);
311 311
312 return -ENOMEM; 312 return -ENOMEM;
313} 313}
diff --git a/drivers/net/mipsnet.h b/drivers/net/mipsnet.h
index 878535953cb1..026c732024c9 100644
--- a/drivers/net/mipsnet.h
+++ b/drivers/net/mipsnet.h
@@ -1,28 +1,8 @@
1// 1/*
2// <COPYRIGHT CLASS="1B" YEAR="2005"> 2 * This file is subject to the terms and conditions of the GNU General Public
3// Unpublished work (c) MIPS Technologies, Inc. All rights reserved. 3 * License. See the file "COPYING" in the main directory of this archive
4// Unpublished rights reserved under the copyright laws of the U.S.A. and 4 * for more details.
5// other countries. 5 */
6//
7// PROPRIETARY / SECRET CONFIDENTIAL INFORMATION OF MIPS TECHNOLOGIES, INC.
8// FOR INTERNAL USE ONLY.
9//
10// Under no circumstances (contract or otherwise) may this information be
11// disclosed to, or copied, modified or used by anyone other than employees
12// or contractors of MIPS Technologies having a need to know.
13// </COPYRIGHT>
14//
15//++
16// File: MIPS_Net.h
17//
18// Description:
19// The definition of the emulated MIPSNET device's interface.
20//
21// Notes: This include file needs to work from a Linux device drivers.
22//
23//--
24//
25
26#ifndef __MIPSNET_H 6#ifndef __MIPSNET_H
27#define __MIPSNET_H 7#define __MIPSNET_H
28 8
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 384a736a0d2f..356f50909222 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -131,10 +131,9 @@ typedef struct local_info_t {
131 u_short tx_queue_len; 131 u_short tx_queue_len;
132 cardtype_t cardtype; 132 cardtype_t cardtype;
133 u_short sent; 133 u_short sent;
134 u_char mc_filter[8];
135} local_info_t; 134} local_info_t;
136 135
137#define MC_FILTERBREAK 8 136#define MC_FILTERBREAK 64
138 137
139/*====================================================================*/ 138/*====================================================================*/
140/* 139/*
@@ -1005,15 +1004,8 @@ static void fjn_reset(struct net_device *dev)
1005 for (i = 0; i < 6; i++) 1004 for (i = 0; i < 6; i++)
1006 outb(dev->dev_addr[i], ioaddr + NODE_ID + i); 1005 outb(dev->dev_addr[i], ioaddr + NODE_ID + i);
1007 1006
1008 /* Switch to bank 1 */ 1007 /* (re)initialize the multicast table */
1009 if (lp->cardtype == MBH10302) 1008 set_rx_mode(dev);
1010 outb(BANK_1, ioaddr + CONFIG_1);
1011 else
1012 outb(BANK_1U, ioaddr + CONFIG_1);
1013
1014 /* set the multicast table to accept none. */
1015 for (i = 0; i < 8; i++)
1016 outb(0x00, ioaddr + MAR_ADR + i);
1017 1009
1018 /* Switch to bank 2 (runtime mode) */ 1010 /* Switch to bank 2 (runtime mode) */
1019 if (lp->cardtype == MBH10302) 1011 if (lp->cardtype == MBH10302)
@@ -1264,11 +1256,11 @@ static struct net_device_stats *fjn_get_stats(struct net_device *dev)
1264static void set_rx_mode(struct net_device *dev) 1256static void set_rx_mode(struct net_device *dev)
1265{ 1257{
1266 kio_addr_t ioaddr = dev->base_addr; 1258 kio_addr_t ioaddr = dev->base_addr;
1267 struct local_info_t *lp = netdev_priv(dev);
1268 u_char mc_filter[8]; /* Multicast hash filter */ 1259 u_char mc_filter[8]; /* Multicast hash filter */
1269 u_long flags; 1260 u_long flags;
1270 int i; 1261 int i;
1271 1262
1263 int saved_bank;
1272 int saved_config_0 = inb(ioaddr + CONFIG_0); 1264 int saved_config_0 = inb(ioaddr + CONFIG_0);
1273 1265
1274 local_irq_save(flags); 1266 local_irq_save(flags);
@@ -1306,15 +1298,13 @@ static void set_rx_mode(struct net_device *dev)
1306 outb(2, ioaddr + RX_MODE); /* Use normal mode. */ 1298 outb(2, ioaddr + RX_MODE); /* Use normal mode. */
1307 } 1299 }
1308 1300
1309 if (memcmp(mc_filter, lp->mc_filter, sizeof(mc_filter))) { 1301 /* Switch to bank 1 and set the multicast table. */
1310 int saved_bank = inb(ioaddr + CONFIG_1); 1302 saved_bank = inb(ioaddr + CONFIG_1);
1311 /* Switch to bank 1 and set the multicast table. */ 1303 outb(0xe4, ioaddr + CONFIG_1);
1312 outb(0xe4, ioaddr + CONFIG_1); 1304
1313 for (i = 0; i < 8; i++) 1305 for (i = 0; i < 8; i++)
1314 outb(mc_filter[i], ioaddr + MAR_ADR + i); 1306 outb(mc_filter[i], ioaddr + MAR_ADR + i);
1315 memcpy(lp->mc_filter, mc_filter, sizeof(mc_filter)); 1307 outb(saved_bank, ioaddr + CONFIG_1);
1316 outb(saved_bank, ioaddr + CONFIG_1);
1317 }
1318 1308
1319 outb(saved_config_0, ioaddr + CONFIG_0); 1309 outb(saved_config_0, ioaddr + CONFIG_0);
1320 1310
diff --git a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile
index 6783039ffb75..7653d6e33aa2 100644
--- a/drivers/net/sk98lin/Makefile
+++ b/drivers/net/sk98lin/Makefile
@@ -27,8 +27,7 @@ sk98lin-objs := \
27 sktimer.o \ 27 sktimer.o \
28 skvpd.o \ 28 skvpd.o \
29 skxmac2.o \ 29 skxmac2.o \
30 skproc.o \ 30 skproc.o
31 skcsum.o
32 31
33# DBGDEF = \ 32# DBGDEF = \
34# -DDEBUG 33# -DDEBUG
@@ -77,7 +76,7 @@ endif
77# SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources 76# SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources
78# SK_DBGCAT_DRV_EVENT 0x08000000 driver events 77# SK_DBGCAT_DRV_EVENT 0x08000000 driver events
79 78
80EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DSK_USE_CSUM -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM) 79EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM)
81 80
82clean: 81clean:
83 rm -f core *.o *.a *.s 82 rm -f core *.o *.a *.s
diff --git a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
index 542cec57f86a..2dc5728e3ef6 100644
--- a/drivers/net/sk98lin/h/skdrv2nd.h
+++ b/drivers/net/sk98lin/h/skdrv2nd.h
@@ -425,10 +425,6 @@ struct s_AC {
425 TX_PORT TxPort[SK_MAX_MACS][2]; 425 TX_PORT TxPort[SK_MAX_MACS][2];
426 RX_PORT RxPort[SK_MAX_MACS]; 426 RX_PORT RxPort[SK_MAX_MACS];
427 427
428 unsigned int CsOfs1; /* for checksum calculation */
429 unsigned int CsOfs2; /* for checksum calculation */
430 SK_U32 CsOfs; /* for checksum calculation */
431
432 SK_BOOL CheckQueue; /* check event queue soon */ 428 SK_BOOL CheckQueue; /* check event queue soon */
433 SK_TIMER DrvCleanupTimer;/* to check for pending descriptors */ 429 SK_TIMER DrvCleanupTimer;/* to check for pending descriptors */
434 DIM_INFO DynIrqModInfo; /* all data related to DIM */ 430 DIM_INFO DynIrqModInfo; /* all data related to DIM */
diff --git a/drivers/net/sk98lin/skcsum.c b/drivers/net/sk98lin/skcsum.c
deleted file mode 100644
index 38a6e7a631f3..000000000000
--- a/drivers/net/sk98lin/skcsum.c
+++ /dev/null
@@ -1,871 +0,0 @@
1/******************************************************************************
2 *
3 * Name: skcsum.c
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.12 $
6 * Date: $Date: 2003/08/20 13:55:53 $
7 * Purpose: Store/verify Internet checksum in send/receive packets.
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 * (C)Copyright 1998-2003 SysKonnect GmbH.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * The information in this file is provided "AS IS" without warranty.
21 *
22 ******************************************************************************/
23
24#ifdef SK_USE_CSUM /* Check if CSUM is to be used. */
25
26#ifndef lint
27static const char SysKonnectFileId[] =
28 "@(#) $Id: skcsum.c,v 1.12 2003/08/20 13:55:53 mschmid Exp $ (C) SysKonnect.";
29#endif /* !lint */
30
31/******************************************************************************
32 *
33 * Description:
34 *
35 * This is the "GEnesis" common module "CSUM".
36 *
37 * This module contains the code necessary to calculate, store, and verify the
38 * Internet Checksum of IP, TCP, and UDP frames.
39 *
40 * "GEnesis" is an abbreviation of "Gigabit Ethernet Network System in Silicon"
41 * and is the code name of this SysKonnect project.
42 *
43 * Compilation Options:
44 *
45 * SK_USE_CSUM - Define if CSUM is to be used. Otherwise, CSUM will be an
46 * empty module.
47 *
48 * SKCS_OVERWRITE_PROTO - Define to overwrite the default protocol id
49 * definitions. In this case, all SKCS_PROTO_xxx definitions must be made
50 * external.
51 *
52 * SKCS_OVERWRITE_STATUS - Define to overwrite the default return status
53 * definitions. In this case, all SKCS_STATUS_xxx definitions must be made
54 * external.
55 *
56 * Include File Hierarchy:
57 *
58 * "h/skdrv1st.h"
59 * "h/skcsum.h"
60 * "h/sktypes.h"
61 * "h/skqueue.h"
62 * "h/skdrv2nd.h"
63 *
64 ******************************************************************************/
65
66#include "h/skdrv1st.h"
67#include "h/skcsum.h"
68#include "h/skdrv2nd.h"
69
70/* defines ********************************************************************/
71
72/* The size of an Ethernet MAC header. */
73#define SKCS_ETHERNET_MAC_HEADER_SIZE (6+6+2)
74
75/* The size of the used topology's MAC header. */
76#define SKCS_MAC_HEADER_SIZE SKCS_ETHERNET_MAC_HEADER_SIZE
77
78/* The size of the IP header without any option fields. */
79#define SKCS_IP_HEADER_SIZE 20
80
81/*
82 * Field offsets within the IP header.
83 */
84
85/* "Internet Header Version" and "Length". */
86#define SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH 0
87
88/* "Total Length". */
89#define SKCS_OFS_IP_TOTAL_LENGTH 2
90
91/* "Flags" "Fragment Offset". */
92#define SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET 6
93
94/* "Next Level Protocol" identifier. */
95#define SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL 9
96
97/* Source IP address. */
98#define SKCS_OFS_IP_SOURCE_ADDRESS 12
99
100/* Destination IP address. */
101#define SKCS_OFS_IP_DESTINATION_ADDRESS 16
102
103
104/*
105 * Field offsets within the UDP header.
106 */
107
108/* UDP checksum. */
109#define SKCS_OFS_UDP_CHECKSUM 6
110
111/* IP "Next Level Protocol" identifiers (see RFC 790). */
112#define SKCS_PROTO_ID_TCP 6 /* Transport Control Protocol */
113#define SKCS_PROTO_ID_UDP 17 /* User Datagram Protocol */
114
115/* IP "Don't Fragment" bit. */
116#define SKCS_IP_DONT_FRAGMENT SKCS_HTON16(0x4000)
117
118/* Add a byte offset to a pointer. */
119#define SKCS_IDX(pPtr, Ofs) ((void *) ((char *) (pPtr) + (Ofs)))
120
121/*
122 * Macros that convert host to network representation and vice versa, i.e.
123 * little/big endian conversion on little endian machines only.
124 */
125#ifdef SK_LITTLE_ENDIAN
126#define SKCS_HTON16(Val16) (((unsigned) (Val16) >> 8) | (((Val16) & 0xff) << 8))
127#endif /* SK_LITTLE_ENDIAN */
128#ifdef SK_BIG_ENDIAN
129#define SKCS_HTON16(Val16) (Val16)
130#endif /* SK_BIG_ENDIAN */
131#define SKCS_NTOH16(Val16) SKCS_HTON16(Val16)
132
133/* typedefs *******************************************************************/
134
135/* function prototypes ********************************************************/
136
137/******************************************************************************
138 *
139 * SkCsGetSendInfo - get checksum information for a send packet
140 *
141 * Description:
142 * Get all checksum information necessary to send a TCP or UDP packet. The
143 * function checks the IP header passed to it. If the high-level protocol
144 * is either TCP or UDP the pseudo header checksum is calculated and
145 * returned.
146 *
147 * The function returns the total length of the IP header (including any
148 * IP option fields), which is the same as the start offset of the IP data
149 * which in turn is the start offset of the TCP or UDP header.
150 *
151 * The function also returns the TCP or UDP pseudo header checksum, which
152 * should be used as the start value for the hardware checksum calculation.
153 * (Note that any actual pseudo header checksum can never calculate to
154 * zero.)
155 *
156 * Note:
157 * There is a bug in the GENESIS ASIC which may lead to wrong checksums.
158 *
159 * Arguments:
160 * pAc - A pointer to the adapter context struct.
161 *
162 * pIpHeader - Pointer to IP header. Must be at least the IP header *not*
163 * including any option fields, i.e. at least 20 bytes.
164 *
165 * Note: This pointer will be used to address 8-, 16-, and 32-bit
166 * variables with the respective alignment offsets relative to the pointer.
167 * Thus, the pointer should point to a 32-bit aligned address. If the
168 * target system cannot address 32-bit variables on non 32-bit aligned
169 * addresses, then the pointer *must* point to a 32-bit aligned address.
170 *
171 * pPacketInfo - A pointer to the packet information structure for this
172 * packet. Before calling this SkCsGetSendInfo(), the following field must
173 * be initialized:
174 *
175 * ProtocolFlags - Initialize with any combination of
176 * SKCS_PROTO_XXX bit flags. SkCsGetSendInfo() will only work on
177 * the protocols specified here. Any protocol(s) not specified
178 * here will be ignored.
179 *
180 * Note: Only one checksum can be calculated in hardware. Thus, if
181 * SKCS_PROTO_IP is specified in the 'ProtocolFlags',
182 * SkCsGetSendInfo() must calculate the IP header checksum in
183 * software. It might be a better idea to have the calling
184 * protocol stack calculate the IP header checksum.
185 *
186 * Returns: N/A
187 * On return, the following fields in 'pPacketInfo' may or may not have
188 * been filled with information, depending on the protocol(s) found in the
189 * packet:
190 *
191 * ProtocolFlags - Returns the SKCS_PROTO_XXX bit flags of the protocol(s)
192 * that were both requested by the caller and actually found in the packet.
193 * Protocol(s) not specified by the caller and/or not found in the packet
194 * will have their respective SKCS_PROTO_XXX bit flags reset.
195 *
196 * Note: For IP fragments, TCP and UDP packet information is ignored.
197 *
198 * IpHeaderLength - The total length in bytes of the complete IP header
199 * including any option fields is returned here. This is the start offset
200 * of the IP data, i.e. the TCP or UDP header if present.
201 *
202 * IpHeaderChecksum - If IP has been specified in the 'ProtocolFlags', the
203 * 16-bit Internet Checksum of the IP header is returned here. This value
204 * is to be stored into the packet's 'IP Header Checksum' field.
205 *
206 * PseudoHeaderChecksum - If this is a TCP or UDP packet and if TCP or UDP
207 * has been specified in the 'ProtocolFlags', the 16-bit Internet Checksum
208 * of the TCP or UDP pseudo header is returned here.
209 */
210void SkCsGetSendInfo(
211SK_AC *pAc, /* Adapter context struct. */
212void *pIpHeader, /* IP header. */
213SKCS_PACKET_INFO *pPacketInfo, /* Packet information struct. */
214int NetNumber) /* Net number */
215{
216 /* Internet Header Version found in IP header. */
217 unsigned InternetHeaderVersion;
218
219 /* Length of the IP header as found in IP header. */
220 unsigned IpHeaderLength;
221
222 /* Bit field specifiying the desired/found protocols. */
223 unsigned ProtocolFlags;
224
225 /* Next level protocol identifier found in IP header. */
226 unsigned NextLevelProtocol;
227
228 /* Length of IP data portion. */
229 unsigned IpDataLength;
230
231 /* TCP/UDP pseudo header checksum. */
232 unsigned long PseudoHeaderChecksum;
233
234 /* Pointer to next level protocol statistics structure. */
235 SKCS_PROTO_STATS *NextLevelProtoStats;
236
237 /* Temporary variable. */
238 unsigned Tmp;
239
240 Tmp = *(SK_U8 *)
241 SKCS_IDX(pIpHeader, SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH);
242
243 /* Get the Internet Header Version (IHV). */
244 /* Note: The IHV is stored in the upper four bits. */
245
246 InternetHeaderVersion = Tmp >> 4;
247
248 /* Check the Internet Header Version. */
249 /* Note: We currently only support IP version 4. */
250
251 if (InternetHeaderVersion != 4) { /* IPv4? */
252 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_TX,
253 ("Tx: Unknown Internet Header Version %u.\n",
254 InternetHeaderVersion));
255 pPacketInfo->ProtocolFlags = 0;
256 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
257 return;
258 }
259
260 /* Get the IP header length (IHL). */
261 /*
262 * Note: The IHL is stored in the lower four bits as the number of
263 * 4-byte words.
264 */
265
266 IpHeaderLength = (Tmp & 0xf) * 4;
267 pPacketInfo->IpHeaderLength = IpHeaderLength;
268
269 /* Check the IP header length. */
270
271 /* 04-Aug-1998 sw - Really check the IHL? Necessary? */
272
273 if (IpHeaderLength < 5*4) {
274 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_TX,
275 ("Tx: Invalid IP Header Length %u.\n", IpHeaderLength));
276 pPacketInfo->ProtocolFlags = 0;
277 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
278 return;
279 }
280
281 /* This is an IPv4 frame with a header of valid length. */
282
283 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxOkCts++;
284
285 /* Check if we should calculate the IP header checksum. */
286
287 ProtocolFlags = pPacketInfo->ProtocolFlags;
288
289 if (ProtocolFlags & SKCS_PROTO_IP) {
290 pPacketInfo->IpHeaderChecksum =
291 SkCsCalculateChecksum(pIpHeader, IpHeaderLength);
292 }
293
294 /* Get the next level protocol identifier. */
295
296 NextLevelProtocol =
297 *(SK_U8 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL);
298
299 /*
300 * Check if this is a TCP or UDP frame and if we should calculate the
301 * TCP/UDP pseudo header checksum.
302 *
303 * Also clear all protocol bit flags of protocols not present in the
304 * frame.
305 */
306
307 if ((ProtocolFlags & SKCS_PROTO_TCP) != 0 &&
308 NextLevelProtocol == SKCS_PROTO_ID_TCP) {
309 /* TCP/IP frame. */
310 ProtocolFlags &= SKCS_PROTO_TCP | SKCS_PROTO_IP;
311 NextLevelProtoStats =
312 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_TCP];
313 }
314 else if ((ProtocolFlags & SKCS_PROTO_UDP) != 0 &&
315 NextLevelProtocol == SKCS_PROTO_ID_UDP) {
316 /* UDP/IP frame. */
317 ProtocolFlags &= SKCS_PROTO_UDP | SKCS_PROTO_IP;
318 NextLevelProtoStats =
319 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
320 }
321 else {
322 /*
323 * Either not a TCP or UDP frame and/or TCP/UDP processing not
324 * specified.
325 */
326 pPacketInfo->ProtocolFlags = ProtocolFlags & SKCS_PROTO_IP;
327 return;
328 }
329
330 /* Check if this is an IP fragment. */
331
332 /*
333 * Note: An IP fragment has a non-zero "Fragment Offset" field and/or
334 * the "More Fragments" bit set. Thus, if both the "Fragment Offset"
335 * and the "More Fragments" are zero, it is *not* a fragment. We can
336 * easily check both at the same time since they are in the same 16-bit
337 * word.
338 */
339
340 if ((*(SK_U16 *)
341 SKCS_IDX(pIpHeader, SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET) &
342 ~SKCS_IP_DONT_FRAGMENT) != 0) {
343 /* IP fragment; ignore all other protocols. */
344 pPacketInfo->ProtocolFlags = ProtocolFlags & SKCS_PROTO_IP;
345 NextLevelProtoStats->TxUnableCts++;
346 return;
347 }
348
349 /*
350 * Calculate the TCP/UDP pseudo header checksum.
351 */
352
353 /* Get total length of IP header and data. */
354
355 IpDataLength =
356 *(SK_U16 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_TOTAL_LENGTH);
357
358 /* Get length of IP data portion. */
359
360 IpDataLength = SKCS_NTOH16(IpDataLength) - IpHeaderLength;
361
362 /* Calculate the sum of all pseudo header fields (16-bit). */
363
364 PseudoHeaderChecksum =
365 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
366 SKCS_OFS_IP_SOURCE_ADDRESS + 0) +
367 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
368 SKCS_OFS_IP_SOURCE_ADDRESS + 2) +
369 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
370 SKCS_OFS_IP_DESTINATION_ADDRESS + 0) +
371 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
372 SKCS_OFS_IP_DESTINATION_ADDRESS + 2) +
373 (unsigned long) SKCS_HTON16(NextLevelProtocol) +
374 (unsigned long) SKCS_HTON16(IpDataLength);
375
376 /* Add-in any carries. */
377
378 SKCS_OC_ADD(PseudoHeaderChecksum, PseudoHeaderChecksum, 0);
379
380 /* Add-in any new carry. */
381
382 SKCS_OC_ADD(pPacketInfo->PseudoHeaderChecksum, PseudoHeaderChecksum, 0);
383
384 pPacketInfo->ProtocolFlags = ProtocolFlags;
385 NextLevelProtoStats->TxOkCts++; /* Success. */
386} /* SkCsGetSendInfo */
387
388
389/******************************************************************************
390 *
391 * SkCsGetReceiveInfo - verify checksum information for a received packet
392 *
393 * Description:
394 * Verify a received frame's checksum. The function returns a status code
395 * reflecting the result of the verification.
396 *
397 * Note:
398 * Before calling this function you have to verify that the frame is
399 * not padded and Checksum1 and Checksum2 are bigger than 1.
400 *
401 * Arguments:
402 * pAc - Pointer to adapter context struct.
403 *
404 * pIpHeader - Pointer to IP header. Must be at least the length in bytes
405 * of the received IP header including any option fields. For UDP packets,
406 * 8 additional bytes are needed to access the UDP checksum.
407 *
408 * Note: The actual length of the IP header is stored in the lower four
409 * bits of the first octet of the IP header as the number of 4-byte words,
410 * so it must be multiplied by four to get the length in bytes. Thus, the
411 * maximum IP header length is 15 * 4 = 60 bytes.
412 *
413 * Checksum1 - The first 16-bit Internet Checksum calculated by the
414 * hardware starting at the offset returned by SkCsSetReceiveFlags().
415 *
416 * Checksum2 - The second 16-bit Internet Checksum calculated by the
417 * hardware starting at the offset returned by SkCsSetReceiveFlags().
418 *
419 * Returns:
420 * SKCS_STATUS_UNKNOWN_IP_VERSION - Not an IP v4 frame.
421 * SKCS_STATUS_IP_CSUM_ERROR - IP checksum error.
422 * SKCS_STATUS_IP_CSUM_ERROR_TCP - IP checksum error in TCP frame.
423 * SKCS_STATUS_IP_CSUM_ERROR_UDP - IP checksum error in UDP frame
424 * SKCS_STATUS_IP_FRAGMENT - IP fragment (IP checksum ok).
425 * SKCS_STATUS_IP_CSUM_OK - IP checksum ok (not a TCP or UDP frame).
426 * SKCS_STATUS_TCP_CSUM_ERROR - TCP checksum error (IP checksum ok).
427 * SKCS_STATUS_UDP_CSUM_ERROR - UDP checksum error (IP checksum ok).
428 * SKCS_STATUS_TCP_CSUM_OK - IP and TCP checksum ok.
429 * SKCS_STATUS_UDP_CSUM_OK - IP and UDP checksum ok.
430 * SKCS_STATUS_IP_CSUM_OK_NO_UDP - IP checksum OK and no UDP checksum.
431 *
432 * Note: If SKCS_OVERWRITE_STATUS is defined, the SKCS_STATUS_XXX values
433 * returned here can be defined in some header file by the module using CSUM.
434 * In this way, the calling module can assign return values for its own needs,
435 * e.g. by assigning bit flags to the individual protocols.
436 */
437SKCS_STATUS SkCsGetReceiveInfo(
438SK_AC *pAc, /* Adapter context struct. */
439void *pIpHeader, /* IP header. */
440unsigned Checksum1, /* Hardware checksum 1. */
441unsigned Checksum2, /* Hardware checksum 2. */
442int NetNumber) /* Net number */
443{
444 /* Internet Header Version found in IP header. */
445 unsigned InternetHeaderVersion;
446
447 /* Length of the IP header as found in IP header. */
448 unsigned IpHeaderLength;
449
450 /* Length of IP data portion. */
451 unsigned IpDataLength;
452
453 /* IP header checksum. */
454 unsigned IpHeaderChecksum;
455
456 /* IP header options checksum, if any. */
457 unsigned IpOptionsChecksum;
458
459 /* IP data checksum, i.e. TCP/UDP checksum. */
460 unsigned IpDataChecksum;
461
462 /* Next level protocol identifier found in IP header. */
463 unsigned NextLevelProtocol;
464
465 /* The checksum of the "next level protocol", i.e. TCP or UDP. */
466 unsigned long NextLevelProtocolChecksum;
467
468 /* Pointer to next level protocol statistics structure. */
469 SKCS_PROTO_STATS *NextLevelProtoStats;
470
471 /* Temporary variable. */
472 unsigned Tmp;
473
474 Tmp = *(SK_U8 *)
475 SKCS_IDX(pIpHeader, SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH);
476
477 /* Get the Internet Header Version (IHV). */
478 /* Note: The IHV is stored in the upper four bits. */
479
480 InternetHeaderVersion = Tmp >> 4;
481
482 /* Check the Internet Header Version. */
483 /* Note: We currently only support IP version 4. */
484
485 if (InternetHeaderVersion != 4) { /* IPv4? */
486 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_RX,
487 ("Rx: Unknown Internet Header Version %u.\n",
488 InternetHeaderVersion));
489 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxUnableCts++;
490 return (SKCS_STATUS_UNKNOWN_IP_VERSION);
491 }
492
493 /* Get the IP header length (IHL). */
494 /*
495 * Note: The IHL is stored in the lower four bits as the number of
496 * 4-byte words.
497 */
498
499 IpHeaderLength = (Tmp & 0xf) * 4;
500
501 /* Check the IP header length. */
502
503 /* 04-Aug-1998 sw - Really check the IHL? Necessary? */
504
505 if (IpHeaderLength < 5*4) {
506 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_RX,
507 ("Rx: Invalid IP Header Length %u.\n", IpHeaderLength));
508 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxErrCts++;
509 return (SKCS_STATUS_IP_CSUM_ERROR);
510 }
511
512 /* This is an IPv4 frame with a header of valid length. */
513
514 /* Get the IP header and data checksum. */
515
516 IpDataChecksum = Checksum2;
517
518 /*
519 * The IP header checksum is calculated as follows:
520 *
521 * IpHeaderChecksum = Checksum1 - Checksum2
522 */
523
524 SKCS_OC_SUB(IpHeaderChecksum, Checksum1, Checksum2);
525
526 /* Check if any IP header options. */
527
528 if (IpHeaderLength > SKCS_IP_HEADER_SIZE) {
529
530 /* Get the IP options checksum. */
531
532 IpOptionsChecksum = SkCsCalculateChecksum(
533 SKCS_IDX(pIpHeader, SKCS_IP_HEADER_SIZE),
534 IpHeaderLength - SKCS_IP_HEADER_SIZE);
535
536 /* Adjust the IP header and IP data checksums. */
537
538 SKCS_OC_ADD(IpHeaderChecksum, IpHeaderChecksum, IpOptionsChecksum);
539
540 SKCS_OC_SUB(IpDataChecksum, IpDataChecksum, IpOptionsChecksum);
541 }
542
543 /*
544 * Check if the IP header checksum is ok.
545 *
546 * NOTE: We must check the IP header checksum even if the caller just wants
547 * us to check upper-layer checksums, because we cannot do any further
548 * processing of the packet without a valid IP checksum.
549 */
550
551 /* Get the next level protocol identifier. */
552
553 NextLevelProtocol = *(SK_U8 *)
554 SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL);
555
556 if (IpHeaderChecksum != 0xffff) {
557 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxErrCts++;
558 /* the NDIS tester wants to know the upper level protocol too */
559 if (NextLevelProtocol == SKCS_PROTO_ID_TCP) {
560 return(SKCS_STATUS_IP_CSUM_ERROR_TCP);
561 }
562 else if (NextLevelProtocol == SKCS_PROTO_ID_UDP) {
563 return(SKCS_STATUS_IP_CSUM_ERROR_UDP);
564 }
565 return (SKCS_STATUS_IP_CSUM_ERROR);
566 }
567
568 /*
569 * Check if this is a TCP or UDP frame and if we should calculate the
570 * TCP/UDP pseudo header checksum.
571 *
572 * Also clear all protocol bit flags of protocols not present in the
573 * frame.
574 */
575
576 if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_TCP) != 0 &&
577 NextLevelProtocol == SKCS_PROTO_ID_TCP) {
578 /* TCP/IP frame. */
579 NextLevelProtoStats =
580 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_TCP];
581 }
582 else if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_UDP) != 0 &&
583 NextLevelProtocol == SKCS_PROTO_ID_UDP) {
584 /* UDP/IP frame. */
585 NextLevelProtoStats =
586 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
587 }
588 else {
589 /*
590 * Either not a TCP or UDP frame and/or TCP/UDP processing not
591 * specified.
592 */
593 return (SKCS_STATUS_IP_CSUM_OK);
594 }
595
596 /* Check if this is an IP fragment. */
597
598 /*
599 * Note: An IP fragment has a non-zero "Fragment Offset" field and/or
600 * the "More Fragments" bit set. Thus, if both the "Fragment Offset"
601 * and the "More Fragments" are zero, it is *not* a fragment. We can
602 * easily check both at the same time since they are in the same 16-bit
603 * word.
604 */
605
606 if ((*(SK_U16 *)
607 SKCS_IDX(pIpHeader, SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET) &
608 ~SKCS_IP_DONT_FRAGMENT) != 0) {
609 /* IP fragment; ignore all other protocols. */
610 NextLevelProtoStats->RxUnableCts++;
611 return (SKCS_STATUS_IP_FRAGMENT);
612 }
613
614 /*
615 * 08-May-2000 ra
616 *
617 * From RFC 768 (UDP)
618 * If the computed checksum is zero, it is transmitted as all ones (the
619 * equivalent in one's complement arithmetic). An all zero transmitted
620 * checksum value means that the transmitter generated no checksum (for
621 * debugging or for higher level protocols that don't care).
622 */
623
624 if (NextLevelProtocol == SKCS_PROTO_ID_UDP &&
625 *(SK_U16*)SKCS_IDX(pIpHeader, IpHeaderLength + 6) == 0x0000) {
626
627 NextLevelProtoStats->RxOkCts++;
628
629 return (SKCS_STATUS_IP_CSUM_OK_NO_UDP);
630 }
631
632 /*
633 * Calculate the TCP/UDP checksum.
634 */
635
636 /* Get total length of IP header and data. */
637
638 IpDataLength =
639 *(SK_U16 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_TOTAL_LENGTH);
640
641 /* Get length of IP data portion. */
642
643 IpDataLength = SKCS_NTOH16(IpDataLength) - IpHeaderLength;
644
645 NextLevelProtocolChecksum =
646
647 /* Calculate the pseudo header checksum. */
648
649 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
650 SKCS_OFS_IP_SOURCE_ADDRESS + 0) +
651 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
652 SKCS_OFS_IP_SOURCE_ADDRESS + 2) +
653 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
654 SKCS_OFS_IP_DESTINATION_ADDRESS + 0) +
655 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
656 SKCS_OFS_IP_DESTINATION_ADDRESS + 2) +
657 (unsigned long) SKCS_HTON16(NextLevelProtocol) +
658 (unsigned long) SKCS_HTON16(IpDataLength) +
659
660 /* Add the TCP/UDP header checksum. */
661
662 (unsigned long) IpDataChecksum;
663
664 /* Add-in any carries. */
665
666 SKCS_OC_ADD(NextLevelProtocolChecksum, NextLevelProtocolChecksum, 0);
667
668 /* Add-in any new carry. */
669
670 SKCS_OC_ADD(NextLevelProtocolChecksum, NextLevelProtocolChecksum, 0);
671
672 /* Check if the TCP/UDP checksum is ok. */
673
674 if ((unsigned) NextLevelProtocolChecksum == 0xffff) {
675
676 /* TCP/UDP checksum ok. */
677
678 NextLevelProtoStats->RxOkCts++;
679
680 return (NextLevelProtocol == SKCS_PROTO_ID_TCP ?
681 SKCS_STATUS_TCP_CSUM_OK : SKCS_STATUS_UDP_CSUM_OK);
682 }
683
684 /* TCP/UDP checksum error. */
685
686 NextLevelProtoStats->RxErrCts++;
687
688 return (NextLevelProtocol == SKCS_PROTO_ID_TCP ?
689 SKCS_STATUS_TCP_CSUM_ERROR : SKCS_STATUS_UDP_CSUM_ERROR);
690} /* SkCsGetReceiveInfo */
691
692
693/******************************************************************************
694 *
695 * SkCsSetReceiveFlags - set checksum receive flags
696 *
697 * Description:
698 * Use this function to set the various receive flags. According to the
699 * protocol flags set by the caller, the start offsets within received
700 * packets of the two hardware checksums are returned. These offsets must
701 * be stored in all receive descriptors.
702 *
703 * Arguments:
704 * pAc - Pointer to adapter context struct.
705 *
706 * ReceiveFlags - Any combination of SK_PROTO_XXX flags of the protocols
707 * for which the caller wants checksum information on received frames.
708 *
709 * pChecksum1Offset - The start offset of the first receive descriptor
710 * hardware checksum to be calculated for received frames is returned
711 * here.
712 *
713 * pChecksum2Offset - The start offset of the second receive descriptor
714 * hardware checksum to be calculated for received frames is returned
715 * here.
716 *
717 * Returns: N/A
718 * Returns the two hardware checksum start offsets.
719 */
720void SkCsSetReceiveFlags(
721SK_AC *pAc, /* Adapter context struct. */
722unsigned ReceiveFlags, /* New receive flags. */
723unsigned *pChecksum1Offset, /* Offset for hardware checksum 1. */
724unsigned *pChecksum2Offset, /* Offset for hardware checksum 2. */
725int NetNumber)
726{
727 /* Save the receive flags. */
728
729 pAc->Csum.ReceiveFlags[NetNumber] = ReceiveFlags;
730
731 /* First checksum start offset is the IP header. */
732 *pChecksum1Offset = SKCS_MAC_HEADER_SIZE;
733
734 /*
735 * Second checksum start offset is the IP data. Note that this may vary
736 * if there are any IP header options in the actual packet.
737 */
738 *pChecksum2Offset = SKCS_MAC_HEADER_SIZE + SKCS_IP_HEADER_SIZE;
739} /* SkCsSetReceiveFlags */
740
741#ifndef SK_CS_CALCULATE_CHECKSUM
742
743/******************************************************************************
744 *
745 * SkCsCalculateChecksum - calculate checksum for specified data
746 *
747 * Description:
748 * Calculate and return the 16-bit Internet Checksum for the specified
749 * data.
750 *
751 * Arguments:
752 * pData - Pointer to data for which the checksum shall be calculated.
753 * Note: The pointer should be aligned on a 16-bit boundary.
754 *
755 * Length - Length in bytes of data to checksum.
756 *
757 * Returns:
758 * The 16-bit Internet Checksum for the specified data.
759 *
760 * Note: The checksum is calculated in the machine's natural byte order,
761 * i.e. little vs. big endian. Thus, the resulting checksum is different
762 * for the same input data on little and big endian machines.
763 *
764 * However, when written back to the network packet, the byte order is
765 * always in correct network order.
766 */
767unsigned SkCsCalculateChecksum(
768void *pData, /* Data to checksum. */
769unsigned Length) /* Length of data. */
770{
771 SK_U16 *pU16; /* Pointer to the data as 16-bit words. */
772 unsigned long Checksum; /* Checksum; must be at least 32 bits. */
773
774 /* Sum up all 16-bit words. */
775
776 pU16 = (SK_U16 *) pData;
777 for (Checksum = 0; Length > 1; Length -= 2) {
778 Checksum += *pU16++;
779 }
780
781 /* If this is an odd number of bytes, add-in the last byte. */
782
783 if (Length > 0) {
784#ifdef SK_BIG_ENDIAN
785 /* Add the last byte as the high byte. */
786 Checksum += ((unsigned) *(SK_U8 *) pU16) << 8;
787#else /* !SK_BIG_ENDIAN */
788 /* Add the last byte as the low byte. */
789 Checksum += *(SK_U8 *) pU16;
790#endif /* !SK_BIG_ENDIAN */
791 }
792
793 /* Add-in any carries. */
794
795 SKCS_OC_ADD(Checksum, Checksum, 0);
796
797 /* Add-in any new carry. */
798
799 SKCS_OC_ADD(Checksum, Checksum, 0);
800
801 /* Note: All bits beyond the 16-bit limit are now zero. */
802
803 return ((unsigned) Checksum);
804} /* SkCsCalculateChecksum */
805
806#endif /* SK_CS_CALCULATE_CHECKSUM */
807
808/******************************************************************************
809 *
810 * SkCsEvent - the CSUM event dispatcher
811 *
812 * Description:
813 * This is the event handler for the CSUM module.
814 *
815 * Arguments:
816 * pAc - Pointer to adapter context.
817 *
818 * Ioc - I/O context.
819 *
820 * Event - Event id.
821 *
822 * Param - Event dependent parameter.
823 *
824 * Returns:
825 * The 16-bit Internet Checksum for the specified data.
826 *
827 * Note: The checksum is calculated in the machine's natural byte order,
828 * i.e. little vs. big endian. Thus, the resulting checksum is different
829 * for the same input data on little and big endian machines.
830 *
831 * However, when written back to the network packet, the byte order is
832 * always in correct network order.
833 */
834int SkCsEvent(
835SK_AC *pAc, /* Pointer to adapter context. */
836SK_IOC Ioc, /* I/O context. */
837SK_U32 Event, /* Event id. */
838SK_EVPARA Param) /* Event dependent parameter. */
839{
840 int ProtoIndex;
841 int NetNumber;
842
843 switch (Event) {
844 /*
845 * Clear protocol statistics.
846 *
847 * Param - Protocol index, or -1 for all protocols.
848 * - Net number.
849 */
850 case SK_CSUM_EVENT_CLEAR_PROTO_STATS:
851
852 ProtoIndex = (int)Param.Para32[1];
853 NetNumber = (int)Param.Para32[0];
854 if (ProtoIndex < 0) { /* Clear for all protocols. */
855 if (NetNumber >= 0) {
856 SK_MEMSET(&pAc->Csum.ProtoStats[NetNumber][0], 0,
857 sizeof(pAc->Csum.ProtoStats[NetNumber]));
858 }
859 }
860 else { /* Clear for individual protocol. */
861 SK_MEMSET(&pAc->Csum.ProtoStats[NetNumber][ProtoIndex], 0,
862 sizeof(pAc->Csum.ProtoStats[NetNumber][ProtoIndex]));
863 }
864 break;
865 default:
866 break;
867 }
868 return (0); /* Success. */
869} /* SkCsEvent */
870
871#endif /* SK_USE_CSUM */
diff --git a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
index fb639959292b..b71769ae4603 100644
--- a/drivers/net/sk98lin/skethtool.c
+++ b/drivers/net/sk98lin/skethtool.c
@@ -549,4 +549,6 @@ struct ethtool_ops SkGeEthtoolOps = {
549 .phys_id = locateDevice, 549 .phys_id = locateDevice,
550 .get_pauseparam = getPauseParams, 550 .get_pauseparam = getPauseParams,
551 .set_pauseparam = setPauseParams, 551 .set_pauseparam = setPauseParams,
552 .get_link = ethtool_op_get_link,
553 .get_perm_addr = ethtool_op_get_perm_addr,
552}; 554};
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index b18c92cb629e..00c5d7f04c68 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -101,7 +101,6 @@
101 * "h/skgeinit.h" 101 * "h/skgeinit.h"
102 * "h/skaddr.h" 102 * "h/skaddr.h"
103 * "h/skgesirq.h" 103 * "h/skgesirq.h"
104 * "h/skcsum.h"
105 * "h/skrlmt.h" 104 * "h/skrlmt.h"
106 * 105 *
107 ******************************************************************************/ 106 ******************************************************************************/
@@ -113,6 +112,7 @@
113#include <linux/init.h> 112#include <linux/init.h>
114#include <linux/proc_fs.h> 113#include <linux/proc_fs.h>
115#include <linux/dma-mapping.h> 114#include <linux/dma-mapping.h>
115#include <linux/ip.h>
116 116
117#include "h/skdrv1st.h" 117#include "h/skdrv1st.h"
118#include "h/skdrv2nd.h" 118#include "h/skdrv2nd.h"
@@ -601,11 +601,6 @@ SK_BOOL DualNet;
601 return(-EAGAIN); 601 return(-EAGAIN);
602 } 602 }
603 603
604 SkCsSetReceiveFlags(pAC,
605 SKCS_PROTO_IP | SKCS_PROTO_TCP | SKCS_PROTO_UDP,
606 &pAC->CsOfs1, &pAC->CsOfs2, 0);
607 pAC->CsOfs = (pAC->CsOfs2 << 16) | pAC->CsOfs1;
608
609 BoardInitMem(pAC); 604 BoardInitMem(pAC);
610 /* tschilling: New common function with minimum size check. */ 605 /* tschilling: New common function with minimum size check. */
611 DualNet = SK_FALSE; 606 DualNet = SK_FALSE;
@@ -823,7 +818,7 @@ uintptr_t VNextDescr; /* the virtual bus address of the next descriptor */
823 /* set the pointers right */ 818 /* set the pointers right */
824 pDescr->VNextRxd = VNextDescr & 0xffffffffULL; 819 pDescr->VNextRxd = VNextDescr & 0xffffffffULL;
825 pDescr->pNextRxd = pNextDescr; 820 pDescr->pNextRxd = pNextDescr;
826 pDescr->TcpSumStarts = pAC->CsOfs; 821 pDescr->TcpSumStarts = 0;
827 822
828 /* advance one step */ 823 /* advance one step */
829 pPrevDescr = pDescr; 824 pPrevDescr = pDescr;
@@ -1505,8 +1500,6 @@ struct sk_buff *pMessage) /* pointer to send-message */
1505 TXD *pOldTxd; 1500 TXD *pOldTxd;
1506 unsigned long Flags; 1501 unsigned long Flags;
1507 SK_U64 PhysAddr; 1502 SK_U64 PhysAddr;
1508 int Protocol;
1509 int IpHeaderLength;
1510 int BytesSend = pMessage->len; 1503 int BytesSend = pMessage->len;
1511 1504
1512 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X")); 1505 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X"));
@@ -1579,8 +1572,10 @@ struct sk_buff *pMessage) /* pointer to send-message */
1579 pTxd->pMBuf = pMessage; 1572 pTxd->pMBuf = pMessage;
1580 1573
1581 if (pMessage->ip_summed == CHECKSUM_HW) { 1574 if (pMessage->ip_summed == CHECKSUM_HW) {
1582 Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff); 1575 u16 hdrlen = pMessage->h.raw - pMessage->data;
1583 if ((Protocol == C_PROTO_ID_UDP) && 1576 u16 offset = hdrlen + pMessage->csum;
1577
1578 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1584 (pAC->GIni.GIChipRev == 0) && 1579 (pAC->GIni.GIChipRev == 0) &&
1585 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { 1580 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1586 pTxd->TBControl = BMU_TCP_CHECK; 1581 pTxd->TBControl = BMU_TCP_CHECK;
@@ -1588,14 +1583,9 @@ struct sk_buff *pMessage) /* pointer to send-message */
1588 pTxd->TBControl = BMU_UDP_CHECK; 1583 pTxd->TBControl = BMU_UDP_CHECK;
1589 } 1584 }
1590 1585
1591 IpHeaderLength = (SK_U8)pMessage->data[C_OFFSET_IPHEADER]; 1586 pTxd->TcpSumOfs = 0;
1592 IpHeaderLength = (IpHeaderLength & 0xf) * 4; 1587 pTxd->TcpSumSt = hdrlen;
1593 pTxd->TcpSumOfs = 0; /* PH-Checksum already calculated */ 1588 pTxd->TcpSumWr = offset;
1594 pTxd->TcpSumSt = C_LEN_ETHERMAC_HEADER + IpHeaderLength +
1595 (Protocol == C_PROTO_ID_UDP ?
1596 C_OFFSET_UDPHEADER_UDPCS :
1597 C_OFFSET_TCPHEADER_TCPCS);
1598 pTxd->TcpSumWr = C_LEN_ETHERMAC_HEADER + IpHeaderLength;
1599 1589
1600 pTxd->TBControl |= BMU_OWN | BMU_STF | 1590 pTxd->TBControl |= BMU_OWN | BMU_STF |
1601 BMU_SW | BMU_EOF | 1591 BMU_SW | BMU_EOF |
@@ -1658,11 +1648,10 @@ struct sk_buff *pMessage) /* pointer to send-message */
1658 TXD *pTxdLst; 1648 TXD *pTxdLst;
1659 int CurrFrag; 1649 int CurrFrag;
1660 int BytesSend; 1650 int BytesSend;
1661 int IpHeaderLength;
1662 int Protocol;
1663 skb_frag_t *sk_frag; 1651 skb_frag_t *sk_frag;
1664 SK_U64 PhysAddr; 1652 SK_U64 PhysAddr;
1665 unsigned long Flags; 1653 unsigned long Flags;
1654 SK_U32 Control;
1666 1655
1667 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags); 1656 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
1668#ifndef USE_TX_COMPLETE 1657#ifndef USE_TX_COMPLETE
@@ -1685,7 +1674,6 @@ struct sk_buff *pMessage) /* pointer to send-message */
1685 pTxdFst = pTxd; 1674 pTxdFst = pTxd;
1686 pTxdLst = pTxd; 1675 pTxdLst = pTxd;
1687 BytesSend = 0; 1676 BytesSend = 0;
1688 Protocol = 0;
1689 1677
1690 /* 1678 /*
1691 ** Map the first fragment (header) into the DMA-space 1679 ** Map the first fragment (header) into the DMA-space
@@ -1703,32 +1691,31 @@ struct sk_buff *pMessage) /* pointer to send-message */
1703 ** Does the HW need to evaluate checksum for TCP or UDP packets? 1691 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1704 */ 1692 */
1705 if (pMessage->ip_summed == CHECKSUM_HW) { 1693 if (pMessage->ip_summed == CHECKSUM_HW) {
1706 pTxd->TBControl = BMU_STF | BMU_STFWD | skb_headlen(pMessage); 1694 u16 hdrlen = pMessage->h.raw - pMessage->data;
1695 u16 offset = hdrlen + pMessage->csum;
1696
1697 Control = BMU_STFWD;
1698
1707 /* 1699 /*
1708 ** We have to use the opcode for tcp here, because the 1700 ** We have to use the opcode for tcp here, because the
1709 ** opcode for udp is not working in the hardware yet 1701 ** opcode for udp is not working in the hardware yet
1710 ** (Revision 2.0) 1702 ** (Revision 2.0)
1711 */ 1703 */
1712 Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff); 1704 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1713 if ((Protocol == C_PROTO_ID_UDP) &&
1714 (pAC->GIni.GIChipRev == 0) && 1705 (pAC->GIni.GIChipRev == 0) &&
1715 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { 1706 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1716 pTxd->TBControl |= BMU_TCP_CHECK; 1707 Control |= BMU_TCP_CHECK;
1717 } else { 1708 } else {
1718 pTxd->TBControl |= BMU_UDP_CHECK; 1709 Control |= BMU_UDP_CHECK;
1719 } 1710 }
1720 1711
1721 IpHeaderLength = ((SK_U8)pMessage->data[C_OFFSET_IPHEADER] & 0xf)*4; 1712 pTxd->TcpSumOfs = 0;
1722 pTxd->TcpSumOfs = 0; /* PH-Checksum already claculated */ 1713 pTxd->TcpSumSt = hdrlen;
1723 pTxd->TcpSumSt = C_LEN_ETHERMAC_HEADER + IpHeaderLength + 1714 pTxd->TcpSumWr = offset;
1724 (Protocol == C_PROTO_ID_UDP ? 1715 } else
1725 C_OFFSET_UDPHEADER_UDPCS : 1716 Control = BMU_CHECK | BMU_SW;
1726 C_OFFSET_TCPHEADER_TCPCS); 1717
1727 pTxd->TcpSumWr = C_LEN_ETHERMAC_HEADER + IpHeaderLength; 1718 pTxd->TBControl = BMU_STF | Control | skb_headlen(pMessage);
1728 } else {
1729 pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_STF |
1730 skb_headlen(pMessage);
1731 }
1732 1719
1733 pTxd = pTxd->pNextTxd; 1720 pTxd = pTxd->pNextTxd;
1734 pTxPort->TxdRingFree--; 1721 pTxPort->TxdRingFree--;
@@ -1752,40 +1739,18 @@ struct sk_buff *pMessage) /* pointer to send-message */
1752 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32); 1739 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
1753 pTxd->pMBuf = pMessage; 1740 pTxd->pMBuf = pMessage;
1754 1741
1755 /* 1742 pTxd->TBControl = Control | BMU_OWN | sk_frag->size;;
1756 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1757 */
1758 if (pMessage->ip_summed == CHECKSUM_HW) {
1759 pTxd->TBControl = BMU_OWN | BMU_SW | BMU_STFWD;
1760 /*
1761 ** We have to use the opcode for tcp here because the
1762 ** opcode for udp is not working in the hardware yet
1763 ** (revision 2.0)
1764 */
1765 if ((Protocol == C_PROTO_ID_UDP) &&
1766 (pAC->GIni.GIChipRev == 0) &&
1767 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1768 pTxd->TBControl |= BMU_TCP_CHECK;
1769 } else {
1770 pTxd->TBControl |= BMU_UDP_CHECK;
1771 }
1772 } else {
1773 pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_OWN;
1774 }
1775 1743
1776 /* 1744 /*
1777 ** Do we have the last fragment? 1745 ** Do we have the last fragment?
1778 */ 1746 */
1779 if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags ) { 1747 if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags ) {
1780#ifdef USE_TX_COMPLETE 1748#ifdef USE_TX_COMPLETE
1781 pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF | sk_frag->size; 1749 pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF;
1782#else 1750#else
1783 pTxd->TBControl |= BMU_EOF | sk_frag->size; 1751 pTxd->TBControl |= BMU_EOF;
1784#endif 1752#endif
1785 pTxdFst->TBControl |= BMU_OWN | BMU_SW; 1753 pTxdFst->TBControl |= BMU_OWN | BMU_SW;
1786
1787 } else {
1788 pTxd->TBControl |= sk_frag->size;
1789 } 1754 }
1790 pTxdLst = pTxd; 1755 pTxdLst = pTxd;
1791 pTxd = pTxd->pNextTxd; 1756 pTxd = pTxd->pNextTxd;
@@ -2032,7 +1997,6 @@ SK_U32 Control; /* control field of descriptor */
2032struct sk_buff *pMsg; /* pointer to message holding frame */ 1997struct sk_buff *pMsg; /* pointer to message holding frame */
2033struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */ 1998struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */
2034int FrameLength; /* total length of received frame */ 1999int FrameLength; /* total length of received frame */
2035int IpFrameLength;
2036SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */ 2000SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */
2037SK_EVPARA EvPara; /* an event parameter union */ 2001SK_EVPARA EvPara; /* an event parameter union */
2038unsigned long Flags; /* for spin lock */ 2002unsigned long Flags; /* for spin lock */
@@ -2045,10 +2009,6 @@ SK_BOOL IsMc;
2045SK_BOOL IsBadFrame; /* Bad frame */ 2009SK_BOOL IsBadFrame; /* Bad frame */
2046 2010
2047SK_U32 FrameStat; 2011SK_U32 FrameStat;
2048unsigned short Csum1;
2049unsigned short Csum2;
2050unsigned short Type;
2051int Result;
2052SK_U64 PhysAddr; 2012SK_U64 PhysAddr;
2053 2013
2054rx_start: 2014rx_start:
@@ -2177,8 +2137,8 @@ rx_start:
2177 (dma_addr_t) PhysAddr, 2137 (dma_addr_t) PhysAddr,
2178 FrameLength, 2138 FrameLength,
2179 PCI_DMA_FROMDEVICE); 2139 PCI_DMA_FROMDEVICE);
2180 eth_copy_and_sum(pNewMsg, pMsg->data, 2140 memcpy(pNewMsg->data, pMsg, FrameLength);
2181 FrameLength, 0); 2141
2182 pci_dma_sync_single_for_device(pAC->PciDev, 2142 pci_dma_sync_single_for_device(pAC->PciDev,
2183 (dma_addr_t) PhysAddr, 2143 (dma_addr_t) PhysAddr,
2184 FrameLength, 2144 FrameLength,
@@ -2206,69 +2166,16 @@ rx_start:
2206 2166
2207 /* set length in message */ 2167 /* set length in message */
2208 skb_put(pMsg, FrameLength); 2168 skb_put(pMsg, FrameLength);
2209 /* hardware checksum */ 2169 } /* frame > SK_COPY_TRESHOLD */
2210 Type = ntohs(*((short*)&pMsg->data[12]));
2211 2170
2212#ifdef USE_SK_RX_CHECKSUM 2171#ifdef USE_SK_RX_CHECKSUM
2213 if (Type == 0x800) { 2172 pMsg->csum = pRxd->TcpSums;
2214 Csum1=le16_to_cpu(pRxd->TcpSums & 0xffff); 2173 pMsg->ip_summed = CHECKSUM_HW;
2215 Csum2=le16_to_cpu((pRxd->TcpSums >> 16) & 0xffff);
2216 IpFrameLength = (int) ntohs((unsigned short)
2217 ((unsigned short *) pMsg->data)[8]);
2218
2219 /*
2220 * Test: If frame is padded, a check is not possible!
2221 * Frame not padded? Length difference must be 14 (0xe)!
2222 */
2223 if ((FrameLength - IpFrameLength) != 0xe) {
2224 /* Frame padded => TCP offload not possible! */
2225 pMsg->ip_summed = CHECKSUM_NONE;
2226 } else {
2227 /* Frame not padded => TCP offload! */
2228 if ((((Csum1 & 0xfffe) && (Csum2 & 0xfffe)) &&
2229 (pAC->GIni.GIChipId == CHIP_ID_GENESIS)) ||
2230 (pAC->ChipsetType)) {
2231 Result = SkCsGetReceiveInfo(pAC,
2232 &pMsg->data[14],
2233 Csum1, Csum2, pRxPort->PortIndex);
2234 if (Result ==
2235 SKCS_STATUS_IP_FRAGMENT ||
2236 Result ==
2237 SKCS_STATUS_IP_CSUM_OK ||
2238 Result ==
2239 SKCS_STATUS_TCP_CSUM_OK ||
2240 Result ==
2241 SKCS_STATUS_UDP_CSUM_OK) {
2242 pMsg->ip_summed =
2243 CHECKSUM_UNNECESSARY;
2244 }
2245 else if (Result ==
2246 SKCS_STATUS_TCP_CSUM_ERROR ||
2247 Result ==
2248 SKCS_STATUS_UDP_CSUM_ERROR ||
2249 Result ==
2250 SKCS_STATUS_IP_CSUM_ERROR_UDP ||
2251 Result ==
2252 SKCS_STATUS_IP_CSUM_ERROR_TCP ||
2253 Result ==
2254 SKCS_STATUS_IP_CSUM_ERROR ) {
2255 /* HW Checksum error */
2256 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2257 SK_DBGCAT_DRV_RX_PROGRESS,
2258 ("skge: CRC error. Frame dropped!\n"));
2259 goto rx_failed;
2260 } else {
2261 pMsg->ip_summed =
2262 CHECKSUM_NONE;
2263 }
2264 }/* checksumControl calculation valid */
2265 } /* Frame length check */
2266 } /* IP frame */
2267#else 2174#else
2268 pMsg->ip_summed = CHECKSUM_NONE; 2175 pMsg->ip_summed = CHECKSUM_NONE;
2269#endif 2176#endif
2270 } /* frame > SK_COPY_TRESHOLD */ 2177
2271 2178
2272 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V")); 2179 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V"));
2273 ForRlmt = SK_RLMT_RX_PROTOCOL; 2180 ForRlmt = SK_RLMT_RX_PROTOCOL;
2274#if 0 2181#if 0
@@ -4946,7 +4853,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4946 dev->irq = pdev->irq; 4853 dev->irq = pdev->irq;
4947 error = SkGeInitPCI(pAC); 4854 error = SkGeInitPCI(pAC);
4948 if (error) { 4855 if (error) {
4949 printk("SKGE: PCI setup failed: %i\n", error); 4856 printk(KERN_ERR "sk98lin: PCI setup failed: %i\n", error);
4950 goto out_free_netdev; 4857 goto out_free_netdev;
4951 } 4858 }
4952 4859
@@ -4982,7 +4889,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4982 4889
4983 /* Register net device */ 4890 /* Register net device */
4984 if (register_netdev(dev)) { 4891 if (register_netdev(dev)) {
4985 printk(KERN_ERR "SKGE: Could not register device.\n"); 4892 printk(KERN_ERR "sk98lin: Could not register device.\n");
4986 goto out_free_resources; 4893 goto out_free_resources;
4987 } 4894 }
4988 4895
@@ -5001,8 +4908,8 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
5001 4908
5002 SkGeYellowLED(pAC, pAC->IoBase, 1); 4909 SkGeYellowLED(pAC, pAC->IoBase, 1);
5003 4910
5004
5005 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6); 4911 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
4912 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
5006 4913
5007 SkGeProcCreate(dev); 4914 SkGeProcCreate(dev);
5008 4915
@@ -5048,13 +4955,14 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
5048#endif 4955#endif
5049 4956
5050 if (register_netdev(dev)) { 4957 if (register_netdev(dev)) {
5051 printk(KERN_ERR "SKGE: Could not register device.\n"); 4958 printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n");
5052 free_netdev(dev); 4959 free_netdev(dev);
5053 pAC->dev[1] = pAC->dev[0]; 4960 pAC->dev[1] = pAC->dev[0];
5054 } else { 4961 } else {
5055 SkGeProcCreate(dev); 4962 SkGeProcCreate(dev);
5056 memcpy(&dev->dev_addr, 4963 memcpy(&dev->dev_addr,
5057 &pAC->Addr.Net[1].CurrentMacAddress, 6); 4964 &pAC->Addr.Net[1].CurrentMacAddress, 6);
4965 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
5058 4966
5059 printk("%s: %s\n", dev->name, pAC->DeviceStr); 4967 printk("%s: %s\n", dev->name, pAC->DeviceStr);
5060 printk(" PrefPort:B RlmtMode:Dual Check Link State\n"); 4968 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 596c93b12daa..716467879b9c 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -2300,14 +2300,12 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2300 td->dma_hi = map >> 32; 2300 td->dma_hi = map >> 32;
2301 2301
2302 if (skb->ip_summed == CHECKSUM_HW) { 2302 if (skb->ip_summed == CHECKSUM_HW) {
2303 const struct iphdr *ip
2304 = (const struct iphdr *) (skb->data + ETH_HLEN);
2305 int offset = skb->h.raw - skb->data; 2303 int offset = skb->h.raw - skb->data;
2306 2304
2307 /* This seems backwards, but it is what the sk98lin 2305 /* This seems backwards, but it is what the sk98lin
2308 * does. Looks like hardware is wrong? 2306 * does. Looks like hardware is wrong?
2309 */ 2307 */
2310 if (ip->protocol == IPPROTO_UDP 2308 if (skb->h.ipiph->protocol == IPPROTO_UDP
2311 && hw->chip_rev == 0 && hw->chip_id == CHIP_ID_YUKON) 2309 && hw->chip_rev == 0 && hw->chip_id == CHIP_ID_YUKON)
2312 control = BMU_TCP_CHECK; 2310 control = BMU_TCP_CHECK;
2313 else 2311 else
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 340ab4ee4b67..7a92b1cbd6aa 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2755,8 +2755,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2755 SET_NETDEV_DEV(dev, dmdev); 2755 SET_NETDEV_DEV(dev, dmdev);
2756 2756
2757 2757
2758 if (test_bit(FLAG_MPI,&ai->flags)) 2758 reset_card (dev, 1);
2759 reset_card (dev, 1); 2759 msleep(400);
2760 2760
2761 rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev ); 2761 rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev );
2762 if (rc) { 2762 if (rc) {
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 488ab06fb79f..6fd0bf736830 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -3512,9 +3512,8 @@ static int orinoco_ioctl_setpower(struct net_device *dev,
3512 break; 3512 break;
3513 default: 3513 default:
3514 err = -EINVAL; 3514 err = -EINVAL;
3515 }
3516 if (err)
3517 goto out; 3515 goto out;
3516 }
3518 3517
3519 if (prq->flags & IW_POWER_TIMEOUT) { 3518 if (prq->flags & IW_POWER_TIMEOUT) {
3520 priv->pm_on = 1; 3519 priv->pm_on = 1;
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 2c22b4b3619d..078579ae6359 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -355,9 +355,10 @@ static void add_pcc_socket(ulong base, int irq, ulong mapaddr, kio_addr_t ioaddr
355#ifndef CONFIG_PLAT_USRV 355#ifndef CONFIG_PLAT_USRV
356 /* insert interrupt */ 356 /* insert interrupt */
357 request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 357 request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
358#ifndef CONFIG_PLAT_MAPPI3
358 /* eject interrupt */ 359 /* eject interrupt */
359 request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 360 request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
360 361#endif
361 debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n"); 362 debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n");
362 pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01); 363 pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01);
363#endif /* CONFIG_PLAT_USRV */ 364#endif /* CONFIG_PLAT_USRV */
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index dfea346b00a5..f9792528e33f 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -380,23 +380,23 @@ megaraid_queue(Scsi_Cmnd *scmd, void (*done)(Scsi_Cmnd *))
380 380
381 spin_lock_irqsave(&adapter->lock, flags); 381 spin_lock_irqsave(&adapter->lock, flags);
382 scb = mega_build_cmd(adapter, scmd, &busy); 382 scb = mega_build_cmd(adapter, scmd, &busy);
383 if (!scb)
384 goto out;
383 385
384 if(scb) { 386 scb->state |= SCB_PENDQ;
385 scb->state |= SCB_PENDQ; 387 list_add_tail(&scb->list, &adapter->pending_list);
386 list_add_tail(&scb->list, &adapter->pending_list);
387 388
388 /* 389 /*
389 * Check if the HBA is in quiescent state, e.g., during a 390 * Check if the HBA is in quiescent state, e.g., during a
390 * delete logical drive opertion. If it is, don't run 391 * delete logical drive opertion. If it is, don't run
391 * the pending_list. 392 * the pending_list.
392 */ 393 */
393 if(atomic_read(&adapter->quiescent) == 0) { 394 if (atomic_read(&adapter->quiescent) == 0)
394 mega_runpendq(adapter); 395 mega_runpendq(adapter);
395 }
396 return 0;
397 }
398 spin_unlock_irqrestore(&adapter->lock, flags);
399 396
397 busy = 0;
398 out:
399 spin_unlock_irqrestore(&adapter->lock, flags);
400 return busy; 400 return busy;
401} 401}
402 402
@@ -4677,7 +4677,6 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4677 4677
4678 adapter->flag = flag; 4678 adapter->flag = flag;
4679 spin_lock_init(&adapter->lock); 4679 spin_lock_init(&adapter->lock);
4680 scsi_assign_lock(host, &adapter->lock);
4681 4680
4682 host->cmd_per_lun = max_cmd_per_lun; 4681 host->cmd_per_lun = max_cmd_per_lun;
4683 host->max_sectors = max_sectors_per_io; 4682 host->max_sectors = max_sectors_per_io;
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index e08510d09ff6..d2bcd1f87cd6 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -102,7 +102,7 @@ static unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
102#define SERIAL_PORT_DFNS 102#define SERIAL_PORT_DFNS
103#endif 103#endif
104 104
105static struct old_serial_port old_serial_port[] = { 105static const struct old_serial_port old_serial_port[] = {
106 SERIAL_PORT_DFNS /* defined in asm/serial.h */ 106 SERIAL_PORT_DFNS /* defined in asm/serial.h */
107}; 107};
108 108
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 5c3c03932d6d..8d92adfbb8bd 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -468,7 +468,7 @@ static unsigned short timedia_eight_port[] = {
468 0x9167, 0x9168, 0xA066, 0xA167, 0xA168, 0 468 0x9167, 0x9168, 0xA066, 0xA167, 0xA168, 0
469}; 469};
470 470
471static struct timedia_struct { 471static const struct timedia_struct {
472 int num; 472 int num;
473 unsigned short *ids; 473 unsigned short *ids;
474} timedia_data[] = { 474} timedia_data[] = {
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 2331296e1e17..c17d680e3f04 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1779,7 +1779,7 @@ struct baud_rates {
1779 unsigned int cflag; 1779 unsigned int cflag;
1780}; 1780};
1781 1781
1782static struct baud_rates baud_rates[] = { 1782static const struct baud_rates baud_rates[] = {
1783 { 921600, B921600 }, 1783 { 921600, B921600 },
1784 { 460800, B460800 }, 1784 { 460800, B460800 },
1785 { 230400, B230400 }, 1785 { 230400, B230400 },
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 2c7d3ef76e8e..7ce0c7e66d37 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -85,7 +85,7 @@ struct multi_id {
85 int multi; /* 1 = multifunction, > 1 = # ports */ 85 int multi; /* 1 = multifunction, > 1 = # ports */
86}; 86};
87 87
88static struct multi_id multi_id[] = { 88static const struct multi_id multi_id[] = {
89 { MANFID_OMEGA, PRODID_OMEGA_QSP_100, 4 }, 89 { MANFID_OMEGA, PRODID_OMEGA_QSP_100, 4 },
90 { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232, 2 }, 90 { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232, 2 },
91 { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232_D1, 2 }, 91 { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232_D1, 2 },
@@ -354,8 +354,8 @@ next_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
354 354
355static int simple_config(dev_link_t *link) 355static int simple_config(dev_link_t *link)
356{ 356{
357 static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 357 static const kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
358 static int size_table[2] = { 8, 16 }; 358 static const int size_table[2] = { 8, 16 };
359 client_handle_t handle = link->handle; 359 client_handle_t handle = link->handle;
360 struct serial_info *info = link->priv; 360 struct serial_info *info = link->priv;
361 struct serial_cfg_mem *cfg_mem; 361 struct serial_cfg_mem *cfg_mem;
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 79861ee12a29..9d59dc62e6d2 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -787,6 +787,9 @@ static const struct usb_device_id cxacru_usb_ids[] = {
787 { /* V = Conexant P = ADSL modem (Hasbani project) */ 787 { /* V = Conexant P = ADSL modem (Hasbani project) */
788 USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00 788 USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00
789 }, 789 },
790 { /* V = Conexant P = ADSL modem (Well PTI-800 */
791 USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
792 },
790 { /* V = Conexant P = ADSL modem */ 793 { /* V = Conexant P = ADSL modem */
791 USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00 794 USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
792 }, 795 },
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index c466739428b2..2e6593e6c1bd 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -879,7 +879,7 @@ static int usbatm_atm_init(struct usbatm_data *instance)
879 879
880 fail: 880 fail:
881 instance->atm_dev = NULL; 881 instance->atm_dev = NULL;
882 shutdown_atm_dev(atm_dev); /* usbatm_atm_dev_close will eventually be called */ 882 atm_dev_deregister(atm_dev); /* usbatm_atm_dev_close will eventually be called */
883 return ret; 883 return ret;
884} 884}
885 885
@@ -1164,7 +1164,7 @@ void usbatm_usb_disconnect(struct usb_interface *intf)
1164 1164
1165 /* ATM finalize */ 1165 /* ATM finalize */
1166 if (instance->atm_dev) 1166 if (instance->atm_dev)
1167 shutdown_atm_dev(instance->atm_dev); 1167 atm_dev_deregister(instance->atm_dev);
1168 1168
1169 usbatm_put_instance(instance); /* taken in usbatm_usb_probe */ 1169 usbatm_put_instance(instance); /* taken in usbatm_usb_probe */
1170} 1170}
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 5131d88e8c5b..29b5b2a6e183 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -219,6 +219,7 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
219 goto done; 219 goto done;
220 } 220 }
221 } 221 }
222 synchronize_irq(dev->irq);
222 223
223 /* FIXME until the generic PM interfaces change a lot more, this 224 /* FIXME until the generic PM interfaces change a lot more, this
224 * can't use PCI D1 and D2 states. For example, the confusion 225 * can't use PCI D1 and D2 states. For example, the confusion
@@ -392,7 +393,7 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
392 393
393 dev->dev.power.power_state = PMSG_ON; 394 dev->dev.power.power_state = PMSG_ON;
394 395
395 hcd->saw_irq = 0; 396 clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
396 397
397 if (hcd->driver->resume) { 398 if (hcd->driver->resume) {
398 retval = hcd->driver->resume(hcd); 399 retval = hcd->driver->resume(hcd);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 5e5f65a475ab..da24c31ee00d 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1315,11 +1315,12 @@ static int hcd_unlink_urb (struct urb *urb, int status)
1315 * finish unlinking the initial failed usb_set_address() 1315 * finish unlinking the initial failed usb_set_address()
1316 * or device descriptor fetch. 1316 * or device descriptor fetch.
1317 */ 1317 */
1318 if (!hcd->saw_irq && hcd->self.root_hub != urb->dev) { 1318 if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags)
1319 && hcd->self.root_hub != urb->dev) {
1319 dev_warn (hcd->self.controller, "Unlink after no-IRQ? " 1320 dev_warn (hcd->self.controller, "Unlink after no-IRQ? "
1320 "Controller is probably using the wrong IRQ." 1321 "Controller is probably using the wrong IRQ."
1321 "\n"); 1322 "\n");
1322 hcd->saw_irq = 1; 1323 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
1323 } 1324 }
1324 1325
1325 urb->status = status; 1326 urb->status = status;
@@ -1649,13 +1650,15 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs * r)
1649 struct usb_hcd *hcd = __hcd; 1650 struct usb_hcd *hcd = __hcd;
1650 int start = hcd->state; 1651 int start = hcd->state;
1651 1652
1652 if (start == HC_STATE_HALT) 1653 if (unlikely(start == HC_STATE_HALT ||
1654 !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
1653 return IRQ_NONE; 1655 return IRQ_NONE;
1654 if (hcd->driver->irq (hcd, r) == IRQ_NONE) 1656 if (hcd->driver->irq (hcd, r) == IRQ_NONE)
1655 return IRQ_NONE; 1657 return IRQ_NONE;
1656 1658
1657 hcd->saw_irq = 1; 1659 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
1658 if (hcd->state == HC_STATE_HALT) 1660
1661 if (unlikely(hcd->state == HC_STATE_HALT))
1659 usb_hc_died (hcd); 1662 usb_hc_died (hcd);
1660 return IRQ_HANDLED; 1663 return IRQ_HANDLED;
1661} 1664}
@@ -1768,6 +1771,8 @@ int usb_add_hcd(struct usb_hcd *hcd,
1768 1771
1769 dev_info(hcd->self.controller, "%s\n", hcd->product_desc); 1772 dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
1770 1773
1774 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1775
1771 /* till now HC has been in an indeterminate state ... */ 1776 /* till now HC has been in an indeterminate state ... */
1772 if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) { 1777 if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) {
1773 dev_err(hcd->self.controller, "can't reset\n"); 1778 dev_err(hcd->self.controller, "can't reset\n");
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 24a62a2ff86d..c8a1b350e2cf 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -72,7 +72,12 @@ struct usb_hcd { /* usb_bus.hcpriv points to this */
72 * hardware info/state 72 * hardware info/state
73 */ 73 */
74 const struct hc_driver *driver; /* hw-specific hooks */ 74 const struct hc_driver *driver; /* hw-specific hooks */
75 unsigned saw_irq : 1; 75
76 /* Flags that need to be manipulated atomically */
77 unsigned long flags;
78#define HCD_FLAG_HW_ACCESSIBLE 0x00000001
79#define HCD_FLAG_SAW_IRQ 0x00000002
80
76 unsigned can_wakeup:1; /* hw supports wakeup? */ 81 unsigned can_wakeup:1; /* hw supports wakeup? */
77 unsigned remote_wakeup:1;/* sw should use wakeup? */ 82 unsigned remote_wakeup:1;/* sw should use wakeup? */
78 unsigned rh_registered:1;/* is root hub registered? */ 83 unsigned rh_registered:1;/* is root hub registered? */
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 441c26064b44..13f73a836e45 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -121,8 +121,8 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
121 return 0; 121 return 0;
122} 122}
123 123
124/* called by khubd or root hub (re)init threads; leaves HC in halt state */ 124/* called during probe() after chip reset completes */
125static int ehci_pci_reset(struct usb_hcd *hcd) 125static int ehci_pci_setup(struct usb_hcd *hcd)
126{ 126{
127 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 127 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
128 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 128 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
@@ -141,6 +141,11 @@ static int ehci_pci_reset(struct usb_hcd *hcd)
141 if (retval) 141 if (retval)
142 return retval; 142 return retval;
143 143
144 /* data structure init */
145 retval = ehci_init(hcd);
146 if (retval)
147 return retval;
148
144 /* NOTE: only the parts below this line are PCI-specific */ 149 /* NOTE: only the parts below this line are PCI-specific */
145 150
146 switch (pdev->vendor) { 151 switch (pdev->vendor) {
@@ -154,7 +159,8 @@ static int ehci_pci_reset(struct usb_hcd *hcd)
154 /* AMD8111 EHCI doesn't work, according to AMD errata */ 159 /* AMD8111 EHCI doesn't work, according to AMD errata */
155 if (pdev->device == 0x7463) { 160 if (pdev->device == 0x7463) {
156 ehci_info(ehci, "ignoring AMD8111 (errata)\n"); 161 ehci_info(ehci, "ignoring AMD8111 (errata)\n");
157 return -EIO; 162 retval = -EIO;
163 goto done;
158 } 164 }
159 break; 165 break;
160 case PCI_VENDOR_ID_NVIDIA: 166 case PCI_VENDOR_ID_NVIDIA:
@@ -207,9 +213,8 @@ static int ehci_pci_reset(struct usb_hcd *hcd)
207 /* REVISIT: per-port wake capability (PCI 0x62) currently unused */ 213 /* REVISIT: per-port wake capability (PCI 0x62) currently unused */
208 214
209 retval = ehci_pci_reinit(ehci, pdev); 215 retval = ehci_pci_reinit(ehci, pdev);
210 216done:
211 /* finish init */ 217 return retval;
212 return ehci_init(hcd);
213} 218}
214 219
215/*-------------------------------------------------------------------------*/ 220/*-------------------------------------------------------------------------*/
@@ -228,14 +233,36 @@ static int ehci_pci_reset(struct usb_hcd *hcd)
228static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) 233static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
229{ 234{
230 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 235 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
236 unsigned long flags;
237 int rc = 0;
231 238
232 if (time_before(jiffies, ehci->next_statechange)) 239 if (time_before(jiffies, ehci->next_statechange))
233 msleep(10); 240 msleep(10);
234 241
242 /* Root hub was already suspended. Disable irq emission and
243 * mark HW unaccessible, bail out if RH has been resumed. Use
244 * the spinlock to properly synchronize with possible pending
245 * RH suspend or resume activity.
246 *
247 * This is still racy as hcd->state is manipulated outside of
248 * any locks =P But that will be a different fix.
249 */
250 spin_lock_irqsave (&ehci->lock, flags);
251 if (hcd->state != HC_STATE_SUSPENDED) {
252 rc = -EINVAL;
253 goto bail;
254 }
255 writel (0, &ehci->regs->intr_enable);
256 (void)readl(&ehci->regs->intr_enable);
257
258 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
259 bail:
260 spin_unlock_irqrestore (&ehci->lock, flags);
261
235 // could save FLADJ in case of Vaux power loss 262 // could save FLADJ in case of Vaux power loss
236 // ... we'd only use it to handle clock skew 263 // ... we'd only use it to handle clock skew
237 264
238 return 0; 265 return rc;
239} 266}
240 267
241static int ehci_pci_resume(struct usb_hcd *hcd) 268static int ehci_pci_resume(struct usb_hcd *hcd)
@@ -251,6 +278,9 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
251 if (time_before(jiffies, ehci->next_statechange)) 278 if (time_before(jiffies, ehci->next_statechange))
252 msleep(100); 279 msleep(100);
253 280
281 /* Mark hardware accessible again as we are out of D3 state by now */
282 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
283
254 /* If CF is clear, we lost PCI Vaux power and need to restart. */ 284 /* If CF is clear, we lost PCI Vaux power and need to restart. */
255 if (readl(&ehci->regs->configured_flag) != FLAG_CF) 285 if (readl(&ehci->regs->configured_flag) != FLAG_CF)
256 goto restart; 286 goto restart;
@@ -319,7 +349,7 @@ static const struct hc_driver ehci_pci_hc_driver = {
319 /* 349 /*
320 * basic lifecycle operations 350 * basic lifecycle operations
321 */ 351 */
322 .reset = ehci_pci_reset, 352 .reset = ehci_pci_setup,
323 .start = ehci_run, 353 .start = ehci_run,
324#ifdef CONFIG_PM 354#ifdef CONFIG_PM
325 .suspend = ehci_pci_suspend, 355 .suspend = ehci_pci_suspend,
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 5bb872c3496d..bf03ec0d8ee2 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -912,6 +912,7 @@ submit_async (
912 int epnum; 912 int epnum;
913 unsigned long flags; 913 unsigned long flags;
914 struct ehci_qh *qh = NULL; 914 struct ehci_qh *qh = NULL;
915 int rc = 0;
915 916
916 qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list); 917 qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list);
917 epnum = ep->desc.bEndpointAddress; 918 epnum = ep->desc.bEndpointAddress;
@@ -926,21 +927,28 @@ submit_async (
926#endif 927#endif
927 928
928 spin_lock_irqsave (&ehci->lock, flags); 929 spin_lock_irqsave (&ehci->lock, flags);
930 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
931 &ehci_to_hcd(ehci)->flags))) {
932 rc = -ESHUTDOWN;
933 goto done;
934 }
935
929 qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv); 936 qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv);
937 if (unlikely(qh == NULL)) {
938 rc = -ENOMEM;
939 goto done;
940 }
930 941
931 /* Control/bulk operations through TTs don't need scheduling, 942 /* Control/bulk operations through TTs don't need scheduling,
932 * the HC and TT handle it when the TT has a buffer ready. 943 * the HC and TT handle it when the TT has a buffer ready.
933 */ 944 */
934 if (likely (qh != NULL)) { 945 if (likely (qh->qh_state == QH_STATE_IDLE))
935 if (likely (qh->qh_state == QH_STATE_IDLE)) 946 qh_link_async (ehci, qh_get (qh));
936 qh_link_async (ehci, qh_get (qh)); 947 done:
937 }
938 spin_unlock_irqrestore (&ehci->lock, flags); 948 spin_unlock_irqrestore (&ehci->lock, flags);
939 if (unlikely (qh == NULL)) { 949 if (unlikely (qh == NULL))
940 qtd_list_free (ehci, urb, qtd_list); 950 qtd_list_free (ehci, urb, qtd_list);
941 return -ENOMEM; 951 return rc;
942 }
943 return 0;
944} 952}
945 953
946/*-------------------------------------------------------------------------*/ 954/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index f0c8aa1ccd5d..57e77374d228 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -602,6 +602,12 @@ static int intr_submit (
602 602
603 spin_lock_irqsave (&ehci->lock, flags); 603 spin_lock_irqsave (&ehci->lock, flags);
604 604
605 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
606 &ehci_to_hcd(ehci)->flags))) {
607 status = -ESHUTDOWN;
608 goto done;
609 }
610
605 /* get qh and force any scheduling errors */ 611 /* get qh and force any scheduling errors */
606 INIT_LIST_HEAD (&empty); 612 INIT_LIST_HEAD (&empty);
607 qh = qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv); 613 qh = qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv);
@@ -1456,7 +1462,11 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb,
1456 1462
1457 /* schedule ... need to lock */ 1463 /* schedule ... need to lock */
1458 spin_lock_irqsave (&ehci->lock, flags); 1464 spin_lock_irqsave (&ehci->lock, flags);
1459 status = iso_stream_schedule (ehci, urb, stream); 1465 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
1466 &ehci_to_hcd(ehci)->flags)))
1467 status = -ESHUTDOWN;
1468 else
1469 status = iso_stream_schedule (ehci, urb, stream);
1460 if (likely (status == 0)) 1470 if (likely (status == 0))
1461 itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); 1471 itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream);
1462 spin_unlock_irqrestore (&ehci->lock, flags); 1472 spin_unlock_irqrestore (&ehci->lock, flags);
@@ -1815,7 +1825,11 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb,
1815 1825
1816 /* schedule ... need to lock */ 1826 /* schedule ... need to lock */
1817 spin_lock_irqsave (&ehci->lock, flags); 1827 spin_lock_irqsave (&ehci->lock, flags);
1818 status = iso_stream_schedule (ehci, urb, stream); 1828 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
1829 &ehci_to_hcd(ehci)->flags)))
1830 status = -ESHUTDOWN;
1831 else
1832 status = iso_stream_schedule (ehci, urb, stream);
1819 if (status == 0) 1833 if (status == 0)
1820 sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); 1834 sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream);
1821 spin_unlock_irqrestore (&ehci->lock, flags); 1835 spin_unlock_irqrestore (&ehci->lock, flags);
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 5c0c6c8a7a82..bf1d9abc07ac 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -115,7 +115,7 @@
115 115
116/*-------------------------------------------------------------------------*/ 116/*-------------------------------------------------------------------------*/
117 117
118// #define OHCI_VERBOSE_DEBUG /* not always helpful */ 118#undef OHCI_VERBOSE_DEBUG /* not always helpful */
119 119
120/* For initializing controller (mask in an HCFS mode too) */ 120/* For initializing controller (mask in an HCFS mode too) */
121#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR 121#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
@@ -253,6 +253,10 @@ static int ohci_urb_enqueue (
253 spin_lock_irqsave (&ohci->lock, flags); 253 spin_lock_irqsave (&ohci->lock, flags);
254 254
255 /* don't submit to a dead HC */ 255 /* don't submit to a dead HC */
256 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
257 retval = -ENODEV;
258 goto fail;
259 }
256 if (!HC_IS_RUNNING(hcd->state)) { 260 if (!HC_IS_RUNNING(hcd->state)) {
257 retval = -ENODEV; 261 retval = -ENODEV;
258 goto fail; 262 goto fail;
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index e01e77bc324b..72e3b12a1926 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -53,6 +53,11 @@ static int ohci_bus_suspend (struct usb_hcd *hcd)
53 53
54 spin_lock_irqsave (&ohci->lock, flags); 54 spin_lock_irqsave (&ohci->lock, flags);
55 55
56 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) {
57 spin_unlock_irqrestore (&ohci->lock, flags);
58 return -ESHUTDOWN;
59 }
60
56 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); 61 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
57 switch (ohci->hc_control & OHCI_CTRL_HCFS) { 62 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
58 case OHCI_USB_RESUME: 63 case OHCI_USB_RESUME:
@@ -140,11 +145,19 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
140 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 145 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
141 u32 temp, enables; 146 u32 temp, enables;
142 int status = -EINPROGRESS; 147 int status = -EINPROGRESS;
148 unsigned long flags;
143 149
144 if (time_before (jiffies, ohci->next_statechange)) 150 if (time_before (jiffies, ohci->next_statechange))
145 msleep(5); 151 msleep(5);
146 152
147 spin_lock_irq (&ohci->lock); 153 spin_lock_irqsave (&ohci->lock, flags);
154
155 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) {
156 spin_unlock_irqrestore (&ohci->lock, flags);
157 return -ESHUTDOWN;
158 }
159
160
148 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); 161 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
149 162
150 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { 163 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
@@ -179,7 +192,7 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
179 ohci_dbg (ohci, "lost power\n"); 192 ohci_dbg (ohci, "lost power\n");
180 status = -EBUSY; 193 status = -EBUSY;
181 } 194 }
182 spin_unlock_irq (&ohci->lock); 195 spin_unlock_irqrestore (&ohci->lock, flags);
183 if (status == -EBUSY) { 196 if (status == -EBUSY) {
184 (void) ohci_init (ohci); 197 (void) ohci_init (ohci);
185 return ohci_restart (ohci); 198 return ohci_restart (ohci);
@@ -297,8 +310,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
297 /* handle autosuspended root: finish resuming before 310 /* handle autosuspended root: finish resuming before
298 * letting khubd or root hub timer see state changes. 311 * letting khubd or root hub timer see state changes.
299 */ 312 */
300 if ((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER 313 if (unlikely((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER
301 || !HC_IS_RUNNING(hcd->state)) { 314 || !HC_IS_RUNNING(hcd->state))) {
302 can_suspend = 0; 315 can_suspend = 0;
303 goto done; 316 goto done;
304 } 317 }
@@ -508,6 +521,9 @@ static int ohci_hub_control (
508 u32 temp; 521 u32 temp;
509 int retval = 0; 522 int retval = 0;
510 523
524 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
525 return -ESHUTDOWN;
526
511 switch (typeReq) { 527 switch (typeReq) {
512 case ClearHubFeature: 528 case ClearHubFeature:
513 switch (wValue) { 529 switch (wValue) {
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 5f22e6590cd1..1b09dde068e1 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -105,13 +105,36 @@ ohci_pci_start (struct usb_hcd *hcd)
105 105
106static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) 106static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
107{ 107{
108 /* root hub was already suspended */ 108 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
109 return 0; 109 unsigned long flags;
110 int rc = 0;
111
112 /* Root hub was already suspended. Disable irq emission and
113 * mark HW unaccessible, bail out if RH has been resumed. Use
114 * the spinlock to properly synchronize with possible pending
115 * RH suspend or resume activity.
116 *
117 * This is still racy as hcd->state is manipulated outside of
118 * any locks =P But that will be a different fix.
119 */
120 spin_lock_irqsave (&ohci->lock, flags);
121 if (hcd->state != HC_STATE_SUSPENDED) {
122 rc = -EINVAL;
123 goto bail;
124 }
125 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
126 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
127 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
128 bail:
129 spin_unlock_irqrestore (&ohci->lock, flags);
130
131 return rc;
110} 132}
111 133
112 134
113static int ohci_pci_resume (struct usb_hcd *hcd) 135static int ohci_pci_resume (struct usb_hcd *hcd)
114{ 136{
137 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
115 usb_hcd_resume_root_hub(hcd); 138 usb_hcd_resume_root_hub(hcd);
116 return 0; 139 return 0;
117} 140}
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index d33ce3982a5f..ed550132db0b 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -717,6 +717,7 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message)
717 * at the source, so we must turn off PIRQ. 717 * at the source, so we must turn off PIRQ.
718 */ 718 */
719 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); 719 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0);
720 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
720 uhci->hc_inaccessible = 1; 721 uhci->hc_inaccessible = 1;
721 hcd->poll_rh = 0; 722 hcd->poll_rh = 0;
722 723
@@ -733,6 +734,11 @@ static int uhci_resume(struct usb_hcd *hcd)
733 734
734 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); 735 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__);
735 736
737 /* We aren't in D3 state anymore, we do that even if dead as I
738 * really don't want to keep a stale HCD_FLAG_HW_ACCESSIBLE=0
739 */
740 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
741
736 if (uhci->rh_state == UHCI_RH_RESET) /* Dead */ 742 if (uhci->rh_state == UHCI_RH_RESET) /* Dead */
737 return 0; 743 return 0;
738 spin_lock_irq(&uhci->lock); 744 spin_lock_irq(&uhci->lock);
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 25b6ca6ad081..3e470c8b4193 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -534,6 +534,12 @@ config FB_SUN3
534 bool "Sun3 framebuffer support" 534 bool "Sun3 framebuffer support"
535 depends on (FB = y) && (SUN3 || SUN3X) && BROKEN 535 depends on (FB = y) && (SUN3 || SUN3X) && BROKEN
536 536
537config FB_SBUS
538 bool "SBUS and UPA framebuffers"
539 depends on (FB = y) && (SPARC32 || SPARC64)
540 help
541 Say Y if you want support for SBUS or UPA based frame buffer device.
542
537config FB_BW2 543config FB_BW2
538 bool "BWtwo support" 544 bool "BWtwo support"
539 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3) 545 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3)
@@ -546,6 +552,7 @@ config FB_BW2
546config FB_CG3 552config FB_CG3
547 bool "CGthree support" 553 bool "CGthree support"
548 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3) 554 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3)
555 select FB_CFB_FILLRECT
549 select FB_CFB_COPYAREA 556 select FB_CFB_COPYAREA
550 select FB_CFB_IMAGEBLIT 557 select FB_CFB_IMAGEBLIT
551 help 558 help
@@ -1210,12 +1217,6 @@ config FB_AU1100
1210 1217
1211source "drivers/video/geode/Kconfig" 1218source "drivers/video/geode/Kconfig"
1212 1219
1213config FB_SBUS
1214 bool "SBUS and UPA framebuffers"
1215 depends on (FB = y) && (SPARC32 || SPARC64)
1216 help
1217 Say Y if you want support for SBUS or UPA based frame buffer device.
1218
1219config FB_FFB 1220config FB_FFB
1220 bool "Creator/Creator3D/Elite3D support" 1221 bool "Creator/Creator3D/Elite3D support"
1221 depends on FB_SBUS && SPARC64 1222 depends on FB_SBUS && SPARC64
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index 2858c5c8ba3c..e0dbdfc0c8b4 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -404,7 +404,7 @@ struct cirrusfb_info {
404 struct cirrusfb_regs currentmode; 404 struct cirrusfb_regs currentmode;
405 int blank_mode; 405 int blank_mode;
406 406
407 u32 pseudo_palette[17]; 407 u32 pseudo_palette[16];
408 struct { u8 red, green, blue, pad; } palette[256]; 408 struct { u8 red, green, blue, pad; } palette[256];
409 409
410#ifdef CONFIG_ZORRO 410#ifdef CONFIG_ZORRO
@@ -1603,14 +1603,14 @@ static int cirrusfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1603 1603
1604 switch (info->var.bits_per_pixel) { 1604 switch (info->var.bits_per_pixel) {
1605 case 8: 1605 case 8:
1606 ((u8*)(info->pseudo_palette))[regno] = v; 1606 cinfo->pseudo_palette[regno] = v;
1607 break; 1607 break;
1608 case 16: 1608 case 16:
1609 ((u16*)(info->pseudo_palette))[regno] = v; 1609 cinfo->pseudo_palette[regno] = v;
1610 break; 1610 break;
1611 case 24: 1611 case 24:
1612 case 32: 1612 case 32:
1613 ((u32*)(info->pseudo_palette))[regno] = v; 1613 cinfo->pseudo_palette[regno] = v;
1614 break; 1614 break;
1615 } 1615 }
1616 return 0; 1616 return 0;
@@ -2020,18 +2020,21 @@ static void cirrusfb_prim_fillrect(struct cirrusfb_info *cinfo,
2020 const struct fb_fillrect *region) 2020 const struct fb_fillrect *region)
2021{ 2021{
2022 int m; /* bytes per pixel */ 2022 int m; /* bytes per pixel */
2023 u32 color = (cinfo->info->fix.visual == FB_VISUAL_TRUECOLOR) ?
2024 cinfo->pseudo_palette[region->color] : region->color;
2025
2023 if(cinfo->info->var.bits_per_pixel == 1) { 2026 if(cinfo->info->var.bits_per_pixel == 1) {
2024 cirrusfb_RectFill(cinfo->regbase, cinfo->info->var.bits_per_pixel, 2027 cirrusfb_RectFill(cinfo->regbase, cinfo->info->var.bits_per_pixel,
2025 region->dx / 8, region->dy, 2028 region->dx / 8, region->dy,
2026 region->width / 8, region->height, 2029 region->width / 8, region->height,
2027 region->color, 2030 color,
2028 cinfo->currentmode.line_length); 2031 cinfo->currentmode.line_length);
2029 } else { 2032 } else {
2030 m = ( cinfo->info->var.bits_per_pixel + 7 ) / 8; 2033 m = ( cinfo->info->var.bits_per_pixel + 7 ) / 8;
2031 cirrusfb_RectFill(cinfo->regbase, cinfo->info->var.bits_per_pixel, 2034 cirrusfb_RectFill(cinfo->regbase, cinfo->info->var.bits_per_pixel,
2032 region->dx * m, region->dy, 2035 region->dx * m, region->dy,
2033 region->width * m, region->height, 2036 region->width * m, region->height,
2034 region->color, 2037 color,
2035 cinfo->currentmode.line_length); 2038 cinfo->currentmode.line_length);
2036 } 2039 }
2037 return; 2040 return;
diff --git a/drivers/video/console/fbcon_ccw.c b/drivers/video/console/fbcon_ccw.c
index 3afd1eeb1ade..4952b66ae206 100644
--- a/drivers/video/console/fbcon_ccw.c
+++ b/drivers/video/console/fbcon_ccw.c
@@ -34,7 +34,7 @@ static inline void ccw_update_attr(u8 *dst, u8 *src, int attribute,
34 msk <<= (8 - mod); 34 msk <<= (8 - mod);
35 35
36 if (offset > mod) 36 if (offset > mod)
37 set_bit(FBCON_BIT(7), (void *)&msk1); 37 msk1 |= 0x01;
38 38
39 for (i = 0; i < vc->vc_font.width; i++) { 39 for (i = 0; i < vc->vc_font.width; i++) {
40 for (j = 0; j < width; j++) { 40 for (j = 0; j < width; j++) {
diff --git a/drivers/video/console/fbcon_rotate.h b/drivers/video/console/fbcon_rotate.h
index e504fbf5c604..1b8f92fdc6a8 100644
--- a/drivers/video/console/fbcon_rotate.h
+++ b/drivers/video/console/fbcon_rotate.h
@@ -21,21 +21,13 @@
21 (s == SCROLL_REDRAW || s == SCROLL_MOVE || !(i)->fix.xpanstep) ? \ 21 (s == SCROLL_REDRAW || s == SCROLL_MOVE || !(i)->fix.xpanstep) ? \
22 (i)->var.xres : (i)->var.xres_virtual; }) 22 (i)->var.xres : (i)->var.xres_virtual; })
23 23
24/*
25 * The bitmap is always big endian
26 */
27#if defined(__LITTLE_ENDIAN)
28#define FBCON_BIT(b) (7 - (b))
29#else
30#define FBCON_BIT(b) (b)
31#endif
32 24
33static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat) 25static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat)
34{ 26{
35 u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8; 27 u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
36 28
37 pat +=index; 29 pat +=index;
38 return (test_bit(FBCON_BIT(bit), (void *)pat)); 30 return (*pat) & (0x80 >> bit);
39} 31}
40 32
41static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat) 33static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat)
@@ -43,7 +35,8 @@ static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat)
43 u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8; 35 u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
44 36
45 pat += index; 37 pat += index;
46 set_bit(FBCON_BIT(bit), (void *)pat); 38
39 (*pat) |= 0x80 >> bit;
47} 40}
48 41
49static inline void rotate_ud(const char *in, char *out, u32 width, u32 height) 42static inline void rotate_ud(const char *in, char *out, u32 width, u32 height)