Эх сурвалжийг харах

Merge branch 'master' into upstream

Jeff Garzik 19 жил өмнө
parent
commit
242898be7a
94 өөрчлөгдсөн 1133 нэмэгдсэн , 723 устгасан
  1. 4 1
      Documentation/cpu-freq/user-guide.txt
  2. 2 3
      Documentation/sysctl/kernel.txt
  3. 15 0
      MAINTAINERS
  4. 1 1
      Makefile
  5. 2 1
      arch/i386/kernel/cpu/cpufreq/Kconfig
  6. 1 2
      arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
  7. 129 92
      arch/i386/kernel/cpu/cpufreq/longhaul.c
  8. 57 29
      arch/ia64/kernel/uncached.c
  9. 7 3
      arch/sh/kernel/cpu/sh4/sq.c
  10. 1 1
      arch/x86_64/kernel/smp.c
  11. 5 8
      drivers/acpi/acpi_memhotplug.c
  12. 3 5
      drivers/char/hvsi.c
  13. 24 27
      drivers/char/hw_random/omap-rng.c
  14. 78 61
      drivers/char/keyboard.c
  15. 54 21
      drivers/cpufreq/cpufreq.c
  16. 1 0
      drivers/edac/edac_mc.h
  17. 5 2
      drivers/i2c/busses/scx200_acb.c
  18. 3 0
      drivers/ieee1394/sbp2.c
  19. 3 7
      drivers/input/evdev.c
  20. 2 2
      drivers/input/gameport/fm801-gp.c
  21. 49 17
      drivers/input/gameport/gameport.c
  22. 44 13
      drivers/input/input.c
  23. 10 9
      drivers/input/joystick/iforce/iforce-main.c
  24. 1 1
      drivers/input/joystick/spaceball.c
  25. 60 43
      drivers/input/keyboard/atkbd.c
  26. 10 10
      drivers/input/misc/wistron_btns.c
  27. 1 2
      drivers/input/mouse/logips2pp.c
  28. 34 18
      drivers/input/mouse/trackpoint.c
  29. 5 0
      drivers/input/serio/libps2.c
  30. 51 14
      drivers/input/serio/serio.c
  31. 0 1
      drivers/isdn/hardware/eicon/divasync.h
  32. 3 3
      drivers/md/linear.c
  33. 8 0
      drivers/pnp/pnpacpi/rsparser.c
  34. 99 74
      drivers/usb/input/ati_remote.c
  35. 2 1
      drivers/usb/input/hid-input.c
  36. 38 34
      drivers/usb/input/hiddev.c
  37. 3 7
      drivers/video/aty/aty128fb.c
  38. 8 10
      drivers/video/au1100fb.c
  39. 9 2
      fs/befs/linuxvfs.c
  40. 3 9
      fs/lockd/svclock.c
  41. 3 1
      fs/nfs/namespace.c
  42. 1 1
      fs/nfs/read.c
  43. 1 1
      fs/nfs/write.c
  44. 1 1
      fs/reiserfs/file.c
  45. 14 12
      fs/reiserfs/inode.c
  46. 1 1
      fs/reiserfs/ioctl.c
  47. 6 5
      fs/udf/ialloc.c
  48. 1 1
      fs/ufs/balloc.c
  49. 9 8
      fs/ufs/util.c
  50. 2 0
      include/linux/debug_locks.h
  51. 22 2
      include/linux/input.h
  52. 0 1
      include/linux/lockd/lockd.h
  53. 2 4
      include/linux/nfs_fs.h
  54. 8 0
      include/linux/sched.h
  55. 1 1
      include/linux/sunrpc/xprt.h
  56. 4 4
      include/linux/vmstat.h
  57. 1 1
      include/net/red.h
  58. 3 1
      kernel/fork.c
  59. 1 0
      kernel/futex.c
  60. 3 3
      kernel/futex_compat.c
  61. 18 8
      kernel/power/process.c
  62. 3 1
      kernel/printk.c
  63. 6 3
      kernel/resource.c
  64. 6 4
      lib/spinlock_debug.c
  65. 2 1
      mm/fadvise.c
  66. 34 10
      mm/memory_hotplug.c
  67. 1 1
      net/bridge/br_netlink.c
  68. 2 1
      net/ipv4/tcp_input.c
  69. 7 5
      net/lapb/lapb_iface.c
  70. 8 12
      net/llc/af_llc.c
  71. 2 2
      net/llc/llc_sap.c
  72. 1 1
      net/sched/sch_api.c
  73. 5 1
      net/sunrpc/cache.c
  74. 29 23
      net/sunrpc/clnt.c
  75. 4 2
      net/sunrpc/rpc_pipe.c
  76. 3 18
      net/sunrpc/xprt.c
  77. 28 1
      net/sunrpc/xprtsock.c
  78. 13 4
      sound/aoa/codecs/snd-aoa-codec-toonie.c
  79. 5 2
      sound/aoa/core/snd-aoa-gpio-feature.c
  80. 1 1
      sound/aoa/core/snd-aoa-gpio-pmf.c
  81. 1 2
      sound/core/oss/mixer_oss.c
  82. 2 0
      sound/core/oss/pcm_oss.c
  83. 1 2
      sound/core/seq/seq_device.c
  84. 3 6
      sound/core/sgbuf.c
  85. 2 5
      sound/drivers/vx/vx_pcm.c
  86. 2 2
      sound/pci/echoaudio/echoaudio.c
  87. 11 0
      sound/pci/emu10k1/emu10k1_main.c
  88. 5 1
      sound/pci/emu10k1/irq.c
  89. 1 2
      sound/ppc/awacs.c
  90. 1 2
      sound/ppc/daca.c
  91. 1 2
      sound/ppc/keywest.c
  92. 3 10
      sound/ppc/powermac.c
  93. 1 2
      sound/ppc/tumbler.c
  94. 2 4
      sound/usb/usbaudio.c

+ 4 - 1
Documentation/cpu-freq/user-guide.txt

@@ -153,10 +153,13 @@ scaling_governor,		and by "echoing" the name of another
 				that some governors won't load - they only
 				that some governors won't load - they only
 				work on some specific architectures or
 				work on some specific architectures or
 				processors.
 				processors.
-scaling_min_freq and 
+scaling_min_freq and
 scaling_max_freq		show the current "policy limits" (in
 scaling_max_freq		show the current "policy limits" (in
 				kHz). By echoing new values into these
 				kHz). By echoing new values into these
 				files, you can change these limits.
 				files, you can change these limits.
+				NOTE: when setting a policy you need to
+				first set scaling_max_freq, then
+				scaling_min_freq.
 
 
 
 
 If you have selected the "userspace" governor which allows you to
 If you have selected the "userspace" governor which allows you to

+ 2 - 3
Documentation/sysctl/kernel.txt

@@ -211,9 +211,8 @@ Controls the kernel's behaviour when an oops or BUG is encountered.
 
 
 0: try to continue operation
 0: try to continue operation
 
 
-1: delay a few seconds (to give klogd time to record the oops output) and
-   then panic.  If the `panic' sysctl is also non-zero then the machine will
-   be rebooted.
+1: panic immediatly.  If the `panic' sysctl is also non-zero then the
+   machine will be rebooted.
 
 
 ==============================================================
 ==============================================================
 
 

+ 15 - 0
MAINTAINERS

@@ -298,6 +298,13 @@ L:	info-linux@geode.amd.com
 W:	http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html
 W:	http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html
 S:	Supported
 S:	Supported
 
 
+AOA (Apple Onboard Audio) ALSA DRIVER
+P:	Johannes Berg
+M:	johannes@sipsolutions.net
+L:	linuxppc-dev@ozlabs.org
+L:	alsa-devel@alsa-project.org
+S:	Maintained
+
 APM DRIVER
 APM DRIVER
 P:	Stephen Rothwell
 P:	Stephen Rothwell
 M:	sfr@canb.auug.org.au
 M:	sfr@canb.auug.org.au
@@ -2659,6 +2666,14 @@ M:	dbrownell@users.sourceforge.net
 L:	spi-devel-general@lists.sourceforge.net
 L:	spi-devel-general@lists.sourceforge.net
 S:	Maintained
 S:	Maintained
 
 
+STABLE BRANCH:
+P:	Greg Kroah-Hartman
+M:	greg@kroah.com
+P:	Chris Wright
+M:	chrisw@sous-sol.org
+L:	stable@kernel.org
+S:	Maintained
+
 TPM DEVICE DRIVER
 TPM DEVICE DRIVER
 P:	Kylene Hall
 P:	Kylene Hall
 M:	kjhall@us.ibm.com
 M:	kjhall@us.ibm.com

+ 1 - 1
Makefile

@@ -1,7 +1,7 @@
 VERSION = 2
 VERSION = 2
 PATCHLEVEL = 6
 PATCHLEVEL = 6
 SUBLEVEL = 18
 SUBLEVEL = 18
-EXTRAVERSION = -rc3
+EXTRAVERSION = -rc4
 NAME=Crazed Snow-Weasel
 NAME=Crazed Snow-Weasel
 
 
 # *DOCUMENTATION*
 # *DOCUMENTATION*

+ 2 - 1
arch/i386/kernel/cpu/cpufreq/Kconfig

@@ -96,6 +96,7 @@ config X86_POWERNOW_K8_ACPI
 
 
 config X86_GX_SUSPMOD
 config X86_GX_SUSPMOD
 	tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation"
 	tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation"
+	depends on PCI
 	help
 	help
 	 This add the CPUFreq driver for NatSemi Geode processors which
 	 This add the CPUFreq driver for NatSemi Geode processors which
 	 support suspend modulation.
 	 support suspend modulation.
@@ -202,7 +203,7 @@ config X86_LONGRUN
 config X86_LONGHAUL
 config X86_LONGHAUL
 	tristate "VIA Cyrix III Longhaul"
 	tristate "VIA Cyrix III Longhaul"
 	select CPU_FREQ_TABLE
 	select CPU_FREQ_TABLE
-	depends on BROKEN
+	depends on ACPI_PROCESSOR
 	help
 	help
 	  This adds the CPUFreq driver for VIA Samuel/CyrixIII,
 	  This adds the CPUFreq driver for VIA Samuel/CyrixIII,
 	  VIA Cyrix Samuel/C3, VIA Cyrix Ezra and VIA Cyrix Ezra-T
 	  VIA Cyrix Samuel/C3, VIA Cyrix Ezra and VIA Cyrix Ezra-T

+ 1 - 2
arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c

@@ -384,8 +384,7 @@ static int acpi_cpufreq_early_init_acpi(void)
 	}
 	}
 
 
 	/* Do initialization in ACPI core */
 	/* Do initialization in ACPI core */
-	acpi_processor_preregister_performance(acpi_perf_data);
-	return 0;
+	return acpi_processor_preregister_performance(acpi_perf_data);
 }
 }
 
 
 static int
 static int

+ 129 - 92
arch/i386/kernel/cpu/cpufreq/longhaul.c

@@ -29,11 +29,13 @@
 #include <linux/cpufreq.h>
 #include <linux/cpufreq.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/string.h>
-#include <linux/pci.h>
 
 
 #include <asm/msr.h>
 #include <asm/msr.h>
 #include <asm/timex.h>
 #include <asm/timex.h>
 #include <asm/io.h>
 #include <asm/io.h>
+#include <asm/acpi.h>
+#include <linux/acpi.h>
+#include <acpi/processor.h>
 
 
 #include "longhaul.h"
 #include "longhaul.h"
 
 
@@ -56,6 +58,8 @@ static int minvid, maxvid;
 static unsigned int minmult, maxmult;
 static unsigned int minmult, maxmult;
 static int can_scale_voltage;
 static int can_scale_voltage;
 static int vrmrev;
 static int vrmrev;
+static struct acpi_processor *pr = NULL;
+static struct acpi_processor_cx *cx = NULL;
 
 
 /* Module parameters */
 /* Module parameters */
 static int dont_scale_voltage;
 static int dont_scale_voltage;
@@ -118,84 +122,65 @@ static int longhaul_get_cpu_mult(void)
 	return eblcr_table[invalue];
 	return eblcr_table[invalue];
 }
 }
 
 
+/* For processor with BCR2 MSR */
 
 
-static void do_powersaver(union msr_longhaul *longhaul,
-			unsigned int clock_ratio_index)
+static void do_longhaul1(int cx_address, unsigned int clock_ratio_index)
 {
 {
-	struct pci_dev *dev;
-	unsigned long flags;
-	unsigned int tmp_mask;
-	int version;
-	int i;
-	u16 pci_cmd;
-	u16 cmd_state[64];
+	union msr_bcr2 bcr2;
+	u32 t;
 
 
-	switch (cpu_model) {
-	case CPU_EZRA_T:
-		version = 3;
-		break;
-	case CPU_NEHEMIAH:
-		version = 0xf;
-		break;
-	default:
-		return;
-	}
+	rdmsrl(MSR_VIA_BCR2, bcr2.val);
+	/* Enable software clock multiplier */
+	bcr2.bits.ESOFTBF = 1;
+	bcr2.bits.CLOCKMUL = clock_ratio_index;
 
 
-	rdmsrl(MSR_VIA_LONGHAUL, longhaul->val);
-	longhaul->bits.SoftBusRatio = clock_ratio_index & 0xf;
-	longhaul->bits.SoftBusRatio4 = (clock_ratio_index & 0x10) >> 4;
-	longhaul->bits.EnableSoftBusRatio = 1;
-	longhaul->bits.RevisionKey = 0;
+	/* Sync to timer tick */
+	safe_halt();
+	ACPI_FLUSH_CPU_CACHE();
+	/* Change frequency on next halt or sleep */
+	wrmsrl(MSR_VIA_BCR2, bcr2.val);
+	/* Invoke C3 */
+	inb(cx_address);
+	/* Dummy op - must do something useless after P_LVL3 read */
+	t = inl(acpi_fadt.xpm_tmr_blk.address);
+
+	/* Disable software clock multiplier */
+	local_irq_disable();
+	rdmsrl(MSR_VIA_BCR2, bcr2.val);
+	bcr2.bits.ESOFTBF = 0;
+	wrmsrl(MSR_VIA_BCR2, bcr2.val);
+}
 
 
-	preempt_disable();
-	local_irq_save(flags);
+/* For processor with Longhaul MSR */
 
 
-	/*
-	 * get current pci bus master state for all devices
-	 * and clear bus master bit
-	 */
-	dev = NULL;
-	i = 0;
-	do {
-		dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
-		if (dev != NULL) {
-			pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
-			cmd_state[i++] = pci_cmd;
-			pci_cmd &= ~PCI_COMMAND_MASTER;
-			pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
-		}
-	} while (dev != NULL);
+static void do_powersaver(int cx_address, unsigned int clock_ratio_index)
+{
+	union msr_longhaul longhaul;
+	u32 t;
 
 
-	tmp_mask=inb(0x21);	/* works on C3. save mask. */
-	outb(0xFE,0x21);	/* TMR0 only */
-	outb(0xFF,0x80);	/* delay */
+	rdmsrl(MSR_VIA_LONGHAUL, longhaul.val);
+	longhaul.bits.RevisionKey = longhaul.bits.RevisionID;
+	longhaul.bits.SoftBusRatio = clock_ratio_index & 0xf;
+	longhaul.bits.SoftBusRatio4 = (clock_ratio_index & 0x10) >> 4;
+	longhaul.bits.EnableSoftBusRatio = 1;
 
 
+	/* Sync to timer tick */
 	safe_halt();
 	safe_halt();
-	wrmsrl(MSR_VIA_LONGHAUL, longhaul->val);
-	halt();
-
+	ACPI_FLUSH_CPU_CACHE();
+	/* Change frequency on next halt or sleep */
+	wrmsrl(MSR_VIA_LONGHAUL, longhaul.val);
+	/* Invoke C3 */
+	inb(cx_address);
+	/* Dummy op - must do something useless after P_LVL3 read */
+	t = inl(acpi_fadt.xpm_tmr_blk.address);
+
+	/* Disable bus ratio bit */
 	local_irq_disable();
 	local_irq_disable();
-
-	outb(tmp_mask,0x21);	/* restore mask */
-
-	/* restore pci bus master state for all devices */
-	dev = NULL;
-	i = 0;
-	do {
-		dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
-		if (dev != NULL) {
-			pci_cmd = cmd_state[i++];
-			pci_write_config_byte(dev, PCI_COMMAND, pci_cmd);
-		}
-	} while (dev != NULL);
-	local_irq_restore(flags);
-	preempt_enable();
-
-	/* disable bus ratio bit */
-	rdmsrl(MSR_VIA_LONGHAUL, longhaul->val);
-	longhaul->bits.EnableSoftBusRatio = 0;
-	longhaul->bits.RevisionKey = version;
-	wrmsrl(MSR_VIA_LONGHAUL, longhaul->val);
+	longhaul.bits.RevisionKey = longhaul.bits.RevisionID;
+	longhaul.bits.EnableSoftBusRatio = 0;
+	longhaul.bits.EnableSoftBSEL = 0;
+	longhaul.bits.EnableSoftVID = 0;
+	wrmsrl(MSR_VIA_LONGHAUL, longhaul.val);
 }
 }
 
 
 /**
 /**
@@ -209,9 +194,9 @@ static void longhaul_setstate(unsigned int clock_ratio_index)
 {
 {
 	int speed, mult;
 	int speed, mult;
 	struct cpufreq_freqs freqs;
 	struct cpufreq_freqs freqs;
-	union msr_longhaul longhaul;
-	union msr_bcr2 bcr2;
 	static unsigned int old_ratio=-1;
 	static unsigned int old_ratio=-1;
+	unsigned long flags;
+	unsigned int pic1_mask, pic2_mask;
 
 
 	if (old_ratio == clock_ratio_index)
 	if (old_ratio == clock_ratio_index)
 		return;
 		return;
@@ -234,6 +219,20 @@ static void longhaul_setstate(unsigned int clock_ratio_index)
 	dprintk ("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n",
 	dprintk ("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n",
 			fsb, mult/10, mult%10, print_speed(speed/1000));
 			fsb, mult/10, mult%10, print_speed(speed/1000));
 
 
+	preempt_disable();
+	local_irq_save(flags);
+
+	pic2_mask = inb(0xA1);
+	pic1_mask = inb(0x21);	/* works on C3. save mask. */
+	outb(0xFF,0xA1);	/* Overkill */
+	outb(0xFE,0x21);	/* TMR0 only */
+
+	/* Disable bus master arbitration */
+	if (pr->flags.bm_check) {
+		acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1,
+				  ACPI_MTX_DO_NOT_LOCK);
+	}
+
 	switch (longhaul_version) {
 	switch (longhaul_version) {
 
 
 	/*
 	/*
@@ -245,20 +244,7 @@ static void longhaul_setstate(unsigned int clock_ratio_index)
 	 */
 	 */
 	case TYPE_LONGHAUL_V1:
 	case TYPE_LONGHAUL_V1:
 	case TYPE_LONGHAUL_V2:
 	case TYPE_LONGHAUL_V2:
-		rdmsrl (MSR_VIA_BCR2, bcr2.val);
-		/* Enable software clock multiplier */
-		bcr2.bits.ESOFTBF = 1;
-		bcr2.bits.CLOCKMUL = clock_ratio_index;
-		local_irq_disable();
-		wrmsrl (MSR_VIA_BCR2, bcr2.val);
-		safe_halt();
-
-		/* Disable software clock multiplier */
-		rdmsrl (MSR_VIA_BCR2, bcr2.val);
-		bcr2.bits.ESOFTBF = 0;
-		local_irq_disable();
-		wrmsrl (MSR_VIA_BCR2, bcr2.val);
-		local_irq_enable();
+		do_longhaul1(cx->address, clock_ratio_index);
 		break;
 		break;
 
 
 	/*
 	/*
@@ -273,10 +259,22 @@ static void longhaul_setstate(unsigned int clock_ratio_index)
 	 * to work in practice.
 	 * to work in practice.
 	 */
 	 */
 	case TYPE_POWERSAVER:
 	case TYPE_POWERSAVER:
-		do_powersaver(&longhaul, clock_ratio_index);
+		do_powersaver(cx->address, clock_ratio_index);
 		break;
 		break;
 	}
 	}
 
 
+	/* Enable bus master arbitration */
+	if (pr->flags.bm_check) {
+		acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0,
+				  ACPI_MTX_DO_NOT_LOCK);
+	}
+
+	outb(pic2_mask,0xA1);	/* restore mask */
+	outb(pic1_mask,0x21);
+
+	local_irq_restore(flags);
+	preempt_enable();
+
 	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
 	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
 }
 }
 
 
@@ -324,9 +322,11 @@ static int guess_fsb(void)
 static int __init longhaul_get_ranges(void)
 static int __init longhaul_get_ranges(void)
 {
 {
 	unsigned long invalue;
 	unsigned long invalue;
-	unsigned int multipliers[32]= {
-		50,30,40,100,55,35,45,95,90,70,80,60,120,75,85,65,
-		-1,110,120,-1,135,115,125,105,130,150,160,140,-1,155,-1,145 };
+	unsigned int ezra_t_multipliers[32]= {
+			90,  30,  40, 100,  55,  35,  45,  95,
+			50,  70,  80,  60, 120,  75,  85,  65,
+			-1, 110, 120,  -1, 135, 115, 125, 105,
+			130, 150, 160, 140,  -1, 155,  -1, 145 };
 	unsigned int j, k = 0;
 	unsigned int j, k = 0;
 	union msr_longhaul longhaul;
 	union msr_longhaul longhaul;
 	unsigned long lo, hi;
 	unsigned long lo, hi;
@@ -355,13 +355,13 @@ static int __init longhaul_get_ranges(void)
 			invalue = longhaul.bits.MaxMHzBR;
 			invalue = longhaul.bits.MaxMHzBR;
 			if (longhaul.bits.MaxMHzBR4)
 			if (longhaul.bits.MaxMHzBR4)
 				invalue += 16;
 				invalue += 16;
-			maxmult=multipliers[invalue];
+			maxmult=ezra_t_multipliers[invalue];
 
 
 			invalue = longhaul.bits.MinMHzBR;
 			invalue = longhaul.bits.MinMHzBR;
 			if (longhaul.bits.MinMHzBR4 == 1)
 			if (longhaul.bits.MinMHzBR4 == 1)
 				minmult = 30;
 				minmult = 30;
 			else
 			else
-				minmult = multipliers[invalue];
+				minmult = ezra_t_multipliers[invalue];
 			fsb = eblcr_fsb_table_v2[longhaul.bits.MaxMHzFSB];
 			fsb = eblcr_fsb_table_v2[longhaul.bits.MaxMHzFSB];
 			break;
 			break;
 		}
 		}
@@ -527,6 +527,18 @@ static unsigned int longhaul_get(unsigned int cpu)
 	return calc_speed(longhaul_get_cpu_mult());
 	return calc_speed(longhaul_get_cpu_mult());
 }
 }
 
 
