aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/cpu-freq/index.txt10
-rw-r--r--Documentation/hwmon/adt747318
-rw-r--r--Documentation/hwmon/sysfs-interface12
-rw-r--r--Documentation/video4linux/CARDLIST.em28xx2
-rw-r--r--Documentation/video4linux/gspca.txt1
-rw-r--r--Makefile2
-rw-r--r--arch/mips/Kconfig27
-rw-r--r--arch/mips/kernel/head.S1
-rw-r--r--arch/mips/sibyte/swarm/Makefile3
-rw-r--r--arch/mips/sibyte/swarm/platform.c85
-rw-r--r--arch/x86/kernel/acpi/boot.c16
-rw-r--r--arch/x86/kernel/cpu/cpufreq/p4-clockmod.c2
-rw-r--r--arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c2
-rw-r--r--arch/x86/kernel/kgdb.c7
-rw-r--r--drivers/ata/Kconfig2
-rw-r--r--drivers/ata/ahci.c25
-rw-r--r--drivers/ata/ata_piix.c184
-rw-r--r--drivers/ata/libata-core.c252
-rw-r--r--drivers/ata/libata-eh.c362
-rw-r--r--drivers/ata/libata-scsi.c108
-rw-r--r--drivers/ata/libata.h3
-rw-r--r--drivers/ata/pata_bf54x.c34
-rw-r--r--drivers/ata/pata_sil680.c2
-rw-r--r--drivers/ata/sata_fsl.c26
-rw-r--r--drivers/ata/sata_inic162x.c8
-rw-r--r--drivers/ata/sata_mv.c28
-rw-r--r--drivers/ata/sata_nv.c16
-rw-r--r--drivers/ata/sata_promise.c16
-rw-r--r--drivers/ata/sata_qstor.c12
-rw-r--r--drivers/ata/sata_sil.c16
-rw-r--r--drivers/ata/sata_sil24.c12
-rw-r--r--drivers/ata/sata_sis.c28
-rw-r--r--drivers/ata/sata_svw.c10
-rw-r--r--drivers/ata/sata_uli.c24
-rw-r--r--drivers/ata/sata_via.c24
-rw-r--r--drivers/ata/sata_vsc.c10
-rw-r--r--drivers/bluetooth/bpa10x.c2
-rw-r--r--drivers/bluetooth/btusb.c8
-rw-r--r--drivers/hwmon/abituguru3.c3
-rw-r--r--drivers/hwmon/it87.c70
-rw-r--r--drivers/ide/Kconfig4
-rw-r--r--drivers/ide/ide-cd.c6
-rw-r--r--drivers/ide/ide-dma.c2
-rw-r--r--drivers/ide/ide-probe.c2
-rw-r--r--drivers/ide/mips/Makefile1
-rw-r--r--drivers/ide/mips/swarm.c197
-rw-r--r--drivers/media/common/tuners/tuner-xc2028.h1
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c1
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c16
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c16
-rw-r--r--drivers/media/dvb/frontends/s5h1420.c11
-rw-r--r--drivers/media/dvb/frontends/s5h1420.h8
-rw-r--r--drivers/media/dvb/siano/sms-cards.c4
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c2
-rw-r--r--drivers/media/video/cafe_ccic.c1
-rw-r--r--drivers/media/video/cpia2/cpia2_usb.c5
-rw-r--r--drivers/media/video/cx18/cx18-cards.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-audio.c12
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c55
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c9
-rw-r--r--drivers/media/video/gspca/gspca.c3
-rw-r--r--drivers/media/video/gspca/pac7311.c1
-rw-r--r--drivers/media/video/gspca/sonixb.c4
-rw-r--r--drivers/media/video/gspca/sonixj.c19
-rw-r--r--drivers/media/video/gspca/spca561.c2
-rw-r--r--drivers/media/video/gspca/zc3xx.c4
-rw-r--r--drivers/media/video/ov511.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-devattr.c2
-rw-r--r--drivers/media/video/s2255drv.c3
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c2
-rw-r--r--drivers/media/video/w9968cf.c2
-rw-r--r--drivers/media/video/wm8739.c4
-rw-r--r--drivers/media/video/zoran_card.c2
-rw-r--r--drivers/media/video/zoran_driver.c15
-rw-r--r--drivers/misc/eeepc-laptop.c16
-rw-r--r--drivers/mmc/host/atmel-mci.c6
-rw-r--r--drivers/pnp/Makefile5
-rw-r--r--drivers/pnp/pnpacpi/core.c2
-rw-r--r--drivers/pnp/pnpbios/core.c2
-rw-r--r--drivers/scsi/libsas/sas_ata.c8
-rw-r--r--fs/splice.c3
-rw-r--r--include/asm-mips/sn/mapped_kernel.h8
-rw-r--r--include/linux/ata.h9
-rw-r--r--include/linux/ide.h4
-rw-r--r--include/linux/libata.h66
-rw-r--r--kernel/kgdb.c3
-rw-r--r--mm/slob.c8
-rw-r--r--net/ax25/af_ax25.c3
-rw-r--r--net/ax25/ax25_std_timer.c8
-rw-r--r--net/core/dev.c43
-rw-r--r--net/core/rtnetlink.c2
-rw-r--r--net/ipv4/tcp_hybla.c6
-rw-r--r--net/ipv4/tcp_input.c3
-rw-r--r--net/netrom/af_netrom.c2
-rw-r--r--scripts/mod/modpost.c6
95 files changed, 1340 insertions, 770 deletions
diff --git a/Documentation/cpu-freq/index.txt b/Documentation/cpu-freq/index.txt
index ffdb5323df37..3d0b915035b9 100644
--- a/Documentation/cpu-freq/index.txt
+++ b/Documentation/cpu-freq/index.txt
@@ -35,11 +35,9 @@ Mailing List
35------------ 35------------
36There is a CPU frequency changing CVS commit and general list where 36There is a CPU frequency changing CVS commit and general list where
37you can report bugs, problems or submit patches. To post a message, 37you can report bugs, problems or submit patches. To post a message,
38send an email to cpufreq@lists.linux.org.uk, to subscribe go to 38send an email to cpufreq@vger.kernel.org, to subscribe go to
39http://lists.linux.org.uk/mailman/listinfo/cpufreq. Previous post to the 39http://vger.kernel.org/vger-lists.html#cpufreq and follow the
40mailing list are available to subscribers at 40instructions there.
41http://lists.linux.org.uk/mailman/private/cpufreq/.
42
43 41
44Links 42Links
45----- 43-----
@@ -50,7 +48,7 @@ how to access the CVS repository:
50* http://cvs.arm.linux.org.uk/ 48* http://cvs.arm.linux.org.uk/
51 49
52the CPUFreq Mailing list: 50the CPUFreq Mailing list:
53* http://lists.linux.org.uk/mailman/listinfo/cpufreq 51* http://vger.kernel.org/vger-lists.html#cpufreq
54 52
55Clock and voltage scaling for the SA-1100: 53Clock and voltage scaling for the SA-1100:
56* http://www.lartmaker.nl/projects/scaling 54* http://www.lartmaker.nl/projects/scaling
diff --git a/Documentation/hwmon/adt7473 b/Documentation/hwmon/adt7473
index 2126de34c711..1cbf671822e2 100644
--- a/Documentation/hwmon/adt7473
+++ b/Documentation/hwmon/adt7473
@@ -14,14 +14,14 @@ Description
14 14
15This driver implements support for the Analog Devices ADT7473 chip family. 15This driver implements support for the Analog Devices ADT7473 chip family.
16 16
17The LM85 uses the 2-wire interface compatible with the SMBUS 2.0 17The ADT7473 uses the 2-wire interface compatible with the SMBUS 2.0
18specification. Using an analog to digital converter it measures three (3) 18specification. Using an analog to digital converter it measures three (3)
19temperatures and two (2) voltages. It has three (3) 16-bit counters for 19temperatures and two (2) voltages. It has four (4) 16-bit counters for
20measuring fan speed. There are three (3) PWM outputs that can be used 20measuring fan speed. There are three (3) PWM outputs that can be used
21to control fan speed. 21to control fan speed.
22 22
23A sophisticated control system for the PWM outputs is designed into the 23A sophisticated control system for the PWM outputs is designed into the
24LM85 that allows fan speed to be adjusted automatically based on any of the 24ADT7473 that allows fan speed to be adjusted automatically based on any of the
25three temperature sensors. Each PWM output is individually adjustable and 25three temperature sensors. Each PWM output is individually adjustable and
26programmable. Once configured, the ADT7473 will adjust the PWM outputs in 26programmable. Once configured, the ADT7473 will adjust the PWM outputs in
27response to the measured temperatures without further host intervention. 27response to the measured temperatures without further host intervention.
@@ -46,14 +46,6 @@ from the raw value to get the temperature value.
46The Analog Devices datasheet is very detailed and describes a procedure for 46The Analog Devices datasheet is very detailed and describes a procedure for
47determining an optimal configuration for the automatic PWM control. 47determining an optimal configuration for the automatic PWM control.
48 48
49Hardware Configurations
50-----------------------
51
52The ADT7473 chips have an optional SMBALERT output that can be used to
53signal the chipset in case a limit is exceeded or the temperature sensors
54fail. Individual sensor interrupts can be masked so they won't trigger
55SMBALERT. The SMBALERT output if configured replaces the PWM2 function.
56
57Configuration Notes 49Configuration Notes
58------------------- 50-------------------
59 51
@@ -61,8 +53,8 @@ Besides standard interfaces driver adds the following:
61 53
62* PWM Control 54* PWM Control
63 55
64* pwm#_auto_point1_pwm and pwm#_auto_point1_temp and 56* pwm#_auto_point1_pwm and temp#_auto_point1_temp and
65* pwm#_auto_point2_pwm and pwm#_auto_point2_temp - 57* pwm#_auto_point2_pwm and temp#_auto_point2_temp -
66 58
67point1: Set the pwm speed at a lower temperature bound. 59point1: Set the pwm speed at a lower temperature bound.
68point2: Set the pwm speed at a higher temperature bound. 60point2: Set the pwm speed at a higher temperature bound.
diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface
index 2d845730d4e0..6dbfd5efd991 100644
--- a/Documentation/hwmon/sysfs-interface
+++ b/Documentation/hwmon/sysfs-interface
@@ -329,6 +329,10 @@ power[1-*]_average Average power use
329 Unit: microWatt 329 Unit: microWatt
330 RO 330 RO
331 331
332power[1-*]_average_interval Power use averaging interval
333 Unit: milliseconds
334 RW
335
332power[1-*]_average_highest Historical average maximum power use 336power[1-*]_average_highest Historical average maximum power use
333 Unit: microWatt 337 Unit: microWatt
334 RO 338 RO
@@ -354,6 +358,14 @@ power[1-*]_reset_history Reset input_highest, input_lowest,
354 WO 358 WO
355 359
356********** 360**********
361* Energy *
362**********
363
364energy[1-*]_input Cumulative energy use
365 Unit: microJoule
366 RO
367
368**********
357* Alarms * 369* Alarms *
358********** 370**********
359 371
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx
index 89c7f32abf9f..53449cb99b17 100644
--- a/Documentation/video4linux/CARDLIST.em28xx
+++ b/Documentation/video4linux/CARDLIST.em28xx
@@ -46,7 +46,7 @@
46 45 -> Pinnacle PCTV DVB-T (em2870) 46 45 -> Pinnacle PCTV DVB-T (em2870)
47 46 -> Compro, VideoMate U3 (em2870) [185b:2870] 47 46 -> Compro, VideoMate U3 (em2870) [185b:2870]
48 47 -> KWorld DVB-T 305U (em2880) [eb1a:e305] 48 47 -> KWorld DVB-T 305U (em2880) [eb1a:e305]
49 48 -> KWorld DVB-T 310U (em2880) 49 48 -> KWorld DVB-T 310U (em2880) [eb1a:e310]
50 49 -> MSI DigiVox A/D (em2880) [eb1a:e310] 50 49 -> MSI DigiVox A/D (em2880) [eb1a:e310]
51 50 -> MSI DigiVox A/D II (em2880) [eb1a:e320] 51 50 -> MSI DigiVox A/D II (em2880) [eb1a:e320]
52 51 -> Terratec Hybrid XS Secam (em2880) [0ccd:004c] 52 51 -> Terratec Hybrid XS Secam (em2880) [0ccd:004c]
diff --git a/Documentation/video4linux/gspca.txt b/Documentation/video4linux/gspca.txt
index 0f03900c48fb..9a3e4d797fa8 100644
--- a/Documentation/video4linux/gspca.txt
+++ b/Documentation/video4linux/gspca.txt
@@ -190,6 +190,7 @@ pac7311 093a:260f SnakeCam
190pac7311 093a:2621 PAC731x 190pac7311 093a:2621 PAC731x
191pac7311 093a:2624 PAC7302 191pac7311 093a:2624 PAC7302
192pac7311 093a:2626 Labtec 2200 192pac7311 093a:2626 Labtec 2200
193pac7311 093a:262a Webcam 300k
193zc3xx 0ac8:0302 Z-star Vimicro zc0302 194zc3xx 0ac8:0302 Z-star Vimicro zc0302
194vc032x 0ac8:0321 Vimicro generic vc0321 195vc032x 0ac8:0321 Vimicro generic vc0321
195vc032x 0ac8:0323 Vimicro Vc0323 196vc032x 0ac8:0323 Vimicro Vc0323
diff --git a/Makefile b/Makefile
index 1d03c1644ddb..16e3fbb968a8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 27 3SUBLEVEL = 27
4EXTRAVERSION = -rc8 4EXTRAVERSION =
5NAME = Rotary Wombat 5NAME = Rotary Wombat
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index c930b8ceb418..1e06d233fa83 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -211,6 +211,7 @@ config MIPS_MALTA
211 select SYS_SUPPORTS_64BIT_KERNEL 211 select SYS_SUPPORTS_64BIT_KERNEL
212 select SYS_SUPPORTS_BIG_ENDIAN 212 select SYS_SUPPORTS_BIG_ENDIAN
213 select SYS_SUPPORTS_LITTLE_ENDIAN 213 select SYS_SUPPORTS_LITTLE_ENDIAN
214 select SYS_SUPPORTS_MIPS_CMP if BROKEN # because SYNC_R4K is broken
214 select SYS_SUPPORTS_MULTITHREADING 215 select SYS_SUPPORTS_MULTITHREADING
215 select SYS_SUPPORTS_SMARTMIPS 216 select SYS_SUPPORTS_SMARTMIPS
216 help 217 help
@@ -1499,6 +1500,18 @@ config MIPS_APSP_KSPD
1499 "exit" syscall notifying other kernel modules the SP program is 1500 "exit" syscall notifying other kernel modules the SP program is
1500 exiting. You probably want to say yes here. 1501 exiting. You probably want to say yes here.
1501 1502
1503config MIPS_CMP
1504 bool "MIPS CMP framework support"
1505 depends on SYS_SUPPORTS_MIPS_CMP
1506 select SYNC_R4K if BROKEN
1507 select SYS_SUPPORTS_SMP
1508 select SYS_SUPPORTS_SCHED_SMT if SMP
1509 select WEAK_ORDERING
1510 default n
1511 help
1512 This is a placeholder option for the GCMP work. It will need to
1513 be handled differently...
1514
1502config SB1_PASS_1_WORKAROUNDS 1515config SB1_PASS_1_WORKAROUNDS
1503 bool 1516 bool
1504 depends on CPU_SB1_PASS_1 1517 depends on CPU_SB1_PASS_1
@@ -1675,6 +1688,9 @@ config SMP
1675config SMP_UP 1688config SMP_UP
1676 bool 1689 bool
1677 1690
1691config SYS_SUPPORTS_MIPS_CMP
1692 bool
1693
1678config SYS_SUPPORTS_SMP 1694config SYS_SUPPORTS_SMP
1679 bool 1695 bool
1680 1696
@@ -1722,17 +1738,6 @@ config NR_CPUS
1722 performance should round up your number of processors to the next 1738 performance should round up your number of processors to the next
1723 power of two. 1739 power of two.
1724 1740
1725config MIPS_CMP
1726 bool "MIPS CMP framework support"
1727 depends on SMP
1728 select SYNC_R4K
1729 select SYS_SUPPORTS_SCHED_SMT
1730 select WEAK_ORDERING
1731 default n
1732 help
1733 This is a placeholder option for the GCMP work. It will need to
1734 be handled differently...
1735
1736source "kernel/time/Kconfig" 1741source "kernel/time/Kconfig"
1737 1742
1738# 1743#
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 361364501d34..492a0a8d70fb 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -22,6 +22,7 @@
22#include <asm/irqflags.h> 22#include <asm/irqflags.h>
23#include <asm/regdef.h> 23#include <asm/regdef.h>
24#include <asm/page.h> 24#include <asm/page.h>
25#include <asm/pgtable-bits.h>
25#include <asm/mipsregs.h> 26#include <asm/mipsregs.h>
26#include <asm/stackframe.h> 27#include <asm/stackframe.h>
27 28
diff --git a/arch/mips/sibyte/swarm/Makefile b/arch/mips/sibyte/swarm/Makefile
index f18ba9201bbc..7b45f199d92a 100644
--- a/arch/mips/sibyte/swarm/Makefile
+++ b/arch/mips/sibyte/swarm/Makefile
@@ -1,3 +1,4 @@
1obj-y := setup.o rtc_xicor1241.o rtc_m41t81.o 1obj-y := platform.o setup.o rtc_xicor1241.o \
2 rtc_m41t81.o
2 3
3obj-$(CONFIG_I2C_BOARDINFO) += swarm-i2c.o 4obj-$(CONFIG_I2C_BOARDINFO) += swarm-i2c.o
diff --git a/arch/mips/sibyte/swarm/platform.c b/arch/mips/sibyte/swarm/platform.c
new file mode 100644
index 000000000000..54847fe1e564
--- /dev/null
+++ b/arch/mips/sibyte/swarm/platform.c
@@ -0,0 +1,85 @@
1#include <linux/err.h>
2#include <linux/kernel.h>
3#include <linux/init.h>
4#include <linux/io.h>
5#include <linux/platform_device.h>
6#include <linux/ata_platform.h>
7
8#include <asm/sibyte/board.h>
9#include <asm/sibyte/sb1250_genbus.h>
10#include <asm/sibyte/sb1250_regs.h>
11
12#if defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR)
13
14#define DRV_NAME "pata-swarm"
15
16#define SWARM_IDE_SHIFT 5
17#define SWARM_IDE_BASE 0x1f0
18#define SWARM_IDE_CTRL 0x3f6
19
20static struct resource swarm_pata_resource[] = {
21 {
22 .name = "Swarm GenBus IDE",
23 .flags = IORESOURCE_MEM,
24 }, {
25 .name = "Swarm GenBus IDE",
26 .flags = IORESOURCE_MEM,
27 }, {
28 .name = "Swarm GenBus IDE",
29 .flags = IORESOURCE_IRQ,
30 .start = K_INT_GB_IDE,
31 .end = K_INT_GB_IDE,
32 },
33};
34
35static struct pata_platform_info pata_platform_data = {
36 .ioport_shift = SWARM_IDE_SHIFT,
37};
38
39static struct platform_device swarm_pata_device = {
40 .name = "pata_platform",
41 .id = -1,
42 .resource = swarm_pata_resource,
43 .num_resources = ARRAY_SIZE(swarm_pata_resource),
44 .dev = {
45 .platform_data = &pata_platform_data,
46 .coherent_dma_mask = ~0, /* grumble */
47 },
48};
49
50static int __init swarm_pata_init(void)
51{
52 u8 __iomem *base;
53 phys_t offset, size;
54 struct resource *r;
55
56 if (!SIBYTE_HAVE_IDE)
57 return -ENODEV;
58
59 base = ioremap(A_IO_EXT_BASE, 0x800);
60 offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
61 size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
62 iounmap(base);
63
64 offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
65 size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
66 if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
67 pr_info(DRV_NAME ": PATA interface at GenBus disabled\n");
68
69 return -EBUSY;
70 }
71
72 pr_info(DRV_NAME ": PATA interface at GenBus slot %i\n", IDE_CS);
73
74 r = swarm_pata_resource;
75 r[0].start = offset + (SWARM_IDE_BASE << SWARM_IDE_SHIFT);
76 r[0].end = offset + ((SWARM_IDE_BASE + 8) << SWARM_IDE_SHIFT) - 1;
77 r[1].start = offset + (SWARM_IDE_CTRL << SWARM_IDE_SHIFT);
78 r[1].end = offset + ((SWARM_IDE_CTRL + 1) << SWARM_IDE_SHIFT) - 1;
79
80 return platform_device_register(&swarm_pata_device);
81}
82
83device_initcall(swarm_pata_init);
84
85#endif /* defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR) */
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index e5032d7b391d..7d40ef7b36e3 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1604,6 +1604,14 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
1604 */ 1604 */
1605 { 1605 {
1606 .callback = dmi_ignore_irq0_timer_override, 1606 .callback = dmi_ignore_irq0_timer_override,
1607 .ident = "HP nx6115 laptop",
1608 .matches = {
1609 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1610 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1611 },
1612 },
1613 {
1614 .callback = dmi_ignore_irq0_timer_override,
1607 .ident = "HP NX6125 laptop", 1615 .ident = "HP NX6125 laptop",
1608 .matches = { 1616 .matches = {
1609 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 1617 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
@@ -1618,6 +1626,14 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
1618 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"), 1626 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1619 }, 1627 },
1620 }, 1628 },
1629 {
1630 .callback = dmi_ignore_irq0_timer_override,
1631 .ident = "HP 6715b laptop",
1632 .matches = {
1633 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1634 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1635 },
1636 },
1621 {} 1637 {}
1622}; 1638};
1623 1639
diff --git a/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c b/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
index f1685fb91fbd..b8e05ee4f736 100644
--- a/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
+++ b/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
@@ -171,7 +171,7 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
171 } 171 }
172 172
173 if (c->x86 != 0xF) { 173 if (c->x86 != 0xF) {
174 printk(KERN_WARNING PFX "Unknown p4-clockmod-capable CPU. Please send an e-mail to <cpufreq@lists.linux.org.uk>\n"); 174 printk(KERN_WARNING PFX "Unknown p4-clockmod-capable CPU. Please send an e-mail to <cpufreq@vger.kernel.org>\n");
175 return 0; 175 return 0;
176 } 176 }
177 177
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
index 15e13c01cc36..3b5f06423e77 100644
--- a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -26,7 +26,7 @@
26#include <asm/cpufeature.h> 26#include <asm/cpufeature.h>
27 27
28#define PFX "speedstep-centrino: " 28#define PFX "speedstep-centrino: "
29#define MAINTAINER "cpufreq@lists.linux.org.uk" 29#define MAINTAINER "cpufreq@vger.kernel.org"
30 30
31#define dprintk(msg...) \ 31#define dprintk(msg...) \
32 cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg) 32 cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg)
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 8282a2139681..10435a120d22 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -455,12 +455,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
455 return NOTIFY_DONE; 455 return NOTIFY_DONE;
456 456
457 case DIE_NMI_IPI: 457 case DIE_NMI_IPI:
458 if (atomic_read(&kgdb_active) != -1) { 458 /* Just ignore, we will handle the roundup on DIE_NMI. */
459 /* KGDB CPU roundup */
460 kgdb_nmicallback(raw_smp_processor_id(), regs);
461 was_in_debug_nmi[raw_smp_processor_id()] = 1;
462 touch_nmi_watchdog();
463 }
464 return NOTIFY_DONE; 459 return NOTIFY_DONE;
465 460
466 case DIE_NMIUNKNOWN: 461 case DIE_NMIUNKNOWN:
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 11c8c19f0fb7..f17cd4b572f8 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -663,7 +663,7 @@ config HAVE_PATA_PLATFORM
663 663
664config PATA_PLATFORM 664config PATA_PLATFORM
665 tristate "Generic platform device PATA support" 665 tristate "Generic platform device PATA support"
666 depends on EMBEDDED || ARCH_RPC || PPC || HAVE_PATA_PLATFORM 666 depends on EMBEDDED || PPC || HAVE_PATA_PLATFORM
667 help 667 help
668 This option enables support for generic directly connected ATA 668 This option enables support for generic directly connected ATA
669 devices commonly found on embedded systems. 669 devices commonly found on embedded systems.
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 2e1a7cb2ed5f..aeadd00411a1 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -267,8 +267,8 @@ struct ahci_port_priv {
267 * per PM slot */ 267 * per PM slot */
268}; 268};
269 269
270static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 270static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
271static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 271static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
272static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 272static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
273static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc); 273static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc);
274static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc); 274static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc);
@@ -316,6 +316,7 @@ static struct device_attribute *ahci_shost_attrs[] = {
316 316
317static struct device_attribute *ahci_sdev_attrs[] = { 317static struct device_attribute *ahci_sdev_attrs[] = {
318 &dev_attr_sw_activity, 318 &dev_attr_sw_activity,
319 &dev_attr_unload_heads,
319 NULL 320 NULL
320}; 321};
321 322
@@ -820,10 +821,10 @@ static unsigned ahci_scr_offset(struct ata_port *ap, unsigned int sc_reg)
820 return 0; 821 return 0;
821} 822}
822 823
823static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 824static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
824{ 825{
825 void __iomem *port_mmio = ahci_port_base(ap); 826 void __iomem *port_mmio = ahci_port_base(link->ap);
826 int offset = ahci_scr_offset(ap, sc_reg); 827 int offset = ahci_scr_offset(link->ap, sc_reg);
827 828
828 if (offset) { 829 if (offset) {
829 *val = readl(port_mmio + offset); 830 *val = readl(port_mmio + offset);
@@ -832,10 +833,10 @@ static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
832 return -EINVAL; 833 return -EINVAL;
833} 834}
834 835
835static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 836static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
836{ 837{
837 void __iomem *port_mmio = ahci_port_base(ap); 838 void __iomem *port_mmio = ahci_port_base(link->ap);
838 int offset = ahci_scr_offset(ap, sc_reg); 839 int offset = ahci_scr_offset(link->ap, sc_reg);
839 840
840 if (offset) { 841 if (offset) {
841 writel(val, port_mmio + offset); 842 writel(val, port_mmio + offset);
@@ -973,7 +974,7 @@ static void ahci_disable_alpm(struct ata_port *ap)
973 writel(PORT_IRQ_PHYRDY, port_mmio + PORT_IRQ_STAT); 974 writel(PORT_IRQ_PHYRDY, port_mmio + PORT_IRQ_STAT);
974 975
975 /* go ahead and clean out PhyRdy Change from Serror too */ 976 /* go ahead and clean out PhyRdy Change from Serror too */
976 ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18))); 977 ahci_scr_write(&ap->link, SCR_ERROR, ((1 << 16) | (1 << 18)));
977 978
978 /* 979 /*
979 * Clear flag to indicate that we should ignore all PhyRdy 980 * Clear flag to indicate that we should ignore all PhyRdy
@@ -1937,8 +1938,8 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
1937 ata_ehi_push_desc(host_ehi, "irq_stat 0x%08x", irq_stat); 1938 ata_ehi_push_desc(host_ehi, "irq_stat 0x%08x", irq_stat);
1938 1939
1939 /* AHCI needs SError cleared; otherwise, it might lock up */ 1940 /* AHCI needs SError cleared; otherwise, it might lock up */
1940 ahci_scr_read(ap, SCR_ERROR, &serror); 1941 ahci_scr_read(&ap->link, SCR_ERROR, &serror);
1941 ahci_scr_write(ap, SCR_ERROR, serror); 1942 ahci_scr_write(&ap->link, SCR_ERROR, serror);
1942 host_ehi->serror |= serror; 1943 host_ehi->serror |= serror;
1943 1944
1944 /* some controllers set IRQ_IF_ERR on device errors, ignore it */ 1945 /* some controllers set IRQ_IF_ERR on device errors, ignore it */
@@ -2027,7 +2028,7 @@ static void ahci_port_intr(struct ata_port *ap)
2027 if ((hpriv->flags & AHCI_HFLAG_NO_HOTPLUG) && 2028 if ((hpriv->flags & AHCI_HFLAG_NO_HOTPLUG) &&
2028 (status & PORT_IRQ_PHYRDY)) { 2029 (status & PORT_IRQ_PHYRDY)) {
2029 status &= ~PORT_IRQ_PHYRDY; 2030 status &= ~PORT_IRQ_PHYRDY;
2030 ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18))); 2031 ahci_scr_write(&ap->link, SCR_ERROR, ((1 << 16) | (1 << 18)));
2031 } 2032 }
2032 2033
2033 if (unlikely(status & PORT_IRQ_ERROR)) { 2034 if (unlikely(status & PORT_IRQ_ERROR)) {
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index e6b4606e36b6..e9e32ed6b1a3 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -165,8 +165,10 @@ static void piix_set_dmamode(struct ata_port *ap, struct ata_device *adev);
165static void ich_set_dmamode(struct ata_port *ap, struct ata_device *adev); 165static void ich_set_dmamode(struct ata_port *ap, struct ata_device *adev);
166static int ich_pata_cable_detect(struct ata_port *ap); 166static int ich_pata_cable_detect(struct ata_port *ap);
167static u8 piix_vmw_bmdma_status(struct ata_port *ap); 167static u8 piix_vmw_bmdma_status(struct ata_port *ap);
168static int piix_sidpr_scr_read(struct ata_port *ap, unsigned int reg, u32 *val); 168static int piix_sidpr_scr_read(struct ata_link *link,
169static int piix_sidpr_scr_write(struct ata_port *ap, unsigned int reg, u32 val); 169 unsigned int reg, u32 *val);
170static int piix_sidpr_scr_write(struct ata_link *link,
171 unsigned int reg, u32 val);
170#ifdef CONFIG_PM 172#ifdef CONFIG_PM
171static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); 173static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
172static int piix_pci_device_resume(struct pci_dev *pdev); 174static int piix_pci_device_resume(struct pci_dev *pdev);
@@ -278,12 +280,15 @@ static const struct pci_device_id piix_pci_tbl[] = {
278 /* SATA Controller IDE (PCH) */ 280 /* SATA Controller IDE (PCH) */
279 { 0x8086, 0x3b20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 281 { 0x8086, 0x3b20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
280 /* SATA Controller IDE (PCH) */ 282 /* SATA Controller IDE (PCH) */
283 { 0x8086, 0x3b21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
284 /* SATA Controller IDE (PCH) */
281 { 0x8086, 0x3b26, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, 285 { 0x8086, 0x3b26, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
282 /* SATA Controller IDE (PCH) */ 286 /* SATA Controller IDE (PCH) */
287 { 0x8086, 0x3b28, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
288 /* SATA Controller IDE (PCH) */
283 { 0x8086, 0x3b2d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, 289 { 0x8086, 0x3b2d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
284 /* SATA Controller IDE (PCH) */ 290 /* SATA Controller IDE (PCH) */
285 { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 291 { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
286
287 { } /* terminate list */ 292 { } /* terminate list */
288}; 293};
289 294
@@ -582,6 +587,7 @@ static const struct ich_laptop ich_laptop[] = {
582 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ 587 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */
583 { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ 588 { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */
584 { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ 589 { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */
590 { 0x27DF, 0x1071, 0xD221 }, /* ICH7 on Hercules EC-900 */
585 { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on ACER Aspire 2023WLMi */ 591 { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on ACER Aspire 2023WLMi */
586 { 0x24CA, 0x1025, 0x003d }, /* ICH4 on ACER TM290 */ 592 { 0x24CA, 0x1025, 0x003d }, /* ICH4 on ACER TM290 */
587 { 0x266F, 0x1025, 0x0066 }, /* ICH6 on ACER Aspire 1694WLMi */ 593 { 0x266F, 0x1025, 0x0066 }, /* ICH6 on ACER Aspire 1694WLMi */
@@ -885,23 +891,9 @@ static void ich_set_dmamode(struct ata_port *ap, struct ata_device *adev)
885 * Serial ATA Index/Data Pair Superset Registers access 891 * Serial ATA Index/Data Pair Superset Registers access
886 * 892 *
887 * Beginning from ICH8, there's a sane way to access SCRs using index 893 * Beginning from ICH8, there's a sane way to access SCRs using index
888 * and data register pair located at BAR5. This creates an 894 * and data register pair located at BAR5 which means that we have
889 * interesting problem of mapping two SCRs to one port. 895 * separate SCRs for master and slave. This is handled using libata
890 * 896 * slave_link facility.
891 * Although they have separate SCRs, the master and slave aren't
892 * independent enough to be treated as separate links - e.g. softreset
893 * resets both. Also, there's no protocol defined for hard resetting
894 * singled device sharing the virtual port (no defined way to acquire
895 * device signature). This is worked around by merging the SCR values
896 * into one sensible value and requesting follow-up SRST after
897 * hardreset.
898 *
899 * SCR merging is perfomed in nibbles which is the unit contents in
900 * SCRs are organized. If two values are equal, the value is used.
901 * When they differ, merge table which lists precedence of possible
902 * values is consulted and the first match or the last entry when
903 * nothing matches is used. When there's no merge table for the
904 * specific nibble, value from the first port is used.
905 */ 897 */
906static const int piix_sidx_map[] = { 898static const int piix_sidx_map[] = {
907 [SCR_STATUS] = 0, 899 [SCR_STATUS] = 0,
@@ -909,120 +901,38 @@ static const int piix_sidx_map[] = {
909 [SCR_CONTROL] = 1, 901 [SCR_CONTROL] = 1,
910}; 902};
911 903
912static void piix_sidpr_sel(struct ata_device *dev, unsigned int reg) 904static void piix_sidpr_sel(struct ata_link *link, unsigned int reg)
913{ 905{
914 struct ata_port *ap = dev->link->ap; 906 struct ata_port *ap = link->ap;
915 struct piix_host_priv *hpriv = ap->host->private_data; 907 struct piix_host_priv *hpriv = ap->host->private_data;
916 908
917 iowrite32(((ap->port_no * 2 + dev->devno) << 8) | piix_sidx_map[reg], 909 iowrite32(((ap->port_no * 2 + link->pmp) << 8) | piix_sidx_map[reg],
918 hpriv->sidpr + PIIX_SIDPR_IDX); 910 hpriv->sidpr + PIIX_SIDPR_IDX);
919} 911}
920 912
921static int piix_sidpr_read(struct ata_device *dev, unsigned int reg) 913static int piix_sidpr_scr_read(struct ata_link *link,
922{ 914 unsigned int reg, u32 *val)
923 struct piix_host_priv *hpriv = dev->link->ap->host->private_data;
924
925 piix_sidpr_sel(dev, reg);
926 return ioread32(hpriv->sidpr + PIIX_SIDPR_DATA);
927}
928
929static void piix_sidpr_write(struct ata_device *dev, unsigned int reg, u32 val)
930{
931 struct piix_host_priv *hpriv = dev->link->ap->host->private_data;
932
933 piix_sidpr_sel(dev, reg);
934 iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA);
935}
936
937static u32 piix_merge_scr(u32 val0, u32 val1, const int * const *merge_tbl)
938{
939 u32 val = 0;
940 int i, mi;
941
942 for (i = 0, mi = 0; i < 32 / 4; i++) {
943 u8 c0 = (val0 >> (i * 4)) & 0xf;
944 u8 c1 = (val1 >> (i * 4)) & 0xf;
945 u8 merged = c0;
946 const int *cur;
947
948 /* if no merge preference, assume the first value */
949 cur = merge_tbl[mi];
950 if (!cur)
951 goto done;
952 mi++;
953
954 /* if two values equal, use it */
955 if (c0 == c1)
956 goto done;
957
958 /* choose the first match or the last from the merge table */
959 while (*cur != -1) {
960 if (c0 == *cur || c1 == *cur)
961 break;
962 cur++;
963 }
964 if (*cur == -1)
965 cur--;
966 merged = *cur;
967 done:
968 val |= merged << (i * 4);
969 }
970
971 return val;
972}
973
974static int piix_sidpr_scr_read(struct ata_port *ap, unsigned int reg, u32 *val)
975{ 915{
976 const int * const sstatus_merge_tbl[] = { 916 struct piix_host_priv *hpriv = link->ap->host->private_data;
977 /* DET */ (const int []){ 1, 3, 0, 4, 3, -1 },
978 /* SPD */ (const int []){ 2, 1, 0, -1 },
979 /* IPM */ (const int []){ 6, 2, 1, 0, -1 },
980 NULL,
981 };
982 const int * const scontrol_merge_tbl[] = {
983 /* DET */ (const int []){ 1, 0, 4, 0, -1 },
984 /* SPD */ (const int []){ 0, 2, 1, 0, -1 },
985 /* IPM */ (const int []){ 0, 1, 2, 3, 0, -1 },
986 NULL,
987 };
988 u32 v0, v1;
989 917
990 if (reg >= ARRAY_SIZE(piix_sidx_map)) 918 if (reg >= ARRAY_SIZE(piix_sidx_map))
991 return -EINVAL; 919 return -EINVAL;
992 920
993 if (!(ap->flags & ATA_FLAG_SLAVE_POSS)) { 921 piix_sidpr_sel(link, reg);
994 *val = piix_sidpr_read(&ap->link.device[0], reg); 922 *val = ioread32(hpriv->sidpr + PIIX_SIDPR_DATA);
995 return 0;
996 }
997
998 v0 = piix_sidpr_read(&ap->link.device[0], reg);
999 v1 = piix_sidpr_read(&ap->link.device[1], reg);
1000
1001 switch (reg) {
1002 case SCR_STATUS:
1003 *val = piix_merge_scr(v0, v1, sstatus_merge_tbl);
1004 break;
1005 case SCR_ERROR:
1006 *val = v0 | v1;
1007 break;
1008 case SCR_CONTROL:
1009 *val = piix_merge_scr(v0, v1, scontrol_merge_tbl);
1010 break;
1011 }
1012
1013 return 0; 923 return 0;
1014} 924}
1015 925
1016static int piix_sidpr_scr_write(struct ata_port *ap, unsigned int reg, u32 val) 926static int piix_sidpr_scr_write(struct ata_link *link,
927 unsigned int reg, u32 val)
1017{ 928{
929 struct piix_host_priv *hpriv = link->ap->host->private_data;
930
1018 if (reg >= ARRAY_SIZE(piix_sidx_map)) 931 if (reg >= ARRAY_SIZE(piix_sidx_map))
1019 return -EINVAL; 932 return -EINVAL;
1020 933
1021 piix_sidpr_write(&ap->link.device[0], reg, val); 934 piix_sidpr_sel(link, reg);
1022 935 iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA);
1023 if (ap->flags & ATA_FLAG_SLAVE_POSS)
1024 piix_sidpr_write(&ap->link.device[1], reg, val);
1025
1026 return 0; 936 return 0;
1027} 937}
1028 938
@@ -1363,28 +1273,28 @@ static const int *__devinit piix_init_sata_map(struct pci_dev *pdev,
1363 return map; 1273 return map;
1364} 1274}
1365 1275
1366static void __devinit piix_init_sidpr(struct ata_host *host) 1276static int __devinit piix_init_sidpr(struct ata_host *host)
1367{ 1277{
1368 struct pci_dev *pdev = to_pci_dev(host->dev); 1278 struct pci_dev *pdev = to_pci_dev(host->dev);
1369 struct piix_host_priv *hpriv = host->private_data; 1279 struct piix_host_priv *hpriv = host->private_data;
1370 struct ata_device *dev0 = &host->ports[0]->link.device[0]; 1280 struct ata_link *link0 = &host->ports[0]->link;
1371 u32 scontrol; 1281 u32 scontrol;
1372 int i; 1282 int i, rc;
1373 1283
1374 /* check for availability */ 1284 /* check for availability */
1375 for (i = 0; i < 4; i++) 1285 for (i = 0; i < 4; i++)
1376 if (hpriv->map[i] == IDE) 1286 if (hpriv->map[i] == IDE)
1377 return; 1287 return 0;
1378 1288
1379 if (!(host->ports[0]->flags & PIIX_FLAG_SIDPR)) 1289 if (!(host->ports[0]->flags & PIIX_FLAG_SIDPR))
1380 return; 1290 return 0;
1381 1291
1382 if (pci_resource_start(pdev, PIIX_SIDPR_BAR) == 0 || 1292 if (pci_resource_start(pdev, PIIX_SIDPR_BAR) == 0 ||
1383 pci_resource_len(pdev, PIIX_SIDPR_BAR) != PIIX_SIDPR_LEN) 1293 pci_resource_len(pdev, PIIX_SIDPR_BAR) != PIIX_SIDPR_LEN)
1384 return; 1294 return 0;
1385 1295
1386 if (pcim_iomap_regions(pdev, 1 << PIIX_SIDPR_BAR, DRV_NAME)) 1296 if (pcim_iomap_regions(pdev, 1 << PIIX_SIDPR_BAR, DRV_NAME))
1387 return; 1297 return 0;
1388 1298
1389 hpriv->sidpr = pcim_iomap_table(pdev)[PIIX_SIDPR_BAR]; 1299 hpriv->sidpr = pcim_iomap_table(pdev)[PIIX_SIDPR_BAR];
1390 1300
@@ -1392,7 +1302,7 @@ static void __devinit piix_init_sidpr(struct ata_host *host)
1392 * Give it a test drive by inhibiting power save modes which 1302 * Give it a test drive by inhibiting power save modes which
1393 * we'll do anyway. 1303 * we'll do anyway.
1394 */ 1304 */
1395 scontrol = piix_sidpr_read(dev0, SCR_CONTROL); 1305 piix_sidpr_scr_read(link0, SCR_CONTROL, &scontrol);
1396 1306
1397 /* if IPM is already 3, SCR access is probably working. Don't 1307 /* if IPM is already 3, SCR access is probably working. Don't
1398 * un-inhibit power save modes as BIOS might have inhibited 1308 * un-inhibit power save modes as BIOS might have inhibited
@@ -1400,18 +1310,30 @@ static void __devinit piix_init_sidpr(struct ata_host *host)
1400 */ 1310 */
1401 if ((scontrol & 0xf00) != 0x300) { 1311 if ((scontrol & 0xf00) != 0x300) {
1402 scontrol |= 0x300; 1312 scontrol |= 0x300;
1403 piix_sidpr_write(dev0, SCR_CONTROL, scontrol); 1313 piix_sidpr_scr_write(link0, SCR_CONTROL, scontrol);
1404 scontrol = piix_sidpr_read(dev0, SCR_CONTROL); 1314 piix_sidpr_scr_read(link0, SCR_CONTROL, &scontrol);
1405 1315
1406 if ((scontrol & 0xf00) != 0x300) { 1316 if ((scontrol & 0xf00) != 0x300) {
1407 dev_printk(KERN_INFO, host->dev, "SCR access via " 1317 dev_printk(KERN_INFO, host->dev, "SCR access via "
1408 "SIDPR is available but doesn't work\n"); 1318 "SIDPR is available but doesn't work\n");
1409 return; 1319 return 0;
1410 } 1320 }
1411 } 1321 }
1412 1322
1413 host->ports[0]->ops = &piix_sidpr_sata_ops; 1323 /* okay, SCRs available, set ops and ask libata for slave_link */
1414 host->ports[1]->ops = &piix_sidpr_sata_ops; 1324 for (i = 0; i < 2; i++) {
1325 struct ata_port *ap = host->ports[i];
1326
1327 ap->ops = &piix_sidpr_sata_ops;
1328
1329 if (ap->flags & ATA_FLAG_SLAVE_POSS) {
1330 rc = ata_slave_link_init(ap);
1331 if (rc)
1332 return rc;
1333 }
1334 }
1335
1336 return 0;
1415} 1337}
1416 1338
1417static void piix_iocfg_bit18_quirk(struct pci_dev *pdev) 1339static void piix_iocfg_bit18_quirk(struct pci_dev *pdev)
@@ -1521,7 +1443,9 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1521 /* initialize controller */ 1443 /* initialize controller */
1522 if (port_flags & ATA_FLAG_SATA) { 1444 if (port_flags & ATA_FLAG_SATA) {
1523 piix_init_pcs(host, piix_map_db_table[ent->driver_data]); 1445 piix_init_pcs(host, piix_map_db_table[ent->driver_data]);
1524 piix_init_sidpr(host); 1446 rc = piix_init_sidpr(host);
1447 if (rc)
1448 return rc;
1525 } 1449 }
1526 1450
1527 /* apply IOCFG bit18 quirk */ 1451 /* apply IOCFG bit18 quirk */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 79e3a8e7a84a..1ee9499bd343 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -163,6 +163,67 @@ MODULE_LICENSE("GPL");
163MODULE_VERSION(DRV_VERSION); 163MODULE_VERSION(DRV_VERSION);
164 164
165 165
166/*
167 * Iterator helpers. Don't use directly.
168 *
169 * LOCKING:
170 * Host lock or EH context.
171 */
172struct ata_link *__ata_port_next_link(struct ata_port *ap,
173 struct ata_link *link, bool dev_only)
174{
175 /* NULL link indicates start of iteration */
176 if (!link) {
177 if (dev_only && sata_pmp_attached(ap))
178 return ap->pmp_link;
179 return &ap->link;
180 }
181
182 /* we just iterated over the host master link, what's next? */
183 if (link == &ap->link) {
184 if (!sata_pmp_attached(ap)) {
185 if (unlikely(ap->slave_link) && !dev_only)
186 return ap->slave_link;
187 return NULL;
188 }
189 return ap->pmp_link;
190 }
191
192 /* slave_link excludes PMP */
193 if (unlikely(link == ap->slave_link))
194 return NULL;
195
196 /* iterate to the next PMP link */
197 if (++link < ap->pmp_link + ap->nr_pmp_links)
198 return link;
199 return NULL;
200}
201
202/**
203 * ata_dev_phys_link - find physical link for a device
204 * @dev: ATA device to look up physical link for
205 *
206 * Look up physical link which @dev is attached to. Note that
207 * this is different from @dev->link only when @dev is on slave
208 * link. For all other cases, it's the same as @dev->link.
209 *
210 * LOCKING:
211 * Don't care.
212 *
213 * RETURNS:
214 * Pointer to the found physical link.
215 */
216struct ata_link *ata_dev_phys_link(struct ata_device *dev)
217{
218 struct ata_port *ap = dev->link->ap;
219
220 if (!ap->slave_link)
221 return dev->link;
222 if (!dev->devno)
223 return &ap->link;
224 return ap->slave_link;
225}
226
166/** 227/**
167 * ata_force_cbl - force cable type according to libata.force 228 * ata_force_cbl - force cable type according to libata.force
168 * @ap: ATA port of interest 229 * @ap: ATA port of interest
@@ -206,7 +267,8 @@ void ata_force_cbl(struct ata_port *ap)
206 * the host link and all fan-out ports connected via PMP. If the 267 * the host link and all fan-out ports connected via PMP. If the
207 * device part is specified as 0 (e.g. 1.00:), it specifies the 268 * device part is specified as 0 (e.g. 1.00:), it specifies the
208 * first fan-out link not the host link. Device number 15 always 269 * first fan-out link not the host link. Device number 15 always
209 * points to the host link whether PMP is attached or not. 270 * points to the host link whether PMP is attached or not. If the
271 * controller has slave link, device number 16 points to it.
210 * 272 *
211 * LOCKING: 273 * LOCKING:
212 * EH context. 274 * EH context.
@@ -214,12 +276,11 @@ void ata_force_cbl(struct ata_port *ap)
214static void ata_force_link_limits(struct ata_link *link) 276static void ata_force_link_limits(struct ata_link *link)
215{ 277{
216 bool did_spd = false; 278 bool did_spd = false;
217 int linkno, i; 279 int linkno = link->pmp;
280 int i;
218 281
219 if (ata_is_host_link(link)) 282 if (ata_is_host_link(link))
220 linkno = 15; 283 linkno += 15;
221 else
222 linkno = link->pmp;
223 284
224 for (i = ata_force_tbl_size - 1; i >= 0; i--) { 285 for (i = ata_force_tbl_size - 1; i >= 0; i--) {
225 const struct ata_force_ent *fe = &ata_force_tbl[i]; 286 const struct ata_force_ent *fe = &ata_force_tbl[i];
@@ -266,9 +327,9 @@ static void ata_force_xfermask(struct ata_device *dev)
266 int alt_devno = devno; 327 int alt_devno = devno;
267 int i; 328 int i;
268 329
269 /* allow n.15 for the first device attached to host port */ 330 /* allow n.15/16 for devices attached to host port */
270 if (ata_is_host_link(dev->link) && devno == 0) 331 if (ata_is_host_link(dev->link))
271 alt_devno = 15; 332 alt_devno += 15;
272 333
273 for (i = ata_force_tbl_size - 1; i >= 0; i--) { 334 for (i = ata_force_tbl_size - 1; i >= 0; i--) {
274 const struct ata_force_ent *fe = &ata_force_tbl[i]; 335 const struct ata_force_ent *fe = &ata_force_tbl[i];
@@ -320,9 +381,9 @@ static void ata_force_horkage(struct ata_device *dev)
320 int alt_devno = devno; 381 int alt_devno = devno;
321 int i; 382 int i;
322 383
323 /* allow n.15 for the first device attached to host port */ 384 /* allow n.15/16 for devices attached to host port */
324 if (ata_is_host_link(dev->link) && devno == 0) 385 if (ata_is_host_link(dev->link))
325 alt_devno = 15; 386 alt_devno += 15;
326 387
327 for (i = 0; i < ata_force_tbl_size; i++) { 388 for (i = 0; i < ata_force_tbl_size; i++) {
328 const struct ata_force_ent *fe = &ata_force_tbl[i]; 389 const struct ata_force_ent *fe = &ata_force_tbl[i];
@@ -2681,7 +2742,7 @@ static void sata_print_link_status(struct ata_link *link)
2681 return; 2742 return;
2682 sata_scr_read(link, SCR_CONTROL, &scontrol); 2743 sata_scr_read(link, SCR_CONTROL, &scontrol);
2683 2744
2684 if (ata_link_online(link)) { 2745 if (ata_phys_link_online(link)) {
2685 tmp = (sstatus >> 4) & 0xf; 2746 tmp = (sstatus >> 4) & 0xf;
2686 ata_link_printk(link, KERN_INFO, 2747 ata_link_printk(link, KERN_INFO,
2687 "SATA link up %s (SStatus %X SControl %X)\n", 2748 "SATA link up %s (SStatus %X SControl %X)\n",
@@ -3372,6 +3433,12 @@ int ata_wait_ready(struct ata_link *link, unsigned long deadline,
3372 unsigned long nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT); 3433 unsigned long nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT);
3373 int warned = 0; 3434 int warned = 0;
3374 3435
3436 /* Slave readiness can't be tested separately from master. On
3437 * M/S emulation configuration, this function should be called
3438 * only on the master and it will handle both master and slave.
3439 */
3440 WARN_ON(link == link->ap->slave_link);
3441
3375 if (time_after(nodev_deadline, deadline)) 3442 if (time_after(nodev_deadline, deadline))
3376 nodev_deadline = deadline; 3443 nodev_deadline = deadline;
3377 3444
@@ -3593,7 +3660,7 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
3593 } 3660 }
3594 3661
3595 /* no point in trying softreset on offline link */ 3662 /* no point in trying softreset on offline link */
3596 if (ata_link_offline(link)) 3663 if (ata_phys_link_offline(link))
3597 ehc->i.action &= ~ATA_EH_SOFTRESET; 3664 ehc->i.action &= ~ATA_EH_SOFTRESET;
3598 3665
3599 return 0; 3666 return 0;
@@ -3671,7 +3738,7 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
3671 if (rc) 3738 if (rc)
3672 goto out; 3739 goto out;
3673 /* if link is offline nothing more to do */ 3740 /* if link is offline nothing more to do */
3674 if (ata_link_offline(link)) 3741 if (ata_phys_link_offline(link))
3675 goto out; 3742 goto out;
3676 3743
3677 /* Link is online. From this point, -ENODEV too is an error. */ 3744 /* Link is online. From this point, -ENODEV too is an error. */
@@ -4868,10 +4935,8 @@ int sata_scr_valid(struct ata_link *link)
4868int sata_scr_read(struct ata_link *link, int reg, u32 *val) 4935int sata_scr_read(struct ata_link *link, int reg, u32 *val)
4869{ 4936{
4870 if (ata_is_host_link(link)) { 4937 if (ata_is_host_link(link)) {
4871 struct ata_port *ap = link->ap;
4872
4873 if (sata_scr_valid(link)) 4938 if (sata_scr_valid(link))
4874 return ap->ops->scr_read(ap, reg, val); 4939 return link->ap->ops->scr_read(link, reg, val);
4875 return -EOPNOTSUPP; 4940 return -EOPNOTSUPP;
4876 } 4941 }
4877 4942
@@ -4897,10 +4962,8 @@ int sata_scr_read(struct ata_link *link, int reg, u32 *val)
4897int sata_scr_write(struct ata_link *link, int reg, u32 val) 4962int sata_scr_write(struct ata_link *link, int reg, u32 val)
4898{ 4963{
4899 if (ata_is_host_link(link)) { 4964 if (ata_is_host_link(link)) {
4900 struct ata_port *ap = link->ap;
4901
4902 if (sata_scr_valid(link)) 4965 if (sata_scr_valid(link))
4903 return ap->ops->scr_write(ap, reg, val); 4966 return link->ap->ops->scr_write(link, reg, val);
4904 return -EOPNOTSUPP; 4967 return -EOPNOTSUPP;
4905 } 4968 }
4906 4969
@@ -4925,13 +4988,12 @@ int sata_scr_write(struct ata_link *link, int reg, u32 val)
4925int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) 4988int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
4926{ 4989{
4927 if (ata_is_host_link(link)) { 4990 if (ata_is_host_link(link)) {
4928 struct ata_port *ap = link->ap;
4929 int rc; 4991 int rc;
4930 4992
4931 if (sata_scr_valid(link)) { 4993 if (sata_scr_valid(link)) {
4932 rc = ap->ops->scr_write(ap, reg, val); 4994 rc = link->ap->ops->scr_write(link, reg, val);
4933 if (rc == 0) 4995 if (rc == 0)
4934 rc = ap->ops->scr_read(ap, reg, &val); 4996 rc = link->ap->ops->scr_read(link, reg, &val);
4935 return rc; 4997 return rc;
4936 } 4998 }
4937 return -EOPNOTSUPP; 4999 return -EOPNOTSUPP;
@@ -4941,7 +5003,7 @@ int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
4941} 5003}
4942 5004
4943/** 5005/**
4944 * ata_link_online - test whether the given link is online 5006 * ata_phys_link_online - test whether the given link is online
4945 * @link: ATA link to test 5007 * @link: ATA link to test
4946 * 5008 *
4947 * Test whether @link is online. Note that this function returns 5009 * Test whether @link is online. Note that this function returns
@@ -4952,20 +5014,20 @@ int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
4952 * None. 5014 * None.
4953 * 5015 *
4954 * RETURNS: 5016 * RETURNS:
4955 * 1 if the port online status is available and online. 5017 * True if the port online status is available and online.
4956 */ 5018 */
4957int ata_link_online(struct ata_link *link) 5019bool ata_phys_link_online(struct ata_link *link)
4958{ 5020{
4959 u32 sstatus; 5021 u32 sstatus;
4960 5022
4961 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5023 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
4962 (sstatus & 0xf) == 0x3) 5024 (sstatus & 0xf) == 0x3)
4963 return 1; 5025 return true;
4964 return 0; 5026 return false;
4965} 5027}
4966 5028
4967/** 5029/**
4968 * ata_link_offline - test whether the given link is offline 5030 * ata_phys_link_offline - test whether the given link is offline
4969 * @link: ATA link to test 5031 * @link: ATA link to test
4970 * 5032 *
4971 * Test whether @link is offline. Note that this function 5033 * Test whether @link is offline. Note that this function
@@ -4976,16 +5038,68 @@ int ata_link_online(struct ata_link *link)
4976 * None. 5038 * None.
4977 * 5039 *
4978 * RETURNS: 5040 * RETURNS:
4979 * 1 if the port offline status is available and offline. 5041 * True if the port offline status is available and offline.
4980 */ 5042 */
4981int ata_link_offline(struct ata_link *link) 5043bool ata_phys_link_offline(struct ata_link *link)
4982{ 5044{
4983 u32 sstatus; 5045 u32 sstatus;
4984 5046
4985 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5047 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
4986 (sstatus & 0xf) != 0x3) 5048 (sstatus & 0xf) != 0x3)
4987 return 1; 5049 return true;
4988 return 0; 5050 return false;
5051}
5052
5053/**
5054 * ata_link_online - test whether the given link is online
5055 * @link: ATA link to test
5056 *
5057 * Test whether @link is online. This is identical to
5058 * ata_phys_link_online() when there's no slave link. When
5059 * there's a slave link, this function should only be called on
5060 * the master link and will return true if any of M/S links is
5061 * online.
5062 *
5063 * LOCKING:
5064 * None.
5065 *
5066 * RETURNS:
5067 * True if the port online status is available and online.
5068 */
5069bool ata_link_online(struct ata_link *link)
5070{
5071 struct ata_link *slave = link->ap->slave_link;
5072
5073 WARN_ON(link == slave); /* shouldn't be called on slave link */
5074
5075 return ata_phys_link_online(link) ||
5076 (slave && ata_phys_link_online(slave));
5077}
5078
5079/**
5080 * ata_link_offline - test whether the given link is offline
5081 * @link: ATA link to test
5082 *
5083 * Test whether @link is offline. This is identical to
5084 * ata_phys_link_offline() when there's no slave link. When
5085 * there's a slave link, this function should only be called on
5086 * the master link and will return true if both M/S links are
5087 * offline.
5088 *
5089 * LOCKING:
5090 * None.
5091 *
5092 * RETURNS:
5093 * True if the port offline status is available and offline.
5094 */
5095bool ata_link_offline(struct ata_link *link)
5096{
5097 struct ata_link *slave = link->ap->slave_link;
5098
5099 WARN_ON(link == slave); /* shouldn't be called on slave link */
5100
5101 return ata_phys_link_offline(link) &&
5102 (!slave || ata_phys_link_offline(slave));
4989} 5103}
4990 5104
4991#ifdef CONFIG_PM 5105#ifdef CONFIG_PM
@@ -5127,11 +5241,11 @@ int ata_port_start(struct ata_port *ap)
5127 */ 5241 */
5128void ata_dev_init(struct ata_device *dev) 5242void ata_dev_init(struct ata_device *dev)
5129{ 5243{
5130 struct ata_link *link = dev->link; 5244 struct ata_link *link = ata_dev_phys_link(dev);
5131 struct ata_port *ap = link->ap; 5245 struct ata_port *ap = link->ap;
5132 unsigned long flags; 5246 unsigned long flags;
5133 5247
5134 /* SATA spd limit is bound to the first device */ 5248 /* SATA spd limit is bound to the attached device, reset together */
5135 link->sata_spd_limit = link->hw_sata_spd_limit; 5249 link->sata_spd_limit = link->hw_sata_spd_limit;
5136 link->sata_spd = 0; 5250 link->sata_spd = 0;
5137 5251
@@ -5264,6 +5378,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
5264 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan); 5378 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
5265 INIT_LIST_HEAD(&ap->eh_done_q); 5379 INIT_LIST_HEAD(&ap->eh_done_q);
5266 init_waitqueue_head(&ap->eh_wait_q); 5380 init_waitqueue_head(&ap->eh_wait_q);
5381 init_completion(&ap->park_req_pending);
5267 init_timer_deferrable(&ap->fastdrain_timer); 5382 init_timer_deferrable(&ap->fastdrain_timer);
5268 ap->fastdrain_timer.function = ata_eh_fastdrain_timerfn; 5383 ap->fastdrain_timer.function = ata_eh_fastdrain_timerfn;
5269 ap->fastdrain_timer.data = (unsigned long)ap; 5384 ap->fastdrain_timer.data = (unsigned long)ap;
@@ -5294,6 +5409,7 @@ static void ata_host_release(struct device *gendev, void *res)
5294 scsi_host_put(ap->scsi_host); 5409 scsi_host_put(ap->scsi_host);
5295 5410
5296 kfree(ap->pmp_link); 5411 kfree(ap->pmp_link);
5412 kfree(ap->slave_link);
5297 kfree(ap); 5413 kfree(ap);
5298 host->ports[i] = NULL; 5414 host->ports[i] = NULL;
5299 } 5415 }
@@ -5414,6 +5530,68 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev,
5414 return host; 5530 return host;
5415} 5531}
5416 5532
5533/**
5534 * ata_slave_link_init - initialize slave link
5535 * @ap: port to initialize slave link for
5536 *
5537 * Create and initialize slave link for @ap. This enables slave
5538 * link handling on the port.
5539 *
5540 * In libata, a port contains links and a link contains devices.
5541 * There is single host link but if a PMP is attached to it,
5542 * there can be multiple fan-out links. On SATA, there's usually
5543 * a single device connected to a link but PATA and SATA
5544 * controllers emulating TF based interface can have two - master
5545 * and slave.
5546 *
5547 * However, there are a few controllers which don't fit into this
5548 * abstraction too well - SATA controllers which emulate TF
5549 * interface with both master and slave devices but also have
5550 * separate SCR register sets for each device. These controllers
5551 * need separate links for physical link handling
5552 * (e.g. onlineness, link speed) but should be treated like a
5553 * traditional M/S controller for everything else (e.g. command
5554 * issue, softreset).
5555 *
5556 * slave_link is libata's way of handling this class of
5557 * controllers without impacting core layer too much. For
5558 * anything other than physical link handling, the default host
5559 * link is used for both master and slave. For physical link
5560 * handling, separate @ap->slave_link is used. All dirty details
5561 * are implemented inside libata core layer. From LLD's POV, the
5562 * only difference is that prereset, hardreset and postreset are
5563 * called once more for the slave link, so the reset sequence
5564 * looks like the following.
5565 *
5566 * prereset(M) -> prereset(S) -> hardreset(M) -> hardreset(S) ->
5567 * softreset(M) -> postreset(M) -> postreset(S)
5568 *
5569 * Note that softreset is called only for the master. Softreset
5570 * resets both M/S by definition, so SRST on master should handle
5571 * both (the standard method will work just fine).
5572 *
5573 * LOCKING:
5574 * Should be called before host is registered.
5575 *
5576 * RETURNS:
5577 * 0 on success, -errno on failure.
5578 */
5579int ata_slave_link_init(struct ata_port *ap)
5580{
5581 struct ata_link *link;
5582
5583 WARN_ON(ap->slave_link);
5584 WARN_ON(ap->flags & ATA_FLAG_PMP);
5585
5586 link = kzalloc(sizeof(*link), GFP_KERNEL);
5587 if (!link)
5588 return -ENOMEM;
5589
5590 ata_link_init(ap, link, 1);
5591 ap->slave_link = link;
5592 return 0;
5593}
5594
5417static void ata_host_stop(struct device *gendev, void *res) 5595static void ata_host_stop(struct device *gendev, void *res)
5418{ 5596{
5419 struct ata_host *host = dev_get_drvdata(gendev); 5597 struct ata_host *host = dev_get_drvdata(gendev);
@@ -5640,6 +5818,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
5640 5818
5641 /* init sata_spd_limit to the current value */ 5819 /* init sata_spd_limit to the current value */
5642 sata_link_init_spd(&ap->link); 5820 sata_link_init_spd(&ap->link);
5821 if (ap->slave_link)
5822 sata_link_init_spd(ap->slave_link);
5643 5823
5644 /* print per-port info to dmesg */ 5824 /* print per-port info to dmesg */
5645 xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask, 5825 xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask,
@@ -6260,10 +6440,12 @@ EXPORT_SYMBOL_GPL(ata_base_port_ops);
6260EXPORT_SYMBOL_GPL(sata_port_ops); 6440EXPORT_SYMBOL_GPL(sata_port_ops);
6261EXPORT_SYMBOL_GPL(ata_dummy_port_ops); 6441EXPORT_SYMBOL_GPL(ata_dummy_port_ops);
6262EXPORT_SYMBOL_GPL(ata_dummy_port_info); 6442EXPORT_SYMBOL_GPL(ata_dummy_port_info);
6443EXPORT_SYMBOL_GPL(__ata_port_next_link);
6263EXPORT_SYMBOL_GPL(ata_std_bios_param); 6444EXPORT_SYMBOL_GPL(ata_std_bios_param);
6264EXPORT_SYMBOL_GPL(ata_host_init); 6445EXPORT_SYMBOL_GPL(ata_host_init);
6265EXPORT_SYMBOL_GPL(ata_host_alloc); 6446EXPORT_SYMBOL_GPL(ata_host_alloc);
6266EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); 6447EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo);
6448EXPORT_SYMBOL_GPL(ata_slave_link_init);
6267EXPORT_SYMBOL_GPL(ata_host_start); 6449EXPORT_SYMBOL_GPL(ata_host_start);
6268EXPORT_SYMBOL_GPL(ata_host_register); 6450EXPORT_SYMBOL_GPL(ata_host_register);
6269EXPORT_SYMBOL_GPL(ata_host_activate); 6451EXPORT_SYMBOL_GPL(ata_host_activate);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index c1db2f234d2e..f2dd99122bd6 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -79,6 +79,8 @@ enum {
79 */ 79 */
80 ATA_EH_PRERESET_TIMEOUT = 10000, 80 ATA_EH_PRERESET_TIMEOUT = 10000,
81 ATA_EH_FASTDRAIN_INTERVAL = 3000, 81 ATA_EH_FASTDRAIN_INTERVAL = 3000,
82
83 ATA_EH_UA_TRIES = 5,
82}; 84};
83 85
84/* The following table determines how we sequence resets. Each entry 86/* The following table determines how we sequence resets. Each entry
@@ -1357,6 +1359,37 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
1357} 1359}
1358 1360
1359/** 1361/**
1362 * atapi_eh_tur - perform ATAPI TEST_UNIT_READY
1363 * @dev: target ATAPI device
1364 * @r_sense_key: out parameter for sense_key
1365 *
1366 * Perform ATAPI TEST_UNIT_READY.
1367 *
1368 * LOCKING:
1369 * EH context (may sleep).
1370 *
1371 * RETURNS:
1372 * 0 on success, AC_ERR_* mask on failure.
1373 */
1374static unsigned int atapi_eh_tur(struct ata_device *dev, u8 *r_sense_key)
1375{
1376 u8 cdb[ATAPI_CDB_LEN] = { TEST_UNIT_READY, 0, 0, 0, 0, 0 };
1377 struct ata_taskfile tf;
1378 unsigned int err_mask;
1379
1380 ata_tf_init(dev, &tf);
1381
1382 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1383 tf.command = ATA_CMD_PACKET;
1384 tf.protocol = ATAPI_PROT_NODATA;
1385
1386 err_mask = ata_exec_internal(dev, &tf, cdb, DMA_NONE, NULL, 0, 0);
1387 if (err_mask == AC_ERR_DEV)
1388 *r_sense_key = tf.feature >> 4;
1389 return err_mask;
1390}
1391
1392/**
1360 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE 1393 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE
1361 * @dev: device to perform REQUEST_SENSE to 1394 * @dev: device to perform REQUEST_SENSE to
1362 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) 1395 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long)
@@ -1756,7 +1789,7 @@ static unsigned int ata_eh_speed_down_verdict(struct ata_device *dev)
1756static unsigned int ata_eh_speed_down(struct ata_device *dev, 1789static unsigned int ata_eh_speed_down(struct ata_device *dev,
1757 unsigned int eflags, unsigned int err_mask) 1790 unsigned int eflags, unsigned int err_mask)
1758{ 1791{
1759 struct ata_link *link = dev->link; 1792 struct ata_link *link = ata_dev_phys_link(dev);
1760 int xfer_ok = 0; 1793 int xfer_ok = 0;
1761 unsigned int verdict; 1794 unsigned int verdict;
1762 unsigned int action = 0; 1795 unsigned int action = 0;
@@ -1880,7 +1913,8 @@ static void ata_eh_link_autopsy(struct ata_link *link)
1880 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 1913 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
1881 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 1914 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
1882 1915
1883 if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link) 1916 if (!(qc->flags & ATA_QCFLAG_FAILED) ||
1917 ata_dev_phys_link(qc->dev) != link)
1884 continue; 1918 continue;
1885 1919
1886 /* inherit upper level err_mask */ 1920 /* inherit upper level err_mask */
@@ -1967,6 +2001,23 @@ void ata_eh_autopsy(struct ata_port *ap)
1967 ata_port_for_each_link(link, ap) 2001 ata_port_for_each_link(link, ap)
1968 ata_eh_link_autopsy(link); 2002 ata_eh_link_autopsy(link);
1969 2003
2004 /* Handle the frigging slave link. Autopsy is done similarly
2005 * but actions and flags are transferred over to the master
2006 * link and handled from there.
2007 */
2008 if (ap->slave_link) {
2009 struct ata_eh_context *mehc = &ap->link.eh_context;
2010 struct ata_eh_context *sehc = &ap->slave_link->eh_context;
2011
2012 ata_eh_link_autopsy(ap->slave_link);
2013
2014 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS);
2015 mehc->i.action |= sehc->i.action;
2016 mehc->i.dev_action[1] |= sehc->i.dev_action[1];
2017 mehc->i.flags |= sehc->i.flags;
2018 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS);
2019 }
2020
1970 /* Autopsy of fanout ports can affect host link autopsy. 2021 /* Autopsy of fanout ports can affect host link autopsy.
1971 * Perform host link autopsy last. 2022 * Perform host link autopsy last.
1972 */ 2023 */
@@ -2001,7 +2052,8 @@ static void ata_eh_link_report(struct ata_link *link)
2001 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 2052 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
2002 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 2053 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
2003 2054
2004 if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link || 2055 if (!(qc->flags & ATA_QCFLAG_FAILED) ||
2056 ata_dev_phys_link(qc->dev) != link ||
2005 ((qc->flags & ATA_QCFLAG_QUIET) && 2057 ((qc->flags & ATA_QCFLAG_QUIET) &&
2006 qc->err_mask == AC_ERR_DEV)) 2058 qc->err_mask == AC_ERR_DEV))
2007 continue; 2059 continue;
@@ -2068,7 +2120,7 @@ static void ata_eh_link_report(struct ata_link *link)
2068 char cdb_buf[70] = ""; 2120 char cdb_buf[70] = "";
2069 2121
2070 if (!(qc->flags & ATA_QCFLAG_FAILED) || 2122 if (!(qc->flags & ATA_QCFLAG_FAILED) ||
2071 qc->dev->link != link || !qc->err_mask) 2123 ata_dev_phys_link(qc->dev) != link || !qc->err_mask)
2072 continue; 2124 continue;
2073 2125
2074 if (qc->dma_dir != DMA_NONE) { 2126 if (qc->dma_dir != DMA_NONE) {
@@ -2160,12 +2212,14 @@ void ata_eh_report(struct ata_port *ap)
2160} 2212}
2161 2213
2162static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset, 2214static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset,
2163 unsigned int *classes, unsigned long deadline) 2215 unsigned int *classes, unsigned long deadline,
2216 bool clear_classes)
2164{ 2217{
2165 struct ata_device *dev; 2218 struct ata_device *dev;
2166 2219
2167 ata_link_for_each_dev(dev, link) 2220 if (clear_classes)
2168 classes[dev->devno] = ATA_DEV_UNKNOWN; 2221 ata_link_for_each_dev(dev, link)
2222 classes[dev->devno] = ATA_DEV_UNKNOWN;
2169 2223
2170 return reset(link, classes, deadline); 2224 return reset(link, classes, deadline);
2171} 2225}
@@ -2187,17 +2241,20 @@ int ata_eh_reset(struct ata_link *link, int classify,
2187 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset) 2241 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
2188{ 2242{
2189 struct ata_port *ap = link->ap; 2243 struct ata_port *ap = link->ap;
2244 struct ata_link *slave = ap->slave_link;
2190 struct ata_eh_context *ehc = &link->eh_context; 2245 struct ata_eh_context *ehc = &link->eh_context;
2246 struct ata_eh_context *sehc = &slave->eh_context;
2191 unsigned int *classes = ehc->classes; 2247 unsigned int *classes = ehc->classes;
2192 unsigned int lflags = link->flags; 2248 unsigned int lflags = link->flags;
2193 int verbose = !(ehc->i.flags & ATA_EHI_QUIET); 2249 int verbose = !(ehc->i.flags & ATA_EHI_QUIET);
2194 int max_tries = 0, try = 0; 2250 int max_tries = 0, try = 0;
2251 struct ata_link *failed_link;
2195 struct ata_device *dev; 2252 struct ata_device *dev;
2196 unsigned long deadline, now; 2253 unsigned long deadline, now;
2197 ata_reset_fn_t reset; 2254 ata_reset_fn_t reset;
2198 unsigned long flags; 2255 unsigned long flags;
2199 u32 sstatus; 2256 u32 sstatus;
2200 int nr_known, rc; 2257 int nr_unknown, rc;
2201 2258
2202 /* 2259 /*
2203 * Prepare to reset 2260 * Prepare to reset
@@ -2252,8 +2309,30 @@ int ata_eh_reset(struct ata_link *link, int classify,
2252 } 2309 }
2253 2310
2254 if (prereset) { 2311 if (prereset) {
2255 rc = prereset(link, 2312 unsigned long deadline = ata_deadline(jiffies,
2256 ata_deadline(jiffies, ATA_EH_PRERESET_TIMEOUT)); 2313 ATA_EH_PRERESET_TIMEOUT);
2314
2315 if (slave) {
2316 sehc->i.action &= ~ATA_EH_RESET;
2317 sehc->i.action |= ehc->i.action;
2318 }
2319
2320 rc = prereset(link, deadline);
2321
2322 /* If present, do prereset on slave link too. Reset
2323 * is skipped iff both master and slave links report
2324 * -ENOENT or clear ATA_EH_RESET.
2325 */
2326 if (slave && (rc == 0 || rc == -ENOENT)) {
2327 int tmp;
2328
2329 tmp = prereset(slave, deadline);
2330 if (tmp != -ENOENT)
2331 rc = tmp;
2332
2333 ehc->i.action |= sehc->i.action;
2334 }
2335
2257 if (rc) { 2336 if (rc) {
2258 if (rc == -ENOENT) { 2337 if (rc == -ENOENT) {
2259 ata_link_printk(link, KERN_DEBUG, 2338 ata_link_printk(link, KERN_DEBUG,
@@ -2302,25 +2381,51 @@ int ata_eh_reset(struct ata_link *link, int classify,
2302 else 2381 else
2303 ehc->i.flags |= ATA_EHI_DID_SOFTRESET; 2382 ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
2304 2383
2305 rc = ata_do_reset(link, reset, classes, deadline); 2384 rc = ata_do_reset(link, reset, classes, deadline, true);
2306 if (rc && rc != -EAGAIN) 2385 if (rc && rc != -EAGAIN) {
2386 failed_link = link;
2307 goto fail; 2387 goto fail;
2388 }
2389
2390 /* hardreset slave link if existent */
2391 if (slave && reset == hardreset) {
2392 int tmp;
2393
2394 if (verbose)
2395 ata_link_printk(slave, KERN_INFO,
2396 "hard resetting link\n");
2308 2397
2398 ata_eh_about_to_do(slave, NULL, ATA_EH_RESET);
2399 tmp = ata_do_reset(slave, reset, classes, deadline,
2400 false);
2401 switch (tmp) {
2402 case -EAGAIN:
2403 rc = -EAGAIN;
2404 case 0:
2405 break;
2406 default:
2407 failed_link = slave;
2408 rc = tmp;
2409 goto fail;
2410 }
2411 }
2412
2413 /* perform follow-up SRST if necessary */
2309 if (reset == hardreset && 2414 if (reset == hardreset &&
2310 ata_eh_followup_srst_needed(link, rc, classes)) { 2415 ata_eh_followup_srst_needed(link, rc, classes)) {
2311 /* okay, let's do follow-up softreset */
2312 reset = softreset; 2416 reset = softreset;
2313 2417
2314 if (!reset) { 2418 if (!reset) {
2315 ata_link_printk(link, KERN_ERR, 2419 ata_link_printk(link, KERN_ERR,
2316 "follow-up softreset required " 2420 "follow-up softreset required "
2317 "but no softreset avaliable\n"); 2421 "but no softreset avaliable\n");
2422 failed_link = link;
2318 rc = -EINVAL; 2423 rc = -EINVAL;
2319 goto fail; 2424 goto fail;
2320 } 2425 }
2321 2426
2322 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); 2427 ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
2323 rc = ata_do_reset(link, reset, classes, deadline); 2428 rc = ata_do_reset(link, reset, classes, deadline, true);
2324 } 2429 }
2325 } else { 2430 } else {
2326 if (verbose) 2431 if (verbose)
@@ -2341,7 +2446,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
2341 dev->pio_mode = XFER_PIO_0; 2446 dev->pio_mode = XFER_PIO_0;
2342 dev->flags &= ~ATA_DFLAG_SLEEPING; 2447 dev->flags &= ~ATA_DFLAG_SLEEPING;
2343 2448
2344 if (ata_link_offline(link)) 2449 if (ata_phys_link_offline(ata_dev_phys_link(dev)))
2345 continue; 2450 continue;
2346 2451
2347 /* apply class override */ 2452 /* apply class override */
@@ -2354,6 +2459,8 @@ int ata_eh_reset(struct ata_link *link, int classify,
2354 /* record current link speed */ 2459 /* record current link speed */
2355 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0) 2460 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
2356 link->sata_spd = (sstatus >> 4) & 0xf; 2461 link->sata_spd = (sstatus >> 4) & 0xf;
2462 if (slave && sata_scr_read(slave, SCR_STATUS, &sstatus) == 0)
2463 slave->sata_spd = (sstatus >> 4) & 0xf;
2357 2464
2358 /* thaw the port */ 2465 /* thaw the port */
2359 if (ata_is_host_link(link)) 2466 if (ata_is_host_link(link))
@@ -2366,12 +2473,17 @@ int ata_eh_reset(struct ata_link *link, int classify,
2366 * reset and here. This race is mediated by cross checking 2473 * reset and here. This race is mediated by cross checking
2367 * link onlineness and classification result later. 2474 * link onlineness and classification result later.
2368 */ 2475 */
2369 if (postreset) 2476 if (postreset) {
2370 postreset(link, classes); 2477 postreset(link, classes);
2478 if (slave)
2479 postreset(slave, classes);
2480 }
2371 2481
2372 /* clear cached SError */ 2482 /* clear cached SError */
2373 spin_lock_irqsave(link->ap->lock, flags); 2483 spin_lock_irqsave(link->ap->lock, flags);
2374 link->eh_info.serror = 0; 2484 link->eh_info.serror = 0;
2485 if (slave)
2486 slave->eh_info.serror = 0;
2375 spin_unlock_irqrestore(link->ap->lock, flags); 2487 spin_unlock_irqrestore(link->ap->lock, flags);
2376 2488
2377 /* Make sure onlineness and classification result correspond. 2489 /* Make sure onlineness and classification result correspond.
@@ -2381,19 +2493,21 @@ int ata_eh_reset(struct ata_link *link, int classify,
2381 * link onlineness and classification result, those conditions 2493 * link onlineness and classification result, those conditions
2382 * can be reliably detected and retried. 2494 * can be reliably detected and retried.
2383 */ 2495 */
2384 nr_known = 0; 2496 nr_unknown = 0;
2385 ata_link_for_each_dev(dev, link) { 2497 ata_link_for_each_dev(dev, link) {
2386 /* convert all ATA_DEV_UNKNOWN to ATA_DEV_NONE */ 2498 /* convert all ATA_DEV_UNKNOWN to ATA_DEV_NONE */
2387 if (classes[dev->devno] == ATA_DEV_UNKNOWN) 2499 if (classes[dev->devno] == ATA_DEV_UNKNOWN) {
2388 classes[dev->devno] = ATA_DEV_NONE; 2500 classes[dev->devno] = ATA_DEV_NONE;
2389 else 2501 if (ata_phys_link_online(ata_dev_phys_link(dev)))
2390 nr_known++; 2502 nr_unknown++;
2503 }
2391 } 2504 }
2392 2505
2393 if (classify && !nr_known && ata_link_online(link)) { 2506 if (classify && nr_unknown) {
2394 if (try < max_tries) { 2507 if (try < max_tries) {
2395 ata_link_printk(link, KERN_WARNING, "link online but " 2508 ata_link_printk(link, KERN_WARNING, "link online but "
2396 "device misclassified, retrying\n"); 2509 "device misclassified, retrying\n");
2510 failed_link = link;
2397 rc = -EAGAIN; 2511 rc = -EAGAIN;
2398 goto fail; 2512 goto fail;
2399 } 2513 }
@@ -2404,6 +2518,8 @@ int ata_eh_reset(struct ata_link *link, int classify,
2404 2518
2405 /* reset successful, schedule revalidation */ 2519 /* reset successful, schedule revalidation */
2406 ata_eh_done(link, NULL, ATA_EH_RESET); 2520 ata_eh_done(link, NULL, ATA_EH_RESET);
2521 if (slave)
2522 ata_eh_done(slave, NULL, ATA_EH_RESET);
2407 ehc->last_reset = jiffies; 2523 ehc->last_reset = jiffies;
2408 ehc->i.action |= ATA_EH_REVALIDATE; 2524 ehc->i.action |= ATA_EH_REVALIDATE;
2409 2525
@@ -2411,6 +2527,8 @@ int ata_eh_reset(struct ata_link *link, int classify,
2411 out: 2527 out:
2412 /* clear hotplug flag */ 2528 /* clear hotplug flag */
2413 ehc->i.flags &= ~ATA_EHI_HOTPLUGGED; 2529 ehc->i.flags &= ~ATA_EHI_HOTPLUGGED;
2530 if (slave)
2531 sehc->i.flags &= ~ATA_EHI_HOTPLUGGED;
2414 2532
2415 spin_lock_irqsave(ap->lock, flags); 2533 spin_lock_irqsave(ap->lock, flags);
2416 ap->pflags &= ~ATA_PFLAG_RESETTING; 2534 ap->pflags &= ~ATA_PFLAG_RESETTING;
@@ -2431,7 +2549,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
2431 if (time_before(now, deadline)) { 2549 if (time_before(now, deadline)) {
2432 unsigned long delta = deadline - now; 2550 unsigned long delta = deadline - now;
2433 2551
2434 ata_link_printk(link, KERN_WARNING, 2552 ata_link_printk(failed_link, KERN_WARNING,
2435 "reset failed (errno=%d), retrying in %u secs\n", 2553 "reset failed (errno=%d), retrying in %u secs\n",
2436 rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000)); 2554 rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000));
2437 2555
@@ -2439,13 +2557,92 @@ int ata_eh_reset(struct ata_link *link, int classify,
2439 delta = schedule_timeout_uninterruptible(delta); 2557 delta = schedule_timeout_uninterruptible(delta);
2440 } 2558 }
2441 2559
2442 if (rc == -EPIPE || try == max_tries - 1) 2560 if (try == max_tries - 1) {
2443 sata_down_spd_limit(link); 2561 sata_down_spd_limit(link);
2562 if (slave)
2563 sata_down_spd_limit(slave);
2564 } else if (rc == -EPIPE)
2565 sata_down_spd_limit(failed_link);
2566
2444 if (hardreset) 2567 if (hardreset)
2445 reset = hardreset; 2568 reset = hardreset;
2446 goto retry; 2569 goto retry;
2447} 2570}
2448 2571
2572static inline void ata_eh_pull_park_action(struct ata_port *ap)
2573{
2574 struct ata_link *link;
2575 struct ata_device *dev;
2576 unsigned long flags;
2577
2578 /*
2579 * This function can be thought of as an extended version of
2580 * ata_eh_about_to_do() specially crafted to accommodate the
2581 * requirements of ATA_EH_PARK handling. Since the EH thread
2582 * does not leave the do {} while () loop in ata_eh_recover as
2583 * long as the timeout for a park request to *one* device on
2584 * the port has not expired, and since we still want to pick
2585 * up park requests to other devices on the same port or
2586 * timeout updates for the same device, we have to pull
2587 * ATA_EH_PARK actions from eh_info into eh_context.i
2588 * ourselves at the beginning of each pass over the loop.
2589 *
2590 * Additionally, all write accesses to &ap->park_req_pending
2591 * through INIT_COMPLETION() (see below) or complete_all()
2592 * (see ata_scsi_park_store()) are protected by the host lock.
2593 * As a result we have that park_req_pending.done is zero on
2594 * exit from this function, i.e. when ATA_EH_PARK actions for
2595 * *all* devices on port ap have been pulled into the
2596 * respective eh_context structs. If, and only if,
2597 * park_req_pending.done is non-zero by the time we reach
2598 * wait_for_completion_timeout(), another ATA_EH_PARK action
2599 * has been scheduled for at least one of the devices on port
2600 * ap and we have to cycle over the do {} while () loop in
2601 * ata_eh_recover() again.
2602 */
2603
2604 spin_lock_irqsave(ap->lock, flags);
2605 INIT_COMPLETION(ap->park_req_pending);
2606 ata_port_for_each_link(link, ap) {
2607 ata_link_for_each_dev(dev, link) {
2608 struct ata_eh_info *ehi = &link->eh_info;
2609
2610 link->eh_context.i.dev_action[dev->devno] |=
2611 ehi->dev_action[dev->devno] & ATA_EH_PARK;
2612 ata_eh_clear_action(link, dev, ehi, ATA_EH_PARK);
2613 }
2614 }
2615 spin_unlock_irqrestore(ap->lock, flags);
2616}
2617
2618static void ata_eh_park_issue_cmd(struct ata_device *dev, int park)
2619{
2620 struct ata_eh_context *ehc = &dev->link->eh_context;
2621 struct ata_taskfile tf;
2622 unsigned int err_mask;
2623
2624 ata_tf_init(dev, &tf);
2625 if (park) {
2626 ehc->unloaded_mask |= 1 << dev->devno;
2627 tf.command = ATA_CMD_IDLEIMMEDIATE;
2628 tf.feature = 0x44;
2629 tf.lbal = 0x4c;
2630 tf.lbam = 0x4e;
2631 tf.lbah = 0x55;
2632 } else {
2633 ehc->unloaded_mask &= ~(1 << dev->devno);
2634 tf.command = ATA_CMD_CHK_POWER;
2635 }
2636
2637 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
2638 tf.protocol |= ATA_PROT_NODATA;
2639 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
2640 if (park && (err_mask || tf.lbal != 0xc4)) {
2641 ata_dev_printk(dev, KERN_ERR, "head unload failed!\n");
2642 ehc->unloaded_mask &= ~(1 << dev->devno);
2643 }
2644}
2645
2449static int ata_eh_revalidate_and_attach(struct ata_link *link, 2646static int ata_eh_revalidate_and_attach(struct ata_link *link,
2450 struct ata_device **r_failed_dev) 2647 struct ata_device **r_failed_dev)
2451{ 2648{
@@ -2472,7 +2669,7 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
2472 if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) { 2669 if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) {
2473 WARN_ON(dev->class == ATA_DEV_PMP); 2670 WARN_ON(dev->class == ATA_DEV_PMP);
2474 2671
2475 if (ata_link_offline(link)) { 2672 if (ata_phys_link_offline(ata_dev_phys_link(dev))) {
2476 rc = -EIO; 2673 rc = -EIO;
2477 goto err; 2674 goto err;
2478 } 2675 }
@@ -2610,6 +2807,53 @@ int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
2610 return rc; 2807 return rc;
2611} 2808}
2612 2809
2810/**
2811 * atapi_eh_clear_ua - Clear ATAPI UNIT ATTENTION after reset
2812 * @dev: ATAPI device to clear UA for
2813 *
2814 * Resets and other operations can make an ATAPI device raise
2815 * UNIT ATTENTION which causes the next operation to fail. This
2816 * function clears UA.
2817 *
2818 * LOCKING:
2819 * EH context (may sleep).
2820 *
2821 * RETURNS:
2822 * 0 on success, -errno on failure.
2823 */
2824static int atapi_eh_clear_ua(struct ata_device *dev)
2825{
2826 int i;
2827
2828 for (i = 0; i < ATA_EH_UA_TRIES; i++) {
2829 u8 sense_buffer[SCSI_SENSE_BUFFERSIZE];
2830 u8 sense_key = 0;
2831 unsigned int err_mask;
2832
2833 err_mask = atapi_eh_tur(dev, &sense_key);
2834 if (err_mask != 0 && err_mask != AC_ERR_DEV) {
2835 ata_dev_printk(dev, KERN_WARNING, "TEST_UNIT_READY "
2836 "failed (err_mask=0x%x)\n", err_mask);
2837 return -EIO;
2838 }
2839
2840 if (!err_mask || sense_key != UNIT_ATTENTION)
2841 return 0;
2842
2843 err_mask = atapi_eh_request_sense(dev, sense_buffer, sense_key);
2844 if (err_mask) {
2845 ata_dev_printk(dev, KERN_WARNING, "failed to clear "
2846 "UNIT ATTENTION (err_mask=0x%x)\n", err_mask);
2847 return -EIO;
2848 }
2849 }
2850
2851 ata_dev_printk(dev, KERN_WARNING,
2852 "UNIT ATTENTION persists after %d tries\n", ATA_EH_UA_TRIES);
2853
2854 return 0;
2855}
2856
2613static int ata_link_nr_enabled(struct ata_link *link) 2857static int ata_link_nr_enabled(struct ata_link *link)
2614{ 2858{
2615 struct ata_device *dev; 2859 struct ata_device *dev;
@@ -2697,7 +2941,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
2697 /* This is the last chance, better to slow 2941 /* This is the last chance, better to slow
2698 * down than lose it. 2942 * down than lose it.
2699 */ 2943 */
2700 sata_down_spd_limit(dev->link); 2944 sata_down_spd_limit(ata_dev_phys_link(dev));
2701 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); 2945 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO);
2702 } 2946 }
2703 } 2947 }
@@ -2707,7 +2951,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
2707 ata_dev_disable(dev); 2951 ata_dev_disable(dev);
2708 2952
2709 /* detach if offline */ 2953 /* detach if offline */
2710 if (ata_link_offline(dev->link)) 2954 if (ata_phys_link_offline(ata_dev_phys_link(dev)))
2711 ata_eh_detach_dev(dev); 2955 ata_eh_detach_dev(dev);
2712 2956
2713 /* schedule probe if necessary */ 2957 /* schedule probe if necessary */
@@ -2755,7 +2999,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2755 struct ata_device *dev; 2999 struct ata_device *dev;
2756 int nr_failed_devs; 3000 int nr_failed_devs;
2757 int rc; 3001 int rc;
2758 unsigned long flags; 3002 unsigned long flags, deadline;
2759 3003
2760 DPRINTK("ENTER\n"); 3004 DPRINTK("ENTER\n");
2761 3005
@@ -2829,6 +3073,56 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2829 } 3073 }
2830 } 3074 }
2831 3075
3076 do {
3077 unsigned long now;
3078
3079 /*
3080 * clears ATA_EH_PARK in eh_info and resets
3081 * ap->park_req_pending
3082 */
3083 ata_eh_pull_park_action(ap);
3084
3085 deadline = jiffies;
3086 ata_port_for_each_link(link, ap) {
3087 ata_link_for_each_dev(dev, link) {
3088 struct ata_eh_context *ehc = &link->eh_context;
3089 unsigned long tmp;
3090
3091 if (dev->class != ATA_DEV_ATA)
3092 continue;
3093 if (!(ehc->i.dev_action[dev->devno] &
3094 ATA_EH_PARK))
3095 continue;
3096 tmp = dev->unpark_deadline;
3097 if (time_before(deadline, tmp))
3098 deadline = tmp;
3099 else if (time_before_eq(tmp, jiffies))
3100 continue;
3101 if (ehc->unloaded_mask & (1 << dev->devno))
3102 continue;
3103
3104 ata_eh_park_issue_cmd(dev, 1);
3105 }
3106 }
3107
3108 now = jiffies;
3109 if (time_before_eq(deadline, now))
3110 break;
3111
3112 deadline = wait_for_completion_timeout(&ap->park_req_pending,
3113 deadline - now);
3114 } while (deadline);
3115 ata_port_for_each_link(link, ap) {
3116 ata_link_for_each_dev(dev, link) {
3117 if (!(link->eh_context.unloaded_mask &
3118 (1 << dev->devno)))
3119 continue;
3120
3121 ata_eh_park_issue_cmd(dev, 0);
3122 ata_eh_done(link, dev, ATA_EH_PARK);
3123 }
3124 }
3125
2832 /* the rest */ 3126 /* the rest */
2833 ata_port_for_each_link(link, ap) { 3127 ata_port_for_each_link(link, ap) {
2834 struct ata_eh_context *ehc = &link->eh_context; 3128 struct ata_eh_context *ehc = &link->eh_context;
@@ -2852,6 +3146,20 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2852 ehc->i.flags &= ~ATA_EHI_SETMODE; 3146 ehc->i.flags &= ~ATA_EHI_SETMODE;
2853 } 3147 }
2854 3148
3149 /* If reset has been issued, clear UA to avoid
3150 * disrupting the current users of the device.
3151 */
3152 if (ehc->i.flags & ATA_EHI_DID_RESET) {
3153 ata_link_for_each_dev(dev, link) {
3154 if (dev->class != ATA_DEV_ATAPI)
3155 continue;
3156 rc = atapi_eh_clear_ua(dev);
3157 if (rc)
3158 goto dev_fail;
3159 }
3160 }
3161
3162 /* configure link power saving */
2855 if (ehc->i.action & ATA_EH_LPM) 3163 if (ehc->i.action & ATA_EH_LPM)
2856 ata_link_for_each_dev(dev, link) 3164 ata_link_for_each_dev(dev, link)
2857 ata_dev_enable_pm(dev, ap->pm_policy); 3165 ata_dev_enable_pm(dev, ap->pm_policy);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index b9d3ba423cb2..fccd5e496c62 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -183,6 +183,105 @@ DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
183 ata_scsi_lpm_show, ata_scsi_lpm_put); 183 ata_scsi_lpm_show, ata_scsi_lpm_put);
184EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); 184EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy);
185 185
186static ssize_t ata_scsi_park_show(struct device *device,
187 struct device_attribute *attr, char *buf)
188{
189 struct scsi_device *sdev = to_scsi_device(device);
190 struct ata_port *ap;
191 struct ata_link *link;
192 struct ata_device *dev;
193 unsigned long flags;
194 unsigned int uninitialized_var(msecs);
195 int rc = 0;
196
197 ap = ata_shost_to_port(sdev->host);
198
199 spin_lock_irqsave(ap->lock, flags);
200 dev = ata_scsi_find_dev(ap, sdev);
201 if (!dev) {
202 rc = -ENODEV;
203 goto unlock;
204 }
205 if (dev->flags & ATA_DFLAG_NO_UNLOAD) {
206 rc = -EOPNOTSUPP;
207 goto unlock;
208 }
209
210 link = dev->link;
211 if (ap->pflags & ATA_PFLAG_EH_IN_PROGRESS &&
212 link->eh_context.unloaded_mask & (1 << dev->devno) &&
213 time_after(dev->unpark_deadline, jiffies))
214 msecs = jiffies_to_msecs(dev->unpark_deadline - jiffies);
215 else
216 msecs = 0;
217
218unlock:
219 spin_unlock_irq(ap->lock);
220
221 return rc ? rc : snprintf(buf, 20, "%u\n", msecs);
222}
223
224static ssize_t ata_scsi_park_store(struct device *device,
225 struct device_attribute *attr,
226 const char *buf, size_t len)
227{
228 struct scsi_device *sdev = to_scsi_device(device);
229 struct ata_port *ap;
230 struct ata_device *dev;
231 long int input;
232 unsigned long flags;
233 int rc;
234
235 rc = strict_strtol(buf, 10, &input);
236 if (rc || input < -2)
237 return -EINVAL;
238 if (input > ATA_TMOUT_MAX_PARK) {
239 rc = -EOVERFLOW;
240 input = ATA_TMOUT_MAX_PARK;
241 }
242
243 ap = ata_shost_to_port(sdev->host);
244
245 spin_lock_irqsave(ap->lock, flags);
246 dev = ata_scsi_find_dev(ap, sdev);
247 if (unlikely(!dev)) {
248 rc = -ENODEV;
249 goto unlock;
250 }
251 if (dev->class != ATA_DEV_ATA) {
252 rc = -EOPNOTSUPP;
253 goto unlock;
254 }
255
256 if (input >= 0) {
257 if (dev->flags & ATA_DFLAG_NO_UNLOAD) {
258 rc = -EOPNOTSUPP;
259 goto unlock;
260 }
261
262 dev->unpark_deadline = ata_deadline(jiffies, input);
263 dev->link->eh_info.dev_action[dev->devno] |= ATA_EH_PARK;
264 ata_port_schedule_eh(ap);
265 complete(&ap->park_req_pending);
266 } else {
267 switch (input) {
268 case -1:
269 dev->flags &= ~ATA_DFLAG_NO_UNLOAD;
270 break;
271 case -2:
272 dev->flags |= ATA_DFLAG_NO_UNLOAD;
273 break;
274 }
275 }
276unlock:
277 spin_unlock_irqrestore(ap->lock, flags);
278
279 return rc ? rc : len;
280}
281DEVICE_ATTR(unload_heads, S_IRUGO | S_IWUSR,
282 ata_scsi_park_show, ata_scsi_park_store);
283EXPORT_SYMBOL_GPL(dev_attr_unload_heads);
284
186static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) 285static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
187{ 286{
188 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 287 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
@@ -269,6 +368,12 @@ DEVICE_ATTR(sw_activity, S_IWUGO | S_IRUGO, ata_scsi_activity_show,
269 ata_scsi_activity_store); 368 ata_scsi_activity_store);
270EXPORT_SYMBOL_GPL(dev_attr_sw_activity); 369EXPORT_SYMBOL_GPL(dev_attr_sw_activity);
271 370
371struct device_attribute *ata_common_sdev_attrs[] = {
372 &dev_attr_unload_heads,
373 NULL
374};
375EXPORT_SYMBOL_GPL(ata_common_sdev_attrs);
376
272static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, 377static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
273 void (*done)(struct scsi_cmnd *)) 378 void (*done)(struct scsi_cmnd *))
274{ 379{
@@ -954,6 +1059,9 @@ static int atapi_drain_needed(struct request *rq)
954static int ata_scsi_dev_config(struct scsi_device *sdev, 1059static int ata_scsi_dev_config(struct scsi_device *sdev,
955 struct ata_device *dev) 1060 struct ata_device *dev)
956{ 1061{
1062 if (!ata_id_has_unload(dev->id))
1063 dev->flags |= ATA_DFLAG_NO_UNLOAD;
1064
957 /* configure max sectors */ 1065 /* configure max sectors */
958 blk_queue_max_sectors(sdev->request_queue, dev->max_sectors); 1066 blk_queue_max_sectors(sdev->request_queue, dev->max_sectors);
959 1067
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index ade5c75b6144..e96de96e3020 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -70,6 +70,7 @@ extern int atapi_passthru16;
70extern int libata_fua; 70extern int libata_fua;
71extern int libata_noacpi; 71extern int libata_noacpi;
72extern int libata_allow_tpm; 72extern int libata_allow_tpm;
73extern struct ata_link *ata_dev_phys_link(struct ata_device *dev);
73extern void ata_force_cbl(struct ata_port *ap); 74extern void ata_force_cbl(struct ata_port *ap);
74extern u64 ata_tf_to_lba(const struct ata_taskfile *tf); 75extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
75extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf); 76extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
@@ -107,6 +108,8 @@ extern void ata_qc_issue(struct ata_queued_cmd *qc);
107extern void __ata_qc_complete(struct ata_queued_cmd *qc); 108extern void __ata_qc_complete(struct ata_queued_cmd *qc);
108extern int atapi_check_dma(struct ata_queued_cmd *qc); 109extern int atapi_check_dma(struct ata_queued_cmd *qc);
109extern void swap_buf_le16(u16 *buf, unsigned int buf_words); 110extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
111extern bool ata_phys_link_online(struct ata_link *link);
112extern bool ata_phys_link_offline(struct ata_link *link);
110extern void ata_dev_init(struct ata_device *dev); 113extern void ata_dev_init(struct ata_device *dev);
111extern void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp); 114extern void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp);
112extern int sata_link_init_spd(struct ata_link *link); 115extern int sata_link_init_spd(struct ata_link *link);
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index d3932901a3b3..1266924c11f9 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -1632,6 +1632,8 @@ static int __devinit bfin_atapi_probe(struct platform_device *pdev)
1632 return -ENODEV; 1632 return -ENODEV;
1633 } 1633 }
1634 1634
1635 dev_set_drvdata(&pdev->dev, host);
1636
1635 return 0; 1637 return 0;
1636} 1638}
1637 1639
@@ -1648,6 +1650,7 @@ static int __devexit bfin_atapi_remove(struct platform_device *pdev)
1648 struct ata_host *host = dev_get_drvdata(dev); 1650 struct ata_host *host = dev_get_drvdata(dev);
1649 1651
1650 ata_host_detach(host); 1652 ata_host_detach(host);
1653 dev_set_drvdata(&pdev->dev, NULL);
1651 1654
1652 peripheral_free_list(atapi_io_port); 1655 peripheral_free_list(atapi_io_port);
1653 1656
@@ -1655,27 +1658,44 @@ static int __devexit bfin_atapi_remove(struct platform_device *pdev)
1655} 1658}
1656 1659
1657#ifdef CONFIG_PM 1660#ifdef CONFIG_PM
1658int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state) 1661static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)
1659{ 1662{
1660 return 0; 1663 struct ata_host *host = dev_get_drvdata(&pdev->dev);
1664 if (host)
1665 return ata_host_suspend(host, state);
1666 else
1667 return 0;
1661} 1668}
1662 1669
1663int bfin_atapi_resume(struct platform_device *pdev) 1670static int bfin_atapi_resume(struct platform_device *pdev)
1664{ 1671{
1672 struct ata_host *host = dev_get_drvdata(&pdev->dev);
1673 int ret;
1674
1675 if (host) {
1676 ret = bfin_reset_controller(host);
1677 if (ret) {
1678 printk(KERN_ERR DRV_NAME ": Error during HW init\n");
1679 return ret;
1680 }
1681 ata_host_resume(host);
1682 }
1683
1665 return 0; 1684 return 0;
1666} 1685}
1686#else
1687#define bfin_atapi_suspend NULL
1688#define bfin_atapi_resume NULL
1667#endif 1689#endif
1668 1690
1669static struct platform_driver bfin_atapi_driver = { 1691static struct platform_driver bfin_atapi_driver = {
1670 .probe = bfin_atapi_probe, 1692 .probe = bfin_atapi_probe,
1671 .remove = __devexit_p(bfin_atapi_remove), 1693 .remove = __devexit_p(bfin_atapi_remove),
1694 .suspend = bfin_atapi_suspend,
1695 .resume = bfin_atapi_resume,
1672 .driver = { 1696 .driver = {
1673 .name = DRV_NAME, 1697 .name = DRV_NAME,
1674 .owner = THIS_MODULE, 1698 .owner = THIS_MODULE,
1675#ifdef CONFIG_PM
1676 .suspend = bfin_atapi_suspend,
1677 .resume = bfin_atapi_resume,
1678#endif
1679 }, 1699 },
1680}; 1700};
1681 1701
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index e970b227fbce..a598bb36aafc 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -230,7 +230,7 @@ static u8 sil680_init_chip(struct pci_dev *pdev, int *try_mmio)
230 tmpbyte & 1, tmpbyte & 0x30); 230 tmpbyte & 1, tmpbyte & 0x30);
231 231
232 *try_mmio = 0; 232 *try_mmio = 0;
233#ifdef CONFIG_PPC_MERGE 233#ifdef CONFIG_PPC
234 if (machine_is(cell)) 234 if (machine_is(cell))
235 *try_mmio = (tmpbyte & 1) || pci_resource_start(pdev, 5); 235 *try_mmio = (tmpbyte & 1) || pci_resource_start(pdev, 5);
236#endif 236#endif
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 3924e7209a44..1a56db92ff7a 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -469,10 +469,10 @@ static bool sata_fsl_qc_fill_rtf(struct ata_queued_cmd *qc)
469 return true; 469 return true;
470} 470}
471 471
472static int sata_fsl_scr_write(struct ata_port *ap, unsigned int sc_reg_in, 472static int sata_fsl_scr_write(struct ata_link *link,
473 u32 val) 473 unsigned int sc_reg_in, u32 val)
474{ 474{
475 struct sata_fsl_host_priv *host_priv = ap->host->private_data; 475 struct sata_fsl_host_priv *host_priv = link->ap->host->private_data;
476 void __iomem *ssr_base = host_priv->ssr_base; 476 void __iomem *ssr_base = host_priv->ssr_base;
477 unsigned int sc_reg; 477 unsigned int sc_reg;
478 478
@@ -493,10 +493,10 @@ static int sata_fsl_scr_write(struct ata_port *ap, unsigned int sc_reg_in,
493 return 0; 493 return 0;
494} 494}
495 495
496static int sata_fsl_scr_read(struct ata_port *ap, unsigned int sc_reg_in, 496static int sata_fsl_scr_read(struct ata_link *link,
497 u32 *val) 497 unsigned int sc_reg_in, u32 *val)
498{ 498{
499 struct sata_fsl_host_priv *host_priv = ap->host->private_data; 499 struct sata_fsl_host_priv *host_priv = link->ap->host->private_data;
500 void __iomem *ssr_base = host_priv->ssr_base; 500 void __iomem *ssr_base = host_priv->ssr_base;
501 unsigned int sc_reg; 501 unsigned int sc_reg;
502 502
@@ -645,12 +645,12 @@ static int sata_fsl_port_start(struct ata_port *ap)
645 * Workaround for 8315DS board 3gbps link-up issue, 645 * Workaround for 8315DS board 3gbps link-up issue,
646 * currently limit SATA port to GEN1 speed 646 * currently limit SATA port to GEN1 speed
647 */ 647 */
648 sata_fsl_scr_read(ap, SCR_CONTROL, &temp); 648 sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp);
649 temp &= ~(0xF << 4); 649 temp &= ~(0xF << 4);
650 temp |= (0x1 << 4); 650 temp |= (0x1 << 4);
651 sata_fsl_scr_write(ap, SCR_CONTROL, temp); 651 sata_fsl_scr_write(&ap->link, SCR_CONTROL, temp);
652 652
653 sata_fsl_scr_read(ap, SCR_CONTROL, &temp); 653 sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp);
654 dev_printk(KERN_WARNING, dev, "scr_control, speed limited to %x\n", 654 dev_printk(KERN_WARNING, dev, "scr_control, speed limited to %x\n",
655 temp); 655 temp);
656#endif 656#endif
@@ -868,7 +868,7 @@ issue_srst:
868 ioread32(CQ + hcr_base), 868 ioread32(CQ + hcr_base),
869 ioread32(CA + hcr_base), ioread32(CC + hcr_base)); 869 ioread32(CA + hcr_base), ioread32(CC + hcr_base));
870 870
871 sata_fsl_scr_read(ap, SCR_ERROR, &Serror); 871 sata_fsl_scr_read(&ap->link, SCR_ERROR, &Serror);
872 872
873 DPRINTK("HStatus = 0x%x\n", ioread32(hcr_base + HSTATUS)); 873 DPRINTK("HStatus = 0x%x\n", ioread32(hcr_base + HSTATUS));
874 DPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL)); 874 DPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL));
@@ -972,9 +972,9 @@ static void sata_fsl_error_intr(struct ata_port *ap)
972 * Handle & Clear SError 972 * Handle & Clear SError
973 */ 973 */
974 974
975 sata_fsl_scr_read(ap, SCR_ERROR, &SError); 975 sata_fsl_scr_read(&ap->link, SCR_ERROR, &SError);
976 if (unlikely(SError & 0xFFFF0000)) { 976 if (unlikely(SError & 0xFFFF0000)) {
977 sata_fsl_scr_write(ap, SCR_ERROR, SError); 977 sata_fsl_scr_write(&ap->link, SCR_ERROR, SError);
978 } 978 }
979 979
980 DPRINTK("error_intr,hStat=0x%x,CE=0x%x,DE =0x%x,SErr=0x%x\n", 980 DPRINTK("error_intr,hStat=0x%x,CE=0x%x,DE =0x%x,SErr=0x%x\n",
@@ -1091,7 +1091,7 @@ static void sata_fsl_host_intr(struct ata_port *ap)
1091 1091
1092 hstatus = ioread32(hcr_base + HSTATUS); 1092 hstatus = ioread32(hcr_base + HSTATUS);
1093 1093
1094 sata_fsl_scr_read(ap, SCR_ERROR, &SError); 1094 sata_fsl_scr_read(&ap->link, SCR_ERROR, &SError);
1095 1095
1096 if (unlikely(SError & 0xFFFF0000)) { 1096 if (unlikely(SError & 0xFFFF0000)) {
1097 DPRINTK("serror @host_intr : 0x%x\n", SError); 1097 DPRINTK("serror @host_intr : 0x%x\n", SError);
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index 5032c32fa505..fbbd87c96f10 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -269,9 +269,9 @@ static void inic_reset_port(void __iomem *port_base)
269 writeb(0xff, port_base + PORT_IRQ_STAT); 269 writeb(0xff, port_base + PORT_IRQ_STAT);
270} 270}
271 271
272static int inic_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val) 272static int inic_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val)
273{ 273{
274 void __iomem *scr_addr = inic_port_base(ap) + PORT_SCR; 274 void __iomem *scr_addr = inic_port_base(link->ap) + PORT_SCR;
275 void __iomem *addr; 275 void __iomem *addr;
276 276
277 if (unlikely(sc_reg >= ARRAY_SIZE(scr_map))) 277 if (unlikely(sc_reg >= ARRAY_SIZE(scr_map)))
@@ -286,9 +286,9 @@ static int inic_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val)
286 return 0; 286 return 0;
287} 287}
288 288
289static int inic_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) 289static int inic_scr_write(struct ata_link *link, unsigned sc_reg, u32 val)
290{ 290{
291 void __iomem *scr_addr = inic_port_base(ap) + PORT_SCR; 291 void __iomem *scr_addr = inic_port_base(link->ap) + PORT_SCR;
292 292
293 if (unlikely(sc_reg >= ARRAY_SIZE(scr_map))) 293 if (unlikely(sc_reg >= ARRAY_SIZE(scr_map)))
294 return -EINVAL; 294 return -EINVAL;
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index c815f8ecf6e6..2b24ae58b52e 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -493,10 +493,10 @@ struct mv_hw_ops {
493 void (*reset_bus)(struct ata_host *host, void __iomem *mmio); 493 void (*reset_bus)(struct ata_host *host, void __iomem *mmio);
494}; 494};
495 495
496static int mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val); 496static int mv_scr_read(struct ata_link *link, unsigned int sc_reg_in, u32 *val);
497static int mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); 497static int mv_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val);
498static int mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val); 498static int mv5_scr_read(struct ata_link *link, unsigned int sc_reg_in, u32 *val);
499static int mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); 499static int mv5_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val);
500static int mv_port_start(struct ata_port *ap); 500static int mv_port_start(struct ata_port *ap);
501static void mv_port_stop(struct ata_port *ap); 501static void mv_port_stop(struct ata_port *ap);
502static int mv_qc_defer(struct ata_queued_cmd *qc); 502static int mv_qc_defer(struct ata_queued_cmd *qc);
@@ -1070,23 +1070,23 @@ static unsigned int mv_scr_offset(unsigned int sc_reg_in)
1070 return ofs; 1070 return ofs;
1071} 1071}
1072 1072
1073static int mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val) 1073static int mv_scr_read(struct ata_link *link, unsigned int sc_reg_in, u32 *val)
1074{ 1074{
1075 unsigned int ofs = mv_scr_offset(sc_reg_in); 1075 unsigned int ofs = mv_scr_offset(sc_reg_in);
1076 1076
1077 if (ofs != 0xffffffffU) { 1077 if (ofs != 0xffffffffU) {
1078 *val = readl(mv_ap_base(ap) + ofs); 1078 *val = readl(mv_ap_base(link->ap) + ofs);
1079 return 0; 1079 return 0;
1080 } else 1080 } else
1081 return -EINVAL; 1081 return -EINVAL;
1082} 1082}
1083 1083
1084static int mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) 1084static int mv_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val)
1085{ 1085{
1086 unsigned int ofs = mv_scr_offset(sc_reg_in); 1086 unsigned int ofs = mv_scr_offset(sc_reg_in);
1087 1087
1088 if (ofs != 0xffffffffU) { 1088 if (ofs != 0xffffffffU) {
1089 writelfl(val, mv_ap_base(ap) + ofs); 1089 writelfl(val, mv_ap_base(link->ap) + ofs);
1090 return 0; 1090 return 0;
1091 } else 1091 } else
1092 return -EINVAL; 1092 return -EINVAL;
@@ -2251,11 +2251,11 @@ static unsigned int mv5_scr_offset(unsigned int sc_reg_in)
2251 return ofs; 2251 return ofs;
2252} 2252}
2253 2253
2254static int mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val) 2254static int mv5_scr_read(struct ata_link *link, unsigned int sc_reg_in, u32 *val)
2255{ 2255{
2256 struct mv_host_priv *hpriv = ap->host->private_data; 2256 struct mv_host_priv *hpriv = link->ap->host->private_data;
2257 void __iomem *mmio = hpriv->base; 2257 void __iomem *mmio = hpriv->base;
2258 void __iomem *addr = mv5_phy_base(mmio, ap->port_no); 2258 void __iomem *addr = mv5_phy_base(mmio, link->ap->port_no);
2259 unsigned int ofs = mv5_scr_offset(sc_reg_in); 2259 unsigned int ofs = mv5_scr_offset(sc_reg_in);
2260 2260
2261 if (ofs != 0xffffffffU) { 2261 if (ofs != 0xffffffffU) {
@@ -2265,11 +2265,11 @@ static int mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val)
2265 return -EINVAL; 2265 return -EINVAL;
2266} 2266}
2267 2267
2268static int mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) 2268static int mv5_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val)
2269{ 2269{
2270 struct mv_host_priv *hpriv = ap->host->private_data; 2270 struct mv_host_priv *hpriv = link->ap->host->private_data;
2271 void __iomem *mmio = hpriv->base; 2271 void __iomem *mmio = hpriv->base;
2272 void __iomem *addr = mv5_phy_base(mmio, ap->port_no); 2272 void __iomem *addr = mv5_phy_base(mmio, link->ap->port_no);
2273 unsigned int ofs = mv5_scr_offset(sc_reg_in); 2273 unsigned int ofs = mv5_scr_offset(sc_reg_in);
2274 2274
2275 if (ofs != 0xffffffffU) { 2275 if (ofs != 0xffffffffU) {
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 14601dc05e41..fae3841de0d8 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -302,8 +302,8 @@ static void nv_ck804_host_stop(struct ata_host *host);
302static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance); 302static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance);
303static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance); 303static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance);
304static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance); 304static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance);
305static int nv_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 305static int nv_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
306static int nv_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 306static int nv_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
307 307
308static void nv_nf2_freeze(struct ata_port *ap); 308static void nv_nf2_freeze(struct ata_port *ap);
309static void nv_nf2_thaw(struct ata_port *ap); 309static void nv_nf2_thaw(struct ata_port *ap);
@@ -1511,21 +1511,21 @@ static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance)
1511 return ret; 1511 return ret;
1512} 1512}
1513 1513
1514static int nv_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 1514static int nv_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
1515{ 1515{
1516 if (sc_reg > SCR_CONTROL) 1516 if (sc_reg > SCR_CONTROL)
1517 return -EINVAL; 1517 return -EINVAL;
1518 1518
1519 *val = ioread32(ap->ioaddr.scr_addr + (sc_reg * 4)); 1519 *val = ioread32(link->ap->ioaddr.scr_addr + (sc_reg * 4));
1520 return 0; 1520 return 0;
1521} 1521}
1522 1522
1523static int nv_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 1523static int nv_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
1524{ 1524{
1525 if (sc_reg > SCR_CONTROL) 1525 if (sc_reg > SCR_CONTROL)
1526 return -EINVAL; 1526 return -EINVAL;
1527 1527
1528 iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)); 1528 iowrite32(val, link->ap->ioaddr.scr_addr + (sc_reg * 4));
1529 return 0; 1529 return 0;
1530} 1530}
1531 1531
@@ -2218,9 +2218,9 @@ static void nv_swncq_host_interrupt(struct ata_port *ap, u16 fis)
2218 if (!pp->qc_active) 2218 if (!pp->qc_active)
2219 return; 2219 return;
2220 2220
2221 if (ap->ops->scr_read(ap, SCR_ERROR, &serror)) 2221 if (ap->ops->scr_read(&ap->link, SCR_ERROR, &serror))
2222 return; 2222 return;
2223 ap->ops->scr_write(ap, SCR_ERROR, serror); 2223 ap->ops->scr_write(&ap->link, SCR_ERROR, serror);
2224 2224
2225 if (ata_stat & ATA_ERR) { 2225 if (ata_stat & ATA_ERR) {
2226 ata_ehi_clear_desc(ehi); 2226 ata_ehi_clear_desc(ehi);
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 030665ba76b7..750d8cdc00cd 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -137,8 +137,8 @@ struct pdc_port_priv {
137 dma_addr_t pkt_dma; 137 dma_addr_t pkt_dma;
138}; 138};
139 139
140static int pdc_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 140static int pdc_sata_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
141static int pdc_sata_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 141static int pdc_sata_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
142static int pdc_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 142static int pdc_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
143static int pdc_common_port_start(struct ata_port *ap); 143static int pdc_common_port_start(struct ata_port *ap);
144static int pdc_sata_port_start(struct ata_port *ap); 144static int pdc_sata_port_start(struct ata_port *ap);
@@ -386,19 +386,21 @@ static int pdc_sata_cable_detect(struct ata_port *ap)
386 return ATA_CBL_SATA; 386 return ATA_CBL_SATA;
387} 387}
388 388
389static int pdc_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 389static int pdc_sata_scr_read(struct ata_link *link,
390 unsigned int sc_reg, u32 *val)
390{ 391{
391 if (sc_reg > SCR_CONTROL) 392 if (sc_reg > SCR_CONTROL)
392 return -EINVAL; 393 return -EINVAL;
393 *val = readl(ap->ioaddr.scr_addr + (sc_reg * 4)); 394 *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 4));
394 return 0; 395 return 0;
395} 396}
396 397
397static int pdc_sata_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 398static int pdc_sata_scr_write(struct ata_link *link,
399 unsigned int sc_reg, u32 val)
398{ 400{
399 if (sc_reg > SCR_CONTROL) 401 if (sc_reg > SCR_CONTROL)
400 return -EINVAL; 402 return -EINVAL;
401 writel(val, ap->ioaddr.scr_addr + (sc_reg * 4)); 403 writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 4));
402 return 0; 404 return 0;
403} 405}
404 406
@@ -731,7 +733,7 @@ static void pdc_error_intr(struct ata_port *ap, struct ata_queued_cmd *qc,
731 if (sata_scr_valid(&ap->link)) { 733 if (sata_scr_valid(&ap->link)) {
732 u32 serror; 734 u32 serror;
733 735
734 pdc_sata_scr_read(ap, SCR_ERROR, &serror); 736 pdc_sata_scr_read(&ap->link, SCR_ERROR, &serror);
735 ehi->serror |= serror; 737 ehi->serror |= serror;
736 } 738 }
737 739
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c
index 1600107047cf..a000c86ac859 100644
--- a/drivers/ata/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -111,8 +111,8 @@ struct qs_port_priv {
111 qs_state_t state; 111 qs_state_t state;
112}; 112};
113 113
114static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 114static int qs_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
115static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 115static int qs_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
116static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 116static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
117static int qs_port_start(struct ata_port *ap); 117static int qs_port_start(struct ata_port *ap);
118static void qs_host_stop(struct ata_host *host); 118static void qs_host_stop(struct ata_host *host);
@@ -242,11 +242,11 @@ static int qs_prereset(struct ata_link *link, unsigned long deadline)
242 return ata_sff_prereset(link, deadline); 242 return ata_sff_prereset(link, deadline);
243} 243}
244 244
245static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 245static int qs_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
246{ 246{
247 if (sc_reg > SCR_CONTROL) 247 if (sc_reg > SCR_CONTROL)
248 return -EINVAL; 248 return -EINVAL;
249 *val = readl(ap->ioaddr.scr_addr + (sc_reg * 8)); 249 *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 8));
250 return 0; 250 return 0;
251} 251}
252 252
@@ -256,11 +256,11 @@ static void qs_error_handler(struct ata_port *ap)
256 ata_std_error_handler(ap); 256 ata_std_error_handler(ap);
257} 257}
258 258
259static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 259static int qs_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
260{ 260{
261 if (sc_reg > SCR_CONTROL) 261 if (sc_reg > SCR_CONTROL)
262 return -EINVAL; 262 return -EINVAL;
263 writel(val, ap->ioaddr.scr_addr + (sc_reg * 8)); 263 writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 8));
264 return 0; 264 return 0;
265} 265}
266 266
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 88bf4212590f..031d7b7dee34 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -115,8 +115,8 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
115static int sil_pci_device_resume(struct pci_dev *pdev); 115static int sil_pci_device_resume(struct pci_dev *pdev);
116#endif 116#endif
117static void sil_dev_config(struct ata_device *dev); 117static void sil_dev_config(struct ata_device *dev);
118static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 118static int sil_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
119static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 119static int sil_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
120static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed); 120static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed);
121static void sil_freeze(struct ata_port *ap); 121static void sil_freeze(struct ata_port *ap);
122static void sil_thaw(struct ata_port *ap); 122static void sil_thaw(struct ata_port *ap);
@@ -317,9 +317,9 @@ static inline void __iomem *sil_scr_addr(struct ata_port *ap,
317 return NULL; 317 return NULL;
318} 318}
319 319
320static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 320static int sil_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
321{ 321{
322 void __iomem *mmio = sil_scr_addr(ap, sc_reg); 322 void __iomem *mmio = sil_scr_addr(link->ap, sc_reg);
323 323
324 if (mmio) { 324 if (mmio) {
325 *val = readl(mmio); 325 *val = readl(mmio);
@@ -328,9 +328,9 @@ static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
328 return -EINVAL; 328 return -EINVAL;
329} 329}
330 330
331static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 331static int sil_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
332{ 332{
333 void __iomem *mmio = sil_scr_addr(ap, sc_reg); 333 void __iomem *mmio = sil_scr_addr(link->ap, sc_reg);
334 334
335 if (mmio) { 335 if (mmio) {
336 writel(val, mmio); 336 writel(val, mmio);
@@ -352,8 +352,8 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
352 * controllers continue to assert IRQ as long as 352 * controllers continue to assert IRQ as long as
353 * SError bits are pending. Clear SError immediately. 353 * SError bits are pending. Clear SError immediately.
354 */ 354 */
355 sil_scr_read(ap, SCR_ERROR, &serror); 355 sil_scr_read(&ap->link, SCR_ERROR, &serror);
356 sil_scr_write(ap, SCR_ERROR, serror); 356 sil_scr_write(&ap->link, SCR_ERROR, serror);
357 357
358 /* Sometimes spurious interrupts occur, double check 358 /* Sometimes spurious interrupts occur, double check
359 * it's PHYRDY CHG. 359 * it's PHYRDY CHG.
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 84ffcc26a74b..4621807a1a6a 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -340,8 +340,8 @@ struct sil24_port_priv {
340}; 340};
341 341
342static void sil24_dev_config(struct ata_device *dev); 342static void sil24_dev_config(struct ata_device *dev);
343static int sil24_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val); 343static int sil24_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val);
344static int sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); 344static int sil24_scr_write(struct ata_link *link, unsigned sc_reg, u32 val);
345static int sil24_qc_defer(struct ata_queued_cmd *qc); 345static int sil24_qc_defer(struct ata_queued_cmd *qc);
346static void sil24_qc_prep(struct ata_queued_cmd *qc); 346static void sil24_qc_prep(struct ata_queued_cmd *qc);
347static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc); 347static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc);
@@ -504,9 +504,9 @@ static int sil24_scr_map[] = {
504 [SCR_ACTIVE] = 3, 504 [SCR_ACTIVE] = 3,
505}; 505};
506 506
507static int sil24_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val) 507static int sil24_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val)
508{ 508{
509 void __iomem *scr_addr = sil24_port_base(ap) + PORT_SCONTROL; 509 void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL;
510 510
511 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { 511 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
512 void __iomem *addr; 512 void __iomem *addr;
@@ -517,9 +517,9 @@ static int sil24_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val)
517 return -EINVAL; 517 return -EINVAL;
518} 518}
519 519
520static int sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) 520static int sil24_scr_write(struct ata_link *link, unsigned sc_reg, u32 val)
521{ 521{
522 void __iomem *scr_addr = sil24_port_base(ap) + PORT_SCONTROL; 522 void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL;
523 523
524 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { 524 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
525 void __iomem *addr; 525 void __iomem *addr;
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index 1010b3069bd5..9c43b4e7c4a6 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -64,8 +64,8 @@ enum {
64}; 64};
65 65
66static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 66static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
67static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 67static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
68static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 68static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
69 69
70static const struct pci_device_id sis_pci_tbl[] = { 70static const struct pci_device_id sis_pci_tbl[] = {
71 { PCI_VDEVICE(SI, 0x0180), sis_180 }, /* SiS 964/180 */ 71 { PCI_VDEVICE(SI, 0x0180), sis_180 }, /* SiS 964/180 */
@@ -134,10 +134,11 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
134 return addr; 134 return addr;
135} 135}
136 136
137static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 137static u32 sis_scr_cfg_read(struct ata_link *link,
138 unsigned int sc_reg, u32 *val)
138{ 139{
139 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 140 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
140 unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); 141 unsigned int cfg_addr = get_scr_cfg_addr(link->ap, sc_reg);
141 u32 val2 = 0; 142 u32 val2 = 0;
142 u8 pmr; 143 u8 pmr;
143 144
@@ -158,10 +159,11 @@ static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
158 return 0; 159 return 0;
159} 160}
160 161
161static int sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 162static int sis_scr_cfg_write(struct ata_link *link,
163 unsigned int sc_reg, u32 val)
162{ 164{
163 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 165 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
164 unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); 166 unsigned int cfg_addr = get_scr_cfg_addr(link->ap, sc_reg);
165 u8 pmr; 167 u8 pmr;
166 168
167 if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ 169 if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */
@@ -178,8 +180,9 @@ static int sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val)
178 return 0; 180 return 0;
179} 181}
180 182
181static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 183static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
182{ 184{
185 struct ata_port *ap = link->ap;
183 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 186 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
184 u8 pmr; 187 u8 pmr;
185 188
@@ -187,7 +190,7 @@ static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
187 return -EINVAL; 190 return -EINVAL;
188 191
189 if (ap->flags & SIS_FLAG_CFGSCR) 192 if (ap->flags & SIS_FLAG_CFGSCR)
190 return sis_scr_cfg_read(ap, sc_reg, val); 193 return sis_scr_cfg_read(link, sc_reg, val);
191 194
192 pci_read_config_byte(pdev, SIS_PMR, &pmr); 195 pci_read_config_byte(pdev, SIS_PMR, &pmr);
193 196
@@ -202,8 +205,9 @@ static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
202 return 0; 205 return 0;
203} 206}
204 207
205static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 208static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
206{ 209{
210 struct ata_port *ap = link->ap;
207 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 211 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
208 u8 pmr; 212 u8 pmr;
209 213
@@ -213,7 +217,7 @@ static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val)
213 pci_read_config_byte(pdev, SIS_PMR, &pmr); 217 pci_read_config_byte(pdev, SIS_PMR, &pmr);
214 218
215 if (ap->flags & SIS_FLAG_CFGSCR) 219 if (ap->flags & SIS_FLAG_CFGSCR)
216 return sis_scr_cfg_write(ap, sc_reg, val); 220 return sis_scr_cfg_write(link, sc_reg, val);
217 else { 221 else {
218 iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)); 222 iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4));
219 if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || 223 if ((pdev->device == 0x0182) || (pdev->device == 0x0183) ||
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index fb13b82aacba..609d147813ae 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -123,20 +123,22 @@ static int k2_sata_check_atapi_dma(struct ata_queued_cmd *qc)
123 } 123 }
124} 124}
125 125
126static int k2_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 126static int k2_sata_scr_read(struct ata_link *link,
127 unsigned int sc_reg, u32 *val)
127{ 128{
128 if (sc_reg > SCR_CONTROL) 129 if (sc_reg > SCR_CONTROL)
129 return -EINVAL; 130 return -EINVAL;
130 *val = readl(ap->ioaddr.scr_addr + (sc_reg * 4)); 131 *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 4));
131 return 0; 132 return 0;
132} 133}
133 134
134 135
135static int k2_sata_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 136static int k2_sata_scr_write(struct ata_link *link,
137 unsigned int sc_reg, u32 val)
136{ 138{
137 if (sc_reg > SCR_CONTROL) 139 if (sc_reg > SCR_CONTROL)
138 return -EINVAL; 140 return -EINVAL;
139 writel(val, ap->ioaddr.scr_addr + (sc_reg * 4)); 141 writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 4));
140 return 0; 142 return 0;
141} 143}
142 144
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index db529b849948..019575bb3e08 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -57,8 +57,8 @@ struct uli_priv {
57}; 57};
58 58
59static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 59static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
60static int uli_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 60static int uli_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
61static int uli_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 61static int uli_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
62 62
63static const struct pci_device_id uli_pci_tbl[] = { 63static const struct pci_device_id uli_pci_tbl[] = {
64 { PCI_VDEVICE(AL, 0x5289), uli_5289 }, 64 { PCI_VDEVICE(AL, 0x5289), uli_5289 },
@@ -107,39 +107,39 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
107 return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg); 107 return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg);
108} 108}
109 109
110static u32 uli_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg) 110static u32 uli_scr_cfg_read(struct ata_link *link, unsigned int sc_reg)
111{ 111{
112 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 112 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
113 unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); 113 unsigned int cfg_addr = get_scr_cfg_addr(link->ap, sc_reg);
114 u32 val; 114 u32 val;
115 115
116 pci_read_config_dword(pdev, cfg_addr, &val); 116 pci_read_config_dword(pdev, cfg_addr, &val);
117 return val; 117 return val;
118} 118}
119 119
120static void uli_scr_cfg_write(struct ata_port *ap, unsigned int scr, u32 val) 120static void uli_scr_cfg_write(struct ata_link *link, unsigned int scr, u32 val)
121{ 121{
122 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 122 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
123 unsigned int cfg_addr = get_scr_cfg_addr(ap, scr); 123 unsigned int cfg_addr = get_scr_cfg_addr(link->ap, scr);
124 124
125 pci_write_config_dword(pdev, cfg_addr, val); 125 pci_write_config_dword(pdev, cfg_addr, val);
126} 126}
127 127
128static int uli_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 128static int uli_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
129{ 129{
130 if (sc_reg > SCR_CONTROL) 130 if (sc_reg > SCR_CONTROL)
131 return -EINVAL; 131 return -EINVAL;
132 132
133 *val = uli_scr_cfg_read(ap, sc_reg); 133 *val = uli_scr_cfg_read(link, sc_reg);
134 return 0; 134 return 0;
135} 135}
136 136
137static int uli_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 137static int uli_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
138{ 138{
139 if (sc_reg > SCR_CONTROL) //SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0 139 if (sc_reg > SCR_CONTROL) //SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0
140 return -EINVAL; 140 return -EINVAL;
141 141
142 uli_scr_cfg_write(ap, sc_reg, val); 142 uli_scr_cfg_write(link, sc_reg, val);
143 return 0; 143 return 0;
144} 144}
145 145
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 96deeb354e16..1cfa74535d91 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -68,8 +68,8 @@ enum {
68}; 68};
69 69
70static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 70static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
71static int svia_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 71static int svia_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
72static int svia_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 72static int svia_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
73static void svia_noop_freeze(struct ata_port *ap); 73static void svia_noop_freeze(struct ata_port *ap);
74static int vt6420_prereset(struct ata_link *link, unsigned long deadline); 74static int vt6420_prereset(struct ata_link *link, unsigned long deadline);
75static int vt6421_pata_cable_detect(struct ata_port *ap); 75static int vt6421_pata_cable_detect(struct ata_port *ap);
@@ -152,19 +152,19 @@ MODULE_LICENSE("GPL");
152MODULE_DEVICE_TABLE(pci, svia_pci_tbl); 152MODULE_DEVICE_TABLE(pci, svia_pci_tbl);
153MODULE_VERSION(DRV_VERSION); 153MODULE_VERSION(DRV_VERSION);
154 154
155static int svia_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 155static int svia_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
156{ 156{
157 if (sc_reg > SCR_CONTROL) 157 if (sc_reg > SCR_CONTROL)
158 return -EINVAL; 158 return -EINVAL;
159 *val = ioread32(ap->ioaddr.scr_addr + (4 * sc_reg)); 159 *val = ioread32(link->ap->ioaddr.scr_addr + (4 * sc_reg));
160 return 0; 160 return 0;
161} 161}
162 162
163static int svia_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 163static int svia_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
164{ 164{
165 if (sc_reg > SCR_CONTROL) 165 if (sc_reg > SCR_CONTROL)
166 return -EINVAL; 166 return -EINVAL;
167 iowrite32(val, ap->ioaddr.scr_addr + (4 * sc_reg)); 167 iowrite32(val, link->ap->ioaddr.scr_addr + (4 * sc_reg));
168 return 0; 168 return 0;
169} 169}
170 170
@@ -210,20 +210,20 @@ static int vt6420_prereset(struct ata_link *link, unsigned long deadline)
210 goto skip_scr; 210 goto skip_scr;
211 211
212 /* Resume phy. This is the old SATA resume sequence */ 212 /* Resume phy. This is the old SATA resume sequence */
213 svia_scr_write(ap, SCR_CONTROL, 0x300); 213 svia_scr_write(link, SCR_CONTROL, 0x300);
214 svia_scr_read(ap, SCR_CONTROL, &scontrol); /* flush */ 214 svia_scr_read(link, SCR_CONTROL, &scontrol); /* flush */
215 215
216 /* wait for phy to become ready, if necessary */ 216 /* wait for phy to become ready, if necessary */
217 do { 217 do {
218 msleep(200); 218 msleep(200);
219 svia_scr_read(ap, SCR_STATUS, &sstatus); 219 svia_scr_read(link, SCR_STATUS, &sstatus);
220 if ((sstatus & 0xf) != 1) 220 if ((sstatus & 0xf) != 1)
221 break; 221 break;
222 } while (time_before(jiffies, timeout)); 222 } while (time_before(jiffies, timeout));
223 223
224 /* open code sata_print_link_status() */ 224 /* open code sata_print_link_status() */
225 svia_scr_read(ap, SCR_STATUS, &sstatus); 225 svia_scr_read(link, SCR_STATUS, &sstatus);
226 svia_scr_read(ap, SCR_CONTROL, &scontrol); 226 svia_scr_read(link, SCR_CONTROL, &scontrol);
227 227
228 online = (sstatus & 0xf) == 0x3; 228 online = (sstatus & 0xf) == 0x3;
229 229
@@ -232,7 +232,7 @@ static int vt6420_prereset(struct ata_link *link, unsigned long deadline)
232 online ? "up" : "down", sstatus, scontrol); 232 online ? "up" : "down", sstatus, scontrol);
233 233
234 /* SStatus is read one more time */ 234 /* SStatus is read one more time */
235 svia_scr_read(ap, SCR_STATUS, &sstatus); 235 svia_scr_read(link, SCR_STATUS, &sstatus);
236 236
237 if (!online) { 237 if (!online) {
238 /* tell EH to bail */ 238 /* tell EH to bail */
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c
index f3d635c0a2e9..c57cdff9e6bd 100644
--- a/drivers/ata/sata_vsc.c
+++ b/drivers/ata/sata_vsc.c
@@ -98,20 +98,22 @@ enum {
98 VSC_SATA_INT_PHY_CHANGE), 98 VSC_SATA_INT_PHY_CHANGE),
99}; 99};
100 100
101static int vsc_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 101static int vsc_sata_scr_read(struct ata_link *link,
102 unsigned int sc_reg, u32 *val)
102{ 103{
103 if (sc_reg > SCR_CONTROL) 104 if (sc_reg > SCR_CONTROL)
104 return -EINVAL; 105 return -EINVAL;
105 *val = readl(ap->ioaddr.scr_addr + (sc_reg * 4)); 106 *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 4));
106 return 0; 107 return 0;
107} 108}
108 109
109 110
110static int vsc_sata_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 111static int vsc_sata_scr_write(struct ata_link *link,
112 unsigned int sc_reg, u32 val)
111{ 113{
112 if (sc_reg > SCR_CONTROL) 114 if (sc_reg > SCR_CONTROL)
113 return -EINVAL; 115 return -EINVAL;
114 writel(val, ap->ioaddr.scr_addr + (sc_reg * 4)); 116 writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 4));
115 return 0; 117 return 0;
116} 118}
117 119
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index 1e55a658e6ce..32f3a8ed8d3d 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -256,7 +256,6 @@ static inline int bpa10x_submit_intr_urb(struct hci_dev *hdev)
256 BT_ERR("%s urb %p submission failed (%d)", 256 BT_ERR("%s urb %p submission failed (%d)",
257 hdev->name, urb, -err); 257 hdev->name, urb, -err);
258 usb_unanchor_urb(urb); 258 usb_unanchor_urb(urb);
259 kfree(buf);
260 } 259 }
261 260
262 usb_free_urb(urb); 261 usb_free_urb(urb);
@@ -298,7 +297,6 @@ static inline int bpa10x_submit_bulk_urb(struct hci_dev *hdev)
298 BT_ERR("%s urb %p submission failed (%d)", 297 BT_ERR("%s urb %p submission failed (%d)",
299 hdev->name, urb, -err); 298 hdev->name, urb, -err);
300 usb_unanchor_urb(urb); 299 usb_unanchor_urb(urb);
301 kfree(buf);
302 } 300 }
303 301
304 usb_free_urb(urb); 302 usb_free_urb(urb);
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 29ae99817c60..af472e052732 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -102,6 +102,7 @@ static struct usb_device_id blacklist_table[] = {
102 { USB_DEVICE(0x0a5c, 0x2101), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 102 { USB_DEVICE(0x0a5c, 0x2101), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU },
103 103
104 /* Broadcom BCM2046 */ 104 /* Broadcom BCM2046 */
105 { USB_DEVICE(0x0a5c, 0x2146), .driver_info = BTUSB_RESET },
105 { USB_DEVICE(0x0a5c, 0x2151), .driver_info = BTUSB_RESET }, 106 { USB_DEVICE(0x0a5c, 0x2151), .driver_info = BTUSB_RESET },
106 107
107 /* Apple MacBook Pro with Broadcom chip */ 108 /* Apple MacBook Pro with Broadcom chip */
@@ -113,6 +114,7 @@ static struct usb_device_id blacklist_table[] = {
113 114
114 /* Targus ACB10US */ 115 /* Targus ACB10US */
115 { USB_DEVICE(0x0a5c, 0x2100), .driver_info = BTUSB_RESET }, 116 { USB_DEVICE(0x0a5c, 0x2100), .driver_info = BTUSB_RESET },
117 { USB_DEVICE(0x0a5c, 0x2154), .driver_info = BTUSB_RESET },
116 118
117 /* ANYCOM Bluetooth USB-200 and USB-250 */ 119 /* ANYCOM Bluetooth USB-200 and USB-250 */
118 { USB_DEVICE(0x0a5c, 0x2111), .driver_info = BTUSB_RESET }, 120 { USB_DEVICE(0x0a5c, 0x2111), .driver_info = BTUSB_RESET },
@@ -150,6 +152,9 @@ static struct usb_device_id blacklist_table[] = {
150 { USB_DEVICE(0x050d, 0x0012), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 152 { USB_DEVICE(0x050d, 0x0012), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU },
151 { USB_DEVICE(0x050d, 0x0013), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 153 { USB_DEVICE(0x050d, 0x0013), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU },
152 154
155 /* Belkin F8T016 device */
156 { USB_DEVICE(0x050d, 0x016a), .driver_info = BTUSB_RESET },
157
153 /* Digianswer devices */ 158 /* Digianswer devices */
154 { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER }, 159 { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER },
155 { USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE }, 160 { USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE },
@@ -271,7 +276,6 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev)
271 BT_ERR("%s urb %p submission failed (%d)", 276 BT_ERR("%s urb %p submission failed (%d)",
272 hdev->name, urb, -err); 277 hdev->name, urb, -err);
273 usb_unanchor_urb(urb); 278 usb_unanchor_urb(urb);
274 kfree(buf);
275 } 279 }
276 280
277 usb_free_urb(urb); 281 usb_free_urb(urb);
@@ -354,7 +358,6 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev)
354 BT_ERR("%s urb %p submission failed (%d)", 358 BT_ERR("%s urb %p submission failed (%d)",
355 hdev->name, urb, -err); 359 hdev->name, urb, -err);
356 usb_unanchor_urb(urb); 360 usb_unanchor_urb(urb);
357 kfree(buf);
358 } 361 }
359 362
360 usb_free_urb(urb); 363 usb_free_urb(urb);
@@ -475,7 +478,6 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev)
475 BT_ERR("%s urb %p submission failed (%d)", 478 BT_ERR("%s urb %p submission failed (%d)",
476 hdev->name, urb, -err); 479 hdev->name, urb, -err);
477 usb_unanchor_urb(urb); 480 usb_unanchor_urb(urb);
478 kfree(buf);
479 } 481 }
480 482
481 usb_free_urb(urb); 483 usb_free_urb(urb);
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index d568c65c1370..d9e7a49d6cbf 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -279,7 +279,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
279 { "OTES1 Fan", 36, 2, 60, 1, 0 }, 279 { "OTES1 Fan", 36, 2, 60, 1, 0 },
280 { NULL, 0, 0, 0, 0, 0 } } 280 { NULL, 0, 0, 0, 0, 0 } }
281 }, 281 },
282 { 0x0011, NULL /* Abit AT8 32X, need DMI string */, { 282 { 0x0011, "AT8 32X(ATI RD580-ULI M1575)", {
283 { "CPU Core", 0, 0, 10, 1, 0 }, 283 { "CPU Core", 0, 0, 10, 1, 0 },
284 { "DDR", 1, 0, 20, 1, 0 }, 284 { "DDR", 1, 0, 20, 1, 0 },
285 { "DDR VTT", 2, 0, 10, 1, 0 }, 285 { "DDR VTT", 2, 0, 10, 1, 0 },
@@ -303,6 +303,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
303 { "SYS Fan", 34, 2, 60, 1, 0 }, 303 { "SYS Fan", 34, 2, 60, 1, 0 },
304 { "AUX1 Fan", 35, 2, 60, 1, 0 }, 304 { "AUX1 Fan", 35, 2, 60, 1, 0 },
305 { "AUX2 Fan", 36, 2, 60, 1, 0 }, 305 { "AUX2 Fan", 36, 2, 60, 1, 0 },
306 { "AUX3 Fan", 37, 2, 60, 1, 0 },
306 { NULL, 0, 0, 0, 0, 0 } } 307 { NULL, 0, 0, 0, 0, 0 } }
307 }, 308 },
308 { 0x0012, NULL /* Abit AN8 32X, need DMI string */, { 309 { 0x0012, NULL /* Abit AN8 32X, need DMI string */, {
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index f1133081cc42..d793cc011990 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -46,6 +46,8 @@
46#include <linux/err.h> 46#include <linux/err.h>
47#include <linux/mutex.h> 47#include <linux/mutex.h>
48#include <linux/sysfs.h> 48#include <linux/sysfs.h>
49#include <linux/string.h>
50#include <linux/dmi.h>
49#include <asm/io.h> 51#include <asm/io.h>
50 52
51#define DRVNAME "it87" 53#define DRVNAME "it87"
@@ -236,6 +238,8 @@ struct it87_sio_data {
236 /* Values read from Super-I/O config space */ 238 /* Values read from Super-I/O config space */
237 u8 revision; 239 u8 revision;
238 u8 vid_value; 240 u8 vid_value;
241 /* Values set based on DMI strings */
242 u8 skip_pwm;
239}; 243};
240 244
241/* For each registered chip, we need to keep some data in memory. 245/* For each registered chip, we need to keep some data in memory.
@@ -964,6 +968,7 @@ static int __init it87_find(unsigned short *address,
964{ 968{
965 int err = -ENODEV; 969 int err = -ENODEV;
966 u16 chip_type; 970 u16 chip_type;
971 const char *board_vendor, *board_name;
967 972
968 superio_enter(); 973 superio_enter();
969 chip_type = force_id ? force_id : superio_inw(DEVID); 974 chip_type = force_id ? force_id : superio_inw(DEVID);
@@ -1022,6 +1027,24 @@ static int __init it87_find(unsigned short *address,
1022 pr_info("it87: in7 is VCCH (+5V Stand-By)\n"); 1027 pr_info("it87: in7 is VCCH (+5V Stand-By)\n");
1023 } 1028 }
1024 1029
1030 /* Disable specific features based on DMI strings */
1031 board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
1032 board_name = dmi_get_system_info(DMI_BOARD_NAME);
1033 if (board_vendor && board_name) {
1034 if (strcmp(board_vendor, "nVIDIA") == 0
1035 && strcmp(board_name, "FN68PT") == 0) {
1036 /* On the Shuttle SN68PT, FAN_CTL2 is apparently not
1037 connected to a fan, but to something else. One user
1038 has reported instant system power-off when changing
1039 the PWM2 duty cycle, so we disable it.
1040 I use the board name string as the trigger in case
1041 the same board is ever used in other systems. */
1042 pr_info("it87: Disabling pwm2 due to "
1043 "hardware constraints\n");
1044 sio_data->skip_pwm = (1 << 1);
1045 }
1046 }
1047
1025exit: 1048exit:
1026 superio_exit(); 1049 superio_exit();
1027 return err; 1050 return err;
@@ -1168,25 +1191,33 @@ static int __devinit it87_probe(struct platform_device *pdev)
1168 } 1191 }
1169 1192
1170 if (enable_pwm_interface) { 1193 if (enable_pwm_interface) {
1171 if ((err = device_create_file(dev, 1194 if (!(sio_data->skip_pwm & (1 << 0))) {
1172 &sensor_dev_attr_pwm1_enable.dev_attr)) 1195 if ((err = device_create_file(dev,
1173 || (err = device_create_file(dev, 1196 &sensor_dev_attr_pwm1_enable.dev_attr))
1174 &sensor_dev_attr_pwm2_enable.dev_attr)) 1197 || (err = device_create_file(dev,
1175 || (err = device_create_file(dev, 1198 &sensor_dev_attr_pwm1.dev_attr))
1176 &sensor_dev_attr_pwm3_enable.dev_attr)) 1199 || (err = device_create_file(dev,
1177 || (err = device_create_file(dev, 1200 &dev_attr_pwm1_freq)))
1178 &sensor_dev_attr_pwm1.dev_attr)) 1201 goto ERROR4;
1179 || (err = device_create_file(dev, 1202 }
1180 &sensor_dev_attr_pwm2.dev_attr)) 1203 if (!(sio_data->skip_pwm & (1 << 1))) {
1181 || (err = device_create_file(dev, 1204 if ((err = device_create_file(dev,
1182 &sensor_dev_attr_pwm3.dev_attr)) 1205 &sensor_dev_attr_pwm2_enable.dev_attr))
1183 || (err = device_create_file(dev, 1206 || (err = device_create_file(dev,
1184 &dev_attr_pwm1_freq)) 1207 &sensor_dev_attr_pwm2.dev_attr))
1185 || (err = device_create_file(dev, 1208 || (err = device_create_file(dev,
1186 &dev_attr_pwm2_freq)) 1209 &dev_attr_pwm2_freq)))
1187 || (err = device_create_file(dev, 1210 goto ERROR4;
1188 &dev_attr_pwm3_freq))) 1211 }
1189 goto ERROR4; 1212 if (!(sio_data->skip_pwm & (1 << 2))) {
1213 if ((err = device_create_file(dev,
1214 &sensor_dev_attr_pwm3_enable.dev_attr))
1215 || (err = device_create_file(dev,
1216 &sensor_dev_attr_pwm3.dev_attr))
1217 || (err = device_create_file(dev,
1218 &dev_attr_pwm3_freq)))
1219 goto ERROR4;
1220 }
1190 } 1221 }
1191 1222
1192 if (data->type == it8712 || data->type == it8716 1223 if (data->type == it8712 || data->type == it8716
@@ -1546,6 +1577,7 @@ static int __init sm_it87_init(void)
1546 unsigned short isa_address=0; 1577 unsigned short isa_address=0;
1547 struct it87_sio_data sio_data; 1578 struct it87_sio_data sio_data;
1548 1579
1580 memset(&sio_data, 0, sizeof(struct it87_sio_data));
1549 err = it87_find(&isa_address, &sio_data); 1581 err = it87_find(&isa_address, &sio_data);
1550 if (err) 1582 if (err)
1551 return err; 1583 return err;
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 8e93a797c93d..052879a6f853 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -780,10 +780,6 @@ config BLK_DEV_IDEDMA_PMAC
780 to transfer data to and from memory. Saying Y is safe and improves 780 to transfer data to and from memory. Saying Y is safe and improves
781 performance. 781 performance.
782 782
783config BLK_DEV_IDE_SWARM
784 tristate "IDE for Sibyte evaluation boards"
785 depends on SIBYTE_SB1xxx_SOC
786
787config BLK_DEV_IDE_AU1XXX 783config BLK_DEV_IDE_AU1XXX
788 bool "IDE for AMD Alchemy Au1200" 784 bool "IDE for AMD Alchemy Au1200"
789 depends on SOC_AU1200 785 depends on SOC_AU1200
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 49a8c589e346..f16bb4667238 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1661,7 +1661,9 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1661 cdi->mask &= ~CDC_PLAY_AUDIO; 1661 cdi->mask &= ~CDC_PLAY_AUDIO;
1662 1662
1663 mechtype = buf[8 + 6] >> 5; 1663 mechtype = buf[8 + 6] >> 5;
1664 if (mechtype == mechtype_caddy || mechtype == mechtype_popup) 1664 if (mechtype == mechtype_caddy ||
1665 mechtype == mechtype_popup ||
1666 (drive->atapi_flags & IDE_AFLAG_NO_AUTOCLOSE))
1665 cdi->mask |= CDC_CLOSE_TRAY; 1667 cdi->mask |= CDC_CLOSE_TRAY;
1666 1668
1667 if (cdi->sanyo_slot > 0) { 1669 if (cdi->sanyo_slot > 0) {
@@ -1859,6 +1861,8 @@ static const struct cd_list_entry ide_cd_quirks_list[] = {
1859 { "MATSHITADVD-ROM SR-8176", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, 1861 { "MATSHITADVD-ROM SR-8176", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1860 { "MATSHITADVD-ROM SR-8174", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, 1862 { "MATSHITADVD-ROM SR-8174", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1861 { "Optiarc DVD RW AD-5200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, 1863 { "Optiarc DVD RW AD-5200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1864 { "Optiarc DVD RW AD-7200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1865 { "Optiarc DVD RW AD-7543A", NULL, IDE_AFLAG_NO_AUTOCLOSE },
1862 { NULL, NULL, 0 } 1866 { NULL, NULL, 0 }
1863}; 1867};
1864 1868
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index adc682755857..3fa07c0aeaa4 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -211,7 +211,7 @@ int ide_build_dmatable (ide_drive_t *drive, struct request *rq)
211 xcount = bcount & 0xffff; 211 xcount = bcount & 0xffff;
212 if (is_trm290) 212 if (is_trm290)
213 xcount = ((xcount >> 2) - 1) << 16; 213 xcount = ((xcount >> 2) - 1) << 16;
214 if (xcount == 0x0000) { 214 else if (xcount == 0x0000) {
215 /* 215 /*
216 * Most chipsets correctly interpret a length of 0x0000 as 64KB, 216 * Most chipsets correctly interpret a length of 0x0000 as 64KB,
217 * but at least one (e.g. CS5530) misinterprets it as zero (!). 217 * but at least one (e.g. CS5530) misinterprets it as zero (!).
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 994e41099b42..a51a30e9eab3 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1492,7 +1492,7 @@ static struct device_attribute *ide_port_attrs[] = {
1492 1492
1493static int ide_sysfs_register_port(ide_hwif_t *hwif) 1493static int ide_sysfs_register_port(ide_hwif_t *hwif)
1494{ 1494{
1495 int i, rc; 1495 int i, uninitialized_var(rc);
1496 1496
1497 for (i = 0; ide_port_attrs[i]; i++) { 1497 for (i = 0; ide_port_attrs[i]; i++) {
1498 rc = device_create_file(hwif->portdev, ide_port_attrs[i]); 1498 rc = device_create_file(hwif->portdev, ide_port_attrs[i]);
diff --git a/drivers/ide/mips/Makefile b/drivers/ide/mips/Makefile
index 677c7b2bac92..5873fa0b8769 100644
--- a/drivers/ide/mips/Makefile
+++ b/drivers/ide/mips/Makefile
@@ -1,4 +1,3 @@
1obj-$(CONFIG_BLK_DEV_IDE_SWARM) += swarm.o
2obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o 1obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o
3 2
4EXTRA_CFLAGS := -Idrivers/ide 3EXTRA_CFLAGS := -Idrivers/ide
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
deleted file mode 100644
index 39c9ee995857..000000000000
--- a/drivers/ide/mips/swarm.c
+++ /dev/null
@@ -1,197 +0,0 @@
1/*
2 * Copyright (C) 2001, 2002, 2003 Broadcom Corporation
3 * Copyright (C) 2004 MontaVista Software Inc.
4 * Author: Manish Lachwani, mlachwani@mvista.com
5 * Copyright (C) 2004 MIPS Technologies, Inc. All rights reserved.
6 * Author: Maciej W. Rozycki <macro@mips.com>
7 * Copyright (c) 2006, 2008 Maciej W. Rozycki
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24/*
25 * Derived loosely from ide-pmac.c, so:
26 * Copyright (C) 1998 Paul Mackerras.
27 * Copyright (C) 1995-1998 Mark Lord
28 */
29
30/*
31 * Boards with SiByte processors so far have supported IDE devices via
32 * the Generic Bus, PCI bus, and built-in PCMCIA interface. In all
33 * cases, byte-swapping must be avoided for these devices (whereas
34 * other PCI devices, for example, will require swapping). Any
35 * SiByte-targetted kernel including IDE support will include this
36 * file. Probing of a Generic Bus for an IDE device is controlled by
37 * the definition of "SIBYTE_HAVE_IDE", which is provided by
38 * <asm/sibyte/board.h> for Broadcom boards.
39 */
40
41#include <linux/ide.h>
42#include <linux/ioport.h>
43#include <linux/kernel.h>
44#include <linux/types.h>
45#include <linux/platform_device.h>
46
47#include <asm/io.h>
48
49#include <asm/sibyte/board.h>
50#include <asm/sibyte/sb1250_genbus.h>
51#include <asm/sibyte/sb1250_regs.h>
52
53#define DRV_NAME "ide-swarm"
54
55static char swarm_ide_string[] = DRV_NAME;
56
57static struct resource swarm_ide_resource = {
58 .name = "SWARM GenBus IDE",
59 .flags = IORESOURCE_MEM,
60};
61
62static struct platform_device *swarm_ide_dev;
63
64static const struct ide_port_info swarm_port_info = {
65 .name = DRV_NAME,
66 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
67};
68
69/*
70 * swarm_ide_probe - if the board header indicates the existence of
71 * Generic Bus IDE, allocate a HWIF for it.
72 */
73static int __devinit swarm_ide_probe(struct device *dev)
74{
75 u8 __iomem *base;
76 struct ide_host *host;
77 phys_t offset, size;
78 int i, rc;
79 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
80
81 if (!SIBYTE_HAVE_IDE)
82 return -ENODEV;
83
84 base = ioremap(A_IO_EXT_BASE, 0x800);
85 offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
86 size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
87 iounmap(base);
88
89 offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
90 size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
91 if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
92 printk(KERN_INFO DRV_NAME
93 ": IDE interface at GenBus disabled\n");
94 return -EBUSY;
95 }
96
97 printk(KERN_INFO DRV_NAME ": IDE interface at GenBus slot %i\n",
98 IDE_CS);
99
100 swarm_ide_resource.start = offset;
101 swarm_ide_resource.end = offset + size - 1;
102 if (request_resource(&iomem_resource, &swarm_ide_resource)) {
103 printk(KERN_ERR DRV_NAME
104 ": can't request I/O memory resource\n");
105 return -EBUSY;
106 }
107
108 base = ioremap(offset, size);
109
110 memset(&hw, 0, sizeof(hw));
111 for (i = 0; i <= 7; i++)
112 hw.io_ports_array[i] =
113 (unsigned long)(base + ((0x1f0 + i) << 5));
114 hw.io_ports.ctl_addr =
115 (unsigned long)(base + (0x3f6 << 5));
116 hw.irq = K_INT_GB_IDE;
117 hw.chipset = ide_generic;
118
119 rc = ide_host_add(&swarm_port_info, hws, &host);
120 if (rc)
121 goto err;
122
123 dev_set_drvdata(dev, host);
124
125 return 0;
126err:
127 release_resource(&swarm_ide_resource);
128 iounmap(base);
129 return rc;
130}
131
132static struct device_driver swarm_ide_driver = {
133 .name = swarm_ide_string,
134 .bus = &platform_bus_type,
135 .probe = swarm_ide_probe,
136};
137
138static void swarm_ide_platform_release(struct device *device)
139{
140 struct platform_device *pldev;
141
142 /* free device */
143 pldev = to_platform_device(device);
144 kfree(pldev);
145}
146
147static int __devinit swarm_ide_init_module(void)
148{
149 struct platform_device *pldev;
150 int err;
151
152 printk(KERN_INFO "SWARM IDE driver\n");
153
154 if (driver_register(&swarm_ide_driver)) {
155 printk(KERN_ERR "Driver registration failed\n");
156 err = -ENODEV;
157 goto out;
158 }
159
160 if (!(pldev = kzalloc(sizeof (*pldev), GFP_KERNEL))) {
161 err = -ENOMEM;
162 goto out_unregister_driver;
163 }
164
165 pldev->name = swarm_ide_string;
166 pldev->id = 0;
167 pldev->dev.release = swarm_ide_platform_release;
168
169 if (platform_device_register(pldev)) {
170 err = -ENODEV;
171 goto out_free_pldev;
172 }
173
174 if (!pldev->dev.driver) {
175 /*
176 * The driver was not bound to this device, there was
177 * no hardware at this address. Unregister it, as the
178 * release fuction will take care of freeing the
179 * allocated structure
180 */
181 platform_device_unregister (pldev);
182 }
183
184 swarm_ide_dev = pldev;
185
186 return 0;
187
188out_free_pldev:
189 kfree(pldev);
190
191out_unregister_driver:
192 driver_unregister(&swarm_ide_driver);
193out:
194 return err;
195}
196
197module_init(swarm_ide_init_module);
diff --git a/drivers/media/common/tuners/tuner-xc2028.h b/drivers/media/common/tuners/tuner-xc2028.h
index 216025cf5d4b..2c5b6282b569 100644
--- a/drivers/media/common/tuners/tuner-xc2028.h
+++ b/drivers/media/common/tuners/tuner-xc2028.h
@@ -10,6 +10,7 @@
10#include "dvb_frontend.h" 10#include "dvb_frontend.h"
11 11
12#define XC2028_DEFAULT_FIRMWARE "xc3028-v27.fw" 12#define XC2028_DEFAULT_FIRMWARE "xc3028-v27.fw"
13#define XC3028L_DEFAULT_FIRMWARE "xc3028L-v36.fw"
13 14
14/* Dmoduler IF (kHz) */ 15/* Dmoduler IF (kHz) */
15#define XC3028_FE_DEFAULT 0 /* Don't load SCODE */ 16#define XC3028_FE_DEFAULT 0 /* Don't load SCODE */
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 4eed783f4bce..a127a4175c40 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -491,6 +491,7 @@ static struct s5h1420_config skystar2_rev2_7_s5h1420_config = {
491 .demod_address = 0x53, 491 .demod_address = 0x53,
492 .invert = 1, 492 .invert = 1,
493 .repeated_start_workaround = 1, 493 .repeated_start_workaround = 1,
494 .serial_mpeg = 1,
494}; 495};
495 496
496static struct itd1000_config skystar2_rev2_7_itd1000_config = { 497static struct itd1000_config skystar2_rev2_7_itd1000_config = {
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 069d847ba887..0c733c66a441 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -364,15 +364,16 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
364 enum dmx_success success) 364 enum dmx_success success)
365{ 365{
366 struct dmxdev_filter *dmxdevfilter = filter->priv; 366 struct dmxdev_filter *dmxdevfilter = filter->priv;
367 unsigned long flags;
367 int ret; 368 int ret;
368 369
369 if (dmxdevfilter->buffer.error) { 370 if (dmxdevfilter->buffer.error) {
370 wake_up(&dmxdevfilter->buffer.queue); 371 wake_up(&dmxdevfilter->buffer.queue);
371 return 0; 372 return 0;
372 } 373 }
373 spin_lock(&dmxdevfilter->dev->lock); 374 spin_lock_irqsave(&dmxdevfilter->dev->lock, flags);
374 if (dmxdevfilter->state != DMXDEV_STATE_GO) { 375 if (dmxdevfilter->state != DMXDEV_STATE_GO) {
375 spin_unlock(&dmxdevfilter->dev->lock); 376 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
376 return 0; 377 return 0;
377 } 378 }
378 del_timer(&dmxdevfilter->timer); 379 del_timer(&dmxdevfilter->timer);
@@ -391,7 +392,7 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
391 } 392 }
392 if (dmxdevfilter->params.sec.flags & DMX_ONESHOT) 393 if (dmxdevfilter->params.sec.flags & DMX_ONESHOT)
393 dmxdevfilter->state = DMXDEV_STATE_DONE; 394 dmxdevfilter->state = DMXDEV_STATE_DONE;
394 spin_unlock(&dmxdevfilter->dev->lock); 395 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
395 wake_up(&dmxdevfilter->buffer.queue); 396 wake_up(&dmxdevfilter->buffer.queue);
396 return 0; 397 return 0;
397} 398}
@@ -403,11 +404,12 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
403{ 404{
404 struct dmxdev_filter *dmxdevfilter = feed->priv; 405 struct dmxdev_filter *dmxdevfilter = feed->priv;
405 struct dvb_ringbuffer *buffer; 406 struct dvb_ringbuffer *buffer;
407 unsigned long flags;
406 int ret; 408 int ret;
407 409
408 spin_lock(&dmxdevfilter->dev->lock); 410 spin_lock_irqsave(&dmxdevfilter->dev->lock, flags);
409 if (dmxdevfilter->params.pes.output == DMX_OUT_DECODER) { 411 if (dmxdevfilter->params.pes.output == DMX_OUT_DECODER) {
410 spin_unlock(&dmxdevfilter->dev->lock); 412 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
411 return 0; 413 return 0;
412 } 414 }
413 415
@@ -417,7 +419,7 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
417 else 419 else
418 buffer = &dmxdevfilter->dev->dvr_buffer; 420 buffer = &dmxdevfilter->dev->dvr_buffer;
419 if (buffer->error) { 421 if (buffer->error) {
420 spin_unlock(&dmxdevfilter->dev->lock); 422 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
421 wake_up(&buffer->queue); 423 wake_up(&buffer->queue);
422 return 0; 424 return 0;
423 } 425 }
@@ -428,7 +430,7 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
428 dvb_ringbuffer_flush(buffer); 430 dvb_ringbuffer_flush(buffer);
429 buffer->error = ret; 431 buffer->error = ret;
430 } 432 }
431 spin_unlock(&dmxdevfilter->dev->lock); 433 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
432 wake_up(&buffer->queue); 434 wake_up(&buffer->queue);
433 return 0; 435 return 0;
434} 436}
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index e2eca0b1fe7c..a2c1fd5d2f67 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -399,7 +399,9 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
399void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, 399void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
400 size_t count) 400 size_t count)
401{ 401{
402 spin_lock(&demux->lock); 402 unsigned long flags;
403
404 spin_lock_irqsave(&demux->lock, flags);
403 405
404 while (count--) { 406 while (count--) {
405 if (buf[0] == 0x47) 407 if (buf[0] == 0x47)
@@ -407,16 +409,17 @@ void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
407 buf += 188; 409 buf += 188;
408 } 410 }
409 411
410 spin_unlock(&demux->lock); 412 spin_unlock_irqrestore(&demux->lock, flags);
411} 413}
412 414
413EXPORT_SYMBOL(dvb_dmx_swfilter_packets); 415EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
414 416
415void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) 417void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
416{ 418{
419 unsigned long flags;
417 int p = 0, i, j; 420 int p = 0, i, j;
418 421
419 spin_lock(&demux->lock); 422 spin_lock_irqsave(&demux->lock, flags);
420 423
421 if (demux->tsbufp) { 424 if (demux->tsbufp) {
422 i = demux->tsbufp; 425 i = demux->tsbufp;
@@ -449,17 +452,18 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
449 } 452 }
450 453
451bailout: 454bailout:
452 spin_unlock(&demux->lock); 455 spin_unlock_irqrestore(&demux->lock, flags);
453} 456}
454 457
455EXPORT_SYMBOL(dvb_dmx_swfilter); 458EXPORT_SYMBOL(dvb_dmx_swfilter);
456 459
457void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) 460void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
458{ 461{
462 unsigned long flags;
459 int p = 0, i, j; 463 int p = 0, i, j;
460 u8 tmppack[188]; 464 u8 tmppack[188];
461 465
462 spin_lock(&demux->lock); 466 spin_lock_irqsave(&demux->lock, flags);
463 467
464 if (demux->tsbufp) { 468 if (demux->tsbufp) {
465 i = demux->tsbufp; 469 i = demux->tsbufp;
@@ -500,7 +504,7 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
500 } 504 }
501 505
502bailout: 506bailout:
503 spin_unlock(&demux->lock); 507 spin_unlock_irqrestore(&demux->lock, flags);
504} 508}
505 509
506EXPORT_SYMBOL(dvb_dmx_swfilter_204); 510EXPORT_SYMBOL(dvb_dmx_swfilter_204);
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c
index 747d3fa2e5e5..2e9fd2893ede 100644
--- a/drivers/media/dvb/frontends/s5h1420.c
+++ b/drivers/media/dvb/frontends/s5h1420.c
@@ -59,7 +59,7 @@ struct s5h1420_state {
59 * it does not support repeated-start, workaround: write addr-1 59 * it does not support repeated-start, workaround: write addr-1
60 * and then read 60 * and then read
61 */ 61 */
62 u8 shadow[255]; 62 u8 shadow[256];
63}; 63};
64 64
65static u32 s5h1420_getsymbolrate(struct s5h1420_state* state); 65static u32 s5h1420_getsymbolrate(struct s5h1420_state* state);
@@ -94,8 +94,11 @@ static u8 s5h1420_readreg(struct s5h1420_state *state, u8 reg)
94 if (ret != 3) 94 if (ret != 3)
95 return ret; 95 return ret;
96 } else { 96 } else {
97 ret = i2c_transfer(state->i2c, &msg[1], 2); 97 ret = i2c_transfer(state->i2c, &msg[1], 1);
98 if (ret != 2) 98 if (ret != 1)
99 return ret;
100 ret = i2c_transfer(state->i2c, &msg[2], 1);
101 if (ret != 1)
99 return ret; 102 return ret;
100 } 103 }
101 104
@@ -823,7 +826,7 @@ static int s5h1420_init (struct dvb_frontend* fe)
823 struct s5h1420_state* state = fe->demodulator_priv; 826 struct s5h1420_state* state = fe->demodulator_priv;
824 827
825 /* disable power down and do reset */ 828 /* disable power down and do reset */
826 state->CON_1_val = 0x10; 829 state->CON_1_val = state->config->serial_mpeg << 4;
827 s5h1420_writereg(state, 0x02, state->CON_1_val); 830 s5h1420_writereg(state, 0x02, state->CON_1_val);
828 msleep(10); 831 msleep(10);
829 s5h1420_reset(state); 832 s5h1420_reset(state);
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h
index 4c913f142bc4..ff308136d865 100644
--- a/drivers/media/dvb/frontends/s5h1420.h
+++ b/drivers/media/dvb/frontends/s5h1420.h
@@ -32,10 +32,12 @@ struct s5h1420_config
32 u8 demod_address; 32 u8 demod_address;
33 33
34 /* does the inversion require inversion? */ 34 /* does the inversion require inversion? */
35 u8 invert : 1; 35 u8 invert:1;
36 36
37 u8 repeated_start_workaround : 1; 37 u8 repeated_start_workaround:1;
38 u8 cdclk_polarity : 1; /* 1 == falling edge, 0 == raising edge */ 38 u8 cdclk_polarity:1; /* 1 == falling edge, 0 == raising edge */
39
40 u8 serial_mpeg:1;
39}; 41};
40 42
41#if defined(CONFIG_DVB_S5H1420) || (defined(CONFIG_DVB_S5H1420_MODULE) && defined(MODULE)) 43#if defined(CONFIG_DVB_S5H1420) || (defined(CONFIG_DVB_S5H1420_MODULE) && defined(MODULE))
diff --git a/drivers/media/dvb/siano/sms-cards.c b/drivers/media/dvb/siano/sms-cards.c
index cc5efb643f33..9da260fe3fd1 100644
--- a/drivers/media/dvb/siano/sms-cards.c
+++ b/drivers/media/dvb/siano/sms-cards.c
@@ -40,6 +40,8 @@ struct usb_device_id smsusb_id_table[] = {
40 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B }, 40 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B },
41 { USB_DEVICE(0x2040, 0x5500), 41 { USB_DEVICE(0x2040, 0x5500),
42 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 42 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
43 { USB_DEVICE(0x2040, 0x5510),
44 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
43 { USB_DEVICE(0x2040, 0x5580), 45 { USB_DEVICE(0x2040, 0x5580),
44 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 46 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
45 { USB_DEVICE(0x2040, 0x5590), 47 { USB_DEVICE(0x2040, 0x5590),
@@ -87,7 +89,7 @@ static struct sms_board sms_boards[] = {
87 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-b-dvbt-01.fw", 89 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-b-dvbt-01.fw",
88 }, 90 },
89 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = { 91 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = {
90 .name = "Hauppauge WinTV-Nova-T-MiniStick", 92 .name = "Hauppauge WinTV MiniStick",
91 .type = SMS_NOVA_B0, 93 .type = SMS_NOVA_B0,
92 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-01.fw", 94 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-01.fw",
93 }, 95 },
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 6ae4cc860efe..933eaef41ead 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -3431,7 +3431,7 @@ static int radio_open(struct inode *inode, struct file *file)
3431 dprintk("bttv: open minor=%d\n",minor); 3431 dprintk("bttv: open minor=%d\n",minor);
3432 3432
3433 for (i = 0; i < bttv_num; i++) { 3433 for (i = 0; i < bttv_num; i++) {
3434 if (bttvs[i].radio_dev->minor == minor) { 3434 if (bttvs[i].radio_dev && bttvs[i].radio_dev->minor == minor) {
3435 btv = &bttvs[i]; 3435 btv = &bttvs[i];
3436 break; 3436 break;
3437 } 3437 }
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index c149b7d712e5..5405c30dbb04 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -19,6 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/mm.h>
22#include <linux/pci.h> 23#include <linux/pci.h>
23#include <linux/i2c.h> 24#include <linux/i2c.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
diff --git a/drivers/media/video/cpia2/cpia2_usb.c b/drivers/media/video/cpia2/cpia2_usb.c
index a4574740350d..a8a199047cbd 100644
--- a/drivers/media/video/cpia2/cpia2_usb.c
+++ b/drivers/media/video/cpia2/cpia2_usb.c
@@ -632,7 +632,7 @@ int cpia2_usb_transfer_cmd(struct camera_data *cam,
632static int submit_urbs(struct camera_data *cam) 632static int submit_urbs(struct camera_data *cam)
633{ 633{
634 struct urb *urb; 634 struct urb *urb;
635 int fx, err, i; 635 int fx, err, i, j;
636 636
637 for(i=0; i<NUM_SBUF; ++i) { 637 for(i=0; i<NUM_SBUF; ++i) {
638 if (cam->sbuf[i].data) 638 if (cam->sbuf[i].data)
@@ -657,6 +657,9 @@ static int submit_urbs(struct camera_data *cam)
657 } 657 }
658 urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL); 658 urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL);
659 if (!urb) { 659 if (!urb) {
660 ERR("%s: usb_alloc_urb error!\n", __func__);
661 for (j = 0; j < i; j++)
662 usb_free_urb(cam->sbuf[j].urb);
660 return -ENOMEM; 663 return -ENOMEM;
661 } 664 }
662 665
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c
index 8fe5f38c4d7c..3cb9734ec07b 100644
--- a/drivers/media/video/cx18/cx18-cards.c
+++ b/drivers/media/video/cx18/cx18-cards.c
@@ -163,7 +163,7 @@ static const struct cx18_card cx18_card_h900 = {
163 }, 163 },
164 .audio_inputs = { 164 .audio_inputs = {
165 { CX18_CARD_INPUT_AUD_TUNER, 165 { CX18_CARD_INPUT_AUD_TUNER,
166 CX18_AV_AUDIO8, 0 }, 166 CX18_AV_AUDIO5, 0 },
167 { CX18_CARD_INPUT_LINE_IN1, 167 { CX18_CARD_INPUT_LINE_IN1,
168 CX18_AV_AUDIO_SERIAL1, 0 }, 168 CX18_AV_AUDIO_SERIAL1, 0 },
169 }, 169 },
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c
index 3c006103c1eb..ac3292d7646c 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -117,10 +117,10 @@ static void em28xx_audio_isocirq(struct urb *urb)
117 117
118 if (oldptr + length >= runtime->buffer_size) { 118 if (oldptr + length >= runtime->buffer_size) {
119 unsigned int cnt = 119 unsigned int cnt =
120 runtime->buffer_size - oldptr - 1; 120 runtime->buffer_size - oldptr;
121 memcpy(runtime->dma_area + oldptr * stride, cp, 121 memcpy(runtime->dma_area + oldptr * stride, cp,
122 cnt * stride); 122 cnt * stride);
123 memcpy(runtime->dma_area, cp + cnt, 123 memcpy(runtime->dma_area, cp + cnt * stride,
124 length * stride - cnt * stride); 124 length * stride - cnt * stride);
125 } else { 125 } else {
126 memcpy(runtime->dma_area + oldptr * stride, cp, 126 memcpy(runtime->dma_area + oldptr * stride, cp,
@@ -161,8 +161,14 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
161 161
162 memset(dev->adev->transfer_buffer[i], 0x80, sb_size); 162 memset(dev->adev->transfer_buffer[i], 0x80, sb_size);
163 urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); 163 urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC);
164 if (!urb) 164 if (!urb) {
165 em28xx_errdev("usb_alloc_urb failed!\n");
166 for (j = 0; j < i; j++) {
167 usb_free_urb(dev->adev->urb[j]);
168 kfree(dev->adev->transfer_buffer[j]);
169 }
165 return -ENOMEM; 170 return -ENOMEM;
171 }
166 172
167 urb->dev = dev->udev; 173 urb->dev = dev->udev;
168 urb->context = dev; 174 urb->context = dev;
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 452da70e719f..de943cf6c169 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -93,28 +93,6 @@ struct em28xx_board em28xx_boards[] = {
93 .amux = 0, 93 .amux = 0,
94 } }, 94 } },
95 }, 95 },
96 [EM2800_BOARD_KWORLD_USB2800] = {
97 .name = "Kworld USB2800",
98 .valid = EM28XX_BOARD_NOT_VALIDATED,
99 .is_em2800 = 1,
100 .vchannels = 3,
101 .tuner_type = TUNER_PHILIPS_FCV1236D,
102 .tda9887_conf = TDA9887_PRESENT,
103 .decoder = EM28XX_SAA7113,
104 .input = { {
105 .type = EM28XX_VMUX_TELEVISION,
106 .vmux = SAA7115_COMPOSITE2,
107 .amux = 0,
108 }, {
109 .type = EM28XX_VMUX_COMPOSITE1,
110 .vmux = SAA7115_COMPOSITE0,
111 .amux = 1,
112 }, {
113 .type = EM28XX_VMUX_SVIDEO,
114 .vmux = SAA7115_SVIDEO3,
115 .amux = 1,
116 } },
117 },
118 [EM2820_BOARD_KWORLD_PVRTV2800RF] = { 96 [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
119 .name = "Kworld PVR TV 2800 RF", 97 .name = "Kworld PVR TV 2800 RF",
120 .is_em2800 = 0, 98 .is_em2800 = 0,
@@ -599,7 +577,7 @@ struct em28xx_board em28xx_boards[] = {
599 }, { 577 }, {
600 .type = EM28XX_VMUX_COMPOSITE1, 578 .type = EM28XX_VMUX_COMPOSITE1,
601 .vmux = TVP5150_COMPOSITE1, 579 .vmux = TVP5150_COMPOSITE1,
602 .amux = 1, 580 .amux = 3,
603 }, { 581 }, {
604 .type = EM28XX_VMUX_SVIDEO, 582 .type = EM28XX_VMUX_SVIDEO,
605 .vmux = TVP5150_SVIDEO, 583 .vmux = TVP5150_SVIDEO,
@@ -952,22 +930,23 @@ struct em28xx_board em28xx_boards[] = {
952 }, 930 },
953 [EM2880_BOARD_KWORLD_DVB_310U] = { 931 [EM2880_BOARD_KWORLD_DVB_310U] = {
954 .name = "KWorld DVB-T 310U", 932 .name = "KWorld DVB-T 310U",
955 .valid = EM28XX_BOARD_NOT_VALIDATED,
956 .vchannels = 3, 933 .vchannels = 3,
957 .tuner_type = TUNER_XC2028, 934 .tuner_type = TUNER_XC2028,
935 .has_dvb = 1,
936 .mts_firmware = 1,
958 .decoder = EM28XX_TVP5150, 937 .decoder = EM28XX_TVP5150,
959 .input = { { 938 .input = { {
960 .type = EM28XX_VMUX_TELEVISION, 939 .type = EM28XX_VMUX_TELEVISION,
961 .vmux = TVP5150_COMPOSITE0, 940 .vmux = TVP5150_COMPOSITE0,
962 .amux = 0, 941 .amux = EM28XX_AMUX_VIDEO,
963 }, { 942 }, {
964 .type = EM28XX_VMUX_COMPOSITE1, 943 .type = EM28XX_VMUX_COMPOSITE1,
965 .vmux = TVP5150_COMPOSITE1, 944 .vmux = TVP5150_COMPOSITE1,
966 .amux = 1, 945 .amux = EM28XX_AMUX_AC97_LINE_IN,
967 }, { 946 }, { /* S-video has not been tested yet */
968 .type = EM28XX_VMUX_SVIDEO, 947 .type = EM28XX_VMUX_SVIDEO,
969 .vmux = TVP5150_SVIDEO, 948 .vmux = TVP5150_SVIDEO,
970 .amux = 1, 949 .amux = EM28XX_AMUX_AC97_LINE_IN,
971 } }, 950 } },
972 }, 951 },
973 [EM2881_BOARD_DNT_DA2_HYBRID] = { 952 [EM2881_BOARD_DNT_DA2_HYBRID] = {
@@ -1282,6 +1261,7 @@ static struct em28xx_reg_seq em2882_terratec_hybrid_xs_digital[] = {
1282static struct em28xx_hash_table em28xx_eeprom_hash [] = { 1261static struct em28xx_hash_table em28xx_eeprom_hash [] = {
1283 /* P/N: SA 60002070465 Tuner: TVF7533-MF */ 1262 /* P/N: SA 60002070465 Tuner: TVF7533-MF */
1284 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF}, 1263 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1264 {0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1285}; 1265};
1286 1266
1287/* I2C devicelist hash table for devices with generic USB IDs */ 1267/* I2C devicelist hash table for devices with generic USB IDs */
@@ -1552,9 +1532,12 @@ static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
1552 /* djh - Not sure which demod we need here */ 1532 /* djh - Not sure which demod we need here */
1553 ctl->demod = XC3028_FE_DEFAULT; 1533 ctl->demod = XC3028_FE_DEFAULT;
1554 break; 1534 break;
1535 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1536 ctl->demod = XC3028_FE_DEFAULT;
1537 ctl->fname = XC3028L_DEFAULT_FIRMWARE;
1538 break;
1555 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: 1539 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1556 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: 1540 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1557 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1558 /* FIXME: Better to specify the needed IF */ 1541 /* FIXME: Better to specify the needed IF */
1559 ctl->demod = XC3028_FE_DEFAULT; 1542 ctl->demod = XC3028_FE_DEFAULT;
1560 break; 1543 break;
@@ -1764,6 +1747,20 @@ void em28xx_card_setup(struct em28xx *dev)
1764 break; 1747 break;
1765 case EM2820_BOARD_UNKNOWN: 1748 case EM2820_BOARD_UNKNOWN:
1766 case EM2800_BOARD_UNKNOWN: 1749 case EM2800_BOARD_UNKNOWN:
1750 /*
1751 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
1752 *
1753 * This occurs because they share identical USB vendor and
1754 * product IDs.
1755 *
1756 * What we do here is look up the EEPROM hash of the K-WORLD
1757 * and if it is found then we decide that we do not have
1758 * a DIGIVOX and reset the device to the K-WORLD instead.
1759 *
1760 * This solution is only valid if they do not share eeprom
1761 * hash identities which has not been determined as yet.
1762 */
1763 case EM2880_BOARD_MSI_DIGIVOX_AD:
1767 if (!em28xx_hint_board(dev)) 1764 if (!em28xx_hint_board(dev))
1768 em28xx_set_model(dev); 1765 em28xx_set_model(dev);
1769 break; 1766 break;
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index 4b992bc0083c..d2b1a1a52689 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -452,6 +452,15 @@ static int dvb_init(struct em28xx *dev)
452 goto out_free; 452 goto out_free;
453 } 453 }
454 break; 454 break;
455 case EM2880_BOARD_KWORLD_DVB_310U:
456 dvb->frontend = dvb_attach(zl10353_attach,
457 &em28xx_zl10353_with_xc3028,
458 &dev->i2c_adap);
459 if (attach_xc3028(0x61, dev) < 0) {
460 result = -EINVAL;
461 goto out_free;
462 }
463 break;
455 default: 464 default:
456 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" 465 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card"
457 " isn't supported yet\n", 466 " isn't supported yet\n",
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 7be69284da03..ac95c55887df 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -459,6 +459,7 @@ static int create_urbs(struct gspca_dev *gspca_dev,
459 urb = usb_alloc_urb(npkt, GFP_KERNEL); 459 urb = usb_alloc_urb(npkt, GFP_KERNEL);
460 if (!urb) { 460 if (!urb) {
461 err("usb_alloc_urb failed"); 461 err("usb_alloc_urb failed");
462 destroy_urbs(gspca_dev);
462 return -ENOMEM; 463 return -ENOMEM;
463 } 464 }
464 urb->transfer_buffer = usb_buffer_alloc(gspca_dev->dev, 465 urb->transfer_buffer = usb_buffer_alloc(gspca_dev->dev,
@@ -468,8 +469,8 @@ static int create_urbs(struct gspca_dev *gspca_dev,
468 469
469 if (urb->transfer_buffer == NULL) { 470 if (urb->transfer_buffer == NULL) {
470 usb_free_urb(urb); 471 usb_free_urb(urb);
471 destroy_urbs(gspca_dev);
472 err("usb_buffer_urb failed"); 472 err("usb_buffer_urb failed");
473 destroy_urbs(gspca_dev);
473 return -ENOMEM; 474 return -ENOMEM;
474 } 475 }
475 gspca_dev->urb[n] = urb; 476 gspca_dev->urb[n] = urb;
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index d4be51843286..ba865b7f1ed8 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -1063,6 +1063,7 @@ static __devinitdata struct usb_device_id device_table[] = {
1063 {USB_DEVICE(0x093a, 0x2621), .driver_info = SENSOR_PAC7302}, 1063 {USB_DEVICE(0x093a, 0x2621), .driver_info = SENSOR_PAC7302},
1064 {USB_DEVICE(0x093a, 0x2624), .driver_info = SENSOR_PAC7302}, 1064 {USB_DEVICE(0x093a, 0x2624), .driver_info = SENSOR_PAC7302},
1065 {USB_DEVICE(0x093a, 0x2626), .driver_info = SENSOR_PAC7302}, 1065 {USB_DEVICE(0x093a, 0x2626), .driver_info = SENSOR_PAC7302},
1066 {USB_DEVICE(0x093a, 0x262a), .driver_info = SENSOR_PAC7302},
1066 {} 1067 {}
1067}; 1068};
1068MODULE_DEVICE_TABLE(usb, device_table); 1069MODULE_DEVICE_TABLE(usb, device_table);
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index 5dd78c6766ea..12b81ae526b7 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -232,7 +232,7 @@ static struct ctrl sd_ctrls[] = {
232static struct v4l2_pix_format vga_mode[] = { 232static struct v4l2_pix_format vga_mode[] = {
233 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 233 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
234 .bytesperline = 160, 234 .bytesperline = 160,
235 .sizeimage = 160 * 120 * 5 / 4, 235 .sizeimage = 160 * 120,
236 .colorspace = V4L2_COLORSPACE_SRGB, 236 .colorspace = V4L2_COLORSPACE_SRGB,
237 .priv = 2 | MODE_RAW}, 237 .priv = 2 | MODE_RAW},
238 {160, 120, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, 238 {160, 120, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE,
@@ -264,7 +264,7 @@ static struct v4l2_pix_format sif_mode[] = {
264 .priv = 1 | MODE_REDUCED_SIF}, 264 .priv = 1 | MODE_REDUCED_SIF},
265 {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 265 {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
266 .bytesperline = 176, 266 .bytesperline = 176,
267 .sizeimage = 176 * 144 * 5 / 4, 267 .sizeimage = 176 * 144,
268 .colorspace = V4L2_COLORSPACE_SRGB, 268 .colorspace = V4L2_COLORSPACE_SRGB,
269 .priv = 1 | MODE_RAW}, 269 .priv = 1 | MODE_RAW},
270 {176, 144, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, 270 {176, 144, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE,
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index d75b1d20b318..572b0f363b64 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -707,6 +707,7 @@ static void i2c_w8(struct gspca_dev *gspca_dev,
707 0x08, 0, /* value, index */ 707 0x08, 0, /* value, index */
708 gspca_dev->usb_buf, 8, 708 gspca_dev->usb_buf, 8,
709 500); 709 500);
710 msleep(2);
710} 711}
711 712
712/* read 5 bytes in gspca_dev->usb_buf */ 713/* read 5 bytes in gspca_dev->usb_buf */
@@ -976,13 +977,13 @@ static int sd_init(struct gspca_dev *gspca_dev)
976 case BRIDGE_SN9C105: 977 case BRIDGE_SN9C105:
977 if (regF1 != 0x11) 978 if (regF1 != 0x11)
978 return -ENODEV; 979 return -ENODEV;
979 reg_w(gspca_dev, 0x02, regGpio, 2); 980 reg_w(gspca_dev, 0x01, regGpio, 2);
980 break; 981 break;
981 case BRIDGE_SN9C120: 982 case BRIDGE_SN9C120:
982 if (regF1 != 0x12) 983 if (regF1 != 0x12)
983 return -ENODEV; 984 return -ENODEV;
984 regGpio[1] = 0x70; 985 regGpio[1] = 0x70;
985 reg_w(gspca_dev, 0x02, regGpio, 2); 986 reg_w(gspca_dev, 0x01, regGpio, 2);
986 break; 987 break;
987 default: 988 default:
988/* case BRIDGE_SN9C110: */ 989/* case BRIDGE_SN9C110: */
@@ -1183,7 +1184,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
1183 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; 1184 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1184 static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ 1185 static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1185 static const __u8 CE_ov76xx[] = 1186 static const __u8 CE_ov76xx[] =
1186 { 0x32, 0xdd, 0x32, 0xdd }; /* OV7630/48 */ 1187 { 0x32, 0xdd, 0x32, 0xdd };
1187 1188
1188 sn9c1xx = sn_tb[(int) sd->sensor]; 1189 sn9c1xx = sn_tb[(int) sd->sensor];
1189 configure_gpio(gspca_dev, sn9c1xx); 1190 configure_gpio(gspca_dev, sn9c1xx);
@@ -1223,8 +1224,15 @@ static void sd_start(struct gspca_dev *gspca_dev)
1223 reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def); 1224 reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def);
1224 for (i = 0; i < 8; i++) 1225 for (i = 0; i < 8; i++)
1225 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 1226 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1227 switch (sd->sensor) {
1228 case SENSOR_OV7660:
1229 reg_w1(gspca_dev, 0x9a, 0x05);
1230 break;
1231 default:
1226 reg_w1(gspca_dev, 0x9a, 0x08); 1232 reg_w1(gspca_dev, 0x9a, 0x08);
1227 reg_w1(gspca_dev, 0x99, 0x59); 1233 reg_w1(gspca_dev, 0x99, 0x59);
1234 break;
1235 }
1228 1236
1229 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 1237 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1230 if (mode) 1238 if (mode)
@@ -1275,8 +1283,8 @@ static void sd_start(struct gspca_dev *gspca_dev)
1275/* reg1 = 0x44; */ 1283/* reg1 = 0x44; */
1276/* reg1 = 0x46; (done) */ 1284/* reg1 = 0x46; (done) */
1277 } else { 1285 } else {
1278 reg17 = 0x22; /* 640 MCKSIZE */ 1286 reg17 = 0xa2; /* 640 */
1279 reg1 = 0x06; 1287 reg1 = 0x44;
1280 } 1288 }
1281 break; 1289 break;
1282 } 1290 }
@@ -1285,6 +1293,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
1285 switch (sd->sensor) { 1293 switch (sd->sensor) {
1286 case SENSOR_OV7630: 1294 case SENSOR_OV7630:
1287 case SENSOR_OV7648: 1295 case SENSOR_OV7648:
1296 case SENSOR_OV7660:
1288 reg_w(gspca_dev, 0xce, CE_ov76xx, 4); 1297 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
1289 break; 1298 break;
1290 default: 1299 default:
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index cfbc9ebc5c5d..95fcfcb9e31b 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -225,7 +225,7 @@ static int i2c_read(struct gspca_dev *gspca_dev, __u16 reg, __u8 mode)
225 reg_w_val(gspca_dev->dev, 0x8802, (mode | 0x01)); 225 reg_w_val(gspca_dev->dev, 0x8802, (mode | 0x01));
226 do { 226 do {
227 reg_r(gspca_dev, 0x8803, 1); 227 reg_r(gspca_dev, 0x8803, 1);
228 if (!gspca_dev->usb_buf) 228 if (!gspca_dev->usb_buf[0])
229 break; 229 break;
230 } while (--retry); 230 } while (--retry);
231 if (retry == 0) 231 if (retry == 0)
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 8d7c27e6ac77..d61ef727e0c2 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -6576,8 +6576,8 @@ static int setlightfreq(struct gspca_dev *gspca_dev)
6576 cs2102_60HZ, cs2102_60HZScale}, 6576 cs2102_60HZ, cs2102_60HZScale},
6577/* SENSOR_CS2102K 1 */ 6577/* SENSOR_CS2102K 1 */
6578 {cs2102_NoFliker, cs2102_NoFlikerScale, 6578 {cs2102_NoFliker, cs2102_NoFlikerScale,
6579 cs2102_50HZ, cs2102_50HZScale, 6579 NULL, NULL, /* currently disabled */
6580 cs2102_60HZ, cs2102_60HZScale}, 6580 NULL, NULL},
6581/* SENSOR_GC0305 2 */ 6581/* SENSOR_GC0305 2 */
6582 {gc0305_NoFliker, gc0305_NoFliker, 6582 {gc0305_NoFliker, gc0305_NoFliker,
6583 gc0305_50HZ, gc0305_50HZ, 6583 gc0305_50HZ, gc0305_50HZ,
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index 3d3c48db45d9..c6852402c5e9 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -3591,7 +3591,7 @@ static int
3591ov51x_init_isoc(struct usb_ov511 *ov) 3591ov51x_init_isoc(struct usb_ov511 *ov)
3592{ 3592{
3593 struct urb *urb; 3593 struct urb *urb;
3594 int fx, err, n, size; 3594 int fx, err, n, i, size;
3595 3595
3596 PDEBUG(3, "*** Initializing capture ***"); 3596 PDEBUG(3, "*** Initializing capture ***");
3597 3597
@@ -3662,6 +3662,8 @@ ov51x_init_isoc(struct usb_ov511 *ov)
3662 urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL); 3662 urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL);
3663 if (!urb) { 3663 if (!urb) {
3664 err("init isoc: usb_alloc_urb ret. NULL"); 3664 err("init isoc: usb_alloc_urb ret. NULL");
3665 for (i = 0; i < n; i++)
3666 usb_free_urb(ov->sbuf[i].urb);
3665 return -ENOMEM; 3667 return -ENOMEM;
3666 } 3668 }
3667 ov->sbuf[n].urb = urb; 3669 ov->sbuf[n].urb = urb;
@@ -5651,7 +5653,7 @@ static ssize_t show_exposure(struct device *cd,
5651 if (!ov->dev) 5653 if (!ov->dev)
5652 return -ENODEV; 5654 return -ENODEV;
5653 sensor_get_exposure(ov, &exp); 5655 sensor_get_exposure(ov, &exp);
5654 return sprintf(buf, "%d\n", exp >> 8); 5656 return sprintf(buf, "%d\n", exp);
5655} 5657}
5656static DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL); 5658static DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
5657 5659
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.c b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
index 88e175168438..cbe2a3417851 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-devattr.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
@@ -489,6 +489,8 @@ static const struct pvr2_device_desc pvr2_device_751xx = {
489struct usb_device_id pvr2_device_table[] = { 489struct usb_device_id pvr2_device_table[] = {
490 { USB_DEVICE(0x2040, 0x2900), 490 { USB_DEVICE(0x2040, 0x2900),
491 .driver_info = (kernel_ulong_t)&pvr2_device_29xxx}, 491 .driver_info = (kernel_ulong_t)&pvr2_device_29xxx},
492 { USB_DEVICE(0x2040, 0x2950), /* Logically identical to 2900 */
493 .driver_info = (kernel_ulong_t)&pvr2_device_29xxx},
492 { USB_DEVICE(0x2040, 0x2400), 494 { USB_DEVICE(0x2040, 0x2400),
493 .driver_info = (kernel_ulong_t)&pvr2_device_24xxx}, 495 .driver_info = (kernel_ulong_t)&pvr2_device_24xxx},
494 { USB_DEVICE(0x1164, 0x0622), 496 { USB_DEVICE(0x1164, 0x0622),
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index b1d09d8e2b85..92b83feae366 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -669,7 +669,7 @@ static void s2255_fillbuff(struct s2255_dev *dev, struct s2255_buffer *buf,
669 (unsigned long)vbuf, pos); 669 (unsigned long)vbuf, pos);
670 /* tell v4l buffer was filled */ 670 /* tell v4l buffer was filled */
671 671
672 buf->vb.field_count++; 672 buf->vb.field_count = dev->frame_count[chn] * 2;
673 do_gettimeofday(&ts); 673 do_gettimeofday(&ts);
674 buf->vb.ts = ts; 674 buf->vb.ts = ts;
675 buf->vb.state = VIDEOBUF_DONE; 675 buf->vb.state = VIDEOBUF_DONE;
@@ -1268,6 +1268,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1268 dev->last_frame[chn] = -1; 1268 dev->last_frame[chn] = -1;
1269 dev->bad_payload[chn] = 0; 1269 dev->bad_payload[chn] = 0;
1270 dev->cur_frame[chn] = 0; 1270 dev->cur_frame[chn] = 0;
1271 dev->frame_count[chn] = 0;
1271 for (j = 0; j < SYS_FRAMES; j++) { 1272 for (j = 0; j < SYS_FRAMES; j++) {
1272 dev->buffer[chn].frame[j].ulState = 0; 1273 dev->buffer[chn].frame[j].ulState = 0;
1273 dev->buffer[chn].frame[j].cur_size = 0; 1274 dev->buffer[chn].frame[j].cur_size = 0;
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index 6ef3e5297de8..feab12aa2c7b 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -592,7 +592,7 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
592 if (ctrl == NULL) 592 if (ctrl == NULL)
593 return -EINVAL; 593 return -EINVAL;
594 594
595 data = kmalloc(8, GFP_KERNEL); 595 data = kmalloc(ctrl->info->size, GFP_KERNEL);
596 if (data == NULL) 596 if (data == NULL)
597 return -ENOMEM; 597 return -ENOMEM;
598 598
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index 168baabe4659..11edf79f57be 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -911,7 +911,6 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
911 911
912 for (i = 0; i < W9968CF_URBS; i++) { 912 for (i = 0; i < W9968CF_URBS; i++) {
913 urb = usb_alloc_urb(W9968CF_ISO_PACKETS, GFP_KERNEL); 913 urb = usb_alloc_urb(W9968CF_ISO_PACKETS, GFP_KERNEL);
914 cam->urb[i] = urb;
915 if (!urb) { 914 if (!urb) {
916 for (j = 0; j < i; j++) 915 for (j = 0; j < i; j++)
917 usb_free_urb(cam->urb[j]); 916 usb_free_urb(cam->urb[j]);
@@ -919,6 +918,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
919 return -ENOMEM; 918 return -ENOMEM;
920 } 919 }
921 920
921 cam->urb[i] = urb;
922 urb->dev = udev; 922 urb->dev = udev;
923 urb->context = (void*)cam; 923 urb->context = (void*)cam;
924 urb->pipe = usb_rcvisocpipe(udev, 1); 924 urb->pipe = usb_rcvisocpipe(udev, 1);
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index 95c79ad80487..54ac3fe26ec2 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -274,10 +274,8 @@ static int wm8739_probe(struct i2c_client *client,
274 client->addr << 1, client->adapter->name); 274 client->addr << 1, client->adapter->name);
275 275
276 state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL); 276 state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL);
277 if (state == NULL) { 277 if (state == NULL)
278 kfree(client);
279 return -ENOMEM; 278 return -ENOMEM;
280 }
281 state->vol_l = 0x17; /* 0dB */ 279 state->vol_l = 0x17; /* 0dB */
282 state->vol_r = 0x17; /* 0dB */ 280 state->vol_r = 0x17; /* 0dB */
283 state->muted = 0; 281 state->muted = 0;
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index d842a7cb99d2..3282be730298 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -988,7 +988,7 @@ zoran_open_init_params (struct zoran *zr)
988 zr->v4l_grab_seq = 0; 988 zr->v4l_grab_seq = 0;
989 zr->v4l_settings.width = 192; 989 zr->v4l_settings.width = 192;
990 zr->v4l_settings.height = 144; 990 zr->v4l_settings.height = 144;
991 zr->v4l_settings.format = &zoran_formats[4]; /* YUY2 - YUV-4:2:2 packed */ 991 zr->v4l_settings.format = &zoran_formats[7]; /* YUY2 - YUV-4:2:2 packed */
992 zr->v4l_settings.bytesperline = 992 zr->v4l_settings.bytesperline =
993 zr->v4l_settings.width * 993 zr->v4l_settings.width *
994 ((zr->v4l_settings.format->depth + 7) / 8); 994 ((zr->v4l_settings.format->depth + 7) / 8);
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index ec6f59674b10..2dab9eea4def 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -134,7 +134,7 @@ const struct zoran_format zoran_formats[] = {
134 }, { 134 }, {
135 .name = "16-bit RGB BE", 135 .name = "16-bit RGB BE",
136 ZFMT(-1, 136 ZFMT(-1,
137 V4L2_PIX_FMT_RGB565, V4L2_COLORSPACE_SRGB), 137 V4L2_PIX_FMT_RGB565X, V4L2_COLORSPACE_SRGB),
138 .depth = 16, 138 .depth = 16,
139 .flags = ZORAN_FORMAT_CAPTURE | 139 .flags = ZORAN_FORMAT_CAPTURE |
140 ZORAN_FORMAT_OVERLAY, 140 ZORAN_FORMAT_OVERLAY,
@@ -2737,7 +2737,8 @@ zoran_do_ioctl (struct inode *inode,
2737 fh->v4l_settings.format->fourcc; 2737 fh->v4l_settings.format->fourcc;
2738 fmt->fmt.pix.colorspace = 2738 fmt->fmt.pix.colorspace =
2739 fh->v4l_settings.format->colorspace; 2739 fh->v4l_settings.format->colorspace;
2740 fmt->fmt.pix.bytesperline = 0; 2740 fmt->fmt.pix.bytesperline =
2741 fh->v4l_settings.bytesperline;
2741 if (BUZ_MAX_HEIGHT < 2742 if (BUZ_MAX_HEIGHT <
2742 (fh->v4l_settings.height * 2)) 2743 (fh->v4l_settings.height * 2))
2743 fmt->fmt.pix.field = 2744 fmt->fmt.pix.field =
@@ -2833,13 +2834,6 @@ zoran_do_ioctl (struct inode *inode,
2833 fmt->fmt.pix.pixelformat, 2834 fmt->fmt.pix.pixelformat,
2834 (char *) &printformat); 2835 (char *) &printformat);
2835 2836
2836 if (fmt->fmt.pix.bytesperline > 0) {
2837 dprintk(5,
2838 KERN_ERR "%s: bpl not supported\n",
2839 ZR_DEVNAME(zr));
2840 return -EINVAL;
2841 }
2842
2843 /* we can be requested to do JPEG/raw playback/capture */ 2837 /* we can be requested to do JPEG/raw playback/capture */
2844 if (! 2838 if (!
2845 (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE || 2839 (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE ||
@@ -2923,6 +2917,7 @@ zoran_do_ioctl (struct inode *inode,
2923 fh->jpg_buffers.buffer_size = 2917 fh->jpg_buffers.buffer_size =
2924 zoran_v4l2_calc_bufsize(&fh-> 2918 zoran_v4l2_calc_bufsize(&fh->
2925 jpg_settings); 2919 jpg_settings);
2920 fmt->fmt.pix.bytesperline = 0;
2926 fmt->fmt.pix.sizeimage = 2921 fmt->fmt.pix.sizeimage =
2927 fh->jpg_buffers.buffer_size; 2922 fh->jpg_buffers.buffer_size;
2928 2923
@@ -2979,6 +2974,8 @@ zoran_do_ioctl (struct inode *inode,
2979 2974
2980 /* tell the user the 2975 /* tell the user the
2981 * results/missing stuff */ 2976 * results/missing stuff */
2977 fmt->fmt.pix.bytesperline =
2978 fh->v4l_settings.bytesperline;
2982 fmt->fmt.pix.sizeimage = 2979 fmt->fmt.pix.sizeimage =
2983 fh->v4l_settings.height * 2980 fh->v4l_settings.height *
2984 fh->v4l_settings.bytesperline; 2981 fh->v4l_settings.bytesperline;
diff --git a/drivers/misc/eeepc-laptop.c b/drivers/misc/eeepc-laptop.c
index facdb9893c84..1ee8501e90f1 100644
--- a/drivers/misc/eeepc-laptop.c
+++ b/drivers/misc/eeepc-laptop.c
@@ -450,12 +450,14 @@ static int eeepc_get_fan_pwm(void)
450 int value = 0; 450 int value = 0;
451 451
452 read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value); 452 read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value);
453 value = value * 255 / 100;
453 return (value); 454 return (value);
454} 455}
455 456
456static void eeepc_set_fan_pwm(int value) 457static void eeepc_set_fan_pwm(int value)
457{ 458{
458 value = SENSORS_LIMIT(value, 0, 100); 459 value = SENSORS_LIMIT(value, 0, 255);
460 value = value * 100 / 255;
459 ec_write(EEEPC_EC_SC02, value); 461 ec_write(EEEPC_EC_SC02, value);
460} 462}
461 463
@@ -520,15 +522,23 @@ static ssize_t show_sys_hwmon(int (*get)(void), char *buf)
520 static SENSOR_DEVICE_ATTR(_name, _mode, show_##_name, store_##_name, 0); 522 static SENSOR_DEVICE_ATTR(_name, _mode, show_##_name, store_##_name, 0);
521 523
522EEEPC_CREATE_SENSOR_ATTR(fan1_input, S_IRUGO, eeepc_get_fan_rpm, NULL); 524EEEPC_CREATE_SENSOR_ATTR(fan1_input, S_IRUGO, eeepc_get_fan_rpm, NULL);
523EEEPC_CREATE_SENSOR_ATTR(fan1_pwm, S_IRUGO | S_IWUSR, 525EEEPC_CREATE_SENSOR_ATTR(pwm1, S_IRUGO | S_IWUSR,
524 eeepc_get_fan_pwm, eeepc_set_fan_pwm); 526 eeepc_get_fan_pwm, eeepc_set_fan_pwm);
525EEEPC_CREATE_SENSOR_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, 527EEEPC_CREATE_SENSOR_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
526 eeepc_get_fan_ctrl, eeepc_set_fan_ctrl); 528 eeepc_get_fan_ctrl, eeepc_set_fan_ctrl);
527 529
530static ssize_t
531show_name(struct device *dev, struct device_attribute *attr, char *buf)
532{
533 return sprintf(buf, "eeepc\n");
534}
535static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
536
528static struct attribute *hwmon_attributes[] = { 537static struct attribute *hwmon_attributes[] = {
529 &sensor_dev_attr_fan1_pwm.dev_attr.attr, 538 &sensor_dev_attr_pwm1.dev_attr.attr,
530 &sensor_dev_attr_fan1_input.dev_attr.attr, 539 &sensor_dev_attr_fan1_input.dev_attr.attr,
531 &sensor_dev_attr_pwm1_enable.dev_attr.attr, 540 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
541 &sensor_dev_attr_name.dev_attr.attr,
532 NULL 542 NULL
533}; 543};
534 544
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 917035e16da4..00008967ef7a 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -426,8 +426,6 @@ static u32 atmci_submit_data(struct mmc_host *mmc, struct mmc_data *data)
426 host->sg = NULL; 426 host->sg = NULL;
427 host->data = data; 427 host->data = data;
428 428
429 mci_writel(host, BLKR, MCI_BCNT(data->blocks)
430 | MCI_BLKLEN(data->blksz));
431 dev_vdbg(&mmc->class_dev, "BLKR=0x%08x\n", 429 dev_vdbg(&mmc->class_dev, "BLKR=0x%08x\n",
432 MCI_BCNT(data->blocks) | MCI_BLKLEN(data->blksz)); 430 MCI_BCNT(data->blocks) | MCI_BLKLEN(data->blksz));
433 431
@@ -483,6 +481,10 @@ static void atmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
483 if (data->blocks > 1 && data->blksz & 3) 481 if (data->blocks > 1 && data->blksz & 3)
484 goto fail; 482 goto fail;
485 atmci_set_timeout(host, data); 483 atmci_set_timeout(host, data);
484
485 /* Must set block count/size before sending command */
486 mci_writel(host, BLKR, MCI_BCNT(data->blocks)
487 | MCI_BLKLEN(data->blksz));
486 } 488 }
487 489
488 iflags = MCI_CMDRDY; 490 iflags = MCI_CMDRDY;
diff --git a/drivers/pnp/Makefile b/drivers/pnp/Makefile
index 26f5abc9c3f7..e83f34f1b5ba 100644
--- a/drivers/pnp/Makefile
+++ b/drivers/pnp/Makefile
@@ -2,12 +2,15 @@
2# Makefile for the Linux Plug-and-Play Support. 2# Makefile for the Linux Plug-and-Play Support.
3# 3#
4 4
5obj-y := core.o card.o driver.o resource.o manager.o support.o interface.o quirks.o system.o 5obj-y := core.o card.o driver.o resource.o manager.o support.o interface.o quirks.o
6 6
7obj-$(CONFIG_PNPACPI) += pnpacpi/ 7obj-$(CONFIG_PNPACPI) += pnpacpi/
8obj-$(CONFIG_PNPBIOS) += pnpbios/ 8obj-$(CONFIG_PNPBIOS) += pnpbios/
9obj-$(CONFIG_ISAPNP) += isapnp/ 9obj-$(CONFIG_ISAPNP) += isapnp/
10 10
11# pnp_system_init goes after pnpacpi/pnpbios init
12obj-y += system.o
13
11ifeq ($(CONFIG_PNP_DEBUG),y) 14ifeq ($(CONFIG_PNP_DEBUG),y)
12EXTRA_CFLAGS += -DDEBUG 15EXTRA_CFLAGS += -DDEBUG
13endif 16endif
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index c1b9ea34977b..53561d72b4ee 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -268,7 +268,7 @@ static int __init pnpacpi_init(void)
268 return 0; 268 return 0;
269} 269}
270 270
271subsys_initcall(pnpacpi_init); 271fs_initcall(pnpacpi_init);
272 272
273static int __init pnpacpi_setup(char *str) 273static int __init pnpacpi_setup(char *str)
274{ 274{
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 19a4be1a9a31..662dfcddedc6 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -571,7 +571,7 @@ static int __init pnpbios_init(void)
571 return 0; 571 return 0;
572} 572}
573 573
574subsys_initcall(pnpbios_init); 574fs_initcall(pnpbios_init);
575 575
576static int __init pnpbios_thread_init(void) 576static int __init pnpbios_thread_init(void)
577{ 577{
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 48ee8c7f5bdd..e1872989710a 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -294,10 +294,10 @@ static void sas_ata_post_internal(struct ata_queued_cmd *qc)
294 } 294 }
295} 295}
296 296
297static int sas_ata_scr_write(struct ata_port *ap, unsigned int sc_reg_in, 297static int sas_ata_scr_write(struct ata_link *link, unsigned int sc_reg_in,
298 u32 val) 298 u32 val)
299{ 299{
300 struct domain_device *dev = ap->private_data; 300 struct domain_device *dev = link->ap->private_data;
301 301
302 SAS_DPRINTK("STUB %s\n", __func__); 302 SAS_DPRINTK("STUB %s\n", __func__);
303 switch (sc_reg_in) { 303 switch (sc_reg_in) {
@@ -319,10 +319,10 @@ static int sas_ata_scr_write(struct ata_port *ap, unsigned int sc_reg_in,
319 return 0; 319 return 0;
320} 320}
321 321
322static int sas_ata_scr_read(struct ata_port *ap, unsigned int sc_reg_in, 322static int sas_ata_scr_read(struct ata_link *link, unsigned int sc_reg_in,
323 u32 *val) 323 u32 *val)
324{ 324{
325 struct domain_device *dev = ap->private_data; 325 struct domain_device *dev = link->ap->private_data;
326 326
327 SAS_DPRINTK("STUB %s\n", __func__); 327 SAS_DPRINTK("STUB %s\n", __func__);
328 switch (sc_reg_in) { 328 switch (sc_reg_in) {
diff --git a/fs/splice.c b/fs/splice.c
index 1bbc6f4bb09c..a1e701c27156 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -898,6 +898,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
898 if (unlikely(!(out->f_mode & FMODE_WRITE))) 898 if (unlikely(!(out->f_mode & FMODE_WRITE)))
899 return -EBADF; 899 return -EBADF;
900 900
901 if (unlikely(out->f_flags & O_APPEND))
902 return -EINVAL;
903
901 ret = rw_verify_area(WRITE, out, ppos, len); 904 ret = rw_verify_area(WRITE, out, ppos, len);
902 if (unlikely(ret < 0)) 905 if (unlikely(ret < 0))
903 return ret; 906 return ret;
diff --git a/include/asm-mips/sn/mapped_kernel.h b/include/asm-mips/sn/mapped_kernel.h
index c3dd5d0d525f..721496a0bb92 100644
--- a/include/asm-mips/sn/mapped_kernel.h
+++ b/include/asm-mips/sn/mapped_kernel.h
@@ -5,6 +5,8 @@
5#ifndef __ASM_SN_MAPPED_KERNEL_H 5#ifndef __ASM_SN_MAPPED_KERNEL_H
6#define __ASM_SN_MAPPED_KERNEL_H 6#define __ASM_SN_MAPPED_KERNEL_H
7 7
8#include <linux/mmzone.h>
9
8/* 10/*
9 * Note on how mapped kernels work: the text and data section is 11 * Note on how mapped kernels work: the text and data section is
10 * compiled at cksseg segment (LOADADDR = 0xc001c000), and the 12 * compiled at cksseg segment (LOADADDR = 0xc001c000), and the
@@ -29,10 +31,8 @@
29#define MAPPED_ADDR_RO_TO_PHYS(x) (x - REP_BASE) 31#define MAPPED_ADDR_RO_TO_PHYS(x) (x - REP_BASE)
30#define MAPPED_ADDR_RW_TO_PHYS(x) (x - REP_BASE - 16777216) 32#define MAPPED_ADDR_RW_TO_PHYS(x) (x - REP_BASE - 16777216)
31 33
32#define MAPPED_KERN_RO_PHYSBASE(n) \ 34#define MAPPED_KERN_RO_PHYSBASE(n) (hub_data(n)->kern_vars.kv_ro_baseaddr)
33 (PLAT_NODE_DATA(n)->kern_vars.kv_ro_baseaddr) 35#define MAPPED_KERN_RW_PHYSBASE(n) (hub_data(n)->kern_vars.kv_rw_baseaddr)
34#define MAPPED_KERN_RW_PHYSBASE(n) \
35 (PLAT_NODE_DATA(n)->kern_vars.kv_rw_baseaddr)
36 36
37#define MAPPED_KERN_RO_TO_PHYS(x) \ 37#define MAPPED_KERN_RO_TO_PHYS(x) \
38 ((unsigned long)MAPPED_ADDR_RO_TO_PHYS(x) | \ 38 ((unsigned long)MAPPED_ADDR_RO_TO_PHYS(x) | \
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 8a12d718c169..a26ebd25bac1 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -667,6 +667,15 @@ static inline int ata_id_has_dword_io(const u16 *id)
667 return 0; 667 return 0;
668} 668}
669 669
670static inline int ata_id_has_unload(const u16 *id)
671{
672 if (ata_id_major_version(id) >= 7 &&
673 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 &&
674 id[ATA_ID_CFSSE] & (1 << 13))
675 return 1;
676 return 0;
677}
678
670static inline int ata_id_current_chs_valid(const u16 *id) 679static inline int ata_id_current_chs_valid(const u16 *id)
671{ 680{
672 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command 681 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 1524829f73f2..6514db8fd2e4 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -366,7 +366,9 @@ enum {
366 /* Currently on a filemark */ 366 /* Currently on a filemark */
367 IDE_AFLAG_FILEMARK = (1 << 25), 367 IDE_AFLAG_FILEMARK = (1 << 25),
368 /* 0 = no tape is loaded, so we don't rewind after ejecting */ 368 /* 0 = no tape is loaded, so we don't rewind after ejecting */
369 IDE_AFLAG_MEDIUM_PRESENT = (1 << 26) 369 IDE_AFLAG_MEDIUM_PRESENT = (1 << 26),
370
371 IDE_AFLAG_NO_AUTOCLOSE = (1 << 27),
370}; 372};
371 373
372struct ide_drive_s { 374struct ide_drive_s {
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 225bfc5bd9ec..947cf84e555d 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -146,6 +146,7 @@ enum {
146 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ 146 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */
147 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ 147 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
148 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */ 148 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */
149 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */
149 ATA_DFLAG_INIT_MASK = (1 << 24) - 1, 150 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
150 151
151 ATA_DFLAG_DETACH = (1 << 24), 152 ATA_DFLAG_DETACH = (1 << 24),
@@ -244,6 +245,7 @@ enum {
244 ATA_TMOUT_BOOT = 30000, /* heuristic */ 245 ATA_TMOUT_BOOT = 30000, /* heuristic */
245 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */ 246 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */
246 ATA_TMOUT_INTERNAL_QUICK = 5000, 247 ATA_TMOUT_INTERNAL_QUICK = 5000,
248 ATA_TMOUT_MAX_PARK = 30000,
247 249
248 /* FIXME: GoVault needs 2s but we can't afford that without 250 /* FIXME: GoVault needs 2s but we can't afford that without
249 * parallel probing. 800ms is enough for iVDR disk 251 * parallel probing. 800ms is enough for iVDR disk
@@ -319,8 +321,11 @@ enum {
319 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, 321 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
320 ATA_EH_ENABLE_LINK = (1 << 3), 322 ATA_EH_ENABLE_LINK = (1 << 3),
321 ATA_EH_LPM = (1 << 4), /* link power management action */ 323 ATA_EH_LPM = (1 << 4), /* link power management action */
324 ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */
322 325
323 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, 326 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK,
327 ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET |
328 ATA_EH_ENABLE_LINK | ATA_EH_LPM,
324 329
325 /* ata_eh_info->flags */ 330 /* ata_eh_info->flags */
326 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ 331 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
@@ -452,6 +457,7 @@ enum link_pm {
452 MEDIUM_POWER, 457 MEDIUM_POWER,
453}; 458};
454extern struct device_attribute dev_attr_link_power_management_policy; 459extern struct device_attribute dev_attr_link_power_management_policy;
460extern struct device_attribute dev_attr_unload_heads;
455extern struct device_attribute dev_attr_em_message_type; 461extern struct device_attribute dev_attr_em_message_type;
456extern struct device_attribute dev_attr_em_message; 462extern struct device_attribute dev_attr_em_message;
457extern struct device_attribute dev_attr_sw_activity; 463extern struct device_attribute dev_attr_sw_activity;
@@ -554,8 +560,8 @@ struct ata_ering {
554struct ata_device { 560struct ata_device {
555 struct ata_link *link; 561 struct ata_link *link;
556 unsigned int devno; /* 0 or 1 */ 562 unsigned int devno; /* 0 or 1 */
557 unsigned long flags; /* ATA_DFLAG_xxx */
558 unsigned int horkage; /* List of broken features */ 563 unsigned int horkage; /* List of broken features */
564 unsigned long flags; /* ATA_DFLAG_xxx */
559 struct scsi_device *sdev; /* attached SCSI device */ 565 struct scsi_device *sdev; /* attached SCSI device */
560#ifdef CONFIG_ATA_ACPI 566#ifdef CONFIG_ATA_ACPI
561 acpi_handle acpi_handle; 567 acpi_handle acpi_handle;
@@ -564,6 +570,7 @@ struct ata_device {
564 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ 570 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
565 u64 n_sectors; /* size of device, if ATA */ 571 u64 n_sectors; /* size of device, if ATA */
566 unsigned int class; /* ATA_DEV_xxx */ 572 unsigned int class; /* ATA_DEV_xxx */
573 unsigned long unpark_deadline;
567 574
568 u8 pio_mode; 575 u8 pio_mode;
569 u8 dma_mode; 576 u8 dma_mode;
@@ -621,6 +628,7 @@ struct ata_eh_context {
621 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE]; 628 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
622 unsigned int classes[ATA_MAX_DEVICES]; 629 unsigned int classes[ATA_MAX_DEVICES];
623 unsigned int did_probe_mask; 630 unsigned int did_probe_mask;
631 unsigned int unloaded_mask;
624 unsigned int saved_ncq_enabled; 632 unsigned int saved_ncq_enabled;
625 u8 saved_xfer_mode[ATA_MAX_DEVICES]; 633 u8 saved_xfer_mode[ATA_MAX_DEVICES];
626 /* timestamp for the last reset attempt or success */ 634 /* timestamp for the last reset attempt or success */
@@ -688,7 +696,8 @@ struct ata_port {
688 unsigned int qc_active; 696 unsigned int qc_active;
689 int nr_active_links; /* #links with active qcs */ 697 int nr_active_links; /* #links with active qcs */
690 698
691 struct ata_link link; /* host default link */ 699 struct ata_link link; /* host default link */
700 struct ata_link *slave_link; /* see ata_slave_link_init() */
692 701
693 int nr_pmp_links; /* nr of available PMP links */ 702 int nr_pmp_links; /* nr of available PMP links */
694 struct ata_link *pmp_link; /* array of PMP links */ 703 struct ata_link *pmp_link; /* array of PMP links */
@@ -709,6 +718,7 @@ struct ata_port {
709 struct list_head eh_done_q; 718 struct list_head eh_done_q;
710 wait_queue_head_t eh_wait_q; 719 wait_queue_head_t eh_wait_q;
711 int eh_tries; 720 int eh_tries;
721 struct completion park_req_pending;
712 722
713 pm_message_t pm_mesg; 723 pm_message_t pm_mesg;
714 int *pm_result; 724 int *pm_result;
@@ -772,8 +782,8 @@ struct ata_port_operations {
772 /* 782 /*
773 * Optional features 783 * Optional features
774 */ 784 */
775 int (*scr_read)(struct ata_port *ap, unsigned int sc_reg, u32 *val); 785 int (*scr_read)(struct ata_link *link, unsigned int sc_reg, u32 *val);
776 int (*scr_write)(struct ata_port *ap, unsigned int sc_reg, u32 val); 786 int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val);
777 void (*pmp_attach)(struct ata_port *ap); 787 void (*pmp_attach)(struct ata_port *ap);
778 void (*pmp_detach)(struct ata_port *ap); 788 void (*pmp_detach)(struct ata_port *ap);
779 int (*enable_pm)(struct ata_port *ap, enum link_pm policy); 789 int (*enable_pm)(struct ata_port *ap, enum link_pm policy);
@@ -895,6 +905,7 @@ extern void ata_port_disable(struct ata_port *);
895extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); 905extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
896extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, 906extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
897 const struct ata_port_info * const * ppi, int n_ports); 907 const struct ata_port_info * const * ppi, int n_ports);
908extern int ata_slave_link_init(struct ata_port *ap);
898extern int ata_host_start(struct ata_host *host); 909extern int ata_host_start(struct ata_host *host);
899extern int ata_host_register(struct ata_host *host, 910extern int ata_host_register(struct ata_host *host,
900 struct scsi_host_template *sht); 911 struct scsi_host_template *sht);
@@ -920,8 +931,8 @@ extern int sata_scr_valid(struct ata_link *link);
920extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); 931extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
921extern int sata_scr_write(struct ata_link *link, int reg, u32 val); 932extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
922extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val); 933extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val);
923extern int ata_link_online(struct ata_link *link); 934extern bool ata_link_online(struct ata_link *link);
924extern int ata_link_offline(struct ata_link *link); 935extern bool ata_link_offline(struct ata_link *link);
925#ifdef CONFIG_PM 936#ifdef CONFIG_PM
926extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); 937extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
927extern void ata_host_resume(struct ata_host *host); 938extern void ata_host_resume(struct ata_host *host);
@@ -1098,6 +1109,7 @@ extern void ata_std_error_handler(struct ata_port *ap);
1098 */ 1109 */
1099extern const struct ata_port_operations ata_base_port_ops; 1110extern const struct ata_port_operations ata_base_port_ops;
1100extern const struct ata_port_operations sata_port_ops; 1111extern const struct ata_port_operations sata_port_ops;
1112extern struct device_attribute *ata_common_sdev_attrs[];
1101 1113
1102#define ATA_BASE_SHT(drv_name) \ 1114#define ATA_BASE_SHT(drv_name) \
1103 .module = THIS_MODULE, \ 1115 .module = THIS_MODULE, \
@@ -1112,7 +1124,8 @@ extern const struct ata_port_operations sata_port_ops;
1112 .proc_name = drv_name, \ 1124 .proc_name = drv_name, \
1113 .slave_configure = ata_scsi_slave_config, \ 1125 .slave_configure = ata_scsi_slave_config, \
1114 .slave_destroy = ata_scsi_slave_destroy, \ 1126 .slave_destroy = ata_scsi_slave_destroy, \
1115 .bios_param = ata_std_bios_param 1127 .bios_param = ata_std_bios_param, \
1128 .sdev_attrs = ata_common_sdev_attrs
1116 1129
1117#define ATA_NCQ_SHT(drv_name) \ 1130#define ATA_NCQ_SHT(drv_name) \
1118 ATA_BASE_SHT(drv_name), \ 1131 ATA_BASE_SHT(drv_name), \
@@ -1134,7 +1147,7 @@ static inline bool sata_pmp_attached(struct ata_port *ap)
1134 1147
1135static inline int ata_is_host_link(const struct ata_link *link) 1148static inline int ata_is_host_link(const struct ata_link *link)
1136{ 1149{
1137 return link == &link->ap->link; 1150 return link == &link->ap->link || link == link->ap->slave_link;
1138} 1151}
1139#else /* CONFIG_SATA_PMP */ 1152#else /* CONFIG_SATA_PMP */
1140static inline bool sata_pmp_supported(struct ata_port *ap) 1153static inline bool sata_pmp_supported(struct ata_port *ap)
@@ -1167,7 +1180,7 @@ static inline int sata_srst_pmp(struct ata_link *link)
1167 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) 1180 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
1168 1181
1169#define ata_link_printk(link, lv, fmt, args...) do { \ 1182#define ata_link_printk(link, lv, fmt, args...) do { \
1170 if (sata_pmp_attached((link)->ap)) \ 1183 if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \
1171 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ 1184 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
1172 (link)->pmp , ##args); \ 1185 (link)->pmp , ##args); \
1173 else \ 1186 else \
@@ -1265,34 +1278,17 @@ static inline int ata_link_active(struct ata_link *link)
1265 return ata_tag_valid(link->active_tag) || link->sactive; 1278 return ata_tag_valid(link->active_tag) || link->sactive;
1266} 1279}
1267 1280
1268static inline struct ata_link *ata_port_first_link(struct ata_port *ap) 1281extern struct ata_link *__ata_port_next_link(struct ata_port *ap,
1269{ 1282 struct ata_link *link,
1270 if (sata_pmp_attached(ap)) 1283 bool dev_only);
1271 return ap->pmp_link;
1272 return &ap->link;
1273}
1274
1275static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1276{
1277 struct ata_port *ap = link->ap;
1278
1279 if (ata_is_host_link(link)) {
1280 if (!sata_pmp_attached(ap))
1281 return NULL;
1282 return ap->pmp_link;
1283 }
1284
1285 if (++link < ap->nr_pmp_links + ap->pmp_link)
1286 return link;
1287 return NULL;
1288}
1289 1284
1290#define __ata_port_for_each_link(lk, ap) \ 1285#define __ata_port_for_each_link(link, ap) \
1291 for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk)) 1286 for ((link) = __ata_port_next_link((ap), NULL, false); (link); \
1287 (link) = __ata_port_next_link((ap), (link), false))
1292 1288
1293#define ata_port_for_each_link(link, ap) \ 1289#define ata_port_for_each_link(link, ap) \
1294 for ((link) = ata_port_first_link(ap); (link); \ 1290 for ((link) = __ata_port_next_link((ap), NULL, true); (link); \
1295 (link) = ata_port_next_link(link)) 1291 (link) = __ata_port_next_link((ap), (link), true))
1296 1292
1297#define ata_link_for_each_dev(dev, link) \ 1293#define ata_link_for_each_dev(dev, link) \
1298 for ((dev) = (link)->device; \ 1294 for ((dev) = (link)->device; \
diff --git a/kernel/kgdb.c b/kernel/kgdb.c
index 25d955dbb989..e4dcfb2272a4 100644
--- a/kernel/kgdb.c
+++ b/kernel/kgdb.c
@@ -590,6 +590,7 @@ static void kgdb_wait(struct pt_regs *regs)
590 590
591 /* Signal the primary CPU that we are done: */ 591 /* Signal the primary CPU that we are done: */
592 atomic_set(&cpu_in_kgdb[cpu], 0); 592 atomic_set(&cpu_in_kgdb[cpu], 0);
593 touch_softlockup_watchdog();
593 clocksource_touch_watchdog(); 594 clocksource_touch_watchdog();
594 local_irq_restore(flags); 595 local_irq_restore(flags);
595} 596}
@@ -1432,6 +1433,7 @@ acquirelock:
1432 atomic_read(&kgdb_cpu_doing_single_step) != cpu) { 1433 atomic_read(&kgdb_cpu_doing_single_step) != cpu) {
1433 1434
1434 atomic_set(&kgdb_active, -1); 1435 atomic_set(&kgdb_active, -1);
1436 touch_softlockup_watchdog();
1435 clocksource_touch_watchdog(); 1437 clocksource_touch_watchdog();
1436 local_irq_restore(flags); 1438 local_irq_restore(flags);
1437 1439
@@ -1524,6 +1526,7 @@ acquirelock:
1524kgdb_restore: 1526kgdb_restore:
1525 /* Free kgdb_active */ 1527 /* Free kgdb_active */
1526 atomic_set(&kgdb_active, -1); 1528 atomic_set(&kgdb_active, -1);
1529 touch_softlockup_watchdog();
1527 clocksource_touch_watchdog(); 1530 clocksource_touch_watchdog();
1528 local_irq_restore(flags); 1531 local_irq_restore(flags);
1529 1532
diff --git a/mm/slob.c b/mm/slob.c
index 4c82dd41f32e..cb675d126791 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -514,9 +514,11 @@ size_t ksize(const void *block)
514 return 0; 514 return 0;
515 515
516 sp = (struct slob_page *)virt_to_page(block); 516 sp = (struct slob_page *)virt_to_page(block);
517 if (slob_page(sp)) 517 if (slob_page(sp)) {
518 return ((slob_t *)block - 1)->units + SLOB_UNIT; 518 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
519 else 519 unsigned int *m = (unsigned int *)(block - align);
520 return SLOB_UNITS(*m) * SLOB_UNIT;
521 } else
520 return sp->page.private; 522 return sp->page.private;
521} 523}
522 524
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 01c83e2a4c19..28c71574a781 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -317,6 +317,9 @@ void ax25_destroy_socket(ax25_cb *ax25)
317 /* Queue the unaccepted socket for death */ 317 /* Queue the unaccepted socket for death */
318 sock_orphan(skb->sk); 318 sock_orphan(skb->sk);
319 319
320 /* 9A4GL: hack to release unaccepted sockets */
321 skb->sk->sk_state = TCP_LISTEN;
322
320 ax25_start_heartbeat(sax25); 323 ax25_start_heartbeat(sax25);
321 sax25->state = AX25_STATE_0; 324 sax25->state = AX25_STATE_0;
322 } 325 }
diff --git a/net/ax25/ax25_std_timer.c b/net/ax25/ax25_std_timer.c
index cdc7e751ef36..96e4b9273250 100644
--- a/net/ax25/ax25_std_timer.c
+++ b/net/ax25/ax25_std_timer.c
@@ -39,9 +39,11 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)
39 39
40 switch (ax25->state) { 40 switch (ax25->state) {
41 case AX25_STATE_0: 41 case AX25_STATE_0:
42 if (!sk || 42 /* Magic here: If we listen() and a new link dies before it
43 sock_flag(sk, SOCK_DESTROY) || 43 is accepted() it isn't 'dead' so doesn't get removed. */
44 sock_flag(sk, SOCK_DEAD)) { 44 if (!sk || sock_flag(sk, SOCK_DESTROY) ||
45 (sk->sk_state == TCP_LISTEN &&
46 sock_flag(sk, SOCK_DEAD))) {
45 if (sk) { 47 if (sk) {
46 sock_hold(sk); 48 sock_hold(sk);
47 ax25_destroy_socket(ax25); 49 ax25_destroy_socket(ax25);
diff --git a/net/core/dev.c b/net/core/dev.c
index e8eb2b478344..0ae08d3f57e7 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2918,6 +2918,12 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
2918 return 0; 2918 return 0;
2919} 2919}
2920 2920
2921static void dev_change_rx_flags(struct net_device *dev, int flags)
2922{
2923 if (dev->flags & IFF_UP && dev->change_rx_flags)
2924 dev->change_rx_flags(dev, flags);
2925}
2926
2921static int __dev_set_promiscuity(struct net_device *dev, int inc) 2927static int __dev_set_promiscuity(struct net_device *dev, int inc)
2922{ 2928{
2923 unsigned short old_flags = dev->flags; 2929 unsigned short old_flags = dev->flags;
@@ -2955,8 +2961,7 @@ static int __dev_set_promiscuity(struct net_device *dev, int inc)
2955 current->uid, current->gid, 2961 current->uid, current->gid,
2956 audit_get_sessionid(current)); 2962 audit_get_sessionid(current));
2957 2963
2958 if (dev->change_rx_flags) 2964 dev_change_rx_flags(dev, IFF_PROMISC);
2959 dev->change_rx_flags(dev, IFF_PROMISC);
2960 } 2965 }
2961 return 0; 2966 return 0;
2962} 2967}
@@ -3022,8 +3027,7 @@ int dev_set_allmulti(struct net_device *dev, int inc)
3022 } 3027 }
3023 } 3028 }
3024 if (dev->flags ^ old_flags) { 3029 if (dev->flags ^ old_flags) {
3025 if (dev->change_rx_flags) 3030 dev_change_rx_flags(dev, IFF_ALLMULTI);
3026 dev->change_rx_flags(dev, IFF_ALLMULTI);
3027 dev_set_rx_mode(dev); 3031 dev_set_rx_mode(dev);
3028 } 3032 }
3029 return 0; 3033 return 0;
@@ -3347,8 +3351,8 @@ int dev_change_flags(struct net_device *dev, unsigned flags)
3347 * Load in the correct multicast list now the flags have changed. 3351 * Load in the correct multicast list now the flags have changed.
3348 */ 3352 */
3349 3353
3350 if (dev->change_rx_flags && (old_flags ^ flags) & IFF_MULTICAST) 3354 if ((old_flags ^ flags) & IFF_MULTICAST)
3351 dev->change_rx_flags(dev, IFF_MULTICAST); 3355 dev_change_rx_flags(dev, IFF_MULTICAST);
3352 3356
3353 dev_set_rx_mode(dev); 3357 dev_set_rx_mode(dev);
3354 3358
@@ -3808,14 +3812,11 @@ static int dev_new_index(struct net *net)
3808} 3812}
3809 3813
3810/* Delayed registration/unregisteration */ 3814/* Delayed registration/unregisteration */
3811static DEFINE_SPINLOCK(net_todo_list_lock);
3812static LIST_HEAD(net_todo_list); 3815static LIST_HEAD(net_todo_list);
3813 3816
3814static void net_set_todo(struct net_device *dev) 3817static void net_set_todo(struct net_device *dev)
3815{ 3818{
3816 spin_lock(&net_todo_list_lock);
3817 list_add_tail(&dev->todo_list, &net_todo_list); 3819 list_add_tail(&dev->todo_list, &net_todo_list);
3818 spin_unlock(&net_todo_list_lock);
3819} 3820}
3820 3821
3821static void rollback_registered(struct net_device *dev) 3822static void rollback_registered(struct net_device *dev)
@@ -4142,33 +4143,24 @@ static void netdev_wait_allrefs(struct net_device *dev)
4142 * free_netdev(y1); 4143 * free_netdev(y1);
4143 * free_netdev(y2); 4144 * free_netdev(y2);
4144 * 4145 *
4145 * We are invoked by rtnl_unlock() after it drops the semaphore. 4146 * We are invoked by rtnl_unlock().
4146 * This allows us to deal with problems: 4147 * This allows us to deal with problems:
4147 * 1) We can delete sysfs objects which invoke hotplug 4148 * 1) We can delete sysfs objects which invoke hotplug
4148 * without deadlocking with linkwatch via keventd. 4149 * without deadlocking with linkwatch via keventd.
4149 * 2) Since we run with the RTNL semaphore not held, we can sleep 4150 * 2) Since we run with the RTNL semaphore not held, we can sleep
4150 * safely in order to wait for the netdev refcnt to drop to zero. 4151 * safely in order to wait for the netdev refcnt to drop to zero.
4152 *
4153 * We must not return until all unregister events added during
4154 * the interval the lock was held have been completed.
4151 */ 4155 */
4152static DEFINE_MUTEX(net_todo_run_mutex);
4153void netdev_run_todo(void) 4156void netdev_run_todo(void)
4154{ 4157{
4155 struct list_head list; 4158 struct list_head list;
4156 4159
4157 /* Need to guard against multiple cpu's getting out of order. */
4158 mutex_lock(&net_todo_run_mutex);
4159
4160 /* Not safe to do outside the semaphore. We must not return
4161 * until all unregister events invoked by the local processor
4162 * have been completed (either by this todo run, or one on
4163 * another cpu).
4164 */
4165 if (list_empty(&net_todo_list))
4166 goto out;
4167
4168 /* Snapshot list, allow later requests */ 4160 /* Snapshot list, allow later requests */
4169 spin_lock(&net_todo_list_lock);
4170 list_replace_init(&net_todo_list, &list); 4161 list_replace_init(&net_todo_list, &list);
4171 spin_unlock(&net_todo_list_lock); 4162
4163 __rtnl_unlock();
4172 4164
4173 while (!list_empty(&list)) { 4165 while (!list_empty(&list)) {
4174 struct net_device *dev 4166 struct net_device *dev
@@ -4200,9 +4192,6 @@ void netdev_run_todo(void)
4200 /* Free network device */ 4192 /* Free network device */
4201 kobject_put(&dev->dev.kobj); 4193 kobject_put(&dev->dev.kobj);
4202 } 4194 }
4203
4204out:
4205 mutex_unlock(&net_todo_run_mutex);
4206} 4195}
4207 4196
4208static struct net_device_stats *internal_stats(struct net_device *dev) 4197static struct net_device_stats *internal_stats(struct net_device *dev)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 71edb8b36341..d6381c2a4693 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -73,7 +73,7 @@ void __rtnl_unlock(void)
73 73
74void rtnl_unlock(void) 74void rtnl_unlock(void)
75{ 75{
76 mutex_unlock(&rtnl_mutex); 76 /* This fellow will unlock it for us. */
77 netdev_run_todo(); 77 netdev_run_todo();
78} 78}
79 79
diff --git a/net/ipv4/tcp_hybla.c b/net/ipv4/tcp_hybla.c
index bfcbd148a89d..c209e054a634 100644
--- a/net/ipv4/tcp_hybla.c
+++ b/net/ipv4/tcp_hybla.c
@@ -150,7 +150,11 @@ static void hybla_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
150 ca->snd_cwnd_cents -= 128; 150 ca->snd_cwnd_cents -= 128;
151 tp->snd_cwnd_cnt = 0; 151 tp->snd_cwnd_cnt = 0;
152 } 152 }
153 153 /* check when cwnd has not been incremented for a while */
154 if (increment == 0 && odd == 0 && tp->snd_cwnd_cnt >= tp->snd_cwnd) {
155 tp->snd_cwnd++;
156 tp->snd_cwnd_cnt = 0;
157 }
154 /* clamp down slowstart cwnd to ssthresh value. */ 158 /* clamp down slowstart cwnd to ssthresh value. */
155 if (is_slowstart) 159 if (is_slowstart)
156 tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh); 160 tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh);
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 67ccce2a96bd..7abc6b80d47d 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4879,7 +4879,8 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
4879 goto no_ack; 4879 goto no_ack;
4880 } 4880 }
4881 4881
4882 __tcp_ack_snd_check(sk, 0); 4882 if (!copied_early || tp->rcv_nxt != tp->rcv_wup)
4883 __tcp_ack_snd_check(sk, 0);
4883no_ack: 4884no_ack:
4884#ifdef CONFIG_NET_DMA 4885#ifdef CONFIG_NET_DMA
4885 if (copied_early) 4886 if (copied_early)
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 532e4faa29f7..9f1ea4a27b35 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -525,6 +525,7 @@ static int nr_release(struct socket *sock)
525 if (sk == NULL) return 0; 525 if (sk == NULL) return 0;
526 526
527 sock_hold(sk); 527 sock_hold(sk);
528 sock_orphan(sk);
528 lock_sock(sk); 529 lock_sock(sk);
529 nr = nr_sk(sk); 530 nr = nr_sk(sk);
530 531
@@ -548,7 +549,6 @@ static int nr_release(struct socket *sock)
548 sk->sk_state = TCP_CLOSE; 549 sk->sk_state = TCP_CLOSE;
549 sk->sk_shutdown |= SEND_SHUTDOWN; 550 sk->sk_shutdown |= SEND_SHUTDOWN;
550 sk->sk_state_change(sk); 551 sk->sk_state_change(sk);
551 sock_orphan(sk);
552 sock_set_flag(sk, SOCK_DESTROY); 552 sock_set_flag(sk, SOCK_DESTROY);
553 break; 553 break;
554 554
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 418cd7dbbc93..8e0de6a5e18a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1986,11 +1986,13 @@ static void read_markers(const char *fname)
1986 1986
1987 mod = find_module(modname); 1987 mod = find_module(modname);
1988 if (!mod) { 1988 if (!mod) {
1989 if (is_vmlinux(modname))
1990 have_vmlinux = 1;
1991 mod = new_module(NOFAIL(strdup(modname))); 1989 mod = new_module(NOFAIL(strdup(modname)));
1992 mod->skip = 1; 1990 mod->skip = 1;
1993 } 1991 }
1992 if (is_vmlinux(modname)) {
1993 have_vmlinux = 1;
1994 mod->skip = 0;
1995 }
1994 1996
1995 if (!mod->skip) 1997 if (!mod->skip)
1996 add_marker(mod, marker, fmt); 1998 add_marker(mod, marker, fmt);