+static acpi_status longhaul_walk_callback(acpi_handle obj_handle,
+					  u32 nesting_level,
+					  void *context, void **return_value)
+{
+	struct acpi_device *d;
+
+	if ( acpi_bus_get_device(obj_handle, &d) ) {
+		return 0;
+	}
+	*return_value = (void *)acpi_driver_data(d);
+	return 1;
+}
 
 
 static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
 static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
 {
 {
@@ -534,6 +546,15 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
 	char *cpuname=NULL;
 	char *cpuname=NULL;
 	int ret;
 	int ret;
 
 
+	/* Check ACPI support for C3 state */
+	acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+			 &longhaul_walk_callback, NULL, (void *)&pr);
+	if (pr == NULL) goto err_acpi;
+
+	cx = &pr->power.states[ACPI_STATE_C3];
+	if (cx->address == 0 || cx->latency > 1000) goto err_acpi;
+
+	/* Now check what we have on this motherboard */
 	switch (c->x86_model) {
 	switch (c->x86_model) {
 	case 6:
 	case 6:
 		cpu_model = CPU_SAMUEL;
 		cpu_model = CPU_SAMUEL;
@@ -634,6 +655,10 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
 	cpufreq_frequency_table_get_attr(longhaul_table, policy->cpu);
 	cpufreq_frequency_table_get_attr(longhaul_table, policy->cpu);
 
 
 	return 0;
 	return 0;
+
+err_acpi:
+	printk(KERN_ERR PFX "No ACPI support for CPU frequency changes.\n");
+	return -ENODEV;
 }
 }
 
 
 static int __devexit longhaul_cpu_exit(struct cpufreq_policy *policy)
 static int __devexit longhaul_cpu_exit(struct cpufreq_policy *policy)
@@ -666,6 +691,18 @@ static int __init longhaul_init(void)
 	if (c->x86_vendor != X86_VENDOR_CENTAUR || c->x86 != 6)
 	if (c->x86_vendor != X86_VENDOR_CENTAUR || c->x86 != 6)
 		return -ENODEV;
 		return -ENODEV;
 
 
+#ifdef CONFIG_SMP
+	if (num_online_cpus() > 1) {
+		return -ENODEV;
+		printk(KERN_ERR PFX "More than 1 CPU detected, longhaul disabled.\n");
+	}
+#endif
+#ifdef CONFIG_X86_IO_APIC
+	if (cpu_has_apic) {
+		printk(KERN_ERR PFX "APIC detected. Longhaul is currently broken in this configuration.\n");
+		return -ENODEV;
+	}
+#endif
 	switch (c->x86_model) {
 	switch (c->x86_model) {
 	case 6 ... 9:
 	case 6 ... 9:
 		return cpufreq_register_driver(&longhaul_driver);
 		return cpufreq_register_driver(&longhaul_driver);
@@ -699,6 +736,6 @@ MODULE_AUTHOR ("Dave Jones <davej@codemonkey.org.uk>");
 MODULE_DESCRIPTION ("Longhaul driver for VIA Cyrix processors.");
 MODULE_DESCRIPTION ("Longhaul driver for VIA Cyrix processors.");
 MODULE_LICENSE ("GPL");
 MODULE_LICENSE ("GPL");
 
 
-module_init(longhaul_init);
+late_initcall(longhaul_init);
 module_exit(longhaul_exit);
 module_exit(longhaul_exit);
 
 

+ 57 - 29
arch/ia64/kernel/uncached.c

@@ -32,32 +32,38 @@
 
 
 extern void __init efi_memmap_walk_uc(efi_freemem_callback_t, void *);
 extern void __init efi_memmap_walk_uc(efi_freemem_callback_t, void *);
 
 
-#define MAX_UNCACHED_GRANULES	5
-static int allocated_granules;
+struct uncached_pool {
+	struct gen_pool *pool;
+	struct mutex add_chunk_mutex;	/* serialize adding a converted chunk */
+	int nchunks_added;		/* #of converted chunks added to pool */
+	atomic_t status;		/* smp called function's return status*/
+};
+
+#define MAX_CONVERTED_CHUNKS_PER_NODE	2
 
 
-struct gen_pool *uncached_pool[MAX_NUMNODES];
+struct uncached_pool uncached_pools[MAX_NUMNODES];
 
 
 
 
 static void uncached_ipi_visibility(void *data)
 static void uncached_ipi_visibility(void *data)
 {
 {
 	int status;
 	int status;
+	struct uncached_pool *uc_pool = (struct uncached_pool *)data;
 
 
 	status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL);
 	status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL);
 	if ((status != PAL_VISIBILITY_OK) &&
 	if ((status != PAL_VISIBILITY_OK) &&
 	    (status != PAL_VISIBILITY_OK_REMOTE_NEEDED))
 	    (status != PAL_VISIBILITY_OK_REMOTE_NEEDED))
-		printk(KERN_DEBUG "pal_prefetch_visibility() returns %i on "
-		       "CPU %i\n", status, raw_smp_processor_id());
+		atomic_inc(&uc_pool->status);
 }
 }
 
 
 
 
 static void uncached_ipi_mc_drain(void *data)
 static void uncached_ipi_mc_drain(void *data)
 {
 {
 	int status;
 	int status;
+	struct uncached_pool *uc_pool = (struct uncached_pool *)data;
 
 
 	status = ia64_pal_mc_drain();
 	status = ia64_pal_mc_drain();
-	if (status)
-		printk(KERN_WARNING "ia64_pal_mc_drain() failed with %i on "
-		       "CPU %i\n", status, raw_smp_processor_id());
+	if (status != PAL_STATUS_SUCCESS)
+		atomic_inc(&uc_pool->status);
 }
 }
 
 
 
 
@@ -70,21 +76,34 @@ static void uncached_ipi_mc_drain(void *data)
  * This is accomplished by first allocating a granule of cached memory pages
  * This is accomplished by first allocating a granule of cached memory pages
  * and then converting them to uncached memory pages.
  * and then converting them to uncached memory pages.
  */
  */
-static int uncached_add_chunk(struct gen_pool *pool, int nid)
+static int uncached_add_chunk(struct uncached_pool *uc_pool, int nid)
 {
 {
 	struct page *page;
 	struct page *page;
-	int status, i;
+	int status, i, nchunks_added = uc_pool->nchunks_added;
 	unsigned long c_addr, uc_addr;
 	unsigned long c_addr, uc_addr;
 
 
-	if (allocated_granules >= MAX_UNCACHED_GRANULES)
+	if (mutex_lock_interruptible(&uc_pool->add_chunk_mutex) != 0)
+		return -1;	/* interrupted by a signal */
+
+	if (uc_pool->nchunks_added > nchunks_added) {
+		/* someone added a new chunk while we were waiting */
+		mutex_unlock(&uc_pool->add_chunk_mutex);
+		return 0;
+	}
+
+	if (uc_pool->nchunks_added >= MAX_CONVERTED_CHUNKS_PER_NODE) {
+		mutex_unlock(&uc_pool->add_chunk_mutex);
 		return -1;
 		return -1;
+	}
 
 
 	/* attempt to allocate a granule's worth of cached memory pages */
 	/* attempt to allocate a granule's worth of cached memory pages */
 
 
 	page = alloc_pages_node(nid, GFP_KERNEL | __GFP_ZERO,
 	page = alloc_pages_node(nid, GFP_KERNEL | __GFP_ZERO,
 				IA64_GRANULE_SHIFT-PAGE_SHIFT);
 				IA64_GRANULE_SHIFT-PAGE_SHIFT);
-	if (!page)
+	if (!page) {
+		mutex_unlock(&uc_pool->add_chunk_mutex);
 		return -1;
 		return -1;
+	}
 
 
 	/* convert the memory pages from cached to uncached */
 	/* convert the memory pages from cached to uncached */
 
 
@@ -102,11 +121,14 @@ static int uncached_add_chunk(struct gen_pool *pool, int nid)
 	flush_tlb_kernel_range(uc_addr, uc_adddr + IA64_GRANULE_SIZE);
 	flush_tlb_kernel_range(uc_addr, uc_adddr + IA64_GRANULE_SIZE);
 
 
 	status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL);
 	status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL);
-	if (!status) {
-		status = smp_call_function(uncached_ipi_visibility, NULL, 0, 1);
-		if (status)
+	if (status == PAL_VISIBILITY_OK_REMOTE_NEEDED) {
+		atomic_set(&uc_pool->status, 0);
+		status = smp_call_function(uncached_ipi_visibility, uc_pool,
+					   0, 1);
+		if (status || atomic_read(&uc_pool->status))
 			goto failed;
 			goto failed;
-	}
+	} else if (status != PAL_VISIBILITY_OK)
+		goto failed;
 
 
 	preempt_disable();
 	preempt_disable();
 
 
@@ -120,20 +142,24 @@ static int uncached_add_chunk(struct gen_pool *pool, int nid)
 
 
 	preempt_enable();
 	preempt_enable();
 
 
-	ia64_pal_mc_drain();
-	status = smp_call_function(uncached_ipi_mc_drain, NULL, 0, 1);
-	if (status)
+	status = ia64_pal_mc_drain();
+	if (status != PAL_STATUS_SUCCESS)
+		goto failed;
+	atomic_set(&uc_pool->status, 0);
+	status = smp_call_function(uncached_ipi_mc_drain, uc_pool, 0, 1);
+	if (status || atomic_read(&uc_pool->status))
 		goto failed;
 		goto failed;
 
 
 	/*
 	/*
 	 * The chunk of memory pages has been converted to uncached so now we
 	 * The chunk of memory pages has been converted to uncached so now we
 	 * can add it to the pool.
 	 * can add it to the pool.
 	 */
 	 */
-	status = gen_pool_add(pool, uc_addr, IA64_GRANULE_SIZE, nid);
+	status = gen_pool_add(uc_pool->pool, uc_addr, IA64_GRANULE_SIZE, nid);
 	if (status)
 	if (status)
 		goto failed;
 		goto failed;
 
 
-	allocated_granules++;
+	uc_pool->nchunks_added++;
+	mutex_unlock(&uc_pool->add_chunk_mutex);
 	return 0;
 	return 0;
 
 
 	/* failed to convert or add the chunk so give it back to the kernel */
 	/* failed to convert or add the chunk so give it back to the kernel */
@@ -142,6 +168,7 @@ failed:
 		ClearPageUncached(&page[i]);
 		ClearPageUncached(&page[i]);
 
 
 	free_pages(c_addr, IA64_GRANULE_SHIFT-PAGE_SHIFT);
 	free_pages(c_addr, IA64_GRANULE_SHIFT-PAGE_SHIFT);
+	mutex_unlock(&uc_pool->add_chunk_mutex);
 	return -1;
 	return -1;
 }
 }
 
 
@@ -158,7 +185,7 @@ failed:
 unsigned long uncached_alloc_page(int starting_nid)
 unsigned long uncached_alloc_page(int starting_nid)
 {
 {
 	unsigned long uc_addr;
 	unsigned long uc_addr;
-	struct gen_pool *pool;
+	struct uncached_pool *uc_pool;
 	int nid;
 	int nid;
 
 
 	if (unlikely(starting_nid >= MAX_NUMNODES))
 	if (unlikely(starting_nid >= MAX_NUMNODES))
@@ -171,14 +198,14 @@ unsigned long uncached_alloc_page(int starting_nid)
 	do {
 	do {
 		if (!node_online(nid))
 		if (!node_online(nid))
 			continue;
 			continue;
-		pool = uncached_pool[nid];
-		if (pool == NULL)
+		uc_pool = &uncached_pools[nid];
+		if (uc_pool->pool == NULL)
 			continue;
 			continue;
 		do {
 		do {
-			uc_addr = gen_pool_alloc(pool, PAGE_SIZE);
+			uc_addr = gen_pool_alloc(uc_pool->pool, PAGE_SIZE);
 			if (uc_addr != 0)
 			if (uc_addr != 0)
 				return uc_addr;
 				return uc_addr;
-		} while (uncached_add_chunk(pool, nid) == 0);
+		} while (uncached_add_chunk(uc_pool, nid) == 0);
 
 
 	} while ((nid = (nid + 1) % MAX_NUMNODES) != starting_nid);
 	} while ((nid = (nid + 1) % MAX_NUMNODES) != starting_nid);
 
 
@@ -197,7 +224,7 @@ EXPORT_SYMBOL(uncached_alloc_page);
 void uncached_free_page(unsigned long uc_addr)
 void uncached_free_page(unsigned long uc_addr)
 {
 {
 	int nid = paddr_to_nid(uc_addr - __IA64_UNCACHED_OFFSET);
 	int nid = paddr_to_nid(uc_addr - __IA64_UNCACHED_OFFSET);
-	struct gen_pool *pool = uncached_pool[nid];
+	struct gen_pool *pool = uncached_pools[nid].pool;
 
 
 	if (unlikely(pool == NULL))
 	if (unlikely(pool == NULL))
 		return;
 		return;
@@ -224,7 +251,7 @@ static int __init uncached_build_memmap(unsigned long uc_start,
 					unsigned long uc_end, void *arg)
 					unsigned long uc_end, void *arg)
 {
 {
 	int nid = paddr_to_nid(uc_start - __IA64_UNCACHED_OFFSET);
 	int nid = paddr_to_nid(uc_start - __IA64_UNCACHED_OFFSET);
-	struct gen_pool *pool = uncached_pool[nid];
+	struct gen_pool *pool = uncached_pools[nid].pool;
 	size_t size = uc_end - uc_start;
 	size_t size = uc_end - uc_start;
 
 
 	touch_softlockup_watchdog();
 	touch_softlockup_watchdog();
@@ -242,7 +269,8 @@ static int __init uncached_init(void)
 	int nid;
 	int nid;
 
 
 	for_each_online_node(nid) {
 	for_each_online_node(nid) {
-		uncached_pool[nid] = gen_pool_create(PAGE_SHIFT, nid);
+		uncached_pools[nid].pool = gen_pool_create(PAGE_SHIFT, nid);
+		mutex_init(&uncached_pools[nid].add_chunk_mutex);
 	}
 	}
 
 
 	efi_memmap_walk_uc(uncached_build_memmap, NULL);
 	efi_memmap_walk_uc(uncached_build_memmap, NULL);

+ 7 - 3
arch/sh/kernel/cpu/sh4/sq.c

@@ -421,18 +421,22 @@ static struct miscdevice sq_dev = {
 
 
 static int __init sq_api_init(void)
 static int __init sq_api_init(void)
 {
 {
+	int ret;
 	printk(KERN_NOTICE "sq: Registering store queue API.\n");
 	printk(KERN_NOTICE "sq: Registering store queue API.\n");
 
 
-#ifdef CONFIG_PROC_FS
 	create_proc_read_entry("sq_mapping", 0, 0, sq_mapping_read_proc, 0);
 	create_proc_read_entry("sq_mapping", 0, 0, sq_mapping_read_proc, 0);
-#endif
 
 
-	return misc_register(&sq_dev);
+	ret = misc_register(&sq_dev);
+	if (ret)
+		remove_proc_entry("sq_mapping", NULL);
+
+	return ret;
 }
 }
 
 
 static void __exit sq_api_exit(void)
 static void __exit sq_api_exit(void)
 {
 {
 	misc_deregister(&sq_dev);
 	misc_deregister(&sq_dev);
+	remove_proc_entry("sq_mapping", NULL);
 }
 }
 
 
 module_init(sq_api_init);
 module_init(sq_api_init);

+ 1 - 1
arch/x86_64/kernel/smp.c

@@ -203,7 +203,7 @@ int __cpuinit init_smp_flush(void)
 {
 {
 	int i;
 	int i;
 	for_each_cpu_mask(i, cpu_possible_map) {
 	for_each_cpu_mask(i, cpu_possible_map) {
-		spin_lock_init(&per_cpu(flush_state.tlbstate_lock, i));
+		spin_lock_init(&per_cpu(flush_state, i).tlbstate_lock);
 	}
 	}
 	return 0;
 	return 0;
 }
 }

+ 5 - 8
drivers/acpi/acpi_memhotplug.c

@@ -129,11 +129,15 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
 	struct acpi_memory_info *info, *n;
 	struct acpi_memory_info *info, *n;
 
 
 
 
+	if (!list_empty(&mem_device->res_list))
+		return 0;
+
 	status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS,
 	status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS,
 				     acpi_memory_get_resource, mem_device);
 				     acpi_memory_get_resource, mem_device);
 	if (ACPI_FAILURE(status)) {
 	if (ACPI_FAILURE(status)) {
 		list_for_each_entry_safe(info, n, &mem_device->res_list, list)
 		list_for_each_entry_safe(info, n, &mem_device->res_list, list)
 			kfree(info);
 			kfree(info);
+		INIT_LIST_HEAD(&mem_device->res_list);
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 
@@ -230,17 +234,10 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
 	 * (i.e. memory-hot-remove function)
 	 * (i.e. memory-hot-remove function)
 	 */
 	 */
 	list_for_each_entry(info, &mem_device->res_list, list) {
 	list_for_each_entry(info, &mem_device->res_list, list) {
-		u64 start_pfn, end_pfn;
-
-		start_pfn = info->start_addr >> PAGE_SHIFT;
-		end_pfn = (info->start_addr + info->length - 1) >> PAGE_SHIFT;
-
-		if (pfn_valid(start_pfn) || pfn_valid(end_pfn)) {
-			/* already enabled. try next area */
+		if (info->enabled) { /* just sanity check...*/
 			num_enabled++;
 			num_enabled++;
 			continue;
 			continue;
 		}
 		}
-
 		result = add_memory(node, info->start_addr, info->length);
 		result = add_memory(node, info->start_addr, info->length);
 		if (result)
 		if (result)
 			continue;
 			continue;

+ 3 - 5
drivers/char/hvsi.c

@@ -311,7 +311,8 @@ static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet,
 				/* CD went away; no more connection */
 				/* CD went away; no more connection */
 				pr_debug("hvsi%i: CD dropped\n", hp->index);
 				pr_debug("hvsi%i: CD dropped\n", hp->index);
 				hp->mctrl &= TIOCM_CD;
 				hp->mctrl &= TIOCM_CD;
-				if (!(hp->tty->flags & CLOCAL))
+				/* If userland hasn't done an open(2) yet, hp->tty is NULL. */
+				if (hp->tty && !(hp->tty->flags & CLOCAL))
 					*to_hangup = hp->tty;
 					*to_hangup = hp->tty;
 			}
 			}
 			break;
 			break;
@@ -986,10 +987,7 @@ static void hvsi_write_worker(void *arg)
 		start_j = 0;
 		start_j = 0;
 #endif /* DEBUG */
 #endif /* DEBUG */
 		wake_up_all(&hp->emptyq);
 		wake_up_all(&hp->emptyq);
-		if (test_bit(TTY_DO_WRITE_WAKEUP, &hp->tty->flags)
-				&& hp->tty->ldisc.write_wakeup)
-			hp->tty->ldisc.write_wakeup(hp->tty);
-		wake_up_interruptible(&hp->tty->write_wait);
+		tty_wakeup(hp->tty);
 	}
 	}
 
 
 out:
 out:

+ 24 - 27
drivers/char/hw_random/omap-rng.c

@@ -25,12 +25,12 @@
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/random.h>
 #include <linux/random.h>
+#include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/err.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/hw_random.h>
 #include <linux/hw_random.h>
 
 
 #include <asm/io.h>
 #include <asm/io.h>
-#include <asm/hardware/clock.h>
 
 
 #define RNG_OUT_REG		0x00		/* Output register */
 #define RNG_OUT_REG		0x00		/* Output register */
 #define RNG_STAT_REG		0x04		/* Status register
 #define RNG_STAT_REG		0x04		/* Status register
@@ -52,7 +52,7 @@
 
 
 static void __iomem *rng_base;
 static void __iomem *rng_base;
 static struct clk *rng_ick;
 static struct clk *rng_ick;
-static struct device *rng_dev;
+static struct platform_device *rng_dev;
 
 
 static u32 omap_rng_read_reg(int reg)
 static u32 omap_rng_read_reg(int reg)
 {
 {
@@ -83,9 +83,8 @@ static struct hwrng omap_rng_ops = {
 	.data_read	= omap_rng_data_read,
 	.data_read	= omap_rng_data_read,
 };
 };
 
 
-static int __init omap_rng_probe(struct device *dev)
+static int __init omap_rng_probe(struct platform_device *pdev)
 {
 {
-	struct platform_device *pdev = to_platform_device(dev);
 	struct resource *res, *mem;
 	struct resource *res, *mem;
 	int ret;
 	int ret;
 
 
@@ -95,16 +94,14 @@ static int __init omap_rng_probe(struct device *dev)
 	 */
 	 */
 	BUG_ON(rng_dev);
 	BUG_ON(rng_dev);
 
 
-    	if (cpu_is_omap24xx()) {
+	if (cpu_is_omap24xx()) {
 		rng_ick = clk_get(NULL, "rng_ick");
 		rng_ick = clk_get(NULL, "rng_ick");
 		if (IS_ERR(rng_ick)) {
 		if (IS_ERR(rng_ick)) {
-			dev_err(dev, "Could not get rng_ick\n");
+			dev_err(&pdev->dev, "Could not get rng_ick\n");
 			ret = PTR_ERR(rng_ick);
 			ret = PTR_ERR(rng_ick);
 			return ret;
 			return ret;
-		}
-		else {
-			clk_use(rng_ick);
-		}
+		} else
+			clk_enable(rng_ick);
 	}
 	}
 
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -117,7 +114,7 @@ static int __init omap_rng_probe(struct device *dev)
 	if (mem == NULL)
 	if (mem == NULL)
 		return -EBUSY;
 		return -EBUSY;
 
 
-	dev_set_drvdata(dev, mem);
+	dev_set_drvdata(&pdev->dev, mem);
 	rng_base = (u32 __iomem *)io_p2v(res->start);
 	rng_base = (u32 __iomem *)io_p2v(res->start);
 
 
 	ret = hwrng_register(&omap_rng_ops);
 	ret = hwrng_register(&omap_rng_ops);
@@ -127,25 +124,25 @@ static int __init omap_rng_probe(struct device *dev)
 		return ret;
 		return ret;
 	}
 	}
 
 
-	dev_info(dev, "OMAP Random Number Generator ver. %02x\n",
+	dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n",
 		omap_rng_read_reg(RNG_REV_REG));
 		omap_rng_read_reg(RNG_REV_REG));
 	omap_rng_write_reg(RNG_MASK_REG, 0x1);
 	omap_rng_write_reg(RNG_MASK_REG, 0x1);
 
 
-	rng_dev = dev;
+	rng_dev = pdev;
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-static int __exit omap_rng_remove(struct device *dev)
+static int __exit omap_rng_remove(struct platform_device *pdev)
 {
 {
-	struct resource *mem = dev_get_drvdata(dev);
+	struct resource *mem = dev_get_drvdata(&pdev->dev);
 
 
 	hwrng_unregister(&omap_rng_ops);
 	hwrng_unregister(&omap_rng_ops);
 
 
 	omap_rng_write_reg(RNG_MASK_REG, 0x0);
 	omap_rng_write_reg(RNG_MASK_REG, 0x0);
 
 
 	if (cpu_is_omap24xx()) {
 	if (cpu_is_omap24xx()) {
-		clk_unuse(rng_ick);
+		clk_disable(rng_ick);
 		clk_put(rng_ick);
 		clk_put(rng_ick);
 	}
 	}
 
 
@@ -157,18 +154,16 @@ static int __exit omap_rng_remove(struct device *dev)
 
 
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM
 
 
-static int omap_rng_suspend(struct device *dev, pm_message_t message, u32 level)
+static int omap_rng_suspend(struct platform_device *pdev, pm_message_t message)
 {
 {
 	omap_rng_write_reg(RNG_MASK_REG, 0x0);
 	omap_rng_write_reg(RNG_MASK_REG, 0x0);
-
 	return 0;
 	return 0;
 }
 }
 
 
-static int omap_rng_resume(struct device *dev, pm_message_t message, u32 level)
+static int omap_rng_resume(struct platform_device *pdev)
 {
 {
 	omap_rng_write_reg(RNG_MASK_REG, 0x1);
 	omap_rng_write_reg(RNG_MASK_REG, 0x1);
-
-	return 1;
+	return 0;
 }
 }
 
 
 #else
 #else
@@ -179,9 +174,11 @@ static int omap_rng_resume(struct device *dev, pm_message_t message, u32 level)
 #endif
 #endif
 
 
 
 
-static struct device_driver omap_rng_driver = {
-	.name		= "omap_rng",
-	.bus		= &platform_bus_type,
+static struct platform_driver omap_rng_driver = {
+	.driver = {
+		.name		= "omap_rng",
+		.owner		= THIS_MODULE,
+	},
 	.probe		= omap_rng_probe,
 	.probe		= omap_rng_probe,
 	.remove		= __exit_p(omap_rng_remove),
 	.remove		= __exit_p(omap_rng_remove),
 	.suspend	= omap_rng_suspend,
 	.suspend	= omap_rng_suspend,
@@ -193,12 +190,12 @@ static int __init omap_rng_init(void)
 	if (!cpu_is_omap16xx() && !cpu_is_omap24xx())
 	if (!cpu_is_omap16xx() && !cpu_is_omap24xx())
 		return -ENODEV;
 		return -ENODEV;
 
 
-	return driver_register(&omap_rng_driver);
+	return platform_driver_register(&omap_rng_driver);
 }
 }
 
 
 static void __exit omap_rng_exit(void)
 static void __exit omap_rng_exit(void)
 {
 {
-	driver_unregister(&omap_rng_driver);
+	platform_driver_unregister(&omap_rng_driver);
 }
 }
 
 
 module_init(omap_rng_init);
 module_init(omap_rng_init);

+ 78 - 61
drivers/char/keyboard.c

@@ -107,7 +107,6 @@ const int NR_TYPES = ARRAY_SIZE(max_vals);
 
 
 struct kbd_struct kbd_table[MAX_NR_CONSOLES];
 struct kbd_struct kbd_table[MAX_NR_CONSOLES];
 static struct kbd_struct *kbd = kbd_table;
 static struct kbd_struct *kbd = kbd_table;
-static struct kbd_struct kbd0;
 
 
 int spawnpid, spawnsig;
 int spawnpid, spawnsig;
 
 
@@ -223,13 +222,13 @@ static void kd_nosound(unsigned long ignored)
 {
 {
 	struct list_head *node;
 	struct list_head *node;
 
 
-	list_for_each(node,&kbd_handler.h_list) {
+	list_for_each(node, &kbd_handler.h_list) {
 		struct input_handle *handle = to_handle_h(node);
 		struct input_handle *handle = to_handle_h(node);
 		if (test_bit(EV_SND, handle->dev->evbit)) {
 		if (test_bit(EV_SND, handle->dev->evbit)) {
 			if (test_bit(SND_TONE, handle->dev->sndbit))
 			if (test_bit(SND_TONE, handle->dev->sndbit))
-				input_event(handle->dev, EV_SND, SND_TONE, 0);
+				input_inject_event(handle, EV_SND, SND_TONE, 0);
 			if (test_bit(SND_BELL, handle->dev->sndbit))
 			if (test_bit(SND_BELL, handle->dev->sndbit))
-				input_event(handle->dev, EV_SND, SND_BELL, 0);
+				input_inject_event(handle, EV_SND, SND_BELL, 0);
 		}
 		}
 	}
 	}
 }
 }
@@ -247,11 +246,11 @@ void kd_mksound(unsigned int hz, unsigned int ticks)
 			struct input_handle *handle = to_handle_h(node);
 			struct input_handle *handle = to_handle_h(node);
 			if (test_bit(EV_SND, handle->dev->evbit)) {
 			if (test_bit(EV_SND, handle->dev->evbit)) {
 				if (test_bit(SND_TONE, handle->dev->sndbit)) {
 				if (test_bit(SND_TONE, handle->dev->sndbit)) {
-					input_event(handle->dev, EV_SND, SND_TONE, hz);
+					input_inject_event(handle, EV_SND, SND_TONE, hz);
 					break;
 					break;
 				}
 				}
 				if (test_bit(SND_BELL, handle->dev->sndbit)) {
 				if (test_bit(SND_BELL, handle->dev->sndbit)) {
-					input_event(handle->dev, EV_SND, SND_BELL, 1);
+					input_inject_event(handle, EV_SND, SND_BELL, 1);
 					break;
 					break;
 				}
 				}
 			}
 			}
@@ -272,15 +271,15 @@ int kbd_rate(struct kbd_repeat *rep)
 	unsigned int d = 0;
 	unsigned int d = 0;
 	unsigned int p = 0;
 	unsigned int p = 0;
 
 
-	list_for_each(node,&kbd_handler.h_list) {
+	list_for_each(node, &kbd_handler.h_list) {
 		struct input_handle *handle = to_handle_h(node);
 		struct input_handle *handle = to_handle_h(node);
 		struct input_dev *dev = handle->dev;
 		struct input_dev *dev = handle->dev;
 
 
 		if (test_bit(EV_REP, dev->evbit)) {
 		if (test_bit(EV_REP, dev->evbit)) {
 			if (rep->delay > 0)
 			if (rep->delay > 0)
-				input_event(dev, EV_REP, REP_DELAY, rep->delay);
+				input_inject_event(handle, EV_REP, REP_DELAY, rep->delay);
 			if (rep->period > 0)
 			if (rep->period > 0)
-				input_event(dev, EV_REP, REP_PERIOD, rep->period);
+				input_inject_event(handle, EV_REP, REP_PERIOD, rep->period);
 			d = dev->rep[REP_DELAY];
 			d = dev->rep[REP_DELAY];
 			p = dev->rep[REP_PERIOD];
 			p = dev->rep[REP_PERIOD];
 		}
 		}
@@ -988,7 +987,7 @@ static inline unsigned char getleds(void)
  * interrupt routines for this thing allows us to easily mask
  * interrupt routines for this thing allows us to easily mask
  * this when we don't want any of the above to happen.
  * this when we don't want any of the above to happen.
  * This allows for easy and efficient race-condition prevention
  * This allows for easy and efficient race-condition prevention
- * for kbd_refresh_leds => input_event(dev, EV_LED, ...) => ...
+ * for kbd_start => input_inject_event(dev, EV_LED, ...) => ...
  */
  */
 
 
 static void kbd_bh(unsigned long dummy)
 static void kbd_bh(unsigned long dummy)
@@ -998,11 +997,11 @@ static void kbd_bh(unsigned long dummy)
 
 
 	if (leds != ledstate) {
 	if (leds != ledstate) {
 		list_for_each(node, &kbd_handler.h_list) {
 		list_for_each(node, &kbd_handler.h_list) {
-			struct input_handle * handle = to_handle_h(node);
-			input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01));
-			input_event(handle->dev, EV_LED, LED_NUML,    !!(leds & 0x02));
-			input_event(handle->dev, EV_LED, LED_CAPSL,   !!(leds & 0x04));
-			input_sync(handle->dev);
+			struct input_handle *handle = to_handle_h(node);
+			input_inject_event(handle, EV_LED, LED_SCROLLL, !!(leds & 0x01));
+			input_inject_event(handle, EV_LED, LED_NUML,    !!(leds & 0x02));
+			input_inject_event(handle, EV_LED, LED_CAPSL,   !!(leds & 0x04));
+			input_inject_event(handle, EV_SYN, SYN_REPORT, 0);
 		}
 		}
 	}
 	}
 
 
@@ -1011,23 +1010,6 @@ static void kbd_bh(unsigned long dummy)
 
 
 DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
 DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
 
 
-/*
- * This allows a newly plugged keyboard to pick the LED state.
- */
-static void kbd_refresh_leds(struct input_handle *handle)
-{
-	unsigned char leds = ledstate;
-
-	tasklet_disable(&keyboard_tasklet);
-	if (leds != 0xff) {
-		input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01));
-		input_event(handle->dev, EV_LED, LED_NUML,    !!(leds & 0x02));
-		input_event(handle->dev, EV_LED, LED_CAPSL,   !!(leds & 0x04));
-		input_sync(handle->dev);
-	}
-	tasklet_enable(&keyboard_tasklet);
-}
-
 #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\
 #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\
     defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\
     defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\
     defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\
     defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\
@@ -1043,7 +1025,7 @@ static const unsigned short x86_keycodes[256] =
 	 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
 	 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
 	 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
 	 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
 	 80, 81, 82, 83, 84,118, 86, 87, 88,115,120,119,121,112,123, 92,
 	 80, 81, 82, 83, 84,118, 86, 87, 88,115,120,119,121,112,123, 92,
-	284,285,309,298,312, 91,327,328,329,331,333,335,336,337,338,339,
+	284,285,309,  0,312, 91,327,328,329,331,333,335,336,337,338,339,
 	367,288,302,304,350, 89,334,326,267,126,268,269,125,347,348,349,
 	367,288,302,304,350, 89,334,326,267,126,268,269,125,347,348,349,
 	360,261,262,263,268,376,100,101,321,316,373,286,289,102,351,355,
 	360,261,262,263,268,376,100,101,321,316,373,286,289,102,351,355,
 	103,104,105,275,287,279,306,106,274,107,294,364,358,363,362,361,
 	103,104,105,275,287,279,306,106,274,107,294,364,358,363,362,361,
@@ -1065,38 +1047,55 @@ extern void sun_do_break(void);
 static int emulate_raw(struct vc_data *vc, unsigned int keycode,
 static int emulate_raw(struct vc_data *vc, unsigned int keycode,
 		       unsigned char up_flag)
 		       unsigned char up_flag)
 {
 {
-	if (keycode > 255 || !x86_keycodes[keycode])
-		return -1;
+	int code;
 
 
 	switch (keycode) {
 	switch (keycode) {
 		case KEY_PAUSE:
 		case KEY_PAUSE:
 			put_queue(vc, 0xe1);
 			put_queue(vc, 0xe1);
 			put_queue(vc, 0x1d | up_flag);
 			put_queue(vc, 0x1d | up_flag);
 			put_queue(vc, 0x45 | up_flag);
 			put_queue(vc, 0x45 | up_flag);
-			return 0;
+			break;
+
 		case KEY_HANGEUL:
 		case KEY_HANGEUL:
 			if (!up_flag)
 			if (!up_flag)
 				put_queue(vc, 0xf2);
 				put_queue(vc, 0xf2);
-			return 0;
+			break;
+
 		case KEY_HANJA:
 		case KEY_HANJA:
 			if (!up_flag)
 			if (!up_flag)
 				put_queue(vc, 0xf1);
 				put_queue(vc, 0xf1);
-			return 0;
-	}
+			break;
 
 
-	if (keycode == KEY_SYSRQ && sysrq_alt) {
-		put_queue(vc, 0x54 | up_flag);
-		return 0;
-	}
+		case KEY_SYSRQ:
+			/*
+			 * Real AT keyboards (that's what we're trying
+			 * to emulate here emit 0xe0 0x2a 0xe0 0x37 when
+			 * pressing PrtSc/SysRq alone, but simply 0x54
+			 * when pressing Alt+PrtSc/SysRq.
+			 */
+			if (sysrq_alt) {
+				put_queue(vc, 0x54 | up_flag);
+			} else {
+				put_queue(vc, 0xe0);
+				put_queue(vc, 0x2a | up_flag);
+				put_queue(vc, 0xe0);
+				put_queue(vc, 0x37 | up_flag);
+			}
+			break;
+
+		default:
+			if (keycode > 255)
+				return -1;
 
 
-	if (x86_keycodes[keycode] & 0x100)
-		put_queue(vc, 0xe0);
+			code = x86_keycodes[keycode];
+			if (!code)
+				return -1;
 
 
-	put_queue(vc, (x86_keycodes[keycode] & 0x7f) | up_flag);
+			if (code & 0x100)
+				put_queue(vc, 0xe0);
+			put_queue(vc, (code & 0x7f) | up_flag);
 
 
-	if (keycode == KEY_SYSRQ) {
-		put_queue(vc, 0xe0);
-		put_queue(vc, 0x37 | up_flag);
+			break;
 	}
 	}
 
 
 	return 0;
 	return 0;
@@ -1298,16 +1297,15 @@ static struct input_handle *kbd_connect(struct input_handler *handler,
 	if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit))
 	if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit))
 		return NULL;
 		return NULL;
 
 
-	if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
+	handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
+	if (!handle)
 		return NULL;
 		return NULL;
-	memset(handle, 0, sizeof(struct input_handle));
 
 
 	handle->dev = dev;
 	handle->dev = dev;
 	handle->handler = handler;
 	handle->handler = handler;
 	handle->name = "kbd";
 	handle->name = "kbd";
 
 
 	input_open_device(handle);
 	input_open_device(handle);
-	kbd_refresh_leds(handle);
 
 
 	return handle;
 	return handle;
 }
 }
@@ -1318,6 +1316,24 @@ static void kbd_disconnect(struct input_handle *handle)
 	kfree(handle);
 	kfree(handle);
 }
 }
 
 
+/*
+ * Start keyboard handler on the new keyboard by refreshing LED state to
+ * match the rest of the system.
+ */
+static void kbd_start(struct input_handle *handle)
+{
+	unsigned char leds = ledstate;
+
+	tasklet_disable(&keyboard_tasklet);
+	if (leds != 0xff) {
+		input_inject_event(handle, EV_LED, LED_SCROLLL, !!(leds & 0x01));
+		input_inject_event(handle, EV_LED, LED_NUML,    !!(leds & 0x02));
+		input_inject_event(handle, EV_LED, LED_CAPSL,   !!(leds & 0x04));
+		input_inject_event(handle, EV_SYN, SYN_REPORT, 0);
+	}
+	tasklet_enable(&keyboard_tasklet);
+}
+
 static struct input_device_id kbd_ids[] = {
 static struct input_device_id kbd_ids[] = {
 	{
 	{
                 .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
                 .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
@@ -1338,6 +1354,7 @@ static struct input_handler kbd_handler = {
 	.event		= kbd_event,
 	.event		= kbd_event,
 	.connect	= kbd_connect,
 	.connect	= kbd_connect,
 	.disconnect	= kbd_disconnect,
 	.disconnect	= kbd_disconnect,
+	.start		= kbd_start,
 	.name		= "kbd",
 	.name		= "kbd",
 	.id_table	= kbd_ids,
 	.id_table	= kbd_ids,
 };
 };
@@ -1346,15 +1363,15 @@ int __init kbd_init(void)
 {
 {
 	int i;
 	int i;
 
 
-        kbd0.ledflagstate = kbd0.default_ledflagstate = KBD_DEFLEDS;
-        kbd0.ledmode = LED_SHOW_FLAGS;
-        kbd0.lockstate = KBD_DEFLOCK;
-        kbd0.slockstate = 0;
-        kbd0.modeflags = KBD_DEFMODE;
-        kbd0.kbdmode = VC_XLATE;
-
-        for (i = 0 ; i < MAX_NR_CONSOLES ; i++)
-                kbd_table[i] = kbd0;
+        for (i = 0; i < MAX_NR_CONSOLES; i++) {
+		kbd_table[i].ledflagstate = KBD_DEFLEDS;
+		kbd_table[i].default_ledflagstate = KBD_DEFLEDS;
+		kbd_table[i].ledmode = LED_SHOW_FLAGS;
+		kbd_table[i].lockstate = KBD_DEFLOCK;
+		kbd_table[i].slockstate = 0;
+		kbd_table[i].modeflags = KBD_DEFMODE;
+		kbd_table[i].kbdmode = VC_XLATE;
+	}
 
 
 	input_register_handler(&kbd_handler);
 	input_register_handler(&kbd_handler);
 
 

+ 54 - 21
drivers/cpufreq/cpufreq.c

@@ -284,39 +284,69 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_transition);
  *                          SYSFS INTERFACE                          *
  *                          SYSFS INTERFACE                          *
  *********************************************************************/
  *********************************************************************/
 
 
+static struct cpufreq_governor *__find_governor(const char *str_governor)
+{
+	struct cpufreq_governor *t;
+
+	list_for_each_entry(t, &cpufreq_governor_list, governor_list)
+		if (!strnicmp(str_governor,t->name,CPUFREQ_NAME_LEN))
+			return t;
+
+	return NULL;
+}
+
 /**
 /**
  * cpufreq_parse_governor - parse a governor string
  * cpufreq_parse_governor - parse a governor string
  */
  */
 static int cpufreq_parse_governor (char *str_governor, unsigned int *policy,
 static int cpufreq_parse_governor (char *str_governor, unsigned int *policy,
 				struct cpufreq_governor **governor)
 				struct cpufreq_governor **governor)
 {
 {
+	int err = -EINVAL;
+
 	if (!cpufreq_driver)
 	if (!cpufreq_driver)
-		return -EINVAL;
+		goto out;
+
 	if (cpufreq_driver->setpolicy) {
 	if (cpufreq_driver->setpolicy) {
 		if (!strnicmp(str_governor, "performance", CPUFREQ_NAME_LEN)) {
 		if (!strnicmp(str_governor, "performance", CPUFREQ_NAME_LEN)) {
 			*policy = CPUFREQ_POLICY_PERFORMANCE;
 			*policy = CPUFREQ_POLICY_PERFORMANCE;
-			return 0;
+			err = 0;
 		} else if (!strnicmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) {
 		} else if (!strnicmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) {
 			*policy = CPUFREQ_POLICY_POWERSAVE;
 			*policy = CPUFREQ_POLICY_POWERSAVE;
-			return 0;
+			err = 0;
 		}
 		}
-		return -EINVAL;
-	} else {
+	} else if (cpufreq_driver->target) {
 		struct cpufreq_governor *t;
 		struct cpufreq_governor *t;
+
 		mutex_lock(&cpufreq_governor_mutex);
 		mutex_lock(&cpufreq_governor_mutex);
-		if (!cpufreq_driver || !cpufreq_driver->target)
-			goto out;
-		list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
-			if (!strnicmp(str_governor,t->name,CPUFREQ_NAME_LEN)) {
-				*governor = t;
+
+		t = __find_governor(str_governor);
+
+		if (t == NULL) {
+			char *name = kasprintf(GFP_KERNEL, "cpufreq_%s", str_governor);
+
+			if (name) {
+				int ret;
+
 				mutex_unlock(&cpufreq_governor_mutex);
 				mutex_unlock(&cpufreq_governor_mutex);
-				return 0;
+				ret = request_module(name);
+				mutex_lock(&cpufreq_governor_mutex);
+
+				if (ret == 0)
+					t = __find_governor(str_governor);
 			}
 			}
+
+			kfree(name);
 		}
 		}
-out:
+
+		if (t != NULL) {
+			*governor = t;
+			err = 0;
+		}
+
 		mutex_unlock(&cpufreq_governor_mutex);
 		mutex_unlock(&cpufreq_governor_mutex);
 	}
 	}
-	return -EINVAL;
+  out:
+	return err;
 }
 }
 
 
 
 
@@ -1265,23 +1295,21 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
 
 
 int cpufreq_register_governor(struct cpufreq_governor *governor)
 int cpufreq_register_governor(struct cpufreq_governor *governor)
 {
 {
-	struct cpufreq_governor *t;
+	int err;
 
 
 	if (!governor)
 	if (!governor)
 		return -EINVAL;
 		return -EINVAL;
 
 
 	mutex_lock(&cpufreq_governor_mutex);
 	mutex_lock(&cpufreq_governor_mutex);
 
 
-	list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
-		if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) {
-			mutex_unlock(&cpufreq_governor_mutex);
-			return -EBUSY;
-		}
+	err = -EBUSY;
+	if (__find_governor(governor->name) == NULL) {
+		err = 0;
+		list_add(&governor->governor_list, &cpufreq_governor_list);
 	}
 	}
-	list_add(&governor->governor_list, &cpufreq_governor_list);
 
 
 	mutex_unlock(&cpufreq_governor_mutex);
 	mutex_unlock(&cpufreq_governor_mutex);
-	return 0;
+	return err;
 }
 }
 EXPORT_SYMBOL_GPL(cpufreq_register_governor);
 EXPORT_SYMBOL_GPL(cpufreq_register_governor);
 
 
@@ -1343,6 +1371,11 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_poli
 
 
 	memcpy(&policy->cpuinfo, &data->cpuinfo, sizeof(struct cpufreq_cpuinfo));
 	memcpy(&policy->cpuinfo, &data->cpuinfo, sizeof(struct cpufreq_cpuinfo));
 
 
+	if (policy->min > data->min && policy->min > policy->max) {
+		ret = -EINVAL;
+		goto error_out;
+	}
+
 	/* verify the cpu speed can be set within this limit */
 	/* verify the cpu speed can be set within this limit */
 	ret = cpufreq_driver->verify(policy);
 	ret = cpufreq_driver->verify(policy);
 	if (ret)
 	if (ret)

+ 1 - 0
drivers/edac/edac_mc.h

@@ -29,6 +29,7 @@
 #include <linux/rcupdate.h>
 #include <linux/rcupdate.h>
 #include <linux/completion.h>
 #include <linux/completion.h>
 #include <linux/kobject.h>
 #include <linux/kobject.h>
+#include <linux/platform_device.h>
 
 
 #define EDAC_MC_LABEL_LEN	31
 #define EDAC_MC_LABEL_LEN	31
 #define MC_PROC_NAME_MAX_LEN 7
 #define MC_PROC_NAME_MAX_LEN 7

+ 5 - 2
drivers/i2c/busses/scx200_acb.c

@@ -232,7 +232,7 @@ static void scx200_acb_poll(struct scx200_acb_iface *iface)
 	unsigned long timeout;
 	unsigned long timeout;
 
 
 	timeout = jiffies + POLL_TIMEOUT;
 	timeout = jiffies + POLL_TIMEOUT;
-	while (time_before(jiffies, timeout)) {
+	while (1) {
 		status = inb(ACBST);
 		status = inb(ACBST);
 
 
 		/* Reset the status register to avoid the hang */
 		/* Reset the status register to avoid the hang */
@@ -242,7 +242,10 @@ static void scx200_acb_poll(struct scx200_acb_iface *iface)
 			scx200_acb_machine(iface, status);
 			scx200_acb_machine(iface, status);
 			return;
 			return;
 		}
 		}
-		yield();
+		if (time_after(jiffies, timeout))
+			break;
+		cpu_relax();
+		cond_resched();
 	}
 	}
 
 
 	dev_err(&iface->adapter.dev, "timeout in state %s\n",
 	dev_err(&iface->adapter.dev, "timeout in state %s\n",

+ 3 - 0
drivers/ieee1394/sbp2.c

@@ -2515,6 +2515,9 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
 		sdev->skip_ms_page_8 = 1;
 		sdev->skip_ms_page_8 = 1;
 	if (scsi_id->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
 	if (scsi_id->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
 		sdev->fix_capacity = 1;
 		sdev->fix_capacity = 1;
+	if (scsi_id->ne->guid_vendor_id == 0x0010b9 && /* Maxtor's OUI */
+	    (sdev->type == TYPE_DISK || sdev->type == TYPE_RBC))
+		sdev->allow_restart = 1;
 	return 0;
 	return 0;
 }
 }
 
 

+ 3 - 7
drivers/input/evdev.c

@@ -127,14 +127,10 @@ static int evdev_open(struct inode * inode, struct file * file)
 {
 {
 	struct evdev_list *list;
 	struct evdev_list *list;
 	int i = iminor(inode) - EVDEV_MINOR_BASE;
 	int i = iminor(inode) - EVDEV_MINOR_BASE;
-	int accept_err;
 
 
 	if (i >= EVDEV_MINORS || !evdev_table[i] || !evdev_table[i]->exist)
 	if (i >= EVDEV_MINORS || !evdev_table[i] || !evdev_table[i]->exist)
 		return -ENODEV;
 		return -ENODEV;
 
 
-	if ((accept_err = input_accept_process(&(evdev_table[i]->handle), file)))
-		return accept_err;
-
 	if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL)))
 	if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL)))
 		return -ENOMEM;
 		return -ENOMEM;
 
 
@@ -260,7 +256,7 @@ static ssize_t evdev_write(struct file * file, const char __user * buffer, size_
 
 
 		if (evdev_event_from_user(buffer + retval, &event))
 		if (evdev_event_from_user(buffer + retval, &event))
 			return -EFAULT;
 			return -EFAULT;
-		input_event(list->evdev->handle.dev, event.type, event.code, event.value);
+		input_inject_event(&list->evdev->handle, event.type, event.code, event.value);
 		retval += evdev_event_size();
 		retval += evdev_event_size();
 	}
 	}
 
 
@@ -428,8 +424,8 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
 			if (get_user(v, ip + 1))
 			if (get_user(v, ip + 1))
 				return -EFAULT;
 				return -EFAULT;
 
 
-			input_event(dev, EV_REP, REP_DELAY, u);
-			input_event(dev, EV_REP, REP_PERIOD, v);
+			input_inject_event(&evdev->handle, EV_REP, REP_DELAY, u);
+			input_inject_event(&evdev->handle, EV_REP, REP_PERIOD, v);
 
 
 			return 0;
 			return 0;
 
 

+ 2 - 2
drivers/input/gameport/fm801-gp.c

@@ -106,10 +106,10 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
 	gp->gameport = port;
 	gp->gameport = port;
 	gp->res_port = request_region(port->io, 0x10, "FM801 GP");
 	gp->res_port = request_region(port->io, 0x10, "FM801 GP");
 	if (!gp->res_port) {
 	if (!gp->res_port) {
-		kfree(gp);
-		gameport_free_port(port);
 		printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n",
 		printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n",
 			port->io, port->io + 0x0f);
 			port->io, port->io + 0x0f);
+		gameport_free_port(port);
+		kfree(gp);
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 
 

+ 49 - 17
drivers/input/gameport/gameport.c

@@ -53,6 +53,7 @@ static LIST_HEAD(gameport_list);
 
 
 static struct bus_type gameport_bus;
 static struct bus_type gameport_bus;
 
 
+static void gameport_add_driver(struct gameport_driver *drv);
 static void gameport_add_port(struct gameport *gameport);
 static void gameport_add_port(struct gameport *gameport);
 static void gameport_destroy_port(struct gameport *gameport);
 static void gameport_destroy_port(struct gameport *gameport);
 static void gameport_reconnect_port(struct gameport *gameport);
 static void gameport_reconnect_port(struct gameport *gameport);
@@ -211,8 +212,14 @@ static void gameport_release_driver(struct gameport *gameport)
 
 
 static void gameport_find_driver(struct gameport *gameport)
 static void gameport_find_driver(struct gameport *gameport)
 {
 {
+	int error;
+
 	down_write(&gameport_bus.subsys.rwsem);
 	down_write(&gameport_bus.subsys.rwsem);
-	device_attach(&gameport->dev);
+	error = device_attach(&gameport->dev);
+	if (error < 0)
+		printk(KERN_WARNING
+			"gameport: device_attach() failed for %s (%s), error: %d\n",
+			gameport->phys, gameport->name, error);
 	up_write(&gameport_bus.subsys.rwsem);
 	up_write(&gameport_bus.subsys.rwsem);
 }
 }
 
 
@@ -316,7 +323,6 @@ static void gameport_remove_duplicate_events(struct gameport_event *event)
 	spin_unlock_irqrestore(&gameport_event_lock, flags);
 	spin_unlock_irqrestore(&gameport_event_lock, flags);
 }
 }
 
 
-
 static struct gameport_event *gameport_get_event(void)
 static struct gameport_event *gameport_get_event(void)
 {
 {
 	struct gameport_event *event;
 	struct gameport_event *event;
@@ -342,7 +348,6 @@ static struct gameport_event *gameport_get_event(void)
 static void gameport_handle_event(void)
 static void gameport_handle_event(void)
 {
 {
 	struct gameport_event *event;
 	struct gameport_event *event;
-	struct gameport_driver *gameport_drv;
 
 
 	mutex_lock(&gameport_mutex);
 	mutex_lock(&gameport_mutex);
 
 
@@ -369,8 +374,7 @@ static void gameport_handle_event(void)
 				break;
 				break;
 
 
 			case GAMEPORT_REGISTER_DRIVER:
 			case GAMEPORT_REGISTER_DRIVER:
-				gameport_drv = event->object;
-				driver_register(&gameport_drv->driver);
+				gameport_add_driver(event->object);
 				break;
 				break;
 
 
 			default:
 			default:
@@ -532,6 +536,7 @@ static void gameport_init_port(struct gameport *gameport)
 	if (gameport->parent)
 	if (gameport->parent)
 		gameport->dev.parent = &gameport->parent->dev;
 		gameport->dev.parent = &gameport->parent->dev;
 
 
+	INIT_LIST_HEAD(&gameport->node);
 	spin_lock_init(&gameport->timer_lock);
 	spin_lock_init(&gameport->timer_lock);
 	init_timer(&gameport->poll_timer);
 	init_timer(&gameport->poll_timer);
 	gameport->poll_timer.function = gameport_run_poll_handler;
 	gameport->poll_timer.function = gameport_run_poll_handler;
@@ -544,6 +549,8 @@ static void gameport_init_port(struct gameport *gameport)
  */
  */
 static void gameport_add_port(struct gameport *gameport)
 static void gameport_add_port(struct gameport *gameport)
 {
 {
+	int error;
+
 	if (gameport->parent)
 	if (gameport->parent)
 		gameport->parent->child = gameport;
 		gameport->parent->child = gameport;
 
 
@@ -558,8 +565,13 @@ static void gameport_add_port(struct gameport *gameport)
 		printk(KERN_INFO "gameport: %s is %s, speed %dkHz\n",
 		printk(KERN_INFO "gameport: %s is %s, speed %dkHz\n",
 			gameport->name, gameport->phys, gameport->speed);
 			gameport->name, gameport->phys, gameport->speed);
 
 
-	device_add(&gameport->dev);
-	gameport->registered = 1;
+	error = device_add(&gameport->dev);
+	if (error)
+		printk(KERN_ERR
+			"gameport: device_add() failed for %s (%s), error: %d\n",
+			gameport->phys, gameport->name, error);
+	else
+		gameport->registered = 1;
 }
 }
 
 
 /*
 /*
@@ -583,10 +595,11 @@ static void gameport_destroy_port(struct gameport *gameport)
 
 
 	if (gameport->registered) {
 	if (gameport->registered) {
 		device_del(&gameport->dev);
 		device_del(&gameport->dev);
-		list_del_init(&gameport->node);
 		gameport->registered = 0;
 		gameport->registered = 0;
 	}
 	}
 
 
+	list_del_init(&gameport->node);
+
 	gameport_remove_pending_events(gameport);
 	gameport_remove_pending_events(gameport);
 	put_device(&gameport->dev);
 	put_device(&gameport->dev);
 }
 }
@@ -704,11 +717,22 @@ static int gameport_driver_remove(struct device *dev)
 }
 }
 
 
 static struct bus_type gameport_bus = {
 static struct bus_type gameport_bus = {
-	.name =	"gameport",
-	.probe = gameport_driver_probe,
-	.remove = gameport_driver_remove,
+	.name	= "gameport",
+	.probe	= gameport_driver_probe,
+	.remove	= gameport_driver_remove,
 };
 };
 
 
+static void gameport_add_driver(struct gameport_driver *drv)
+{
+	int error;
+
+	error = driver_register(&drv->driver);
+	if (error)
+		printk(KERN_ERR
+			"gameport: driver_register() failed for %s, error: %d\n",
+			drv->driver.name, error);
+}
+
 void __gameport_register_driver(struct gameport_driver *drv, struct module *owner)
 void __gameport_register_driver(struct gameport_driver *drv, struct module *owner)
 {
 {
 	drv->driver.bus = &gameport_bus;
 	drv->driver.bus = &gameport_bus;
@@ -778,16 +802,24 @@ void gameport_close(struct gameport *gameport)
 
 
 static int __init gameport_init(void)
 static int __init gameport_init(void)
 {
 {
-	gameport_task = kthread_run(gameport_thread, NULL, "kgameportd");
-	if (IS_ERR(gameport_task)) {
-		printk(KERN_ERR "gameport: Failed to start kgameportd\n");
-		return PTR_ERR(gameport_task);
-	}
+	int error;
 
 
 	gameport_bus.dev_attrs = gameport_device_attrs;
 	gameport_bus.dev_attrs = gameport_device_attrs;
 	gameport_bus.drv_attrs = gameport_driver_attrs;
 	gameport_bus.drv_attrs = gameport_driver_attrs;
 	gameport_bus.match = gameport_bus_match;
 	gameport_bus.match = gameport_bus_match;
-	bus_register(&gameport_bus);
+	error = bus_register(&gameport_bus);
+	if (error) {
+		printk(KERN_ERR "gameport: failed to register gameport bus, error: %d\n", error);
+		return error;
+	}
+
+	gameport_task = kthread_run(gameport_thread, NULL, "kgameportd");
+	if (IS_ERR(gameport_task)) {
+		bus_unregister(&gameport_bus);
+		error = PTR_ERR(gameport_task);
+		printk(KERN_ERR "gameport: Failed to start kgameportd, error: %d\n", error);
+		return error;
+	}
 
 
 	return 0;
 	return 0;
 }
 }

+ 44 - 13
drivers/input/input.c

@@ -35,6 +35,16 @@ static LIST_HEAD(input_handler_list);
 
 
 static struct input_handler *input_table[8];
 static struct input_handler *input_table[8];
 
 
+/**
+ * input_event() - report new input event
+ * @handle: device that generated the event
+ * @type: type of the event
+ * @code: event code
+ * @value: value of the event
+ *
+ * This function should be used by drivers implementing various input devices
+ * See also input_inject_event()
+ */
 void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
 void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
 {
 {
 	struct input_handle *handle;
 	struct input_handle *handle;
@@ -183,6 +193,23 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
 }
 }
 EXPORT_SYMBOL(input_event);
 EXPORT_SYMBOL(input_event);
 
 
+/**
+ * input_inject_event() - send input event from input handler
+ * @handle: input handle to send event through
+ * @type: type of the event
+ * @code: event code
+ * @value: value of the event
+ *
+ * Similar to input_event() but will ignore event if device is "grabbed" and handle
+ * injecting event is not the one that owns the device.
+ */
+void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
+{
+	if (!handle->dev->grab || handle->dev->grab == handle)
+		input_event(handle->dev, type, code, value);
+}
+EXPORT_SYMBOL(input_inject_event);
+
 static void input_repeat_key(unsigned long data)
 static void input_repeat_key(unsigned long data)
 {
 {
 	struct input_dev *dev = (void *) data;
 	struct input_dev *dev = (void *) data;
@@ -197,15 +224,6 @@ static void input_repeat_key(unsigned long data)
 		mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD]));
 		mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD]));
 }
 }
 
 
-int input_accept_process(struct input_handle *handle, struct file *file)
-{
-	if (handle->dev->accept)
-		return handle->dev->accept(handle->dev, file);
-
-	return 0;
-}
-EXPORT_SYMBOL(input_accept_process);
-
 int input_grab_device(struct input_handle *handle)
 int input_grab_device(struct input_handle *handle)
 {
 {
 	if (handle->dev->grab)
 	if (handle->dev->grab)
@@ -218,8 +236,15 @@ EXPORT_SYMBOL(input_grab_device);
 
 
 void input_release_device(struct input_handle *handle)
 void input_release_device(struct input_handle *handle)
 {
 {
-	if (handle->dev->grab == handle)
-		handle->dev->grab = NULL;
+	struct input_dev *dev = handle->dev;
+
+	if (dev->grab == handle) {
+		dev->grab = NULL;
+
+		list_for_each_entry(handle, &dev->h_list, d_node)
+			if (handle->handler->start)
+				handle->handler->start(handle);
+	}
 }
 }
 EXPORT_SYMBOL(input_release_device);
 EXPORT_SYMBOL(input_release_device);
 
 
@@ -963,8 +988,11 @@ int input_register_device(struct input_dev *dev)
 	list_for_each_entry(handler, &input_handler_list, node)
 	list_for_each_entry(handler, &input_handler_list, node)
 		if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
 		if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
 			if ((id = input_match_device(handler->id_table, dev)))
 			if ((id = input_match_device(handler->id_table, dev)))
-				if ((handle = handler->connect(handler, dev, id)))
+				if ((handle = handler->connect(handler, dev, id))) {
 					input_link_handle(handle);
 					input_link_handle(handle);
+					if (handler->start)
+						handler->start(handle);
+				}
 
 
 	input_wakeup_procfs_readers();
 	input_wakeup_procfs_readers();
 
 
@@ -1028,8 +1056,11 @@ void input_register_handler(struct input_handler *handler)
 	list_for_each_entry(dev, &input_dev_list, node)
 	list_for_each_entry(dev, &input_dev_list, node)
 		if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
 		if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
 			if ((id = input_match_device(handler->id_table, dev)))
 			if ((id = input_match_device(handler->id_table, dev)))
-				if ((handle = handler->connect(handler, dev, id)))
+				if ((handle = handler->connect(handler, dev, id))) {
 					input_link_handle(handle);
 					input_link_handle(handle);
+					if (handler->start)
+						handler->start(handle);
+				}
 
 
 	input_wakeup_procfs_readers();
 	input_wakeup_procfs_readers();
 }
 }

+ 10 - 9
drivers/input/joystick/iforce/iforce-main.c

@@ -79,6 +79,7 @@ static struct iforce_device iforce_device[] = {
 	{ 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback",	btn_wheel, abs_wheel, ff_iforce }, //?
 	{ 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback",	btn_wheel, abs_wheel, ff_iforce }, //?
 	{ 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel",	btn_wheel, abs_wheel, ff_iforce }, //?
 	{ 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel",	btn_wheel, abs_wheel, ff_iforce }, //?
 	{ 0x06f8, 0x0004, "Gullemot Jet Leader 3D",			btn_joystick, abs_joystick, ff_iforce }, //?
 	{ 0x06f8, 0x0004, "Gullemot Jet Leader 3D",			btn_joystick, abs_joystick, ff_iforce }, //?
+	{ 0x06d6, 0x29bc, "Trust Force Feedback Race Master",		btn_wheel, abs_wheel, ff_iforce },
 	{ 0x0000, 0x0000, "Unknown I-Force Device [%04x:%04x]",		btn_joystick, abs_joystick, ff_iforce }
 	{ 0x0000, 0x0000, "Unknown I-Force Device [%04x:%04x]",		btn_joystick, abs_joystick, ff_iforce }
 };
 };
 
 
@@ -222,22 +223,22 @@ static int iforce_erase_effect(struct input_dev *dev, int effect_id)
 	int err = 0;
 	int err = 0;
 	struct iforce_core_effect* core_effect;
 	struct iforce_core_effect* core_effect;
 
 
-	/* Check who is trying to erase this effect */
-	if (iforce->core_effects[effect_id].owner != current->pid) {
-		printk(KERN_WARNING "iforce-main.c: %d tried to erase an effect belonging to %d\n", current->pid, iforce->core_effects[effect_id].owner);
-		return -EACCES;
-	}
-
 	if (effect_id < 0 || effect_id >= FF_EFFECTS_MAX)
 	if (effect_id < 0 || effect_id >= FF_EFFECTS_MAX)
 		return -EINVAL;
 		return -EINVAL;
 
 
-	core_effect = iforce->core_effects + effect_id;
+	core_effect = &iforce->core_effects[effect_id];
+
+	/* Check who is trying to erase this effect */
+	if (core_effect->owner != current->pid) {
+		printk(KERN_WARNING "iforce-main.c: %d tried to erase an effect belonging to %d\n", current->pid, core_effect->owner);
+		return -EACCES;
+	}
 
 
 	if (test_bit(FF_MOD1_IS_USED, core_effect->flags))
 	if (test_bit(FF_MOD1_IS_USED, core_effect->flags))
-		err = release_resource(&(iforce->core_effects[effect_id].mod1_chunk));
+		err = release_resource(&core_effect->mod1_chunk);
 
 
 	if (!err && test_bit(FF_MOD2_IS_USED, core_effect->flags))
 	if (!err && test_bit(FF_MOD2_IS_USED, core_effect->flags))
-		err = release_resource(&(iforce->core_effects[effect_id].mod2_chunk));
+		err = release_resource(&core_effect->mod2_chunk);
 
 
 	/*TODO: remember to change that if more FF_MOD* bits are added */
 	/*TODO: remember to change that if more FF_MOD* bits are added */
 	core_effect->flags[0] = 0;
 	core_effect->flags[0] = 0;

+ 1 - 1
drivers/input/joystick/spaceball.c

@@ -50,7 +50,7 @@ MODULE_LICENSE("GPL");
  */
  */
 
 
 #define SPACEBALL_MAX_LENGTH	128
 #define SPACEBALL_MAX_LENGTH	128
-#define SPACEBALL_MAX_ID	8
+#define SPACEBALL_MAX_ID	9
 
 
 #define SPACEBALL_1003      1
 #define SPACEBALL_1003      1
 #define SPACEBALL_2003B     3
 #define SPACEBALL_2003B     3

+ 60 - 43
drivers/input/keyboard/atkbd.c

@@ -482,13 +482,7 @@ out:
 	return IRQ_HANDLED;
 	return IRQ_HANDLED;
 }
 }
 
 
-/*
- * atkbd_event_work() is used to complete processing of events that
- * can not be processed by input_event() which is often called from
- * interrupt context.
- */
-
-static void atkbd_event_work(void *data)
+static int atkbd_set_repeat_rate(struct atkbd *atkbd)
 {
 {
 	const short period[32] =
 	const short period[32] =
 		{ 33,  37,  42,  46,  50,  54,  58,  63,  67,  75,  83,  92, 100, 109, 116, 125,
 		{ 33,  37,  42,  46,  50,  54,  58,  63,  67,  75,  83,  92, 100, 109, 116, 125,
@@ -496,41 +490,64 @@ static void atkbd_event_work(void *data)
 	const short delay[4] =
 	const short delay[4] =
 		{ 250, 500, 750, 1000 };
 		{ 250, 500, 750, 1000 };
 
 
-	struct atkbd *atkbd = data;
+	struct input_dev *dev = atkbd->dev;
+	unsigned char param;
+	int i = 0, j = 0;
+
+	while (i < ARRAY_SIZE(period) - 1 && period[i] < dev->rep[REP_PERIOD])
+		i++;
+	dev->rep[REP_PERIOD] = period[i];
+
+	while (j < ARRAY_SIZE(period) - 1 && delay[j] < dev->rep[REP_DELAY])
+		j++;
+	dev->rep[REP_DELAY] = delay[j];
+
+	param = i | (j << 5);
+	return ps2_command(&atkbd->ps2dev, &param, ATKBD_CMD_SETREP);
+}
+
+static int atkbd_set_leds(struct atkbd *atkbd)
+{
 	struct input_dev *dev = atkbd->dev;
 	struct input_dev *dev = atkbd->dev;
 	unsigned char param[2];
 	unsigned char param[2];
-	int i, j;
 
 
-	mutex_lock(&atkbd->event_mutex);
+	param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0)
+		 | (test_bit(LED_NUML,    dev->led) ? 2 : 0)
+		 | (test_bit(LED_CAPSL,   dev->led) ? 4 : 0);
+	if (ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS))
+		return -1;
 
 
-	if (test_and_clear_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask)) {
-		param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0)
-			 | (test_bit(LED_NUML,    dev->led) ? 2 : 0)
-			 | (test_bit(LED_CAPSL,   dev->led) ? 4 : 0);
-		ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS);
-
-		if (atkbd->extra) {
-			param[0] = 0;
-			param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0)
-				 | (test_bit(LED_SLEEP,   dev->led) ? 0x02 : 0)
-				 | (test_bit(LED_SUSPEND, dev->led) ? 0x04 : 0)
-				 | (test_bit(LED_MISC,    dev->led) ? 0x10 : 0)
-				 | (test_bit(LED_MUTE,    dev->led) ? 0x20 : 0);
-			ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_EX_SETLEDS);
-		}
+	if (atkbd->extra) {
+		param[0] = 0;
+		param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0)
+			 | (test_bit(LED_SLEEP,   dev->led) ? 0x02 : 0)
+			 | (test_bit(LED_SUSPEND, dev->led) ? 0x04 : 0)
+			 | (test_bit(LED_MISC,    dev->led) ? 0x10 : 0)
+			 | (test_bit(LED_MUTE,    dev->led) ? 0x20 : 0);
+		if (ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_EX_SETLEDS))
+			return -1;
 	}
 	}
 
 
-	if (test_and_clear_bit(ATKBD_REP_EVENT_BIT, &atkbd->event_mask)) {
-		i = j = 0;
-		while (i < 31 && period[i] < dev->rep[REP_PERIOD])
-			i++;
-		while (j < 3 && delay[j] < dev->rep[REP_DELAY])
-			j++;
-		dev->rep[REP_PERIOD] = period[i];
-		dev->rep[REP_DELAY] = delay[j];
-		param[0] = i | (j << 5);
-		ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETREP);
-	}
+	return 0;
+}
+
+/*
+ * atkbd_event_work() is used to complete processing of events that
+ * can not be processed by input_event() which is often called from
+ * interrupt context.
+ */
+
+static void atkbd_event_work(void *data)
+{
+	struct atkbd *atkbd = data;
+
+	mutex_lock(&atkbd->event_mutex);
+
+	if (test_and_clear_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask))
+		atkbd_set_leds(atkbd);
+
+	if (test_and_clear_bit(ATKBD_REP_EVENT_BIT, &atkbd->event_mask))
+		atkbd_set_repeat_rate(atkbd);
 
 
 	mutex_unlock(&atkbd->event_mutex);
 	mutex_unlock(&atkbd->event_mutex);
 }
 }
@@ -975,7 +992,6 @@ static int atkbd_reconnect(struct serio *serio)
 {
 {
 	struct atkbd *atkbd = serio_get_drvdata(serio);
 	struct atkbd *atkbd = serio_get_drvdata(serio);
 	struct serio_driver *drv = serio->drv;
 	struct serio_driver *drv = serio->drv;
-	unsigned char param[1];
 
 
 	if (!atkbd || !drv) {
 	if (!atkbd || !drv) {
 		printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n");
 		printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n");
@@ -985,10 +1001,6 @@ static int atkbd_reconnect(struct serio *serio)
 	atkbd_disable(atkbd);
 	atkbd_disable(atkbd);
 
 
 	if (atkbd->write) {
 	if (atkbd->write) {
-		param[0] = (test_bit(LED_SCROLLL, atkbd->dev->led) ? 1 : 0)
-		         | (test_bit(LED_NUML,    atkbd->dev->led) ? 2 : 0)
-		         | (test_bit(LED_CAPSL,   atkbd->dev->led) ? 4 : 0);
-
 		if (atkbd_probe(atkbd))
 		if (atkbd_probe(atkbd))
 			return -1;
 			return -1;
 		if (atkbd->set != atkbd_select_set(atkbd, atkbd->set, atkbd->extra))
 		if (atkbd->set != atkbd_select_set(atkbd, atkbd->set, atkbd->extra))
@@ -996,8 +1008,13 @@ static int atkbd_reconnect(struct serio *serio)
 
 
 		atkbd_activate(atkbd);
 		atkbd_activate(atkbd);
 
 
-		if (ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS))
-			return -1;
+/*
+ * Restore repeat rate and LEDs (that were reset by atkbd_activate)
+ * to pre-resume state
+ */
+		if (!atkbd->softrepeat)
+			atkbd_set_repeat_rate(atkbd);
+		atkbd_set_leds(atkbd);
 	}
 	}
 
 
 	atkbd_enable(atkbd);
 	atkbd_enable(atkbd);

+ 10 - 10
drivers/input/misc/wistron_btns.c

@@ -94,7 +94,7 @@ static void call_bios(struct regs *regs)
 
 
 static ssize_t __init locate_wistron_bios(void __iomem *base)
 static ssize_t __init locate_wistron_bios(void __iomem *base)
 {
 {
-	static const unsigned char __initdata signature[] =
+	static unsigned char __initdata signature[] =
 		{ 0x42, 0x21, 0x55, 0x30 };
 		{ 0x42, 0x21, 0x55, 0x30 };
 	ssize_t offset;
 	ssize_t offset;
 
 
@@ -259,11 +259,11 @@ static int __init dmi_matched(struct dmi_system_id *dmi)
 	return 1;
 	return 1;
 }
 }
 
 
-static struct key_entry keymap_empty[] = {
+static struct key_entry keymap_empty[] __initdata = {
 	{ KE_END, 0 }
 	{ KE_END, 0 }
 };
 };
 
 
-static struct key_entry keymap_fs_amilo_pro_v2000[] = {
+static struct key_entry keymap_fs_amilo_pro_v2000[] __initdata = {
 	{ KE_KEY,  0x01, KEY_HELP },
 	{ KE_KEY,  0x01, KEY_HELP },
 	{ KE_KEY,  0x11, KEY_PROG1 },
 	{ KE_KEY,  0x11, KEY_PROG1 },
 	{ KE_KEY,  0x12, KEY_PROG2 },
 	{ KE_KEY,  0x12, KEY_PROG2 },
@@ -273,7 +273,7 @@ static struct key_entry keymap_fs_amilo_pro_v2000[] = {
 	{ KE_END,  0 }
 	{ KE_END,  0 }
 };
 };
 
 
-static struct key_entry keymap_fujitsu_n3510[] = {
+static struct key_entry keymap_fujitsu_n3510[] __initdata = {
 	{ KE_KEY, 0x11, KEY_PROG1 },
 	{ KE_KEY, 0x11, KEY_PROG1 },
 	{ KE_KEY, 0x12, KEY_PROG2 },
 	{ KE_KEY, 0x12, KEY_PROG2 },
 	{ KE_KEY, 0x36, KEY_WWW },
 	{ KE_KEY, 0x36, KEY_WWW },
@@ -285,7 +285,7 @@ static struct key_entry keymap_fujitsu_n3510[] = {
 	{ KE_END, 0 }
 	{ KE_END, 0 }
 };
 };
 
 
-static struct key_entry keymap_wistron_ms2111[] = {
+static struct key_entry keymap_wistron_ms2111[] __initdata = {
 	{ KE_KEY,  0x11, KEY_PROG1 },
 	{ KE_KEY,  0x11, KEY_PROG1 },
 	{ KE_KEY,  0x12, KEY_PROG2 },
 	{ KE_KEY,  0x12, KEY_PROG2 },
 	{ KE_KEY,  0x13, KEY_PROG3 },
 	{ KE_KEY,  0x13, KEY_PROG3 },
@@ -294,7 +294,7 @@ static struct key_entry keymap_wistron_ms2111[] = {
 	{ KE_END,  0 }
 	{ KE_END,  0 }
 };
 };
 
 
-static struct key_entry keymap_wistron_ms2141[] = {
+static struct key_entry keymap_wistron_ms2141[] __initdata = {
 	{ KE_KEY,  0x11, KEY_PROG1 },
 	{ KE_KEY,  0x11, KEY_PROG1 },
 	{ KE_KEY,  0x12, KEY_PROG2 },
 	{ KE_KEY,  0x12, KEY_PROG2 },
 	{ KE_WIFI, 0x30, 0 },
 	{ KE_WIFI, 0x30, 0 },
@@ -307,7 +307,7 @@ static struct key_entry keymap_wistron_ms2141[] = {
 	{ KE_END,  0 }
 	{ KE_END,  0 }
 };
 };
 
 
-static struct key_entry keymap_acer_aspire_1500[] = {
+static struct key_entry keymap_acer_aspire_1500[] __initdata = {
 	{ KE_KEY, 0x11, KEY_PROG1 },
 	{ KE_KEY, 0x11, KEY_PROG1 },
 	{ KE_KEY, 0x12, KEY_PROG2 },
 	{ KE_KEY, 0x12, KEY_PROG2 },
 	{ KE_WIFI, 0x30, 0 },
 	{ KE_WIFI, 0x30, 0 },
@@ -317,7 +317,7 @@ static struct key_entry keymap_acer_aspire_1500[] = {
 	{ KE_END, 0 }
 	{ KE_END, 0 }
 };
 };
 
 
-static struct key_entry keymap_acer_travelmate_240[] = {
+static struct key_entry keymap_acer_travelmate_240[] __initdata = {
 	{ KE_KEY, 0x31, KEY_MAIL },
 	{ KE_KEY, 0x31, KEY_MAIL },
 	{ KE_KEY, 0x36, KEY_WWW },
 	{ KE_KEY, 0x36, KEY_WWW },
 	{ KE_KEY, 0x11, KEY_PROG1 },
 	{ KE_KEY, 0x11, KEY_PROG1 },
@@ -327,7 +327,7 @@ static struct key_entry keymap_acer_travelmate_240[] = {
 	{ KE_END, 0 }
 	{ KE_END, 0 }
 };
 };
 
 
-static struct key_entry keymap_aopen_1559as[] = {
+static struct key_entry keymap_aopen_1559as[] __initdata = {
 	{ KE_KEY,  0x01, KEY_HELP },
 	{ KE_KEY,  0x01, KEY_HELP },
 	{ KE_KEY,  0x06, KEY_PROG3 },
 	{ KE_KEY,  0x06, KEY_PROG3 },
 	{ KE_KEY,  0x11, KEY_PROG1 },
 	{ KE_KEY,  0x11, KEY_PROG1 },
@@ -343,7 +343,7 @@ static struct key_entry keymap_aopen_1559as[] = {
  * a list of buttons and their key codes (reported when loading this module
  * a list of buttons and their key codes (reported when loading this module
  * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
  * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
  */
  */
-static struct dmi_system_id dmi_ids[] = {
+static struct dmi_system_id dmi_ids[] __initdata = {
 	{
 	{
 		.callback = dmi_matched,
 		.callback = dmi_matched,
 		.ident = "Fujitsu-Siemens Amilo Pro V2000",
 		.ident = "Fujitsu-Siemens Amilo Pro V2000",

+ 1 - 2
drivers/input/mouse/logips2pp.c

@@ -238,8 +238,7 @@ static struct ps2pp_info *get_model_info(unsigned char model)
 		{ 100,	PS2PP_KIND_MX,					/* MX510 */
 		{ 100,	PS2PP_KIND_MX,					/* MX510 */
 				PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
 				PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
 				PS2PP_EXTRA_BTN | PS2PP_NAV_BTN },
 				PS2PP_EXTRA_BTN | PS2PP_NAV_BTN },
-		{ 111,  PS2PP_KIND_MX,					/* MX300 */
-				PS2PP_WHEEL | PS2PP_EXTRA_BTN | PS2PP_TASK_BTN },
+		{ 111,  PS2PP_KIND_MX,	PS2PP_WHEEL | PS2PP_SIDE_BTN },	/* MX300 reports task button as side */
 		{ 112,	PS2PP_KIND_MX,					/* MX500 */
 		{ 112,	PS2PP_KIND_MX,					/* MX500 */
 				PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
 				PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
 				PS2PP_EXTRA_BTN | PS2PP_NAV_BTN },
 				PS2PP_EXTRA_BTN | PS2PP_NAV_BTN },

+ 34 - 18
drivers/input/mouse/trackpoint.c

@@ -183,21 +183,26 @@ static struct attribute_group trackpoint_attr_group = {
 	.attrs = trackpoint_attrs,
 	.attrs = trackpoint_attrs,
 };
 };
 
 
-static void trackpoint_disconnect(struct psmouse *psmouse)
+static int trackpoint_start_protocol(struct psmouse *psmouse, unsigned char *firmware_id)
 {
 {
-	sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, &trackpoint_attr_group);
+	unsigned char param[2] = { 0 };
 
 
-	kfree(psmouse->private);
-	psmouse->private = NULL;
+	if (ps2_command(&psmouse->ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
+		return -1;
+
+	if (param[0] != TP_MAGIC_IDENT)
+		return -1;
+
+	if (firmware_id)
+		*firmware_id = param[1];
+
+	return 0;
 }
 }
 
 
 static int trackpoint_sync(struct psmouse *psmouse)
 static int trackpoint_sync(struct psmouse *psmouse)
 {
 {
-	unsigned char toggle;
 	struct trackpoint_data *tp = psmouse->private;
 	struct trackpoint_data *tp = psmouse->private;
-
-	if (!tp)
-		return -1;
+	unsigned char toggle;
 
 
 	/* Disable features that may make device unusable with this driver */
 	/* Disable features that may make device unusable with this driver */
 	trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, &toggle);
 	trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, &toggle);
@@ -263,27 +268,38 @@ static void trackpoint_defaults(struct trackpoint_data *tp)
 	tp->ext_dev = TP_DEF_EXT_DEV;
 	tp->ext_dev = TP_DEF_EXT_DEV;
 }
 }
 
 
+static void trackpoint_disconnect(struct psmouse *psmouse)
+{
+	sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, &trackpoint_attr_group);
+
+	kfree(psmouse->private);
+	psmouse->private = NULL;
+}
+
+static int trackpoint_reconnect(struct psmouse *psmouse)
+{
+	if (trackpoint_start_protocol(psmouse, NULL))
+		return -1;
+
+	if (trackpoint_sync(psmouse))
+		return -1;
+
+	return 0;
+}
+
 int trackpoint_detect(struct psmouse *psmouse, int set_properties)
 int trackpoint_detect(struct psmouse *psmouse, int set_properties)
 {
 {
 	struct trackpoint_data *priv;
 	struct trackpoint_data *priv;
 	struct ps2dev *ps2dev = &psmouse->ps2dev;
 	struct ps2dev *ps2dev = &psmouse->ps2dev;
 	unsigned char firmware_id;
 	unsigned char firmware_id;
 	unsigned char button_info;
 	unsigned char button_info;
-	unsigned char param[2];
-
-	param[0] = param[1] = 0;
 
 
-	if (ps2_command(ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
-		return -1;
-
-	if (param[0] != TP_MAGIC_IDENT)
+	if (trackpoint_start_protocol(psmouse, &firmware_id))
 		return -1;
 		return -1;
 
 
 	if (!set_properties)
 	if (!set_properties)
 		return 0;
 		return 0;
 
 
-	firmware_id = param[1];
-
 	if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) {
 	if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) {
 		printk(KERN_WARNING "trackpoint.c: failed to get extended button data\n");
 		printk(KERN_WARNING "trackpoint.c: failed to get extended button data\n");
 		button_info = 0;
 		button_info = 0;
@@ -296,7 +312,7 @@ int trackpoint_detect(struct psmouse *psmouse, int set_properties)
 	psmouse->vendor = "IBM";
 	psmouse->vendor = "IBM";
 	psmouse->name = "TrackPoint";
 	psmouse->name = "TrackPoint";
 
 
-	psmouse->reconnect = trackpoint_sync;
+	psmouse->reconnect = trackpoint_reconnect;
 	psmouse->disconnect = trackpoint_disconnect;
 	psmouse->disconnect = trackpoint_disconnect;
 
 
 	trackpoint_defaults(priv);
 	trackpoint_defaults(priv);

+ 5 - 0
drivers/input/serio/libps2.c

@@ -177,6 +177,11 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
 		return -1;
 		return -1;
 	}
 	}
 
 
+	if (send && !param) {
+		WARN_ON(1);
+		return -1;
+	}
+
 	mutex_lock_nested(&ps2dev->cmd_mutex, SINGLE_DEPTH_NESTING);
 	mutex_lock_nested(&ps2dev->cmd_mutex, SINGLE_DEPTH_NESTING);
 
 
 	serio_pause_rx(ps2dev->serio);
 	serio_pause_rx(ps2dev->serio);

+ 51 - 14
drivers/input/serio/serio.c

@@ -62,6 +62,7 @@ static LIST_HEAD(serio_list);
 
 
 static struct bus_type serio_bus;
 static struct bus_type serio_bus;
 
 
+static void serio_add_driver(struct serio_driver *drv);
 static void serio_add_port(struct serio *serio);
 static void serio_add_port(struct serio *serio);
 static void serio_destroy_port(struct serio *serio);
 static void serio_destroy_port(struct serio *serio);
 static void serio_reconnect_port(struct serio *serio);
 static void serio_reconnect_port(struct serio *serio);
@@ -140,8 +141,14 @@ static void serio_release_driver(struct serio *serio)
 
 
 static void serio_find_driver(struct serio *serio)
 static void serio_find_driver(struct serio *serio)
 {
 {
+	int error;
+
 	down_write(&serio_bus.subsys.rwsem);
 	down_write(&serio_bus.subsys.rwsem);
-	device_attach(&serio->dev);
+	error = device_attach(&serio->dev);
+	if (error < 0)
+		printk(KERN_WARNING
+			"serio: device_attach() failed for %s (%s), error: %d\n",
+			serio->phys, serio->name, error);
 	up_write(&serio_bus.subsys.rwsem);
 	up_write(&serio_bus.subsys.rwsem);
 }
 }
 
 
@@ -272,7 +279,6 @@ static struct serio_event *serio_get_event(void)
 static void serio_handle_event(void)
 static void serio_handle_event(void)
 {
 {
 	struct serio_event *event;
 	struct serio_event *event;
-	struct serio_driver *serio_drv;
 
 
 	mutex_lock(&serio_mutex);
 	mutex_lock(&serio_mutex);
 
 
@@ -304,8 +310,7 @@ static void serio_handle_event(void)
 				break;
 				break;
 
 
 			case SERIO_REGISTER_DRIVER:
 			case SERIO_REGISTER_DRIVER:
-				serio_drv = event->object;
-				driver_register(&serio_drv->driver);
+				serio_add_driver(event->object);
 				break;
 				break;
 
 
 			default:
 			default:
@@ -525,6 +530,7 @@ static void serio_init_port(struct serio *serio)
 
 
 	__module_get(THIS_MODULE);
 	__module_get(THIS_MODULE);
 
 
+	INIT_LIST_HEAD(&serio->node);
 	spin_lock_init(&serio->lock);
 	spin_lock_init(&serio->lock);
 	mutex_init(&serio->drv_mutex);
 	mutex_init(&serio->drv_mutex);
 	device_initialize(&serio->dev);
 	device_initialize(&serio->dev);
@@ -542,6 +548,8 @@ static void serio_init_port(struct serio *serio)
  */
  */
 static void serio_add_port(struct serio *serio)
 static void serio_add_port(struct serio *serio)
 {
 {
+	int error;
+
 	if (serio->parent) {
 	if (serio->parent) {
 		serio_pause_rx(serio->parent);
 		serio_pause_rx(serio->parent);
 		serio->parent->child = serio;
 		serio->parent->child = serio;
@@ -551,9 +559,19 @@ static void serio_add_port(struct serio *serio)
 	list_add_tail(&serio->node, &serio_list);
 	list_add_tail(&serio->node, &serio_list);
 	if (serio->start)
 	if (serio->start)
 		serio->start(serio);
 		serio->start(serio);
-	device_add(&serio->dev);
-	sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
-	serio->registered = 1;
+	error = device_add(&serio->dev);
+	if (error)
+		printk(KERN_ERR
+			"serio: device_add() failed for %s (%s), error: %d\n",
+			serio->phys, serio->name, error);
+	else {
+		serio->registered = 1;
+		error = sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
+		if (error)
+			printk(KERN_ERR
+				"serio: sysfs_create_group() failed for %s (%s), error: %d\n",
+				serio->phys, serio->name, error);
+	}
 }
 }
 
 
 /*
 /*
@@ -583,10 +601,10 @@ static void serio_destroy_port(struct serio *serio)
 	if (serio->registered) {
 	if (serio->registered) {
 		sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
 		sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
 		device_del(&serio->dev);
 		device_del(&serio->dev);
-		list_del_init(&serio->node);
 		serio->registered = 0;
 		serio->registered = 0;
 	}
 	}
 
 
+	list_del_init(&serio->node);
 	serio_remove_pending_events(serio);
 	serio_remove_pending_events(serio);
 	put_device(&serio->dev);
 	put_device(&serio->dev);
 }
 }
@@ -756,6 +774,17 @@ static struct bus_type serio_bus = {
 	.remove = serio_driver_remove,
 	.remove = serio_driver_remove,
 };
 };
 
 
+static void serio_add_driver(struct serio_driver *drv)
+{
+	int error;
+
+	error = driver_register(&drv->driver);
+	if (error)
+		printk(KERN_ERR
+			"serio: driver_register() failed for %s, error: %d\n",
+			drv->driver.name, error);
+}
+
 void __serio_register_driver(struct serio_driver *drv, struct module *owner)
 void __serio_register_driver(struct serio_driver *drv, struct module *owner)
 {
 {
 	drv->driver.bus = &serio_bus;
 	drv->driver.bus = &serio_bus;
@@ -903,18 +932,26 @@ irqreturn_t serio_interrupt(struct serio *serio,
 
 
 static int __init serio_init(void)
 static int __init serio_init(void)
 {
 {
-	serio_task = kthread_run(serio_thread, NULL, "kseriod");
-	if (IS_ERR(serio_task)) {
-		printk(KERN_ERR "serio: Failed to start kseriod\n");
-		return PTR_ERR(serio_task);
-	}
+	int error;
 
 
 	serio_bus.dev_attrs = serio_device_attrs;
 	serio_bus.dev_attrs = serio_device_attrs;
 	serio_bus.drv_attrs = serio_driver_attrs;
 	serio_bus.drv_attrs = serio_driver_attrs;
 	serio_bus.match = serio_bus_match;
 	serio_bus.match = serio_bus_match;
 	serio_bus.uevent = serio_uevent;
 	serio_bus.uevent = serio_uevent;
 	serio_bus.resume = serio_resume;
 	serio_bus.resume = serio_resume;
-	bus_register(&serio_bus);
+	error = bus_register(&serio_bus);
+	if (error) {
+		printk(KERN_ERR "serio: failed to register serio bus, error: %d\n", error);
+		return error;
+	}
+
+	serio_task = kthread_run(serio_thread, NULL, "kseriod");
+	if (IS_ERR(serio_task)) {
+		bus_unregister(&serio_bus);
+		error = PTR_ERR(serio_task);
+		printk(KERN_ERR "serio: Failed to start kseriod, error: %d\n", error);
+		return error;
+	}
 
 
 	return 0;
 	return 0;
 }
 }

+ 0 - 1
drivers/isdn/hardware/eicon/divasync.h

@@ -256,7 +256,6 @@ typedef struct
 #define NO_ORDER_CHECK_MASK 0x00000010
 #define NO_ORDER_CHECK_MASK 0x00000010
 #define LOW_CHANNEL_MASK 0x00000020
 #define LOW_CHANNEL_MASK 0x00000020
 #define NO_HSCX30_MASK  0x00000040
 #define NO_HSCX30_MASK  0x00000040
-#define MODE_MASK   0x00000080
 #define SET_BOARD   0x00001000
 #define SET_BOARD   0x00001000
 #define SET_CRC4   0x00030000
 #define SET_CRC4   0x00030000
 #define SET_L1_TRISTATE  0x00040000
 #define SET_L1_TRISTATE  0x00040000

+ 3 - 3
drivers/md/linear.c

@@ -162,7 +162,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
 		goto out;
 		goto out;
 	}
 	}
 
 
-	min_spacing = mddev->array_size;
+	min_spacing = conf->array_size;
 	sector_div(min_spacing, PAGE_SIZE/sizeof(struct dev_info *));
 	sector_div(min_spacing, PAGE_SIZE/sizeof(struct dev_info *));
 
 
 	/* min_spacing is the minimum spacing that will fit the hash
 	/* min_spacing is the minimum spacing that will fit the hash
@@ -171,7 +171,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
 	 * that is larger than min_spacing as use the size of that as
 	 * that is larger than min_spacing as use the size of that as
 	 * the actual spacing
 	 * the actual spacing
 	 */
 	 */
-	conf->hash_spacing = mddev->array_size;
+	conf->hash_spacing = conf->array_size;
 	for (i=0; i < cnt-1 ; i++) {
 	for (i=0; i < cnt-1 ; i++) {
 		sector_t sz = 0;
 		sector_t sz = 0;
 		int j;
 		int j;
@@ -228,7 +228,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
 	curr_offset = 0;
 	curr_offset = 0;
 	i = 0;
 	i = 0;
 	for (curr_offset = 0;
 	for (curr_offset = 0;
-	     curr_offset < mddev->array_size;
+	     curr_offset < conf->array_size;
 	     curr_offset += conf->hash_spacing) {
 	     curr_offset += conf->hash_spacing) {
 
 
 		while (i < mddev->raid_disks-1 &&
 		while (i < mddev->raid_disks-1 &&

+ 8 - 0
drivers/pnp/pnpacpi/rsparser.c

@@ -173,6 +173,9 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
 		return;
 		return;
 	}
 	}
 
 
+	if (p->producer_consumer == ACPI_PRODUCER)
+		return;
+
 	if (p->resource_type == ACPI_MEMORY_RANGE)
 	if (p->resource_type == ACPI_MEMORY_RANGE)
 		pnpacpi_parse_allocated_memresource(res_table,
 		pnpacpi_parse_allocated_memresource(res_table,
 				p->minimum, p->address_length);
 				p->minimum, p->address_length);
@@ -252,9 +255,14 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
 		break;
 		break;
 
 
 	case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
 	case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
+		if (res->data.ext_address64.producer_consumer == ACPI_PRODUCER)
+			return AE_OK;
 		break;
 		break;
 
 
 	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
 	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+		if (res->data.extended_irq.producer_consumer == ACPI_PRODUCER)
+			return AE_OK;
+
 		for (i = 0; i < res->data.extended_irq.interrupt_count; i++) {
 		for (i = 0; i < res->data.extended_irq.interrupt_count; i++) {
 			pnpacpi_parse_allocated_irqresource(res_table,
 			pnpacpi_parse_allocated_irqresource(res_table,
 				res->data.extended_irq.interrupts[i],
 				res->data.extended_irq.interrupts[i],

+ 99 - 74
drivers/usb/input/ati_remote.c

@@ -111,14 +111,28 @@
 #define NAME_BUFSIZE      80    /* size of product name, path buffers */
 #define NAME_BUFSIZE      80    /* size of product name, path buffers */
 #define DATA_BUFSIZE      63    /* size of URB data buffers */
 #define DATA_BUFSIZE      63    /* size of URB data buffers */
 
 
+/*
+ * Duplicate event filtering time.
+ * Sequential, identical KIND_FILTERED inputs with less than
+ * FILTER_TIME milliseconds between them are considered as repeat
+ * events. The hardware generates 5 events for the first keypress
+ * and we have to take this into account for an accurate repeat
+ * behaviour.
+ */
+#define FILTER_TIME	60 /* msec */
+
 static unsigned long channel_mask;
 static unsigned long channel_mask;
-module_param(channel_mask, ulong, 0444);
+module_param(channel_mask, ulong, 0644);
 MODULE_PARM_DESC(channel_mask, "Bitmask of remote control channels to ignore");
 MODULE_PARM_DESC(channel_mask, "Bitmask of remote control channels to ignore");
 
 
 static int debug;
 static int debug;
-module_param(debug, int, 0444);
+module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Enable extra debug messages and information");
 MODULE_PARM_DESC(debug, "Enable extra debug messages and information");
 
 
+static int repeat_filter = FILTER_TIME;
+module_param(repeat_filter, int, 0644);
+MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec");
+
 #define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
 #define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
 #undef err
 #undef err
 #define err(format, arg...) printk(KERN_ERR format , ## arg)
 #define err(format, arg...) printk(KERN_ERR format , ## arg)
@@ -143,18 +157,6 @@ MODULE_DEVICE_TABLE(usb, ati_remote_table);
 static char init1[] = { 0x01, 0x00, 0x20, 0x14 };
 static char init1[] = { 0x01, 0x00, 0x20, 0x14 };
 static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 };
 static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 };
 
 
-/* Acceleration curve for directional control pad */
-static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
-
-/* Duplicate event filtering time.
- * Sequential, identical KIND_FILTERED inputs with less than
- * FILTER_TIME jiffies between them are considered as repeat
- * events. The hardware generates 5 events for the first keypress
- * and we have to take this into account for an accurate repeat
- * behaviour.
- */
-#define FILTER_TIME 60 /* msec */
-
 struct ati_remote {
 struct ati_remote {
 	struct input_dev *idev;
 	struct input_dev *idev;
 	struct usb_device *udev;
 	struct usb_device *udev;
@@ -411,6 +413,43 @@ static int ati_remote_event_lookup(int rem, unsigned char d1, unsigned char d2)
 	return -1;
 	return -1;
 }
 }
 
 
+/*
+ *	ati_remote_compute_accel
+ *
+ * Implements acceleration curve for directional control pad
+ * If elapsed time since last event is > 1/4 second, user "stopped",
+ * so reset acceleration. Otherwise, user is probably holding the control
+ * pad down, so we increase acceleration, ramping up over two seconds to
+ * a maximum speed.
+ */
+static int ati_remote_compute_accel(struct ati_remote *ati_remote)
+{
+	static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
+	unsigned long now = jiffies;
+	int acc;
+
+	if (time_after(now, ati_remote->old_jiffies + msecs_to_jiffies(250))) {
+		acc = 1;
+		ati_remote->acc_jiffies = now;
+	}
+	else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(125)))
+		acc = accel[0];
+	else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(250)))
+		acc = accel[1];
+	else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(500)))
+		acc = accel[2];
+	else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(1000)))
+		acc = accel[3];
+	else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(1500)))
+		acc = accel[4];
+	else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(2000)))
+		acc = accel[5];
+	else
+		acc = accel[6];
+
+	return acc;
+}
+
 /*
 /*
  *	ati_remote_report_input
  *	ati_remote_report_input
  */
  */
@@ -464,9 +503,9 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
 
 
 	if (ati_remote_tbl[index].kind == KIND_FILTERED) {
 	if (ati_remote_tbl[index].kind == KIND_FILTERED) {
 		/* Filter duplicate events which happen "too close" together. */
 		/* Filter duplicate events which happen "too close" together. */
-		if ((ati_remote->old_data[0] == data[1]) &&
-			(ati_remote->old_data[1] == data[2]) &&
-			time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(FILTER_TIME))) {
+		if (ati_remote->old_data[0] == data[1] &&
+		    ati_remote->old_data[1] == data[2] &&
+		    time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(repeat_filter))) {
 			ati_remote->repeat_count++;
 			ati_remote->repeat_count++;
 		} else {
 		} else {
 			ati_remote->repeat_count = 0;
 			ati_remote->repeat_count = 0;
@@ -476,75 +515,61 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
 		ati_remote->old_data[1] = data[2];
 		ati_remote->old_data[1] = data[2];
 		ati_remote->old_jiffies = jiffies;
 		ati_remote->old_jiffies = jiffies;
 
 
-		if ((ati_remote->repeat_count > 0)
-		    && (ati_remote->repeat_count < 5))
+		if (ati_remote->repeat_count > 0 &&
+		    ati_remote->repeat_count < 5)
 			return;
 			return;
 
 
 
 
 		input_regs(dev, regs);
 		input_regs(dev, regs);
 		input_event(dev, ati_remote_tbl[index].type,
 		input_event(dev, ati_remote_tbl[index].type,
 			ati_remote_tbl[index].code, 1);
 			ati_remote_tbl[index].code, 1);
+		input_sync(dev);
 		input_event(dev, ati_remote_tbl[index].type,
 		input_event(dev, ati_remote_tbl[index].type,
 			ati_remote_tbl[index].code, 0);
 			ati_remote_tbl[index].code, 0);
 		input_sync(dev);
 		input_sync(dev);
 
 
-		return;
-	}
+	} else {
 
 
-	/*
-	 * Other event kinds are from the directional control pad, and have an
-	 * acceleration factor applied to them.  Without this acceleration, the
-	 * control pad is mostly unusable.
-	 *
-	 * If elapsed time since last event is > 1/4 second, user "stopped",
-	 * so reset acceleration. Otherwise, user is probably holding the control
-	 * pad down, so we increase acceleration, ramping up over two seconds to
-	 * a maximum speed.  The acceleration curve is #defined above.
-	 */
-	if (time_after(jiffies, ati_remote->old_jiffies + (HZ >> 2))) {
-		acc = 1;
-		ati_remote->acc_jiffies = jiffies;
-	}
-	else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 3)))  acc = accel[0];
-	else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 2)))  acc = accel[1];
-	else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 1)))  acc = accel[2];
-	else if (time_before(jiffies, ati_remote->acc_jiffies + HZ))         acc = accel[3];
-	else if (time_before(jiffies, ati_remote->acc_jiffies + HZ+(HZ>>1))) acc = accel[4];
-	else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ << 1)))  acc = accel[5];
-	else acc = accel[6];
-
-	input_regs(dev, regs);
-	switch (ati_remote_tbl[index].kind) {
-	case KIND_ACCEL:
-		input_event(dev, ati_remote_tbl[index].type,
-			ati_remote_tbl[index].code,
-			ati_remote_tbl[index].value * acc);
-		break;
-	case KIND_LU:
-		input_report_rel(dev, REL_X, -acc);
-		input_report_rel(dev, REL_Y, -acc);
-		break;
-	case KIND_RU:
-		input_report_rel(dev, REL_X, acc);
-		input_report_rel(dev, REL_Y, -acc);
-		break;
-	case KIND_LD:
-		input_report_rel(dev, REL_X, -acc);
-		input_report_rel(dev, REL_Y, acc);
-		break;
-	case KIND_RD:
-		input_report_rel(dev, REL_X, acc);
-		input_report_rel(dev, REL_Y, acc);
-		break;
-	default:
-		dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n",
-			ati_remote_tbl[index].kind);
-	}
-	input_sync(dev);
+		/*
+		 * Other event kinds are from the directional control pad, and have an
+		 * acceleration factor applied to them.  Without this acceleration, the
+		 * control pad is mostly unusable.
+		 */
+		acc = ati_remote_compute_accel(ati_remote);
+
+		input_regs(dev, regs);
+		switch (ati_remote_tbl[index].kind) {
+		case KIND_ACCEL:
+			input_event(dev, ati_remote_tbl[index].type,
+				ati_remote_tbl[index].code,
+				ati_remote_tbl[index].value * acc);
+			break;
+		case KIND_LU:
+			input_report_rel(dev, REL_X, -acc);
+			input_report_rel(dev, REL_Y, -acc);
+			break;
+		case KIND_RU:
+			input_report_rel(dev, REL_X, acc);
+			input_report_rel(dev, REL_Y, -acc);
+			break;
+		case KIND_LD:
+			input_report_rel(dev, REL_X, -acc);
+			input_report_rel(dev, REL_Y, acc);
+			break;
+		case KIND_RD:
+			input_report_rel(dev, REL_X, acc);
+			input_report_rel(dev, REL_Y, acc);
+			break;
+		default:
+			dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n",
+				ati_remote_tbl[index].kind);
+		}
+		input_sync(dev);
 
 
-	ati_remote->old_jiffies = jiffies;
-	ati_remote->old_data[0] = data[1];
-	ati_remote->old_data[1] = data[2];
+		ati_remote->old_jiffies = jiffies;
+		ati_remote->old_data[0] = data[1];
+		ati_remote->old_data[1] = data[2];
+	}
 }
 }
 
 
 /*
 /*

+ 2 - 1
drivers/usb/input/hid-input.c

@@ -607,7 +607,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 
 
 	}
 	}
 
 
-	if (usage->hat_min < usage->hat_max || usage->hat_dir) {
+	if (usage->type == EV_ABS &&
+	    (usage->hat_min < usage->hat_max || usage->hat_dir)) {
 		int i;
 		int i;
 		for (i = usage->code; i < usage->code + 2 && i <= max; i++) {
 		for (i = usage->code; i < usage->code + 2 && i <= max; i++) {
 			input_set_abs_params(input, i, -1, 1, 0, 0);
 			input_set_abs_params(input, i, -1, 1, 0, 0);

+ 38 - 34
drivers/usb/input/hiddev.c

@@ -49,7 +49,7 @@ struct hiddev {
 	int open;
 	int open;
 	wait_queue_head_t wait;
 	wait_queue_head_t wait;
 	struct hid_device *hid;
 	struct hid_device *hid;
-	struct hiddev_list *list;
+	struct list_head list;
 };
 };
 
 
 struct hiddev_list {
 struct hiddev_list {
@@ -59,7 +59,7 @@ struct hiddev_list {
 	unsigned flags;
 	unsigned flags;
 	struct fasync_struct *fasync;
 	struct fasync_struct *fasync;
 	struct hiddev *hiddev;
 	struct hiddev *hiddev;
-	struct hiddev_list *next;
+	struct list_head node;
 };
 };
 
 
 static struct hiddev *hiddev_table[HIDDEV_MINORS];
 static struct hiddev *hiddev_table[HIDDEV_MINORS];
@@ -73,12 +73,15 @@ static struct hiddev *hiddev_table[HIDDEV_MINORS];
 static struct hid_report *
 static struct hid_report *
 hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo)
 hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo)
 {
 {
-	unsigned flags = rinfo->report_id & ~HID_REPORT_ID_MASK;
+	unsigned int flags = rinfo->report_id & ~HID_REPORT_ID_MASK;
+	unsigned int rid = rinfo->report_id & HID_REPORT_ID_MASK;
 	struct hid_report_enum *report_enum;
 	struct hid_report_enum *report_enum;
+	struct hid_report *report;
 	struct list_head *list;
 	struct list_head *list;
 
 
 	if (rinfo->report_type < HID_REPORT_TYPE_MIN ||
 	if (rinfo->report_type < HID_REPORT_TYPE_MIN ||
-	    rinfo->report_type > HID_REPORT_TYPE_MAX) return NULL;
+	    rinfo->report_type > HID_REPORT_TYPE_MAX)
+		return NULL;
 
 
 	report_enum = hid->report_enum +
 	report_enum = hid->report_enum +
 		(rinfo->report_type - HID_REPORT_TYPE_MIN);
 		(rinfo->report_type - HID_REPORT_TYPE_MIN);
@@ -88,21 +91,25 @@ hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo)
 		break;
 		break;
 
 
 	case HID_REPORT_ID_FIRST:
 	case HID_REPORT_ID_FIRST:
-		list = report_enum->report_list.next;
-		if (list == &report_enum->report_list)
+		if (list_empty(&report_enum->report_list))
 			return NULL;
 			return NULL;
-		rinfo->report_id = ((struct hid_report *) list)->id;
+
+		list = report_enum->report_list.next;
+		report = list_entry(list, struct hid_report, list);
+		rinfo->report_id = report->id;
 		break;
 		break;
 
 
 	case HID_REPORT_ID_NEXT:
 	case HID_REPORT_ID_NEXT:
-		list = (struct list_head *)
-			report_enum->report_id_hash[rinfo->report_id & HID_REPORT_ID_MASK];
-		if (list == NULL)
+		report = report_enum->report_id_hash[rid];
+		if (!report)
 			return NULL;
 			return NULL;
-		list = list->next;
+
+		list = report->list.next;
 		if (list == &report_enum->report_list)
 		if (list == &report_enum->report_list)
 			return NULL;
 			return NULL;
-		rinfo->report_id = ((struct hid_report *) list)->id;
+
+		report = list_entry(list, struct hid_report, list);
+		rinfo->report_id = report->id;
 		break;
 		break;
 
 
 	default:
 	default:
@@ -125,12 +132,13 @@ hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref)
 	struct hid_field *field;
 	struct hid_field *field;
 
 
 	if (uref->report_type < HID_REPORT_TYPE_MIN ||
 	if (uref->report_type < HID_REPORT_TYPE_MIN ||
-	    uref->report_type > HID_REPORT_TYPE_MAX) return NULL;
+	    uref->report_type > HID_REPORT_TYPE_MAX)
+		return NULL;
 
 
 	report_enum = hid->report_enum +
 	report_enum = hid->report_enum +
 		(uref->report_type - HID_REPORT_TYPE_MIN);
 		(uref->report_type - HID_REPORT_TYPE_MIN);
 
 
-	list_for_each_entry(report, &report_enum->report_list, list)
+	list_for_each_entry(report, &report_enum->report_list, list) {
 		for (i = 0; i < report->maxfield; i++) {
 		for (i = 0; i < report->maxfield; i++) {
 			field = report->field[i];
 			field = report->field[i];
 			for (j = 0; j < field->maxusage; j++) {
 			for (j = 0; j < field->maxusage; j++) {
@@ -142,6 +150,7 @@ hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref)
 				}
 				}
 			}
 			}
 		}
 		}
+	}
 
 
 	return NULL;
 	return NULL;
 }
 }
@@ -150,9 +159,9 @@ static void hiddev_send_event(struct hid_device *hid,
 			      struct hiddev_usage_ref *uref)
 			      struct hiddev_usage_ref *uref)
 {
 {
 	struct hiddev *hiddev = hid->hiddev;
 	struct hiddev *hiddev = hid->hiddev;
-	struct hiddev_list *list = hiddev->list;
+	struct hiddev_list *list;
 
 
-	while (list) {
+	list_for_each_entry(list, &hiddev->list, node) {
 		if (uref->field_index != HID_FIELD_INDEX_NONE ||
 		if (uref->field_index != HID_FIELD_INDEX_NONE ||
 		    (list->flags & HIDDEV_FLAG_REPORT) != 0) {
 		    (list->flags & HIDDEV_FLAG_REPORT) != 0) {
 			list->buffer[list->head] = *uref;
 			list->buffer[list->head] = *uref;
@@ -160,8 +169,6 @@ static void hiddev_send_event(struct hid_device *hid,
 				(HIDDEV_BUFFER_SIZE - 1);
 				(HIDDEV_BUFFER_SIZE - 1);
 			kill_fasync(&list->fasync, SIGIO, POLL_IN);
 			kill_fasync(&list->fasync, SIGIO, POLL_IN);
 		}
 		}
-
-		list = list->next;
 	}
 	}
 
 
 	wake_up_interruptible(&hiddev->wait);
 	wake_up_interruptible(&hiddev->wait);
@@ -180,7 +187,7 @@ void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
 	uref.report_type =
 	uref.report_type =
 	  (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
 	  (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
 	  ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
 	  ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
-	   ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
+	   ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE : 0));
 	uref.report_id = field->report->id;
 	uref.report_id = field->report->id;
 	uref.field_index = field->index;
 	uref.field_index = field->index;
 	uref.usage_index = (usage - field->usage);
 	uref.usage_index = (usage - field->usage);
@@ -200,7 +207,7 @@ void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
 	uref.report_type =
 	uref.report_type =
 	  (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
 	  (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
 	  ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
 	  ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
-	   ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
+	   ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE : 0));
 	uref.report_id = report->id;
 	uref.report_id = report->id;
 	uref.field_index = HID_FIELD_INDEX_NONE;
 	uref.field_index = HID_FIELD_INDEX_NONE;
 
 
@@ -213,7 +220,9 @@ static int hiddev_fasync(int fd, struct file *file, int on)
 {
 {
 	int retval;
 	int retval;
 	struct hiddev_list *list = file->private_data;
 	struct hiddev_list *list = file->private_data;
+
 	retval = fasync_helper(fd, file, on, &list->fasync);
 	retval = fasync_helper(fd, file, on, &list->fasync);
+
 	return retval < 0 ? retval : 0;
 	return retval < 0 ? retval : 0;
 }
 }
 
 
@@ -224,14 +233,9 @@ static int hiddev_fasync(int fd, struct file *file, int on)
 static int hiddev_release(struct inode * inode, struct file * file)
 static int hiddev_release(struct inode * inode, struct file * file)
 {
 {
 	struct hiddev_list *list = file->private_data;
 	struct hiddev_list *list = file->private_data;
-	struct hiddev_list **listptr;
 
 
-	listptr = &list->hiddev->list;
 	hiddev_fasync(-1, file, 0);
 	hiddev_fasync(-1, file, 0);
-
-	while (*listptr && (*listptr != list))
-		listptr = &((*listptr)->next);
-	*listptr = (*listptr)->next;
+	list_del(&list->node);
 
 
 	if (!--list->hiddev->open) {
 	if (!--list->hiddev->open) {
 		if (list->hiddev->exist)
 		if (list->hiddev->exist)
@@ -248,7 +252,8 @@ static int hiddev_release(struct inode * inode, struct file * file)
 /*
 /*
  * open file op
  * open file op
  */
  */
-static int hiddev_open(struct inode * inode, struct file * file) {
+static int hiddev_open(struct inode *inode, struct file *file)
+{
 	struct hiddev_list *list;
 	struct hiddev_list *list;
 
 
 	int i = iminor(inode) - HIDDEV_MINOR_BASE;
 	int i = iminor(inode) - HIDDEV_MINOR_BASE;
@@ -260,9 +265,7 @@ static int hiddev_open(struct inode * inode, struct file * file) {
 		return -ENOMEM;
 		return -ENOMEM;
 
 
 	list->hiddev = hiddev_table[i];
 	list->hiddev = hiddev_table[i];
-	list->next = hiddev_table[i]->list;
-	hiddev_table[i]->list = list;
-
+	list_add_tail(&list->node, &hiddev_table[i]->list);
 	file->private_data = list;
 	file->private_data = list;
 
 
 	if (!list->hiddev->open++)
 	if (!list->hiddev->open++)
@@ -362,6 +365,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
 static unsigned int hiddev_poll(struct file *file, poll_table *wait)
 static unsigned int hiddev_poll(struct file *file, poll_table *wait)
 {
 {
 	struct hiddev_list *list = file->private_data;
 	struct hiddev_list *list = file->private_data;
+
 	poll_wait(file, &list->hiddev->wait, wait);
 	poll_wait(file, &list->hiddev->wait, wait);
 	if (list->head != list->tail)
 	if (list->head != list->tail)
 		return POLLIN | POLLRDNORM;
 		return POLLIN | POLLRDNORM;
@@ -382,7 +386,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
 	struct hiddev_collection_info cinfo;
 	struct hiddev_collection_info cinfo;
 	struct hiddev_report_info rinfo;
 	struct hiddev_report_info rinfo;
 	struct hiddev_field_info finfo;
 	struct hiddev_field_info finfo;
-	struct hiddev_usage_ref_multi *uref_multi=NULL;
+	struct hiddev_usage_ref_multi *uref_multi = NULL;
 	struct hiddev_usage_ref *uref;
 	struct hiddev_usage_ref *uref;
 	struct hiddev_devinfo dinfo;
 	struct hiddev_devinfo dinfo;
 	struct hid_report *report;
 	struct hid_report *report;
@@ -764,15 +768,15 @@ int hiddev_connect(struct hid_device *hid)
 	}
 	}
 
 
 	init_waitqueue_head(&hiddev->wait);
 	init_waitqueue_head(&hiddev->wait);
-
-	hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;
-
+	INIT_LIST_HEAD(&hiddev->list);
 	hiddev->hid = hid;
 	hiddev->hid = hid;
 	hiddev->exist = 1;
 	hiddev->exist = 1;
 
 
 	hid->minor = hid->intf->minor;
 	hid->minor = hid->intf->minor;
 	hid->hiddev = hiddev;
 	hid->hiddev = hiddev;
 
 
+	hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;
+
 	return 0;
 	return 0;
 }
 }
 
 

+ 3 - 7
drivers/video/aty/aty128fb.c

@@ -1913,9 +1913,6 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
 	u8 chip_rev;
 	u8 chip_rev;
 	u32 dac;
 	u32 dac;
 
 
-	if (!par->vram_size)	/* may have already been probed */
-		par->vram_size = aty_ld_le32(CONFIG_MEMSIZE) & 0x03FFFFFF;
-
 	/* Get the chip revision */
 	/* Get the chip revision */
 	chip_rev = (aty_ld_le32(CONFIG_CNTL) >> 16) & 0x1F;
 	chip_rev = (aty_ld_le32(CONFIG_CNTL) >> 16) & 0x1F;
 
 
@@ -2028,9 +2025,6 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
 
 
 	aty128_init_engine(par);
 	aty128_init_engine(par);
 
 
-	if (register_framebuffer(info) < 0)
-		return 0;
-
 	par->pm_reg = pci_find_capability(pdev, PCI_CAP_ID_PM);
 	par->pm_reg = pci_find_capability(pdev, PCI_CAP_ID_PM);
 	par->pdev = pdev;
 	par->pdev = pdev;
 	par->asleep = 0;
 	par->asleep = 0;
@@ -2040,6 +2034,9 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
 	aty128_bl_init(par);
 	aty128_bl_init(par);
 #endif
 #endif
 
 
+	if (register_framebuffer(info) < 0)
+		return 0;
+
 	printk(KERN_INFO "fb%d: %s frame buffer device on %s\n",
 	printk(KERN_INFO "fb%d: %s frame buffer device on %s\n",
 	       info->node, info->fix.id, video_card);
 	       info->node, info->fix.id, video_card);
 
 
@@ -2089,7 +2086,6 @@ static int __devinit aty128_probe(struct pci_dev *pdev, const struct pci_device_
 	par = info->par;
 	par = info->par;
 
 
 	info->pseudo_palette = par->pseudo_palette;
 	info->pseudo_palette = par->pseudo_palette;
-	info->fix = aty128fb_fix;
 
 
 	/* Virtualize mmio region */
 	/* Virtualize mmio region */
 	info->fix.mmio_start = reg_addr;
 	info->fix.mmio_start = reg_addr;

+ 8 - 10
drivers/video/au1100fb.c

@@ -156,7 +156,7 @@ int au1100fb_setmode(struct au1100fb_device *fbdev)
 
 
 			info->fix.visual = FB_VISUAL_TRUECOLOR;
 			info->fix.visual = FB_VISUAL_TRUECOLOR;
 			info->fix.line_length = info->var.xres_virtual << 1; /* depth=16 */
 			info->fix.line_length = info->var.xres_virtual << 1; /* depth=16 */
-	}
+		}
 	} else {
 	} else {
 		/* mono */
 		/* mono */
 		info->fix.visual = FB_VISUAL_MONO10;
 		info->fix.visual = FB_VISUAL_MONO10;
@@ -164,20 +164,16 @@ int au1100fb_setmode(struct au1100fb_device *fbdev)
 	}
 	}
 
 
 	info->screen_size = info->fix.line_length * info->var.yres_virtual;
 	info->screen_size = info->fix.line_length * info->var.yres_virtual;
+	info->var.rotate = ((fbdev->panel->control_base&LCD_CONTROL_SM_MASK) \
+				>> LCD_CONTROL_SM_BIT) * 90;
 
 
 	/* Determine BPP mode and format */
 	/* Determine BPP mode and format */
-	fbdev->regs->lcd_control = fbdev->panel->control_base |
-			    ((info->var.rotate/90) << LCD_CONTROL_SM_BIT);
-
-	fbdev->regs->lcd_intenable = 0;
-	fbdev->regs->lcd_intstatus = 0;
-
+	fbdev->regs->lcd_control = fbdev->panel->control_base;
 	fbdev->regs->lcd_horztiming = fbdev->panel->horztiming;
 	fbdev->regs->lcd_horztiming = fbdev->panel->horztiming;
-
 	fbdev->regs->lcd_verttiming = fbdev->panel->verttiming;
 	fbdev->regs->lcd_verttiming = fbdev->panel->verttiming;
-
 	fbdev->regs->lcd_clkcontrol = fbdev->panel->clkcontrol_base;
 	fbdev->regs->lcd_clkcontrol = fbdev->panel->clkcontrol_base;
-
+	fbdev->regs->lcd_intenable = 0;
+	fbdev->regs->lcd_intstatus = 0;
 	fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(fbdev->fb_phys);
 	fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(fbdev->fb_phys);
 
 
 	if (panel_is_dual(fbdev->panel)) {
 	if (panel_is_dual(fbdev->panel)) {
@@ -206,6 +202,8 @@ int au1100fb_setmode(struct au1100fb_device *fbdev)
 
 
 	/* Resume controller */
 	/* Resume controller */
 	fbdev->regs->lcd_control |= LCD_CONTROL_GO;
 	fbdev->regs->lcd_control |= LCD_CONTROL_GO;
+	mdelay(10);
+	au1100fb_fb_blank(VESA_NO_BLANKING, info);
 
 
 	return 0;
 	return 0;
 }
 }

+ 9 - 2
fs/befs/linuxvfs.c

@@ -512,7 +512,11 @@ befs_utf2nls(struct super_block *sb, const char *in,
 	wchar_t uni;
 	wchar_t uni;
 	int unilen, utflen;
 	int unilen, utflen;
 	char *result;
 	char *result;
-	int maxlen = in_len; /* The utf8->nls conversion can't make more chars */
+	/* The utf8->nls conversion won't make the final nls string bigger
+	 * than the utf one, but if the string is pure ascii they'll have the
+	 * same width and an extra char is needed to save the additional \0
+	 */
+	int maxlen = in_len + 1;
 
 
 	befs_debug(sb, "---> utf2nls()");
 	befs_debug(sb, "---> utf2nls()");
 
 
@@ -588,7 +592,10 @@ befs_nls2utf(struct super_block *sb, const char *in,
 	wchar_t uni;
 	wchar_t uni;
 	int unilen, utflen;
 	int unilen, utflen;
 	char *result;
 	char *result;
-	int maxlen = 3 * in_len;
+	/* There're nls characters that will translate to 3-chars-wide UTF-8
+	 * characters, a additional byte is needed to save the final \0
+	 * in special cases */
+	int maxlen = (3 * in_len) + 1;
 
 
 	befs_debug(sb, "---> nls2utf()\n");
 	befs_debug(sb, "---> nls2utf()\n");
 
 

+ 3 - 9
fs/lockd/svclock.c

@@ -638,9 +638,6 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
 	if (task->tk_status < 0) {
 	if (task->tk_status < 0) {
 		/* RPC error: Re-insert for retransmission */
 		/* RPC error: Re-insert for retransmission */
 		timeout = 10 * HZ;
 		timeout = 10 * HZ;
-	} else if (block->b_done) {
-		/* Block already removed, kill it for real */
-		timeout = 0;
 	} else {
 	} else {
 		/* Call was successful, now wait for client callback */
 		/* Call was successful, now wait for client callback */
 		timeout = 60 * HZ;
 		timeout = 60 * HZ;
@@ -709,13 +706,10 @@ nlmsvc_retry_blocked(void)
 			break;
 			break;
 	        if (time_after(block->b_when,jiffies))
 	        if (time_after(block->b_when,jiffies))
 			break;
 			break;
-		dprintk("nlmsvc_retry_blocked(%p, when=%ld, done=%d)\n",
-			block, block->b_when, block->b_done);
+		dprintk("nlmsvc_retry_blocked(%p, when=%ld)\n",
+			block, block->b_when);
 		kref_get(&block->b_count);
 		kref_get(&block->b_count);
-		if (block->b_done)
-			nlmsvc_unlink_block(block);
-		else
-			nlmsvc_grant_blocked(block);
+		nlmsvc_grant_blocked(block);
 		nlmsvc_release_block(block);
 		nlmsvc_release_block(block);
 	}
 	}
 
 

+ 3 - 1
fs/nfs/namespace.c

@@ -51,7 +51,7 @@ char *nfs_path(const char *base, const struct dentry *dentry,
 		namelen = dentry->d_name.len;
 		namelen = dentry->d_name.len;
 		buflen -= namelen + 1;
 		buflen -= namelen + 1;
 		if (buflen < 0)
 		if (buflen < 0)
-			goto Elong;
+			goto Elong_unlock;
 		end -= namelen;
 		end -= namelen;
 		memcpy(end, dentry->d_name.name, namelen);
 		memcpy(end, dentry->d_name.name, namelen);
 		*--end = '/';
 		*--end = '/';
@@ -68,6 +68,8 @@ char *nfs_path(const char *base, const struct dentry *dentry,
 	end -= namelen;
 	end -= namelen;
 	memcpy(end, base, namelen);
 	memcpy(end, base, namelen);
 	return end;
 	return end;
+Elong_unlock:
+	spin_unlock(&dcache_lock);
 Elong:
 Elong:
 	return ERR_PTR(-ENAMETOOLONG);
 	return ERR_PTR(-ENAMETOOLONG);
 }
 }

+ 1 - 1
fs/nfs/read.c

@@ -63,7 +63,7 @@ struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
 	return p;
 	return p;
 }
 }
 
 
-void nfs_readdata_free(struct nfs_read_data *p)
+static void nfs_readdata_free(struct nfs_read_data *p)
 {
 {
 	if (p && (p->pagevec != &p->page_array[0]))
 	if (p && (p->pagevec != &p->page_array[0]))
 		kfree(p->pagevec);
 		kfree(p->pagevec);

+ 1 - 1
fs/nfs/write.c

@@ -137,7 +137,7 @@ struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
 	return p;
 	return p;
 }
 }
 
 
-void nfs_writedata_free(struct nfs_write_data *p)
+static void nfs_writedata_free(struct nfs_write_data *p)
 {
 {
 	if (p && (p->pagevec != &p->page_array[0]))
 	if (p && (p->pagevec != &p->page_array[0]))
 		kfree(p->pagevec);
 		kfree(p->pagevec);

+ 1 - 1
fs/reiserfs/file.c

@@ -48,8 +48,8 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
 		return 0;
 		return 0;
 	}
 	}
 
 
-	reiserfs_write_lock(inode->i_sb);
 	mutex_lock(&inode->i_mutex);
 	mutex_lock(&inode->i_mutex);
+	reiserfs_write_lock(inode->i_sb);
 	/* freeing preallocation only involves relogging blocks that
 	/* freeing preallocation only involves relogging blocks that
 	 * are already in the current transaction.  preallocation gets
 	 * are already in the current transaction.  preallocation gets
 	 * freed at the end of each transaction, so it is impossible for
 	 * freed at the end of each transaction, so it is impossible for

+ 14 - 12
fs/reiserfs/inode.c

@@ -39,14 +39,10 @@ void reiserfs_delete_inode(struct inode *inode)
 
 
 	/* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */
 	/* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */
 	if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) {	/* also handles bad_inode case */
 	if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) {	/* also handles bad_inode case */
-		mutex_lock(&inode->i_mutex);
-
 		reiserfs_delete_xattrs(inode);
 		reiserfs_delete_xattrs(inode);
 
 
-		if (journal_begin(&th, inode->i_sb, jbegin_count)) {
-			mutex_unlock(&inode->i_mutex);
+		if (journal_begin(&th, inode->i_sb, jbegin_count))
 			goto out;
 			goto out;
-		}
 		reiserfs_update_inode_transaction(inode);
 		reiserfs_update_inode_transaction(inode);
 
 
 		err = reiserfs_delete_object(&th, inode);
 		err = reiserfs_delete_object(&th, inode);
@@ -57,12 +53,8 @@ void reiserfs_delete_inode(struct inode *inode)
 		if (!err) 
 		if (!err) 
 			DQUOT_FREE_INODE(inode);
 			DQUOT_FREE_INODE(inode);
 
 
-		if (journal_end(&th, inode->i_sb, jbegin_count)) {
-			mutex_unlock(&inode->i_mutex);
+		if (journal_end(&th, inode->i_sb, jbegin_count))
 			goto out;
 			goto out;
-		}
-
-		mutex_unlock(&inode->i_mutex);
 
 
 		/* check return value from reiserfs_delete_object after
 		/* check return value from reiserfs_delete_object after
 		 * ending the transaction
 		 * ending the transaction
@@ -2348,6 +2340,7 @@ static int reiserfs_write_full_page(struct page *page,
 	unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT;
 	unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT;
 	int error = 0;
 	int error = 0;
 	unsigned long block;
 	unsigned long block;
+	sector_t last_block;
 	struct buffer_head *head, *bh;
 	struct buffer_head *head, *bh;
 	int partial = 0;
 	int partial = 0;
 	int nr = 0;
 	int nr = 0;
@@ -2395,10 +2388,19 @@ static int reiserfs_write_full_page(struct page *page,
 	}
 	}
 	bh = head;
 	bh = head;
 	block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits);
 	block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits);
+	last_block = (i_size_read(inode) - 1) >> inode->i_blkbits;
 	/* first map all the buffers, logging any direct items we find */
 	/* first map all the buffers, logging any direct items we find */
 	do {
 	do {
-		if ((checked || buffer_dirty(bh)) && (!buffer_mapped(bh) ||
-						      (buffer_mapped(bh)
+		if (block > last_block) {
+			/*
+			 * This can happen when the block size is less than
+			 * the page size.  The corresponding bytes in the page
+			 * were zero filled above
+			 */
+			clear_buffer_dirty(bh);
+			set_buffer_uptodate(bh);
+		} else if ((checked || buffer_dirty(bh)) &&
+		           (!buffer_mapped(bh) || (buffer_mapped(bh)
 						       && bh->b_blocknr ==
 						       && bh->b_blocknr ==
 						       0))) {
 						       0))) {
 			/* not mapped yet, or it points to a direct item, search
 			/* not mapped yet, or it points to a direct item, search

+ 1 - 1
fs/reiserfs/ioctl.c

@@ -116,12 +116,12 @@ static int reiserfs_unpack(struct inode *inode, struct file *filp)
 	if (REISERFS_I(inode)->i_flags & i_nopack_mask) {
 	if (REISERFS_I(inode)->i_flags & i_nopack_mask) {
 		return 0;
 		return 0;
 	}
 	}
-	reiserfs_write_lock(inode->i_sb);
 
 
 	/* we need to make sure nobody is changing the file size beneath
 	/* we need to make sure nobody is changing the file size beneath
 	 ** us
 	 ** us
 	 */
 	 */
 	mutex_lock(&inode->i_mutex);
 	mutex_lock(&inode->i_mutex);
+	reiserfs_write_lock(inode->i_sb);
 
 
 	write_from = inode->i_size & (blocksize - 1);
 	write_from = inode->i_size & (blocksize - 1);
 	/* if we are on a block boundary, we are already unpacked.  */
 	/* if we are on a block boundary, we are already unpacked.  */

+ 6 - 5
fs/udf/ialloc.c

@@ -75,6 +75,12 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
 	}
 	}
 	*err = -ENOSPC;
 	*err = -ENOSPC;
 
 
+	UDF_I_UNIQUE(inode) = 0;
+	UDF_I_LENEXTENTS(inode) = 0;
+	UDF_I_NEXT_ALLOC_BLOCK(inode) = 0;
+	UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
+	UDF_I_STRAT4096(inode) = 0;
+
 	block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum,
 	block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum,
 		start, err);
 		start, err);
 	if (*err)
 	if (*err)
@@ -84,11 +90,6 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
 	}
 	}
 
 
 	mutex_lock(&sbi->s_alloc_mutex);
 	mutex_lock(&sbi->s_alloc_mutex);
-	UDF_I_UNIQUE(inode) = 0;
-	UDF_I_LENEXTENTS(inode) = 0;
-	UDF_I_NEXT_ALLOC_BLOCK(inode) = 0;
-	UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
-	UDF_I_STRAT4096(inode) = 0;
 	if (UDF_SB_LVIDBH(sb))
 	if (UDF_SB_LVIDBH(sb))
 	{
 	{
 		struct logicalVolHeaderDesc *lvhd;
 		struct logicalVolHeaderDesc *lvhd;

+ 1 - 1
fs/ufs/balloc.c

@@ -248,7 +248,7 @@ static void ufs_change_blocknr(struct inode *inode, unsigned int baseblk,
 
 
 		if (likely(cur_index != index)) {
 		if (likely(cur_index != index)) {
 			page = ufs_get_locked_page(mapping, index);
 			page = ufs_get_locked_page(mapping, index);
-			if (IS_ERR(page))
+			if (!page || IS_ERR(page)) /* it was truncated or EIO */
 				continue;
 				continue;
 		} else
 		} else
 			page = locked_page;
 			page = locked_page;

+ 9 - 8
fs/ufs/util.c

@@ -251,12 +251,12 @@ struct page *ufs_get_locked_page(struct address_space *mapping,
 {
 {
 	struct page *page;
 	struct page *page;
 
 
-try_again:
 	page = find_lock_page(mapping, index);
 	page = find_lock_page(mapping, index);
 	if (!page) {
 	if (!page) {
 		page = read_cache_page(mapping, index,
 		page = read_cache_page(mapping, index,
 				       (filler_t*)mapping->a_ops->readpage,
 				       (filler_t*)mapping->a_ops->readpage,
 				       NULL);
 				       NULL);
+
 		if (IS_ERR(page)) {
 		if (IS_ERR(page)) {
 			printk(KERN_ERR "ufs_change_blocknr: "
 			printk(KERN_ERR "ufs_change_blocknr: "
 			       "read_cache_page error: ino %lu, index: %lu\n",
 			       "read_cache_page error: ino %lu, index: %lu\n",
@@ -266,6 +266,14 @@ try_again:
 
 
 		lock_page(page);
 		lock_page(page);
 
 
+		if (unlikely(page->mapping == NULL)) {
+			/* Truncate got there first */
+			unlock_page(page);
+			page_cache_release(page);
+			page = NULL;
+			goto out;
+		}
+
 		if (!PageUptodate(page) || PageError(page)) {
 		if (!PageUptodate(page) || PageError(page)) {
 			unlock_page(page);
 			unlock_page(page);
 			page_cache_release(page);
 			page_cache_release(page);
@@ -275,15 +283,8 @@ try_again:
 			       mapping->host->i_ino, index);
 			       mapping->host->i_ino, index);
 
 
 			page = ERR_PTR(-EIO);
 			page = ERR_PTR(-EIO);
-			goto out;
 		}
 		}
 	}
 	}
-
-	if (unlikely(!page->mapping || !page_has_buffers(page))) {
-		unlock_page(page);
-		page_cache_release(page);
-		goto try_again;/*we really need these buffers*/
-	}
 out:
 out:
 	return page;
 	return page;
 }
 }

+ 2 - 0
include/linux/debug_locks.h

@@ -1,6 +1,8 @@
 #ifndef __LINUX_DEBUG_LOCKING_H
 #ifndef __LINUX_DEBUG_LOCKING_H
 #define __LINUX_DEBUG_LOCKING_H
 #define __LINUX_DEBUG_LOCKING_H
 
 
+struct task_struct;
+
 extern int debug_locks;
 extern int debug_locks;
 extern int debug_locks_silent;
 extern int debug_locks_silent;
 
 

+ 22 - 2
include/linux/input.h

@@ -893,7 +893,6 @@ struct input_dev {
 
 
 	int (*open)(struct input_dev *dev);
 	int (*open)(struct input_dev *dev);
 	void (*close)(struct input_dev *dev);
 	void (*close)(struct input_dev *dev);
-	int (*accept)(struct input_dev *dev, struct file *file);
 	int (*flush)(struct input_dev *dev, struct file *file);
 	int (*flush)(struct input_dev *dev, struct file *file);
 	int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
 	int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
 	int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect);
 	int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect);
@@ -961,6 +960,26 @@ struct input_dev {
 
 
 struct input_handle;
 struct input_handle;
 
 
+/**
+ * struct input_handler - implements one of interfaces for input devices
+ * @private: driver-specific data
+ * @event: event handler
+ * @connect: called when attaching a handler to an input device
+ * @disconnect: disconnects a handler from input device
+ * @start: starts handler for given handle. This function is called by
+ *	input core right after connect() method and also when a process
+ *	that "grabbed" a device releases it
+ * @fops: file operations this driver implements
+ * @minor: beginning of range of 32 minors for devices this driver
+ *	can provide
+ * @name: name of the handler, to be shown in /proc/bus/input/handlers
+ * @id_table: pointer to a table of input_device_ids this driver can
+ *	handle
+ * @blacklist: prointer to a table of input_device_ids this driver should
+ *	ignore even if they match @id_table
+ * @h_list: list of input handles associated with the handler
+ * @node: for placing the driver onto input_handler_list
+ */
 struct input_handler {
 struct input_handler {
 
 
 	void *private;
 	void *private;
@@ -968,6 +987,7 @@ struct input_handler {
 	void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
 	void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
 	struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id);
 	struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id);
 	void (*disconnect)(struct input_handle *handle);
 	void (*disconnect)(struct input_handle *handle);
+	void (*start)(struct input_handle *handle);
 
 
 	const struct file_operations *fops;
 	const struct file_operations *fops;
 	int minor;
 	int minor;
@@ -1030,10 +1050,10 @@ void input_release_device(struct input_handle *);
 int input_open_device(struct input_handle *);
 int input_open_device(struct input_handle *);
 void input_close_device(struct input_handle *);
 void input_close_device(struct input_handle *);
 
 
-int input_accept_process(struct input_handle *handle, struct file *file);
 int input_flush_device(struct input_handle* handle, struct file* file);
 int input_flush_device(struct input_handle* handle, struct file* file);
 
 
 void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
 void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
+void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value);
 
 
 static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
 static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
 {
 {

+ 0 - 1
include/linux/lockd/lockd.h

@@ -123,7 +123,6 @@ struct nlm_block {
 	unsigned int		b_id;		/* block id */
 	unsigned int		b_id;		/* block id */
 	unsigned char		b_queued;	/* re-queued */
 	unsigned char		b_queued;	/* re-queued */
 	unsigned char		b_granted;	/* VFS granted lock */
 	unsigned char		b_granted;	/* VFS granted lock */
-	unsigned char		b_done;		/* callback complete */
 	struct nlm_file *	b_file;		/* file in question */
 	struct nlm_file *	b_file;		/* file in question */
 };
 };
 
 

+ 2 - 4
include/linux/nfs_fs.h

@@ -476,10 +476,9 @@ static inline int nfs_wb_page(struct inode *inode, struct page* page)
 }
 }
 
 
 /*
 /*
- * Allocate and free nfs_write_data structures
+ * Allocate nfs_write_data structures
  */
  */
 extern struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount);
 extern struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount);
-extern void nfs_writedata_free(struct nfs_write_data *p);
 
 
 /*
 /*
  * linux/fs/nfs/read.c
  * linux/fs/nfs/read.c
@@ -491,10 +490,9 @@ extern int  nfs_readpage_result(struct rpc_task *, struct nfs_read_data *);
 extern void nfs_readdata_release(void *data);
 extern void nfs_readdata_release(void *data);
 
 
 /*
 /*
- * Allocate and free nfs_read_data structures
+ * Allocate nfs_read_data structures
  */
  */
 extern struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount);
 extern struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount);
-extern void nfs_readdata_free(struct nfs_read_data *p);
 
 
 /*
 /*
  * linux/fs/nfs3proc.c
  * linux/fs/nfs3proc.c

+ 8 - 0
include/linux/sched.h

@@ -1557,6 +1557,14 @@ static inline void freeze(struct task_struct *p)
 	p->flags |= PF_FREEZE;
 	p->flags |= PF_FREEZE;
 }
 }
 
 
+/*
+ * Sometimes we may need to cancel the previous 'freeze' request
+ */
+static inline void do_not_freeze(struct task_struct *p)
+{
+	p->flags &= ~PF_FREEZE;
+}
+
 /*
 /*
  * Wake up a frozen process
  * Wake up a frozen process
  */
  */

+ 1 - 1
include/linux/sunrpc/xprt.h

@@ -229,7 +229,7 @@ int			xprt_reserve_xprt(struct rpc_task *task);
 int			xprt_reserve_xprt_cong(struct rpc_task *task);
 int			xprt_reserve_xprt_cong(struct rpc_task *task);
 int			xprt_prepare_transmit(struct rpc_task *task);
 int			xprt_prepare_transmit(struct rpc_task *task);
 void			xprt_transmit(struct rpc_task *task);
 void			xprt_transmit(struct rpc_task *task);
-void			xprt_abort_transmit(struct rpc_task *task);
+void			xprt_end_transmit(struct rpc_task *task);
 int			xprt_adjust_timeout(struct rpc_rqst *req);
 int			xprt_adjust_timeout(struct rpc_rqst *req);
 void			xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
 void			xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
 void			xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
 void			xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);

+ 4 - 4
include/linux/vmstat.h

@@ -41,23 +41,23 @@ DECLARE_PER_CPU(struct vm_event_state, vm_event_states);
 
 
 static inline void __count_vm_event(enum vm_event_item item)
 static inline void __count_vm_event(enum vm_event_item item)
 {
 {
-	__get_cpu_var(vm_event_states.event[item])++;
+	__get_cpu_var(vm_event_states).event[item]++;
 }
 }
 
 
 static inline void count_vm_event(enum vm_event_item item)
 static inline void count_vm_event(enum vm_event_item item)
 {
 {
-	get_cpu_var(vm_event_states.event[item])++;
+	get_cpu_var(vm_event_states).event[item]++;
 	put_cpu();
 	put_cpu();
 }
 }
 
 
 static inline void __count_vm_events(enum vm_event_item item, long delta)
 static inline void __count_vm_events(enum vm_event_item item, long delta)
 {
 {
-	__get_cpu_var(vm_event_states.event[item]) += delta;
+	__get_cpu_var(vm_event_states).event[item] += delta;
 }
 }
 
 
 static inline void count_vm_events(enum vm_event_item item, long delta)
 static inline void count_vm_events(enum vm_event_item item, long delta)
 {
 {
-	get_cpu_var(vm_event_states.event[item]) += delta;
+	get_cpu_var(vm_event_states).event[item] += delta;
 	put_cpu();
 	put_cpu();
 }
 }
 
 

+ 1 - 1
include/net/red.h

@@ -212,7 +212,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p)
 		 * Seems, it is the best solution to
 		 * Seems, it is the best solution to
 		 * problem of too coarse exponent tabulation.
 		 * problem of too coarse exponent tabulation.
 		 */
 		 */
-		us_idle = (p->qavg * us_idle) >> p->Scell_log;
+		us_idle = (p->qavg * (u64)us_idle) >> p->Scell_log;
 
 
 		if (us_idle < (p->qavg >> 1))
 		if (us_idle < (p->qavg >> 1))
 			return p->qavg - us_idle;
 			return p->qavg - us_idle;

+ 3 - 1
kernel/fork.c

@@ -1387,8 +1387,10 @@ long do_fork(unsigned long clone_flags,
 
 
 		if (clone_flags & CLONE_VFORK) {
 		if (clone_flags & CLONE_VFORK) {
 			wait_for_completion(&vfork);
 			wait_for_completion(&vfork);
-			if (unlikely (current->ptrace & PT_TRACE_VFORK_DONE))
+			if (unlikely (current->ptrace & PT_TRACE_VFORK_DONE)) {
+				current->ptrace_message = nr;
 				ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP);
 				ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP);
+			}
 		}
 		}
 	} else {
 	} else {
 		free_pid(pid);
 		free_pid(pid);

+ 1 - 0
kernel/futex.c

@@ -948,6 +948,7 @@ static int unqueue_me(struct futex_q *q)
 	/* In the common case we don't take the spinlock, which is nice. */
 	/* In the common case we don't take the spinlock, which is nice. */
  retry:
  retry:
 	lock_ptr = q->lock_ptr;
 	lock_ptr = q->lock_ptr;
+	barrier();
 	if (lock_ptr != 0) {
 	if (lock_ptr != 0) {
 		spin_lock(lock_ptr);
 		spin_lock(lock_ptr);
 		/*
 		/*

+ 3 - 3
kernel/futex_compat.c

@@ -39,7 +39,7 @@ void compat_exit_robust_list(struct task_struct *curr)
 {
 {
 	struct compat_robust_list_head __user *head = curr->compat_robust_list;
 	struct compat_robust_list_head __user *head = curr->compat_robust_list;
 	struct robust_list __user *entry, *pending;
 	struct robust_list __user *entry, *pending;
-	unsigned int limit = ROBUST_LIST_LIMIT, pi;
+	unsigned int limit = ROBUST_LIST_LIMIT, pi, pip;
 	compat_uptr_t uentry, upending;
 	compat_uptr_t uentry, upending;
 	compat_long_t futex_offset;
 	compat_long_t futex_offset;
 
 
@@ -59,10 +59,10 @@ void compat_exit_robust_list(struct task_struct *curr)
 	 * if it exists:
 	 * if it exists:
 	 */
 	 */
 	if (fetch_robust_entry(&upending, &pending,
 	if (fetch_robust_entry(&upending, &pending,
-			       &head->list_op_pending, &pi))
+			       &head->list_op_pending, &pip))
 		return;
 		return;
 	if (upending)
 	if (upending)
-		handle_futex_death((void *)pending + futex_offset, curr, pi);
+		handle_futex_death((void *)pending + futex_offset, curr, pip);
 
 
 	while (compat_ptr(uentry) != &head->list) {
 	while (compat_ptr(uentry) != &head->list) {
 		/*
 		/*

+ 18 - 8
kernel/power/process.c

@@ -66,13 +66,25 @@ static inline void freeze_process(struct task_struct *p)
 	}
 	}
 }
 }
 
 
+static void cancel_freezing(struct task_struct *p)
+{
+	unsigned long flags;
+
+	if (freezing(p)) {
+		pr_debug("  clean up: %s\n", p->comm);
+		do_not_freeze(p);
+		spin_lock_irqsave(&p->sighand->siglock, flags);
+		recalc_sigpending_tsk(p);
+		spin_unlock_irqrestore(&p->sighand->siglock, flags);
+	}
+}
+
 /* 0 = success, else # of processes that we failed to stop */
 /* 0 = success, else # of processes that we failed to stop */
 int freeze_processes(void)
 int freeze_processes(void)
 {
 {
 	int todo, nr_user, user_frozen;
 	int todo, nr_user, user_frozen;
 	unsigned long start_time;
 	unsigned long start_time;
 	struct task_struct *g, *p;
 	struct task_struct *g, *p;
-	unsigned long flags;
 
 
 	printk( "Stopping tasks: " );
 	printk( "Stopping tasks: " );
 	start_time = jiffies;
 	start_time = jiffies;
@@ -85,6 +97,10 @@ int freeze_processes(void)
 				continue;
 				continue;
 			if (frozen(p))
 			if (frozen(p))
 				continue;
 				continue;
+			if (p->state == TASK_TRACED && frozen(p->parent)) {
+				cancel_freezing(p);
+				continue;
+			}
 			if (p->mm && !(p->flags & PF_BORROWED_MM)) {
 			if (p->mm && !(p->flags & PF_BORROWED_MM)) {
 				/* The task is a user-space one.
 				/* The task is a user-space one.
 				 * Freeze it unless there's a vfork completion
 				 * Freeze it unless there's a vfork completion
@@ -126,13 +142,7 @@ int freeze_processes(void)
 		do_each_thread(g, p) {
 		do_each_thread(g, p) {
 			if (freezeable(p) && !frozen(p))
 			if (freezeable(p) && !frozen(p))
 				printk(KERN_ERR "  %s\n", p->comm);
 				printk(KERN_ERR "  %s\n", p->comm);
-			if (freezing(p)) {
-				pr_debug("  clean up: %s\n", p->comm);
-				p->flags &= ~PF_FREEZE;
-				spin_lock_irqsave(&p->sighand->siglock, flags);
-				recalc_sigpending_tsk(p);
-				spin_unlock_irqrestore(&p->sighand->siglock, flags);
-			}
+			cancel_freezing(p);
 		} while_each_thread(g, p);
 		} while_each_thread(g, p);
 		read_unlock(&tasklist_lock);
 		read_unlock(&tasklist_lock);
 		return todo;
 		return todo;

+ 3 - 1
kernel/printk.c

@@ -799,6 +799,9 @@ void release_console_sem(void)
 		up(&secondary_console_sem);
 		up(&secondary_console_sem);
 		return;
 		return;
 	}
 	}
+
+	console_may_schedule = 0;
+
 	for ( ; ; ) {
 	for ( ; ; ) {
 		spin_lock_irqsave(&logbuf_lock, flags);
 		spin_lock_irqsave(&logbuf_lock, flags);
 		wake_klogd |= log_start - log_end;
 		wake_klogd |= log_start - log_end;
@@ -812,7 +815,6 @@ void release_console_sem(void)
 		local_irq_restore(flags);
 		local_irq_restore(flags);
 	}
 	}
 	console_locked = 0;
 	console_locked = 0;
-	console_may_schedule = 0;
 	up(&console_sem);
 	up(&console_sem);
 	spin_unlock_irqrestore(&logbuf_lock, flags);
 	spin_unlock_irqrestore(&logbuf_lock, flags);
 	if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait)) {
 	if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait)) {

+ 6 - 3
kernel/resource.c

@@ -244,6 +244,7 @@ int find_next_system_ram(struct resource *res)
 
 
 	start = res->start;
 	start = res->start;
 	end = res->end;
 	end = res->end;
+	BUG_ON(start >= end);
 
 
 	read_lock(&resource_lock);
 	read_lock(&resource_lock);
 	for (p = iomem_resource.child; p ; p = p->sibling) {
 	for (p = iomem_resource.child; p ; p = p->sibling) {
@@ -254,15 +255,17 @@ int find_next_system_ram(struct resource *res)
 			p = NULL;
 			p = NULL;
 			break;
 			break;
 		}
 		}
-		if (p->start >= start)
+		if ((p->end >= start) && (p->start < end))
 			break;
 			break;
 	}
 	}
 	read_unlock(&resource_lock);
 	read_unlock(&resource_lock);
 	if (!p)
 	if (!p)
 		return -1;
 		return -1;
 	/* copy data */
 	/* copy data */
-	res->start = p->start;
-	res->end = p->end;
+	if (res->start < p->start)
+		res->start = p->start;
+	if (res->end > p->end)
+		res->end = p->end;
 	return 0;
 	return 0;
 }
 }
 #endif
 #endif

+ 6 - 4
lib/spinlock_debug.c

@@ -162,6 +162,7 @@ static void rwlock_bug(rwlock_t *lock, const char *msg)
 
 
 #define RWLOCK_BUG_ON(cond, lock, msg) if (unlikely(cond)) rwlock_bug(lock, msg)
 #define RWLOCK_BUG_ON(cond, lock, msg) if (unlikely(cond)) rwlock_bug(lock, msg)
 
 
+#if 0		/* __write_lock_debug() can lock up - maybe this can too? */
 static void __read_lock_debug(rwlock_t *lock)
 static void __read_lock_debug(rwlock_t *lock)
 {
 {
 	int print_once = 1;
 	int print_once = 1;
@@ -184,12 +185,12 @@ static void __read_lock_debug(rwlock_t *lock)
 		}
 		}
 	}
 	}
 }
 }
+#endif
 
 
 void _raw_read_lock(rwlock_t *lock)
 void _raw_read_lock(rwlock_t *lock)
 {
 {
 	RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
 	RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
-	if (unlikely(!__raw_read_trylock(&lock->raw_lock)))
-		__read_lock_debug(lock);
+	__raw_read_lock(&lock->raw_lock);
 }
 }
 
 
 int _raw_read_trylock(rwlock_t *lock)
 int _raw_read_trylock(rwlock_t *lock)
@@ -235,6 +236,7 @@ static inline void debug_write_unlock(rwlock_t *lock)
 	lock->owner_cpu = -1;
 	lock->owner_cpu = -1;
 }
 }
 
 
+#if 0		/* This can cause lockups */
 static void __write_lock_debug(rwlock_t *lock)
 static void __write_lock_debug(rwlock_t *lock)
 {
 {
 	int print_once = 1;
 	int print_once = 1;
@@ -257,12 +259,12 @@ static void __write_lock_debug(rwlock_t *lock)
 		}
 		}
 	}
 	}
 }
 }
+#endif
 
 
 void _raw_write_lock(rwlock_t *lock)
 void _raw_write_lock(rwlock_t *lock)
 {
 {
 	debug_write_lock_before(lock);
 	debug_write_lock_before(lock);
-	if (unlikely(!__raw_write_trylock(&lock->raw_lock)))
-		__write_lock_debug(lock);
+	__raw_write_lock(&lock->raw_lock);
 	debug_write_lock_after(lock);
 	debug_write_lock_after(lock);
 }
 }
 
 

+ 2 - 1
mm/fadvise.c

@@ -73,7 +73,6 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
 		file->f_ra.ra_pages = bdi->ra_pages * 2;
 		file->f_ra.ra_pages = bdi->ra_pages * 2;
 		break;
 		break;
 	case POSIX_FADV_WILLNEED:
 	case POSIX_FADV_WILLNEED:
-	case POSIX_FADV_NOREUSE:
 		if (!mapping->a_ops->readpage) {
 		if (!mapping->a_ops->readpage) {
 			ret = -EINVAL;
 			ret = -EINVAL;
 			break;
 			break;
@@ -94,6 +93,8 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
 		if (ret > 0)
 		if (ret > 0)
 			ret = 0;
 			ret = 0;
 		break;
 		break;
+	case POSIX_FADV_NOREUSE:
+		break;
 	case POSIX_FADV_DONTNEED:
 	case POSIX_FADV_DONTNEED:
 		if (!bdi_write_congested(mapping->backing_dev_info))
 		if (!bdi_write_congested(mapping->backing_dev_info))
 			filemap_flush(mapping);
 			filemap_flush(mapping);

+ 34 - 10
mm/memory_hotplug.c

@@ -52,6 +52,9 @@ static int __add_section(struct zone *zone, unsigned long phys_start_pfn)
 	int nr_pages = PAGES_PER_SECTION;
 	int nr_pages = PAGES_PER_SECTION;
 	int ret;
 	int ret;
 
 
+	if (pfn_valid(phys_start_pfn))
+		return -EEXIST;
+
 	ret = sparse_add_one_section(zone, phys_start_pfn, nr_pages);
 	ret = sparse_add_one_section(zone, phys_start_pfn, nr_pages);
 
 
 	if (ret < 0)
 	if (ret < 0)
@@ -76,15 +79,22 @@ int __add_pages(struct zone *zone, unsigned long phys_start_pfn,
 {
 {
 	unsigned long i;
 	unsigned long i;
 	int err = 0;
 	int err = 0;
+	int start_sec, end_sec;
+	/* during initialize mem_map, align hot-added range to section */
+	start_sec = pfn_to_section_nr(phys_start_pfn);
+	end_sec = pfn_to_section_nr(phys_start_pfn + nr_pages - 1);
 
 
-	for (i = 0; i < nr_pages; i += PAGES_PER_SECTION) {
-		err = __add_section(zone, phys_start_pfn + i);
+	for (i = start_sec; i <= end_sec; i++) {
+		err = __add_section(zone, i << PFN_SECTION_SHIFT);
 
 
-		/* We want to keep adding the rest of the
-		 * sections if the first ones already exist
+		/*
+		 * EEXIST is finally dealed with by ioresource collision
+		 * check. see add_memory() => register_memory_resource()
+		 * Warning will be printed if there is collision.
 		 */
 		 */
 		if (err && (err != -EEXIST))
 		if (err && (err != -EEXIST))
 			break;
 			break;
+		err = 0;
 	}
 	}
 
 
 	return err;
 	return err;
@@ -156,7 +166,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
 	res.flags = IORESOURCE_MEM; /* we just need system ram */
 	res.flags = IORESOURCE_MEM; /* we just need system ram */
 	section_end = res.end;
 	section_end = res.end;
 
 
-	while (find_next_system_ram(&res) >= 0) {
+	while ((res.start < res.end) && (find_next_system_ram(&res) >= 0)) {
 		start_pfn = (unsigned long)(res.start >> PAGE_SHIFT);
 		start_pfn = (unsigned long)(res.start >> PAGE_SHIFT);
 		nr_pages = (unsigned long)
 		nr_pages = (unsigned long)
                            ((res.end + 1 - res.start) >> PAGE_SHIFT);
                            ((res.end + 1 - res.start) >> PAGE_SHIFT);
@@ -213,10 +223,9 @@ static void rollback_node_hotadd(int nid, pg_data_t *pgdat)
 }
 }
 
 
 /* add this memory to iomem resource */
 /* add this memory to iomem resource */
-static void register_memory_resource(u64 start, u64 size)
+static struct resource *register_memory_resource(u64 start, u64 size)
 {
 {
 	struct resource *res;
 	struct resource *res;
-
 	res = kzalloc(sizeof(struct resource), GFP_KERNEL);
 	res = kzalloc(sizeof(struct resource), GFP_KERNEL);
 	BUG_ON(!res);
 	BUG_ON(!res);
 
 
@@ -228,7 +237,18 @@ static void register_memory_resource(u64 start, u64 size)
 		printk("System RAM resource %llx - %llx cannot be added\n",
 		printk("System RAM resource %llx - %llx cannot be added\n",
 		(unsigned long long)res->start, (unsigned long long)res->end);
 		(unsigned long long)res->start, (unsigned long long)res->end);
 		kfree(res);
 		kfree(res);
+		res = NULL;
 	}
 	}
+	return res;
+}
+
+static void release_memory_resource(struct resource *res)
+{
+	if (!res)
+		return;
+	release_resource(res);
+	kfree(res);
+	return;
 }
 }
 
 
 
 
@@ -237,8 +257,13 @@ int add_memory(int nid, u64 start, u64 size)
 {
 {
 	pg_data_t *pgdat = NULL;
 	pg_data_t *pgdat = NULL;
 	int new_pgdat = 0;
 	int new_pgdat = 0;
+	struct resource *res;
 	int ret;
 	int ret;
 
 
+	res = register_memory_resource(start, size);
+	if (!res)
+		return -EEXIST;
+
 	if (!node_online(nid)) {
 	if (!node_online(nid)) {
 		pgdat = hotadd_new_pgdat(nid, start);
 		pgdat = hotadd_new_pgdat(nid, start);
 		if (!pgdat)
 		if (!pgdat)
@@ -268,14 +293,13 @@ int add_memory(int nid, u64 start, u64 size)
 		BUG_ON(ret);
 		BUG_ON(ret);
 	}
 	}
 
 
-	/* register this memory as resource */
-	register_memory_resource(start, size);
-
 	return ret;
 	return ret;
 error:
 error:
 	/* rollback pgdat allocation and others */
 	/* rollback pgdat allocation and others */
 	if (new_pgdat)
 	if (new_pgdat)
 		rollback_node_hotadd(nid, pgdat);
 		rollback_node_hotadd(nid, pgdat);
+	if (res)
+		release_memory_resource(res);
 
 
 	return ret;
 	return ret;
 }
 }

+ 1 - 1
net/bridge/br_netlink.c

@@ -85,7 +85,7 @@ void br_ifinfo_notify(int event, struct net_bridge_port *port)
 		goto err_out;
 		goto err_out;
 
 
 	err = br_fill_ifinfo(skb, port, current->pid, 0, event, 0);
 	err = br_fill_ifinfo(skb, port, current->pid, 0, event, 0);
-	if (err)
+	if (err < 0)
 		goto err_kfree;
 		goto err_kfree;
 
 
 	NETLINK_CB(skb).dst_group = RTNLGRP_LINK;
 	NETLINK_CB(skb).dst_group = RTNLGRP_LINK;

+ 2 - 1
net/ipv4/tcp_input.c

@@ -3541,7 +3541,8 @@ void tcp_cwnd_application_limited(struct sock *sk)
 	if (inet_csk(sk)->icsk_ca_state == TCP_CA_Open &&
 	if (inet_csk(sk)->icsk_ca_state == TCP_CA_Open &&
 	    sk->sk_socket && !test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
 	    sk->sk_socket && !test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
 		/* Limited by application or receiver window. */
 		/* Limited by application or receiver window. */
-		u32 win_used = max(tp->snd_cwnd_used, 2U);
+		u32 init_win = tcp_init_cwnd(tp, __sk_dst_get(sk));
+		u32 win_used = max(tp->snd_cwnd_used, init_win);
 		if (win_used < tp->snd_cwnd) {
 		if (win_used < tp->snd_cwnd) {
 			tp->snd_ssthresh = tcp_current_ssthresh(sk);
 			tp->snd_ssthresh = tcp_current_ssthresh(sk);
 			tp->snd_cwnd = (tp->snd_cwnd + win_used) >> 1;
 			tp->snd_cwnd = (tp->snd_cwnd + win_used) >> 1;

+ 7 - 5
net/lapb/lapb_iface.c

@@ -238,11 +238,13 @@ int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms)
 		goto out_put;
 		goto out_put;
 
 
 	if (lapb->state == LAPB_STATE_0) {
 	if (lapb->state == LAPB_STATE_0) {
-		if (((parms->mode & LAPB_EXTENDED) &&
-		     (parms->window < 1 || parms->window > 127)) ||
-		    (parms->window < 1 || parms->window > 7))
-			goto out_put;
-
+		if (parms->mode & LAPB_EXTENDED) {
+			if (parms->window < 1 || parms->window > 127)
+				goto out_put;
+		} else {
+			if (parms->window < 1 || parms->window > 7)
+				goto out_put;
+		}
 		lapb->mode    = parms->mode;
 		lapb->mode    = parms->mode;
 		lapb->window  = parms->window;
 		lapb->window  = parms->window;
 	}
 	}

+ 8 - 12
net/llc/af_llc.c

@@ -784,24 +784,20 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
 		copied += used;
 		copied += used;
 		len -= used;
 		len -= used;
 
 
-		if (used + offset < skb->len)
-			continue;
-
 		if (!(flags & MSG_PEEK)) {
 		if (!(flags & MSG_PEEK)) {
 			sk_eat_skb(sk, skb, 0);
 			sk_eat_skb(sk, skb, 0);
 			*seq = 0;
 			*seq = 0;
 		}
 		}
+
+		/* For non stream protcols we get one packet per recvmsg call */
+		if (sk->sk_type != SOCK_STREAM)
+			goto copy_uaddr;
+
+		/* Partial read */
+		if (used + offset < skb->len)
+			continue;
 	} while (len > 0);
 	} while (len > 0);
 
 
-	/* 
-	 * According to UNIX98, msg_name/msg_namelen are ignored
-	 * on connected socket. -ANK
-	 * But... af_llc still doesn't have separate sets of methods for
-	 * SOCK_DGRAM and SOCK_STREAM :-( So we have to do this test, will
-	 * eventually fix this tho :-) -acme
-	 */
-	if (sk->sk_type == SOCK_DGRAM)
-		goto copy_uaddr;
 out:
 out:
 	release_sock(sk);
 	release_sock(sk);
 	return copied;
 	return copied;

+ 2 - 2
net/llc/llc_sap.c

@@ -51,10 +51,10 @@ void llc_save_primitive(struct sock *sk, struct sk_buff* skb, u8 prim)
 {
 {
 	struct sockaddr_llc *addr;
 	struct sockaddr_llc *addr;
 
 
-	if (skb->sk->sk_type == SOCK_STREAM) /* See UNIX98 */
-		return;
        /* save primitive for use by the user. */
        /* save primitive for use by the user. */
 	addr		  = llc_ui_skb_cb(skb);
 	addr		  = llc_ui_skb_cb(skb);
+
+	memset(addr, 0, sizeof(*addr));
 	addr->sllc_family = sk->sk_family;
 	addr->sllc_family = sk->sk_family;
 	addr->sllc_arphrd = skb->dev->type;
 	addr->sllc_arphrd = skb->dev->type;
 	addr->sllc_test   = prim == LLC_TEST_PRIM;
 	addr->sllc_test   = prim == LLC_TEST_PRIM;

+ 1 - 1
net/sched/sch_api.c

@@ -430,7 +430,7 @@ qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp)
 	}
 	}
 #endif
 #endif
 
 
-	err = -EINVAL;
+	err = -ENOENT;
 	if (ops == NULL)
 	if (ops == NULL)
 		goto err_out;
 		goto err_out;
 
 

+ 5 - 1
net/sunrpc/cache.c

@@ -71,7 +71,12 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
 	new = detail->alloc();
 	new = detail->alloc();
 	if (!new)
 	if (!new)
 		return NULL;
 		return NULL;
+	/* must fully initialise 'new', else
+	 * we might get lose if we need to
+	 * cache_put it soon.
+	 */
 	cache_init(new);
 	cache_init(new);
+	detail->init(new, key);
 
 
 	write_lock(&detail->hash_lock);
 	write_lock(&detail->hash_lock);
 
 
@@ -85,7 +90,6 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
 			return tmp;
 			return tmp;
 		}
 		}
 	}
 	}
-	detail->init(new, key);
 	new->next = *head;
 	new->next = *head;
 	*head = new;
 	*head = new;
 	detail->entries++;
 	detail->entries++;

+ 29 - 23
net/sunrpc/clnt.c

@@ -921,26 +921,43 @@ call_transmit(struct rpc_task *task)
 	task->tk_status = xprt_prepare_transmit(task);
 	task->tk_status = xprt_prepare_transmit(task);
 	if (task->tk_status != 0)
 	if (task->tk_status != 0)
 		return;
 		return;
+	task->tk_action = call_transmit_status;
 	/* Encode here so that rpcsec_gss can use correct sequence number. */
 	/* Encode here so that rpcsec_gss can use correct sequence number. */
 	if (rpc_task_need_encode(task)) {
 	if (rpc_task_need_encode(task)) {
-		task->tk_rqstp->rq_bytes_sent = 0;
+		BUG_ON(task->tk_rqstp->rq_bytes_sent != 0);
 		call_encode(task);
 		call_encode(task);
 		/* Did the encode result in an error condition? */
 		/* Did the encode result in an error condition? */
 		if (task->tk_status != 0)
 		if (task->tk_status != 0)
-			goto out_nosend;
+			return;
 	}
 	}
-	task->tk_action = call_transmit_status;
 	xprt_transmit(task);
 	xprt_transmit(task);
 	if (task->tk_status < 0)
 	if (task->tk_status < 0)
 		return;
 		return;
-	if (!task->tk_msg.rpc_proc->p_decode) {
-		task->tk_action = rpc_exit_task;
-		rpc_wake_up_task(task);
-	}
-	return;
-out_nosend:
-	/* release socket write lock before attempting to handle error */
-	xprt_abort_transmit(task);
+	/*
+	 * On success, ensure that we call xprt_end_transmit() before sleeping
+	 * in order to allow access to the socket to other RPC requests.
+	 */
+	call_transmit_status(task);
+	if (task->tk_msg.rpc_proc->p_decode != NULL)
+		return;
+	task->tk_action = rpc_exit_task;
+	rpc_wake_up_task(task);
+}
+
+/*
+ * 5a.	Handle cleanup after a transmission
+ */
+static void
+call_transmit_status(struct rpc_task *task)
+{
+	task->tk_action = call_status;
+	/*
+	 * Special case: if we've been waiting on the socket's write_space()
+	 * callback, then don't call xprt_end_transmit().
+	 */
+	if (task->tk_status == -EAGAIN)
+		return;
+	xprt_end_transmit(task);
 	rpc_task_force_reencode(task);
 	rpc_task_force_reencode(task);
 }
 }
 
 
@@ -992,18 +1009,7 @@ call_status(struct rpc_task *task)
 }
 }
 
 
 /*
 /*
- * 6a.	Handle transmission errors.
- */
-static void
-call_transmit_status(struct rpc_task *task)
-{
-	if (task->tk_status != -EAGAIN)
-		rpc_task_force_reencode(task);
-	call_status(task);
-}
-
-/*
- * 6b.	Handle RPC timeout
+ * 6a.	Handle RPC timeout
  * 	We do not release the request slot, so we keep using the
  * 	We do not release the request slot, so we keep using the
  *	same XID for all retransmits.
  *	same XID for all retransmits.
  */
  */

+ 4 - 2
net/sunrpc/rpc_pipe.c

@@ -667,10 +667,11 @@ rpc_mkdir(char *path, struct rpc_clnt *rpc_client)
 			RPCAUTH_info, RPCAUTH_EOF);
 			RPCAUTH_info, RPCAUTH_EOF);
 	if (error)
 	if (error)
 		goto err_depopulate;
 		goto err_depopulate;
+	dget(dentry);
 out:
 out:
 	mutex_unlock(&dir->i_mutex);
 	mutex_unlock(&dir->i_mutex);
 	rpc_release_path(&nd);
 	rpc_release_path(&nd);
-	return dget(dentry);
+	return dentry;
 err_depopulate:
 err_depopulate:
 	rpc_depopulate(dentry);
 	rpc_depopulate(dentry);
 	__rpc_rmdir(dir, dentry);
 	__rpc_rmdir(dir, dentry);
@@ -731,10 +732,11 @@ rpc_mkpipe(char *path, void *private, struct rpc_pipe_ops *ops, int flags)
 	rpci->flags = flags;
 	rpci->flags = flags;
 	rpci->ops = ops;
 	rpci->ops = ops;
 	inode_dir_notify(dir, DN_CREATE);
 	inode_dir_notify(dir, DN_CREATE);
+	dget(dentry);
 out:
 out:
 	mutex_unlock(&dir->i_mutex);
 	mutex_unlock(&dir->i_mutex);
 	rpc_release_path(&nd);
 	rpc_release_path(&nd);
-	return dget(dentry);
+	return dentry;
 err_dput:
 err_dput:
 	dput(dentry);
 	dput(dentry);
 	dentry = ERR_PTR(-ENOMEM);
 	dentry = ERR_PTR(-ENOMEM);

+ 3 - 18
net/sunrpc/xprt.c

@@ -707,12 +707,9 @@ out_unlock:
 	return err;
 	return err;
 }
 }
 
 
-void
-xprt_abort_transmit(struct rpc_task *task)
+void xprt_end_transmit(struct rpc_task *task)
 {
 {
-	struct rpc_xprt	*xprt = task->tk_xprt;
-
-	xprt_release_write(xprt, task);
+	xprt_release_write(task->tk_xprt, task);
 }
 }
 
 
 /**
 /**
@@ -761,8 +758,6 @@ void xprt_transmit(struct rpc_task *task)
 			task->tk_status = -ENOTCONN;
 			task->tk_status = -ENOTCONN;
 		else if (!req->rq_received)
 		else if (!req->rq_received)
 			rpc_sleep_on(&xprt->pending, task, NULL, xprt_timer);
 			rpc_sleep_on(&xprt->pending, task, NULL, xprt_timer);
-
-		xprt->ops->release_xprt(xprt, task);
 		spin_unlock_bh(&xprt->transport_lock);
 		spin_unlock_bh(&xprt->transport_lock);
 		return;
 		return;
 	}
 	}
@@ -772,18 +767,8 @@ void xprt_transmit(struct rpc_task *task)
 	 *	 schedq, and being picked up by a parallel run of rpciod().
 	 *	 schedq, and being picked up by a parallel run of rpciod().
 	 */
 	 */
 	task->tk_status = status;
 	task->tk_status = status;
-
-	switch (status) {
-	case -ECONNREFUSED:
+	if (status == -ECONNREFUSED)
 		rpc_sleep_on(&xprt->sending, task, NULL, NULL);
 		rpc_sleep_on(&xprt->sending, task, NULL, NULL);
-	case -EAGAIN:
-	case -ENOTCONN:
-		return;
-	default:
-		break;
-	}
-	xprt_release_write(xprt, task);
-	return;
 }
 }
 
 
 static inline void do_xprt_reserve(struct rpc_task *task)
 static inline void do_xprt_reserve(struct rpc_task *task)

+ 28 - 1
net/sunrpc/xprtsock.c

@@ -413,6 +413,33 @@ static int xs_tcp_send_request(struct rpc_task *task)
 	return status;
 	return status;
 }
 }
 
 
+/**
+ * xs_tcp_release_xprt - clean up after a tcp transmission
+ * @xprt: transport
+ * @task: rpc task
+ *
+ * This cleans up if an error causes us to abort the transmission of a request.
+ * In this case, the socket may need to be reset in order to avoid confusing
+ * the server.
+ */
+static void xs_tcp_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
+{
+	struct rpc_rqst *req;
+
+	if (task != xprt->snd_task)
+		return;
+	if (task == NULL)
+		goto out_release;
+	req = task->tk_rqstp;
+	if (req->rq_bytes_sent == 0)
+		goto out_release;
+	if (req->rq_bytes_sent == req->rq_snd_buf.len)
+		goto out_release;
+	set_bit(XPRT_CLOSE_WAIT, &task->tk_xprt->state);
+out_release:
+	xprt_release_xprt(xprt, task);
+}
+
 /**
 /**
  * xs_close - close a socket
  * xs_close - close a socket
  * @xprt: transport
  * @xprt: transport
@@ -1250,7 +1277,7 @@ static struct rpc_xprt_ops xs_udp_ops = {
 
 
 static struct rpc_xprt_ops xs_tcp_ops = {
 static struct rpc_xprt_ops xs_tcp_ops = {
 	.reserve_xprt		= xprt_reserve_xprt,
 	.reserve_xprt		= xprt_reserve_xprt,
-	.release_xprt		= xprt_release_xprt,
+	.release_xprt		= xs_tcp_release_xprt,
 	.set_port		= xs_set_port,
 	.set_port		= xs_set_port,
 	.connect		= xs_connect,
 	.connect		= xs_connect,
 	.buf_alloc		= rpc_malloc,
 	.buf_alloc		= rpc_malloc,

+ 13 - 4
sound/aoa/codecs/snd-aoa-codec-toonie.c

@@ -51,6 +51,13 @@ static struct transfer_info toonie_transfers[] = {
 	{}
 	{}
 };
 };
 
 
+static int toonie_usable(struct codec_info_item *cii,
+			 struct transfer_info *ti,
+			 struct transfer_info *out)
+{
+	return 1;
+}
+
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM
 static int toonie_suspend(struct codec_info_item *cii, pm_message_t state)
 static int toonie_suspend(struct codec_info_item *cii, pm_message_t state)
 {
 {
@@ -69,6 +76,7 @@ static struct codec_info toonie_codec_info = {
 	.sysclock_factor = 256,
 	.sysclock_factor = 256,
 	.bus_factor = 64,
 	.bus_factor = 64,
 	.owner = THIS_MODULE,
 	.owner = THIS_MODULE,
+	.usable = toonie_usable,
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM
 	.suspend = toonie_suspend,
 	.suspend = toonie_suspend,
 	.resume = toonie_resume,
 	.resume = toonie_resume,
@@ -79,19 +87,20 @@ static int toonie_init_codec(struct aoa_codec *codec)
 {
 {
 	struct toonie *toonie = codec_to_toonie(codec);
 	struct toonie *toonie = codec_to_toonie(codec);
 
 
+	/* nothing connected? what a joke! */
+	if (toonie->codec.connected != 1)
+		return -ENOTCONN;
+
 	if (aoa_snd_device_new(SNDRV_DEV_LOWLEVEL, toonie, &ops)) {
 	if (aoa_snd_device_new(SNDRV_DEV_LOWLEVEL, toonie, &ops)) {
 		printk(KERN_ERR PFX "failed to create toonie snd device!\n");
 		printk(KERN_ERR PFX "failed to create toonie snd device!\n");
 		return -ENODEV;
 		return -ENODEV;
 	}
 	}
 
 
-	/* nothing connected? what a joke! */
-	if (toonie->codec.connected != 1)
-		return -ENOTCONN;
-
 	if (toonie->codec.soundbus_dev->attach_codec(toonie->codec.soundbus_dev,
 	if (toonie->codec.soundbus_dev->attach_codec(toonie->codec.soundbus_dev,
 						     aoa_get_card(),
 						     aoa_get_card(),
 						     &toonie_codec_info, toonie)) {
 						     &toonie_codec_info, toonie)) {
 		printk(KERN_ERR PFX "error creating toonie pcm\n");
 		printk(KERN_ERR PFX "error creating toonie pcm\n");
+		snd_device_free(aoa_get_card(), toonie);
 		return -ENODEV;
 		return -ENODEV;
 	}
 	}
 
 

+ 5 - 2
sound/aoa/core/snd-aoa-gpio-feature.c

@@ -112,7 +112,10 @@ static struct device_node *get_gpio(char *name,
 
 
 static void get_irq(struct device_node * np, int *irqptr)
 static void get_irq(struct device_node * np, int *irqptr)
 {
 {
-	*irqptr = irq_of_parse_and_map(np, 0);
+	if (np)
+		*irqptr = irq_of_parse_and_map(np, 0);
+	else
+		*irqptr = NO_IRQ;
 }
 }
 
 
 /* 0x4 is outenable, 0x1 is out, thus 4 or 5 */
 /* 0x4 is outenable, 0x1 is out, thus 4 or 5 */
@@ -322,7 +325,7 @@ static int ftr_set_notify(struct gpio_runtime *rt,
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 
-	if (irq == -1)
+	if (irq == NO_IRQ)
 		return -ENODEV;
 		return -ENODEV;
 
 
 	mutex_lock(&notif->mutex);
 	mutex_lock(&notif->mutex);

+ 1 - 1
sound/aoa/core/snd-aoa-gpio-pmf.c

@@ -18,7 +18,7 @@ static void pmf_gpio_set_##name(struct gpio_runtime *rt, int on)\
 							\
 							\
 	if (unlikely(!rt)) return;				\
 	if (unlikely(!rt)) return;				\
 	rc = pmf_call_function(rt->node, #name "-mute", &args);	\
 	rc = pmf_call_function(rt->node, #name "-mute", &args);	\
-	if (rc)							\
+	if (rc && rc != -ENODEV)				\
 		printk(KERN_WARNING "pmf_gpio_set_" #name	\
 		printk(KERN_WARNING "pmf_gpio_set_" #name	\
 		" failed, rc: %d\n", rc);			\
 		" failed, rc: %d\n", rc);			\
 	rt->implementation_private &= ~(1<<bit);		\
 	rt->implementation_private &= ~(1<<bit);		\

+ 1 - 2
sound/core/oss/mixer_oss.c

@@ -988,13 +988,12 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mix
 	if (ptr->index == 0 && (kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0)) != NULL) {
 	if (ptr->index == 0 && (kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0)) != NULL) {
 		struct snd_ctl_elem_info *uinfo;
 		struct snd_ctl_elem_info *uinfo;
 
 
-		uinfo = kmalloc(sizeof(*uinfo), GFP_KERNEL);
+		uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
 		if (! uinfo) {
 		if (! uinfo) {
 			up_read(&mixer->card->controls_rwsem);
 			up_read(&mixer->card->controls_rwsem);
 			return -ENOMEM;
 			return -ENOMEM;
 		}
 		}
 			
 			
-		memset(uinfo, 0, sizeof(*uinfo));
 		if (kctl->info(kctl, uinfo)) {
 		if (kctl->info(kctl, uinfo)) {
 			up_read(&mixer->card->controls_rwsem);
 			up_read(&mixer->card->controls_rwsem);
 			return 0;
 			return 0;

+ 2 - 0
sound/core/oss/pcm_oss.c

@@ -2228,6 +2228,8 @@ static int snd_pcm_oss_open_file(struct file *file,
 	for (idx = 0; idx < 2; idx++) {
 	for (idx = 0; idx < 2; idx++) {
 		if (setup[idx].disable)
 		if (setup[idx].disable)
 			continue;
 			continue;
+		if (! pcm->streams[idx].substream_count)
+			continue; /* no matching substream */
 		if (idx == SNDRV_PCM_STREAM_PLAYBACK) {
 		if (idx == SNDRV_PCM_STREAM_PLAYBACK) {
 			if (! (f_mode & FMODE_WRITE))
 			if (! (f_mode & FMODE_WRITE))
 				continue;
 				continue;

+ 1 - 2
sound/core/seq/seq_device.c

@@ -372,10 +372,9 @@ static struct ops_list * create_driver(char *id)
 {
 {
 	struct ops_list *ops;
 	struct ops_list *ops;
 
 
-	ops = kmalloc(sizeof(*ops), GFP_KERNEL);
+	ops = kzalloc(sizeof(*ops), GFP_KERNEL);
 	if (ops == NULL)
 	if (ops == NULL)
 		return ops;
 		return ops;
-	memset(ops, 0, sizeof(*ops));
 
 
 	/* set up driver entry */
 	/* set up driver entry */
 	strlcpy(ops->id, id, sizeof(ops->id));
 	strlcpy(ops->id, id, sizeof(ops->id));

+ 3 - 6
sound/core/sgbuf.c

@@ -68,21 +68,18 @@ void *snd_malloc_sgbuf_pages(struct device *device,
 
 
 	dmab->area = NULL;
 	dmab->area = NULL;
 	dmab->addr = 0;
 	dmab->addr = 0;
-	dmab->private_data = sgbuf = kmalloc(sizeof(*sgbuf), GFP_KERNEL);
+	dmab->private_data = sgbuf = kzalloc(sizeof(*sgbuf), GFP_KERNEL);
 	if (! sgbuf)
 	if (! sgbuf)
 		return NULL;
 		return NULL;
-	memset(sgbuf, 0, sizeof(*sgbuf));
 	sgbuf->dev = device;
 	sgbuf->dev = device;
 	pages = snd_sgbuf_aligned_pages(size);
 	pages = snd_sgbuf_aligned_pages(size);
 	sgbuf->tblsize = sgbuf_align_table(pages);
 	sgbuf->tblsize = sgbuf_align_table(pages);
-	sgbuf->table = kmalloc(sizeof(*sgbuf->table) * sgbuf->tblsize, GFP_KERNEL);
+	sgbuf->table = kcalloc(sgbuf->tblsize, sizeof(*sgbuf->table), GFP_KERNEL);
 	if (! sgbuf->table)
 	if (! sgbuf->table)
 		goto _failed;
 		goto _failed;
-	memset(sgbuf->table, 0, sizeof(*sgbuf->table) * sgbuf->tblsize);
-	sgbuf->page_table = kmalloc(sizeof(*sgbuf->page_table) * sgbuf->tblsize, GFP_KERNEL);
+	sgbuf->page_table = kcalloc(sgbuf->tblsize, sizeof(*sgbuf->page_table), GFP_KERNEL);
 	if (! sgbuf->page_table)
 	if (! sgbuf->page_table)
 		goto _failed;
 		goto _failed;
-	memset(sgbuf->page_table, 0, sizeof(*sgbuf->page_table) * sgbuf->tblsize);
 
 
 	/* allocate each page */
 	/* allocate each page */
 	for (i = 0; i < pages; i++) {
 	for (i = 0; i < pages; i++) {

+ 2 - 5
sound/drivers/vx/vx_pcm.c

@@ -1252,18 +1252,15 @@ static int vx_init_audio_io(struct vx_core *chip)
 	chip->audio_info = rmh.Stat[1];
 	chip->audio_info = rmh.Stat[1];
 
 
 	/* allocate pipes */
 	/* allocate pipes */
-	chip->playback_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_outs, GFP_KERNEL);
+	chip->playback_pipes = kcalloc(chip->audio_outs, sizeof(struct vx_pipe *), GFP_KERNEL);
 	if (!chip->playback_pipes)
 	if (!chip->playback_pipes)
 		return -ENOMEM;
 		return -ENOMEM;
-	chip->capture_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_ins, GFP_KERNEL);
+	chip->capture_pipes = kcalloc(chip->audio_ins, sizeof(struct vx_pipe *), GFP_KERNEL);
 	if (!chip->capture_pipes) {
 	if (!chip->capture_pipes) {
 		kfree(chip->playback_pipes);
 		kfree(chip->playback_pipes);
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 
 
-	memset(chip->playback_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_outs);
-	memset(chip->capture_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_ins);
-
 	preferred = chip->ibl.size;
 	preferred = chip->ibl.size;
 	chip->ibl.size = 0;
 	chip->ibl.size = 0;
 	vx_set_ibl(chip, &chip->ibl); /* query the info */
 	vx_set_ibl(chip, &chip->ibl); /* query the info */

+ 2 - 2
sound/pci/echoaudio/echoaudio.c

@@ -236,9 +236,9 @@ static int pcm_open(struct snd_pcm_substream *substream,
 	chip = snd_pcm_substream_chip(substream);
 	chip = snd_pcm_substream_chip(substream);
 	runtime = substream->runtime;
 	runtime = substream->runtime;
 
 
-	if (!(pipe = kmalloc(sizeof(struct audiopipe), GFP_KERNEL)))
+	pipe = kzalloc(sizeof(struct audiopipe), GFP_KERNEL);
+	if (!pipe)
 		return -ENOMEM;
 		return -ENOMEM;
-	memset(pipe, 0, sizeof(struct audiopipe));
 	pipe->index = -1;		/* Not configured yet */
 	pipe->index = -1;		/* Not configured yet */
 
 
 	/* Set up hw capabilities and contraints */
 	/* Set up hw capabilities and contraints */

+ 11 - 0
sound/pci/emu10k1/emu10k1_main.c

@@ -936,6 +936,17 @@ static struct snd_emu_chip_details emu_chip_details[] = {
 	 .ca0151_chip = 1,
 	 .ca0151_chip = 1,
 	 .spk71 = 1,
 	 .spk71 = 1,
 	 .spdif_bug = 1} ,
 	 .spdif_bug = 1} ,
+	/* Dell OEM/Creative Labs Audigy 2 ZS */
+	/* See ALSA bug#1365 */
+	{.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102,
+	 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0353]",
+	 .id = "Audigy2",
+	 .emu10k2_chip = 1,
+	 .ca0102_chip = 1,
+	 .ca0151_chip = 1,
+	 .spk71 = 1,
+	 .spdif_bug = 1,
+	 .ac97_chip = 1} ,
 	{.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
 	{.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
 	 .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", 
 	 .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", 
 	 .id = "Audigy2",
 	 .id = "Audigy2",

+ 5 - 1
sound/pci/emu10k1/irq.c

@@ -37,9 +37,13 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 	int handled = 0;
 	int handled = 0;
 
 
 	while ((status = inl(emu->port + IPR)) != 0) {
 	while ((status = inl(emu->port + IPR)) != 0) {
-		//printk("emu10k1 irq - status = 0x%x\n", status);
+		//snd_printk(KERN_INFO "emu10k1 irq - status = 0x%x\n", status);
 		orig_status = status;
 		orig_status = status;
 		handled = 1;
 		handled = 1;
+		if ((status & 0xffffffff) == 0xffffffff) {
+			snd_printk(KERN_INFO "snd-emu10k1: Suspected sound card removal\n");
+			break;
+		}
 		if (status & IPR_PCIERROR) {
 		if (status & IPR_PCIERROR) {
 			snd_printk(KERN_ERR "interrupt: PCI error\n");
 			snd_printk(KERN_ERR "interrupt: PCI error\n");
 			snd_emu10k1_intr_disable(emu, INTE_PCIERRORENABLE);
 			snd_emu10k1_intr_disable(emu, INTE_PCIERRORENABLE);

+ 1 - 2
sound/ppc/awacs.c

@@ -801,11 +801,10 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
 	chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf;
 	chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf;
 #ifdef PMAC_AMP_AVAIL
 #ifdef PMAC_AMP_AVAIL
 	if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) {
 	if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) {
-		struct awacs_amp *amp = kmalloc(sizeof(*amp), GFP_KERNEL);
+		struct awacs_amp *amp = kzalloc(sizeof(*amp), GFP_KERNEL);
 		if (! amp)
 		if (! amp)
 			return -ENOMEM;
 			return -ENOMEM;
 		chip->mixer_data = amp;
 		chip->mixer_data = amp;
-		memset(amp, 0, sizeof(*amp));
 		chip->mixer_free = awacs_amp_free;
 		chip->mixer_free = awacs_amp_free;
 		awacs_amp_set_vol(amp, 0, 63, 63, 0); /* mute and zero vol */
 		awacs_amp_set_vol(amp, 0, 63, 63, 0); /* mute and zero vol */
 		awacs_amp_set_vol(amp, 1, 63, 63, 0);
 		awacs_amp_set_vol(amp, 1, 63, 63, 0);

+ 1 - 2
sound/ppc/daca.c

@@ -258,10 +258,9 @@ int __init snd_pmac_daca_init(struct snd_pmac *chip)
 		request_module("i2c-powermac");
 		request_module("i2c-powermac");
 #endif /* CONFIG_KMOD */	
 #endif /* CONFIG_KMOD */	
 
 
-	mix = kmalloc(sizeof(*mix), GFP_KERNEL);
+	mix = kzalloc(sizeof(*mix), GFP_KERNEL);
 	if (! mix)
 	if (! mix)
 		return -ENOMEM;
 		return -ENOMEM;
-	memset(mix, 0, sizeof(*mix));
 	chip->mixer_data = mix;
 	chip->mixer_data = mix;
 	chip->mixer_free = daca_cleanup;
 	chip->mixer_free = daca_cleanup;
 	mix->amp_on = 1; /* default on */
 	mix->amp_on = 1; /* default on */

+ 1 - 2
sound/ppc/keywest.c

@@ -64,11 +64,10 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter)
 	if (strncmp(i2c_device_name(adapter), "mac-io", 6))
 	if (strncmp(i2c_device_name(adapter), "mac-io", 6))
 		return 0; /* ignored */
 		return 0; /* ignored */
 
 
-	new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+	new_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
 	if (! new_client)
 	if (! new_client)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
-	memset(new_client, 0, sizeof(*new_client));
 	new_client->addr = keywest_ctx->addr;
 	new_client->addr = keywest_ctx->addr;
 	i2c_set_clientdata(new_client, keywest_ctx);
 	i2c_set_clientdata(new_client, keywest_ctx);
 	new_client->adapter = adapter;
 	new_client->adapter = adapter;

+ 3 - 10
sound/ppc/powermac.c

@@ -181,21 +181,14 @@ static int __init alsa_card_pmac_init(void)
 	if ((err = platform_driver_register(&snd_pmac_driver)) < 0)
 	if ((err = platform_driver_register(&snd_pmac_driver)) < 0)
 		return err;
 		return err;
 	device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0);
 	device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0);
-	if (!IS_ERR(device)) {
-		if (platform_get_drvdata(device))
-			return 0;
-		platform_device_unregister(device);
-		err = -ENODEV;
-	} else
-		err = PTR_ERR(device);
-	platform_driver_unregister(&snd_pmac_driver);
-	return err;
+	return 0;
 
 
 }
 }
 
 
 static void __exit alsa_card_pmac_exit(void)
 static void __exit alsa_card_pmac_exit(void)
 {
 {
-	platform_device_unregister(device);
+	if (!IS_ERR(device))
+		platform_device_unregister(device);
 	platform_driver_unregister(&snd_pmac_driver);
 	platform_driver_unregister(&snd_pmac_driver);
 }
 }
 
 

+ 1 - 2
sound/ppc/tumbler.c

@@ -1316,10 +1316,9 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
 		request_module("i2c-powermac");
 		request_module("i2c-powermac");
 #endif /* CONFIG_KMOD */	
 #endif /* CONFIG_KMOD */	
 
 
-	mix = kmalloc(sizeof(*mix), GFP_KERNEL);
+	mix = kzalloc(sizeof(*mix), GFP_KERNEL);
 	if (! mix)
 	if (! mix)
 		return -ENOMEM;
 		return -ENOMEM;
-	memset(mix, 0, sizeof(*mix));
 	mix->headphone_irq = -1;
 	mix->headphone_irq = -1;
 
 
 	chip->mixer_data = mix;
 	chip->mixer_data = mix;

+ 2 - 4
sound/usb/usbaudio.c

@@ -2260,10 +2260,9 @@ static int add_audio_endpoint(struct snd_usb_audio *chip, int stream, struct aud
 	}
 	}
 
 
 	/* create a new pcm */
 	/* create a new pcm */
-	as = kmalloc(sizeof(*as), GFP_KERNEL);
+	as = kzalloc(sizeof(*as), GFP_KERNEL);
 	if (! as)
 	if (! as)
 		return -ENOMEM;
 		return -ENOMEM;
-	memset(as, 0, sizeof(*as));
 	as->pcm_index = chip->pcm_devs;
 	as->pcm_index = chip->pcm_devs;
 	as->chip = chip;
 	as->chip = chip;
 	as->fmt_type = fp->fmt_type;
 	as->fmt_type = fp->fmt_type;
@@ -2633,13 +2632,12 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 			csep = NULL;
 			csep = NULL;
 		}
 		}
 
 
-		fp = kmalloc(sizeof(*fp), GFP_KERNEL);
+		fp = kzalloc(sizeof(*fp), GFP_KERNEL);
 		if (! fp) {
 		if (! fp) {
 			snd_printk(KERN_ERR "cannot malloc\n");
 			snd_printk(KERN_ERR "cannot malloc\n");
 			return -ENOMEM;
 			return -ENOMEM;
 		}
 		}
 
 
-		memset(fp, 0, sizeof(*fp));
 		fp->iface = iface_no;
 		fp->iface = iface_no;
 		fp->altsetting = altno;
 		fp->altsetting = altno;
 		fp->altset_idx = i;
 		fp->altset_idx = i;