aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig18
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/ac.c20
-rw-r--r--drivers/acpi/battery.c22
-rw-r--r--drivers/acpi/ec.c100
-rw-r--r--drivers/acpi/osl.c25
-rw-r--r--drivers/acpi/processor_core.c33
-rw-r--r--drivers/acpi/processor_idle.c112
-rw-r--r--drivers/acpi/processor_throttling.c286
-rw-r--r--drivers/acpi/sbs.c43
-rw-r--r--drivers/acpi/tables/tbutils.c2
-rw-r--r--drivers/acpi/video.c155
-rw-r--r--drivers/ata/ata_piix.c121
-rw-r--r--drivers/ata/libata-core.c116
-rw-r--r--drivers/ata/libata-eh.c137
-rw-r--r--drivers/ata/libata-scsi.c38
-rw-r--r--drivers/ata/pata_ali.c20
-rw-r--r--drivers/ata/pata_at32.c61
-rw-r--r--drivers/ata/pata_bf54x.c13
-rw-r--r--drivers/ata/pata_hpt37x.c2
-rw-r--r--drivers/ata/pata_isapnp.c11
-rw-r--r--drivers/ata/pata_jmicron.c9
-rw-r--r--drivers/ata/pata_sil680.c32
-rw-r--r--drivers/ata/pata_sis.c1
-rw-r--r--drivers/ata/sata_mv.c64
-rw-r--r--drivers/ata/sata_sil24.c26
-rw-r--r--drivers/base/core.c4
-rw-r--r--drivers/base/power/Makefile3
-rw-r--r--drivers/base/power/main.c8
-rw-r--r--drivers/base/power/power.h28
-rw-r--r--drivers/block/virtio_blk.c10
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/sonypi.c8
-rw-r--r--drivers/char/tpm/tpm_tis.c10
-rw-r--r--drivers/crypto/Kconfig2
-rw-r--r--drivers/dma/Kconfig8
-rw-r--r--drivers/ide/Kconfig47
-rw-r--r--drivers/ide/Makefile2
-rw-r--r--drivers/ide/cris/ide-cris.c7
-rw-r--r--drivers/ide/ide-dma.c1
-rw-r--r--drivers/ide/ide-iops.c13
-rw-r--r--drivers/ide/ide-probe.c32
-rw-r--r--drivers/ide/legacy/ali14xx.c7
-rw-r--r--drivers/ide/legacy/macide.c2
-rw-r--r--drivers/ide/legacy/q40ide.c2
-rw-r--r--drivers/ide/pci/aec62xx.c11
-rw-r--r--drivers/ide/pci/alim15x3.c5
-rw-r--r--drivers/ide/pci/piix.c1
-rw-r--r--drivers/ide/pci/siimage.c45
-rw-r--r--drivers/ide/pci/sis5513.c1
-rw-r--r--drivers/ide/pci/trm290.c3
-rw-r--r--drivers/ide/ppc/pmac.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_av.c8
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_cq.c19
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c15
-rw-r--r--drivers/infiniband/hw/ipath/ipath_srq.c44
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c8
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c3
-rw-r--r--drivers/infiniband/ulp/iser/iser_memory.c6
-rw-r--r--drivers/input/keyboard/Kconfig2
-rw-r--r--drivers/input/keyboard/gpio_keys.c38
-rw-r--r--drivers/input/serio/Kconfig2
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h8
-rw-r--r--drivers/isdn/hisax/hfcscard.c3
-rw-r--r--drivers/isdn/i4l/isdn_common.c5
-rw-r--r--drivers/isdn/i4l/isdn_net.c8
-rw-r--r--drivers/kvm/kvm_main.c3
-rw-r--r--drivers/kvm/svm.c1
-rw-r--r--drivers/kvm/x86_emulate.c6
-rw-r--r--drivers/lguest/lguest_device.c2
-rw-r--r--drivers/mfd/sm501.c2
-rw-r--r--drivers/misc/sony-laptop.c10
-rw-r--r--drivers/misc/thinkpad_acpi.c231
-rw-r--r--drivers/misc/thinkpad_acpi.h4
-rw-r--r--drivers/mmc/card/block.c22
-rw-r--r--drivers/mmc/card/queue.c3
-rw-r--r--drivers/mmc/card/sdio_uart.c2
-rw-r--r--drivers/mmc/host/tifm_sd.c18
-rw-r--r--drivers/net/Kconfig4
-rw-r--r--drivers/net/amd8111e.c6
-rw-r--r--drivers/net/bfin_mac.c4
-rw-r--r--drivers/net/bfin_mac.h2
-rwxr-xr-x[-rw-r--r--]drivers/net/chelsio/cxgb2.c70
-rwxr-xr-x[-rw-r--r--]drivers/net/chelsio/pm3393.c112
-rwxr-xr-x[-rw-r--r--]drivers/net/chelsio/sge.c44
-rwxr-xr-x[-rw-r--r--]drivers/net/chelsio/sge.h3
-rw-r--r--drivers/net/e1000/e1000_main.c2
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/ehea/ehea_main.c20
-rw-r--r--drivers/net/ehea/ehea_qmr.h4
-rw-r--r--drivers/net/fec_mpc52xx.c2
-rw-r--r--drivers/net/forcedeth.c38
-rw-r--r--drivers/net/ibm_newemac/core.c31
-rw-r--r--drivers/net/ibm_newemac/core.h1
-rw-r--r--drivers/net/lib82596.c50
-rw-r--r--drivers/net/mlx4/qp.c2
-rw-r--r--drivers/net/phy/marvell.c26
-rw-r--r--drivers/net/phy/phy.c3
-rw-r--r--drivers/net/plip.c4
-rw-r--r--drivers/net/s2io.c32
-rw-r--r--drivers/net/skge.c108
-rw-r--r--drivers/net/sky2.c121
-rw-r--r--drivers/net/sky2.h21
-rw-r--r--drivers/net/smc911x.c19
-rw-r--r--drivers/net/smc911x.h2
-rw-r--r--drivers/net/smc91x.h2
-rw-r--r--drivers/net/tulip/dmfe.c4
-rw-r--r--drivers/net/ucc_geth.c10
-rw-r--r--drivers/net/usb/dm9601.c2
-rw-r--r--drivers/net/via-velocity.c11
-rw-r--r--drivers/net/virtio_net.c12
-rw-r--r--drivers/net/wireless/b43/main.c2
-rw-r--r--drivers/net/wireless/b43/phy.c2
-rw-r--r--drivers/net/wireless/b43legacy/dma.c2
-rw-r--r--drivers/net/wireless/b43legacy/main.c2
-rw-r--r--drivers/net/wireless/b43legacy/phy.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_phy.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c16
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c13
-rw-r--r--drivers/net/wireless/libertas/if_cs.c3
-rw-r--r--drivers/net/wireless/libertas/main.c4
-rw-r--r--drivers/net/wireless/libertas/wext.c2
-rw-r--r--drivers/net/wireless/netwave_cs.c2
-rw-r--r--drivers/net/wireless/p54usb.c2
-rw-r--r--drivers/pci/hotplug/acpiphp.h8
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c29
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c36
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c47
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c41
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c96
-rw-r--r--drivers/pci/hotplug/fakephp.c14
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c16
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c19
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c15
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c1
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c16
-rw-r--r--drivers/pci/pci-sysfs.c4
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c29
-rw-r--r--drivers/pci/pcie/portdrv_pci.c2
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c39
-rw-r--r--drivers/pnp/resource.c4
-rw-r--r--drivers/ps3/Makefile4
-rw-r--r--drivers/ps3/ps3-sys-manager.c (renamed from drivers/ps3/sys-manager.c)0
-rw-r--r--drivers/ps3/ps3-vuart.c (renamed from drivers/ps3/vuart.c)0
-rw-r--r--drivers/rtc/Kconfig2
-rw-r--r--drivers/rtc/interface.c4
-rw-r--r--drivers/rtc/rtc-dev.c12
-rw-r--r--drivers/s390/cio/css.c2
-rw-r--r--drivers/s390/cio/device_fsm.c2
-rw-r--r--drivers/s390/cio/device_id.c45
-rw-r--r--drivers/s390/net/ctcmain.c45
-rw-r--r--drivers/scsi/ide-scsi.c22
-rw-r--r--drivers/scsi/zorro7xx.c3
-rw-r--r--drivers/serial/Kconfig2
-rw-r--r--drivers/serial/ip22zilog.c247
-rw-r--r--drivers/serial/pxa.c4
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/spi/atmel_spi.c2
-rw-r--r--drivers/spi/spi_s3c24xx_gpio.c21
-rw-r--r--drivers/usb/README6
-rw-r--r--drivers/usb/core/driver.c11
-rw-r--r--drivers/usb/core/hcd.c3
-rw-r--r--drivers/usb/core/hub.c2
-rw-r--r--drivers/usb/core/message.c36
-rw-r--r--drivers/usb/core/sysfs.c6
-rw-r--r--drivers/usb/core/usb.c25
-rw-r--r--drivers/usb/gadget/omap_udc.c6
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c16
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/ehci-hcd.c5
-rw-r--r--drivers/usb/image/microtek.c2
-rw-r--r--drivers/usb/misc/adutux.c262
-rw-r--r--drivers/usb/misc/usbled.c4
-rw-r--r--drivers/usb/serial/generic.c5
-rw-r--r--drivers/usb/serial/keyspan.c32
-rw-r--r--drivers/usb/serial/mos7840.c2
-rw-r--r--drivers/usb/serial/pl2303.c1
-rw-r--r--drivers/usb/serial/pl2303.h3
-rw-r--r--drivers/usb/serial/sierra.c2
-rw-r--r--drivers/usb/storage/scsiglue.c4
-rw-r--r--drivers/usb/storage/unusual_devs.h17
-rw-r--r--drivers/video/Kconfig11
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/atmel_lcdfb.c4
-rw-r--r--drivers/video/aty/radeon_base.c1
-rw-r--r--drivers/video/console/Kconfig2
-rw-r--r--drivers/video/efifb.c232
-rw-r--r--drivers/video/fb_ddc.c8
-rw-r--r--drivers/video/imacfb.c4
-rw-r--r--drivers/video/ps3fb.c11
-rw-r--r--drivers/virtio/virtio.c13
-rw-r--r--drivers/zorro/zorro-driver.c15
193 files changed, 2720 insertions, 1907 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 087a7028ae84..b9f923ef173d 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -50,7 +50,6 @@ config ACPI_SLEEP
50config ACPI_PROCFS 50config ACPI_PROCFS
51 bool "Deprecated /proc/acpi files" 51 bool "Deprecated /proc/acpi files"
52 depends on PROC_FS 52 depends on PROC_FS
53 default y
54 ---help--- 53 ---help---
55 For backwards compatibility, this option allows 54 For backwards compatibility, this option allows
56 deprecated /proc/acpi/ files to exist, even when 55 deprecated /proc/acpi/ files to exist, even when
@@ -61,7 +60,6 @@ config ACPI_PROCFS
61 /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version) 60 /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version)
62 /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT) 61 /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT)
63 /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP) 62 /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP)
64 /proc/acpi/battery (/sys/class/power_supply)
65 /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer) 63 /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer)
66 /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level) 64 /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level)
67 65
@@ -69,7 +67,21 @@ config ACPI_PROCFS
69 and functions which do not yet exist in /sys. 67 and functions which do not yet exist in /sys.
70 68
71 Say N to delete /proc/acpi/ files that have moved to /sys/ 69 Say N to delete /proc/acpi/ files that have moved to /sys/
72 70config ACPI_PROCFS_POWER
71 bool "Deprecated power /proc/acpi folders"
72 depends on PROC_FS
73 default y
74 ---help---
75 For backwards compatibility, this option allows
76 deprecated power /proc/acpi/ folders to exist, even when
77 they have been replaced by functions in /sys.
78 The deprecated folders (and their replacements) include:
79 /proc/acpi/battery/* (/sys/class/power_supply/*)
80 /proc/acpi/ac_adapter/* (sys/class/power_supply/*)
81 This option has no effect on /proc/acpi/ folders
82 and functions, which do not yet exist in /sys
83
84 Say N to delete power /proc/acpi/ folders that have moved to /sys/
73config ACPI_PROC_EVENT 85config ACPI_PROC_EVENT
74 bool "Deprecated /proc/acpi/event support" 86 bool "Deprecated /proc/acpi/event support"
75 depends on PROC_FS 87 depends on PROC_FS
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 54e3ab0e5fc0..456446f90077 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -58,6 +58,6 @@ obj-$(CONFIG_ACPI_NUMA) += numa.o
58obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o 58obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o
59obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o 59obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o
60obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o 60obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
61obj-y += cm_sbs.o 61obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
62obj-$(CONFIG_ACPI_SBS) += sbs.o 62obj-$(CONFIG_ACPI_SBS) += sbs.o
63obj-$(CONFIG_ACPI_SBS) += sbshc.o 63obj-$(CONFIG_ACPI_SBS) += sbshc.o
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 30238f6ff232..76ed4f52bebd 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -27,7 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#ifdef CONFIG_ACPI_PROCFS 30#ifdef CONFIG_ACPI_PROCFS_POWER
31#include <linux/proc_fs.h> 31#include <linux/proc_fs.h>
32#include <linux/seq_file.h> 32#include <linux/seq_file.h>
33#endif 33#endif
@@ -51,7 +51,7 @@ MODULE_AUTHOR("Paul Diefenbaugh");
51MODULE_DESCRIPTION("ACPI AC Adapter Driver"); 51MODULE_DESCRIPTION("ACPI AC Adapter Driver");
52MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
53 53
54#ifdef CONFIG_ACPI_PROCFS 54#ifdef CONFIG_ACPI_PROCFS_POWER
55extern struct proc_dir_entry *acpi_lock_ac_dir(void); 55extern struct proc_dir_entry *acpi_lock_ac_dir(void);
56extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); 56extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir);
57static int acpi_ac_open_fs(struct inode *inode, struct file *file); 57static int acpi_ac_open_fs(struct inode *inode, struct file *file);
@@ -86,7 +86,7 @@ struct acpi_ac {
86 86
87#define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); 87#define to_acpi_ac(x) container_of(x, struct acpi_ac, charger);
88 88
89#ifdef CONFIG_ACPI_PROCFS 89#ifdef CONFIG_ACPI_PROCFS_POWER
90static const struct file_operations acpi_ac_fops = { 90static const struct file_operations acpi_ac_fops = {
91 .open = acpi_ac_open_fs, 91 .open = acpi_ac_open_fs,
92 .read = seq_read, 92 .read = seq_read,
@@ -136,7 +136,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
136 return 0; 136 return 0;
137} 137}
138 138
139#ifdef CONFIG_ACPI_PROCFS 139#ifdef CONFIG_ACPI_PROCFS_POWER
140/* -------------------------------------------------------------------------- 140/* --------------------------------------------------------------------------
141 FS Interface (/proc) 141 FS Interface (/proc)
142 -------------------------------------------------------------------------- */ 142 -------------------------------------------------------------------------- */
@@ -275,7 +275,7 @@ static int acpi_ac_add(struct acpi_device *device)
275 if (result) 275 if (result)
276 goto end; 276 goto end;
277 277
278#ifdef CONFIG_ACPI_PROCFS 278#ifdef CONFIG_ACPI_PROCFS_POWER
279 result = acpi_ac_add_fs(device); 279 result = acpi_ac_add_fs(device);
280#endif 280#endif
281 if (result) 281 if (result)
@@ -300,7 +300,7 @@ static int acpi_ac_add(struct acpi_device *device)
300 300
301 end: 301 end:
302 if (result) { 302 if (result) {
303#ifdef CONFIG_ACPI_PROCFS 303#ifdef CONFIG_ACPI_PROCFS_POWER
304 acpi_ac_remove_fs(device); 304 acpi_ac_remove_fs(device);
305#endif 305#endif
306 kfree(ac); 306 kfree(ac);
@@ -339,7 +339,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
339 ACPI_ALL_NOTIFY, acpi_ac_notify); 339 ACPI_ALL_NOTIFY, acpi_ac_notify);
340 if (ac->charger.dev) 340 if (ac->charger.dev)
341 power_supply_unregister(&ac->charger); 341 power_supply_unregister(&ac->charger);
342#ifdef CONFIG_ACPI_PROCFS 342#ifdef CONFIG_ACPI_PROCFS_POWER
343 acpi_ac_remove_fs(device); 343 acpi_ac_remove_fs(device);
344#endif 344#endif
345 345
@@ -355,7 +355,7 @@ static int __init acpi_ac_init(void)
355 if (acpi_disabled) 355 if (acpi_disabled)
356 return -ENODEV; 356 return -ENODEV;
357 357
358#ifdef CONFIG_ACPI_PROCFS 358#ifdef CONFIG_ACPI_PROCFS_POWER
359 acpi_ac_dir = acpi_lock_ac_dir(); 359 acpi_ac_dir = acpi_lock_ac_dir();
360 if (!acpi_ac_dir) 360 if (!acpi_ac_dir)
361 return -ENODEV; 361 return -ENODEV;
@@ -363,7 +363,7 @@ static int __init acpi_ac_init(void)
363 363
364 result = acpi_bus_register_driver(&acpi_ac_driver); 364 result = acpi_bus_register_driver(&acpi_ac_driver);
365 if (result < 0) { 365 if (result < 0) {
366#ifdef CONFIG_ACPI_PROCFS 366#ifdef CONFIG_ACPI_PROCFS_POWER
367 acpi_unlock_ac_dir(acpi_ac_dir); 367 acpi_unlock_ac_dir(acpi_ac_dir);
368#endif 368#endif
369 return -ENODEV; 369 return -ENODEV;
@@ -377,7 +377,7 @@ static void __exit acpi_ac_exit(void)
377 377
378 acpi_bus_unregister_driver(&acpi_ac_driver); 378 acpi_bus_unregister_driver(&acpi_ac_driver);
379 379
380#ifdef CONFIG_ACPI_PROCFS 380#ifdef CONFIG_ACPI_PROCFS_POWER
381 acpi_unlock_ac_dir(acpi_ac_dir); 381 acpi_unlock_ac_dir(acpi_ac_dir);
382#endif 382#endif
383 383
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 192c244f6190..7d6be23eff89 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -31,7 +31,7 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33 33
34#ifdef CONFIG_ACPI_PROCFS 34#ifdef CONFIG_ACPI_PROCFS_POWER
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/seq_file.h> 36#include <linux/seq_file.h>
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
@@ -63,7 +63,7 @@ static unsigned int cache_time = 1000;
63module_param(cache_time, uint, 0644); 63module_param(cache_time, uint, 0644);
64MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); 64MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
65 65
66#ifdef CONFIG_ACPI_PROCFS 66#ifdef CONFIG_ACPI_PROCFS_POWER
67extern struct proc_dir_entry *acpi_lock_battery_dir(void); 67extern struct proc_dir_entry *acpi_lock_battery_dir(void);
68extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); 68extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
69 69
@@ -153,6 +153,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
153 val->intval = POWER_SUPPLY_STATUS_CHARGING; 153 val->intval = POWER_SUPPLY_STATUS_CHARGING;
154 else if (battery->state == 0) 154 else if (battery->state == 0)
155 val->intval = POWER_SUPPLY_STATUS_FULL; 155 val->intval = POWER_SUPPLY_STATUS_FULL;
156 else
157 val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
156 break; 158 break;
157 case POWER_SUPPLY_PROP_PRESENT: 159 case POWER_SUPPLY_PROP_PRESENT:
158 val->intval = acpi_battery_present(battery); 160 val->intval = acpi_battery_present(battery);
@@ -221,7 +223,7 @@ static enum power_supply_property energy_battery_props[] = {
221 POWER_SUPPLY_PROP_MANUFACTURER, 223 POWER_SUPPLY_PROP_MANUFACTURER,
222}; 224};
223 225
224#ifdef CONFIG_ACPI_PROCFS 226#ifdef CONFIG_ACPI_PROCFS_POWER
225inline char *acpi_battery_units(struct acpi_battery *battery) 227inline char *acpi_battery_units(struct acpi_battery *battery)
226{ 228{
227 return (battery->power_unit)?"mA":"mW"; 229 return (battery->power_unit)?"mA":"mW";
@@ -479,7 +481,7 @@ static int acpi_battery_update(struct acpi_battery *battery)
479 FS Interface (/proc) 481 FS Interface (/proc)
480 -------------------------------------------------------------------------- */ 482 -------------------------------------------------------------------------- */
481 483
482#ifdef CONFIG_ACPI_PROCFS 484#ifdef CONFIG_ACPI_PROCFS_POWER
483static struct proc_dir_entry *acpi_battery_dir; 485static struct proc_dir_entry *acpi_battery_dir;
484 486
485static int acpi_battery_print_info(struct seq_file *seq, int result) 487static int acpi_battery_print_info(struct seq_file *seq, int result)
@@ -786,7 +788,7 @@ static int acpi_battery_add(struct acpi_device *device)
786 acpi_driver_data(device) = battery; 788 acpi_driver_data(device) = battery;
787 mutex_init(&battery->lock); 789 mutex_init(&battery->lock);
788 acpi_battery_update(battery); 790 acpi_battery_update(battery);
789#ifdef CONFIG_ACPI_PROCFS 791#ifdef CONFIG_ACPI_PROCFS_POWER
790 result = acpi_battery_add_fs(device); 792 result = acpi_battery_add_fs(device);
791 if (result) 793 if (result)
792 goto end; 794 goto end;
@@ -804,7 +806,7 @@ static int acpi_battery_add(struct acpi_device *device)
804 device->status.battery_present ? "present" : "absent"); 806 device->status.battery_present ? "present" : "absent");
805 end: 807 end:
806 if (result) { 808 if (result) {
807#ifdef CONFIG_ACPI_PROCFS 809#ifdef CONFIG_ACPI_PROCFS_POWER
808 acpi_battery_remove_fs(device); 810 acpi_battery_remove_fs(device);
809#endif 811#endif
810 kfree(battery); 812 kfree(battery);
@@ -823,7 +825,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
823 status = acpi_remove_notify_handler(device->handle, 825 status = acpi_remove_notify_handler(device->handle,
824 ACPI_ALL_NOTIFY, 826 ACPI_ALL_NOTIFY,
825 acpi_battery_notify); 827 acpi_battery_notify);
826#ifdef CONFIG_ACPI_PROCFS 828#ifdef CONFIG_ACPI_PROCFS_POWER
827 acpi_battery_remove_fs(device); 829 acpi_battery_remove_fs(device);
828#endif 830#endif
829 sysfs_remove_battery(battery); 831 sysfs_remove_battery(battery);
@@ -859,13 +861,13 @@ static int __init acpi_battery_init(void)
859{ 861{
860 if (acpi_disabled) 862 if (acpi_disabled)
861 return -ENODEV; 863 return -ENODEV;
862#ifdef CONFIG_ACPI_PROCFS 864#ifdef CONFIG_ACPI_PROCFS_POWER
863 acpi_battery_dir = acpi_lock_battery_dir(); 865 acpi_battery_dir = acpi_lock_battery_dir();
864 if (!acpi_battery_dir) 866 if (!acpi_battery_dir)
865 return -ENODEV; 867 return -ENODEV;
866#endif 868#endif
867 if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { 869 if (acpi_bus_register_driver(&acpi_battery_driver) < 0) {
868#ifdef CONFIG_ACPI_PROCFS 870#ifdef CONFIG_ACPI_PROCFS_POWER
869 acpi_unlock_battery_dir(acpi_battery_dir); 871 acpi_unlock_battery_dir(acpi_battery_dir);
870#endif 872#endif
871 return -ENODEV; 873 return -ENODEV;
@@ -876,7 +878,7 @@ static int __init acpi_battery_init(void)
876static void __exit acpi_battery_exit(void) 878static void __exit acpi_battery_exit(void)
877{ 879{
878 acpi_bus_unregister_driver(&acpi_battery_driver); 880 acpi_bus_unregister_driver(&acpi_battery_driver);
879#ifdef CONFIG_ACPI_PROCFS 881#ifdef CONFIG_ACPI_PROCFS_POWER
880 acpi_unlock_battery_dir(acpi_battery_dir); 882 acpi_unlock_battery_dir(acpi_battery_dir);
881#endif 883#endif
882} 884}
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 06b78e5e33a1..d411017f8c06 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -47,6 +47,9 @@
47#undef PREFIX 47#undef PREFIX
48#define PREFIX "ACPI: EC: " 48#define PREFIX "ACPI: EC: "
49 49
50/* Uncomment next line to get verbose print outs*/
51/* #define DEBUG */
52
50/* EC status register */ 53/* EC status register */
51#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ 54#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
52#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ 55#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
@@ -75,7 +78,10 @@ enum {
75 EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ 78 EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */
76 EC_FLAGS_QUERY_PENDING, /* Query is pending */ 79 EC_FLAGS_QUERY_PENDING, /* Query is pending */
77 EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ 80 EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */
78 EC_FLAGS_ONLY_IBF_GPE, /* Expect GPE only for IBF = 0 event */ 81 EC_FLAGS_NO_ADDRESS_GPE, /* Expect GPE only for non-address event */
82 EC_FLAGS_ADDRESS, /* Address is being written */
83 EC_FLAGS_NO_WDATA_GPE, /* Don't expect WDATA GPE event */
84 EC_FLAGS_WDATA, /* Data is being written */
79}; 85};
80 86
81static int acpi_ec_remove(struct acpi_device *device, int type); 87static int acpi_ec_remove(struct acpi_device *device, int type);
@@ -131,21 +137,27 @@ static struct acpi_ec {
131 137
132static inline u8 acpi_ec_read_status(struct acpi_ec *ec) 138static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
133{ 139{
134 return inb(ec->command_addr); 140 u8 x = inb(ec->command_addr);
141 pr_debug(PREFIX "---> status = 0x%2x\n", x);
142 return x;
135} 143}
136 144
137static inline u8 acpi_ec_read_data(struct acpi_ec *ec) 145static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
138{ 146{
147 u8 x = inb(ec->data_addr);
148 pr_debug(PREFIX "---> data = 0x%2x\n", x);
139 return inb(ec->data_addr); 149 return inb(ec->data_addr);
140} 150}
141 151
142static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) 152static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
143{ 153{
154 pr_debug(PREFIX "<--- command = 0x%2x\n", command);
144 outb(command, ec->command_addr); 155 outb(command, ec->command_addr);
145} 156}
146 157
147static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) 158static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
148{ 159{
160 pr_debug(PREFIX "<--- data = 0x%2x\n", data);
149 outb(data, ec->data_addr); 161 outb(data, ec->data_addr);
150} 162}
151 163
@@ -166,38 +178,54 @@ static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
166 178
167static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) 179static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
168{ 180{
181 int ret = 0;
182 if (unlikely(test_bit(EC_FLAGS_ADDRESS, &ec->flags) &&
183 test_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags)))
184 force_poll = 1;
185 if (unlikely(test_bit(EC_FLAGS_WDATA, &ec->flags) &&
186 test_bit(EC_FLAGS_NO_WDATA_GPE, &ec->flags)))
187 force_poll = 1;
169 if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && 188 if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) &&
170 likely(!force_poll)) { 189 likely(!force_poll)) {
171 if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), 190 if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event),
172 msecs_to_jiffies(ACPI_EC_DELAY))) 191 msecs_to_jiffies(ACPI_EC_DELAY)))
173 return 0; 192 goto end;
174 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 193 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
175 if (acpi_ec_check_status(ec, event)) { 194 if (acpi_ec_check_status(ec, event)) {
176 if (event == ACPI_EC_EVENT_OBF_1) { 195 if (test_bit(EC_FLAGS_ADDRESS, &ec->flags)) {
177 /* miss OBF = 1 GPE, don't expect it anymore */ 196 /* miss address GPE, don't expect it anymore */
178 printk(KERN_INFO PREFIX "missing OBF_1 confirmation," 197 pr_info(PREFIX "missing address confirmation, "
179 "switching to degraded mode.\n"); 198 "don't expect it any longer.\n");
180 set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); 199 set_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags);
200 } else if (test_bit(EC_FLAGS_WDATA, &ec->flags)) {
201 /* miss write data GPE, don't expect it */
202 pr_info(PREFIX "missing write data confirmation, "
203 "don't expect it any longer.\n");
204 set_bit(EC_FLAGS_NO_WDATA_GPE, &ec->flags);
181 } else { 205 } else {
182 /* missing GPEs, switch back to poll mode */ 206 /* missing GPEs, switch back to poll mode */
183 printk(KERN_INFO PREFIX "missing IBF_1 confirmations," 207 if (printk_ratelimit())
184 "switch off interrupt mode.\n"); 208 pr_info(PREFIX "missing confirmations, "
209 "switch off interrupt mode.\n");
185 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); 210 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
186 } 211 }
187 return 0; 212 goto end;
188 } 213 }
189 } else { 214 } else {
190 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); 215 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
191 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 216 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
192 while (time_before(jiffies, delay)) { 217 while (time_before(jiffies, delay)) {
193 if (acpi_ec_check_status(ec, event)) 218 if (acpi_ec_check_status(ec, event))
194 return 0; 219 goto end;
195 } 220 }
196 } 221 }
197 printk(KERN_ERR PREFIX "acpi_ec_wait timeout," 222 pr_err(PREFIX "acpi_ec_wait timeout,"
198 " status = %d, expect_event = %d\n", 223 " status = %d, expect_event = %d\n",
199 acpi_ec_read_status(ec), event); 224 acpi_ec_read_status(ec), event);
200 return -ETIME; 225 ret = -ETIME;
226 end:
227 clear_bit(EC_FLAGS_ADDRESS, &ec->flags);
228 return ret;
201} 229}
202 230
203static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, 231static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
@@ -208,22 +236,26 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
208 int result = 0; 236 int result = 0;
209 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 237 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
210 acpi_ec_write_cmd(ec, command); 238 acpi_ec_write_cmd(ec, command);
211 239 pr_debug(PREFIX "transaction start\n");
212 for (; wdata_len > 0; --wdata_len) { 240 for (; wdata_len > 0; --wdata_len) {
213 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); 241 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
214 if (result) { 242 if (result) {
215 printk(KERN_ERR PREFIX 243 pr_err(PREFIX
216 "write_cmd timeout, command = %d\n", command); 244 "write_cmd timeout, command = %d\n", command);
217 goto end; 245 goto end;
218 } 246 }
247 /* mark the address byte written to EC */
248 if (rdata_len + wdata_len > 1)
249 set_bit(EC_FLAGS_ADDRESS, &ec->flags);
219 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 250 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
220 acpi_ec_write_data(ec, *(wdata++)); 251 acpi_ec_write_data(ec, *(wdata++));
221 } 252 }
222 253
223 if (!rdata_len) { 254 if (!rdata_len) {
255 set_bit(EC_FLAGS_WDATA, &ec->flags);
224 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); 256 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
225 if (result) { 257 if (result) {
226 printk(KERN_ERR PREFIX 258 pr_err(PREFIX
227 "finish-write timeout, command = %d\n", command); 259 "finish-write timeout, command = %d\n", command);
228 goto end; 260 goto end;
229 } 261 }
@@ -231,12 +263,9 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
231 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 263 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
232 264
233 for (; rdata_len > 0; --rdata_len) { 265 for (; rdata_len > 0; --rdata_len) {
234 if (test_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags))
235 force_poll = 1;
236 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); 266 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll);
237 if (result) { 267 if (result) {
238 printk(KERN_ERR PREFIX "read timeout, command = %d\n", 268 pr_err(PREFIX "read timeout, command = %d\n", command);
239 command);
240 goto end; 269 goto end;
241 } 270 }
242 /* Don't expect GPE after last read */ 271 /* Don't expect GPE after last read */
@@ -245,6 +274,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
245 *(rdata++) = acpi_ec_read_data(ec); 274 *(rdata++) = acpi_ec_read_data(ec);
246 } 275 }
247 end: 276 end:
277 pr_debug(PREFIX "transaction end\n");
248 return result; 278 return result;
249} 279}
250 280
@@ -273,8 +303,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
273 303
274 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); 304 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0);
275 if (status) { 305 if (status) {
276 printk(KERN_ERR PREFIX 306 pr_err(PREFIX "input buffer is not empty, "
277 "input buffer is not empty, aborting transaction\n"); 307 "aborting transaction\n");
278 goto end; 308 goto end;
279 } 309 }
280 310
@@ -488,6 +518,7 @@ static u32 acpi_ec_gpe_handler(void *data)
488 acpi_status status = AE_OK; 518 acpi_status status = AE_OK;
489 struct acpi_ec *ec = data; 519 struct acpi_ec *ec = data;
490 520
521 pr_debug(PREFIX "~~~> interrupt\n");
491 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 522 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
492 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) 523 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
493 wake_up(&ec->wait); 524 wake_up(&ec->wait);
@@ -498,8 +529,9 @@ static u32 acpi_ec_gpe_handler(void *data)
498 acpi_ec_gpe_query, ec); 529 acpi_ec_gpe_query, ec);
499 } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) { 530 } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) {
500 /* this is non-query, must be confirmation */ 531 /* this is non-query, must be confirmation */
501 printk(KERN_INFO PREFIX "non-query interrupt received," 532 if (printk_ratelimit())
502 " switching to interrupt mode\n"); 533 pr_info(PREFIX "non-query interrupt received,"
534 " switching to interrupt mode\n");
503 set_bit(EC_FLAGS_GPE_MODE, &ec->flags); 535 set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
504 } 536 }
505 537
@@ -701,10 +733,10 @@ static void ec_remove_handlers(struct acpi_ec *ec)
701{ 733{
702 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, 734 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
703 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) 735 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
704 printk(KERN_ERR PREFIX "failed to remove space handler\n"); 736 pr_err(PREFIX "failed to remove space handler\n");
705 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, 737 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe,
706 &acpi_ec_gpe_handler))) 738 &acpi_ec_gpe_handler)))
707 printk(KERN_ERR PREFIX "failed to remove gpe handler\n"); 739 pr_err(PREFIX "failed to remove gpe handler\n");
708 ec->handlers_installed = 0; 740 ec->handlers_installed = 0;
709} 741}
710 742
@@ -747,9 +779,9 @@ static int acpi_ec_add(struct acpi_device *device)
747 first_ec = ec; 779 first_ec = ec;
748 acpi_driver_data(device) = ec; 780 acpi_driver_data(device) = ec;
749 acpi_ec_add_fs(device); 781 acpi_ec_add_fs(device);
750 printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", 782 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
751 ec->gpe, ec->command_addr, ec->data_addr); 783 ec->gpe, ec->command_addr, ec->data_addr);
752 printk(KERN_INFO PREFIX "driver started in %s mode\n", 784 pr_info(PREFIX "driver started in %s mode\n",
753 (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll"); 785 (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll");
754 return 0; 786 return 0;
755} 787}
@@ -875,18 +907,26 @@ int __init acpi_ec_ecdt_probe(void)
875 status = acpi_get_table(ACPI_SIG_ECDT, 1, 907 status = acpi_get_table(ACPI_SIG_ECDT, 1,
876 (struct acpi_table_header **)&ecdt_ptr); 908 (struct acpi_table_header **)&ecdt_ptr);
877 if (ACPI_SUCCESS(status)) { 909 if (ACPI_SUCCESS(status)) {
878 printk(KERN_INFO PREFIX "EC description table is found, configuring boot EC\n"); 910 pr_info(PREFIX "EC description table is found, configuring boot EC\n");
879 boot_ec->command_addr = ecdt_ptr->control.address; 911 boot_ec->command_addr = ecdt_ptr->control.address;
880 boot_ec->data_addr = ecdt_ptr->data.address; 912 boot_ec->data_addr = ecdt_ptr->data.address;
881 boot_ec->gpe = ecdt_ptr->gpe; 913 boot_ec->gpe = ecdt_ptr->gpe;
882 boot_ec->handle = ACPI_ROOT_OBJECT; 914 boot_ec->handle = ACPI_ROOT_OBJECT;
883 } else { 915 } else {
916 /* This workaround is needed only on some broken machines,
917 * which require early EC, but fail to provide ECDT */
918 acpi_handle x;
884 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n"); 919 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
885 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, 920 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
886 boot_ec, NULL); 921 boot_ec, NULL);
887 /* Check that acpi_get_devices actually find something */ 922 /* Check that acpi_get_devices actually find something */
888 if (ACPI_FAILURE(status) || !boot_ec->handle) 923 if (ACPI_FAILURE(status) || !boot_ec->handle)
889 goto error; 924 goto error;
925 /* We really need to limit this workaround, the only ASUS,
926 * which needs it, has fake EC._INI method, so use it as flag.
927 */
928 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x)))
929 goto error;
890 } 930 }
891 931
892 ret = ec_install_handlers(boot_ec); 932 ret = ec_install_handlers(boot_ec);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index aabc6ca4a81c..e3a673a00845 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -387,17 +387,14 @@ acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
387 if (!value) 387 if (!value)
388 value = &dummy; 388 value = &dummy;
389 389
390 switch (width) { 390 *value = 0;
391 case 8: 391 if (width <= 8) {
392 *(u8 *) value = inb(port); 392 *(u8 *) value = inb(port);
393 break; 393 } else if (width <= 16) {
394 case 16:
395 *(u16 *) value = inw(port); 394 *(u16 *) value = inw(port);
396 break; 395 } else if (width <= 32) {
397 case 32:
398 *(u32 *) value = inl(port); 396 *(u32 *) value = inl(port);
399 break; 397 } else {
400 default:
401 BUG(); 398 BUG();
402 } 399 }
403 400
@@ -408,17 +405,13 @@ EXPORT_SYMBOL(acpi_os_read_port);
408 405
409acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) 406acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
410{ 407{
411 switch (width) { 408 if (width <= 8) {
412 case 8:
413 outb(value, port); 409 outb(value, port);
414 break; 410 } else if (width <= 16) {
415 case 16:
416 outw(value, port); 411 outw(value, port);
417 break; 412 } else if (width <= 32) {
418 case 32:
419 outl(value, port); 413 outl(value, port);
420 break; 414 } else {
421 default:
422 BUG(); 415 BUG();
423 } 416 }
424 417
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 235a51e328c3..e48ee4f8749f 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -494,7 +494,7 @@ static int get_cpu_id(acpi_handle handle, u32 acpi_id)
494 if (apic_id == -1) 494 if (apic_id == -1)
495 return apic_id; 495 return apic_id;
496 496
497 for (i = 0; i < NR_CPUS; ++i) { 497 for_each_possible_cpu(i) {
498 if (cpu_physical_id(i) == apic_id) 498 if (cpu_physical_id(i) == apic_id)
499 return i; 499 return i;
500 } 500 }
@@ -612,12 +612,6 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid)
612 request_region(pr->throttling.address, 6, "ACPI CPU throttle"); 612 request_region(pr->throttling.address, 6, "ACPI CPU throttle");
613 } 613 }
614 614
615#ifdef CONFIG_CPU_FREQ
616 acpi_processor_ppc_has_changed(pr);
617#endif
618 acpi_processor_get_throttling_info(pr);
619 acpi_processor_get_limit_info(pr);
620
621 return 0; 615 return 0;
622} 616}
623 617
@@ -638,7 +632,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
638 return 0; 632 return 0;
639 } 633 }
640 634
641 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0)); 635 BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
642 636
643 /* 637 /*
644 * Buggy BIOS check 638 * Buggy BIOS check
@@ -647,7 +641,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
647 */ 641 */
648 if (processor_device_array[pr->id] != NULL && 642 if (processor_device_array[pr->id] != NULL &&
649 processor_device_array[pr->id] != device) { 643 processor_device_array[pr->id] != device) {
650 printk(KERN_WARNING "BIOS reported wrong ACPI id" 644 printk(KERN_WARNING "BIOS reported wrong ACPI id "
651 "for the processor\n"); 645 "for the processor\n");
652 return -ENODEV; 646 return -ENODEV;
653 } 647 }
@@ -665,6 +659,12 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
665 /* _PDC call should be done before doing anything else (if reqd.). */ 659 /* _PDC call should be done before doing anything else (if reqd.). */
666 arch_acpi_processor_init_pdc(pr); 660 arch_acpi_processor_init_pdc(pr);
667 acpi_processor_set_pdc(pr); 661 acpi_processor_set_pdc(pr);
662#ifdef CONFIG_CPU_FREQ
663 acpi_processor_ppc_has_changed(pr);
664#endif
665 acpi_processor_get_throttling_info(pr);
666 acpi_processor_get_limit_info(pr);
667
668 668
669 acpi_processor_power_init(pr, device); 669 acpi_processor_power_init(pr, device);
670 670
@@ -684,7 +684,7 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
684{ 684{
685 struct acpi_processor *pr = data; 685 struct acpi_processor *pr = data;
686 struct acpi_device *device = NULL; 686 struct acpi_device *device = NULL;
687 687 int saved;
688 688
689 if (!pr) 689 if (!pr)
690 return; 690 return;
@@ -694,7 +694,10 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
694 694
695 switch (event) { 695 switch (event) {
696 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: 696 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
697 saved = pr->performance_platform_limit;
697 acpi_processor_ppc_has_changed(pr); 698 acpi_processor_ppc_has_changed(pr);
699 if (saved == pr->performance_platform_limit)
700 break;
698 acpi_bus_generate_proc_event(device, event, 701 acpi_bus_generate_proc_event(device, event,
699 pr->performance_platform_limit); 702 pr->performance_platform_limit);
700 acpi_bus_generate_netlink_event(device->pnp.device_class, 703 acpi_bus_generate_netlink_event(device->pnp.device_class,
@@ -771,7 +774,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
771 774
772 pr = acpi_driver_data(device); 775 pr = acpi_driver_data(device);
773 776
774 if (pr->id >= NR_CPUS) { 777 if (pr->id >= nr_cpu_ids) {
775 kfree(pr); 778 kfree(pr);
776 return 0; 779 return 0;
777 } 780 }
@@ -842,7 +845,7 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
842 if (!pr) 845 if (!pr)
843 return -ENODEV; 846 return -ENODEV;
844 847
845 if ((pr->id >= 0) && (pr->id < NR_CPUS)) { 848 if ((pr->id >= 0) && (pr->id < nr_cpu_ids)) {
846 kobject_uevent(&(*device)->dev.kobj, KOBJ_ONLINE); 849 kobject_uevent(&(*device)->dev.kobj, KOBJ_ONLINE);
847 } 850 }
848 return 0; 851 return 0;
@@ -880,13 +883,13 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
880 break; 883 break;
881 } 884 }
882 885
883 if (pr->id >= 0 && (pr->id < NR_CPUS)) { 886 if (pr->id >= 0 && (pr->id < nr_cpu_ids)) {
884 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); 887 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
885 break; 888 break;
886 } 889 }
887 890
888 result = acpi_processor_start(device); 891 result = acpi_processor_start(device);
889 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { 892 if ((!result) && ((pr->id >= 0) && (pr->id < nr_cpu_ids))) {
890 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); 893 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
891 } else { 894 } else {
892 printk(KERN_ERR PREFIX "Device [%s] failed to start\n", 895 printk(KERN_ERR PREFIX "Device [%s] failed to start\n",
@@ -909,7 +912,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
909 return; 912 return;
910 } 913 }
911 914
912 if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) 915 if ((pr->id < nr_cpu_ids) && (cpu_present(pr->id)))
913 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); 916 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
914 break; 917 break;
915 default: 918 default:
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index f996d0e37689..b1fbee3f7fe1 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -197,6 +197,19 @@ static inline u32 ticks_elapsed_in_us(u32 t1, u32 t2)
197 return PM_TIMER_TICKS_TO_US((0xFFFFFFFF - t1) + t2); 197 return PM_TIMER_TICKS_TO_US((0xFFFFFFFF - t1) + t2);
198} 198}
199 199
200static void acpi_safe_halt(void)
201{
202 current_thread_info()->status &= ~TS_POLLING;
203 /*
204 * TS_POLLING-cleared state must be visible before we
205 * test NEED_RESCHED:
206 */
207 smp_mb();
208 if (!need_resched())
209 safe_halt();
210 current_thread_info()->status |= TS_POLLING;
211}
212
200#ifndef CONFIG_CPU_IDLE 213#ifndef CONFIG_CPU_IDLE
201 214
202static void 215static void
@@ -239,19 +252,6 @@ acpi_processor_power_activate(struct acpi_processor *pr,
239 return; 252 return;
240} 253}
241 254
242static void acpi_safe_halt(void)
243{
244 current_thread_info()->status &= ~TS_POLLING;
245 /*
246 * TS_POLLING-cleared state must be visible before we
247 * test NEED_RESCHED:
248 */
249 smp_mb();
250 if (!need_resched())
251 safe_halt();
252 current_thread_info()->status |= TS_POLLING;
253}
254
255static atomic_t c3_cpu_count; 255static atomic_t c3_cpu_count;
256 256
257/* Common C-state entry for C2, C3, .. */ 257/* Common C-state entry for C2, C3, .. */
@@ -1373,15 +1373,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
1373 if (pr->flags.bm_check) 1373 if (pr->flags.bm_check)
1374 acpi_idle_update_bm_rld(pr, cx); 1374 acpi_idle_update_bm_rld(pr, cx);
1375 1375
1376 current_thread_info()->status &= ~TS_POLLING; 1376 acpi_safe_halt();
1377 /*
1378 * TS_POLLING-cleared state must be visible before we test
1379 * NEED_RESCHED:
1380 */
1381 smp_mb();
1382 if (!need_resched())
1383 safe_halt();
1384 current_thread_info()->status |= TS_POLLING;
1385 1377
1386 cx->usage++; 1378 cx->usage++;
1387 1379
@@ -1399,6 +1391,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1399 struct acpi_processor *pr; 1391 struct acpi_processor *pr;
1400 struct acpi_processor_cx *cx = cpuidle_get_statedata(state); 1392 struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
1401 u32 t1, t2; 1393 u32 t1, t2;
1394 int sleep_ticks = 0;
1395
1402 pr = processors[smp_processor_id()]; 1396 pr = processors[smp_processor_id()];
1403 1397
1404 if (unlikely(!pr)) 1398 if (unlikely(!pr))
@@ -1428,6 +1422,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1428 ACPI_FLUSH_CPU_CACHE(); 1422 ACPI_FLUSH_CPU_CACHE();
1429 1423
1430 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); 1424 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
1425 /* Tell the scheduler that we are going deep-idle: */
1426 sched_clock_idle_sleep_event();
1431 acpi_state_timer_broadcast(pr, cx, 1); 1427 acpi_state_timer_broadcast(pr, cx, 1);
1432 acpi_idle_do_entry(cx); 1428 acpi_idle_do_entry(cx);
1433 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 1429 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
@@ -1436,6 +1432,10 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1436 /* TSC could halt in idle, so notify users */ 1432 /* TSC could halt in idle, so notify users */
1437 mark_tsc_unstable("TSC halts in idle");; 1433 mark_tsc_unstable("TSC halts in idle");;
1438#endif 1434#endif
1435 sleep_ticks = ticks_elapsed(t1, t2);
1436
1437 /* Tell the scheduler how much we idled: */
1438 sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
1439 1439
1440 local_irq_enable(); 1440 local_irq_enable();
1441 current_thread_info()->status |= TS_POLLING; 1441 current_thread_info()->status |= TS_POLLING;
@@ -1443,7 +1443,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1443 cx->usage++; 1443 cx->usage++;
1444 1444
1445 acpi_state_timer_broadcast(pr, cx, 0); 1445 acpi_state_timer_broadcast(pr, cx, 0);
1446 cx->time += ticks_elapsed(t1, t2); 1446 cx->time += sleep_ticks;
1447 return ticks_elapsed_in_us(t1, t2); 1447 return ticks_elapsed_in_us(t1, t2);
1448} 1448}
1449 1449
@@ -1463,6 +1463,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1463 struct acpi_processor *pr; 1463 struct acpi_processor *pr;
1464 struct acpi_processor_cx *cx = cpuidle_get_statedata(state); 1464 struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
1465 u32 t1, t2; 1465 u32 t1, t2;
1466 int sleep_ticks = 0;
1467
1466 pr = processors[smp_processor_id()]; 1468 pr = processors[smp_processor_id()];
1467 1469
1468 if (unlikely(!pr)) 1470 if (unlikely(!pr))
@@ -1471,6 +1473,15 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1471 if (acpi_idle_suspend) 1473 if (acpi_idle_suspend)
1472 return(acpi_idle_enter_c1(dev, state)); 1474 return(acpi_idle_enter_c1(dev, state));
1473 1475
1476 if (acpi_idle_bm_check()) {
1477 if (dev->safe_state) {
1478 return dev->safe_state->enter(dev, dev->safe_state);
1479 } else {
1480 acpi_safe_halt();
1481 return 0;
1482 }
1483 }
1484
1474 local_irq_disable(); 1485 local_irq_disable();
1475 current_thread_info()->status &= ~TS_POLLING; 1486 current_thread_info()->status &= ~TS_POLLING;
1476 /* 1487 /*
@@ -1485,38 +1496,45 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1485 return 0; 1496 return 0;
1486 } 1497 }
1487 1498
1499 /* Tell the scheduler that we are going deep-idle: */
1500 sched_clock_idle_sleep_event();
1488 /* 1501 /*
1489 * Must be done before busmaster disable as we might need to 1502 * Must be done before busmaster disable as we might need to
1490 * access HPET ! 1503 * access HPET !
1491 */ 1504 */
1492 acpi_state_timer_broadcast(pr, cx, 1); 1505 acpi_state_timer_broadcast(pr, cx, 1);
1493 1506
1494 if (acpi_idle_bm_check()) { 1507 acpi_idle_update_bm_rld(pr, cx);
1495 cx = pr->power.bm_state;
1496
1497 acpi_idle_update_bm_rld(pr, cx);
1498
1499 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
1500 acpi_idle_do_entry(cx);
1501 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
1502 } else {
1503 acpi_idle_update_bm_rld(pr, cx);
1504 1508
1509 /*
1510 * disable bus master
1511 * bm_check implies we need ARB_DIS
1512 * !bm_check implies we need cache flush
1513 * bm_control implies whether we can do ARB_DIS
1514 *
1515 * That leaves a case where bm_check is set and bm_control is
1516 * not set. In that case we cannot do much, we enter C3
1517 * without doing anything.
1518 */
1519 if (pr->flags.bm_check && pr->flags.bm_control) {
1505 spin_lock(&c3_lock); 1520 spin_lock(&c3_lock);
1506 c3_cpu_count++; 1521 c3_cpu_count++;
1507 /* Disable bus master arbitration when all CPUs are in C3 */ 1522 /* Disable bus master arbitration when all CPUs are in C3 */
1508 if (c3_cpu_count == num_online_cpus()) 1523 if (c3_cpu_count == num_online_cpus())
1509 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); 1524 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1);
1510 spin_unlock(&c3_lock); 1525 spin_unlock(&c3_lock);
1526 } else if (!pr->flags.bm_check) {
1527 ACPI_FLUSH_CPU_CACHE();
1528 }
1511 1529
1512 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); 1530 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
1513 acpi_idle_do_entry(cx); 1531 acpi_idle_do_entry(cx);
1514 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 1532 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
1515 1533
1534 /* Re-enable bus master arbitration */
1535 if (pr->flags.bm_check && pr->flags.bm_control) {
1516 spin_lock(&c3_lock); 1536 spin_lock(&c3_lock);
1517 /* Re-enable bus master arbitration */ 1537 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
1518 if (c3_cpu_count == num_online_cpus())
1519 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
1520 c3_cpu_count--; 1538 c3_cpu_count--;
1521 spin_unlock(&c3_lock); 1539 spin_unlock(&c3_lock);
1522 } 1540 }
@@ -1525,6 +1543,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1525 /* TSC could halt in idle, so notify users */ 1543 /* TSC could halt in idle, so notify users */
1526 mark_tsc_unstable("TSC halts in idle"); 1544 mark_tsc_unstable("TSC halts in idle");
1527#endif 1545#endif
1546 sleep_ticks = ticks_elapsed(t1, t2);
1547 /* Tell the scheduler how much we idled: */
1548 sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
1528 1549
1529 local_irq_enable(); 1550 local_irq_enable();
1530 current_thread_info()->status |= TS_POLLING; 1551 current_thread_info()->status |= TS_POLLING;
@@ -1532,7 +1553,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1532 cx->usage++; 1553 cx->usage++;
1533 1554
1534 acpi_state_timer_broadcast(pr, cx, 0); 1555 acpi_state_timer_broadcast(pr, cx, 0);
1535 cx->time += ticks_elapsed(t1, t2); 1556 cx->time += sleep_ticks;
1536 return ticks_elapsed_in_us(t1, t2); 1557 return ticks_elapsed_in_us(t1, t2);
1537} 1558}
1538 1559
@@ -1584,12 +1605,14 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
1584 case ACPI_STATE_C1: 1605 case ACPI_STATE_C1:
1585 state->flags |= CPUIDLE_FLAG_SHALLOW; 1606 state->flags |= CPUIDLE_FLAG_SHALLOW;
1586 state->enter = acpi_idle_enter_c1; 1607 state->enter = acpi_idle_enter_c1;
1608 dev->safe_state = state;
1587 break; 1609 break;
1588 1610
1589 case ACPI_STATE_C2: 1611 case ACPI_STATE_C2:
1590 state->flags |= CPUIDLE_FLAG_BALANCED; 1612 state->flags |= CPUIDLE_FLAG_BALANCED;
1591 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1613 state->flags |= CPUIDLE_FLAG_TIME_VALID;
1592 state->enter = acpi_idle_enter_simple; 1614 state->enter = acpi_idle_enter_simple;
1615 dev->safe_state = state;
1593 break; 1616 break;
1594 1617
1595 case ACPI_STATE_C3: 1618 case ACPI_STATE_C3:
@@ -1610,14 +1633,6 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
1610 if (!count) 1633 if (!count)
1611 return -EINVAL; 1634 return -EINVAL;
1612 1635
1613 /* find the deepest state that can handle active BM */
1614 if (pr->flags.bm_check) {
1615 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++)
1616 if (pr->power.states[i].type == ACPI_STATE_C3)
1617 break;
1618 pr->power.bm_state = &pr->power.states[i-1];
1619 }
1620
1621 return 0; 1636 return 0;
1622} 1637}
1623 1638
@@ -1658,6 +1673,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1658 1673
1659 if (!first_run) { 1674 if (!first_run) {
1660 dmi_check_system(processor_power_dmi_table); 1675 dmi_check_system(processor_power_dmi_table);
1676 max_cstate = acpi_processor_cstate_check(max_cstate);
1661 if (max_cstate < ACPI_C_STATES_MAX) 1677 if (max_cstate < ACPI_C_STATES_MAX)
1662 printk(KERN_NOTICE 1678 printk(KERN_NOTICE
1663 "ACPI: processor limited to max C-state %d\n", 1679 "ACPI: processor limited to max C-state %d\n",
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 0b8204e7082a..c26c61fb36c3 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -70,7 +70,55 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
70 70
71int acpi_processor_tstate_has_changed(struct acpi_processor *pr) 71int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
72{ 72{
73 return acpi_processor_get_platform_limit(pr); 73 int result = 0;
74 int throttling_limit;
75 int current_state;
76 struct acpi_processor_limit *limit;
77 int target_state;
78
79 result = acpi_processor_get_platform_limit(pr);
80 if (result) {
81 /* Throttling Limit is unsupported */
82 return result;
83 }
84
85 throttling_limit = pr->throttling_platform_limit;
86 if (throttling_limit >= pr->throttling.state_count) {
87 /* Uncorrect Throttling Limit */
88 return -EINVAL;
89 }
90
91 current_state = pr->throttling.state;
92 if (current_state > throttling_limit) {
93 /*
94 * The current state can meet the requirement of
95 * _TPC limit. But it is reasonable that OSPM changes
96 * t-states from high to low for better performance.
97 * Of course the limit condition of thermal
98 * and user should be considered.
99 */
100 limit = &pr->limit;
101 target_state = throttling_limit;
102 if (limit->thermal.tx > target_state)
103 target_state = limit->thermal.tx;
104 if (limit->user.tx > target_state)
105 target_state = limit->user.tx;
106 } else if (current_state == throttling_limit) {
107 /*
108 * Unnecessary to change the throttling state
109 */
110 return 0;
111 } else {
112 /*
113 * If the current state is lower than the limit of _TPC, it
114 * will be forced to switch to the throttling state defined
115 * by throttling_platfor_limit.
116 * Because the previous state meets with the limit condition
117 * of thermal and user, it is unnecessary to check it again.
118 */
119 target_state = throttling_limit;
120 }
121 return acpi_processor_set_throttling(pr, target_state);
74} 122}
75 123
76/* 124/*
@@ -83,6 +131,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
83 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 131 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
84 union acpi_object *ptc = NULL; 132 union acpi_object *ptc = NULL;
85 union acpi_object obj = { 0 }; 133 union acpi_object obj = { 0 };
134 struct acpi_processor_throttling *throttling;
86 135
87 status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer); 136 status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
88 if (ACPI_FAILURE(status)) { 137 if (ACPI_FAILURE(status)) {
@@ -134,6 +183,22 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
134 memcpy(&pr->throttling.status_register, obj.buffer.pointer, 183 memcpy(&pr->throttling.status_register, obj.buffer.pointer,
135 sizeof(struct acpi_ptc_register)); 184 sizeof(struct acpi_ptc_register));
136 185
186 throttling = &pr->throttling;
187
188 if ((throttling->control_register.bit_width +
189 throttling->control_register.bit_offset) > 32) {
190 printk(KERN_ERR PREFIX "Invalid _PTC control register\n");
191 result = -EFAULT;
192 goto end;
193 }
194
195 if ((throttling->status_register.bit_width +
196 throttling->status_register.bit_offset) > 32) {
197 printk(KERN_ERR PREFIX "Invalid _PTC status register\n");
198 result = -EFAULT;
199 goto end;
200 }
201
137 end: 202 end:
138 kfree(buffer.pointer); 203 kfree(buffer.pointer);
139 204
@@ -328,44 +393,132 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
328 return 0; 393 return 0;
329} 394}
330 395
331static int acpi_read_throttling_status(struct acpi_processor_throttling 396#ifdef CONFIG_X86
332 *throttling) 397static int acpi_throttling_rdmsr(struct acpi_processor *pr,
398 acpi_integer * value)
333{ 399{
334 int value = -1; 400 struct cpuinfo_x86 *c;
401 u64 msr_high, msr_low;
402 unsigned int cpu;
403 u64 msr = 0;
404 int ret = -1;
405
406 cpu = pr->id;
407 c = &cpu_data(cpu);
408
409 if ((c->x86_vendor != X86_VENDOR_INTEL) ||
410 !cpu_has(c, X86_FEATURE_ACPI)) {
411 printk(KERN_ERR PREFIX
412 "HARDWARE addr space,NOT supported yet\n");
413 } else {
414 msr_low = 0;
415 msr_high = 0;
416 rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
417 (u32 *)&msr_low , (u32 *) &msr_high);
418 msr = (msr_high << 32) | msr_low;
419 *value = (acpi_integer) msr;
420 ret = 0;
421 }
422 return ret;
423}
424
425static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
426{
427 struct cpuinfo_x86 *c;
428 unsigned int cpu;
429 int ret = -1;
430 u64 msr;
431
432 cpu = pr->id;
433 c = &cpu_data(cpu);
434
435 if ((c->x86_vendor != X86_VENDOR_INTEL) ||
436 !cpu_has(c, X86_FEATURE_ACPI)) {
437 printk(KERN_ERR PREFIX
438 "HARDWARE addr space,NOT supported yet\n");
439 } else {
440 msr = value;
441 wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
442 msr & 0xffffffff, msr >> 32);
443 ret = 0;
444 }
445 return ret;
446}
447#else
448static int acpi_throttling_rdmsr(struct acpi_processor *pr,
449 acpi_integer * value)
450{
451 printk(KERN_ERR PREFIX
452 "HARDWARE addr space,NOT supported yet\n");
453 return -1;
454}
455
456static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
457{
458 printk(KERN_ERR PREFIX
459 "HARDWARE addr space,NOT supported yet\n");
460 return -1;
461}
462#endif
463
464static int acpi_read_throttling_status(struct acpi_processor *pr,
465 acpi_integer *value)
466{
467 u32 bit_width, bit_offset;
468 u64 ptc_value;
469 u64 ptc_mask;
470 struct acpi_processor_throttling *throttling;
471 int ret = -1;
472
473 throttling = &pr->throttling;
335 switch (throttling->status_register.space_id) { 474 switch (throttling->status_register.space_id) {
336 case ACPI_ADR_SPACE_SYSTEM_IO: 475 case ACPI_ADR_SPACE_SYSTEM_IO:
476 ptc_value = 0;
477 bit_width = throttling->status_register.bit_width;
478 bit_offset = throttling->status_register.bit_offset;
479
337 acpi_os_read_port((acpi_io_address) throttling->status_register. 480 acpi_os_read_port((acpi_io_address) throttling->status_register.
338 address, &value, 481 address, (u32 *) &ptc_value,
339 (u32) throttling->status_register.bit_width * 482 (u32) (bit_width + bit_offset));
340 8); 483 ptc_mask = (1 << bit_width) - 1;
484 *value = (acpi_integer) ((ptc_value >> bit_offset) & ptc_mask);
485 ret = 0;
341 break; 486 break;
342 case ACPI_ADR_SPACE_FIXED_HARDWARE: 487 case ACPI_ADR_SPACE_FIXED_HARDWARE:
343 printk(KERN_ERR PREFIX 488 ret = acpi_throttling_rdmsr(pr, value);
344 "HARDWARE addr space,NOT supported yet\n");
345 break; 489 break;
346 default: 490 default:
347 printk(KERN_ERR PREFIX "Unknown addr space %d\n", 491 printk(KERN_ERR PREFIX "Unknown addr space %d\n",
348 (u32) (throttling->status_register.space_id)); 492 (u32) (throttling->status_register.space_id));
349 } 493 }
350 return value; 494 return ret;
351} 495}
352 496
353static int acpi_write_throttling_state(struct acpi_processor_throttling 497static int acpi_write_throttling_state(struct acpi_processor *pr,
354 *throttling, int value) 498 acpi_integer value)
355{ 499{
500 u32 bit_width, bit_offset;
501 u64 ptc_value;
502 u64 ptc_mask;
503 struct acpi_processor_throttling *throttling;
356 int ret = -1; 504 int ret = -1;
357 505
506 throttling = &pr->throttling;
358 switch (throttling->control_register.space_id) { 507 switch (throttling->control_register.space_id) {
359 case ACPI_ADR_SPACE_SYSTEM_IO: 508 case ACPI_ADR_SPACE_SYSTEM_IO:
509 bit_width = throttling->control_register.bit_width;
510 bit_offset = throttling->control_register.bit_offset;
511 ptc_mask = (1 << bit_width) - 1;
512 ptc_value = value & ptc_mask;
513
360 acpi_os_write_port((acpi_io_address) throttling-> 514 acpi_os_write_port((acpi_io_address) throttling->
361 control_register.address, value, 515 control_register.address,
362 (u32) throttling->control_register. 516 (u32) (ptc_value << bit_offset),
363 bit_width * 8); 517 (u32) (bit_width + bit_offset));
364 ret = 0; 518 ret = 0;
365 break; 519 break;
366 case ACPI_ADR_SPACE_FIXED_HARDWARE: 520 case ACPI_ADR_SPACE_FIXED_HARDWARE:
367 printk(KERN_ERR PREFIX 521 ret = acpi_throttling_wrmsr(pr, value);
368 "HARDWARE addr space,NOT supported yet\n");
369 break; 522 break;
370 default: 523 default:
371 printk(KERN_ERR PREFIX "Unknown addr space %d\n", 524 printk(KERN_ERR PREFIX "Unknown addr space %d\n",
@@ -374,7 +527,8 @@ static int acpi_write_throttling_state(struct acpi_processor_throttling
374 return ret; 527 return ret;
375} 528}
376 529
377static int acpi_get_throttling_state(struct acpi_processor *pr, int value) 530static int acpi_get_throttling_state(struct acpi_processor *pr,
531 acpi_integer value)
378{ 532{
379 int i; 533 int i;
380 534
@@ -390,22 +544,26 @@ static int acpi_get_throttling_state(struct acpi_processor *pr, int value)
390 return i; 544 return i;
391} 545}
392 546
393static int acpi_get_throttling_value(struct acpi_processor *pr, int state) 547static int acpi_get_throttling_value(struct acpi_processor *pr,
548 int state, acpi_integer *value)
394{ 549{
395 int value = -1; 550 int ret = -1;
551
396 if (state >= 0 && state <= pr->throttling.state_count) { 552 if (state >= 0 && state <= pr->throttling.state_count) {
397 struct acpi_processor_tx_tss *tx = 553 struct acpi_processor_tx_tss *tx =
398 (struct acpi_processor_tx_tss *)&(pr->throttling. 554 (struct acpi_processor_tx_tss *)&(pr->throttling.
399 states_tss[state]); 555 states_tss[state]);
400 value = tx->control; 556 *value = tx->control;
557 ret = 0;
401 } 558 }
402 return value; 559 return ret;
403} 560}
404 561
405static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) 562static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
406{ 563{
407 int state = 0; 564 int state = 0;
408 u32 value = 0; 565 int ret;
566 acpi_integer value;
409 567
410 if (!pr) 568 if (!pr)
411 return -EINVAL; 569 return -EINVAL;
@@ -415,8 +573,9 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
415 573
416 pr->throttling.state = 0; 574 pr->throttling.state = 0;
417 local_irq_disable(); 575 local_irq_disable();
418 value = acpi_read_throttling_status(&pr->throttling); 576 value = 0;
419 if (value >= 0) { 577 ret = acpi_read_throttling_status(pr, &value);
578 if (ret >= 0) {
420 state = acpi_get_throttling_state(pr, value); 579 state = acpi_get_throttling_state(pr, value);
421 pr->throttling.state = state; 580 pr->throttling.state = state;
422 } 581 }
@@ -430,6 +589,40 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
430 return pr->throttling.acpi_processor_get_throttling(pr); 589 return pr->throttling.acpi_processor_get_throttling(pr);
431} 590}
432 591
592static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
593{
594 int i, step;
595
596 if (!pr->throttling.address) {
597 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
598 return -EINVAL;
599 } else if (!pr->throttling.duty_width) {
600 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
601 return -EINVAL;
602 }
603 /* TBD: Support duty_cycle values that span bit 4. */
604 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
605 printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
606 return -EINVAL;
607 }
608
609 pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
610
611 /*
612 * Compute state values. Note that throttling displays a linear power
613 * performance relationship (at 50% performance the CPU will consume
614 * 50% power). Values are in 1/10th of a percent to preserve accuracy.
615 */
616
617 step = (1000 / pr->throttling.state_count);
618
619 for (i = 0; i < pr->throttling.state_count; i++) {
620 pr->throttling.states[i].performance = 1000 - step * i;
621 pr->throttling.states[i].power = 1000 - step * i;
622 }
623 return 0;
624}
625
433static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, 626static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
434 int state) 627 int state)
435{ 628{
@@ -506,7 +699,8 @@ static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
506static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, 699static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
507 int state) 700 int state)
508{ 701{
509 u32 value = 0; 702 int ret;
703 acpi_integer value;
510 704
511 if (!pr) 705 if (!pr)
512 return -EINVAL; 706 return -EINVAL;
@@ -524,10 +718,10 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
524 return -EPERM; 718 return -EPERM;
525 719
526 local_irq_disable(); 720 local_irq_disable();
527 721 value = 0;
528 value = acpi_get_throttling_value(pr, state); 722 ret = acpi_get_throttling_value(pr, state, &value);
529 if (value >= 0) { 723 if (ret >= 0) {
530 acpi_write_throttling_state(&pr->throttling, value); 724 acpi_write_throttling_state(pr, value);
531 pr->throttling.state = state; 725 pr->throttling.state = state;
532 } 726 }
533 local_irq_enable(); 727 local_irq_enable();
@@ -543,8 +737,6 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
543int acpi_processor_get_throttling_info(struct acpi_processor *pr) 737int acpi_processor_get_throttling_info(struct acpi_processor *pr)
544{ 738{
545 int result = 0; 739 int result = 0;
546 int step = 0;
547 int i = 0;
548 740
549 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 741 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
550 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 742 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -563,6 +755,8 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
563 acpi_processor_get_throttling_states(pr) || 755 acpi_processor_get_throttling_states(pr) ||
564 acpi_processor_get_platform_limit(pr)) 756 acpi_processor_get_platform_limit(pr))
565 { 757 {
758 if (acpi_processor_get_fadt_info(pr))
759 return 0;
566 pr->throttling.acpi_processor_get_throttling = 760 pr->throttling.acpi_processor_get_throttling =
567 &acpi_processor_get_throttling_fadt; 761 &acpi_processor_get_throttling_fadt;
568 pr->throttling.acpi_processor_set_throttling = 762 pr->throttling.acpi_processor_set_throttling =
@@ -576,19 +770,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
576 770
577 acpi_processor_get_tsd(pr); 771 acpi_processor_get_tsd(pr);
578 772
579 if (!pr->throttling.address) {
580 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
581 return 0;
582 } else if (!pr->throttling.duty_width) {
583 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
584 return 0;
585 }
586 /* TBD: Support duty_cycle values that span bit 4. */
587 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
588 printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
589 return 0;
590 }
591
592 /* 773 /*
593 * PIIX4 Errata: We don't support throttling on the original PIIX4. 774 * PIIX4 Errata: We don't support throttling on the original PIIX4.
594 * This shouldn't be an issue as few (if any) mobile systems ever 775 * This shouldn't be an issue as few (if any) mobile systems ever
@@ -600,21 +781,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
600 return 0; 781 return 0;
601 } 782 }
602 783
603 pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
604
605 /*
606 * Compute state values. Note that throttling displays a linear power/
607 * performance relationship (at 50% performance the CPU will consume
608 * 50% power). Values are in 1/10th of a percent to preserve accuracy.
609 */
610
611 step = (1000 / pr->throttling.state_count);
612
613 for (i = 0; i < pr->throttling.state_count; i++) {
614 pr->throttling.states[i].performance = step * i;
615 pr->throttling.states[i].power = step * i;
616 }
617
618 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", 784 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
619 pr->throttling.state_count)); 785 pr->throttling.state_count));
620 786
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 90fd09c65f95..6045cdbe176b 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -29,7 +29,7 @@
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31 31
32#ifdef CONFIG_ACPI_PROCFS 32#ifdef CONFIG_ACPI_PROCFS_POWER
33#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
34#include <linux/seq_file.h> 34#include <linux/seq_file.h>
35#include <asm/uaccess.h> 35#include <asm/uaccess.h>
@@ -88,7 +88,7 @@ MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
88struct acpi_battery { 88struct acpi_battery {
89 struct power_supply bat; 89 struct power_supply bat;
90 struct acpi_sbs *sbs; 90 struct acpi_sbs *sbs;
91#ifdef CONFIG_ACPI_PROCFS 91#ifdef CONFIG_ACPI_PROCFS_POWER
92 struct proc_dir_entry *proc_entry; 92 struct proc_dir_entry *proc_entry;
93#endif 93#endif
94 unsigned long update_time; 94 unsigned long update_time;
@@ -113,6 +113,7 @@ struct acpi_battery {
113 u16 spec; 113 u16 spec;
114 u8 id; 114 u8 id;
115 u8 present:1; 115 u8 present:1;
116 u8 have_sysfs_alarm:1;
116}; 117};
117 118
118#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); 119#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat);
@@ -122,7 +123,7 @@ struct acpi_sbs {
122 struct acpi_device *device; 123 struct acpi_device *device;
123 struct acpi_smb_hc *hc; 124 struct acpi_smb_hc *hc;
124 struct mutex lock; 125 struct mutex lock;
125#ifdef CONFIG_ACPI_PROCFS 126#ifdef CONFIG_ACPI_PROCFS_POWER
126 struct proc_dir_entry *charger_entry; 127 struct proc_dir_entry *charger_entry;
127#endif 128#endif
128 struct acpi_battery battery[MAX_SBS_BAT]; 129 struct acpi_battery battery[MAX_SBS_BAT];
@@ -468,7 +469,7 @@ static struct device_attribute alarm_attr = {
468 FS Interface (/proc/acpi) 469 FS Interface (/proc/acpi)
469 -------------------------------------------------------------------------- */ 470 -------------------------------------------------------------------------- */
470 471
471#ifdef CONFIG_ACPI_PROCFS 472#ifdef CONFIG_ACPI_PROCFS_POWER
472/* Generic Routines */ 473/* Generic Routines */
473static int 474static int
474acpi_sbs_add_fs(struct proc_dir_entry **dir, 475acpi_sbs_add_fs(struct proc_dir_entry **dir,
@@ -789,7 +790,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
789 return result; 790 return result;
790 791
791 sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); 792 sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id);
792#ifdef CONFIG_ACPI_PROCFS 793#ifdef CONFIG_ACPI_PROCFS_POWER
793 acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir, 794 acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir,
794 battery->name, &acpi_battery_info_fops, 795 battery->name, &acpi_battery_info_fops,
795 &acpi_battery_state_fops, &acpi_battery_alarm_fops, 796 &acpi_battery_state_fops, &acpi_battery_alarm_fops,
@@ -808,7 +809,13 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
808 } 809 }
809 battery->bat.get_property = acpi_sbs_battery_get_property; 810 battery->bat.get_property = acpi_sbs_battery_get_property;
810 result = power_supply_register(&sbs->device->dev, &battery->bat); 811 result = power_supply_register(&sbs->device->dev, &battery->bat);
811 device_create_file(battery->bat.dev, &alarm_attr); 812 if (result)
813 goto end;
814 result = device_create_file(battery->bat.dev, &alarm_attr);
815 if (result)
816 goto end;
817 battery->have_sysfs_alarm = 1;
818 end:
812 printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", 819 printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n",
813 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), 820 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device),
814 battery->name, sbs->battery->present ? "present" : "absent"); 821 battery->name, sbs->battery->present ? "present" : "absent");
@@ -817,14 +824,16 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
817 824
818static void acpi_battery_remove(struct acpi_sbs *sbs, int id) 825static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
819{ 826{
820 if (sbs->battery[id].bat.dev) 827 struct acpi_battery *battery = &sbs->battery[id];
821 device_remove_file(sbs->battery[id].bat.dev, &alarm_attr); 828
822 power_supply_unregister(&sbs->battery[id].bat); 829 if (battery->bat.dev) {
823#ifdef CONFIG_ACPI_PROCFS 830 if (battery->have_sysfs_alarm)
824 if (sbs->battery[id].proc_entry) { 831 device_remove_file(battery->bat.dev, &alarm_attr);
825 acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry), 832 power_supply_unregister(&battery->bat);
826 acpi_battery_dir);
827 } 833 }
834#ifdef CONFIG_ACPI_PROCFS_POWER
835 if (battery->proc_entry)
836 acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir);
828#endif 837#endif
829} 838}
830 839
@@ -835,7 +844,7 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
835 result = acpi_ac_get_present(sbs); 844 result = acpi_ac_get_present(sbs);
836 if (result) 845 if (result)
837 goto end; 846 goto end;
838#ifdef CONFIG_ACPI_PROCFS 847#ifdef CONFIG_ACPI_PROCFS_POWER
839 result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir, 848 result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir,
840 ACPI_AC_DIR_NAME, NULL, 849 ACPI_AC_DIR_NAME, NULL,
841 &acpi_ac_state_fops, NULL, sbs); 850 &acpi_ac_state_fops, NULL, sbs);
@@ -859,7 +868,7 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
859{ 868{
860 if (sbs->charger.dev) 869 if (sbs->charger.dev)
861 power_supply_unregister(&sbs->charger); 870 power_supply_unregister(&sbs->charger);
862#ifdef CONFIG_ACPI_PROCFS 871#ifdef CONFIG_ACPI_PROCFS_POWER
863 if (sbs->charger_entry) 872 if (sbs->charger_entry)
864 acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); 873 acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
865#endif 874#endif
@@ -965,7 +974,7 @@ static int acpi_sbs_remove(struct acpi_device *device, int type)
965 974
966static void acpi_sbs_rmdirs(void) 975static void acpi_sbs_rmdirs(void)
967{ 976{
968#ifdef CONFIG_ACPI_PROCFS 977#ifdef CONFIG_ACPI_PROCFS_POWER
969 if (acpi_ac_dir) { 978 if (acpi_ac_dir) {
970 acpi_unlock_ac_dir(acpi_ac_dir); 979 acpi_unlock_ac_dir(acpi_ac_dir);
971 acpi_ac_dir = NULL; 980 acpi_ac_dir = NULL;
@@ -1004,7 +1013,7 @@ static int __init acpi_sbs_init(void)
1004 1013
1005 if (acpi_disabled) 1014 if (acpi_disabled)
1006 return -ENODEV; 1015 return -ENODEV;
1007#ifdef CONFIG_ACPI_PROCFS 1016#ifdef CONFIG_ACPI_PROCFS_POWER
1008 acpi_ac_dir = acpi_lock_ac_dir(); 1017 acpi_ac_dir = acpi_lock_ac_dir();
1009 if (!acpi_ac_dir) 1018 if (!acpi_ac_dir)
1010 return -ENODEV; 1019 return -ENODEV;
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index 5f1d85f2ffe4..010f19652f80 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -449,7 +449,7 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
449 /* XSDT has NULL entry, RSDT is used */ 449 /* XSDT has NULL entry, RSDT is used */
450 address = rsdt_address; 450 address = rsdt_address;
451 table_entry_size = sizeof(u32); 451 table_entry_size = sizeof(u32);
452 ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry," 452 ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, "
453 "using RSDT")); 453 "using RSDT"));
454 } 454 }
455 } 455 }
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index bac956b30c57..44a0d9ba9bd6 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/list.h> 31#include <linux/list.h>
32#include <linux/mutex.h>
32#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
33#include <linux/seq_file.h> 34#include <linux/seq_file.h>
34#include <linux/input.h> 35#include <linux/input.h>
@@ -135,8 +136,8 @@ struct acpi_video_bus {
135 u8 attached_count; 136 u8 attached_count;
136 struct acpi_video_bus_cap cap; 137 struct acpi_video_bus_cap cap;
137 struct acpi_video_bus_flags flags; 138 struct acpi_video_bus_flags flags;
138 struct semaphore sem;
139 struct list_head video_device_list; 139 struct list_head video_device_list;
140 struct mutex device_list_lock; /* protects video_device_list */
140 struct proc_dir_entry *dir; 141 struct proc_dir_entry *dir;
141 struct input_dev *input; 142 struct input_dev *input;
142 char phys[32]; /* for input device */ 143 char phys[32]; /* for input device */
@@ -896,7 +897,7 @@ acpi_video_device_write_brightness(struct file *file,
896{ 897{
897 struct seq_file *m = file->private_data; 898 struct seq_file *m = file->private_data;
898 struct acpi_video_device *dev = m->private; 899 struct acpi_video_device *dev = m->private;
899 char str[4] = { 0 }; 900 char str[5] = { 0 };
900 unsigned int level = 0; 901 unsigned int level = 0;
901 int i; 902 int i;
902 903
@@ -1436,9 +1437,9 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1436 return -ENODEV; 1437 return -ENODEV;
1437 } 1438 }
1438 1439
1439 down(&video->sem); 1440 mutex_lock(&video->device_list_lock);
1440 list_add_tail(&data->entry, &video->video_device_list); 1441 list_add_tail(&data->entry, &video->video_device_list);
1441 up(&video->sem); 1442 mutex_unlock(&video->device_list_lock);
1442 1443
1443 acpi_video_device_add_fs(device); 1444 acpi_video_device_add_fs(device);
1444 1445
@@ -1462,12 +1463,14 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1462 1463
1463static void acpi_video_device_rebind(struct acpi_video_bus *video) 1464static void acpi_video_device_rebind(struct acpi_video_bus *video)
1464{ 1465{
1465 struct list_head *node, *next; 1466 struct acpi_video_device *dev;
1466 list_for_each_safe(node, next, &video->video_device_list) { 1467
1467 struct acpi_video_device *dev = 1468 mutex_lock(&video->device_list_lock);
1468 container_of(node, struct acpi_video_device, entry); 1469
1470 list_for_each_entry(dev, &video->video_device_list, entry)
1469 acpi_video_device_bind(video, dev); 1471 acpi_video_device_bind(video, dev);
1470 } 1472
1473 mutex_unlock(&video->device_list_lock);
1471} 1474}
1472 1475
1473/* 1476/*
@@ -1592,30 +1595,33 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1592 1595
1593static int acpi_video_switch_output(struct acpi_video_bus *video, int event) 1596static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
1594{ 1597{
1595 struct list_head *node, *next; 1598 struct list_head *node;
1596 struct acpi_video_device *dev = NULL; 1599 struct acpi_video_device *dev = NULL;
1597 struct acpi_video_device *dev_next = NULL; 1600 struct acpi_video_device *dev_next = NULL;
1598 struct acpi_video_device *dev_prev = NULL; 1601 struct acpi_video_device *dev_prev = NULL;
1599 unsigned long state; 1602 unsigned long state;
1600 int status = 0; 1603 int status = 0;
1601 1604
1605 mutex_lock(&video->device_list_lock);
1602 1606
1603 list_for_each_safe(node, next, &video->video_device_list) { 1607 list_for_each(node, &video->video_device_list) {
1604 dev = container_of(node, struct acpi_video_device, entry); 1608 dev = container_of(node, struct acpi_video_device, entry);
1605 status = acpi_video_device_get_state(dev, &state); 1609 status = acpi_video_device_get_state(dev, &state);
1606 if (state & 0x2) { 1610 if (state & 0x2) {
1607 dev_next = 1611 dev_next = container_of(node->next,
1608 container_of(node->next, struct acpi_video_device, 1612 struct acpi_video_device, entry);
1609 entry); 1613 dev_prev = container_of(node->prev,
1610 dev_prev = 1614 struct acpi_video_device, entry);
1611 container_of(node->prev, struct acpi_video_device,
1612 entry);
1613 goto out; 1615 goto out;
1614 } 1616 }
1615 } 1617 }
1618
1616 dev_next = container_of(node->next, struct acpi_video_device, entry); 1619 dev_next = container_of(node->next, struct acpi_video_device, entry);
1617 dev_prev = container_of(node->prev, struct acpi_video_device, entry); 1620 dev_prev = container_of(node->prev, struct acpi_video_device, entry);
1618 out: 1621
1622 out:
1623 mutex_unlock(&video->device_list_lock);
1624
1619 switch (event) { 1625 switch (event) {
1620 case ACPI_VIDEO_NOTIFY_CYCLE: 1626 case ACPI_VIDEO_NOTIFY_CYCLE:
1621 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: 1627 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
@@ -1691,24 +1697,17 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
1691 struct acpi_device *device) 1697 struct acpi_device *device)
1692{ 1698{
1693 int status = 0; 1699 int status = 0;
1694 struct list_head *node, *next; 1700 struct acpi_device *dev;
1695
1696 1701
1697 acpi_video_device_enumerate(video); 1702 acpi_video_device_enumerate(video);
1698 1703
1699 list_for_each_safe(node, next, &device->children) { 1704 list_for_each_entry(dev, &device->children, node) {
1700 struct acpi_device *dev =
1701 list_entry(node, struct acpi_device, node);
1702
1703 if (!dev)
1704 continue;
1705 1705
1706 status = acpi_video_bus_get_one_device(dev, video); 1706 status = acpi_video_bus_get_one_device(dev, video);
1707 if (ACPI_FAILURE(status)) { 1707 if (ACPI_FAILURE(status)) {
1708 ACPI_EXCEPTION((AE_INFO, status, "Cant attach device")); 1708 ACPI_EXCEPTION((AE_INFO, status, "Cant attach device"));
1709 continue; 1709 continue;
1710 } 1710 }
1711
1712 } 1711 }
1713 return status; 1712 return status;
1714} 1713}
@@ -1724,9 +1723,6 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1724 1723
1725 video = device->video; 1724 video = device->video;
1726 1725
1727 down(&video->sem);
1728 list_del(&device->entry);
1729 up(&video->sem);
1730 acpi_video_device_remove_fs(device->dev); 1726 acpi_video_device_remove_fs(device->dev);
1731 1727
1732 status = acpi_remove_notify_handler(device->dev->handle, 1728 status = acpi_remove_notify_handler(device->dev->handle,
@@ -1734,32 +1730,34 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1734 acpi_video_device_notify); 1730 acpi_video_device_notify);
1735 backlight_device_unregister(device->backlight); 1731 backlight_device_unregister(device->backlight);
1736 video_output_unregister(device->output_dev); 1732 video_output_unregister(device->output_dev);
1733
1737 return 0; 1734 return 0;
1738} 1735}
1739 1736
1740static int acpi_video_bus_put_devices(struct acpi_video_bus *video) 1737static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1741{ 1738{
1742 int status; 1739 int status;
1743 struct list_head *node, *next; 1740 struct acpi_video_device *dev, *next;
1744 1741
1742 mutex_lock(&video->device_list_lock);
1745 1743
1746 list_for_each_safe(node, next, &video->video_device_list) { 1744 list_for_each_entry_safe(dev, next, &video->video_device_list, entry) {
1747 struct acpi_video_device *data =
1748 list_entry(node, struct acpi_video_device, entry);
1749 if (!data)
1750 continue;
1751 1745
1752 status = acpi_video_bus_put_one_device(data); 1746 status = acpi_video_bus_put_one_device(dev);
1753 if (ACPI_FAILURE(status)) 1747 if (ACPI_FAILURE(status))
1754 printk(KERN_WARNING PREFIX 1748 printk(KERN_WARNING PREFIX
1755 "hhuuhhuu bug in acpi video driver.\n"); 1749 "hhuuhhuu bug in acpi video driver.\n");
1756 1750
1757 if (data->brightness) 1751 if (dev->brightness) {
1758 kfree(data->brightness->levels); 1752 kfree(dev->brightness->levels);
1759 kfree(data->brightness); 1753 kfree(dev->brightness);
1760 kfree(data); 1754 }
1755 list_del(&dev->entry);
1756 kfree(dev);
1761 } 1757 }
1762 1758
1759 mutex_unlock(&video->device_list_lock);
1760
1763 return 0; 1761 return 0;
1764} 1762}
1765 1763
@@ -1782,9 +1780,6 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1782 struct input_dev *input; 1780 struct input_dev *input;
1783 int keycode; 1781 int keycode;
1784 1782
1785
1786 printk("video bus notify\n");
1787
1788 if (!video) 1783 if (!video)
1789 return; 1784 return;
1790 1785
@@ -1897,14 +1892,10 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1897static int instance; 1892static int instance;
1898static int acpi_video_bus_add(struct acpi_device *device) 1893static int acpi_video_bus_add(struct acpi_device *device)
1899{ 1894{
1900 int result = 0; 1895 acpi_status status;
1901 acpi_status status = 0; 1896 struct acpi_video_bus *video;
1902 struct acpi_video_bus *video = NULL;
1903 struct input_dev *input; 1897 struct input_dev *input;
1904 1898 int error;
1905
1906 if (!device)
1907 return -EINVAL;
1908 1899
1909 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); 1900 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
1910 if (!video) 1901 if (!video)
@@ -1923,15 +1914,15 @@ static int acpi_video_bus_add(struct acpi_device *device)
1923 acpi_driver_data(device) = video; 1914 acpi_driver_data(device) = video;
1924 1915
1925 acpi_video_bus_find_cap(video); 1916 acpi_video_bus_find_cap(video);
1926 result = acpi_video_bus_check(video); 1917 error = acpi_video_bus_check(video);
1927 if (result) 1918 if (error)
1928 goto end; 1919 goto err_free_video;
1929 1920
1930 result = acpi_video_bus_add_fs(device); 1921 error = acpi_video_bus_add_fs(device);
1931 if (result) 1922 if (error)
1932 goto end; 1923 goto err_free_video;
1933 1924
1934 init_MUTEX(&video->sem); 1925 mutex_init(&video->device_list_lock);
1935 INIT_LIST_HEAD(&video->video_device_list); 1926 INIT_LIST_HEAD(&video->video_device_list);
1936 1927
1937 acpi_video_bus_get_devices(video, device); 1928 acpi_video_bus_get_devices(video, device);
@@ -1943,16 +1934,15 @@ static int acpi_video_bus_add(struct acpi_device *device)
1943 if (ACPI_FAILURE(status)) { 1934 if (ACPI_FAILURE(status)) {
1944 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1935 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1945 "Error installing notify handler\n")); 1936 "Error installing notify handler\n"));
1946 acpi_video_bus_stop_devices(video); 1937 error = -ENODEV;
1947 acpi_video_bus_put_devices(video); 1938 goto err_stop_video;
1948 kfree(video->attached_array);
1949 acpi_video_bus_remove_fs(device);
1950 result = -ENODEV;
1951 goto end;
1952 } 1939 }
1953 1940
1954
1955 video->input = input = input_allocate_device(); 1941 video->input = input = input_allocate_device();
1942 if (!input) {
1943 error = -ENOMEM;
1944 goto err_uninstall_notify;
1945 }
1956 1946
1957 snprintf(video->phys, sizeof(video->phys), 1947 snprintf(video->phys, sizeof(video->phys),
1958 "%s/video/input0", acpi_device_hid(video->device)); 1948 "%s/video/input0", acpi_device_hid(video->device));
@@ -1961,6 +1951,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
1961 input->phys = video->phys; 1951 input->phys = video->phys;
1962 input->id.bustype = BUS_HOST; 1952 input->id.bustype = BUS_HOST;
1963 input->id.product = 0x06; 1953 input->id.product = 0x06;
1954 input->dev.parent = &device->dev;
1964 input->evbit[0] = BIT(EV_KEY); 1955 input->evbit[0] = BIT(EV_KEY);
1965 set_bit(KEY_SWITCHVIDEOMODE, input->keybit); 1956 set_bit(KEY_SWITCHVIDEOMODE, input->keybit);
1966 set_bit(KEY_VIDEO_NEXT, input->keybit); 1957 set_bit(KEY_VIDEO_NEXT, input->keybit);
@@ -1971,18 +1962,10 @@ static int acpi_video_bus_add(struct acpi_device *device)
1971 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); 1962 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit);
1972 set_bit(KEY_DISPLAY_OFF, input->keybit); 1963 set_bit(KEY_DISPLAY_OFF, input->keybit);
1973 set_bit(KEY_UNKNOWN, input->keybit); 1964 set_bit(KEY_UNKNOWN, input->keybit);
1974 result = input_register_device(input);
1975 if (result) {
1976 acpi_remove_notify_handler(video->device->handle,
1977 ACPI_DEVICE_NOTIFY,
1978 acpi_video_bus_notify);
1979 acpi_video_bus_stop_devices(video);
1980 acpi_video_bus_put_devices(video);
1981 kfree(video->attached_array);
1982 acpi_video_bus_remove_fs(device);
1983 goto end;
1984 }
1985 1965
1966 error = input_register_device(input);
1967 if (error)
1968 goto err_free_input_dev;
1986 1969
1987 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", 1970 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1988 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), 1971 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
@@ -1990,11 +1973,23 @@ static int acpi_video_bus_add(struct acpi_device *device)
1990 video->flags.rom ? "yes" : "no", 1973 video->flags.rom ? "yes" : "no",
1991 video->flags.post ? "yes" : "no"); 1974 video->flags.post ? "yes" : "no");
1992 1975
1993 end: 1976 return 0;
1994 if (result) 1977
1995 kfree(video); 1978 err_free_input_dev:
1979 input_free_device(input);
1980 err_uninstall_notify:
1981 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
1982 acpi_video_bus_notify);
1983 err_stop_video:
1984 acpi_video_bus_stop_devices(video);
1985 acpi_video_bus_put_devices(video);
1986 kfree(video->attached_array);
1987 acpi_video_bus_remove_fs(device);
1988 err_free_video:
1989 kfree(video);
1990 acpi_driver_data(device) = NULL;
1996 1991
1997 return result; 1992 return error;
1998} 1993}
1999 1994
2000static int acpi_video_bus_remove(struct acpi_device *device, int type) 1995static int acpi_video_bus_remove(struct acpi_device *device, int type)
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 328ce8a08426..b538e1d22bf2 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -119,18 +119,19 @@ enum {
119 PIIX_80C_SEC = (1 << 7) | (1 << 6), 119 PIIX_80C_SEC = (1 << 7) | (1 << 6),
120 120
121 /* controller IDs */ 121 /* controller IDs */
122 piix_pata_33 = 0, /* PIIX4 at 33Mhz */ 122 piix_pata_mwdma = 0, /* PIIX3 MWDMA only */
123 ich_pata_33 = 1, /* ICH up to UDMA 33 only */ 123 piix_pata_33, /* PIIX4 at 33Mhz */
124 ich_pata_66 = 2, /* ICH up to 66 Mhz */ 124 ich_pata_33, /* ICH up to UDMA 33 only */
125 ich_pata_100 = 3, /* ICH up to UDMA 100 */ 125 ich_pata_66, /* ICH up to 66 Mhz */
126 ich5_sata = 5, 126 ich_pata_100, /* ICH up to UDMA 100 */
127 ich6_sata = 6, 127 ich5_sata,
128 ich6_sata_ahci = 7, 128 ich6_sata,
129 ich6m_sata_ahci = 8, 129 ich6_sata_ahci,
130 ich8_sata_ahci = 9, 130 ich6m_sata_ahci,
131 piix_pata_mwdma = 10, /* PIIX3 MWDMA only */ 131 ich8_sata_ahci,
132 tolapai_sata_ahci = 11, 132 ich8_2port_sata,
133 ich9_2port_sata = 12, 133 ich8m_apple_sata_ahci, /* locks up on second port enable */
134 tolapai_sata_ahci,
134 135
135 /* constants for mapping table */ 136 /* constants for mapping table */
136 P0 = 0, /* port 0 */ 137 P0 = 0, /* port 0 */
@@ -239,19 +240,21 @@ static const struct pci_device_id piix_pci_tbl[] = {
239 /* SATA Controller 1 IDE (ICH8) */ 240 /* SATA Controller 1 IDE (ICH8) */
240 { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, 241 { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
241 /* SATA Controller 2 IDE (ICH8) */ 242 /* SATA Controller 2 IDE (ICH8) */
242 { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, 243 { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
243 /* Mobile SATA Controller IDE (ICH8M) */ 244 /* Mobile SATA Controller IDE (ICH8M) */
244 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, 245 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
246 /* Mobile SATA Controller IDE (ICH8M), Apple */
247 { 0x8086, 0x2828, 0x106b, 0x00a0, 0, 0, ich8m_apple_sata_ahci },
245 /* SATA Controller IDE (ICH9) */ 248 /* SATA Controller IDE (ICH9) */
246 { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, 249 { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
247 /* SATA Controller IDE (ICH9) */ 250 /* SATA Controller IDE (ICH9) */
248 { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, 251 { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
249 /* SATA Controller IDE (ICH9) */ 252 /* SATA Controller IDE (ICH9) */
250 { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, 253 { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
251 /* SATA Controller IDE (ICH9M) */ 254 /* SATA Controller IDE (ICH9M) */
252 { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, 255 { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
253 /* SATA Controller IDE (ICH9M) */ 256 /* SATA Controller IDE (ICH9M) */
254 { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, 257 { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
255 /* SATA Controller IDE (ICH9M) */ 258 /* SATA Controller IDE (ICH9M) */
256 { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, 259 { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
257 /* SATA Controller IDE (Tolapai) */ 260 /* SATA Controller IDE (Tolapai) */
@@ -427,7 +430,7 @@ static const struct piix_map_db ich6m_map_db = {
427 430
428static const struct piix_map_db ich8_map_db = { 431static const struct piix_map_db ich8_map_db = {
429 .mask = 0x3, 432 .mask = 0x3,
430 .port_enable = 0x3, 433 .port_enable = 0xf,
431 .map = { 434 .map = {
432 /* PM PS SM SS MAP */ 435 /* PM PS SM SS MAP */
433 { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */ 436 { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */
@@ -437,7 +440,7 @@ static const struct piix_map_db ich8_map_db = {
437 }, 440 },
438}; 441};
439 442
440static const struct piix_map_db tolapai_map_db = { 443static const struct piix_map_db ich8_2port_map_db = {
441 .mask = 0x3, 444 .mask = 0x3,
442 .port_enable = 0x3, 445 .port_enable = 0x3,
443 .map = { 446 .map = {
@@ -449,7 +452,19 @@ static const struct piix_map_db tolapai_map_db = {
449 }, 452 },
450}; 453};
451 454
452static const struct piix_map_db ich9_2port_map_db = { 455static const struct piix_map_db ich8m_apple_map_db = {
456 .mask = 0x3,
457 .port_enable = 0x1,
458 .map = {
459 /* PM PS SM SS MAP */
460 { P0, NA, NA, NA }, /* 00b */
461 { RV, RV, RV, RV },
462 { P0, P2, IDE, IDE }, /* 10b */
463 { RV, RV, RV, RV },
464 },
465};
466
467static const struct piix_map_db tolapai_map_db = {
453 .mask = 0x3, 468 .mask = 0x3,
454 .port_enable = 0x3, 469 .port_enable = 0x3,
455 .map = { 470 .map = {
@@ -467,11 +482,21 @@ static const struct piix_map_db *piix_map_db_table[] = {
467 [ich6_sata_ahci] = &ich6_map_db, 482 [ich6_sata_ahci] = &ich6_map_db,
468 [ich6m_sata_ahci] = &ich6m_map_db, 483 [ich6m_sata_ahci] = &ich6m_map_db,
469 [ich8_sata_ahci] = &ich8_map_db, 484 [ich8_sata_ahci] = &ich8_map_db,
485 [ich8_2port_sata] = &ich8_2port_map_db,
486 [ich8m_apple_sata_ahci] = &ich8m_apple_map_db,
470 [tolapai_sata_ahci] = &tolapai_map_db, 487 [tolapai_sata_ahci] = &tolapai_map_db,
471 [ich9_2port_sata] = &ich9_2port_map_db,
472}; 488};
473 489
474static struct ata_port_info piix_port_info[] = { 490static struct ata_port_info piix_port_info[] = {
491 [piix_pata_mwdma] = /* PIIX3 MWDMA only */
492 {
493 .sht = &piix_sht,
494 .flags = PIIX_PATA_FLAGS,
495 .pio_mask = 0x1f, /* pio0-4 */
496 .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
497 .port_ops = &piix_pata_ops,
498 },
499
475 [piix_pata_33] = /* PIIX4 at 33MHz */ 500 [piix_pata_33] = /* PIIX4 at 33MHz */
476 { 501 {
477 .sht = &piix_sht, 502 .sht = &piix_sht,
@@ -565,13 +590,15 @@ static struct ata_port_info piix_port_info[] = {
565 .port_ops = &piix_sata_ops, 590 .port_ops = &piix_sata_ops,
566 }, 591 },
567 592
568 [piix_pata_mwdma] = /* PIIX3 MWDMA only */ 593 [ich8_2port_sata] =
569 { 594 {
570 .sht = &piix_sht, 595 .sht = &piix_sht,
571 .flags = PIIX_PATA_FLAGS, 596 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
597 PIIX_FLAG_AHCI,
572 .pio_mask = 0x1f, /* pio0-4 */ 598 .pio_mask = 0x1f, /* pio0-4 */
573 .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ 599 .mwdma_mask = 0x07, /* mwdma0-2 */
574 .port_ops = &piix_pata_ops, 600 .udma_mask = ATA_UDMA6,
601 .port_ops = &piix_sata_ops,
575 }, 602 },
576 603
577 [tolapai_sata_ahci] = 604 [tolapai_sata_ahci] =
@@ -585,7 +612,7 @@ static struct ata_port_info piix_port_info[] = {
585 .port_ops = &piix_sata_ops, 612 .port_ops = &piix_sata_ops,
586 }, 613 },
587 614
588 [ich9_2port_sata] = 615 [ich8m_apple_sata_ahci] =
589 { 616 {
590 .sht = &piix_sht, 617 .sht = &piix_sht,
591 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR | 618 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
@@ -595,6 +622,7 @@ static struct ata_port_info piix_port_info[] = {
595 .udma_mask = ATA_UDMA6, 622 .udma_mask = ATA_UDMA6,
596 .port_ops = &piix_sata_ops, 623 .port_ops = &piix_sata_ops,
597 }, 624 },
625
598}; 626};
599 627
600static struct pci_bits piix_enable_bits[] = { 628static struct pci_bits piix_enable_bits[] = {
@@ -939,6 +967,13 @@ static int piix_broken_suspend(void)
939 }, 967 },
940 }, 968 },
941 { 969 {
970 .ident = "TECRA M3",
971 .matches = {
972 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
973 DMI_MATCH(DMI_PRODUCT_NAME, "Tecra M3"),
974 },
975 },
976 {
942 .ident = "TECRA M5", 977 .ident = "TECRA M5",
943 .matches = { 978 .matches = {
944 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 979 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
@@ -953,6 +988,20 @@ static int piix_broken_suspend(void)
953 }, 988 },
954 }, 989 },
955 { 990 {
991 .ident = "TECRA A8",
992 .matches = {
993 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
994 DMI_MATCH(DMI_PRODUCT_NAME, "TECRA A8"),
995 },
996 },
997 {
998 .ident = "Satellite R25",
999 .matches = {
1000 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1001 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite R25"),
1002 },
1003 },
1004 {
956 .ident = "Satellite U200", 1005 .ident = "Satellite U200",
957 .matches = { 1006 .matches = {
958 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 1007 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
@@ -960,6 +1009,13 @@ static int piix_broken_suspend(void)
960 }, 1009 },
961 }, 1010 },
962 { 1011 {
1012 .ident = "Satellite U200",
1013 .matches = {
1014 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1015 DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE U200"),
1016 },
1017 },
1018 {
963 .ident = "Satellite Pro U200", 1019 .ident = "Satellite Pro U200",
964 .matches = { 1020 .matches = {
965 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 1021 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
@@ -974,6 +1030,13 @@ static int piix_broken_suspend(void)
974 }, 1030 },
975 }, 1031 },
976 { 1032 {
1033 .ident = "SATELLITE U205",
1034 .matches = {
1035 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1036 DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE U205"),
1037 },
1038 },
1039 {
977 .ident = "Portege M500", 1040 .ident = "Portege M500",
978 .matches = { 1041 .matches = {
979 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 1042 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
@@ -1086,12 +1149,12 @@ static int piix_disable_ahci(struct pci_dev *pdev)
1086 if (!mmio) 1149 if (!mmio)
1087 return -ENOMEM; 1150 return -ENOMEM;
1088 1151
1089 tmp = readl(mmio + AHCI_GLOBAL_CTL); 1152 tmp = ioread32(mmio + AHCI_GLOBAL_CTL);
1090 if (tmp & AHCI_ENABLE) { 1153 if (tmp & AHCI_ENABLE) {
1091 tmp &= ~AHCI_ENABLE; 1154 tmp &= ~AHCI_ENABLE;
1092 writel(tmp, mmio + AHCI_GLOBAL_CTL); 1155 iowrite32(tmp, mmio + AHCI_GLOBAL_CTL);
1093 1156
1094 tmp = readl(mmio + AHCI_GLOBAL_CTL); 1157 tmp = ioread32(mmio + AHCI_GLOBAL_CTL);
1095 if (tmp & AHCI_ENABLE) 1158 if (tmp & AHCI_ENABLE)
1096 rc = -EIO; 1159 rc = -EIO;
1097 } 1160 }
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 81898036dbca..b514a80f1370 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -30,6 +30,14 @@
30 * Hardware documentation available from http://www.t13.org/ and 30 * Hardware documentation available from http://www.t13.org/ and
31 * http://www.sata-io.org/ 31 * http://www.sata-io.org/
32 * 32 *
33 * Standards documents from:
34 * http://www.t13.org (ATA standards, PCI DMA IDE spec)
35 * http://www.t10.org (SCSI MMC - for ATAPI MMC)
36 * http://www.sata-io.org (SATA)
37 * http://www.compactflash.org (CF)
38 * http://www.qic.org (QIC157 - Tape and DSC)
39 * http://www.ce-ata.org (CE-ATA: not supported)
40 *
33 */ 41 */
34 42
35#include <linux/kernel.h> 43#include <linux/kernel.h>
@@ -2307,8 +2315,10 @@ int ata_dev_configure(struct ata_device *dev)
2307 } 2315 }
2308 2316
2309 if ((dev->class == ATA_DEV_ATAPI) && 2317 if ((dev->class == ATA_DEV_ATAPI) &&
2310 (atapi_command_packet_set(id) == TYPE_TAPE)) 2318 (atapi_command_packet_set(id) == TYPE_TAPE)) {
2311 dev->max_sectors = ATA_MAX_SECTORS_TAPE; 2319 dev->max_sectors = ATA_MAX_SECTORS_TAPE;
2320 dev->horkage |= ATA_HORKAGE_STUCK_ERR;
2321 }
2312 2322
2313 if (dev->horkage & ATA_HORKAGE_MAX_SEC_128) 2323 if (dev->horkage & ATA_HORKAGE_MAX_SEC_128)
2314 dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128, 2324 dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128,
@@ -2581,81 +2591,6 @@ void sata_print_link_status(struct ata_link *link)
2581} 2591}
2582 2592
2583/** 2593/**
2584 * __sata_phy_reset - Wake/reset a low-level SATA PHY
2585 * @ap: SATA port associated with target SATA PHY.
2586 *
2587 * This function issues commands to standard SATA Sxxx
2588 * PHY registers, to wake up the phy (and device), and
2589 * clear any reset condition.
2590 *
2591 * LOCKING:
2592 * PCI/etc. bus probe sem.
2593 *
2594 */
2595void __sata_phy_reset(struct ata_port *ap)
2596{
2597 struct ata_link *link = &ap->link;
2598 unsigned long timeout = jiffies + (HZ * 5);
2599 u32 sstatus;
2600
2601 if (ap->flags & ATA_FLAG_SATA_RESET) {
2602 /* issue phy wake/reset */
2603 sata_scr_write_flush(link, SCR_CONTROL, 0x301);
2604 /* Couldn't find anything in SATA I/II specs, but
2605 * AHCI-1.1 10.4.2 says at least 1 ms. */
2606 mdelay(1);
2607 }
2608 /* phy wake/clear reset */
2609 sata_scr_write_flush(link, SCR_CONTROL, 0x300);
2610
2611 /* wait for phy to become ready, if necessary */
2612 do {
2613 msleep(200);
2614 sata_scr_read(link, SCR_STATUS, &sstatus);
2615 if ((sstatus & 0xf) != 1)
2616 break;
2617 } while (time_before(jiffies, timeout));
2618
2619 /* print link status */
2620 sata_print_link_status(link);
2621
2622 /* TODO: phy layer with polling, timeouts, etc. */
2623 if (!ata_link_offline(link))
2624 ata_port_probe(ap);
2625 else
2626 ata_port_disable(ap);
2627
2628 if (ap->flags & ATA_FLAG_DISABLED)
2629 return;
2630
2631 if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
2632 ata_port_disable(ap);
2633 return;
2634 }
2635
2636 ap->cbl = ATA_CBL_SATA;
2637}
2638
2639/**
2640 * sata_phy_reset - Reset SATA bus.
2641 * @ap: SATA port associated with target SATA PHY.
2642 *
2643 * This function resets the SATA bus, and then probes
2644 * the bus for devices.
2645 *
2646 * LOCKING:
2647 * PCI/etc. bus probe sem.
2648 *
2649 */
2650void sata_phy_reset(struct ata_port *ap)
2651{
2652 __sata_phy_reset(ap);
2653 if (ap->flags & ATA_FLAG_DISABLED)
2654 return;
2655 ata_bus_reset(ap);
2656}
2657
2658/**
2659 * ata_dev_pair - return other device on cable 2594 * ata_dev_pair - return other device on cable
2660 * @adev: device 2595 * @adev: device
2661 * 2596 *
@@ -4250,6 +4185,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4250 /* Devices which get the IVB wrong */ 4185 /* Devices which get the IVB wrong */
4251 { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB, }, 4186 { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB, },
4252 { "TSSTcorp CDDVDW SH-S202J", "SB00", ATA_HORKAGE_IVB, }, 4187 { "TSSTcorp CDDVDW SH-S202J", "SB00", ATA_HORKAGE_IVB, },
4188 { "TSSTcorp CDDVDW SH-S202J", "SB01", ATA_HORKAGE_IVB, },
4189 { "TSSTcorp CDDVDW SH-S202N", "SB00", ATA_HORKAGE_IVB, },
4190 { "TSSTcorp CDDVDW SH-S202N", "SB01", ATA_HORKAGE_IVB, },
4253 4191
4254 /* End Marker */ 4192 /* End Marker */
4255 { } 4193 { }
@@ -5490,11 +5428,19 @@ fsm_start:
5490 * let the EH abort the command or reset the device. 5428 * let the EH abort the command or reset the device.
5491 */ 5429 */
5492 if (unlikely(status & (ATA_ERR | ATA_DF))) { 5430 if (unlikely(status & (ATA_ERR | ATA_DF))) {
5493 ata_port_printk(ap, KERN_WARNING, "DRQ=1 with device " 5431 /* Some ATAPI tape drives forget to clear the ERR bit
5494 "error, dev_stat 0x%X\n", status); 5432 * when doing the next command (mostly request sense).
5495 qc->err_mask |= AC_ERR_HSM; 5433 * We ignore ERR here to workaround and proceed sending
5496 ap->hsm_task_state = HSM_ST_ERR; 5434 * the CDB.
5497 goto fsm_start; 5435 */
5436 if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) {
5437 ata_port_printk(ap, KERN_WARNING,
5438 "DRQ=1 with device error, "
5439 "dev_stat 0x%X\n", status);
5440 qc->err_mask |= AC_ERR_HSM;
5441 ap->hsm_task_state = HSM_ST_ERR;
5442 goto fsm_start;
5443 }
5498 } 5444 }
5499 5445
5500 /* Send the CDB (atapi) or the first data block (ata pio out). 5446 /* Send the CDB (atapi) or the first data block (ata pio out).
@@ -7021,12 +6967,11 @@ int ata_host_start(struct ata_host *host)
7021 if (ap->ops->port_start) { 6967 if (ap->ops->port_start) {
7022 rc = ap->ops->port_start(ap); 6968 rc = ap->ops->port_start(ap);
7023 if (rc) { 6969 if (rc) {
7024 ata_port_printk(ap, KERN_ERR, "failed to " 6970 if (rc != -ENODEV)
7025 "start port (errno=%d)\n", rc); 6971 dev_printk(KERN_ERR, host->dev, "failed to start port %d (errno=%d)\n", i, rc);
7026 goto err_out; 6972 goto err_out;
7027 } 6973 }
7028 } 6974 }
7029
7030 ata_eh_freeze_port(ap); 6975 ata_eh_freeze_port(ap);
7031 } 6976 }
7032 6977
@@ -7653,8 +7598,6 @@ EXPORT_SYMBOL_GPL(ata_dev_disable);
7653EXPORT_SYMBOL_GPL(sata_set_spd); 7598EXPORT_SYMBOL_GPL(sata_set_spd);
7654EXPORT_SYMBOL_GPL(sata_link_debounce); 7599EXPORT_SYMBOL_GPL(sata_link_debounce);
7655EXPORT_SYMBOL_GPL(sata_link_resume); 7600EXPORT_SYMBOL_GPL(sata_link_resume);
7656EXPORT_SYMBOL_GPL(sata_phy_reset);
7657EXPORT_SYMBOL_GPL(__sata_phy_reset);
7658EXPORT_SYMBOL_GPL(ata_bus_reset); 7601EXPORT_SYMBOL_GPL(ata_bus_reset);
7659EXPORT_SYMBOL_GPL(ata_std_prereset); 7602EXPORT_SYMBOL_GPL(ata_std_prereset);
7660EXPORT_SYMBOL_GPL(ata_std_softreset); 7603EXPORT_SYMBOL_GPL(ata_std_softreset);
@@ -7725,7 +7668,6 @@ EXPORT_SYMBOL_GPL(ata_port_desc);
7725#ifdef CONFIG_PCI 7668#ifdef CONFIG_PCI
7726EXPORT_SYMBOL_GPL(ata_port_pbar_desc); 7669EXPORT_SYMBOL_GPL(ata_port_pbar_desc);
7727#endif /* CONFIG_PCI */ 7670#endif /* CONFIG_PCI */
7728EXPORT_SYMBOL_GPL(ata_eng_timeout);
7729EXPORT_SYMBOL_GPL(ata_port_schedule_eh); 7671EXPORT_SYMBOL_GPL(ata_port_schedule_eh);
7730EXPORT_SYMBOL_GPL(ata_link_abort); 7672EXPORT_SYMBOL_GPL(ata_link_abort);
7731EXPORT_SYMBOL_GPL(ata_port_abort); 7673EXPORT_SYMBOL_GPL(ata_port_abort);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index ed8813b222a0..e6605f038647 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -559,101 +559,6 @@ void ata_port_wait_eh(struct ata_port *ap)
559 } 559 }
560} 560}
561 561
562/**
563 * ata_qc_timeout - Handle timeout of queued command
564 * @qc: Command that timed out
565 *
566 * Some part of the kernel (currently, only the SCSI layer)
567 * has noticed that the active command on port @ap has not
568 * completed after a specified length of time. Handle this
569 * condition by disabling DMA (if necessary) and completing
570 * transactions, with error if necessary.
571 *
572 * This also handles the case of the "lost interrupt", where
573 * for some reason (possibly hardware bug, possibly driver bug)
574 * an interrupt was not delivered to the driver, even though the
575 * transaction completed successfully.
576 *
577 * TODO: kill this function once old EH is gone.
578 *
579 * LOCKING:
580 * Inherited from SCSI layer (none, can sleep)
581 */
582static void ata_qc_timeout(struct ata_queued_cmd *qc)
583{
584 struct ata_port *ap = qc->ap;
585 u8 host_stat = 0, drv_stat;
586 unsigned long flags;
587
588 DPRINTK("ENTER\n");
589
590 ap->hsm_task_state = HSM_ST_IDLE;
591
592 spin_lock_irqsave(ap->lock, flags);
593
594 switch (qc->tf.protocol) {
595
596 case ATA_PROT_DMA:
597 case ATA_PROT_ATAPI_DMA:
598 host_stat = ap->ops->bmdma_status(ap);
599
600 /* before we do anything else, clear DMA-Start bit */
601 ap->ops->bmdma_stop(qc);
602
603 /* fall through */
604
605 default:
606 ata_altstatus(ap);
607 drv_stat = ata_chk_status(ap);
608
609 /* ack bmdma irq events */
610 ap->ops->irq_clear(ap);
611
612 ata_dev_printk(qc->dev, KERN_ERR, "command 0x%x timeout, "
613 "stat 0x%x host_stat 0x%x\n",
614 qc->tf.command, drv_stat, host_stat);
615
616 /* complete taskfile transaction */
617 qc->err_mask |= AC_ERR_TIMEOUT;
618 break;
619 }
620
621 spin_unlock_irqrestore(ap->lock, flags);
622
623 ata_eh_qc_complete(qc);
624
625 DPRINTK("EXIT\n");
626}
627
628/**
629 * ata_eng_timeout - Handle timeout of queued command
630 * @ap: Port on which timed-out command is active
631 *
632 * Some part of the kernel (currently, only the SCSI layer)
633 * has noticed that the active command on port @ap has not
634 * completed after a specified length of time. Handle this
635 * condition by disabling DMA (if necessary) and completing
636 * transactions, with error if necessary.
637 *
638 * This also handles the case of the "lost interrupt", where
639 * for some reason (possibly hardware bug, possibly driver bug)
640 * an interrupt was not delivered to the driver, even though the
641 * transaction completed successfully.
642 *
643 * TODO: kill this function once old EH is gone.
644 *
645 * LOCKING:
646 * Inherited from SCSI layer (none, can sleep)
647 */
648void ata_eng_timeout(struct ata_port *ap)
649{
650 DPRINTK("ENTER\n");
651
652 ata_qc_timeout(ata_qc_from_tag(ap, ap->link.active_tag));
653
654 DPRINTK("EXIT\n");
655}
656
657static int ata_eh_nr_in_flight(struct ata_port *ap) 562static int ata_eh_nr_in_flight(struct ata_port *ap)
658{ 563{
659 unsigned int tag; 564 unsigned int tag;
@@ -1945,30 +1850,54 @@ static void ata_eh_link_report(struct ata_link *link)
1945 ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : ""); 1850 ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : "");
1946 1851
1947 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 1852 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
1948 static const char *dma_str[] = {
1949 [DMA_BIDIRECTIONAL] = "bidi",
1950 [DMA_TO_DEVICE] = "out",
1951 [DMA_FROM_DEVICE] = "in",
1952 [DMA_NONE] = "",
1953 };
1954 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 1853 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
1955 struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; 1854 struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf;
1855 const u8 *cdb = qc->cdb;
1856 char data_buf[20] = "";
1857 char cdb_buf[70] = "";
1956 1858
1957 if (!(qc->flags & ATA_QCFLAG_FAILED) || 1859 if (!(qc->flags & ATA_QCFLAG_FAILED) ||
1958 qc->dev->link != link || !qc->err_mask) 1860 qc->dev->link != link || !qc->err_mask)
1959 continue; 1861 continue;
1960 1862
1863 if (qc->dma_dir != DMA_NONE) {
1864 static const char *dma_str[] = {
1865 [DMA_BIDIRECTIONAL] = "bidi",
1866 [DMA_TO_DEVICE] = "out",
1867 [DMA_FROM_DEVICE] = "in",
1868 };
1869 static const char *prot_str[] = {
1870 [ATA_PROT_PIO] = "pio",
1871 [ATA_PROT_DMA] = "dma",
1872 [ATA_PROT_NCQ] = "ncq",
1873 [ATA_PROT_ATAPI] = "pio",
1874 [ATA_PROT_ATAPI_DMA] = "dma",
1875 };
1876
1877 snprintf(data_buf, sizeof(data_buf), " %s %u %s",
1878 prot_str[qc->tf.protocol], qc->nbytes,
1879 dma_str[qc->dma_dir]);
1880 }
1881
1882 if (is_atapi_taskfile(&qc->tf))
1883 snprintf(cdb_buf, sizeof(cdb_buf),
1884 "cdb %02x %02x %02x %02x %02x %02x %02x %02x "
1885 "%02x %02x %02x %02x %02x %02x %02x %02x\n ",
1886 cdb[0], cdb[1], cdb[2], cdb[3],
1887 cdb[4], cdb[5], cdb[6], cdb[7],
1888 cdb[8], cdb[9], cdb[10], cdb[11],
1889 cdb[12], cdb[13], cdb[14], cdb[15]);
1890
1961 ata_dev_printk(qc->dev, KERN_ERR, 1891 ata_dev_printk(qc->dev, KERN_ERR,
1962 "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x " 1892 "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
1963 "tag %d cdb 0x%x data %u %s\n " 1893 "tag %d%s\n %s"
1964 "res %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x " 1894 "res %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
1965 "Emask 0x%x (%s)%s\n", 1895 "Emask 0x%x (%s)%s\n",
1966 cmd->command, cmd->feature, cmd->nsect, 1896 cmd->command, cmd->feature, cmd->nsect,
1967 cmd->lbal, cmd->lbam, cmd->lbah, 1897 cmd->lbal, cmd->lbam, cmd->lbah,
1968 cmd->hob_feature, cmd->hob_nsect, 1898 cmd->hob_feature, cmd->hob_nsect,
1969 cmd->hob_lbal, cmd->hob_lbam, cmd->hob_lbah, 1899 cmd->hob_lbal, cmd->hob_lbam, cmd->hob_lbah,
1970 cmd->device, qc->tag, qc->cdb[0], qc->nbytes, 1900 cmd->device, qc->tag, data_buf, cdb_buf,
1971 dma_str[qc->dma_dir],
1972 res->command, res->feature, res->nsect, 1901 res->command, res->feature, res->nsect,
1973 res->lbal, res->lbam, res->lbah, 1902 res->lbal, res->lbam, res->lbah,
1974 res->hob_feature, res->hob_nsect, 1903 res->hob_feature, res->hob_nsect,
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 94144ed50a6b..a883bb03d4c7 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2485,11 +2485,40 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2485 if (!using_pio && ata_check_atapi_dma(qc)) 2485 if (!using_pio && ata_check_atapi_dma(qc))
2486 using_pio = 1; 2486 using_pio = 1;
2487 2487
2488 /* Some controller variants snoop this value for Packet transfers 2488 /* Some controller variants snoop this value for Packet
2489 to do state machine and FIFO management. Thus we want to set it 2489 * transfers to do state machine and FIFO management. Thus we
2490 properly, and for DMA where it is effectively meaningless */ 2490 * want to set it properly, and for DMA where it is
2491 * effectively meaningless.
2492 */
2491 nbytes = min(qc->nbytes, (unsigned int)63 * 1024); 2493 nbytes = min(qc->nbytes, (unsigned int)63 * 1024);
2492 2494
2495 /* Most ATAPI devices which honor transfer chunk size don't
2496 * behave according to the spec when odd chunk size which
2497 * matches the transfer length is specified. If the number of
2498 * bytes to transfer is 2n+1. According to the spec, what
2499 * should happen is to indicate that 2n+1 is going to be
2500 * transferred and transfer 2n+2 bytes where the last byte is
2501 * padding.
2502 *
2503 * In practice, this doesn't happen. ATAPI devices first
2504 * indicate and transfer 2n bytes and then indicate and
2505 * transfer 2 bytes where the last byte is padding.
2506 *
2507 * This inconsistency confuses several controllers which
2508 * perform PIO using DMA such as Intel AHCIs and sil3124/32.
2509 * These controllers use actual number of transferred bytes to
2510 * update DMA poitner and transfer of 4n+2 bytes make those
2511 * controller push DMA pointer by 4n+4 bytes because SATA data
2512 * FISes are aligned to 4 bytes. This causes data corruption
2513 * and buffer overrun.
2514 *
2515 * Always setting nbytes to even number solves this problem
2516 * because then ATAPI devices don't have to split data at 2n
2517 * boundaries.
2518 */
2519 if (nbytes & 0x1)
2520 nbytes++;
2521
2493 qc->tf.lbam = (nbytes & 0xFF); 2522 qc->tf.lbam = (nbytes & 0xFF);
2494 qc->tf.lbah = (nbytes >> 8); 2523 qc->tf.lbah = (nbytes >> 8);
2495 2524
@@ -2869,7 +2898,8 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
2869 xlat_func = NULL; 2898 xlat_func = NULL;
2870 if (likely((scsi_op != ATA_16) || !atapi_passthru16)) { 2899 if (likely((scsi_op != ATA_16) || !atapi_passthru16)) {
2871 /* relay SCSI command to ATAPI device */ 2900 /* relay SCSI command to ATAPI device */
2872 if (unlikely(scmd->cmd_len > dev->cdb_len)) 2901 int len = COMMAND_SIZE(scsi_op);
2902 if (unlikely(len > scmd->cmd_len || len > dev->cdb_len))
2873 goto bad_cdb_len; 2903 goto bad_cdb_len;
2874 2904
2875 xlat_func = atapi_xlat; 2905 xlat_func = atapi_xlat;
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 364534e7aff4..8caf9afc8b90 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -63,6 +63,9 @@ static int ali_cable_override(struct pci_dev *pdev)
63 /* Fujitsu P2000 */ 63 /* Fujitsu P2000 */
64 if (pdev->subsystem_vendor == 0x10CF && pdev->subsystem_device == 0x10AF) 64 if (pdev->subsystem_vendor == 0x10CF && pdev->subsystem_device == 0x10AF)
65 return 1; 65 return 1;
66 /* Mitac 8317 (Winbook-A) and relatives */
67 if (pdev->subsystem_vendor == 0x1071 && pdev->subsystem_device == 0x8317)
68 return 1;
66 /* Systems by DMI */ 69 /* Systems by DMI */
67 if (dmi_check_system(cable_dmi_table)) 70 if (dmi_check_system(cable_dmi_table))
68 return 1; 71 return 1;
@@ -282,6 +285,21 @@ static void ali_lock_sectors(struct ata_device *adev)
282 adev->max_sectors = 255; 285 adev->max_sectors = 255;
283} 286}
284 287
288/**
289 * ali_check_atapi_dma - DMA check for most ALi controllers
290 * @adev: Device
291 *
292 * Called to decide whether commands should be sent by DMA or PIO
293 */
294
295static int ali_check_atapi_dma(struct ata_queued_cmd *qc)
296{
297 /* If its not a media command, its not worth it */
298 if (qc->nbytes < 2048)
299 return -EOPNOTSUPP;
300 return 0;
301}
302
285static struct scsi_host_template ali_sht = { 303static struct scsi_host_template ali_sht = {
286 .module = THIS_MODULE, 304 .module = THIS_MODULE,
287 .name = DRV_NAME, 305 .name = DRV_NAME,
@@ -378,6 +396,7 @@ static struct ata_port_operations ali_c2_port_ops = {
378 .mode_filter = ata_pci_default_filter, 396 .mode_filter = ata_pci_default_filter,
379 .tf_load = ata_tf_load, 397 .tf_load = ata_tf_load,
380 .tf_read = ata_tf_read, 398 .tf_read = ata_tf_read,
399 .check_atapi_dma = ali_check_atapi_dma,
381 .check_status = ata_check_status, 400 .check_status = ata_check_status,
382 .exec_command = ata_exec_command, 401 .exec_command = ata_exec_command,
383 .dev_select = ata_std_dev_select, 402 .dev_select = ata_std_dev_select,
@@ -415,6 +434,7 @@ static struct ata_port_operations ali_c5_port_ops = {
415 .mode_filter = ata_pci_default_filter, 434 .mode_filter = ata_pci_default_filter,
416 .tf_load = ata_tf_load, 435 .tf_load = ata_tf_load,
417 .tf_read = ata_tf_read, 436 .tf_read = ata_tf_read,
437 .check_atapi_dma = ali_check_atapi_dma,
418 .check_status = ata_check_status, 438 .check_status = ata_check_status,
419 .exec_command = ata_exec_command, 439 .exec_command = ata_exec_command,
420 .dev_select = ata_std_dev_select, 440 .dev_select = ata_std_dev_select,
diff --git a/drivers/ata/pata_at32.c b/drivers/ata/pata_at32.c
index bb250a48e27c..67e574de31e8 100644
--- a/drivers/ata/pata_at32.c
+++ b/drivers/ata/pata_at32.c
@@ -28,7 +28,7 @@
28#include <asm/arch/smc.h> 28#include <asm/arch/smc.h>
29 29
30#define DRV_NAME "pata_at32" 30#define DRV_NAME "pata_at32"
31#define DRV_VERSION "0.0.2" 31#define DRV_VERSION "0.0.3"
32 32
33/* 33/*
34 * CompactFlash controller memory layout relative to the base address: 34 * CompactFlash controller memory layout relative to the base address:
@@ -64,6 +64,8 @@
64 * Mode 2 | 8.3 | 240 ns | 0x07 64 * Mode 2 | 8.3 | 240 ns | 0x07
65 * Mode 3 | 11.1 | 180 ns | 0x0f 65 * Mode 3 | 11.1 | 180 ns | 0x0f
66 * Mode 4 | 16.7 | 120 ns | 0x1f 66 * Mode 4 | 16.7 | 120 ns | 0x1f
67 *
68 * Alter PIO_MASK below according to table to set maximal PIO mode.
67 */ 69 */
68#define PIO_MASK (0x1f) 70#define PIO_MASK (0x1f)
69 71
@@ -85,36 +87,40 @@ struct at32_ide_info {
85 */ 87 */
86static int pata_at32_setup_timing(struct device *dev, 88static int pata_at32_setup_timing(struct device *dev,
87 struct at32_ide_info *info, 89 struct at32_ide_info *info,
88 const struct ata_timing *timing) 90 const struct ata_timing *ata)
89{ 91{
90 /* These two values are found through testing */
91 const int min_recover = 25;
92 const int ncs_hold = 15;
93
94 struct smc_config *smc = &info->smc; 92 struct smc_config *smc = &info->smc;
93 struct smc_timing timing;
95 94
96 int active; 95 int active;
97 int recover; 96 int recover;
98 97
98 memset(&timing, 0, sizeof(struct smc_timing));
99
99 /* Total cycle time */ 100 /* Total cycle time */
100 smc->read_cycle = timing->cyc8b; 101 timing.read_cycle = ata->cyc8b;
101 102
102 /* DIOR <= CFIOR timings */ 103 /* DIOR <= CFIOR timings */
103 smc->nrd_setup = timing->setup; 104 timing.nrd_setup = ata->setup;
104 smc->nrd_pulse = timing->act8b; 105 timing.nrd_pulse = ata->act8b;
106 timing.nrd_recover = ata->rec8b;
107
108 /* Convert nanosecond timing to clock cycles */
109 smc_set_timing(smc, &timing);
105 110
106 /* Compute recover, extend total cycle if needed */ 111 /* Add one extra cycle setup due to signal ring */
107 active = smc->nrd_setup + smc->nrd_pulse; 112 smc->nrd_setup = smc->nrd_setup + 1;
113
114 active = smc->nrd_setup + smc->nrd_pulse;
108 recover = smc->read_cycle - active; 115 recover = smc->read_cycle - active;
109 116
110 if (recover < min_recover) { 117 /* Need at least two cycles recovery */
111 smc->read_cycle = active + min_recover; 118 if (recover < 2)
112 recover = min_recover; 119 smc->read_cycle = active + 2;
113 }
114 120
115 /* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */ 121 /* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */
116 smc->ncs_read_setup = 0; 122 smc->ncs_read_setup = 1;
117 smc->ncs_read_pulse = active + ncs_hold; 123 smc->ncs_read_pulse = smc->read_cycle - 2;
118 124
119 /* Write timings same as read timings */ 125 /* Write timings same as read timings */
120 smc->write_cycle = smc->read_cycle; 126 smc->write_cycle = smc->read_cycle;
@@ -123,11 +129,13 @@ static int pata_at32_setup_timing(struct device *dev,
123 smc->ncs_write_setup = smc->ncs_read_setup; 129 smc->ncs_write_setup = smc->ncs_read_setup;
124 smc->ncs_write_pulse = smc->ncs_read_pulse; 130 smc->ncs_write_pulse = smc->ncs_read_pulse;
125 131
126 /* Do some debugging output */ 132 /* Do some debugging output of ATA and SMC timings */
127 dev_dbg(dev, "SMC: C=%d S=%d P=%d R=%d NCSS=%d NCSP=%d NCSR=%d\n", 133 dev_dbg(dev, "ATA: C=%d S=%d P=%d R=%d\n",
134 ata->cyc8b, ata->setup, ata->act8b, ata->rec8b);
135
136 dev_dbg(dev, "SMC: C=%d S=%d P=%d NS=%d NP=%d\n",
128 smc->read_cycle, smc->nrd_setup, smc->nrd_pulse, 137 smc->read_cycle, smc->nrd_setup, smc->nrd_pulse,
129 recover, smc->ncs_read_setup, smc->ncs_read_pulse, 138 smc->ncs_read_setup, smc->ncs_read_pulse);
130 smc->read_cycle - smc->ncs_read_pulse);
131 139
132 /* Finally, configure the SMC */ 140 /* Finally, configure the SMC */
133 return smc_set_configuration(info->cs, smc); 141 return smc_set_configuration(info->cs, smc);
@@ -182,7 +190,6 @@ static struct scsi_host_template at32_sht = {
182}; 190};
183 191
184static struct ata_port_operations at32_port_ops = { 192static struct ata_port_operations at32_port_ops = {
185 .port_disable = ata_port_disable,
186 .set_piomode = pata_at32_set_piomode, 193 .set_piomode = pata_at32_set_piomode,
187 .tf_load = ata_tf_load, 194 .tf_load = ata_tf_load,
188 .tf_read = ata_tf_read, 195 .tf_read = ata_tf_read,
@@ -203,7 +210,6 @@ static struct ata_port_operations at32_port_ops = {
203 210
204 .irq_clear = pata_at32_irq_clear, 211 .irq_clear = pata_at32_irq_clear,
205 .irq_on = ata_irq_on, 212 .irq_on = ata_irq_on,
206 .irq_ack = ata_irq_ack,
207 213
208 .port_start = ata_sff_port_start, 214 .port_start = ata_sff_port_start,
209}; 215};
@@ -223,8 +229,7 @@ static int __init pata_at32_init_one(struct device *dev,
223 /* Setup ATA bindings */ 229 /* Setup ATA bindings */
224 ap->ops = &at32_port_ops; 230 ap->ops = &at32_port_ops;
225 ap->pio_mask = PIO_MASK; 231 ap->pio_mask = PIO_MASK;
226 ap->flags = ATA_FLAG_MMIO | ATA_FLAG_SLAVE_POSS 232 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_SLAVE_POSS;
227 | ATA_FLAG_PIO_POLLING;
228 233
229 /* 234 /*
230 * Since all 8-bit taskfile transfers has to go on the lower 235 * Since all 8-bit taskfile transfers has to go on the lower
@@ -357,12 +362,12 @@ static int __init pata_at32_probe(struct platform_device *pdev)
357 info->smc.tdf_mode = 0; /* TDF optimization disabled */ 362 info->smc.tdf_mode = 0; /* TDF optimization disabled */
358 info->smc.tdf_cycles = 0; /* No TDF wait cycles */ 363 info->smc.tdf_cycles = 0; /* No TDF wait cycles */
359 364
360 /* Setup ATA timing */ 365 /* Setup SMC to ATA timing */
361 ret = pata_at32_setup_timing(dev, info, &initial_timing); 366 ret = pata_at32_setup_timing(dev, info, &initial_timing);
362 if (ret) 367 if (ret)
363 goto err_setup_timing; 368 goto err_setup_timing;
364 369
365 /* Setup ATA addresses */ 370 /* Map ATA address space */
366 ret = -ENOMEM; 371 ret = -ENOMEM;
367 info->ide_addr = devm_ioremap(dev, info->res_ide.start, 16); 372 info->ide_addr = devm_ioremap(dev, info->res_ide.start, 16);
368 info->alt_addr = devm_ioremap(dev, info->res_alt.start, 16); 373 info->alt_addr = devm_ioremap(dev, info->res_alt.start, 16);
@@ -373,7 +378,7 @@ static int __init pata_at32_probe(struct platform_device *pdev)
373 pata_at32_debug_bus(dev, info); 378 pata_at32_debug_bus(dev, info);
374#endif 379#endif
375 380
376 /* Register ATA device */ 381 /* Setup and register ATA device */
377 ret = pata_at32_init_one(dev, info); 382 ret = pata_at32_init_one(dev, info);
378 if (ret) 383 if (ret)
379 goto err_ata_device; 384 goto err_ata_device;
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index b5e38426b815..088a41f4e656 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -1145,13 +1145,13 @@ static unsigned char bfin_bmdma_status(struct ata_port *ap)
1145 unsigned short int_status = ATAPI_GET_INT_STATUS(base); 1145 unsigned short int_status = ATAPI_GET_INT_STATUS(base);
1146 1146
1147 if (ATAPI_GET_STATUS(base) & (MULTI_XFER_ON|ULTRA_XFER_ON)) { 1147 if (ATAPI_GET_STATUS(base) & (MULTI_XFER_ON|ULTRA_XFER_ON)) {
1148 host_stat = ATA_DMA_ACTIVE; 1148 host_stat |= ATA_DMA_ACTIVE;
1149 } 1149 }
1150 if (int_status & (MULTI_DONE_INT|UDMAIN_DONE_INT|UDMAOUT_DONE_INT)) { 1150 if (int_status & (MULTI_DONE_INT|UDMAIN_DONE_INT|UDMAOUT_DONE_INT)) {
1151 host_stat = ATA_DMA_INTR; 1151 host_stat |= ATA_DMA_INTR;
1152 } 1152 }
1153 if (int_status & (MULTI_TERM_INT|UDMAIN_TERM_INT|UDMAOUT_TERM_INT)) { 1153 if (int_status & (MULTI_TERM_INT|UDMAIN_TERM_INT|UDMAOUT_TERM_INT)) {
1154 host_stat = ATA_DMA_ERR; 1154 host_stat |= ATA_DMA_ERR;
1155 } 1155 }
1156 1156
1157 return host_stat; 1157 return host_stat;
@@ -1489,6 +1489,8 @@ static int __devinit bfin_atapi_probe(struct platform_device *pdev)
1489 int board_idx = 0; 1489 int board_idx = 0;
1490 struct resource *res; 1490 struct resource *res;
1491 struct ata_host *host; 1491 struct ata_host *host;
1492 unsigned int fsclk = get_sclk();
1493 int udma_mode = 5;
1492 const struct ata_port_info *ppi[] = 1494 const struct ata_port_info *ppi[] =
1493 { &bfin_port_info[board_idx], NULL }; 1495 { &bfin_port_info[board_idx], NULL };
1494 1496
@@ -1507,6 +1509,11 @@ static int __devinit bfin_atapi_probe(struct platform_device *pdev)
1507 if (res == NULL) 1509 if (res == NULL)
1508 return -EINVAL; 1510 return -EINVAL;
1509 1511
1512 while (bfin_port_info[board_idx].udma_mask>0 && udma_fsclk[udma_mode] > fsclk) {
1513 udma_mode--;
1514 bfin_port_info[board_idx].udma_mask >>= 1;
1515 }
1516
1510 /* 1517 /*
1511 * Now that that's out of the way, wire up the port.. 1518 * Now that that's out of the way, wire up the port..
1512 */ 1519 */
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 3816b8605e0d..46dc70e0dee7 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -329,7 +329,7 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline)
329 /* Restore state */ 329 /* Restore state */
330 pci_write_config_byte(pdev, 0x5B, scr2); 330 pci_write_config_byte(pdev, 0x5B, scr2);
331 331
332 if (ata66 & (1 << ap->port_no)) 332 if (ata66 & (2 >> ap->port_no))
333 ap->cbl = ATA_CBL_PATA40; 333 ap->cbl = ATA_CBL_PATA40;
334 else 334 else
335 ap->cbl = ATA_CBL_PATA80; 335 ap->cbl = ATA_CBL_PATA80;
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index 88ab0e1d353f..4320e7986321 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -75,13 +75,16 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
75 struct ata_host *host; 75 struct ata_host *host;
76 struct ata_port *ap; 76 struct ata_port *ap;
77 void __iomem *cmd_addr, *ctl_addr; 77 void __iomem *cmd_addr, *ctl_addr;
78 int irq = 0;
79 irq_handler_t handler = NULL;
78 80
79 if (pnp_port_valid(idev, 0) == 0) 81 if (pnp_port_valid(idev, 0) == 0)
80 return -ENODEV; 82 return -ENODEV;
81 83
82 /* FIXME: Should selected polled PIO here not fail */ 84 if (pnp_irq_valid(idev, 0)) {
83 if (pnp_irq_valid(idev, 0) == 0) 85 irq = pnp_irq(idev, 0);
84 return -ENODEV; 86 handler = ata_interrupt;
87 }
85 88
86 /* allocate host */ 89 /* allocate host */
87 host = ata_host_alloc(&idev->dev, 1); 90 host = ata_host_alloc(&idev->dev, 1);
@@ -115,7 +118,7 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
115 (unsigned long long)pnp_port_start(idev, 1)); 118 (unsigned long long)pnp_port_start(idev, 1));
116 119
117 /* activate */ 120 /* activate */
118 return ata_host_activate(host, pnp_irq(idev, 0), ata_interrupt, 0, 121 return ata_host_activate(host, irq, handler, 0,
119 &isapnp_sht); 122 &isapnp_sht);
120} 123}
121 124
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 225a7223a726..5b8174d94067 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -80,11 +80,10 @@ static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline)
80 * actually do our cable checking etc. Thankfully we don't need 80 * actually do our cable checking etc. Thankfully we don't need
81 * to do the plumbing for other cases. 81 * to do the plumbing for other cases.
82 */ 82 */
83 switch (port_map[port]) 83 switch (port_map[port]) {
84 {
85 case PORT_PATA0: 84 case PORT_PATA0:
86 if (control & (1 << 5)) 85 if ((control & (1 << 5)) == 0)
87 return 0; 86 return -ENOENT;
88 if (control & (1 << 3)) /* 40/80 pin primary */ 87 if (control & (1 << 3)) /* 40/80 pin primary */
89 ap->cbl = ATA_CBL_PATA40; 88 ap->cbl = ATA_CBL_PATA40;
90 else 89 else
@@ -93,7 +92,7 @@ static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline)
93 case PORT_PATA1: 92 case PORT_PATA1:
94 /* Bit 21 is set if the port is enabled */ 93 /* Bit 21 is set if the port is enabled */
95 if ((control5 & (1 << 21)) == 0) 94 if ((control5 & (1 << 21)) == 0)
96 return 0; 95 return -ENOENT;
97 if (control5 & (1 << 19)) /* 40/80 pin secondary */ 96 if (control5 & (1 << 19)) /* 40/80 pin secondary */
98 ap->cbl = ATA_CBL_PATA40; 97 ap->cbl = ATA_CBL_PATA40;
99 else 98 else
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 5c1e9cb59ecb..503245a1eafa 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -33,7 +33,7 @@
33#include <linux/libata.h> 33#include <linux/libata.h>
34 34
35#define DRV_NAME "pata_sil680" 35#define DRV_NAME "pata_sil680"
36#define DRV_VERSION "0.4.7" 36#define DRV_VERSION "0.4.8"
37 37
38#define SIL680_MMIO_BAR 5 38#define SIL680_MMIO_BAR 5
39 39
@@ -94,34 +94,6 @@ static int sil680_cable_detect(struct ata_port *ap) {
94} 94}
95 95
96/** 96/**
97 * sil680_bus_reset - reset the SIL680 bus
98 * @link: ATA link to reset
99 * @deadline: deadline jiffies for the operation
100 *
101 * Perform the SIL680 housekeeping when doing an ATA bus reset
102 */
103
104static int sil680_bus_reset(struct ata_link *link, unsigned int *classes,
105 unsigned long deadline)
106{
107 struct ata_port *ap = link->ap;
108 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
109 unsigned long addr = sil680_selreg(ap, 0);
110 u8 reset;
111
112 pci_read_config_byte(pdev, addr, &reset);
113 pci_write_config_byte(pdev, addr, reset | 0x03);
114 udelay(25);
115 pci_write_config_byte(pdev, addr, reset);
116 return ata_std_softreset(link, classes, deadline);
117}
118
119static void sil680_error_handler(struct ata_port *ap)
120{
121 ata_bmdma_drive_eh(ap, ata_std_prereset, sil680_bus_reset, NULL, ata_std_postreset);
122}
123
124/**
125 * sil680_set_piomode - set initial PIO mode data 97 * sil680_set_piomode - set initial PIO mode data
126 * @ap: ATA interface 98 * @ap: ATA interface
127 * @adev: ATA device 99 * @adev: ATA device
@@ -249,7 +221,7 @@ static struct ata_port_operations sil680_port_ops = {
249 221
250 .freeze = ata_bmdma_freeze, 222 .freeze = ata_bmdma_freeze,
251 .thaw = ata_bmdma_thaw, 223 .thaw = ata_bmdma_thaw,
252 .error_handler = sil680_error_handler, 224 .error_handler = ata_bmdma_error_handler,
253 .post_internal_cmd = ata_bmdma_post_internal_cmd, 225 .post_internal_cmd = ata_bmdma_post_internal_cmd,
254 .cable_detect = sil680_cable_detect, 226 .cable_detect = sil680_cable_detect,
255 227
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index 3b5be77e861c..87546d9f1ca0 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -55,6 +55,7 @@ static const struct sis_laptop sis_laptop[] = {
55 /* devid, subvendor, subdev */ 55 /* devid, subvendor, subdev */
56 { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */ 56 { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */
57 { 0x5513, 0x1734, 0x105F }, /* FSC Amilo A1630 */ 57 { 0x5513, 0x1734, 0x105F }, /* FSC Amilo A1630 */
58 { 0x5513, 0x1071, 0x8640 }, /* EasyNote K5305 */
58 /* end marker */ 59 /* end marker */
59 { 0, } 60 { 0, }
60}; 61};
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index a43f64d2775b..8d864e5e97ed 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -164,10 +164,14 @@ enum {
164 MV_PCI_ERR_ATTRIBUTE = 0x1d48, 164 MV_PCI_ERR_ATTRIBUTE = 0x1d48,
165 MV_PCI_ERR_COMMAND = 0x1d50, 165 MV_PCI_ERR_COMMAND = 0x1d50,
166 166
167 PCI_IRQ_CAUSE_OFS = 0x1d58, 167 PCI_IRQ_CAUSE_OFS = 0x1d58,
168 PCI_IRQ_MASK_OFS = 0x1d5c, 168 PCI_IRQ_MASK_OFS = 0x1d5c,
169 PCI_UNMASK_ALL_IRQS = 0x7fffff, /* bits 22-0 */ 169 PCI_UNMASK_ALL_IRQS = 0x7fffff, /* bits 22-0 */
170 170
171 PCIE_IRQ_CAUSE_OFS = 0x1900,
172 PCIE_IRQ_MASK_OFS = 0x1910,
173 PCIE_UNMASK_ALL_IRQS = 0x70a, /* assorted bits */
174
171 HC_MAIN_IRQ_CAUSE_OFS = 0x1d60, 175 HC_MAIN_IRQ_CAUSE_OFS = 0x1d60,
172 HC_MAIN_IRQ_MASK_OFS = 0x1d64, 176 HC_MAIN_IRQ_MASK_OFS = 0x1d64,
173 PORT0_ERR = (1 << 0), /* shift by port # */ 177 PORT0_ERR = (1 << 0), /* shift by port # */
@@ -303,6 +307,7 @@ enum {
303 MV_HP_GEN_I = (1 << 6), /* Generation I: 50xx */ 307 MV_HP_GEN_I = (1 << 6), /* Generation I: 50xx */
304 MV_HP_GEN_II = (1 << 7), /* Generation II: 60xx */ 308 MV_HP_GEN_II = (1 << 7), /* Generation II: 60xx */
305 MV_HP_GEN_IIE = (1 << 8), /* Generation IIE: 6042/7042 */ 309 MV_HP_GEN_IIE = (1 << 8), /* Generation IIE: 6042/7042 */
310 MV_HP_PCIE = (1 << 9), /* PCIe bus/regs: 7042 */
306 311
307 /* Port private flags (pp_flags) */ 312 /* Port private flags (pp_flags) */
308 MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */ 313 MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */
@@ -388,7 +393,15 @@ struct mv_port_signal {
388 u32 pre; 393 u32 pre;
389}; 394};
390 395
391struct mv_host_priv; 396struct mv_host_priv {
397 u32 hp_flags;
398 struct mv_port_signal signal[8];
399 const struct mv_hw_ops *ops;
400 u32 irq_cause_ofs;
401 u32 irq_mask_ofs;
402 u32 unmask_all_irqs;
403};
404
392struct mv_hw_ops { 405struct mv_hw_ops {
393 void (*phy_errata)(struct mv_host_priv *hpriv, void __iomem *mmio, 406 void (*phy_errata)(struct mv_host_priv *hpriv, void __iomem *mmio,
394 unsigned int port); 407 unsigned int port);
@@ -401,12 +414,6 @@ struct mv_hw_ops {
401 void (*reset_bus)(struct pci_dev *pdev, void __iomem *mmio); 414 void (*reset_bus)(struct pci_dev *pdev, void __iomem *mmio);
402}; 415};
403 416
404struct mv_host_priv {
405 u32 hp_flags;
406 struct mv_port_signal signal[8];
407 const struct mv_hw_ops *ops;
408};
409
410static void mv_irq_clear(struct ata_port *ap); 417static void mv_irq_clear(struct ata_port *ap);
411static int mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val); 418static int mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val);
412static int mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); 419static int mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
@@ -631,11 +638,13 @@ static const struct pci_device_id mv_pci_tbl[] = {
631 /* Adaptec 1430SA */ 638 /* Adaptec 1430SA */
632 { PCI_VDEVICE(ADAPTEC2, 0x0243), chip_7042 }, 639 { PCI_VDEVICE(ADAPTEC2, 0x0243), chip_7042 },
633 640
634 { PCI_VDEVICE(TTI, 0x2310), chip_7042 }, 641 /* Marvell 7042 support */
635
636 /* add Marvell 7042 support */
637 { PCI_VDEVICE(MARVELL, 0x7042), chip_7042 }, 642 { PCI_VDEVICE(MARVELL, 0x7042), chip_7042 },
638 643
644 /* Highpoint RocketRAID PCIe series */
645 { PCI_VDEVICE(TTI, 0x2300), chip_7042 },
646 { PCI_VDEVICE(TTI, 0x2310), chip_7042 },
647
639 { } /* terminate list */ 648 { } /* terminate list */
640}; 649};
641 650
@@ -1648,13 +1657,14 @@ static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc)
1648 1657
1649static void mv_pci_error(struct ata_host *host, void __iomem *mmio) 1658static void mv_pci_error(struct ata_host *host, void __iomem *mmio)
1650{ 1659{
1660 struct mv_host_priv *hpriv = host->private_data;
1651 struct ata_port *ap; 1661 struct ata_port *ap;
1652 struct ata_queued_cmd *qc; 1662 struct ata_queued_cmd *qc;
1653 struct ata_eh_info *ehi; 1663 struct ata_eh_info *ehi;
1654 unsigned int i, err_mask, printed = 0; 1664 unsigned int i, err_mask, printed = 0;
1655 u32 err_cause; 1665 u32 err_cause;
1656 1666
1657 err_cause = readl(mmio + PCI_IRQ_CAUSE_OFS); 1667 err_cause = readl(mmio + hpriv->irq_cause_ofs);
1658 1668
1659 dev_printk(KERN_ERR, host->dev, "PCI ERROR; PCI IRQ cause=0x%08x\n", 1669 dev_printk(KERN_ERR, host->dev, "PCI ERROR; PCI IRQ cause=0x%08x\n",
1660 err_cause); 1670 err_cause);
@@ -1662,7 +1672,7 @@ static void mv_pci_error(struct ata_host *host, void __iomem *mmio)
1662 DPRINTK("All regs @ PCI error\n"); 1672 DPRINTK("All regs @ PCI error\n");
1663 mv_dump_all_regs(mmio, -1, to_pci_dev(host->dev)); 1673 mv_dump_all_regs(mmio, -1, to_pci_dev(host->dev));
1664 1674
1665 writelfl(0, mmio + PCI_IRQ_CAUSE_OFS); 1675 writelfl(0, mmio + hpriv->irq_cause_ofs);
1666 1676
1667 for (i = 0; i < host->n_ports; i++) { 1677 for (i = 0; i < host->n_ports; i++) {
1668 ap = host->ports[i]; 1678 ap = host->ports[i];
@@ -1926,6 +1936,8 @@ static int mv5_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio,
1926#define ZERO(reg) writel(0, mmio + (reg)) 1936#define ZERO(reg) writel(0, mmio + (reg))
1927static void mv_reset_pci_bus(struct pci_dev *pdev, void __iomem *mmio) 1937static void mv_reset_pci_bus(struct pci_dev *pdev, void __iomem *mmio)
1928{ 1938{
1939 struct ata_host *host = dev_get_drvdata(&pdev->dev);
1940 struct mv_host_priv *hpriv = host->private_data;
1929 u32 tmp; 1941 u32 tmp;
1930 1942
1931 tmp = readl(mmio + MV_PCI_MODE); 1943 tmp = readl(mmio + MV_PCI_MODE);
@@ -1937,8 +1949,8 @@ static void mv_reset_pci_bus(struct pci_dev *pdev, void __iomem *mmio)
1937 writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT); 1949 writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT);
1938 ZERO(HC_MAIN_IRQ_MASK_OFS); 1950 ZERO(HC_MAIN_IRQ_MASK_OFS);
1939 ZERO(MV_PCI_SERR_MASK); 1951 ZERO(MV_PCI_SERR_MASK);
1940 ZERO(PCI_IRQ_CAUSE_OFS); 1952 ZERO(hpriv->irq_cause_ofs);
1941 ZERO(PCI_IRQ_MASK_OFS); 1953 ZERO(hpriv->irq_mask_ofs);
1942 ZERO(MV_PCI_ERR_LOW_ADDRESS); 1954 ZERO(MV_PCI_ERR_LOW_ADDRESS);
1943 ZERO(MV_PCI_ERR_HIGH_ADDRESS); 1955 ZERO(MV_PCI_ERR_HIGH_ADDRESS);
1944 ZERO(MV_PCI_ERR_ATTRIBUTE); 1956 ZERO(MV_PCI_ERR_ATTRIBUTE);
@@ -2170,7 +2182,7 @@ static void mv_phy_reset(struct ata_port *ap, unsigned int *class,
2170 mv_scr_read(ap, SCR_ERROR, &serror); 2182 mv_scr_read(ap, SCR_ERROR, &serror);
2171 mv_scr_read(ap, SCR_CONTROL, &scontrol); 2183 mv_scr_read(ap, SCR_CONTROL, &scontrol);
2172 DPRINTK("S-regs after ATA_RST: SStat 0x%08x SErr 0x%08x " 2184 DPRINTK("S-regs after ATA_RST: SStat 0x%08x SErr 0x%08x "
2173 "SCtrl 0x%08x\n", status, serror, scontrol); 2185 "SCtrl 0x%08x\n", sstatus, serror, scontrol);
2174 } 2186 }
2175#endif 2187#endif
2176 2188
@@ -2490,6 +2502,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
2490 break; 2502 break;
2491 2503
2492 case chip_7042: 2504 case chip_7042:
2505 hp_flags |= MV_HP_PCIE;
2493 case chip_6042: 2506 case chip_6042:
2494 hpriv->ops = &mv6xxx_ops; 2507 hpriv->ops = &mv6xxx_ops;
2495 hp_flags |= MV_HP_GEN_IIE; 2508 hp_flags |= MV_HP_GEN_IIE;
@@ -2516,6 +2529,15 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
2516 } 2529 }
2517 2530
2518 hpriv->hp_flags = hp_flags; 2531 hpriv->hp_flags = hp_flags;
2532 if (hp_flags & MV_HP_PCIE) {
2533 hpriv->irq_cause_ofs = PCIE_IRQ_CAUSE_OFS;
2534 hpriv->irq_mask_ofs = PCIE_IRQ_MASK_OFS;
2535 hpriv->unmask_all_irqs = PCIE_UNMASK_ALL_IRQS;
2536 } else {
2537 hpriv->irq_cause_ofs = PCI_IRQ_CAUSE_OFS;
2538 hpriv->irq_mask_ofs = PCI_IRQ_MASK_OFS;
2539 hpriv->unmask_all_irqs = PCI_UNMASK_ALL_IRQS;
2540 }
2519 2541
2520 return 0; 2542 return 0;
2521} 2543}
@@ -2595,10 +2617,10 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx)
2595 } 2617 }
2596 2618
2597 /* Clear any currently outstanding host interrupt conditions */ 2619 /* Clear any currently outstanding host interrupt conditions */
2598 writelfl(0, mmio + PCI_IRQ_CAUSE_OFS); 2620 writelfl(0, mmio + hpriv->irq_cause_ofs);
2599 2621
2600 /* and unmask interrupt generation for host regs */ 2622 /* and unmask interrupt generation for host regs */
2601 writelfl(PCI_UNMASK_ALL_IRQS, mmio + PCI_IRQ_MASK_OFS); 2623 writelfl(hpriv->unmask_all_irqs, mmio + hpriv->irq_mask_ofs);
2602 2624
2603 if (IS_GEN_I(hpriv)) 2625 if (IS_GEN_I(hpriv))
2604 writelfl(~HC_MAIN_MASKED_IRQS_5, mmio + HC_MAIN_IRQ_MASK_OFS); 2626 writelfl(~HC_MAIN_MASKED_IRQS_5, mmio + HC_MAIN_IRQ_MASK_OFS);
@@ -2609,8 +2631,8 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx)
2609 "PCI int cause/mask=0x%08x/0x%08x\n", 2631 "PCI int cause/mask=0x%08x/0x%08x\n",
2610 readl(mmio + HC_MAIN_IRQ_CAUSE_OFS), 2632 readl(mmio + HC_MAIN_IRQ_CAUSE_OFS),
2611 readl(mmio + HC_MAIN_IRQ_MASK_OFS), 2633 readl(mmio + HC_MAIN_IRQ_MASK_OFS),
2612 readl(mmio + PCI_IRQ_CAUSE_OFS), 2634 readl(mmio + hpriv->irq_cause_ofs),
2613 readl(mmio + PCI_IRQ_MASK_OFS)); 2635 readl(mmio + hpriv->irq_mask_ofs));
2614 2636
2615done: 2637done:
2616 return rc; 2638 return rc;
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 187dcb02c681..96fd5260446d 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -63,6 +63,21 @@ enum {
63 SIL24_HOST_BAR = 0, 63 SIL24_HOST_BAR = 0,
64 SIL24_PORT_BAR = 2, 64 SIL24_PORT_BAR = 2,
65 65
66 /* sil24 fetches in chunks of 64bytes. The first block
67 * contains the PRB and two SGEs. From the second block, it's
68 * consisted of four SGEs and called SGT. Calculate the
69 * number of SGTs that fit into one page.
70 */
71 SIL24_PRB_SZ = sizeof(struct sil24_prb)
72 + 2 * sizeof(struct sil24_sge),
73 SIL24_MAX_SGT = (PAGE_SIZE - SIL24_PRB_SZ)
74 / (4 * sizeof(struct sil24_sge)),
75
76 /* This will give us one unused SGEs for ATA. This extra SGE
77 * will be used to store CDB for ATAPI devices.
78 */
79 SIL24_MAX_SGE = 4 * SIL24_MAX_SGT + 1,
80
66 /* 81 /*
67 * Global controller registers (128 bytes @ BAR0) 82 * Global controller registers (128 bytes @ BAR0)
68 */ 83 */
@@ -247,13 +262,13 @@ enum {
247 262
248struct sil24_ata_block { 263struct sil24_ata_block {
249 struct sil24_prb prb; 264 struct sil24_prb prb;
250 struct sil24_sge sge[LIBATA_MAX_PRD]; 265 struct sil24_sge sge[SIL24_MAX_SGE];
251}; 266};
252 267
253struct sil24_atapi_block { 268struct sil24_atapi_block {
254 struct sil24_prb prb; 269 struct sil24_prb prb;
255 u8 cdb[16]; 270 u8 cdb[16];
256 struct sil24_sge sge[LIBATA_MAX_PRD - 1]; 271 struct sil24_sge sge[SIL24_MAX_SGE];
257}; 272};
258 273
259union sil24_cmd_block { 274union sil24_cmd_block {
@@ -378,7 +393,7 @@ static struct scsi_host_template sil24_sht = {
378 .change_queue_depth = ata_scsi_change_queue_depth, 393 .change_queue_depth = ata_scsi_change_queue_depth,
379 .can_queue = SIL24_MAX_CMDS, 394 .can_queue = SIL24_MAX_CMDS,
380 .this_id = ATA_SHT_THIS_ID, 395 .this_id = ATA_SHT_THIS_ID,
381 .sg_tablesize = LIBATA_MAX_PRD, 396 .sg_tablesize = SIL24_MAX_SGE,
382 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 397 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
383 .emulated = ATA_SHT_EMULATED, 398 .emulated = ATA_SHT_EMULATED,
384 .use_clustering = ATA_SHT_USE_CLUSTERING, 399 .use_clustering = ATA_SHT_USE_CLUSTERING,
@@ -1284,6 +1299,7 @@ static void sil24_init_controller(struct ata_host *host)
1284 1299
1285static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 1300static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1286{ 1301{
1302 extern int __MARKER__sil24_cmd_block_is_sized_wrongly;
1287 static int printed_version; 1303 static int printed_version;
1288 struct ata_port_info pi = sil24_port_info[ent->driver_data]; 1304 struct ata_port_info pi = sil24_port_info[ent->driver_data];
1289 const struct ata_port_info *ppi[] = { &pi, NULL }; 1305 const struct ata_port_info *ppi[] = { &pi, NULL };
@@ -1292,6 +1308,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1292 int i, rc; 1308 int i, rc;
1293 u32 tmp; 1309 u32 tmp;
1294 1310
1311 /* cause link error if sil24_cmd_block is sized wrongly */
1312 if (sizeof(union sil24_cmd_block) != PAGE_SIZE)
1313 __MARKER__sil24_cmd_block_is_sized_wrongly = 1;
1314
1295 if (!printed_version++) 1315 if (!printed_version++)
1296 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 1316 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
1297 1317
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 3f4d6aa13990..2683eac30c68 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -770,9 +770,10 @@ int device_add(struct device *dev)
770 error = device_add_attrs(dev); 770 error = device_add_attrs(dev);
771 if (error) 771 if (error)
772 goto AttrsError; 772 goto AttrsError;
773 error = device_pm_add(dev); 773 error = dpm_sysfs_add(dev);
774 if (error) 774 if (error)
775 goto PMError; 775 goto PMError;
776 device_pm_add(dev);
776 error = bus_add_device(dev); 777 error = bus_add_device(dev);
777 if (error) 778 if (error)
778 goto BusError; 779 goto BusError;
@@ -797,6 +798,7 @@ int device_add(struct device *dev)
797 return error; 798 return error;
798 BusError: 799 BusError:
799 device_pm_remove(dev); 800 device_pm_remove(dev);
801 dpm_sysfs_remove(dev);
800 PMError: 802 PMError:
801 if (dev->bus) 803 if (dev->bus)
802 blocking_notifier_call_chain(&dev->bus->bus_notifier, 804 blocking_notifier_call_chain(&dev->bus->bus_notifier,
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile
index a803733c839e..44504e6618fb 100644
--- a/drivers/base/power/Makefile
+++ b/drivers/base/power/Makefile
@@ -1,5 +1,6 @@
1obj-y := shutdown.o 1obj-y := shutdown.o
2obj-$(CONFIG_PM_SLEEP) += main.o sysfs.o 2obj-$(CONFIG_PM) += sysfs.o
3obj-$(CONFIG_PM_SLEEP) += main.o
3obj-$(CONFIG_PM_TRACE) += trace.o 4obj-$(CONFIG_PM_TRACE) += trace.o
4 5
5ifeq ($(CONFIG_DEBUG_DRIVER),y) 6ifeq ($(CONFIG_DEBUG_DRIVER),y)
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 0ab4ab21f564..691ffb64cc37 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -38,20 +38,14 @@ static DEFINE_MUTEX(dpm_list_mtx);
38int (*platform_enable_wakeup)(struct device *dev, int is_on); 38int (*platform_enable_wakeup)(struct device *dev, int is_on);
39 39
40 40
41int device_pm_add(struct device *dev) 41void device_pm_add(struct device *dev)
42{ 42{
43 int error;
44
45 pr_debug("PM: Adding info for %s:%s\n", 43 pr_debug("PM: Adding info for %s:%s\n",
46 dev->bus ? dev->bus->name : "No Bus", 44 dev->bus ? dev->bus->name : "No Bus",
47 kobject_name(&dev->kobj)); 45 kobject_name(&dev->kobj));
48 mutex_lock(&dpm_list_mtx); 46 mutex_lock(&dpm_list_mtx);
49 list_add_tail(&dev->power.entry, &dpm_active); 47 list_add_tail(&dev->power.entry, &dpm_active);
50 error = dpm_sysfs_add(dev);
51 if (error)
52 list_del(&dev->power.entry);
53 mutex_unlock(&dpm_list_mtx); 48 mutex_unlock(&dpm_list_mtx);
54 return error;
55} 49}
56 50
57void device_pm_remove(struct device *dev) 51void device_pm_remove(struct device *dev)
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 5c4efd493fa5..379da4e958e0 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -13,14 +13,29 @@ extern void device_shutdown(void);
13 13
14extern struct list_head dpm_active; /* The active device list */ 14extern struct list_head dpm_active; /* The active device list */
15 15
16static inline struct device * to_device(struct list_head * entry) 16static inline struct device *to_device(struct list_head *entry)
17{ 17{
18 return container_of(entry, struct device, power.entry); 18 return container_of(entry, struct device, power.entry);
19} 19}
20 20
21extern int device_pm_add(struct device *); 21extern void device_pm_add(struct device *);
22extern void device_pm_remove(struct device *); 22extern void device_pm_remove(struct device *);
23 23
24#else /* CONFIG_PM_SLEEP */
25
26
27static inline void device_pm_add(struct device *dev)
28{
29}
30
31static inline void device_pm_remove(struct device *dev)
32{
33}
34
35#endif
36
37#ifdef CONFIG_PM
38
24/* 39/*
25 * sysfs.c 40 * sysfs.c
26 */ 41 */
@@ -28,16 +43,15 @@ extern void device_pm_remove(struct device *);
28extern int dpm_sysfs_add(struct device *); 43extern int dpm_sysfs_add(struct device *);
29extern void dpm_sysfs_remove(struct device *); 44extern void dpm_sysfs_remove(struct device *);
30 45
31#else /* CONFIG_PM_SLEEP */ 46#else /* CONFIG_PM */
32
33 47
34static inline int device_pm_add(struct device * dev) 48static inline int dpm_sysfs_add(struct device *dev)
35{ 49{
36 return 0; 50 return 0;
37} 51}
38static inline void device_pm_remove(struct device * dev)
39{
40 52
53static inline void dpm_sysfs_remove(struct device *dev)
54{
41} 55}
42 56
43#endif 57#endif
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 3cf7129d83e6..924ddd8bccd2 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -223,7 +223,7 @@ static int virtblk_probe(struct virtio_device *vdev)
223 err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_CAPACITY, &cap); 223 err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_CAPACITY, &cap);
224 if (err) { 224 if (err) {
225 dev_err(&vdev->dev, "Bad/missing capacity in config\n"); 225 dev_err(&vdev->dev, "Bad/missing capacity in config\n");
226 goto out_put_disk; 226 goto out_cleanup_queue;
227 } 227 }
228 228
229 /* If capacity is too big, truncate with warning. */ 229 /* If capacity is too big, truncate with warning. */
@@ -239,7 +239,7 @@ static int virtblk_probe(struct virtio_device *vdev)
239 blk_queue_max_segment_size(vblk->disk->queue, v); 239 blk_queue_max_segment_size(vblk->disk->queue, v);
240 else if (err != -ENOENT) { 240 else if (err != -ENOENT) {
241 dev_err(&vdev->dev, "Bad SIZE_MAX in config\n"); 241 dev_err(&vdev->dev, "Bad SIZE_MAX in config\n");
242 goto out_put_disk; 242 goto out_cleanup_queue;
243 } 243 }
244 244
245 err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_SEG_MAX, &v); 245 err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_SEG_MAX, &v);
@@ -247,12 +247,14 @@ static int virtblk_probe(struct virtio_device *vdev)
247 blk_queue_max_hw_segments(vblk->disk->queue, v); 247 blk_queue_max_hw_segments(vblk->disk->queue, v);
248 else if (err != -ENOENT) { 248 else if (err != -ENOENT) {
249 dev_err(&vdev->dev, "Bad SEG_MAX in config\n"); 249 dev_err(&vdev->dev, "Bad SEG_MAX in config\n");
250 goto out_put_disk; 250 goto out_cleanup_queue;
251 } 251 }
252 252
253 add_disk(vblk->disk); 253 add_disk(vblk->disk);
254 return 0; 254 return 0;
255 255
256out_cleanup_queue:
257 blk_cleanup_queue(vblk->disk->queue);
256out_put_disk: 258out_put_disk:
257 put_disk(vblk->disk); 259 put_disk(vblk->disk);
258out_unregister_blkdev: 260out_unregister_blkdev:
@@ -277,6 +279,8 @@ static void virtblk_remove(struct virtio_device *vdev)
277 put_disk(vblk->disk); 279 put_disk(vblk->disk);
278 unregister_blkdev(major, "virtblk"); 280 unregister_blkdev(major, "virtblk");
279 mempool_destroy(vblk->pool); 281 mempool_destroy(vblk->pool);
282 /* There should be nothing in the queue now, so no need to shutdown */
283 vdev->config->del_vq(vblk->vq);
280 kfree(vblk); 284 kfree(vblk);
281} 285}
282 286
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index bf18d757b876..a509b8d79781 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -457,7 +457,7 @@ config LEGACY_PTYS
457config LEGACY_PTY_COUNT 457config LEGACY_PTY_COUNT
458 int "Maximum number of legacy PTY in use" 458 int "Maximum number of legacy PTY in use"
459 depends on LEGACY_PTYS 459 depends on LEGACY_PTYS
460 range 1 256 460 range 0 256
461 default "256" 461 default "256"
462 ---help--- 462 ---help---
463 The maximum number of legacy PTYs that can be used at any one time. 463 The maximum number of legacy PTYs that can be used at any one time.
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 877e53dcb996..921c6d2bc8fc 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -1163,7 +1163,7 @@ static struct acpi_driver sonypi_acpi_driver = {
1163}; 1163};
1164#endif 1164#endif
1165 1165
1166static int __devinit sonypi_create_input_devices(void) 1166static int __devinit sonypi_create_input_devices(struct platform_device *pdev)
1167{ 1167{
1168 struct input_dev *jog_dev; 1168 struct input_dev *jog_dev;
1169 struct input_dev *key_dev; 1169 struct input_dev *key_dev;
@@ -1177,6 +1177,7 @@ static int __devinit sonypi_create_input_devices(void)
1177 jog_dev->name = "Sony Vaio Jogdial"; 1177 jog_dev->name = "Sony Vaio Jogdial";
1178 jog_dev->id.bustype = BUS_ISA; 1178 jog_dev->id.bustype = BUS_ISA;
1179 jog_dev->id.vendor = PCI_VENDOR_ID_SONY; 1179 jog_dev->id.vendor = PCI_VENDOR_ID_SONY;
1180 jog_dev->dev.parent = &pdev->dev;
1180 1181
1181 jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 1182 jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
1182 jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE); 1183 jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE);
@@ -1191,6 +1192,7 @@ static int __devinit sonypi_create_input_devices(void)
1191 key_dev->name = "Sony Vaio Keys"; 1192 key_dev->name = "Sony Vaio Keys";
1192 key_dev->id.bustype = BUS_ISA; 1193 key_dev->id.bustype = BUS_ISA;
1193 key_dev->id.vendor = PCI_VENDOR_ID_SONY; 1194 key_dev->id.vendor = PCI_VENDOR_ID_SONY;
1195 key_dev->dev.parent = &pdev->dev;
1194 1196
1195 /* Initialize the Input Drivers: special keys */ 1197 /* Initialize the Input Drivers: special keys */
1196 key_dev->evbit[0] = BIT_MASK(EV_KEY); 1198 key_dev->evbit[0] = BIT_MASK(EV_KEY);
@@ -1385,7 +1387,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1385 1387
1386 if (useinput) { 1388 if (useinput) {
1387 1389
1388 error = sonypi_create_input_devices(); 1390 error = sonypi_create_input_devices(dev);
1389 if (error) { 1391 if (error) {
1390 printk(KERN_ERR 1392 printk(KERN_ERR
1391 "sonypi: failed to create input devices\n"); 1393 "sonypi: failed to create input devices\n");
@@ -1432,7 +1434,7 @@ static int __devexit sonypi_remove(struct platform_device *dev)
1432{ 1434{
1433 sonypi_disable(); 1435 sonypi_disable();
1434 1436
1435 synchronize_sched(); /* Allow sonypi interrupt to complete. */ 1437 synchronize_irq(sonypi_device.irq);
1436 flush_scheduled_work(); 1438 flush_scheduled_work();
1437 1439
1438 if (useinput) { 1440 if (useinput) {
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index fd771a4d6d18..81503d94fecc 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -450,6 +450,11 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
450 goto out_err; 450 goto out_err;
451 } 451 }
452 452
453 if (request_locality(chip, 0) != 0) {
454 rc = -ENODEV;
455 goto out_err;
456 }
457
453 vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0)); 458 vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
454 459
455 /* Default timeouts */ 460 /* Default timeouts */
@@ -487,11 +492,6 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
487 if (intfcaps & TPM_INTF_DATA_AVAIL_INT) 492 if (intfcaps & TPM_INTF_DATA_AVAIL_INT)
488 dev_dbg(dev, "\tData Avail Int Support\n"); 493 dev_dbg(dev, "\tData Avail Int Support\n");
489 494
490 if (request_locality(chip, 0) != 0) {
491 rc = -ENODEV;
492 goto out_err;
493 }
494
495 /* INTERRUPT Setup */ 495 /* INTERRUPT Setup */
496 init_waitqueue_head(&chip->vendor.read_queue); 496 init_waitqueue_head(&chip->vendor.read_queue);
497 init_waitqueue_head(&chip->vendor.int_queue); 497 init_waitqueue_head(&chip->vendor.int_queue);
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 5fd6688a444a..ddd3a259cea1 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -12,7 +12,7 @@ if CRYPTO_HW
12 12
13config CRYPTO_DEV_PADLOCK 13config CRYPTO_DEV_PADLOCK
14 tristate "Support for VIA PadLock ACE" 14 tristate "Support for VIA PadLock ACE"
15 depends on X86_32 15 depends on X86_32 && !UML
16 select CRYPTO_ALGAPI 16 select CRYPTO_ALGAPI
17 help 17 help
18 Some VIA processors come with an integrated crypto engine 18 Some VIA processors come with an integrated crypto engine
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 6a7d25fc2470..c46b7c219ee9 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -3,11 +3,13 @@
3# 3#
4 4
5menuconfig DMADEVICES 5menuconfig DMADEVICES
6 bool "DMA Offload Engine support" 6 bool "DMA Engine support"
7 depends on (PCI && X86) || ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX 7 depends on (PCI && X86) || ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX
8 help 8 help
9 Intel(R) offload engines enable offloading memory copies in the 9 DMA engines can do asynchronous data transfers without
10 network stack and RAID operations in the MD driver. 10 involving the host CPU. Currently, this framework can be
11 used to offload memory copies in the network stack and
12 RAID operations in the MD driver.
11 13
12if DMADEVICES 14if DMADEVICES
13 15
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index e445fe6e4ba9..45b22282f149 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -313,7 +313,6 @@ comment "IDE chipset support/bugfixes"
313 313
314config IDE_GENERIC 314config IDE_GENERIC
315 tristate "generic/default IDE chipset support" 315 tristate "generic/default IDE chipset support"
316 default H8300
317 help 316 help
318 If unsure, say N. 317 If unsure, say N.
319 318
@@ -484,6 +483,7 @@ config WDC_ALI15X3
484 483
485config BLK_DEV_AMD74XX 484config BLK_DEV_AMD74XX
486 tristate "AMD and nVidia IDE support" 485 tristate "AMD and nVidia IDE support"
486 depends on !ARM
487 select BLK_DEV_IDEDMA_PCI 487 select BLK_DEV_IDEDMA_PCI
488 help 488 help
489 This driver adds explicit support for AMD-7xx and AMD-8111 chips 489 This driver adds explicit support for AMD-7xx and AMD-8111 chips
@@ -883,6 +883,49 @@ config BLK_DEV_IDE_BAST
883 Say Y here if you want to support the onboard IDE channels on the 883 Say Y here if you want to support the onboard IDE channels on the
884 Simtec BAST or the Thorcom VR1000 884 Simtec BAST or the Thorcom VR1000
885 885
886config ETRAX_IDE
887 bool "ETRAX IDE support"
888 depends on CRIS && BROKEN
889 select BLK_DEV_IDEDMA
890 select IDE_GENERIC
891 help
892 Enables the ETRAX IDE driver.
893
894 You can't use parallel ports or SCSI ports at the same time.
895
896config ETRAX_IDE_DELAY
897 int "Delay for drives to regain consciousness"
898 depends on ETRAX_IDE && ETRAX_ARCH_V10
899 default 15
900 help
901 Number of seconds to wait for IDE drives to spin up after an IDE
902 reset.
903
904choice
905 prompt "IDE reset pin"
906 depends on ETRAX_IDE && ETRAX_ARCH_V10
907 default ETRAX_IDE_PB7_RESET
908
909config ETRAX_IDE_PB7_RESET
910 bool "Port_PB_Bit_7"
911 help
912 IDE reset on pin 7 on port B
913
914config ETRAX_IDE_G27_RESET
915 bool "Port_G_Bit_27"
916 help
917 IDE reset on pin 27 on port G
918
919endchoice
920
921config IDE_H8300
922 bool "H8300 IDE support"
923 depends on H8300
924 select IDE_GENERIC
925 default y
926 help
927 Enables the H8300 IDE driver.
928
886config BLK_DEV_GAYLE 929config BLK_DEV_GAYLE
887 bool "Amiga Gayle IDE interface support" 930 bool "Amiga Gayle IDE interface support"
888 depends on AMIGA 931 depends on AMIGA
@@ -963,7 +1006,7 @@ config BLK_DEV_Q40IDE
963 1006
964config BLK_DEV_MPC8xx_IDE 1007config BLK_DEV_MPC8xx_IDE
965 bool "MPC8xx IDE support" 1008 bool "MPC8xx IDE support"
966 depends on 8xx && IDE=y && BLK_DEV_IDE=y && !PPC_MERGE 1009 depends on 8xx && (LWMON || IVMS8 || IVML24 || TQM8xxL) && IDE=y && BLK_DEV_IDE=y && !PPC_MERGE
967 select IDE_GENERIC 1010 select IDE_GENERIC
968 help 1011 help
969 This option provides support for IDE on Motorola MPC8xx Systems. 1012 This option provides support for IDE on Motorola MPC8xx Systems.
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index 75dc6969e0a7..b181fc672057 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -39,7 +39,7 @@ ide-core-$(CONFIG_BLK_DEV_MPC8xx_IDE) += ppc/mpc8xx.o
39ide-core-$(CONFIG_BLK_DEV_IDE_PMAC) += ppc/pmac.o 39ide-core-$(CONFIG_BLK_DEV_IDE_PMAC) += ppc/pmac.o
40 40
41# built-in only drivers from h8300/ 41# built-in only drivers from h8300/
42ide-core-$(CONFIG_H8300) += h8300/ide-h8300.o 42ide-core-$(CONFIG_IDE_H8300) += h8300/ide-h8300.o
43 43
44obj-$(CONFIG_BLK_DEV_IDE) += ide-core.o 44obj-$(CONFIG_BLK_DEV_IDE) += ide-core.o
45obj-$(CONFIG_IDE_GENERIC) += ide-generic.o 45obj-$(CONFIG_IDE_GENERIC) += ide-generic.o
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index 7f5bc2ee6c7e..476e0d65ed43 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -773,15 +773,16 @@ init_e100_ide (void)
773 /* the IDE control register is at ATA address 6, with CS1 active instead of CS0 */ 773 /* the IDE control register is at ATA address 6, with CS1 active instead of CS0 */
774 ide_offsets[IDE_CONTROL_OFFSET] = cris_ide_reg_addr(6, 1, 0); 774 ide_offsets[IDE_CONTROL_OFFSET] = cris_ide_reg_addr(6, 1, 0);
775 775
776 /* first fill in some stuff in the ide_hwifs fields */ 776 for (h = 0; h < 4; h++) {
777 ide_hwif_t *hwif = NULL;
777 778
778 for(h = 0; h < MAX_HWIFS; h++) {
779 ide_hwif_t *hwif = &ide_hwifs[h];
780 ide_setup_ports(&hw, cris_ide_base_address(h), 779 ide_setup_ports(&hw, cris_ide_base_address(h),
781 ide_offsets, 780 ide_offsets,
782 0, 0, cris_ide_ack_intr, 781 0, 0, cris_ide_ack_intr,
783 ide_default_irq(0)); 782 ide_default_irq(0));
784 ide_register_hw(&hw, NULL, 1, &hwif); 783 ide_register_hw(&hw, NULL, 1, &hwif);
784 if (hwif == NULL)
785 continue;
785 hwif->mmio = 1; 786 hwif->mmio = 1;
786 hwif->chipset = ide_etrax100; 787 hwif->chipset = ide_etrax100;
787 hwif->set_pio_mode = &cris_set_pio_mode; 788 hwif->set_pio_mode = &cris_set_pio_mode;
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index e3add70b9cd8..0d795a1678c7 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -130,6 +130,7 @@ static const struct drive_list_entry drive_blacklist [] = {
130 { "_NEC DV5800A", NULL }, 130 { "_NEC DV5800A", NULL },
131 { "SAMSUNG CD-ROM SN-124", "N001" }, 131 { "SAMSUNG CD-ROM SN-124", "N001" },
132 { "Seagate STT20000A", NULL }, 132 { "Seagate STT20000A", NULL },
133 { "CD-ROM CDR_U200", "1.09" },
133 { NULL , NULL } 134 { NULL , NULL }
134 135
135}; 136};
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index e17a9ee120ea..5c3256180ae5 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -303,9 +303,6 @@ void default_hwif_transport(ide_hwif_t *hwif)
303 hwif->atapi_output_bytes = atapi_output_bytes; 303 hwif->atapi_output_bytes = atapi_output_bytes;
304} 304}
305 305
306/*
307 * Beginning of Taskfile OPCODE Library and feature sets.
308 */
309void ide_fix_driveid (struct hd_driveid *id) 306void ide_fix_driveid (struct hd_driveid *id)
310{ 307{
311#ifndef __LITTLE_ENDIAN 308#ifndef __LITTLE_ENDIAN
@@ -592,6 +589,9 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list);
592static const struct drive_list_entry ivb_list[] = { 589static const struct drive_list_entry ivb_list[] = {
593 { "QUANTUM FIREBALLlct10 05" , "A03.0900" }, 590 { "QUANTUM FIREBALLlct10 05" , "A03.0900" },
594 { "TSSTcorp CDDVDW SH-S202J" , "SB00" }, 591 { "TSSTcorp CDDVDW SH-S202J" , "SB00" },
592 { "TSSTcorp CDDVDW SH-S202J" , "SB01" },
593 { "TSSTcorp CDDVDW SH-S202N" , "SB00" },
594 { "TSSTcorp CDDVDW SH-S202N" , "SB01" },
595 { NULL , NULL } 595 { NULL , NULL }
596}; 596};
597 597
@@ -756,7 +756,7 @@ int ide_driveid_update(ide_drive_t *drive)
756int ide_config_drive_speed(ide_drive_t *drive, u8 speed) 756int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
757{ 757{
758 ide_hwif_t *hwif = drive->hwif; 758 ide_hwif_t *hwif = drive->hwif;
759 int error; 759 int error = 0;
760 u8 stat; 760 u8 stat;
761 761
762// while (HWGROUP(drive)->busy) 762// while (HWGROUP(drive)->busy)
@@ -767,6 +767,10 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
767 hwif->dma_host_off(drive); 767 hwif->dma_host_off(drive);
768#endif 768#endif
769 769
770 /* Skip setting PIO flow-control modes on pre-EIDE drives */
771 if ((speed & 0xf8) == XFER_PIO_0 && !(drive->id->capability & 0x08))
772 goto skip;
773
770 /* 774 /*
771 * Don't use ide_wait_cmd here - it will 775 * Don't use ide_wait_cmd here - it will
772 * attempt to set_geometry and recalibrate, 776 * attempt to set_geometry and recalibrate,
@@ -814,6 +818,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
814 drive->id->dma_mword &= ~0x0F00; 818 drive->id->dma_mword &= ~0x0F00;
815 drive->id->dma_1word &= ~0x0F00; 819 drive->id->dma_1word &= ~0x0F00;
816 820
821 skip:
817#ifdef CONFIG_BLK_DEV_IDEDMA 822#ifdef CONFIG_BLK_DEV_IDEDMA
818 if (speed >= XFER_SW_DMA_0) 823 if (speed >= XFER_SW_DMA_0)
819 hwif->dma_host_on(drive); 824 hwif->dma_host_on(drive);
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 56fb0b843429..ee848c705995 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -644,7 +644,7 @@ static void hwif_register (ide_hwif_t *hwif)
644 644
645static int wait_hwif_ready(ide_hwif_t *hwif) 645static int wait_hwif_ready(ide_hwif_t *hwif)
646{ 646{
647 int rc; 647 int unit, rc;
648 648
649 printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); 649 printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name);
650 650
@@ -661,20 +661,26 @@ static int wait_hwif_ready(ide_hwif_t *hwif)
661 return rc; 661 return rc;
662 662
663 /* Now make sure both master & slave are ready */ 663 /* Now make sure both master & slave are ready */
664 SELECT_DRIVE(&hwif->drives[0]); 664 for (unit = 0; unit < MAX_DRIVES; unit++) {
665 hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); 665 ide_drive_t *drive = &hwif->drives[unit];
666 mdelay(2);
667 rc = ide_wait_not_busy(hwif, 35000);
668 if (rc)
669 return rc;
670 SELECT_DRIVE(&hwif->drives[1]);
671 hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]);
672 mdelay(2);
673 rc = ide_wait_not_busy(hwif, 35000);
674 666
667 /* Ignore disks that we will not probe for later. */
668 if (!drive->noprobe || drive->present) {
669 SELECT_DRIVE(drive);
670 hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]);
671 mdelay(2);
672 rc = ide_wait_not_busy(hwif, 35000);
673 if (rc)
674 goto out;
675 } else
676 printk(KERN_DEBUG "%s: ide_wait_not_busy() skipped\n",
677 drive->name);
678 }
679out:
675 /* Exit function with master reselected (let's be sane) */ 680 /* Exit function with master reselected (let's be sane) */
676 SELECT_DRIVE(&hwif->drives[0]); 681 if (unit)
677 682 SELECT_DRIVE(&hwif->drives[0]);
683
678 return rc; 684 return rc;
679} 685}
680 686
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
index 10311ecc674a..38c3a6d63f30 100644
--- a/drivers/ide/legacy/ali14xx.c
+++ b/drivers/ide/legacy/ali14xx.c
@@ -53,12 +53,13 @@
53 53
54/* port addresses for auto-detection */ 54/* port addresses for auto-detection */
55#define ALI_NUM_PORTS 4 55#define ALI_NUM_PORTS 4
56static int ports[ALI_NUM_PORTS] __initdata = {0x074, 0x0f4, 0x034, 0x0e4}; 56static const int ports[ALI_NUM_PORTS] __initdata =
57 { 0x074, 0x0f4, 0x034, 0x0e4 };
57 58
58/* register initialization data */ 59/* register initialization data */
59typedef struct { u8 reg, data; } RegInitializer; 60typedef struct { u8 reg, data; } RegInitializer;
60 61
61static RegInitializer initData[] __initdata = { 62static const RegInitializer initData[] __initdata = {
62 {0x01, 0x0f}, {0x02, 0x00}, {0x03, 0x00}, {0x04, 0x00}, 63 {0x01, 0x0f}, {0x02, 0x00}, {0x03, 0x00}, {0x04, 0x00},
63 {0x05, 0x00}, {0x06, 0x00}, {0x07, 0x2b}, {0x0a, 0x0f}, 64 {0x05, 0x00}, {0x06, 0x00}, {0x07, 0x2b}, {0x0a, 0x0f},
64 {0x25, 0x00}, {0x26, 0x00}, {0x27, 0x00}, {0x28, 0x00}, 65 {0x25, 0x00}, {0x26, 0x00}, {0x27, 0x00}, {0x28, 0x00},
@@ -177,7 +178,7 @@ static int __init findPort (void)
177 * Initialize controller registers with default values. 178 * Initialize controller registers with default values.
178 */ 179 */
179static int __init initRegisters (void) { 180static int __init initRegisters (void) {
180 RegInitializer *p; 181 const RegInitializer *p;
181 u8 t; 182 u8 t;
182 unsigned long flags; 183 unsigned long flags;
183 184
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
index e87cd2f16430..5c6aa77c2370 100644
--- a/drivers/ide/legacy/macide.c
+++ b/drivers/ide/legacy/macide.c
@@ -81,7 +81,7 @@ int macide_ack_intr(ide_hwif_t* hwif)
81 * Probe for a Macintosh IDE interface 81 * Probe for a Macintosh IDE interface
82 */ 82 */
83 83
84void macide_init(void) 84void __init macide_init(void)
85{ 85{
86 hw_regs_t hw; 86 hw_regs_t hw;
87 ide_hwif_t *hwif; 87 ide_hwif_t *hwif;
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c
index a73db1bd482d..6ea46a6723e2 100644
--- a/drivers/ide/legacy/q40ide.c
+++ b/drivers/ide/legacy/q40ide.c
@@ -111,7 +111,7 @@ static const char *q40_ide_names[Q40IDE_NUM_HWIFS]={
111 * Probe for Q40 IDE interfaces 111 * Probe for Q40 IDE interfaces
112 */ 112 */
113 113
114void q40ide_init(void) 114void __init q40ide_init(void)
115{ 115{
116 int i; 116 int i;
117 ide_hwif_t *hwif; 117 ide_hwif_t *hwif;
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index 19ec421f7b9f..44268504ae43 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -260,6 +260,11 @@ static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_devi
260{ 260{
261 struct ide_port_info d; 261 struct ide_port_info d;
262 u8 idx = id->driver_data; 262 u8 idx = id->driver_data;
263 int err;
264
265 err = pci_enable_device(dev);
266 if (err)
267 return err;
263 268
264 d = aec62xx_chipsets[idx]; 269 d = aec62xx_chipsets[idx];
265 270
@@ -272,7 +277,11 @@ static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_devi
272 } 277 }
273 } 278 }
274 279
275 return ide_setup_pci_device(dev, &d); 280 err = ide_setup_pci_device(dev, &d);
281 if (err)
282 pci_disable_device(dev);
283
284 return err;
276} 285}
277 286
278static const struct pci_device_id aec62xx_pci_tbl[] = { 287static const struct pci_device_id aec62xx_pci_tbl[] = {
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index a607dd31a64c..ce293936af4b 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -603,6 +603,11 @@ static int ali_cable_override(struct pci_dev *pdev)
603 pdev->subsystem_device == 0x10AF) 603 pdev->subsystem_device == 0x10AF)
604 return 1; 604 return 1;
605 605
606 /* Mitac 8317 (Winbook-A) and relatives */
607 if (pdev->subsystem_vendor == 0x1071 &&
608 pdev->subsystem_device == 0x8317)
609 return 1;
610
606 /* Systems by DMI */ 611 /* Systems by DMI */
607 if (dmi_check_system(cable_dmi_table)) 612 if (dmi_check_system(cable_dmi_table))
608 return 1; 613 return 1;
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index 63625a0be712..27781d294cea 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -306,6 +306,7 @@ static const struct ich_laptop ich_laptop[] = {
306 { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */ 306 { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */
307 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ 307 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */
308 { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ 308 { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */
309 { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */
309 { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on Acer Aspire 2023WLMi */ 310 { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on Acer Aspire 2023WLMi */
310 /* end marker */ 311 /* end marker */
311 { 0, } 312 { 0, }
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 6d99441c605b..5709c252543b 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/siimage.c Version 1.18 Oct 18 2007 2 * linux/drivers/ide/pci/siimage.c Version 1.19 Nov 16 2007
3 * 3 *
4 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2003 Red Hat <alan@redhat.com> 5 * Copyright (C) 2003 Red Hat <alan@redhat.com>
@@ -460,48 +460,6 @@ static void sil_sata_pre_reset(ide_drive_t *drive)
460} 460}
461 461
462/** 462/**
463 * siimage_reset - reset a device on an siimage controller
464 * @drive: drive to reset
465 *
466 * Perform a controller level reset fo the device. For
467 * SATA we must also check the PHY.
468 */
469
470static void siimage_reset (ide_drive_t *drive)
471{
472 ide_hwif_t *hwif = HWIF(drive);
473 u8 reset = 0;
474 unsigned long addr = siimage_selreg(hwif, 0);
475
476 if (hwif->mmio) {
477 reset = hwif->INB(addr);
478 hwif->OUTB((reset|0x03), addr);
479 /* FIXME:posting */
480 udelay(25);
481 hwif->OUTB(reset, addr);
482 (void) hwif->INB(addr);
483 } else {
484 pci_read_config_byte(hwif->pci_dev, addr, &reset);
485 pci_write_config_byte(hwif->pci_dev, addr, reset|0x03);
486 udelay(25);
487 pci_write_config_byte(hwif->pci_dev, addr, reset);
488 pci_read_config_byte(hwif->pci_dev, addr, &reset);
489 }
490
491 if (SATA_STATUS_REG) {
492 /* SATA_STATUS_REG is valid only when in MMIO mode */
493 u32 sata_stat = readl((void __iomem *)SATA_STATUS_REG);
494 printk(KERN_WARNING "%s: reset phy, status=0x%08x, %s\n",
495 hwif->name, sata_stat, __FUNCTION__);
496 if (!(sata_stat)) {
497 printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n",
498 hwif->name, sata_stat);
499 drive->failures++;
500 }
501 }
502}
503
504/**
505 * proc_reports_siimage - add siimage controller to proc 463 * proc_reports_siimage - add siimage controller to proc
506 * @dev: PCI device 464 * @dev: PCI device
507 * @clocking: SCSC value 465 * @clocking: SCSC value
@@ -857,7 +815,6 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
857{ 815{
858 u8 sata = is_sata(hwif); 816 u8 sata = is_sata(hwif);
859 817
860 hwif->resetproc = &siimage_reset;
861 hwif->set_pio_mode = &sil_set_pio_mode; 818 hwif->set_pio_mode = &sil_set_pio_mode;
862 hwif->set_dma_mode = &sil_set_dma_mode; 819 hwif->set_dma_mode = &sil_set_dma_mode;
863 820
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index f6e2ab3dd166..d90b42917775 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -526,6 +526,7 @@ static const struct sis_laptop sis_laptop[] = {
526 /* devid, subvendor, subdev */ 526 /* devid, subvendor, subdev */
527 { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */ 527 { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */
528 { 0x5513, 0x1734, 0x105f }, /* FSC Amilo A1630 */ 528 { 0x5513, 0x1734, 0x105f }, /* FSC Amilo A1630 */
529 { 0x5513, 0x1071, 0x8640 }, /* EasyNote K5305 */
529 /* end marker */ 530 /* end marker */
530 { 0, } 531 { 0, }
531}; 532};
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c
index 5011ba22e36c..0895e753a35d 100644
--- a/drivers/ide/pci/trm290.c
+++ b/drivers/ide/pci/trm290.c
@@ -240,9 +240,6 @@ static int trm290_ide_dma_test_irq (ide_drive_t *drive)
240 return (status == 0x00ff); 240 return (status == 0x00ff);
241} 241}
242 242
243/*
244 * Invoked from ide-dma.c at boot time.
245 */
246static void __devinit init_hwif_trm290(ide_hwif_t *hwif) 243static void __devinit init_hwif_trm290(ide_hwif_t *hwif)
247{ 244{
248 unsigned int cfgbase = 0; 245 unsigned int cfgbase = 0;
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 5afdfef7264c..7f7a59885777 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1513,7 +1513,7 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
1513 1513
1514 if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) { 1514 if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) {
1515 if (pmif->broken_dma_warn == 0) { 1515 if (pmif->broken_dma_warn == 0) {
1516 printk(KERN_WARNING "%s: DMA on non aligned address," 1516 printk(KERN_WARNING "%s: DMA on non aligned address, "
1517 "switching to PIO on Ohare chipset\n", drive->name); 1517 "switching to PIO on Ohare chipset\n", drive->name);
1518 pmif->broken_dma_warn = 1; 1518 pmif->broken_dma_warn = 1;
1519 } 1519 }
diff --git a/drivers/infiniband/hw/ehca/ehca_av.c b/drivers/infiniband/hw/ehca/ehca_av.c
index 453eb995c1d4..f7782c882ab4 100644
--- a/drivers/infiniband/hw/ehca/ehca_av.c
+++ b/drivers/infiniband/hw/ehca/ehca_av.c
@@ -76,8 +76,12 @@ int ehca_calc_ipd(struct ehca_shca *shca, int port,
76 76
77 link = ib_width_enum_to_int(pa.active_width) * pa.active_speed; 77 link = ib_width_enum_to_int(pa.active_width) * pa.active_speed;
78 78
79 /* IPD = round((link / path) - 1) */ 79 if (path >= link)
80 *ipd = ((link + (path >> 1)) / path) - 1; 80 /* no need to throttle if path faster than link */
81 *ipd = 0;
82 else
83 /* IPD = round((link / path) - 1) */
84 *ipd = ((link + (path >> 1)) / path) - 1;
81 85
82 return 0; 86 return 0;
83} 87}
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 2e3e6547cb78..dd126681fed0 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -1203,7 +1203,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1203 mqpcb->service_level = attr->ah_attr.sl; 1203 mqpcb->service_level = attr->ah_attr.sl;
1204 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_SERVICE_LEVEL, 1); 1204 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_SERVICE_LEVEL, 1);
1205 1205
1206 if (ehca_calc_ipd(shca, my_qp->init_attr.port_num, 1206 if (ehca_calc_ipd(shca, mqpcb->prim_phys_port,
1207 attr->ah_attr.static_rate, 1207 attr->ah_attr.static_rate,
1208 &mqpcb->max_static_rate)) { 1208 &mqpcb->max_static_rate)) {
1209 ret = -EINVAL; 1209 ret = -EINVAL;
@@ -1302,7 +1302,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1302 mqpcb->source_path_bits_al = attr->alt_ah_attr.src_path_bits; 1302 mqpcb->source_path_bits_al = attr->alt_ah_attr.src_path_bits;
1303 mqpcb->service_level_al = attr->alt_ah_attr.sl; 1303 mqpcb->service_level_al = attr->alt_ah_attr.sl;
1304 1304
1305 if (ehca_calc_ipd(shca, my_qp->init_attr.port_num, 1305 if (ehca_calc_ipd(shca, mqpcb->alt_phys_port,
1306 attr->alt_ah_attr.static_rate, 1306 attr->alt_ah_attr.static_rate,
1307 &mqpcb->max_static_rate_al)) { 1307 &mqpcb->max_static_rate_al)) {
1308 ret = -EINVAL; 1308 ret = -EINVAL;
diff --git a/drivers/infiniband/hw/ipath/ipath_cq.c b/drivers/infiniband/hw/ipath/ipath_cq.c
index 08d8ae148cd0..d1380c7a1703 100644
--- a/drivers/infiniband/hw/ipath/ipath_cq.c
+++ b/drivers/infiniband/hw/ipath/ipath_cq.c
@@ -395,12 +395,9 @@ int ipath_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata)
395 goto bail; 395 goto bail;
396 } 396 }
397 397
398 /* 398 /* Check that we can write the offset to mmap. */
399 * Return the address of the WC as the offset to mmap.
400 * See ipath_mmap() for details.
401 */
402 if (udata && udata->outlen >= sizeof(__u64)) { 399 if (udata && udata->outlen >= sizeof(__u64)) {
403 __u64 offset = (__u64) wc; 400 __u64 offset = 0;
404 401
405 ret = ib_copy_to_udata(udata, &offset, sizeof(offset)); 402 ret = ib_copy_to_udata(udata, &offset, sizeof(offset));
406 if (ret) 403 if (ret)
@@ -450,6 +447,18 @@ int ipath_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata)
450 struct ipath_mmap_info *ip = cq->ip; 447 struct ipath_mmap_info *ip = cq->ip;
451 448
452 ipath_update_mmap_info(dev, ip, sz, wc); 449 ipath_update_mmap_info(dev, ip, sz, wc);
450
451 /*
452 * Return the offset to mmap.
453 * See ipath_mmap() for details.
454 */
455 if (udata && udata->outlen >= sizeof(__u64)) {
456 ret = ib_copy_to_udata(udata, &ip->offset,
457 sizeof(ip->offset));
458 if (ret)
459 goto bail;
460 }
461
453 spin_lock_irq(&dev->pending_lock); 462 spin_lock_irq(&dev->pending_lock);
454 if (list_empty(&ip->pending_mmaps)) 463 if (list_empty(&ip->pending_mmaps))
455 list_add(&ip->pending_mmaps, &dev->pending_mmaps); 464 list_add(&ip->pending_mmaps, &dev->pending_mmaps);
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index 6a41fdbc8e57..b997ff88401b 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -835,7 +835,8 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
835 init_attr->qp_type); 835 init_attr->qp_type);
836 if (err) { 836 if (err) {
837 ret = ERR_PTR(err); 837 ret = ERR_PTR(err);
838 goto bail_rwq; 838 vfree(qp->r_rq.wq);
839 goto bail_qp;
839 } 840 }
840 qp->ip = NULL; 841 qp->ip = NULL;
841 ipath_reset_qp(qp); 842 ipath_reset_qp(qp);
@@ -863,7 +864,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
863 sizeof(offset)); 864 sizeof(offset));
864 if (err) { 865 if (err) {
865 ret = ERR_PTR(err); 866 ret = ERR_PTR(err);
866 goto bail_rwq; 867 goto bail_ip;
867 } 868 }
868 } else { 869 } else {
869 u32 s = sizeof(struct ipath_rwq) + 870 u32 s = sizeof(struct ipath_rwq) +
@@ -875,7 +876,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
875 qp->r_rq.wq); 876 qp->r_rq.wq);
876 if (!qp->ip) { 877 if (!qp->ip) {
877 ret = ERR_PTR(-ENOMEM); 878 ret = ERR_PTR(-ENOMEM);
878 goto bail_rwq; 879 goto bail_ip;
879 } 880 }
880 881
881 err = ib_copy_to_udata(udata, &(qp->ip->offset), 882 err = ib_copy_to_udata(udata, &(qp->ip->offset),
@@ -907,9 +908,11 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
907 goto bail; 908 goto bail;
908 909
909bail_ip: 910bail_ip:
910 kfree(qp->ip); 911 if (qp->ip)
911bail_rwq: 912 kref_put(&qp->ip->ref, ipath_release_mmap_info);
912 vfree(qp->r_rq.wq); 913 else
914 vfree(qp->r_rq.wq);
915 ipath_free_qp(&dev->qp_table, qp);
913bail_qp: 916bail_qp:
914 kfree(qp); 917 kfree(qp);
915bail_swq: 918bail_swq:
diff --git a/drivers/infiniband/hw/ipath/ipath_srq.c b/drivers/infiniband/hw/ipath/ipath_srq.c
index 40c36ec19016..2fef36f4b675 100644
--- a/drivers/infiniband/hw/ipath/ipath_srq.c
+++ b/drivers/infiniband/hw/ipath/ipath_srq.c
@@ -59,7 +59,7 @@ int ipath_post_srq_receive(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
59 59
60 if ((unsigned) wr->num_sge > srq->rq.max_sge) { 60 if ((unsigned) wr->num_sge > srq->rq.max_sge) {
61 *bad_wr = wr; 61 *bad_wr = wr;
62 ret = -ENOMEM; 62 ret = -EINVAL;
63 goto bail; 63 goto bail;
64 } 64 }
65 65
@@ -211,11 +211,11 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
211 struct ib_udata *udata) 211 struct ib_udata *udata)
212{ 212{
213 struct ipath_srq *srq = to_isrq(ibsrq); 213 struct ipath_srq *srq = to_isrq(ibsrq);
214 struct ipath_rwq *wq;
214 int ret = 0; 215 int ret = 0;
215 216
216 if (attr_mask & IB_SRQ_MAX_WR) { 217 if (attr_mask & IB_SRQ_MAX_WR) {
217 struct ipath_rwq *owq; 218 struct ipath_rwq *owq;
218 struct ipath_rwq *wq;
219 struct ipath_rwqe *p; 219 struct ipath_rwqe *p;
220 u32 sz, size, n, head, tail; 220 u32 sz, size, n, head, tail;
221 221
@@ -236,27 +236,20 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
236 goto bail; 236 goto bail;
237 } 237 }
238 238
239 /* 239 /* Check that we can write the offset to mmap. */
240 * Return the address of the RWQ as the offset to mmap.
241 * See ipath_mmap() for details.
242 */
243 if (udata && udata->inlen >= sizeof(__u64)) { 240 if (udata && udata->inlen >= sizeof(__u64)) {
244 __u64 offset_addr; 241 __u64 offset_addr;
245 __u64 offset = (__u64) wq; 242 __u64 offset = 0;
246 243
247 ret = ib_copy_from_udata(&offset_addr, udata, 244 ret = ib_copy_from_udata(&offset_addr, udata,
248 sizeof(offset_addr)); 245 sizeof(offset_addr));
249 if (ret) { 246 if (ret)
250 vfree(wq); 247 goto bail_free;
251 goto bail;
252 }
253 udata->outbuf = (void __user *) offset_addr; 248 udata->outbuf = (void __user *) offset_addr;
254 ret = ib_copy_to_udata(udata, &offset, 249 ret = ib_copy_to_udata(udata, &offset,
255 sizeof(offset)); 250 sizeof(offset));
256 if (ret) { 251 if (ret)
257 vfree(wq); 252 goto bail_free;
258 goto bail;
259 }
260 } 253 }
261 254
262 spin_lock_irq(&srq->rq.lock); 255 spin_lock_irq(&srq->rq.lock);
@@ -277,10 +270,8 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
277 else 270 else
278 n -= tail; 271 n -= tail;
279 if (size <= n) { 272 if (size <= n) {
280 spin_unlock_irq(&srq->rq.lock);
281 vfree(wq);
282 ret = -EINVAL; 273 ret = -EINVAL;
283 goto bail; 274 goto bail_unlock;
284 } 275 }
285 n = 0; 276 n = 0;
286 p = wq->wq; 277 p = wq->wq;
@@ -314,6 +305,18 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
314 u32 s = sizeof(struct ipath_rwq) + size * sz; 305 u32 s = sizeof(struct ipath_rwq) + size * sz;
315 306
316 ipath_update_mmap_info(dev, ip, s, wq); 307 ipath_update_mmap_info(dev, ip, s, wq);
308
309 /*
310 * Return the offset to mmap.
311 * See ipath_mmap() for details.
312 */
313 if (udata && udata->inlen >= sizeof(__u64)) {
314 ret = ib_copy_to_udata(udata, &ip->offset,
315 sizeof(ip->offset));
316 if (ret)
317 goto bail;
318 }
319
317 spin_lock_irq(&dev->pending_lock); 320 spin_lock_irq(&dev->pending_lock);
318 if (list_empty(&ip->pending_mmaps)) 321 if (list_empty(&ip->pending_mmaps))
319 list_add(&ip->pending_mmaps, 322 list_add(&ip->pending_mmaps,
@@ -328,7 +331,12 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
328 srq->limit = attr->srq_limit; 331 srq->limit = attr->srq_limit;
329 spin_unlock_irq(&srq->rq.lock); 332 spin_unlock_irq(&srq->rq.lock);
330 } 333 }
334 goto bail;
331 335
336bail_unlock:
337 spin_unlock_irq(&srq->rq.lock);
338bail_free:
339 vfree(wq);
332bail: 340bail:
333 return ret; 341 return ret;
334} 342}
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index 74f77e7c2c1b..c4c998446c7b 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -302,8 +302,10 @@ static int ipath_post_one_send(struct ipath_qp *qp, struct ib_send_wr *wr)
302 next = qp->s_head + 1; 302 next = qp->s_head + 1;
303 if (next >= qp->s_size) 303 if (next >= qp->s_size)
304 next = 0; 304 next = 0;
305 if (next == qp->s_last) 305 if (next == qp->s_last) {
306 goto bail_inval; 306 ret = -ENOMEM;
307 goto bail;
308 }
307 309
308 wqe = get_swqe_ptr(qp, qp->s_head); 310 wqe = get_swqe_ptr(qp, qp->s_head);
309 wqe->wr = *wr; 311 wqe->wr = *wr;
@@ -404,7 +406,7 @@ static int ipath_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
404 406
405 if ((unsigned) wr->num_sge > qp->r_rq.max_sge) { 407 if ((unsigned) wr->num_sge > qp->r_rq.max_sge) {
406 *bad_wr = wr; 408 *bad_wr = wr;
407 ret = -ENOMEM; 409 ret = -EINVAL;
408 goto bail; 410 goto bail;
409 } 411 }
410 412
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index a03a65ebcf0c..c9f6077b615e 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -460,6 +460,9 @@ static struct ipoib_path *path_rec_create(struct net_device *dev, void *gid)
460 struct ipoib_dev_priv *priv = netdev_priv(dev); 460 struct ipoib_dev_priv *priv = netdev_priv(dev);
461 struct ipoib_path *path; 461 struct ipoib_path *path;
462 462
463 if (!priv->broadcast)
464 return NULL;
465
463 path = kzalloc(sizeof *path, GFP_ATOMIC); 466 path = kzalloc(sizeof *path, GFP_ATOMIC);
464 if (!path) 467 if (!path)
465 return NULL; 468 return NULL;
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
index d68798061795..4a17743a639f 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -310,13 +310,15 @@ static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data,
310 if (i + 1 < data->dma_nents) { 310 if (i + 1 < data->dma_nents) {
311 next_addr = ib_sg_dma_address(ibdev, sg_next(sg)); 311 next_addr = ib_sg_dma_address(ibdev, sg_next(sg));
312 /* are i, i+1 fragments of the same page? */ 312 /* are i, i+1 fragments of the same page? */
313 if (end_addr == next_addr) 313 if (end_addr == next_addr) {
314 cnt++;
314 continue; 315 continue;
315 else if (!IS_4K_ALIGNED(end_addr)) { 316 } else if (!IS_4K_ALIGNED(end_addr)) {
316 ret_len = cnt + 1; 317 ret_len = cnt + 1;
317 break; 318 break;
318 } 319 }
319 } 320 }
321 cnt++;
320 } 322 }
321 if (i == data->dma_nents) 323 if (i == data->dma_nents)
322 ret_len = cnt; /* loop ended */ 324 ret_len = cnt; /* loop ended */
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 2316a018fae6..dfa6592c10f6 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -286,7 +286,7 @@ config KEYBOARD_MAPLE
286 286
287config KEYBOARD_BFIN 287config KEYBOARD_BFIN
288 tristate "Blackfin BF54x keypad support" 288 tristate "Blackfin BF54x keypad support"
289 depends on BF54x 289 depends on (BF54x && !BF544)
290 help 290 help
291 Say Y here if you want to use the BF54x keypad. 291 Say Y here if you want to use the BF54x keypad.
292 292
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 3eddf52a0bba..6a9ca4bdcb74 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -75,16 +75,32 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
75 75
76 for (i = 0; i < pdata->nbuttons; i++) { 76 for (i = 0; i < pdata->nbuttons; i++) {
77 struct gpio_keys_button *button = &pdata->buttons[i]; 77 struct gpio_keys_button *button = &pdata->buttons[i];
78 int irq = gpio_to_irq(button->gpio); 78 int irq;
79 unsigned int type = button->type ?: EV_KEY; 79 unsigned int type = button->type ?: EV_KEY;
80 80
81 error = gpio_request(button->gpio, button->desc ?: "gpio_keys");
82 if (error < 0) {
83 pr_err("gpio-keys: failed to request GPIO %d,"
84 " error %d\n", button->gpio, error);
85 goto fail;
86 }
87
88 error = gpio_direction_input(button->gpio);
89 if (error < 0) {
90 pr_err("gpio-keys: failed to configure input"
91 " direction for GPIO %d, error %d\n",
92 button->gpio, error);
93 gpio_free(button->gpio);
94 goto fail;
95 }
96
97 irq = gpio_to_irq(button->gpio);
81 if (irq < 0) { 98 if (irq < 0) {
82 error = irq; 99 error = irq;
83 printk(KERN_ERR 100 pr_err("gpio-keys: Unable to get irq number"
84 "gpio-keys: " 101 " for GPIO %d, error %d\n",
85 "Unable to get irq number for GPIO %d,"
86 "error %d\n",
87 button->gpio, error); 102 button->gpio, error);
103 gpio_free(button->gpio);
88 goto fail; 104 goto fail;
89 } 105 }
90 106
@@ -94,9 +110,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
94 button->desc ? button->desc : "gpio_keys", 110 button->desc ? button->desc : "gpio_keys",
95 pdev); 111 pdev);
96 if (error) { 112 if (error) {
97 printk(KERN_ERR 113 pr_err("gpio-keys: Unable to claim irq %d; error %d\n",
98 "gpio-keys: Unable to claim irq %d; error %d\n",
99 irq, error); 114 irq, error);
115 gpio_free(button->gpio);
100 goto fail; 116 goto fail;
101 } 117 }
102 118
@@ -108,8 +124,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
108 124
109 error = input_register_device(input); 125 error = input_register_device(input);
110 if (error) { 126 if (error) {
111 printk(KERN_ERR 127 pr_err("gpio-keys: Unable to register input device, "
112 "gpio-keys: Unable to register input device, "
113 "error: %d\n", error); 128 "error: %d\n", error);
114 goto fail; 129 goto fail;
115 } 130 }
@@ -119,8 +134,10 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
119 return 0; 134 return 0;
120 135
121 fail: 136 fail:
122 while (--i >= 0) 137 while (--i >= 0) {
123 free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); 138 free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev);
139 gpio_free(pdata->buttons[i].gpio);
140 }
124 141
125 platform_set_drvdata(pdev, NULL); 142 platform_set_drvdata(pdev, NULL);
126 input_free_device(input); 143 input_free_device(input);
@@ -139,6 +156,7 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
139 for (i = 0; i < pdata->nbuttons; i++) { 156 for (i = 0; i < pdata->nbuttons; i++) {
140 int irq = gpio_to_irq(pdata->buttons[i].gpio); 157 int irq = gpio_to_irq(pdata->buttons[i].gpio);
141 free_irq(irq, pdev); 158 free_irq(irq, pdev);
159 gpio_free(pdata->buttons[i].gpio);
142 } 160 }
143 161
144 input_unregister_device(input); 162 input_unregister_device(input);
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index 5ce632ca6815..b88569e21d60 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -21,7 +21,7 @@ if SERIO
21config SERIO_I8042 21config SERIO_I8042
22 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86 22 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86
23 default y 23 default y
24 depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && !M68K && !BFIN 24 depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && !M68K && !BLACKFIN
25 ---help--- 25 ---help---
26 i8042 is the chip over which the standard AT keyboard and PS/2 26 i8042 is the chip over which the standard AT keyboard and PS/2
27 mouse are connected to the computer. If you use these devices, 27 mouse are connected to the computer. If you use these devices,
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index f8fe42148093..c5e68dcd88ac 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -110,6 +110,14 @@ static struct dmi_system_id __initdata i8042_dmi_noloop_table[] = {
110 DMI_MATCH(DMI_PRODUCT_VERSION, "5a"), 110 DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
111 }, 111 },
112 }, 112 },
113 {
114 .ident = "Microsoft Virtual Machine",
115 .matches = {
116 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
117 DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
118 DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
119 },
120 },
113 { } 121 { }
114}; 122};
115 123
diff --git a/drivers/isdn/hisax/hfcscard.c b/drivers/isdn/hisax/hfcscard.c
index 57670dc5034d..909d6709ec16 100644
--- a/drivers/isdn/hisax/hfcscard.c
+++ b/drivers/isdn/hisax/hfcscard.c
@@ -118,8 +118,7 @@ hfcs_card_msg(struct IsdnCardState *cs, int mt, void *arg)
118 return(0); 118 return(0);
119 case CARD_INIT: 119 case CARD_INIT:
120 delay = (75*HZ)/100 +1; 120 delay = (75*HZ)/100 +1;
121 cs->hw.hfcD.timer.expires = jiffies + delay; 121 mod_timer(&cs->hw.hfcD.timer, jiffies + delay);
122 add_timer(&cs->hw.hfcD.timer);
123 spin_lock_irqsave(&cs->lock, flags); 122 spin_lock_irqsave(&cs->lock, flags);
124 reset_hfcs(cs); 123 reset_hfcs(cs);
125 init2bds0(cs); 124 init2bds0(cs);
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index c6df2925ebd0..d6952959d72a 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1515,6 +1515,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
1515 if (copy_from_user(&iocts, argp, 1515 if (copy_from_user(&iocts, argp,
1516 sizeof(isdn_ioctl_struct))) 1516 sizeof(isdn_ioctl_struct)))
1517 return -EFAULT; 1517 return -EFAULT;
1518 iocts.drvid[sizeof(iocts.drvid)-1] = 0;
1518 if (strlen(iocts.drvid)) { 1519 if (strlen(iocts.drvid)) {
1519 if ((p = strchr(iocts.drvid, ','))) 1520 if ((p = strchr(iocts.drvid, ',')))
1520 *p = 0; 1521 *p = 0;
@@ -1599,6 +1600,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
1599 if (copy_from_user(&iocts, argp, 1600 if (copy_from_user(&iocts, argp,
1600 sizeof(isdn_ioctl_struct))) 1601 sizeof(isdn_ioctl_struct)))
1601 return -EFAULT; 1602 return -EFAULT;
1603 iocts.drvid[sizeof(iocts.drvid)-1] = 0;
1602 if (strlen(iocts.drvid)) { 1604 if (strlen(iocts.drvid)) {
1603 drvidx = -1; 1605 drvidx = -1;
1604 for (i = 0; i < ISDN_MAX_DRIVERS; i++) 1606 for (i = 0; i < ISDN_MAX_DRIVERS; i++)
@@ -1643,7 +1645,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
1643 } else { 1645 } else {
1644 p = (char __user *) iocts.arg; 1646 p = (char __user *) iocts.arg;
1645 for (i = 0; i < 10; i++) { 1647 for (i = 0; i < 10; i++) {
1646 sprintf(bname, "%s%s", 1648 snprintf(bname, sizeof(bname), "%s%s",
1647 strlen(dev->drv[drvidx]->msn2eaz[i]) ? 1649 strlen(dev->drv[drvidx]->msn2eaz[i]) ?
1648 dev->drv[drvidx]->msn2eaz[i] : "_", 1650 dev->drv[drvidx]->msn2eaz[i] : "_",
1649 (i < 9) ? "," : "\0"); 1651 (i < 9) ? "," : "\0");
@@ -1673,6 +1675,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
1673 char *p; 1675 char *p;
1674 if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct))) 1676 if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct)))
1675 return -EFAULT; 1677 return -EFAULT;
1678 iocts.drvid[sizeof(iocts.drvid)-1] = 0;
1676 if (strlen(iocts.drvid)) { 1679 if (strlen(iocts.drvid)) {
1677 if ((p = strchr(iocts.drvid, ','))) 1680 if ((p = strchr(iocts.drvid, ',')))
1678 *p = 0; 1681 *p = 0;
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index b39d1f5b378e..ced83c202cac 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -2104,7 +2104,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2104 u_long flags; 2104 u_long flags;
2105 isdn_net_dev *p; 2105 isdn_net_dev *p;
2106 isdn_net_phone *n; 2106 isdn_net_phone *n;
2107 char nr[32]; 2107 char nr[ISDN_MSNLEN];
2108 char *my_eaz; 2108 char *my_eaz;
2109 2109
2110 /* Search name in netdev-chain */ 2110 /* Search name in netdev-chain */
@@ -2113,7 +2113,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2113 nr[1] = '\0'; 2113 nr[1] = '\0';
2114 printk(KERN_INFO "isdn_net: Incoming call without OAD, assuming '0'\n"); 2114 printk(KERN_INFO "isdn_net: Incoming call without OAD, assuming '0'\n");
2115 } else 2115 } else
2116 strcpy(nr, setup->phone); 2116 strlcpy(nr, setup->phone, ISDN_MSNLEN);
2117 si1 = (int) setup->si1; 2117 si1 = (int) setup->si1;
2118 si2 = (int) setup->si2; 2118 si2 = (int) setup->si2;
2119 if (!setup->eazmsn[0]) { 2119 if (!setup->eazmsn[0]) {
@@ -2789,7 +2789,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
2789 chidx = -1; 2789 chidx = -1;
2790 } 2790 }
2791 } 2791 }
2792 strcpy(lp->msn, cfg->eaz); 2792 strlcpy(lp->msn, cfg->eaz, sizeof(lp->msn));
2793 lp->pre_device = drvidx; 2793 lp->pre_device = drvidx;
2794 lp->pre_channel = chidx; 2794 lp->pre_channel = chidx;
2795 lp->onhtime = cfg->onhtime; 2795 lp->onhtime = cfg->onhtime;
@@ -2936,7 +2936,7 @@ isdn_net_addphone(isdn_net_ioctl_phone * phone)
2936 if (p) { 2936 if (p) {
2937 if (!(n = kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) 2937 if (!(n = kmalloc(sizeof(isdn_net_phone), GFP_KERNEL)))
2938 return -ENOMEM; 2938 return -ENOMEM;
2939 strcpy(n->num, phone->phone); 2939 strlcpy(n->num, phone->phone, sizeof(n->num));
2940 n->next = p->local->phone[phone->outgoing & 1]; 2940 n->next = p->local->phone[phone->outgoing & 1];
2941 p->local->phone[phone->outgoing & 1] = n; 2941 p->local->phone[phone->outgoing & 1] = n;
2942 return 0; 2942 return 0;
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 07ae280e8fe5..47c10b8f89b3 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1188,8 +1188,7 @@ int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address)
1188 1188
1189int emulate_clts(struct kvm_vcpu *vcpu) 1189int emulate_clts(struct kvm_vcpu *vcpu)
1190{ 1190{
1191 vcpu->cr0 &= ~X86_CR0_TS; 1191 kvm_x86_ops->set_cr0(vcpu, vcpu->cr0 & ~X86_CR0_TS);
1192 kvm_x86_ops->set_cr0(vcpu, vcpu->cr0);
1193 return X86EMUL_CONTINUE; 1192 return X86EMUL_CONTINUE;
1194} 1193}
1195 1194
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 7a6eead63a6b..4e04e49a2f1c 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -663,6 +663,7 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu)
663 wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]); 663 wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]);
664 664
665 rdtscll(vcpu->host_tsc); 665 rdtscll(vcpu->host_tsc);
666 kvm_put_guest_fpu(vcpu);
666} 667}
667 668
668static void svm_vcpu_decache(struct kvm_vcpu *vcpu) 669static void svm_vcpu_decache(struct kvm_vcpu *vcpu)
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index 33b181451557..bd46de6bf891 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -448,8 +448,7 @@ struct operand {
448 448
449#define JMP_REL(rel) \ 449#define JMP_REL(rel) \
450 do { \ 450 do { \
451 _eip += (int)(rel); \ 451 register_address_increment(_eip, rel); \
452 _eip = ((op_bytes == 2) ? (uint16_t)_eip : (uint32_t)_eip); \
453 } while (0) 452 } while (0)
454 453
455/* 454/*
@@ -1147,7 +1146,7 @@ done_prefixes:
1147 } 1146 }
1148 register_address_increment(_regs[VCPU_REGS_RSP], 1147 register_address_increment(_regs[VCPU_REGS_RSP],
1149 -dst.bytes); 1148 -dst.bytes);
1150 if ((rc = ops->write_std( 1149 if ((rc = ops->write_emulated(
1151 register_address(ctxt->ss_base, 1150 register_address(ctxt->ss_base,
1152 _regs[VCPU_REGS_RSP]), 1151 _regs[VCPU_REGS_RSP]),
1153 &dst.val, dst.bytes, ctxt->vcpu)) != 0) 1152 &dst.val, dst.bytes, ctxt->vcpu)) != 0)
@@ -1359,6 +1358,7 @@ special_insn:
1359 } 1358 }
1360 src.val = (unsigned long) _eip; 1359 src.val = (unsigned long) _eip;
1361 JMP_REL(rel); 1360 JMP_REL(rel);
1361 op_bytes = ad_bytes;
1362 goto push; 1362 goto push;
1363 } 1363 }
1364 case 0xe9: /* jmp rel */ 1364 case 0xe9: /* jmp rel */
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 66f38722253a..e2eec38c83c2 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -247,6 +247,8 @@ static void lg_del_vq(struct virtqueue *vq)
247{ 247{
248 struct lguest_vq_info *lvq = vq->priv; 248 struct lguest_vq_info *lvq = vq->priv;
249 249
250 /* Release the interrupt */
251 free_irq(lvq->config.irq, vq);
250 /* Tell virtio_ring.c to free the virtqueue. */ 252 /* Tell virtio_ring.c to free the virtqueue. */
251 vring_del_virtqueue(vq); 253 vring_del_virtqueue(vq);
252 /* Unmap the pages containing the ring. */ 254 /* Unmap the pages containing the ring. */
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 8135e4c3bf47..afd82966f9a0 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -156,7 +156,7 @@ static void sm501_dump_clk(struct sm501_devdata *sm)
156 156
157 dev_dbg(sm->dev, "PM0[%c]: " 157 dev_dbg(sm->dev, "PM0[%c]: "
158 "P2 %ld.%ld MHz (%ld), V2 %ld.%ld (%ld), " 158 "P2 %ld.%ld MHz (%ld), V2 %ld.%ld (%ld), "
159x "M %ld.%ld (%ld), MX1 %ld.%ld (%ld)\n", 159 "M %ld.%ld (%ld), MX1 %ld.%ld (%ld)\n",
160 (pmc & 3 ) == 0 ? '*' : '-', 160 (pmc & 3 ) == 0 ? '*' : '-',
161 fmt_freq(decode_div(pll2, pm0, 24, 1<<29, 31, px_div)), 161 fmt_freq(decode_div(pll2, pm0, 24, 1<<29, 31, px_div)),
162 fmt_freq(decode_div(pll2, pm0, 16, 1<<20, 15, misc_div)), 162 fmt_freq(decode_div(pll2, pm0, 16, 1<<20, 15, misc_div)),
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index bb13858f60a1..b0f68031b49d 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -338,7 +338,7 @@ static void sony_laptop_report_input_event(u8 event)
338 dprintk("unknown input event %.2x\n", event); 338 dprintk("unknown input event %.2x\n", event);
339} 339}
340 340
341static int sony_laptop_setup_input(void) 341static int sony_laptop_setup_input(struct acpi_device *acpi_device)
342{ 342{
343 struct input_dev *jog_dev; 343 struct input_dev *jog_dev;
344 struct input_dev *key_dev; 344 struct input_dev *key_dev;
@@ -379,6 +379,7 @@ static int sony_laptop_setup_input(void)
379 key_dev->name = "Sony Vaio Keys"; 379 key_dev->name = "Sony Vaio Keys";
380 key_dev->id.bustype = BUS_ISA; 380 key_dev->id.bustype = BUS_ISA;
381 key_dev->id.vendor = PCI_VENDOR_ID_SONY; 381 key_dev->id.vendor = PCI_VENDOR_ID_SONY;
382 key_dev->dev.parent = &acpi_device->dev;
382 383
383 /* Initialize the Input Drivers: special keys */ 384 /* Initialize the Input Drivers: special keys */
384 set_bit(EV_KEY, key_dev->evbit); 385 set_bit(EV_KEY, key_dev->evbit);
@@ -410,6 +411,7 @@ static int sony_laptop_setup_input(void)
410 jog_dev->name = "Sony Vaio Jogdial"; 411 jog_dev->name = "Sony Vaio Jogdial";
411 jog_dev->id.bustype = BUS_ISA; 412 jog_dev->id.bustype = BUS_ISA;
412 jog_dev->id.vendor = PCI_VENDOR_ID_SONY; 413 jog_dev->id.vendor = PCI_VENDOR_ID_SONY;
414 key_dev->dev.parent = &acpi_device->dev;
413 415
414 jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 416 jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
415 jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE); 417 jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE);
@@ -1006,7 +1008,7 @@ static int sony_nc_add(struct acpi_device *device)
1006 } 1008 }
1007 1009
1008 /* setup input devices and helper fifo */ 1010 /* setup input devices and helper fifo */
1009 result = sony_laptop_setup_input(); 1011 result = sony_laptop_setup_input(device);
1010 if (result) { 1012 if (result) {
1011 printk(KERN_ERR DRV_PFX 1013 printk(KERN_ERR DRV_PFX
1012 "Unabe to create input devices.\n"); 1014 "Unabe to create input devices.\n");
@@ -1034,7 +1036,7 @@ static int sony_nc_add(struct acpi_device *device)
1034 sony_backlight_device->props.brightness = 1036 sony_backlight_device->props.brightness =
1035 sony_backlight_get_brightness 1037 sony_backlight_get_brightness
1036 (sony_backlight_device); 1038 (sony_backlight_device);
1037 sony_backlight_device->props.max_brightness = 1039 sony_backlight_device->props.max_brightness =
1038 SONY_MAX_BRIGHTNESS - 1; 1040 SONY_MAX_BRIGHTNESS - 1;
1039 } 1041 }
1040 1042
@@ -2453,7 +2455,7 @@ static int sony_pic_add(struct acpi_device *device)
2453 } 2455 }
2454 2456
2455 /* setup input devices and helper fifo */ 2457 /* setup input devices and helper fifo */
2456 result = sony_laptop_setup_input(); 2458 result = sony_laptop_setup_input(device);
2457 if (result) { 2459 if (result) {
2458 printk(KERN_ERR DRV_PFX 2460 printk(KERN_ERR DRV_PFX
2459 "Unabe to create input devices.\n"); 2461 "Unabe to create input devices.\n");
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index e953276664a0..ab23a3221585 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -21,7 +21,7 @@
21 * 02110-1301, USA. 21 * 02110-1301, USA.
22 */ 22 */
23 23
24#define IBM_VERSION "0.16" 24#define IBM_VERSION "0.17"
25#define TPACPI_SYSFS_VERSION 0x020000 25#define TPACPI_SYSFS_VERSION 0x020000
26 26
27/* 27/*
@@ -964,15 +964,15 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
964 KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */ 964 KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */
965 KEY_UNKNOWN, /* 0x0D: FN+INSERT */ 965 KEY_UNKNOWN, /* 0x0D: FN+INSERT */
966 KEY_UNKNOWN, /* 0x0E: FN+DELETE */ 966 KEY_UNKNOWN, /* 0x0E: FN+DELETE */
967 KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */ 967 KEY_RESERVED, /* 0x0F: FN+HOME (brightness up) */
968 /* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */ 968 /* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */
969 KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */ 969 KEY_RESERVED, /* 0x10: FN+END (brightness down) */
970 KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ 970 KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */
971 KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ 971 KEY_UNKNOWN, /* 0x12: FN+PGDOWN */
972 KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ 972 KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */
973 KEY_VOLUMEUP, /* 0x14: VOLUME UP */ 973 KEY_RESERVED, /* 0x14: VOLUME UP */
974 KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ 974 KEY_RESERVED, /* 0x15: VOLUME DOWN */
975 KEY_MUTE, /* 0x16: MUTE */ 975 KEY_RESERVED, /* 0x16: MUTE */
976 KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ 976 KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */
977 /* (assignments unknown, please report if found) */ 977 /* (assignments unknown, please report if found) */
978 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, 978 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
@@ -993,9 +993,9 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
993 KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ 993 KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */
994 KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ 994 KEY_UNKNOWN, /* 0x12: FN+PGDOWN */
995 KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ 995 KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */
996 KEY_VOLUMEUP, /* 0x14: VOLUME UP */ 996 KEY_RESERVED, /* 0x14: VOLUME UP */
997 KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ 997 KEY_RESERVED, /* 0x15: VOLUME DOWN */
998 KEY_MUTE, /* 0x16: MUTE */ 998 KEY_RESERVED, /* 0x16: MUTE */
999 KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ 999 KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */
1000 /* (assignments unknown, please report if found) */ 1000 /* (assignments unknown, please report if found) */
1001 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, 1001 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
@@ -1342,9 +1342,8 @@ static int hotkey_read(char *p)
1342 return len; 1342 return len;
1343 } 1343 }
1344 1344
1345 res = mutex_lock_interruptible(&hotkey_mutex); 1345 if (mutex_lock_interruptible(&hotkey_mutex))
1346 if (res < 0) 1346 return -ERESTARTSYS;
1347 return res;
1348 res = hotkey_get(&status, &mask); 1347 res = hotkey_get(&status, &mask);
1349 mutex_unlock(&hotkey_mutex); 1348 mutex_unlock(&hotkey_mutex);
1350 if (res) 1349 if (res)
@@ -1373,9 +1372,8 @@ static int hotkey_write(char *buf)
1373 if (!tp_features.hotkey) 1372 if (!tp_features.hotkey)
1374 return -ENODEV; 1373 return -ENODEV;
1375 1374
1376 res = mutex_lock_interruptible(&hotkey_mutex); 1375 if (mutex_lock_interruptible(&hotkey_mutex))
1377 if (res < 0) 1376 return -ERESTARTSYS;
1378 return res;
1379 1377
1380 res = hotkey_get(&status, &mask); 1378 res = hotkey_get(&status, &mask);
1381 if (res) 1379 if (res)
@@ -3114,6 +3112,99 @@ static struct backlight_ops ibm_backlight_data = {
3114 3112
3115static struct mutex brightness_mutex; 3113static struct mutex brightness_mutex;
3116 3114
3115static int __init tpacpi_query_bcll_levels(acpi_handle handle)
3116{
3117 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
3118 union acpi_object *obj;
3119 int rc;
3120
3121 if (ACPI_SUCCESS(acpi_evaluate_object(handle, NULL, NULL, &buffer))) {
3122 obj = (union acpi_object *)buffer.pointer;
3123 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
3124 printk(IBM_ERR "Unknown BCLL data, "
3125 "please report this to %s\n", IBM_MAIL);
3126 rc = 0;
3127 } else {
3128 rc = obj->package.count;
3129 }
3130 } else {
3131 return 0;
3132 }
3133
3134 kfree(buffer.pointer);
3135 return rc;
3136}
3137
3138static acpi_status __init brightness_find_bcll(acpi_handle handle, u32 lvl,
3139 void *context, void **rv)
3140{
3141 char name[ACPI_PATH_SEGMENT_LENGTH];
3142 struct acpi_buffer buffer = { sizeof(name), &name };
3143
3144 if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) &&
3145 !strncmp("BCLL", name, sizeof(name) - 1)) {
3146 if (tpacpi_query_bcll_levels(handle) == 16) {
3147 *rv = handle;
3148 return AE_CTRL_TERMINATE;
3149 } else {
3150 return AE_OK;
3151 }
3152 } else {
3153 return AE_OK;
3154 }
3155}
3156
3157static int __init brightness_check_levels(void)
3158{
3159 int status;
3160 void *found_node = NULL;
3161
3162 if (!vid_handle) {
3163 IBM_ACPIHANDLE_INIT(vid);
3164 }
3165 if (!vid_handle)
3166 return 0;
3167
3168 /* Search for a BCLL package with 16 levels */
3169 status = acpi_walk_namespace(ACPI_TYPE_PACKAGE, vid_handle, 3,
3170 brightness_find_bcll, NULL, &found_node);
3171
3172 return (ACPI_SUCCESS(status) && found_node != NULL);
3173}
3174
3175static acpi_status __init brightness_find_bcl(acpi_handle handle, u32 lvl,
3176 void *context, void **rv)
3177{
3178 char name[ACPI_PATH_SEGMENT_LENGTH];
3179 struct acpi_buffer buffer = { sizeof(name), &name };
3180
3181 if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) &&
3182 !strncmp("_BCL", name, sizeof(name) - 1)) {
3183 *rv = handle;
3184 return AE_CTRL_TERMINATE;
3185 } else {
3186 return AE_OK;
3187 }
3188}
3189
3190static int __init brightness_check_std_acpi_support(void)
3191{
3192 int status;
3193 void *found_node = NULL;
3194
3195 if (!vid_handle) {
3196 IBM_ACPIHANDLE_INIT(vid);
3197 }
3198 if (!vid_handle)
3199 return 0;
3200
3201 /* Search for a _BCL method, but don't execute it */
3202 status = acpi_walk_namespace(ACPI_TYPE_METHOD, vid_handle, 3,
3203 brightness_find_bcl, NULL, &found_node);
3204
3205 return (ACPI_SUCCESS(status) && found_node != NULL);
3206}
3207
3117static int __init brightness_init(struct ibm_init_struct *iibm) 3208static int __init brightness_init(struct ibm_init_struct *iibm)
3118{ 3209{
3119 int b; 3210 int b;
@@ -3122,6 +3213,18 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
3122 3213
3123 mutex_init(&brightness_mutex); 3214 mutex_init(&brightness_mutex);
3124 3215
3216 if (!brightness_enable) {
3217 dbg_printk(TPACPI_DBG_INIT,
3218 "brightness support disabled by module parameter\n");
3219 return 1;
3220 } else if (brightness_enable > 1) {
3221 if (brightness_check_std_acpi_support()) {
3222 printk(IBM_NOTICE
3223 "standard ACPI backlight interface available, not loading native one...\n");
3224 return 1;
3225 }
3226 }
3227
3125 if (!brightness_mode) { 3228 if (!brightness_mode) {
3126 if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO) 3229 if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO)
3127 brightness_mode = 2; 3230 brightness_mode = 2;
@@ -3135,10 +3238,17 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
3135 if (brightness_mode > 3) 3238 if (brightness_mode > 3)
3136 return -EINVAL; 3239 return -EINVAL;
3137 3240
3241 tp_features.bright_16levels =
3242 thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO &&
3243 brightness_check_levels();
3244
3138 b = brightness_get(NULL); 3245 b = brightness_get(NULL);
3139 if (b < 0) 3246 if (b < 0)
3140 return 1; 3247 return 1;
3141 3248
3249 if (tp_features.bright_16levels)
3250 printk(IBM_INFO "detected a 16-level brightness capable ThinkPad\n");
3251
3142 ibm_backlight_device = backlight_device_register( 3252 ibm_backlight_device = backlight_device_register(
3143 TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL, 3253 TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL,
3144 &ibm_backlight_data); 3254 &ibm_backlight_data);
@@ -3148,7 +3258,8 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
3148 } 3258 }
3149 vdbg_printk(TPACPI_DBG_INIT, "brightness is supported\n"); 3259 vdbg_printk(TPACPI_DBG_INIT, "brightness is supported\n");
3150 3260
3151 ibm_backlight_device->props.max_brightness = 7; 3261 ibm_backlight_device->props.max_brightness =
3262 (tp_features.bright_16levels)? 15 : 7;
3152 ibm_backlight_device->props.brightness = b; 3263 ibm_backlight_device->props.brightness = b;
3153 backlight_update_status(ibm_backlight_device); 3264 backlight_update_status(ibm_backlight_device);
3154 3265
@@ -3167,6 +3278,8 @@ static void brightness_exit(void)
3167 3278
3168static int brightness_update_status(struct backlight_device *bd) 3279static int brightness_update_status(struct backlight_device *bd)
3169{ 3280{
3281 /* it is the backlight class's job (caller) to handle
3282 * EINTR and other errors properly */
3170 return brightness_set( 3283 return brightness_set(
3171 (bd->props.fb_blank == FB_BLANK_UNBLANK && 3284 (bd->props.fb_blank == FB_BLANK_UNBLANK &&
3172 bd->props.power == FB_BLANK_UNBLANK) ? 3285 bd->props.power == FB_BLANK_UNBLANK) ?
@@ -3184,13 +3297,14 @@ static int brightness_get(struct backlight_device *bd)
3184 if (brightness_mode & 1) { 3297 if (brightness_mode & 1) {
3185 if (!acpi_ec_read(brightness_offset, &lec)) 3298 if (!acpi_ec_read(brightness_offset, &lec))
3186 return -EIO; 3299 return -EIO;
3187 lec &= 7; 3300 lec &= (tp_features.bright_16levels)? 0x0f : 0x07;
3188 level = lec; 3301 level = lec;
3189 }; 3302 };
3190 if (brightness_mode & 2) { 3303 if (brightness_mode & 2) {
3191 lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS) 3304 lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS)
3192 & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) 3305 & TP_NVRAM_MASK_LEVEL_BRIGHTNESS)
3193 >> TP_NVRAM_POS_LEVEL_BRIGHTNESS; 3306 >> TP_NVRAM_POS_LEVEL_BRIGHTNESS;
3307 lcmos &= (tp_features.bright_16levels)? 0x0f : 0x07;
3194 level = lcmos; 3308 level = lcmos;
3195 } 3309 }
3196 3310
@@ -3206,12 +3320,13 @@ static int brightness_get(struct backlight_device *bd)
3206 return level; 3320 return level;
3207} 3321}
3208 3322
3323/* May return EINTR which can always be mapped to ERESTARTSYS */
3209static int brightness_set(int value) 3324static int brightness_set(int value)
3210{ 3325{
3211 int cmos_cmd, inc, i, res; 3326 int cmos_cmd, inc, i, res;
3212 int current_value; 3327 int current_value;
3213 3328
3214 if (value > 7) 3329 if (value > ((tp_features.bright_16levels)? 15 : 7))
3215 return -EINVAL; 3330 return -EINVAL;
3216 3331
3217 res = mutex_lock_interruptible(&brightness_mutex); 3332 res = mutex_lock_interruptible(&brightness_mutex);
@@ -3227,7 +3342,7 @@ static int brightness_set(int value)
3227 cmos_cmd = value > current_value ? 3342 cmos_cmd = value > current_value ?
3228 TP_CMOS_BRIGHTNESS_UP : 3343 TP_CMOS_BRIGHTNESS_UP :
3229 TP_CMOS_BRIGHTNESS_DOWN; 3344 TP_CMOS_BRIGHTNESS_DOWN;
3230 inc = value > current_value ? 1 : -1; 3345 inc = (value > current_value)? 1 : -1;
3231 3346
3232 res = 0; 3347 res = 0;
3233 for (i = current_value; i != value; i += inc) { 3348 for (i = current_value; i != value; i += inc) {
@@ -3256,10 +3371,11 @@ static int brightness_read(char *p)
3256 if ((level = brightness_get(NULL)) < 0) { 3371 if ((level = brightness_get(NULL)) < 0) {
3257 len += sprintf(p + len, "level:\t\tunreadable\n"); 3372 len += sprintf(p + len, "level:\t\tunreadable\n");
3258 } else { 3373 } else {
3259 len += sprintf(p + len, "level:\t\t%d\n", level & 0x7); 3374 len += sprintf(p + len, "level:\t\t%d\n", level);
3260 len += sprintf(p + len, "commands:\tup, down\n"); 3375 len += sprintf(p + len, "commands:\tup, down\n");
3261 len += sprintf(p + len, "commands:\tlevel <level>" 3376 len += sprintf(p + len, "commands:\tlevel <level>"
3262 " (<level> is 0-7)\n"); 3377 " (<level> is 0-%d)\n",
3378 (tp_features.bright_16levels) ? 15 : 7);
3263 } 3379 }
3264 3380
3265 return len; 3381 return len;
@@ -3268,28 +3384,34 @@ static int brightness_read(char *p)
3268static int brightness_write(char *buf) 3384static int brightness_write(char *buf)
3269{ 3385{
3270 int level; 3386 int level;
3271 int new_level; 3387 int rc;
3272 char *cmd; 3388 char *cmd;
3389 int max_level = (tp_features.bright_16levels) ? 15 : 7;
3273 3390
3274 while ((cmd = next_cmd(&buf))) { 3391 level = brightness_get(NULL);
3275 if ((level = brightness_get(NULL)) < 0) 3392 if (level < 0)
3276 return level; 3393 return level;
3277 level &= 7;
3278 3394
3395 while ((cmd = next_cmd(&buf))) {
3279 if (strlencmp(cmd, "up") == 0) { 3396 if (strlencmp(cmd, "up") == 0) {
3280 new_level = level == 7 ? 7 : level + 1; 3397 if (level < max_level)
3398 level++;
3281 } else if (strlencmp(cmd, "down") == 0) { 3399 } else if (strlencmp(cmd, "down") == 0) {
3282 new_level = level == 0 ? 0 : level - 1; 3400 if (level > 0)
3283 } else if (sscanf(cmd, "level %d", &new_level) == 1 && 3401 level--;
3284 new_level >= 0 && new_level <= 7) { 3402 } else if (sscanf(cmd, "level %d", &level) == 1 &&
3285 /* new_level set */ 3403 level >= 0 && level <= max_level) {
3404 /* new level set */
3286 } else 3405 } else
3287 return -EINVAL; 3406 return -EINVAL;
3288
3289 brightness_set(new_level);
3290 } 3407 }
3291 3408
3292 return 0; 3409 /*
3410 * Now we know what the final level should be, so we try to set it.
3411 * Doing it this way makes the syscall restartable in case of EINTR
3412 */
3413 rc = brightness_set(level);
3414 return (rc == -EINTR)? ERESTARTSYS : rc;
3293} 3415}
3294 3416
3295static struct ibm_struct brightness_driver_data = { 3417static struct ibm_struct brightness_driver_data = {
@@ -3652,9 +3774,8 @@ static ssize_t fan_pwm1_store(struct device *dev,
3652 /* scale down from 0-255 to 0-7 */ 3774 /* scale down from 0-255 to 0-7 */
3653 newlevel = (s >> 5) & 0x07; 3775 newlevel = (s >> 5) & 0x07;
3654 3776
3655 rc = mutex_lock_interruptible(&fan_mutex); 3777 if (mutex_lock_interruptible(&fan_mutex))
3656 if (rc < 0) 3778 return -ERESTARTSYS;
3657 return rc;
3658 3779
3659 rc = fan_get_status(&status); 3780 rc = fan_get_status(&status);
3660 if (!rc && (status & 3781 if (!rc && (status &
@@ -3904,9 +4025,8 @@ static int fan_get_status_safe(u8 *status)
3904 int rc; 4025 int rc;
3905 u8 s; 4026 u8 s;
3906 4027
3907 rc = mutex_lock_interruptible(&fan_mutex); 4028 if (mutex_lock_interruptible(&fan_mutex))
3908 if (rc < 0) 4029 return -ERESTARTSYS;
3909 return rc;
3910 rc = fan_get_status(&s); 4030 rc = fan_get_status(&s);
3911 if (!rc) 4031 if (!rc)
3912 fan_update_desired_level(s); 4032 fan_update_desired_level(s);
@@ -4040,9 +4160,8 @@ static int fan_set_level_safe(int level)
4040 if (!fan_control_allowed) 4160 if (!fan_control_allowed)
4041 return -EPERM; 4161 return -EPERM;
4042 4162
4043 rc = mutex_lock_interruptible(&fan_mutex); 4163 if (mutex_lock_interruptible(&fan_mutex))
4044 if (rc < 0) 4164 return -ERESTARTSYS;
4045 return rc;
4046 4165
4047 if (level == TPACPI_FAN_LAST_LEVEL) 4166 if (level == TPACPI_FAN_LAST_LEVEL)
4048 level = fan_control_desired_level; 4167 level = fan_control_desired_level;
@@ -4063,9 +4182,8 @@ static int fan_set_enable(void)
4063 if (!fan_control_allowed) 4182 if (!fan_control_allowed)
4064 return -EPERM; 4183 return -EPERM;
4065 4184
4066 rc = mutex_lock_interruptible(&fan_mutex); 4185 if (mutex_lock_interruptible(&fan_mutex))
4067 if (rc < 0) 4186 return -ERESTARTSYS;
4068 return rc;
4069 4187
4070 switch (fan_control_access_mode) { 4188 switch (fan_control_access_mode) {
4071 case TPACPI_FAN_WR_ACPI_FANS: 4189 case TPACPI_FAN_WR_ACPI_FANS:
@@ -4119,9 +4237,8 @@ static int fan_set_disable(void)
4119 if (!fan_control_allowed) 4237 if (!fan_control_allowed)
4120 return -EPERM; 4238 return -EPERM;
4121 4239
4122 rc = mutex_lock_interruptible(&fan_mutex); 4240 if (mutex_lock_interruptible(&fan_mutex))
4123 if (rc < 0) 4241 return -ERESTARTSYS;
4124 return rc;
4125 4242
4126 rc = 0; 4243 rc = 0;
4127 switch (fan_control_access_mode) { 4244 switch (fan_control_access_mode) {
@@ -4158,9 +4275,8 @@ static int fan_set_speed(int speed)
4158 if (!fan_control_allowed) 4275 if (!fan_control_allowed)
4159 return -EPERM; 4276 return -EPERM;
4160 4277
4161 rc = mutex_lock_interruptible(&fan_mutex); 4278 if (mutex_lock_interruptible(&fan_mutex))
4162 if (rc < 0) 4279 return -ERESTARTSYS;
4163 return rc;
4164 4280
4165 rc = 0; 4281 rc = 0;
4166 switch (fan_control_access_mode) { 4282 switch (fan_control_access_mode) {
@@ -4701,9 +4817,15 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp)
4701 unsigned int i; 4817 unsigned int i;
4702 struct ibm_struct *ibm; 4818 struct ibm_struct *ibm;
4703 4819
4820 if (!kp || !kp->name || !val)
4821 return -EINVAL;
4822
4704 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { 4823 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
4705 ibm = ibms_init[i].data; 4824 ibm = ibms_init[i].data;
4706 BUG_ON(ibm == NULL); 4825 WARN_ON(ibm == NULL);
4826
4827 if (!ibm || !ibm->name)
4828 continue;
4707 4829
4708 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { 4830 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) {
4709 if (strlen(val) > sizeof(ibms_init[i].param) - 2) 4831 if (strlen(val) > sizeof(ibms_init[i].param) - 2)
@@ -4732,6 +4854,9 @@ module_param_named(fan_control, fan_control_allowed, bool, 0);
4732static int brightness_mode; 4854static int brightness_mode;
4733module_param_named(brightness_mode, brightness_mode, int, 0); 4855module_param_named(brightness_mode, brightness_mode, int, 0);
4734 4856
4857static unsigned int brightness_enable = 2; /* 2 = auto, 0 = no, 1 = yes */
4858module_param(brightness_enable, uint, 0);
4859
4735static unsigned int hotkey_report_mode; 4860static unsigned int hotkey_report_mode;
4736module_param(hotkey_report_mode, uint, 0); 4861module_param(hotkey_report_mode, uint, 0);
4737 4862
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 3abcc8120634..8fba2bbe345e 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -84,7 +84,7 @@
84 84
85/* ThinkPad CMOS NVRAM constants */ 85/* ThinkPad CMOS NVRAM constants */
86#define TP_NVRAM_ADDR_BRIGHTNESS 0x5e 86#define TP_NVRAM_ADDR_BRIGHTNESS 0x5e
87#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x07 87#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x0f
88#define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0 88#define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0
89 89
90#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off") 90#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off")
@@ -246,6 +246,7 @@ static struct {
246 u32 hotkey_wlsw:1; 246 u32 hotkey_wlsw:1;
247 u32 light:1; 247 u32 light:1;
248 u32 light_status:1; 248 u32 light_status:1;
249 u32 bright_16levels:1;
249 u32 wan:1; 250 u32 wan:1;
250 u32 fan_ctrl_status_undef:1; 251 u32 fan_ctrl_status_undef:1;
251 u32 input_device_registered:1; 252 u32 input_device_registered:1;
@@ -338,6 +339,7 @@ static int bluetooth_write(char *buf);
338static struct backlight_device *ibm_backlight_device; 339static struct backlight_device *ibm_backlight_device;
339static int brightness_offset = 0x31; 340static int brightness_offset = 0x31;
340static int brightness_mode; 341static int brightness_mode;
342static unsigned int brightness_enable; /* 0 = no, 1 = yes, 2 = auto */
341 343
342static int brightness_init(struct ibm_init_struct *iibm); 344static int brightness_init(struct ibm_init_struct *iibm);
343static void brightness_exit(void); 345static void brightness_exit(void);
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index e38d5a3b2a89..aeb32a93f6a0 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -44,6 +44,9 @@
44 * max 8 partitions per card 44 * max 8 partitions per card
45 */ 45 */
46#define MMC_SHIFT 3 46#define MMC_SHIFT 3
47#define MMC_NUM_MINORS (256 >> MMC_SHIFT)
48
49static unsigned long dev_use[MMC_NUM_MINORS/(8*sizeof(unsigned long))];
47 50
48/* 51/*
49 * There is one mmc_blk_data per slot. 52 * There is one mmc_blk_data per slot.
@@ -80,6 +83,9 @@ static void mmc_blk_put(struct mmc_blk_data *md)
80 mutex_lock(&open_lock); 83 mutex_lock(&open_lock);
81 md->usage--; 84 md->usage--;
82 if (md->usage == 0) { 85 if (md->usage == 0) {
86 int devidx = md->disk->first_minor >> MMC_SHIFT;
87 __clear_bit(devidx, dev_use);
88
83 put_disk(md->disk); 89 put_disk(md->disk);
84 kfree(md); 90 kfree(md);
85 } 91 }
@@ -321,7 +327,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
321 req->rq_disk->disk_name, err); 327 req->rq_disk->disk_name, err);
322 goto cmd_err; 328 goto cmd_err;
323 } 329 }
324 } while (!(cmd.resp[0] & R1_READY_FOR_DATA)); 330 /*
331 * Some cards mishandle the status bits,
332 * so make sure to check both the busy
333 * indication and the card state.
334 */
335 } while (!(cmd.resp[0] & R1_READY_FOR_DATA) ||
336 (R1_CURRENT_STATE(cmd.resp[0]) == 7));
325 337
326#if 0 338#if 0
327 if (cmd.resp[0] & ~0x00000900) 339 if (cmd.resp[0] & ~0x00000900)
@@ -400,9 +412,6 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
400 return 0; 412 return 0;
401} 413}
402 414
403#define MMC_NUM_MINORS (256 >> MMC_SHIFT)
404
405static unsigned long dev_use[MMC_NUM_MINORS/(8*sizeof(unsigned long))];
406 415
407static inline int mmc_blk_readonly(struct mmc_card *card) 416static inline int mmc_blk_readonly(struct mmc_card *card)
408{ 417{
@@ -568,17 +577,12 @@ static void mmc_blk_remove(struct mmc_card *card)
568 struct mmc_blk_data *md = mmc_get_drvdata(card); 577 struct mmc_blk_data *md = mmc_get_drvdata(card);
569 578
570 if (md) { 579 if (md) {
571 int devidx;
572
573 /* Stop new requests from getting into the queue */ 580 /* Stop new requests from getting into the queue */
574 del_gendisk(md->disk); 581 del_gendisk(md->disk);
575 582
576 /* Then flush out any already in there */ 583 /* Then flush out any already in there */
577 mmc_cleanup_queue(&md->queue); 584 mmc_cleanup_queue(&md->queue);
578 585
579 devidx = md->disk->first_minor >> MMC_SHIFT;
580 __clear_bit(devidx, dev_use);
581
582 mmc_blk_put(md); 586 mmc_blk_put(md);
583 } 587 }
584 mmc_set_drvdata(card, NULL); 588 mmc_set_drvdata(card, NULL);
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 1b9c9b6da5b7..30cd13b13ac3 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -180,12 +180,13 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
180 blk_queue_max_hw_segments(mq->queue, host->max_hw_segs); 180 blk_queue_max_hw_segments(mq->queue, host->max_hw_segs);
181 blk_queue_max_segment_size(mq->queue, host->max_seg_size); 181 blk_queue_max_segment_size(mq->queue, host->max_seg_size);
182 182
183 mq->sg = kzalloc(sizeof(struct scatterlist) * 183 mq->sg = kmalloc(sizeof(struct scatterlist) *
184 host->max_phys_segs, GFP_KERNEL); 184 host->max_phys_segs, GFP_KERNEL);
185 if (!mq->sg) { 185 if (!mq->sg) {
186 ret = -ENOMEM; 186 ret = -ENOMEM;
187 goto cleanup_queue; 187 goto cleanup_queue;
188 } 188 }
189 sg_init_table(mq->sg, host->max_phys_segs);
189 } 190 }
190 191
191 init_MUTEX(&mq->thread_sem); 192 init_MUTEX(&mq->thread_sem);
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index d552de683110..eeea84c309e6 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -386,7 +386,7 @@ static void sdio_uart_stop_rx(struct sdio_uart_port *port)
386 sdio_out(port, UART_IER, port->ier); 386 sdio_out(port, UART_IER, port->ier);
387} 387}
388 388
389static void sdio_uart_receive_chars(struct sdio_uart_port *port, int *status) 389static void sdio_uart_receive_chars(struct sdio_uart_port *port, unsigned int *status)
390{ 390{
391 struct tty_struct *tty = port->tty; 391 struct tty_struct *tty = port->tty;
392 unsigned int ch, flag; 392 unsigned int ch, flag;
diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c
index c11a3d256051..20d5c7bd940a 100644
--- a/drivers/mmc/host/tifm_sd.c
+++ b/drivers/mmc/host/tifm_sd.c
@@ -16,7 +16,6 @@
16#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/scatterlist.h> 18#include <linux/scatterlist.h>
19#include <linux/log2.h>
20#include <asm/io.h> 19#include <asm/io.h>
21 20
22#define DRIVER_NAME "tifm_sd" 21#define DRIVER_NAME "tifm_sd"
@@ -638,17 +637,15 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
638 goto err_out; 637 goto err_out;
639 } 638 }
640 639
641 if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
642 printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n",
643 sock->dev.bus_id, mrq->data->blksz);
644 mrq->cmd->error = -EINVAL;
645 goto err_out;
646 }
647
648 host->cmd_flags = 0; 640 host->cmd_flags = 0;
649 host->block_pos = 0; 641 host->block_pos = 0;
650 host->sg_pos = 0; 642 host->sg_pos = 0;
651 643
644 if (mrq->data && !is_power_of_2(mrq->data->blksz))
645 host->no_dma = 1;
646 else
647 host->no_dma = no_dma ? 1 : 0;
648
652 if (r_data) { 649 if (r_data) {
653 tifm_sd_set_data_timeout(host, r_data); 650 tifm_sd_set_data_timeout(host, r_data);
654 651
@@ -676,7 +673,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
676 : PCI_DMA_FROMDEVICE)) { 673 : PCI_DMA_FROMDEVICE)) {
677 printk(KERN_ERR "%s : scatterlist map failed\n", 674 printk(KERN_ERR "%s : scatterlist map failed\n",
678 sock->dev.bus_id); 675 sock->dev.bus_id);
679 spin_unlock_irqrestore(&sock->lock, flags); 676 mrq->cmd->error = -ENOMEM;
680 goto err_out; 677 goto err_out;
681 } 678 }
682 host->sg_len = tifm_map_sg(sock, r_data->sg, 679 host->sg_len = tifm_map_sg(sock, r_data->sg,
@@ -692,7 +689,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
692 r_data->flags & MMC_DATA_WRITE 689 r_data->flags & MMC_DATA_WRITE
693 ? PCI_DMA_TODEVICE 690 ? PCI_DMA_TODEVICE
694 : PCI_DMA_FROMDEVICE); 691 : PCI_DMA_FROMDEVICE);
695 spin_unlock_irqrestore(&sock->lock, flags); 692 mrq->cmd->error = -ENOMEM;
696 goto err_out; 693 goto err_out;
697 } 694 }
698 695
@@ -966,7 +963,6 @@ static int tifm_sd_probe(struct tifm_dev *sock)
966 return -ENOMEM; 963 return -ENOMEM;
967 964
968 host = mmc_priv(mmc); 965 host = mmc_priv(mmc);
969 host->no_dma = no_dma;
970 tifm_set_drvdata(sock, mmc); 966 tifm_set_drvdata(sock, mmc);
971 host->dev = sock; 967 host->dev = sock;
972 host->timeout_jiffies = msecs_to_jiffies(1000); 968 host->timeout_jiffies = msecs_to_jiffies(1000);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index e8d69b0adf90..d9107e542dfa 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -888,7 +888,7 @@ config SMC91X
888 tristate "SMC 91C9x/91C1xxx support" 888 tristate "SMC 91C9x/91C1xxx support"
889 select CRC32 889 select CRC32
890 select MII 890 select MII
891 depends on ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || SOC_AU1X00 || BFIN 891 depends on ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || SOC_AU1X00 || BLACKFIN
892 help 892 help
893 This is a driver for SMC's 91x series of Ethernet chipsets, 893 This is a driver for SMC's 91x series of Ethernet chipsets,
894 including the SMC91C94 and the SMC91C111. Say Y if you want it 894 including the SMC91C94 and the SMC91C111. Say Y if you want it
@@ -926,7 +926,7 @@ config SMC911X
926 tristate "SMSC LAN911[5678] support" 926 tristate "SMSC LAN911[5678] support"
927 select CRC32 927 select CRC32
928 select MII 928 select MII
929 depends on ARCH_PXA || SUPERH 929 depends on ARCH_PXA || SH_MAGIC_PANEL_R2
930 help 930 help
931 This is a driver for SMSC's LAN911x series of Ethernet chipsets 931 This is a driver for SMSC's LAN911x series of Ethernet chipsets
932 including the new LAN9115, LAN9116, LAN9117, and LAN9118. 932 including the new LAN9115, LAN9116, LAN9117, and LAN9118.
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index eebf5bb2b03a..e7fdd81919bd 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -1340,7 +1340,9 @@ static int amd8111e_close(struct net_device * dev)
1340 struct amd8111e_priv *lp = netdev_priv(dev); 1340 struct amd8111e_priv *lp = netdev_priv(dev);
1341 netif_stop_queue(dev); 1341 netif_stop_queue(dev);
1342 1342
1343#ifdef CONFIG_AMD8111E_NAPI
1343 napi_disable(&lp->napi); 1344 napi_disable(&lp->napi);
1345#endif
1344 1346
1345 spin_lock_irq(&lp->lock); 1347 spin_lock_irq(&lp->lock);
1346 1348
@@ -1372,7 +1374,9 @@ static int amd8111e_open(struct net_device * dev )
1372 dev->name, dev)) 1374 dev->name, dev))
1373 return -EAGAIN; 1375 return -EAGAIN;
1374 1376
1377#ifdef CONFIG_AMD8111E_NAPI
1375 napi_enable(&lp->napi); 1378 napi_enable(&lp->napi);
1379#endif
1376 1380
1377 spin_lock_irq(&lp->lock); 1381 spin_lock_irq(&lp->lock);
1378 1382
@@ -1380,7 +1384,9 @@ static int amd8111e_open(struct net_device * dev )
1380 1384
1381 if(amd8111e_restart(dev)){ 1385 if(amd8111e_restart(dev)){
1382 spin_unlock_irq(&lp->lock); 1386 spin_unlock_irq(&lp->lock);
1387#ifdef CONFIG_AMD8111E_NAPI
1383 napi_disable(&lp->napi); 1388 napi_disable(&lp->napi);
1389#endif
1384 if (dev->irq) 1390 if (dev->irq)
1385 free_irq(dev->irq, dev); 1391 free_irq(dev->irq, dev);
1386 return -ENOMEM; 1392 return -ENOMEM;
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 084acfd6fc5f..eb971755a3ff 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -676,7 +676,7 @@ static void bf537mac_rx(struct net_device *dev)
676 skb->protocol = eth_type_trans(skb, dev); 676 skb->protocol = eth_type_trans(skb, dev);
677#if defined(BFIN_MAC_CSUM_OFFLOAD) 677#if defined(BFIN_MAC_CSUM_OFFLOAD)
678 skb->csum = current_rx_ptr->status.ip_payload_csum; 678 skb->csum = current_rx_ptr->status.ip_payload_csum;
679 skb->ip_summed = CHECKSUM_PARTIAL; 679 skb->ip_summed = CHECKSUM_COMPLETE;
680#endif 680#endif
681 681
682 netif_rx(skb); 682 netif_rx(skb);
@@ -924,7 +924,7 @@ static int __init bf537mac_probe(struct net_device *dev)
924 if (!is_valid_ether_addr(dev->dev_addr)) { 924 if (!is_valid_ether_addr(dev->dev_addr)) {
925 /* Grab the MAC from the board somehow - this is done in the 925 /* Grab the MAC from the board somehow - this is done in the
926 arch/blackfin/mach-bf537/boards/eth_mac.c */ 926 arch/blackfin/mach-bf537/boards/eth_mac.c */
927 get_bf537_ether_addr(dev->dev_addr); 927 bfin_get_ether_addr(dev->dev_addr);
928 } 928 }
929 929
930 /* If still not valid, get a random one */ 930 /* If still not valid, get a random one */
diff --git a/drivers/net/bfin_mac.h b/drivers/net/bfin_mac.h
index 3a107ad75381..5970ea7142cd 100644
--- a/drivers/net/bfin_mac.h
+++ b/drivers/net/bfin_mac.h
@@ -92,4 +92,4 @@ struct bf537mac_local {
92 struct mii_bus mii_bus; 92 struct mii_bus mii_bus;
93}; 93};
94 94
95extern void get_bf537_ether_addr(char *addr); 95extern void bfin_get_ether_addr(char *addr);
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index 2dbf8dc116c6..c5975047c89b 100644..100755
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -374,7 +374,9 @@ static char stats_strings[][ETH_GSTRING_LEN] = {
374 "TxInternalMACXmitError", 374 "TxInternalMACXmitError",
375 "TxFramesWithExcessiveDeferral", 375 "TxFramesWithExcessiveDeferral",
376 "TxFCSErrors", 376 "TxFCSErrors",
377 377 "TxJumboFramesOk",
378 "TxJumboOctetsOk",
379
378 "RxOctetsOK", 380 "RxOctetsOK",
379 "RxOctetsBad", 381 "RxOctetsBad",
380 "RxUnicastFramesOK", 382 "RxUnicastFramesOK",
@@ -392,16 +394,17 @@ static char stats_strings[][ETH_GSTRING_LEN] = {
392 "RxInRangeLengthErrors", 394 "RxInRangeLengthErrors",
393 "RxOutOfRangeLengthField", 395 "RxOutOfRangeLengthField",
394 "RxFrameTooLongErrors", 396 "RxFrameTooLongErrors",
397 "RxJumboFramesOk",
398 "RxJumboOctetsOk",
395 399
396 /* Port stats */ 400 /* Port stats */
397 "RxPackets",
398 "RxCsumGood", 401 "RxCsumGood",
399 "TxPackets",
400 "TxCsumOffload", 402 "TxCsumOffload",
401 "TxTso", 403 "TxTso",
402 "RxVlan", 404 "RxVlan",
403 "TxVlan", 405 "TxVlan",
404 406 "TxNeedHeadroom",
407
405 /* Interrupt stats */ 408 /* Interrupt stats */
406 "rx drops", 409 "rx drops",
407 "pure_rsps", 410 "pure_rsps",
@@ -463,23 +466,56 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
463 const struct cmac_statistics *s; 466 const struct cmac_statistics *s;
464 const struct sge_intr_counts *t; 467 const struct sge_intr_counts *t;
465 struct sge_port_stats ss; 468 struct sge_port_stats ss;
466 unsigned int len;
467 469
468 s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL); 470 s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL);
469 471 t = t1_sge_get_intr_counts(adapter->sge);
470 len = sizeof(u64)*(&s->TxFCSErrors + 1 - &s->TxOctetsOK);
471 memcpy(data, &s->TxOctetsOK, len);
472 data += len;
473
474 len = sizeof(u64)*(&s->RxFrameTooLongErrors + 1 - &s->RxOctetsOK);
475 memcpy(data, &s->RxOctetsOK, len);
476 data += len;
477
478 t1_sge_get_port_stats(adapter->sge, dev->if_port, &ss); 472 t1_sge_get_port_stats(adapter->sge, dev->if_port, &ss);
479 memcpy(data, &ss, sizeof(ss));
480 data += sizeof(ss);
481 473
482 t = t1_sge_get_intr_counts(adapter->sge); 474 *data++ = s->TxOctetsOK;
475 *data++ = s->TxOctetsBad;
476 *data++ = s->TxUnicastFramesOK;
477 *data++ = s->TxMulticastFramesOK;
478 *data++ = s->TxBroadcastFramesOK;
479 *data++ = s->TxPauseFrames;
480 *data++ = s->TxFramesWithDeferredXmissions;
481 *data++ = s->TxLateCollisions;
482 *data++ = s->TxTotalCollisions;
483 *data++ = s->TxFramesAbortedDueToXSCollisions;
484 *data++ = s->TxUnderrun;
485 *data++ = s->TxLengthErrors;
486 *data++ = s->TxInternalMACXmitError;
487 *data++ = s->TxFramesWithExcessiveDeferral;
488 *data++ = s->TxFCSErrors;
489 *data++ = s->TxJumboFramesOK;
490 *data++ = s->TxJumboOctetsOK;
491
492 *data++ = s->RxOctetsOK;
493 *data++ = s->RxOctetsBad;
494 *data++ = s->RxUnicastFramesOK;
495 *data++ = s->RxMulticastFramesOK;
496 *data++ = s->RxBroadcastFramesOK;
497 *data++ = s->RxPauseFrames;
498 *data++ = s->RxFCSErrors;
499 *data++ = s->RxAlignErrors;
500 *data++ = s->RxSymbolErrors;
501 *data++ = s->RxDataErrors;
502 *data++ = s->RxSequenceErrors;
503 *data++ = s->RxRuntErrors;
504 *data++ = s->RxJabberErrors;
505 *data++ = s->RxInternalMACRcvError;
506 *data++ = s->RxInRangeLengthErrors;
507 *data++ = s->RxOutOfRangeLengthField;
508 *data++ = s->RxFrameTooLongErrors;
509 *data++ = s->RxJumboFramesOK;
510 *data++ = s->RxJumboOctetsOK;
511
512 *data++ = ss.rx_cso_good;
513 *data++ = ss.tx_cso;
514 *data++ = ss.tx_tso;
515 *data++ = ss.vlan_xtract;
516 *data++ = ss.vlan_insert;
517 *data++ = ss.tx_need_hdrroom;
518
483 *data++ = t->rx_drops; 519 *data++ = t->rx_drops;
484 *data++ = t->pure_rsps; 520 *data++ = t->pure_rsps;
485 *data++ = t->unhandled_irqs; 521 *data++ = t->unhandled_irqs;
diff --git a/drivers/net/chelsio/pm3393.c b/drivers/net/chelsio/pm3393.c
index 678778a8d133..2117c4fbb107 100644..100755
--- a/drivers/net/chelsio/pm3393.c
+++ b/drivers/net/chelsio/pm3393.c
@@ -45,7 +45,7 @@
45 45
46#include <linux/crc32.h> 46#include <linux/crc32.h>
47 47
48#define OFFSET(REG_ADDR) (REG_ADDR << 2) 48#define OFFSET(REG_ADDR) ((REG_ADDR) << 2)
49 49
50/* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */ 50/* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */
51#define MAX_FRAME_SIZE 9600 51#define MAX_FRAME_SIZE 9600
@@ -428,69 +428,26 @@ static int pm3393_set_speed_duplex_fc(struct cmac *cmac, int speed, int duplex,
428 return 0; 428 return 0;
429} 429}
430 430
431static void pm3393_rmon_update(struct adapter *adapter, u32 offs, u64 *val, 431#define RMON_UPDATE(mac, name, stat_name) \
432 int over) 432{ \
433{ 433 t1_tpi_read((mac)->adapter, OFFSET(name), &val0); \
434 u32 val0, val1, val2; 434 t1_tpi_read((mac)->adapter, OFFSET((name)+1), &val1); \
435 435 t1_tpi_read((mac)->adapter, OFFSET((name)+2), &val2); \
436 t1_tpi_read(adapter, offs, &val0); 436 (mac)->stats.stat_name = (u64)(val0 & 0xffff) | \
437 t1_tpi_read(adapter, offs + 4, &val1); 437 ((u64)(val1 & 0xffff) << 16) | \
438 t1_tpi_read(adapter, offs + 8, &val2); 438 ((u64)(val2 & 0xff) << 32) | \
439 439 ((mac)->stats.stat_name & \
440 *val &= ~0ull << 40; 440 0xffffff0000000000ULL); \
441 *val |= val0 & 0xffff; 441 if (ro & \
442 *val |= (val1 & 0xffff) << 16; 442 (1ULL << ((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2))) \
443 *val |= (u64)(val2 & 0xff) << 32; 443 (mac)->stats.stat_name += 1ULL << 40; \
444
445 if (over)
446 *val += 1ull << 40;
447} 444}
448 445
449static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac, 446static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
450 int flag) 447 int flag)
451{ 448{
452 static struct { 449 u64 ro;
453 unsigned int reg; 450 u32 val0, val1, val2, val3;
454 unsigned int offset;
455 } hw_stats [] = {
456
457#define HW_STAT(name, stat_name) \
458 { name, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL }
459
460 /* Rx stats */
461 HW_STAT(RxOctetsReceivedOK, RxOctetsOK),
462 HW_STAT(RxUnicastFramesReceivedOK, RxUnicastFramesOK),
463 HW_STAT(RxMulticastFramesReceivedOK, RxMulticastFramesOK),
464 HW_STAT(RxBroadcastFramesReceivedOK, RxBroadcastFramesOK),
465 HW_STAT(RxPAUSEMACCtrlFramesReceived, RxPauseFrames),
466 HW_STAT(RxFrameCheckSequenceErrors, RxFCSErrors),
467 HW_STAT(RxFramesLostDueToInternalMACErrors,
468 RxInternalMACRcvError),
469 HW_STAT(RxSymbolErrors, RxSymbolErrors),
470 HW_STAT(RxInRangeLengthErrors, RxInRangeLengthErrors),
471 HW_STAT(RxFramesTooLongErrors , RxFrameTooLongErrors),
472 HW_STAT(RxJabbers, RxJabberErrors),
473 HW_STAT(RxFragments, RxRuntErrors),
474 HW_STAT(RxUndersizedFrames, RxRuntErrors),
475 HW_STAT(RxJumboFramesReceivedOK, RxJumboFramesOK),
476 HW_STAT(RxJumboOctetsReceivedOK, RxJumboOctetsOK),
477
478 /* Tx stats */
479 HW_STAT(TxOctetsTransmittedOK, TxOctetsOK),
480 HW_STAT(TxFramesLostDueToInternalMACTransmissionError,
481 TxInternalMACXmitError),
482 HW_STAT(TxTransmitSystemError, TxFCSErrors),
483 HW_STAT(TxUnicastFramesTransmittedOK, TxUnicastFramesOK),
484 HW_STAT(TxMulticastFramesTransmittedOK, TxMulticastFramesOK),
485 HW_STAT(TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK),
486 HW_STAT(TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames),
487 HW_STAT(TxJumboFramesReceivedOK, TxJumboFramesOK),
488 HW_STAT(TxJumboOctetsReceivedOK, TxJumboOctetsOK)
489 }, *p = hw_stats;
490 u64 ro;
491 u32 val0, val1, val2, val3;
492 u64 *stats = (u64 *) &mac->stats;
493 unsigned int i;
494 451
495 /* Snap the counters */ 452 /* Snap the counters */
496 pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL, 453 pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL,
@@ -504,14 +461,35 @@ static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
504 ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) | 461 ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) |
505 (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48); 462 (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48);
506 463
507 for (i = 0; i < ARRAY_SIZE(hw_stats); i++) { 464 /* Rx stats */
508 unsigned reg = p->reg - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW; 465 RMON_UPDATE(mac, RxOctetsReceivedOK, RxOctetsOK);
509 466 RMON_UPDATE(mac, RxUnicastFramesReceivedOK, RxUnicastFramesOK);
510 pm3393_rmon_update((mac)->adapter, OFFSET(p->reg), 467 RMON_UPDATE(mac, RxMulticastFramesReceivedOK, RxMulticastFramesOK);
511 stats + p->offset, ro & (reg >> 2)); 468 RMON_UPDATE(mac, RxBroadcastFramesReceivedOK, RxBroadcastFramesOK);
512 } 469 RMON_UPDATE(mac, RxPAUSEMACCtrlFramesReceived, RxPauseFrames);
513 470 RMON_UPDATE(mac, RxFrameCheckSequenceErrors, RxFCSErrors);
514 471 RMON_UPDATE(mac, RxFramesLostDueToInternalMACErrors,
472 RxInternalMACRcvError);
473 RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors);
474 RMON_UPDATE(mac, RxInRangeLengthErrors, RxInRangeLengthErrors);
475 RMON_UPDATE(mac, RxFramesTooLongErrors , RxFrameTooLongErrors);
476 RMON_UPDATE(mac, RxJabbers, RxJabberErrors);
477 RMON_UPDATE(mac, RxFragments, RxRuntErrors);
478 RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors);
479 RMON_UPDATE(mac, RxJumboFramesReceivedOK, RxJumboFramesOK);
480 RMON_UPDATE(mac, RxJumboOctetsReceivedOK, RxJumboOctetsOK);
481
482 /* Tx stats */
483 RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK);
484 RMON_UPDATE(mac, TxFramesLostDueToInternalMACTransmissionError,
485 TxInternalMACXmitError);
486 RMON_UPDATE(mac, TxTransmitSystemError, TxFCSErrors);
487 RMON_UPDATE(mac, TxUnicastFramesTransmittedOK, TxUnicastFramesOK);
488 RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK);
489 RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK);
490 RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames);
491 RMON_UPDATE(mac, TxJumboFramesReceivedOK, TxJumboFramesOK);
492 RMON_UPDATE(mac, TxJumboOctetsReceivedOK, TxJumboOctetsOK);
515 493
516 return &mac->stats; 494 return &mac->stats;
517} 495}
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 443666292a5c..b301c0428ae0 100644..100755
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -986,11 +986,10 @@ void t1_sge_get_port_stats(const struct sge *sge, int port,
986 for_each_possible_cpu(cpu) { 986 for_each_possible_cpu(cpu) {
987 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[port], cpu); 987 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[port], cpu);
988 988
989 ss->rx_packets += st->rx_packets;
990 ss->rx_cso_good += st->rx_cso_good; 989 ss->rx_cso_good += st->rx_cso_good;
991 ss->tx_packets += st->tx_packets;
992 ss->tx_cso += st->tx_cso; 990 ss->tx_cso += st->tx_cso;
993 ss->tx_tso += st->tx_tso; 991 ss->tx_tso += st->tx_tso;
992 ss->tx_need_hdrroom += st->tx_need_hdrroom;
994 ss->vlan_xtract += st->vlan_xtract; 993 ss->vlan_xtract += st->vlan_xtract;
995 ss->vlan_insert += st->vlan_insert; 994 ss->vlan_insert += st->vlan_insert;
996 } 995 }
@@ -1380,7 +1379,6 @@ static void sge_rx(struct sge *sge, struct freelQ *fl, unsigned int len)
1380 __skb_pull(skb, sizeof(*p)); 1379 __skb_pull(skb, sizeof(*p));
1381 1380
1382 st = per_cpu_ptr(sge->port_stats[p->iff], smp_processor_id()); 1381 st = per_cpu_ptr(sge->port_stats[p->iff], smp_processor_id());
1383 st->rx_packets++;
1384 1382
1385 skb->protocol = eth_type_trans(skb, adapter->port[p->iff].dev); 1383 skb->protocol = eth_type_trans(skb, adapter->port[p->iff].dev);
1386 skb->dev->last_rx = jiffies; 1384 skb->dev->last_rx = jiffies;
@@ -1624,11 +1622,9 @@ int t1_poll(struct napi_struct *napi, int budget)
1624{ 1622{
1625 struct adapter *adapter = container_of(napi, struct adapter, napi); 1623 struct adapter *adapter = container_of(napi, struct adapter, napi);
1626 struct net_device *dev = adapter->port[0].dev; 1624 struct net_device *dev = adapter->port[0].dev;
1627 int work_done; 1625 int work_done = process_responses(adapter, budget);
1628
1629 work_done = process_responses(adapter, budget);
1630 1626
1631 if (likely(!responses_pending(adapter))) { 1627 if (likely(work_done < budget)) {
1632 netif_rx_complete(dev, napi); 1628 netif_rx_complete(dev, napi);
1633 writel(adapter->sge->respQ.cidx, 1629 writel(adapter->sge->respQ.cidx,
1634 adapter->regs + A_SG_SLEEPING); 1630 adapter->regs + A_SG_SLEEPING);
@@ -1848,7 +1844,8 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1848{ 1844{
1849 struct adapter *adapter = dev->priv; 1845 struct adapter *adapter = dev->priv;
1850 struct sge *sge = adapter->sge; 1846 struct sge *sge = adapter->sge;
1851 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port], smp_processor_id()); 1847 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port],
1848 smp_processor_id());
1852 struct cpl_tx_pkt *cpl; 1849 struct cpl_tx_pkt *cpl;
1853 struct sk_buff *orig_skb = skb; 1850 struct sk_buff *orig_skb = skb;
1854 int ret; 1851 int ret;
@@ -1856,6 +1853,18 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1856 if (skb->protocol == htons(ETH_P_CPL5)) 1853 if (skb->protocol == htons(ETH_P_CPL5))
1857 goto send; 1854 goto send;
1858 1855
1856 /*
1857 * We are using a non-standard hard_header_len.
1858 * Allocate more header room in the rare cases it is not big enough.
1859 */
1860 if (unlikely(skb_headroom(skb) < dev->hard_header_len - ETH_HLEN)) {
1861 skb = skb_realloc_headroom(skb, sizeof(struct cpl_tx_pkt_lso));
1862 ++st->tx_need_hdrroom;
1863 dev_kfree_skb_any(orig_skb);
1864 if (!skb)
1865 return NETDEV_TX_OK;
1866 }
1867
1859 if (skb_shinfo(skb)->gso_size) { 1868 if (skb_shinfo(skb)->gso_size) {
1860 int eth_type; 1869 int eth_type;
1861 struct cpl_tx_pkt_lso *hdr; 1870 struct cpl_tx_pkt_lso *hdr;
@@ -1889,24 +1898,6 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1889 return NETDEV_TX_OK; 1898 return NETDEV_TX_OK;
1890 } 1899 }
1891 1900
1892 /*
1893 * We are using a non-standard hard_header_len and some kernel
1894 * components, such as pktgen, do not handle it right.
1895 * Complain when this happens but try to fix things up.
1896 */
1897 if (unlikely(skb_headroom(skb) < dev->hard_header_len - ETH_HLEN)) {
1898 pr_debug("%s: headroom %d header_len %d\n", dev->name,
1899 skb_headroom(skb), dev->hard_header_len);
1900
1901 if (net_ratelimit())
1902 printk(KERN_ERR "%s: inadequate headroom in "
1903 "Tx packet\n", dev->name);
1904 skb = skb_realloc_headroom(skb, sizeof(*cpl));
1905 dev_kfree_skb_any(orig_skb);
1906 if (!skb)
1907 return NETDEV_TX_OK;
1908 }
1909
1910 if (!(adapter->flags & UDP_CSUM_CAPABLE) && 1901 if (!(adapter->flags & UDP_CSUM_CAPABLE) &&
1911 skb->ip_summed == CHECKSUM_PARTIAL && 1902 skb->ip_summed == CHECKSUM_PARTIAL &&
1912 ip_hdr(skb)->protocol == IPPROTO_UDP) { 1903 ip_hdr(skb)->protocol == IPPROTO_UDP) {
@@ -1952,7 +1943,6 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1952 cpl->vlan_valid = 0; 1943 cpl->vlan_valid = 0;
1953 1944
1954send: 1945send:
1955 st->tx_packets++;
1956 dev->trans_start = jiffies; 1946 dev->trans_start = jiffies;
1957 ret = t1_sge_tx(skb, adapter, 0, dev); 1947 ret = t1_sge_tx(skb, adapter, 0, dev);
1958 1948
diff --git a/drivers/net/chelsio/sge.h b/drivers/net/chelsio/sge.h
index 713d9c55f24d..cced9dff91c5 100644..100755
--- a/drivers/net/chelsio/sge.h
+++ b/drivers/net/chelsio/sge.h
@@ -57,13 +57,12 @@ struct sge_intr_counts {
57}; 57};
58 58
59struct sge_port_stats { 59struct sge_port_stats {
60 u64 rx_packets; /* # of Ethernet packets received */
61 u64 rx_cso_good; /* # of successful RX csum offloads */ 60 u64 rx_cso_good; /* # of successful RX csum offloads */
62 u64 tx_packets; /* # of TX packets */
63 u64 tx_cso; /* # of TX checksum offloads */ 61 u64 tx_cso; /* # of TX checksum offloads */
64 u64 tx_tso; /* # of TSO requests */ 62 u64 tx_tso; /* # of TSO requests */
65 u64 vlan_xtract; /* # of VLAN tag extractions */ 63 u64 vlan_xtract; /* # of VLAN tag extractions */
66 u64 vlan_insert; /* # of VLAN tag insertions */ 64 u64 vlan_insert; /* # of VLAN tag insertions */
65 u64 tx_need_hdrroom; /* # of TX skbs in need of more header room */
67}; 66};
68 67
69struct sk_buff; 68struct sk_buff;
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index cf39473ef90a..4f37506ad374 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3942,7 +3942,7 @@ e1000_clean(struct napi_struct *napi, int budget)
3942 &work_done, budget); 3942 &work_done, budget);
3943 3943
3944 /* If no Tx and not enough Rx work done, exit the polling mode */ 3944 /* If no Tx and not enough Rx work done, exit the polling mode */
3945 if ((!tx_cleaned && (work_done < budget)) || 3945 if ((!tx_cleaned && (work_done == 0)) ||
3946 !netif_running(poll_dev)) { 3946 !netif_running(poll_dev)) {
3947quit_polling: 3947quit_polling:
3948 if (likely(adapter->itr_setting & 3)) 3948 if (likely(adapter->itr_setting & 3))
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index f78e5bf7cb33..5f82a4647eee 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -40,7 +40,7 @@
40#include <asm/io.h> 40#include <asm/io.h>
41 41
42#define DRV_NAME "ehea" 42#define DRV_NAME "ehea"
43#define DRV_VERSION "EHEA_0080" 43#define DRV_VERSION "EHEA_0083"
44 44
45/* eHEA capability flags */ 45/* eHEA capability flags */
46#define DLPAR_PORT_ADD_REM 1 46#define DLPAR_PORT_ADD_REM 1
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index f0319f1e8e05..869e1604b16e 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -136,7 +136,7 @@ static struct net_device_stats *ehea_get_stats(struct net_device *dev)
136 struct ehea_port *port = netdev_priv(dev); 136 struct ehea_port *port = netdev_priv(dev);
137 struct net_device_stats *stats = &port->stats; 137 struct net_device_stats *stats = &port->stats;
138 struct hcp_ehea_port_cb2 *cb2; 138 struct hcp_ehea_port_cb2 *cb2;
139 u64 hret, rx_packets; 139 u64 hret, rx_packets, tx_packets;
140 int i; 140 int i;
141 141
142 memset(stats, 0, sizeof(*stats)); 142 memset(stats, 0, sizeof(*stats));
@@ -162,7 +162,11 @@ static struct net_device_stats *ehea_get_stats(struct net_device *dev)
162 for (i = 0; i < port->num_def_qps; i++) 162 for (i = 0; i < port->num_def_qps; i++)
163 rx_packets += port->port_res[i].rx_packets; 163 rx_packets += port->port_res[i].rx_packets;
164 164
165 stats->tx_packets = cb2->txucp + cb2->txmcp + cb2->txbcp; 165 tx_packets = 0;
166 for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++)
167 tx_packets += port->port_res[i].tx_packets;
168
169 stats->tx_packets = tx_packets;
166 stats->multicast = cb2->rxmcp; 170 stats->multicast = cb2->rxmcp;
167 stats->rx_errors = cb2->rxuerr; 171 stats->rx_errors = cb2->rxuerr;
168 stats->rx_bytes = cb2->rxo; 172 stats->rx_bytes = cb2->rxo;
@@ -406,11 +410,6 @@ static int ehea_treat_poll_error(struct ehea_port_res *pr, int rq,
406 if (cqe->status & EHEA_CQE_STAT_ERR_CRC) 410 if (cqe->status & EHEA_CQE_STAT_ERR_CRC)
407 pr->p_stats.err_frame_crc++; 411 pr->p_stats.err_frame_crc++;
408 412
409 if (netif_msg_rx_err(pr->port)) {
410 ehea_error("CQE Error for QP %d", pr->qp->init_attr.qp_nr);
411 ehea_dump(cqe, sizeof(*cqe), "CQE");
412 }
413
414 if (rq == 2) { 413 if (rq == 2) {
415 *processed_rq2 += 1; 414 *processed_rq2 += 1;
416 skb = get_skb_by_index(pr->rq2_skba.arr, pr->rq2_skba.len, cqe); 415 skb = get_skb_by_index(pr->rq2_skba.arr, pr->rq2_skba.len, cqe);
@@ -422,7 +421,11 @@ static int ehea_treat_poll_error(struct ehea_port_res *pr, int rq,
422 } 421 }
423 422
424 if (cqe->status & EHEA_CQE_STAT_FAT_ERR_MASK) { 423 if (cqe->status & EHEA_CQE_STAT_FAT_ERR_MASK) {
425 ehea_error("Critical receive error. Resetting port."); 424 if (netif_msg_rx_err(pr->port)) {
425 ehea_error("Critical receive error for QP %d. "
426 "Resetting port.", pr->qp->init_attr.qp_nr);
427 ehea_dump(cqe, sizeof(*cqe), "CQE");
428 }
426 schedule_work(&pr->port->reset_task); 429 schedule_work(&pr->port->reset_task);
427 return 1; 430 return 1;
428 } 431 }
@@ -2000,6 +2003,7 @@ static int ehea_start_xmit(struct sk_buff *skb, struct net_device *dev)
2000 } 2003 }
2001 2004
2002 ehea_post_swqe(pr->qp, swqe); 2005 ehea_post_swqe(pr->qp, swqe);
2006 pr->tx_packets++;
2003 2007
2004 if (unlikely(atomic_read(&pr->swqe_avail) <= 1)) { 2008 if (unlikely(atomic_read(&pr->swqe_avail) <= 1)) {
2005 spin_lock_irqsave(&pr->netif_queue, flags); 2009 spin_lock_irqsave(&pr->netif_queue, flags);
diff --git a/drivers/net/ehea/ehea_qmr.h b/drivers/net/ehea/ehea_qmr.h
index 562de0ebdd85..bc62d389c166 100644
--- a/drivers/net/ehea/ehea_qmr.h
+++ b/drivers/net/ehea/ehea_qmr.h
@@ -145,8 +145,8 @@ struct ehea_rwqe {
145#define EHEA_CQE_VLAN_TAG_XTRACT 0x0400 145#define EHEA_CQE_VLAN_TAG_XTRACT 0x0400
146 146
147#define EHEA_CQE_TYPE_RQ 0x60 147#define EHEA_CQE_TYPE_RQ 0x60
148#define EHEA_CQE_STAT_ERR_MASK 0x720F 148#define EHEA_CQE_STAT_ERR_MASK 0x700F
149#define EHEA_CQE_STAT_FAT_ERR_MASK 0x1F 149#define EHEA_CQE_STAT_FAT_ERR_MASK 0xF
150#define EHEA_CQE_STAT_ERR_TCP 0x4000 150#define EHEA_CQE_STAT_ERR_TCP 0x4000
151#define EHEA_CQE_STAT_ERR_IP 0x2000 151#define EHEA_CQE_STAT_ERR_IP 0x2000
152#define EHEA_CQE_STAT_ERR_CRC 0x1000 152#define EHEA_CQE_STAT_ERR_CRC 0x1000
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index a8a0ee220da6..bf5a7caa5b52 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -971,6 +971,8 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
971 971
972 mpc52xx_fec_reset_stats(ndev); 972 mpc52xx_fec_reset_stats(ndev);
973 973
974 SET_NETDEV_DEV(ndev, &op->dev);
975
974 /* Register the new network device */ 976 /* Register the new network device */
975 rv = register_netdev(ndev); 977 rv = register_netdev(ndev);
976 if (rv < 0) 978 if (rv < 0)
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 92ce2e38f0d5..a96583cceb5e 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -5286,19 +5286,15 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5286 if (readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_SYNC_PHY_INIT) { 5286 if (readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_SYNC_PHY_INIT) {
5287 np->mac_in_use = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_MGMT_ST; 5287 np->mac_in_use = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_MGMT_ST;
5288 dprintk(KERN_INFO "%s: mgmt unit is running. mac in use %x.\n", pci_name(pci_dev), np->mac_in_use); 5288 dprintk(KERN_INFO "%s: mgmt unit is running. mac in use %x.\n", pci_name(pci_dev), np->mac_in_use);
5289 for (i = 0; i < 5000; i++) { 5289 if (nv_mgmt_acquire_sema(dev)) {
5290 msleep(1); 5290 /* management unit setup the phy already? */
5291 if (nv_mgmt_acquire_sema(dev)) { 5291 if ((readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_SYNC_MASK) ==
5292 /* management unit setup the phy already? */ 5292 NVREG_XMITCTL_SYNC_PHY_INIT) {
5293 if ((readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_SYNC_MASK) == 5293 /* phy is inited by mgmt unit */
5294 NVREG_XMITCTL_SYNC_PHY_INIT) { 5294 phyinitialized = 1;
5295 /* phy is inited by mgmt unit */ 5295 dprintk(KERN_INFO "%s: Phy already initialized by mgmt unit.\n", pci_name(pci_dev));
5296 phyinitialized = 1; 5296 } else {
5297 dprintk(KERN_INFO "%s: Phy already initialized by mgmt unit.\n", pci_name(pci_dev)); 5297 /* we need to init the phy */
5298 } else {
5299 /* we need to init the phy */
5300 }
5301 break;
5302 } 5298 }
5303 } 5299 }
5304 } 5300 }
@@ -5613,6 +5609,22 @@ static struct pci_device_id pci_tbl[] = {
5613 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_35), 5609 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_35),
5614 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5610 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
5615 }, 5611 },
5612 { /* MCP79 Ethernet Controller */
5613 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_36),
5614 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
5615 },
5616 { /* MCP79 Ethernet Controller */
5617 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_37),
5618 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
5619 },
5620 { /* MCP79 Ethernet Controller */
5621 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_38),
5622 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
5623 },
5624 { /* MCP79 Ethernet Controller */
5625 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_39),
5626 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
5627 },
5616 {0,}, 5628 {0,},
5617}; 5629};
5618 5630
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index 0de3aa2a2e44..eb0718b441bb 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -642,9 +642,11 @@ static void emac_reset_work(struct work_struct *work)
642 DBG(dev, "reset_work" NL); 642 DBG(dev, "reset_work" NL);
643 643
644 mutex_lock(&dev->link_lock); 644 mutex_lock(&dev->link_lock);
645 emac_netif_stop(dev); 645 if (dev->opened) {
646 emac_full_tx_reset(dev); 646 emac_netif_stop(dev);
647 emac_netif_start(dev); 647 emac_full_tx_reset(dev);
648 emac_netif_start(dev);
649 }
648 mutex_unlock(&dev->link_lock); 650 mutex_unlock(&dev->link_lock);
649} 651}
650 652
@@ -1063,10 +1065,9 @@ static int emac_open(struct net_device *ndev)
1063 dev->rx_sg_skb = NULL; 1065 dev->rx_sg_skb = NULL;
1064 1066
1065 mutex_lock(&dev->link_lock); 1067 mutex_lock(&dev->link_lock);
1068 dev->opened = 1;
1066 1069
1067 /* XXX Start PHY polling now. Shouldn't wr do like sungem instead and 1070 /* Start PHY polling now.
1068 * always poll the PHY even when the iface is down ? That would allow
1069 * things like laptop-net to work. --BenH
1070 */ 1071 */
1071 if (dev->phy.address >= 0) { 1072 if (dev->phy.address >= 0) {
1072 int link_poll_interval; 1073 int link_poll_interval;
@@ -1145,9 +1146,11 @@ static void emac_link_timer(struct work_struct *work)
1145 int link_poll_interval; 1146 int link_poll_interval;
1146 1147
1147 mutex_lock(&dev->link_lock); 1148 mutex_lock(&dev->link_lock);
1148
1149 DBG2(dev, "link timer" NL); 1149 DBG2(dev, "link timer" NL);
1150 1150
1151 if (!dev->opened)
1152 goto bail;
1153
1151 if (dev->phy.def->ops->poll_link(&dev->phy)) { 1154 if (dev->phy.def->ops->poll_link(&dev->phy)) {
1152 if (!netif_carrier_ok(dev->ndev)) { 1155 if (!netif_carrier_ok(dev->ndev)) {
1153 /* Get new link parameters */ 1156 /* Get new link parameters */
@@ -1170,13 +1173,14 @@ static void emac_link_timer(struct work_struct *work)
1170 link_poll_interval = PHY_POLL_LINK_OFF; 1173 link_poll_interval = PHY_POLL_LINK_OFF;
1171 } 1174 }
1172 schedule_delayed_work(&dev->link_work, link_poll_interval); 1175 schedule_delayed_work(&dev->link_work, link_poll_interval);
1173 1176 bail:
1174 mutex_unlock(&dev->link_lock); 1177 mutex_unlock(&dev->link_lock);
1175} 1178}
1176 1179
1177static void emac_force_link_update(struct emac_instance *dev) 1180static void emac_force_link_update(struct emac_instance *dev)
1178{ 1181{
1179 netif_carrier_off(dev->ndev); 1182 netif_carrier_off(dev->ndev);
1183 smp_rmb();
1180 if (dev->link_polling) { 1184 if (dev->link_polling) {
1181 cancel_rearming_delayed_work(&dev->link_work); 1185 cancel_rearming_delayed_work(&dev->link_work);
1182 if (dev->link_polling) 1186 if (dev->link_polling)
@@ -1191,11 +1195,14 @@ static int emac_close(struct net_device *ndev)
1191 1195
1192 DBG(dev, "close" NL); 1196 DBG(dev, "close" NL);
1193 1197
1194 if (dev->phy.address >= 0) 1198 if (dev->phy.address >= 0) {
1199 dev->link_polling = 0;
1195 cancel_rearming_delayed_work(&dev->link_work); 1200 cancel_rearming_delayed_work(&dev->link_work);
1196 1201 }
1202 mutex_lock(&dev->link_lock);
1197 emac_netif_stop(dev); 1203 emac_netif_stop(dev);
1198 flush_scheduled_work(); 1204 dev->opened = 0;
1205 mutex_unlock(&dev->link_lock);
1199 1206
1200 emac_rx_disable(dev); 1207 emac_rx_disable(dev);
1201 emac_tx_disable(dev); 1208 emac_tx_disable(dev);
@@ -2756,6 +2763,8 @@ static int __devexit emac_remove(struct of_device *ofdev)
2756 2763
2757 unregister_netdev(dev->ndev); 2764 unregister_netdev(dev->ndev);
2758 2765
2766 flush_scheduled_work();
2767
2759 if (emac_has_feature(dev, EMAC_FTR_HAS_TAH)) 2768 if (emac_has_feature(dev, EMAC_FTR_HAS_TAH))
2760 tah_detach(dev->tah_dev, dev->tah_port); 2769 tah_detach(dev->tah_dev, dev->tah_port);
2761 if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII)) 2770 if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII))
diff --git a/drivers/net/ibm_newemac/core.h b/drivers/net/ibm_newemac/core.h
index 4011803117ca..a010b2463fd9 100644
--- a/drivers/net/ibm_newemac/core.h
+++ b/drivers/net/ibm_newemac/core.h
@@ -258,6 +258,7 @@ struct emac_instance {
258 int stop_timeout; /* in us */ 258 int stop_timeout; /* in us */
259 int no_mcast; 259 int no_mcast;
260 int mcast_pending; 260 int mcast_pending;
261 int opened;
261 struct work_struct reset_work; 262 struct work_struct reset_work;
262 spinlock_t lock; 263 spinlock_t lock;
263}; 264};
diff --git a/drivers/net/lib82596.c b/drivers/net/lib82596.c
index 9a855e512147..b59f442bbf36 100644
--- a/drivers/net/lib82596.c
+++ b/drivers/net/lib82596.c
@@ -176,8 +176,8 @@ struct i596_reg {
176struct i596_tbd { 176struct i596_tbd {
177 unsigned short size; 177 unsigned short size;
178 unsigned short pad; 178 unsigned short pad;
179 dma_addr_t next; 179 u32 next;
180 dma_addr_t data; 180 u32 data;
181 u32 cache_pad[5]; /* Total 32 bytes... */ 181 u32 cache_pad[5]; /* Total 32 bytes... */
182}; 182};
183 183
@@ -195,12 +195,12 @@ struct i596_cmd {
195 struct i596_cmd *v_next; /* Address from CPUs viewpoint */ 195 struct i596_cmd *v_next; /* Address from CPUs viewpoint */
196 unsigned short status; 196 unsigned short status;
197 unsigned short command; 197 unsigned short command;
198 dma_addr_t b_next; /* Address from i596 viewpoint */ 198 u32 b_next; /* Address from i596 viewpoint */
199}; 199};
200 200
201struct tx_cmd { 201struct tx_cmd {
202 struct i596_cmd cmd; 202 struct i596_cmd cmd;
203 dma_addr_t tbd; 203 u32 tbd;
204 unsigned short size; 204 unsigned short size;
205 unsigned short pad; 205 unsigned short pad;
206 struct sk_buff *skb; /* So we can free it after tx */ 206 struct sk_buff *skb; /* So we can free it after tx */
@@ -237,8 +237,8 @@ struct cf_cmd {
237struct i596_rfd { 237struct i596_rfd {
238 unsigned short stat; 238 unsigned short stat;
239 unsigned short cmd; 239 unsigned short cmd;
240 dma_addr_t b_next; /* Address from i596 viewpoint */ 240 u32 b_next; /* Address from i596 viewpoint */
241 dma_addr_t rbd; 241 u32 rbd;
242 unsigned short count; 242 unsigned short count;
243 unsigned short size; 243 unsigned short size;
244 struct i596_rfd *v_next; /* Address from CPUs viewpoint */ 244 struct i596_rfd *v_next; /* Address from CPUs viewpoint */
@@ -249,18 +249,18 @@ struct i596_rfd {
249}; 249};
250 250
251struct i596_rbd { 251struct i596_rbd {
252 /* hardware data */ 252 /* hardware data */
253 unsigned short count; 253 unsigned short count;
254 unsigned short zero1; 254 unsigned short zero1;
255 dma_addr_t b_next; 255 u32 b_next;
256 dma_addr_t b_data; /* Address from i596 viewpoint */ 256 u32 b_data; /* Address from i596 viewpoint */
257 unsigned short size; 257 unsigned short size;
258 unsigned short zero2; 258 unsigned short zero2;
259 /* driver data */ 259 /* driver data */
260 struct sk_buff *skb; 260 struct sk_buff *skb;
261 struct i596_rbd *v_next; 261 struct i596_rbd *v_next;
262 dma_addr_t b_addr; /* This rbd addr from i596 view */ 262 u32 b_addr; /* This rbd addr from i596 view */
263 unsigned char *v_data; /* Address from CPUs viewpoint */ 263 unsigned char *v_data; /* Address from CPUs viewpoint */
264 /* Total 32 bytes... */ 264 /* Total 32 bytes... */
265#ifdef __LP64__ 265#ifdef __LP64__
266 u32 cache_pad[4]; 266 u32 cache_pad[4];
@@ -275,8 +275,8 @@ struct i596_rbd {
275struct i596_scb { 275struct i596_scb {
276 unsigned short status; 276 unsigned short status;
277 unsigned short command; 277 unsigned short command;
278 dma_addr_t cmd; 278 u32 cmd;
279 dma_addr_t rfd; 279 u32 rfd;
280 u32 crc_err; 280 u32 crc_err;
281 u32 align_err; 281 u32 align_err;
282 u32 resource_err; 282 u32 resource_err;
@@ -288,14 +288,14 @@ struct i596_scb {
288}; 288};
289 289
290struct i596_iscp { 290struct i596_iscp {
291 u32 stat; 291 u32 stat;
292 dma_addr_t scb; 292 u32 scb;
293}; 293};
294 294
295struct i596_scp { 295struct i596_scp {
296 u32 sysbus; 296 u32 sysbus;
297 u32 pad; 297 u32 pad;
298 dma_addr_t iscp; 298 u32 iscp;
299}; 299};
300 300
301struct i596_dma { 301struct i596_dma {
diff --git a/drivers/net/mlx4/qp.c b/drivers/net/mlx4/qp.c
index 42b47639c81c..fa24e6597591 100644
--- a/drivers/net/mlx4/qp.c
+++ b/drivers/net/mlx4/qp.c
@@ -113,7 +113,7 @@ int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
113 struct mlx4_cmd_mailbox *mailbox; 113 struct mlx4_cmd_mailbox *mailbox;
114 int ret = 0; 114 int ret = 0;
115 115
116 if (cur_state >= MLX4_QP_NUM_STATE || cur_state >= MLX4_QP_NUM_STATE || 116 if (cur_state >= MLX4_QP_NUM_STATE || new_state >= MLX4_QP_NUM_STATE ||
117 !op[cur_state][new_state]) 117 !op[cur_state][new_state])
118 return -EINVAL; 118 return -EINVAL;
119 119
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 035fd41fb61f..f0574073a2a3 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -143,21 +143,29 @@ static int m88e1111_config_init(struct phy_device *phydev)
143 int err; 143 int err;
144 144
145 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) || 145 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
146 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)) { 146 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
147 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
148 (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
147 int temp; 149 int temp;
148 150
149 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { 151 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
150 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR); 152 if (temp < 0)
151 if (temp < 0) 153 return temp;
152 return temp;
153 154
155 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
154 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY); 156 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
155 157 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
156 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp); 158 temp &= ~MII_M1111_TX_DELAY;
157 if (err < 0) 159 temp |= MII_M1111_RX_DELAY;
158 return err; 160 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
161 temp &= ~MII_M1111_RX_DELAY;
162 temp |= MII_M1111_TX_DELAY;
159 } 163 }
160 164
165 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
166 if (err < 0)
167 return err;
168
161 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); 169 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
162 if (temp < 0) 170 if (temp < 0)
163 return temp; 171 return temp;
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 9bc11773705b..7c9e6e349503 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -406,6 +406,9 @@ int phy_mii_ioctl(struct phy_device *phydev,
406 && phydev->drv->config_init) 406 && phydev->drv->config_init)
407 phydev->drv->config_init(phydev); 407 phydev->drv->config_init(phydev);
408 break; 408 break;
409
410 default:
411 return -ENOTTY;
409 } 412 }
410 413
411 return 0; 414 return 0;
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 5071fcd8a0bd..57c98669984d 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -663,7 +663,7 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl,
663 case PLIP_PK_DONE: 663 case PLIP_PK_DONE:
664 /* Inform the upper layer for the arrival of a packet. */ 664 /* Inform the upper layer for the arrival of a packet. */
665 rcv->skb->protocol=plip_type_trans(rcv->skb, dev); 665 rcv->skb->protocol=plip_type_trans(rcv->skb, dev);
666 netif_rx(rcv->skb); 666 netif_rx_ni(rcv->skb);
667 dev->last_rx = jiffies; 667 dev->last_rx = jiffies;
668 dev->stats.rx_bytes += rcv->length.h; 668 dev->stats.rx_bytes += rcv->length.h;
669 dev->stats.rx_packets++; 669 dev->stats.rx_packets++;
@@ -1269,7 +1269,7 @@ static void plip_attach (struct parport *port)
1269 1269
1270 nl = netdev_priv(dev); 1270 nl = netdev_priv(dev);
1271 nl->dev = dev; 1271 nl->dev = dev;
1272 nl->pardev = parport_register_device(port, name, plip_preempt, 1272 nl->pardev = parport_register_device(port, dev->name, plip_preempt,
1273 plip_wakeup, plip_interrupt, 1273 plip_wakeup, plip_interrupt,
1274 0, dev); 1274 0, dev);
1275 1275
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 632666706247..d5113dd712c2 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -1081,7 +1081,7 @@ static int init_nic(struct s2io_nic *nic)
1081 /* to set the swapper controle on the card */ 1081 /* to set the swapper controle on the card */
1082 if(s2io_set_swapper(nic)) { 1082 if(s2io_set_swapper(nic)) {
1083 DBG_PRINT(ERR_DBG,"ERROR: Setting Swapper failed\n"); 1083 DBG_PRINT(ERR_DBG,"ERROR: Setting Swapper failed\n");
1084 return -1; 1084 return -EIO;
1085 } 1085 }
1086 1086
1087 /* 1087 /*
@@ -1503,7 +1503,7 @@ static int init_nic(struct s2io_nic *nic)
1503 DBG_PRINT(ERR_DBG, "%s: failed rts ds steering", 1503 DBG_PRINT(ERR_DBG, "%s: failed rts ds steering",
1504 dev->name); 1504 dev->name);
1505 DBG_PRINT(ERR_DBG, "set on codepoint %d\n", i); 1505 DBG_PRINT(ERR_DBG, "set on codepoint %d\n", i);
1506 return FAILURE; 1506 return -ENODEV;
1507 } 1507 }
1508 } 1508 }
1509 1509
@@ -1570,7 +1570,7 @@ static int init_nic(struct s2io_nic *nic)
1570 if (time > 10) { 1570 if (time > 10) {
1571 DBG_PRINT(ERR_DBG, "%s: TTI init Failed\n", 1571 DBG_PRINT(ERR_DBG, "%s: TTI init Failed\n",
1572 dev->name); 1572 dev->name);
1573 return -1; 1573 return -ENODEV;
1574 } 1574 }
1575 msleep(50); 1575 msleep(50);
1576 time++; 1576 time++;
@@ -1623,7 +1623,7 @@ static int init_nic(struct s2io_nic *nic)
1623 if (time > 10) { 1623 if (time > 10) {
1624 DBG_PRINT(ERR_DBG, "%s: RTI init Failed\n", 1624 DBG_PRINT(ERR_DBG, "%s: RTI init Failed\n",
1625 dev->name); 1625 dev->name);
1626 return -1; 1626 return -ENODEV;
1627 } 1627 }
1628 time++; 1628 time++;
1629 msleep(50); 1629 msleep(50);
@@ -3914,6 +3914,12 @@ static int s2io_close(struct net_device *dev)
3914{ 3914{
3915 struct s2io_nic *sp = dev->priv; 3915 struct s2io_nic *sp = dev->priv;
3916 3916
3917 /* Return if the device is already closed *
3918 * Can happen when s2io_card_up failed in change_mtu *
3919 */
3920 if (!is_s2io_card_up(sp))
3921 return 0;
3922
3917 netif_stop_queue(dev); 3923 netif_stop_queue(dev);
3918 napi_disable(&sp->napi); 3924 napi_disable(&sp->napi);
3919 /* Reset card, kill tasklet and free Tx and Rx buffers. */ 3925 /* Reset card, kill tasklet and free Tx and Rx buffers. */
@@ -6355,6 +6361,7 @@ static int s2io_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
6355static int s2io_change_mtu(struct net_device *dev, int new_mtu) 6361static int s2io_change_mtu(struct net_device *dev, int new_mtu)
6356{ 6362{
6357 struct s2io_nic *sp = dev->priv; 6363 struct s2io_nic *sp = dev->priv;
6364 int ret = 0;
6358 6365
6359 if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) { 6366 if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) {
6360 DBG_PRINT(ERR_DBG, "%s: MTU size is invalid.\n", 6367 DBG_PRINT(ERR_DBG, "%s: MTU size is invalid.\n",
@@ -6366,9 +6373,11 @@ static int s2io_change_mtu(struct net_device *dev, int new_mtu)
6366 if (netif_running(dev)) { 6373 if (netif_running(dev)) {
6367 s2io_card_down(sp); 6374 s2io_card_down(sp);
6368 netif_stop_queue(dev); 6375 netif_stop_queue(dev);
6369 if (s2io_card_up(sp)) { 6376 ret = s2io_card_up(sp);
6377 if (ret) {
6370 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n", 6378 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n",
6371 __FUNCTION__); 6379 __FUNCTION__);
6380 return ret;
6372 } 6381 }
6373 if (netif_queue_stopped(dev)) 6382 if (netif_queue_stopped(dev))
6374 netif_wake_queue(dev); 6383 netif_wake_queue(dev);
@@ -6379,7 +6388,7 @@ static int s2io_change_mtu(struct net_device *dev, int new_mtu)
6379 writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len); 6388 writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len);
6380 } 6389 }
6381 6390
6382 return 0; 6391 return ret;
6383} 6392}
6384 6393
6385/** 6394/**
@@ -6777,6 +6786,9 @@ static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
6777 unsigned long flags; 6786 unsigned long flags;
6778 register u64 val64 = 0; 6787 register u64 val64 = 0;
6779 6788
6789 if (!is_s2io_card_up(sp))
6790 return;
6791
6780 del_timer_sync(&sp->alarm_timer); 6792 del_timer_sync(&sp->alarm_timer);
6781 /* If s2io_set_link task is executing, wait till it completes. */ 6793 /* If s2io_set_link task is executing, wait till it completes. */
6782 while (test_and_set_bit(__S2IO_STATE_LINK_TASK, &(sp->state))) { 6794 while (test_and_set_bit(__S2IO_STATE_LINK_TASK, &(sp->state))) {
@@ -6850,11 +6862,13 @@ static int s2io_card_up(struct s2io_nic * sp)
6850 u16 interruptible; 6862 u16 interruptible;
6851 6863
6852 /* Initialize the H/W I/O registers */ 6864 /* Initialize the H/W I/O registers */
6853 if (init_nic(sp) != 0) { 6865 ret = init_nic(sp);
6866 if (ret != 0) {
6854 DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n", 6867 DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n",
6855 dev->name); 6868 dev->name);
6856 s2io_reset(sp); 6869 if (ret != -EIO)
6857 return -ENODEV; 6870 s2io_reset(sp);
6871 return ret;
6858 } 6872 }
6859 6873
6860 /* 6874 /*
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 6d62250fba07..186eb8ebfda6 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -44,7 +44,7 @@
44#include "skge.h" 44#include "skge.h"
45 45
46#define DRV_NAME "skge" 46#define DRV_NAME "skge"
47#define DRV_VERSION "1.12" 47#define DRV_VERSION "1.13"
48#define PFX DRV_NAME " " 48#define PFX DRV_NAME " "
49 49
50#define DEFAULT_TX_RING_SIZE 128 50#define DEFAULT_TX_RING_SIZE 128
@@ -1095,16 +1095,9 @@ static void xm_link_down(struct skge_hw *hw, int port)
1095{ 1095{
1096 struct net_device *dev = hw->dev[port]; 1096 struct net_device *dev = hw->dev[port];
1097 struct skge_port *skge = netdev_priv(dev); 1097 struct skge_port *skge = netdev_priv(dev);
1098 u16 cmd = xm_read16(hw, port, XM_MMU_CMD);
1099 1098
1100 xm_write16(hw, port, XM_IMSK, XM_IMSK_DISABLE); 1099 xm_write16(hw, port, XM_IMSK, XM_IMSK_DISABLE);
1101 1100
1102 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1103 xm_write16(hw, port, XM_MMU_CMD, cmd);
1104
1105 /* dummy read to ensure writing */
1106 xm_read16(hw, port, XM_MMU_CMD);
1107
1108 if (netif_carrier_ok(dev)) 1101 if (netif_carrier_ok(dev))
1109 skge_link_down(skge); 1102 skge_link_down(skge);
1110} 1103}
@@ -1194,6 +1187,7 @@ static void genesis_init(struct skge_hw *hw)
1194static void genesis_reset(struct skge_hw *hw, int port) 1187static void genesis_reset(struct skge_hw *hw, int port)
1195{ 1188{
1196 const u8 zero[8] = { 0 }; 1189 const u8 zero[8] = { 0 };
1190 u32 reg;
1197 1191
1198 skge_write8(hw, SK_REG(port, GMAC_IRQ_MSK), 0); 1192 skge_write8(hw, SK_REG(port, GMAC_IRQ_MSK), 0);
1199 1193
@@ -1209,6 +1203,11 @@ static void genesis_reset(struct skge_hw *hw, int port)
1209 xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff); 1203 xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff);
1210 1204
1211 xm_outhash(hw, port, XM_HSM, zero); 1205 xm_outhash(hw, port, XM_HSM, zero);
1206
1207 /* Flush TX and RX fifo */
1208 reg = xm_read32(hw, port, XM_MODE);
1209 xm_write32(hw, port, XM_MODE, reg | XM_MD_FTF);
1210 xm_write32(hw, port, XM_MODE, reg | XM_MD_FRF);
1212} 1211}
1213 1212
1214 1213
@@ -1634,15 +1633,14 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1634 } 1633 }
1635 xm_write16(hw, port, XM_RX_CMD, r); 1634 xm_write16(hw, port, XM_RX_CMD, r);
1636 1635
1637
1638 /* We want short frames padded to 60 bytes. */ 1636 /* We want short frames padded to 60 bytes. */
1639 xm_write16(hw, port, XM_TX_CMD, XM_TX_AUTO_PAD); 1637 xm_write16(hw, port, XM_TX_CMD, XM_TX_AUTO_PAD);
1640 1638
1641 /* 1639 /* Increase threshold for jumbo frames on dual port */
1642 * Bump up the transmit threshold. This helps hold off transmit 1640 if (hw->ports > 1 && jumbo)
1643 * underruns when we're blasting traffic from both ports at once. 1641 xm_write16(hw, port, XM_TX_THR, 1020);
1644 */ 1642 else
1645 xm_write16(hw, port, XM_TX_THR, 512); 1643 xm_write16(hw, port, XM_TX_THR, 512);
1646 1644
1647 /* 1645 /*
1648 * Enable the reception of all error frames. This is is 1646 * Enable the reception of all error frames. This is is
@@ -1713,7 +1711,13 @@ static void genesis_stop(struct skge_port *skge)
1713{ 1711{
1714 struct skge_hw *hw = skge->hw; 1712 struct skge_hw *hw = skge->hw;
1715 int port = skge->port; 1713 int port = skge->port;
1716 u32 reg; 1714 unsigned retries = 1000;
1715 u16 cmd;
1716
1717 /* Disable Tx and Rx */
1718 cmd = xm_read16(hw, port, XM_MMU_CMD);
1719 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1720 xm_write16(hw, port, XM_MMU_CMD, cmd);
1717 1721
1718 genesis_reset(hw, port); 1722 genesis_reset(hw, port);
1719 1723
@@ -1721,20 +1725,17 @@ static void genesis_stop(struct skge_port *skge)
1721 skge_write16(hw, B3_PA_CTRL, 1725 skge_write16(hw, B3_PA_CTRL,
1722 port == 0 ? PA_CLR_TO_TX1 : PA_CLR_TO_TX2); 1726 port == 0 ? PA_CLR_TO_TX1 : PA_CLR_TO_TX2);
1723 1727
1724 /*
1725 * If the transfer sticks at the MAC the STOP command will not
1726 * terminate if we don't flush the XMAC's transmit FIFO !
1727 */
1728 xm_write32(hw, port, XM_MODE,
1729 xm_read32(hw, port, XM_MODE)|XM_MD_FTF);
1730
1731
1732 /* Reset the MAC */ 1728 /* Reset the MAC */
1733 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_SET_MAC_RST); 1729 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_CLR_MAC_RST);
1730 do {
1731 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_SET_MAC_RST);
1732 if (!(skge_read16(hw, SK_REG(port, TX_MFF_CTRL1)) & MFF_SET_MAC_RST))
1733 break;
1734 } while (--retries > 0);
1734 1735
1735 /* For external PHYs there must be special handling */ 1736 /* For external PHYs there must be special handling */
1736 if (hw->phy_type != SK_PHY_XMAC) { 1737 if (hw->phy_type != SK_PHY_XMAC) {
1737 reg = skge_read32(hw, B2_GP_IO); 1738 u32 reg = skge_read32(hw, B2_GP_IO);
1738 if (port == 0) { 1739 if (port == 0) {
1739 reg |= GP_DIR_0; 1740 reg |= GP_DIR_0;
1740 reg &= ~GP_IO_0; 1741 reg &= ~GP_IO_0;
@@ -1801,11 +1802,6 @@ static void genesis_mac_intr(struct skge_hw *hw, int port)
1801 xm_write32(hw, port, XM_MODE, XM_MD_FTF); 1802 xm_write32(hw, port, XM_MODE, XM_MD_FTF);
1802 ++dev->stats.tx_fifo_errors; 1803 ++dev->stats.tx_fifo_errors;
1803 } 1804 }
1804
1805 if (status & XM_IS_RXF_OV) {
1806 xm_write32(hw, port, XM_MODE, XM_MD_FRF);
1807 ++dev->stats.rx_fifo_errors;
1808 }
1809} 1805}
1810 1806
1811static void genesis_link_up(struct skge_port *skge) 1807static void genesis_link_up(struct skge_port *skge)
@@ -1862,9 +1858,9 @@ static void genesis_link_up(struct skge_port *skge)
1862 1858
1863 xm_write32(hw, port, XM_MODE, mode); 1859 xm_write32(hw, port, XM_MODE, mode);
1864 1860
1865 /* Turn on detection of Tx underrun, Rx overrun */ 1861 /* Turn on detection of Tx underrun */
1866 msk = xm_read16(hw, port, XM_IMSK); 1862 msk = xm_read16(hw, port, XM_IMSK);
1867 msk &= ~(XM_IS_RXF_OV | XM_IS_TXF_UR); 1863 msk &= ~XM_IS_TXF_UR;
1868 xm_write16(hw, port, XM_IMSK, msk); 1864 xm_write16(hw, port, XM_IMSK, msk);
1869 1865
1870 xm_read16(hw, port, XM_ISRC); 1866 xm_read16(hw, port, XM_ISRC);
@@ -2194,9 +2190,12 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
2194 TX_JAM_IPG_VAL(TX_JAM_IPG_DEF) | 2190 TX_JAM_IPG_VAL(TX_JAM_IPG_DEF) |
2195 TX_IPG_JAM_DATA(TX_IPG_JAM_DEF)); 2191 TX_IPG_JAM_DATA(TX_IPG_JAM_DEF));
2196 2192
2197 /* serial mode register */ 2193 /* configure the Serial Mode Register */
2198 reg = GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); 2194 reg = DATA_BLIND_VAL(DATA_BLIND_DEF)
2199 if (hw->dev[port]->mtu > 1500) 2195 | GM_SMOD_VLAN_ENA
2196 | IPG_DATA_VAL(IPG_DATA_DEF);
2197
2198 if (hw->dev[port]->mtu > ETH_DATA_LEN)
2200 reg |= GM_SMOD_JUMBO_ENA; 2199 reg |= GM_SMOD_JUMBO_ENA;
2201 2200
2202 gma_write16(hw, port, GM_SERIAL_MODE, reg); 2201 gma_write16(hw, port, GM_SERIAL_MODE, reg);
@@ -2619,8 +2618,8 @@ static int skge_up(struct net_device *dev)
2619 yukon_mac_init(hw, port); 2618 yukon_mac_init(hw, port);
2620 spin_unlock_bh(&hw->phy_lock); 2619 spin_unlock_bh(&hw->phy_lock);
2621 2620
2622 /* Configure RAMbuffers */ 2621 /* Configure RAMbuffers - equally between ports and tx/rx */
2623 chunk = hw->ram_size / ((hw->ports + 1)*2); 2622 chunk = (hw->ram_size - hw->ram_offset) / (hw->ports * 2);
2624 ram_addr = hw->ram_offset + 2 * chunk * port; 2623 ram_addr = hw->ram_offset + 2 * chunk * port;
2625 2624
2626 skge_ramset(hw, rxqaddr[port], ram_addr, chunk); 2625 skge_ramset(hw, rxqaddr[port], ram_addr, chunk);
@@ -2897,11 +2896,7 @@ static void skge_tx_timeout(struct net_device *dev)
2897 2896
2898static int skge_change_mtu(struct net_device *dev, int new_mtu) 2897static int skge_change_mtu(struct net_device *dev, int new_mtu)
2899{ 2898{
2900 struct skge_port *skge = netdev_priv(dev);
2901 struct skge_hw *hw = skge->hw;
2902 int port = skge->port;
2903 int err; 2899 int err;
2904 u16 ctl, reg;
2905 2900
2906 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) 2901 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
2907 return -EINVAL; 2902 return -EINVAL;
@@ -2911,40 +2906,13 @@ static int skge_change_mtu(struct net_device *dev, int new_mtu)
2911 return 0; 2906 return 0;
2912 } 2907 }
2913 2908
2914 skge_write32(hw, B0_IMSK, 0); 2909 skge_down(dev);
2915 dev->trans_start = jiffies; /* prevent tx timeout */
2916 netif_stop_queue(dev);
2917 napi_disable(&skge->napi);
2918
2919 ctl = gma_read16(hw, port, GM_GP_CTRL);
2920 gma_write16(hw, port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA);
2921
2922 skge_rx_clean(skge);
2923 skge_rx_stop(hw, port);
2924 2910
2925 dev->mtu = new_mtu; 2911 dev->mtu = new_mtu;
2926 2912
2927 reg = GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); 2913 err = skge_up(dev);
2928 if (new_mtu > 1500)
2929 reg |= GM_SMOD_JUMBO_ENA;
2930 gma_write16(hw, port, GM_SERIAL_MODE, reg);
2931
2932 skge_write8(hw, RB_ADDR(rxqaddr[port], RB_CTRL), RB_ENA_OP_MD);
2933
2934 err = skge_rx_fill(dev);
2935 wmb();
2936 if (!err)
2937 skge_write8(hw, Q_ADDR(rxqaddr[port], Q_CSR), CSR_START | CSR_IRQ_CL_F);
2938 skge_write32(hw, B0_IMSK, hw->intr_mask);
2939
2940 if (err) 2914 if (err)
2941 dev_close(dev); 2915 dev_close(dev);
2942 else {
2943 gma_write16(hw, port, GM_GP_CTRL, ctl);
2944
2945 napi_enable(&skge->napi);
2946 netif_wake_queue(dev);
2947 }
2948 2916
2949 return err; 2917 return err;
2950} 2918}
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index a2070db725c9..3d1dfc948405 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -31,7 +31,6 @@
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/ethtool.h> 32#include <linux/ethtool.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/aer.h>
35#include <linux/ip.h> 34#include <linux/ip.h>
36#include <net/ip.h> 35#include <net/ip.h>
37#include <linux/tcp.h> 36#include <linux/tcp.h>
@@ -240,22 +239,21 @@ static void sky2_power_on(struct sky2_hw *hw)
240 sky2_write8(hw, B2_Y2_CLK_GATE, 0); 239 sky2_write8(hw, B2_Y2_CLK_GATE, 0);
241 240
242 if (hw->flags & SKY2_HW_ADV_POWER_CTL) { 241 if (hw->flags & SKY2_HW_ADV_POWER_CTL) {
243 struct pci_dev *pdev = hw->pdev;
244 u32 reg; 242 u32 reg;
245 243
246 pci_write_config_dword(pdev, PCI_DEV_REG3, 0); 244 sky2_pci_write32(hw, PCI_DEV_REG3, 0);
247 245
248 pci_read_config_dword(pdev, PCI_DEV_REG4, &reg); 246 reg = sky2_pci_read32(hw, PCI_DEV_REG4);
249 /* set all bits to 0 except bits 15..12 and 8 */ 247 /* set all bits to 0 except bits 15..12 and 8 */
250 reg &= P_ASPM_CONTROL_MSK; 248 reg &= P_ASPM_CONTROL_MSK;
251 pci_write_config_dword(pdev, PCI_DEV_REG4, reg); 249 sky2_pci_write32(hw, PCI_DEV_REG4, reg);
252 250
253 pci_read_config_dword(pdev, PCI_DEV_REG5, &reg); 251 reg = sky2_pci_read32(hw, PCI_DEV_REG5);
254 /* set all bits to 0 except bits 28 & 27 */ 252 /* set all bits to 0 except bits 28 & 27 */
255 reg &= P_CTL_TIM_VMAIN_AV_MSK; 253 reg &= P_CTL_TIM_VMAIN_AV_MSK;
256 pci_write_config_dword(pdev, PCI_DEV_REG5, reg); 254 sky2_pci_write32(hw, PCI_DEV_REG5, reg);
257 255
258 pci_write_config_dword(pdev, PCI_CFG_REG_1, 0); 256 sky2_pci_write32(hw, PCI_CFG_REG_1, 0);
259 257
260 /* Enable workaround for dev 4.107 on Yukon-Ultra & Extreme */ 258 /* Enable workaround for dev 4.107 on Yukon-Ultra & Extreme */
261 reg = sky2_read32(hw, B2_GP_IO); 259 reg = sky2_read32(hw, B2_GP_IO);
@@ -619,12 +617,11 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
619 617
620static void sky2_phy_power(struct sky2_hw *hw, unsigned port, int onoff) 618static void sky2_phy_power(struct sky2_hw *hw, unsigned port, int onoff)
621{ 619{
622 struct pci_dev *pdev = hw->pdev;
623 u32 reg1; 620 u32 reg1;
624 static const u32 phy_power[] = { PCI_Y2_PHY1_POWD, PCI_Y2_PHY2_POWD }; 621 static const u32 phy_power[] = { PCI_Y2_PHY1_POWD, PCI_Y2_PHY2_POWD };
625 static const u32 coma_mode[] = { PCI_Y2_PHY1_COMA, PCI_Y2_PHY2_COMA }; 622 static const u32 coma_mode[] = { PCI_Y2_PHY1_COMA, PCI_Y2_PHY2_COMA };
626 623
627 pci_read_config_dword(pdev, PCI_DEV_REG1, &reg1); 624 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
628 /* Turn on/off phy power saving */ 625 /* Turn on/off phy power saving */
629 if (onoff) 626 if (onoff)
630 reg1 &= ~phy_power[port]; 627 reg1 &= ~phy_power[port];
@@ -634,8 +631,8 @@ static void sky2_phy_power(struct sky2_hw *hw, unsigned port, int onoff)
634 if (onoff && hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) 631 if (onoff && hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
635 reg1 |= coma_mode[port]; 632 reg1 |= coma_mode[port];
636 633
637 pci_write_config_dword(pdev, PCI_DEV_REG1, reg1); 634 sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
638 pci_read_config_dword(pdev, PCI_DEV_REG1, &reg1); 635 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
639 636
640 udelay(100); 637 udelay(100);
641} 638}
@@ -704,9 +701,9 @@ static void sky2_wol_init(struct sky2_port *sky2)
704 sky2_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl); 701 sky2_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl);
705 702
706 /* Turn on legacy PCI-Express PME mode */ 703 /* Turn on legacy PCI-Express PME mode */
707 pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &reg1); 704 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
708 reg1 |= PCI_Y2_PME_LEGACY; 705 reg1 |= PCI_Y2_PME_LEGACY;
709 pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1); 706 sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
710 707
711 /* block receiver */ 708 /* block receiver */
712 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET); 709 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
@@ -848,6 +845,13 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
848 sky2_set_tx_stfwd(hw, port); 845 sky2_set_tx_stfwd(hw, port);
849 } 846 }
850 847
848 if (hw->chip_id == CHIP_ID_YUKON_FE_P &&
849 hw->chip_rev == CHIP_REV_YU_FE2_A0) {
850 /* disable dynamic watermark */
851 reg = sky2_read16(hw, SK_REG(port, TX_GMF_EA));
852 reg &= ~TX_DYN_WM_ENA;
853 sky2_write16(hw, SK_REG(port, TX_GMF_EA), reg);
854 }
851} 855}
852 856
853/* Assign Ram Buffer allocation to queue */ 857/* Assign Ram Buffer allocation to queue */
@@ -1320,15 +1324,12 @@ static int sky2_up(struct net_device *dev)
1320 */ 1324 */
1321 if (otherdev && netif_running(otherdev) && 1325 if (otherdev && netif_running(otherdev) &&
1322 (cap = pci_find_capability(hw->pdev, PCI_CAP_ID_PCIX))) { 1326 (cap = pci_find_capability(hw->pdev, PCI_CAP_ID_PCIX))) {
1323 struct sky2_port *osky2 = netdev_priv(otherdev);
1324 u16 cmd; 1327 u16 cmd;
1325 1328
1326 pci_read_config_word(hw->pdev, cap + PCI_X_CMD, &cmd); 1329 cmd = sky2_pci_read16(hw, cap + PCI_X_CMD);
1327 cmd &= ~PCI_X_CMD_MAX_SPLIT; 1330 cmd &= ~PCI_X_CMD_MAX_SPLIT;
1328 pci_write_config_word(hw->pdev, cap + PCI_X_CMD, cmd); 1331 sky2_pci_write16(hw, cap + PCI_X_CMD, cmd);
1329 1332
1330 sky2->rx_csum = 0;
1331 osky2->rx_csum = 0;
1332 } 1333 }
1333 1334
1334 if (netif_msg_ifup(sky2)) 1335 if (netif_msg_ifup(sky2))
@@ -2426,37 +2427,26 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2426 if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) { 2427 if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
2427 u16 pci_err; 2428 u16 pci_err;
2428 2429
2429 pci_read_config_word(pdev, PCI_STATUS, &pci_err); 2430 pci_err = sky2_pci_read16(hw, PCI_STATUS);
2430 if (net_ratelimit()) 2431 if (net_ratelimit())
2431 dev_err(&pdev->dev, "PCI hardware error (0x%x)\n", 2432 dev_err(&pdev->dev, "PCI hardware error (0x%x)\n",
2432 pci_err); 2433 pci_err);
2433 2434
2434 pci_write_config_word(pdev, PCI_STATUS, 2435 sky2_pci_write16(hw, PCI_STATUS,
2435 pci_err | PCI_STATUS_ERROR_BITS); 2436 pci_err | PCI_STATUS_ERROR_BITS);
2436 } 2437 }
2437 2438
2438 if (status & Y2_IS_PCI_EXP) { 2439 if (status & Y2_IS_PCI_EXP) {
2439 /* PCI-Express uncorrectable Error occurred */ 2440 /* PCI-Express uncorrectable Error occurred */
2440 int aer = pci_find_aer_capability(hw->pdev);
2441 u32 err; 2441 u32 err;
2442 2442
2443 if (aer) { 2443 err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
2444 pci_read_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS, 2444 sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
2445 &err); 2445 0xfffffffful);
2446 pci_cleanup_aer_uncorrect_error_status(pdev);
2447 } else {
2448 /* Either AER not configured, or not working
2449 * because of bad MMCONFIG, so just do recover
2450 * manually.
2451 */
2452 err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
2453 sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
2454 0xfffffffful);
2455 }
2456
2457 if (net_ratelimit()) 2446 if (net_ratelimit())
2458 dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err); 2447 dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err);
2459 2448
2449 sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
2460 } 2450 }
2461 2451
2462 if (status & Y2_HWE_L1_MASK) 2452 if (status & Y2_HWE_L1_MASK)
@@ -2703,13 +2693,10 @@ static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
2703 2693
2704static int __devinit sky2_init(struct sky2_hw *hw) 2694static int __devinit sky2_init(struct sky2_hw *hw)
2705{ 2695{
2706 int rc;
2707 u8 t8; 2696 u8 t8;
2708 2697
2709 /* Enable all clocks and check for bad PCI access */ 2698 /* Enable all clocks and check for bad PCI access */
2710 rc = pci_write_config_dword(hw->pdev, PCI_DEV_REG3, 0); 2699 sky2_pci_write32(hw, PCI_DEV_REG3, 0);
2711 if (rc)
2712 return rc;
2713 2700
2714 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2701 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2715 2702
@@ -2806,32 +2793,21 @@ static void sky2_reset(struct sky2_hw *hw)
2806 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 2793 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2807 2794
2808 /* clear PCI errors, if any */ 2795 /* clear PCI errors, if any */
2809 pci_read_config_word(pdev, PCI_STATUS, &status); 2796 status = sky2_pci_read16(hw, PCI_STATUS);
2810 status |= PCI_STATUS_ERROR_BITS; 2797 status |= PCI_STATUS_ERROR_BITS;
2811 pci_write_config_word(pdev, PCI_STATUS, status); 2798 sky2_pci_write16(hw, PCI_STATUS, status);
2812 2799
2813 sky2_write8(hw, B0_CTST, CS_MRST_CLR); 2800 sky2_write8(hw, B0_CTST, CS_MRST_CLR);
2814 2801
2815 cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); 2802 cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
2816 if (cap) { 2803 if (cap) {
2817 if (pci_find_aer_capability(pdev)) { 2804 sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
2818 /* Check for advanced error reporting */ 2805 0xfffffffful);
2819 pci_cleanup_aer_uncorrect_error_status(pdev);
2820 pci_cleanup_aer_correct_error_status(pdev);
2821 } else {
2822 dev_warn(&pdev->dev,
2823 "PCI Express Advanced Error Reporting"
2824 " not configured or MMCONFIG problem?\n");
2825
2826 sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
2827 0xfffffffful);
2828 }
2829 2806
2830 /* If error bit is stuck on ignore it */ 2807 /* If error bit is stuck on ignore it */
2831 if (sky2_read32(hw, B0_HWE_ISRC) & Y2_IS_PCI_EXP) 2808 if (sky2_read32(hw, B0_HWE_ISRC) & Y2_IS_PCI_EXP)
2832 dev_info(&pdev->dev, "ignoring stuck error report bit\n"); 2809 dev_info(&pdev->dev, "ignoring stuck error report bit\n");
2833 2810 else
2834 else if (pci_enable_pcie_error_reporting(pdev))
2835 hwe_mask |= Y2_IS_PCI_EXP; 2811 hwe_mask |= Y2_IS_PCI_EXP;
2836 } 2812 }
2837 2813
@@ -3672,32 +3648,33 @@ static int sky2_set_tso(struct net_device *dev, u32 data)
3672static int sky2_get_eeprom_len(struct net_device *dev) 3648static int sky2_get_eeprom_len(struct net_device *dev)
3673{ 3649{
3674 struct sky2_port *sky2 = netdev_priv(dev); 3650 struct sky2_port *sky2 = netdev_priv(dev);
3651 struct sky2_hw *hw = sky2->hw;
3675 u16 reg2; 3652 u16 reg2;
3676 3653
3677 pci_read_config_word(sky2->hw->pdev, PCI_DEV_REG2, &reg2); 3654 reg2 = sky2_pci_read16(hw, PCI_DEV_REG2);
3678 return 1 << ( ((reg2 & PCI_VPD_ROM_SZ) >> 14) + 8); 3655 return 1 << ( ((reg2 & PCI_VPD_ROM_SZ) >> 14) + 8);
3679} 3656}
3680 3657
3681static u32 sky2_vpd_read(struct pci_dev *pdev, int cap, u16 offset) 3658static u32 sky2_vpd_read(struct sky2_hw *hw, int cap, u16 offset)
3682{ 3659{
3683 u32 val; 3660 u32 val;
3684 3661
3685 pci_write_config_word(pdev, cap + PCI_VPD_ADDR, offset); 3662 sky2_pci_write16(hw, cap + PCI_VPD_ADDR, offset);
3686 3663
3687 do { 3664 do {
3688 pci_read_config_word(pdev, cap + PCI_VPD_ADDR, &offset); 3665 offset = sky2_pci_read16(hw, cap + PCI_VPD_ADDR);
3689 } while (!(offset & PCI_VPD_ADDR_F)); 3666 } while (!(offset & PCI_VPD_ADDR_F));
3690 3667
3691 pci_read_config_dword(pdev, cap + PCI_VPD_DATA, &val); 3668 val = sky2_pci_read32(hw, cap + PCI_VPD_DATA);
3692 return val; 3669 return val;
3693} 3670}
3694 3671
3695static void sky2_vpd_write(struct pci_dev *pdev, int cap, u16 offset, u32 val) 3672static void sky2_vpd_write(struct sky2_hw *hw, int cap, u16 offset, u32 val)
3696{ 3673{
3697 pci_write_config_word(pdev, cap + PCI_VPD_DATA, val); 3674 sky2_pci_write16(hw, cap + PCI_VPD_DATA, val);
3698 pci_write_config_dword(pdev, cap + PCI_VPD_ADDR, offset | PCI_VPD_ADDR_F); 3675 sky2_pci_write32(hw, cap + PCI_VPD_ADDR, offset | PCI_VPD_ADDR_F);
3699 do { 3676 do {
3700 pci_read_config_word(pdev, cap + PCI_VPD_ADDR, &offset); 3677 offset = sky2_pci_read16(hw, cap + PCI_VPD_ADDR);
3701 } while (offset & PCI_VPD_ADDR_F); 3678 } while (offset & PCI_VPD_ADDR_F);
3702} 3679}
3703 3680
@@ -3715,7 +3692,7 @@ static int sky2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom
3715 eeprom->magic = SKY2_EEPROM_MAGIC; 3692 eeprom->magic = SKY2_EEPROM_MAGIC;
3716 3693
3717 while (length > 0) { 3694 while (length > 0) {
3718 u32 val = sky2_vpd_read(sky2->hw->pdev, cap, offset); 3695 u32 val = sky2_vpd_read(sky2->hw, cap, offset);
3719 int n = min_t(int, length, sizeof(val)); 3696 int n = min_t(int, length, sizeof(val));
3720 3697
3721 memcpy(data, &val, n); 3698 memcpy(data, &val, n);
@@ -3745,10 +3722,10 @@ static int sky2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom
3745 int n = min_t(int, length, sizeof(val)); 3722 int n = min_t(int, length, sizeof(val));
3746 3723
3747 if (n < sizeof(val)) 3724 if (n < sizeof(val))
3748 val = sky2_vpd_read(sky2->hw->pdev, cap, offset); 3725 val = sky2_vpd_read(sky2->hw, cap, offset);
3749 memcpy(&val, data, n); 3726 memcpy(&val, data, n);
3750 3727
3751 sky2_vpd_write(sky2->hw->pdev, cap, offset, val); 3728 sky2_vpd_write(sky2->hw, cap, offset, val);
3752 3729
3753 length -= n; 3730 length -= n;
3754 data += n; 3731 data += n;
@@ -4013,7 +3990,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
4013 sky2->duplex = -1; 3990 sky2->duplex = -1;
4014 sky2->speed = -1; 3991 sky2->speed = -1;
4015 sky2->advertising = sky2_supported_modes(hw); 3992 sky2->advertising = sky2_supported_modes(hw);
4016 sky2->rx_csum = 1; 3993 sky2->rx_csum = (hw->chip_id != CHIP_ID_YUKON_XL);
4017 sky2->wol = wol; 3994 sky2->wol = wol;
4018 3995
4019 spin_lock_init(&sky2->phy_lock); 3996 spin_lock_init(&sky2->phy_lock);
@@ -4184,9 +4161,9 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
4184 */ 4161 */
4185 { 4162 {
4186 u32 reg; 4163 u32 reg;
4187 pci_read_config_dword(pdev,PCI_DEV_REG2, &reg); 4164 reg = sky2_pci_read32(hw, PCI_DEV_REG2);
4188 reg &= ~PCI_REV_DESC; 4165 reg &= ~PCI_REV_DESC;
4189 pci_write_config_dword(pdev, PCI_DEV_REG2, reg); 4166 sky2_pci_write32(hw, PCI_DEV_REG2, reg);
4190 } 4167 }
4191#endif 4168#endif
4192 4169
@@ -4377,7 +4354,7 @@ static int sky2_resume(struct pci_dev *pdev)
4377 if (hw->chip_id == CHIP_ID_YUKON_EX || 4354 if (hw->chip_id == CHIP_ID_YUKON_EX ||
4378 hw->chip_id == CHIP_ID_YUKON_EC_U || 4355 hw->chip_id == CHIP_ID_YUKON_EC_U ||
4379 hw->chip_id == CHIP_ID_YUKON_FE_P) 4356 hw->chip_id == CHIP_ID_YUKON_FE_P)
4380 pci_write_config_dword(pdev, PCI_DEV_REG3, 0); 4357 sky2_pci_write32(hw, PCI_DEV_REG3, 0);
4381 4358
4382 sky2_reset(hw); 4359 sky2_reset(hw);
4383 sky2_write32(hw, B0_IMSK, Y2_IS_BASE); 4360 sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 69525fd7908d..bc646a47edd2 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -2128,4 +2128,25 @@ static inline void gma_set_addr(struct sky2_hw *hw, unsigned port, unsigned reg,
2128 gma_write16(hw, port, reg+4,(u16) addr[2] | ((u16) addr[3] << 8)); 2128 gma_write16(hw, port, reg+4,(u16) addr[2] | ((u16) addr[3] << 8));
2129 gma_write16(hw, port, reg+8,(u16) addr[4] | ((u16) addr[5] << 8)); 2129 gma_write16(hw, port, reg+8,(u16) addr[4] | ((u16) addr[5] << 8));
2130} 2130}
2131
2132/* PCI config space access */
2133static inline u32 sky2_pci_read32(const struct sky2_hw *hw, unsigned reg)
2134{
2135 return sky2_read32(hw, Y2_CFG_SPC + reg);
2136}
2137
2138static inline u16 sky2_pci_read16(const struct sky2_hw *hw, unsigned reg)
2139{
2140 return sky2_read16(hw, Y2_CFG_SPC + reg);
2141}
2142
2143static inline void sky2_pci_write32(struct sky2_hw *hw, unsigned reg, u32 val)
2144{
2145 sky2_write32(hw, Y2_CFG_SPC + reg, val);
2146}
2147
2148static inline void sky2_pci_write16(struct sky2_hw *hw, unsigned reg, u16 val)
2149{
2150 sky2_write16(hw, Y2_CFG_SPC + reg, val);
2151}
2131#endif 2152#endif
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index dd18af0ce676..1a3d80bfe9ea 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -428,7 +428,6 @@ static inline void smc911x_drop_pkt(struct net_device *dev)
428 */ 428 */
429static inline void smc911x_rcv(struct net_device *dev) 429static inline void smc911x_rcv(struct net_device *dev)
430{ 430{
431 struct smc911x_local *lp = netdev_priv(dev);
432 unsigned long ioaddr = dev->base_addr; 431 unsigned long ioaddr = dev->base_addr;
433 unsigned int pkt_len, status; 432 unsigned int pkt_len, status;
434 struct sk_buff *skb; 433 struct sk_buff *skb;
@@ -473,6 +472,7 @@ static inline void smc911x_rcv(struct net_device *dev)
473 skb_put(skb,pkt_len-4); 472 skb_put(skb,pkt_len-4);
474#ifdef SMC_USE_DMA 473#ifdef SMC_USE_DMA
475 { 474 {
475 struct smc911x_local *lp = netdev_priv(dev);
476 unsigned int fifo; 476 unsigned int fifo;
477 /* Lower the FIFO threshold if possible */ 477 /* Lower the FIFO threshold if possible */
478 fifo = SMC_GET_FIFO_INT(); 478 fifo = SMC_GET_FIFO_INT();
@@ -1379,13 +1379,6 @@ static void smc911x_set_multicast_list(struct net_device *dev)
1379 unsigned int multicast_table[2]; 1379 unsigned int multicast_table[2];
1380 unsigned int mcr, update_multicast = 0; 1380 unsigned int mcr, update_multicast = 0;
1381 unsigned long flags; 1381 unsigned long flags;
1382 /* table for flipping the order of 5 bits */
1383 static const unsigned char invert5[] =
1384 {0x00, 0x10, 0x08, 0x18, 0x04, 0x14, 0x0C, 0x1C,
1385 0x02, 0x12, 0x0A, 0x1A, 0x06, 0x16, 0x0E, 0x1E,
1386 0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0D, 0x1D,
1387 0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F};
1388
1389 1382
1390 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); 1383 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1391 1384
@@ -1432,7 +1425,7 @@ static void smc911x_set_multicast_list(struct net_device *dev)
1432 1425
1433 cur_addr = dev->mc_list; 1426 cur_addr = dev->mc_list;
1434 for (i = 0; i < dev->mc_count; i++, cur_addr = cur_addr->next) { 1427 for (i = 0; i < dev->mc_count; i++, cur_addr = cur_addr->next) {
1435 int position; 1428 u32 position;
1436 1429
1437 /* do we have a pointer here? */ 1430 /* do we have a pointer here? */
1438 if (!cur_addr) 1431 if (!cur_addr)
@@ -1442,12 +1435,10 @@ static void smc911x_set_multicast_list(struct net_device *dev)
1442 if (!(*cur_addr->dmi_addr & 1)) 1435 if (!(*cur_addr->dmi_addr & 1))
1443 continue; 1436 continue;
1444 1437
1445 /* only use the low order bits */ 1438 /* upper 6 bits are used as hash index */
1446 position = crc32_le(~0, cur_addr->dmi_addr, 6) & 0x3f; 1439 position = ether_crc(ETH_ALEN, cur_addr->dmi_addr)>>26;
1447 1440
1448 /* do some messy swapping to put the bit in the right spot */ 1441 multicast_table[position>>5] |= 1 << (position&0x1f);
1449 multicast_table[invert5[position&0x1F]&0x1] |=
1450 (1<<invert5[(position>>1)&0x1F]);
1451 } 1442 }
1452 1443
1453 /* be sure I get rid of flags I might have set */ 1444 /* be sure I get rid of flags I might have set */
diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
index 16a0edc078fd..d04e4fa35206 100644
--- a/drivers/net/smc911x.h
+++ b/drivers/net/smc911x.h
@@ -37,7 +37,7 @@
37 #define SMC_USE_16BIT 0 37 #define SMC_USE_16BIT 0
38 #define SMC_USE_32BIT 1 38 #define SMC_USE_32BIT 1
39 #define SMC_IRQ_SENSE IRQF_TRIGGER_FALLING 39 #define SMC_IRQ_SENSE IRQF_TRIGGER_FALLING
40#elif CONFIG_SH_MAGIC_PANEL_R2 40#elif defined(CONFIG_SH_MAGIC_PANEL_R2)
41 #define SMC_USE_SH_DMA 0 41 #define SMC_USE_SH_DMA 0
42 #define SMC_USE_16BIT 0 42 #define SMC_USE_16BIT 0
43 #define SMC_USE_32BIT 1 43 #define SMC_USE_32BIT 1
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index db34e1eb67e9..07b7f7120e37 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -55,7 +55,7 @@
55#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) 55#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
56#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) 56#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)
57 57
58#elif defined(CONFIG_BFIN) 58#elif defined(CONFIG_BLACKFIN)
59 59
60#define SMC_IRQ_FLAGS IRQF_TRIGGER_HIGH 60#define SMC_IRQ_FLAGS IRQF_TRIGGER_HIGH
61#define RPC_LSA_DEFAULT RPC_LED_100_10 61#define RPC_LSA_DEFAULT RPC_LED_100_10
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index ca90566d5bcd..b4891caeae5a 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -2118,8 +2118,8 @@ static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state)
2118 pci_enable_wake(pci_dev, PCI_D3cold, 1); 2118 pci_enable_wake(pci_dev, PCI_D3cold, 1);
2119 2119
2120 /* Power down device*/ 2120 /* Power down device*/
2121 pci_set_power_state(pci_dev, pci_choose_state (pci_dev,state));
2122 pci_save_state(pci_dev); 2121 pci_save_state(pci_dev);
2122 pci_set_power_state(pci_dev, pci_choose_state (pci_dev, state));
2123 2123
2124 return 0; 2124 return 0;
2125} 2125}
@@ -2129,8 +2129,8 @@ static int dmfe_resume(struct pci_dev *pci_dev)
2129 struct net_device *dev = pci_get_drvdata(pci_dev); 2129 struct net_device *dev = pci_get_drvdata(pci_dev);
2130 u32 tmp; 2130 u32 tmp;
2131 2131
2132 pci_restore_state(pci_dev);
2133 pci_set_power_state(pci_dev, PCI_D0); 2132 pci_set_power_state(pci_dev, PCI_D0);
2133 pci_restore_state(pci_dev);
2134 2134
2135 /* Re-initilize DM910X board */ 2135 /* Re-initilize DM910X board */
2136 dmfe_init_dm910x(dev); 2136 dmfe_init_dm910x(dev);
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index a3ff270593f1..7f689907ac28 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -1460,6 +1460,8 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1460 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) || 1460 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) ||
1461 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) || 1461 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) ||
1462 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) || 1462 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
1463 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
1464 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) ||
1463 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1465 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1464 upsmr |= UPSMR_RPM; 1466 upsmr |= UPSMR_RPM;
1465 switch (ugeth->max_speed) { 1467 switch (ugeth->max_speed) {
@@ -1557,6 +1559,8 @@ static void adjust_link(struct net_device *dev)
1557 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) || 1559 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) ||
1558 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) || 1560 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) ||
1559 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) || 1561 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
1562 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
1563 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) ||
1560 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1564 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1561 if (phydev->speed == SPEED_10) 1565 if (phydev->speed == SPEED_10)
1562 upsmr |= UPSMR_R10M; 1566 upsmr |= UPSMR_R10M;
@@ -3795,6 +3799,10 @@ static phy_interface_t to_phy_interface(const char *phy_connection_type)
3795 return PHY_INTERFACE_MODE_RGMII; 3799 return PHY_INTERFACE_MODE_RGMII;
3796 if (strcasecmp(phy_connection_type, "rgmii-id") == 0) 3800 if (strcasecmp(phy_connection_type, "rgmii-id") == 0)
3797 return PHY_INTERFACE_MODE_RGMII_ID; 3801 return PHY_INTERFACE_MODE_RGMII_ID;
3802 if (strcasecmp(phy_connection_type, "rgmii-txid") == 0)
3803 return PHY_INTERFACE_MODE_RGMII_TXID;
3804 if (strcasecmp(phy_connection_type, "rgmii-rxid") == 0)
3805 return PHY_INTERFACE_MODE_RGMII_RXID;
3798 if (strcasecmp(phy_connection_type, "rtbi") == 0) 3806 if (strcasecmp(phy_connection_type, "rtbi") == 0)
3799 return PHY_INTERFACE_MODE_RTBI; 3807 return PHY_INTERFACE_MODE_RTBI;
3800 3808
@@ -3889,6 +3897,8 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
3889 case PHY_INTERFACE_MODE_GMII: 3897 case PHY_INTERFACE_MODE_GMII:
3890 case PHY_INTERFACE_MODE_RGMII: 3898 case PHY_INTERFACE_MODE_RGMII:
3891 case PHY_INTERFACE_MODE_RGMII_ID: 3899 case PHY_INTERFACE_MODE_RGMII_ID:
3900 case PHY_INTERFACE_MODE_RGMII_RXID:
3901 case PHY_INTERFACE_MODE_RGMII_TXID:
3892 case PHY_INTERFACE_MODE_TBI: 3902 case PHY_INTERFACE_MODE_TBI:
3893 case PHY_INTERFACE_MODE_RTBI: 3903 case PHY_INTERFACE_MODE_RTBI:
3894 max_speed = SPEED_1000; 3904 max_speed = SPEED_1000;
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 2c685734b7a4..1ffdd106f4c4 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -94,7 +94,7 @@ static void dm_write_async_callback(struct urb *urb)
94 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context; 94 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
95 95
96 if (urb->status < 0) 96 if (urb->status < 0)
97 printk(KERN_DEBUG "dm_write_async_callback() failed with %d", 97 printk(KERN_DEBUG "dm_write_async_callback() failed with %d\n",
98 urb->status); 98 urb->status);
99 99
100 kfree(req); 100 kfree(req);
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 450e29d7a9f3..35cd65d6b9ed 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -1242,6 +1242,9 @@ static int velocity_rx_refill(struct velocity_info *vptr)
1242static int velocity_init_rd_ring(struct velocity_info *vptr) 1242static int velocity_init_rd_ring(struct velocity_info *vptr)
1243{ 1243{
1244 int ret; 1244 int ret;
1245 int mtu = vptr->dev->mtu;
1246
1247 vptr->rx_buf_sz = (mtu <= ETH_DATA_LEN) ? PKT_BUF_SZ : mtu + 32;
1245 1248
1246 vptr->rd_info = kcalloc(vptr->options.numrx, 1249 vptr->rd_info = kcalloc(vptr->options.numrx,
1247 sizeof(struct velocity_rd_info), GFP_KERNEL); 1250 sizeof(struct velocity_rd_info), GFP_KERNEL);
@@ -1898,8 +1901,6 @@ static int velocity_open(struct net_device *dev)
1898 struct velocity_info *vptr = netdev_priv(dev); 1901 struct velocity_info *vptr = netdev_priv(dev);
1899 int ret; 1902 int ret;
1900 1903
1901 vptr->rx_buf_sz = (dev->mtu <= 1504 ? PKT_BUF_SZ : dev->mtu + 32);
1902
1903 ret = velocity_init_rings(vptr); 1904 ret = velocity_init_rings(vptr);
1904 if (ret < 0) 1905 if (ret < 0)
1905 goto out; 1906 goto out;
@@ -1978,12 +1979,6 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu)
1978 velocity_free_rd_ring(vptr); 1979 velocity_free_rd_ring(vptr);
1979 1980
1980 dev->mtu = new_mtu; 1981 dev->mtu = new_mtu;
1981 if (new_mtu > 8192)
1982 vptr->rx_buf_sz = 9 * 1024;
1983 else if (new_mtu > 4096)
1984 vptr->rx_buf_sz = 8192;
1985 else
1986 vptr->rx_buf_sz = 4 * 1024;
1987 1982
1988 ret = velocity_init_rd_ring(vptr); 1983 ret = velocity_init_rd_ring(vptr);
1989 if (ret < 0) 1984 if (ret < 0)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index a75be57fb209..5413dbf3d4ac 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -198,8 +198,8 @@ again:
198 if (vi->num < vi->max / 2) 198 if (vi->num < vi->max / 2)
199 try_fill_recv(vi); 199 try_fill_recv(vi);
200 200
201 /* All done? */ 201 /* Out of packets? */
202 if (!skb) { 202 if (received < budget) {
203 netif_rx_complete(vi->dev, napi); 203 netif_rx_complete(vi->dev, napi);
204 if (unlikely(!vi->rvq->vq_ops->restart(vi->rvq)) 204 if (unlikely(!vi->rvq->vq_ops->restart(vi->rvq))
205 && netif_rx_reschedule(vi->dev, napi)) 205 && netif_rx_reschedule(vi->dev, napi))
@@ -404,8 +404,12 @@ free:
404 404
405static void virtnet_remove(struct virtio_device *vdev) 405static void virtnet_remove(struct virtio_device *vdev)
406{ 406{
407 unregister_netdev(vdev->priv); 407 struct virtnet_info *vi = vdev->priv;
408 free_netdev(vdev->priv); 408
409 vdev->config->del_vq(vi->svq);
410 vdev->config->del_vq(vi->rvq);
411 unregister_netdev(vi->dev);
412 free_netdev(vi->dev);
409} 413}
410 414
411static struct virtio_device_id id_table[] = { 415static struct virtio_device_id id_table[] = {
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 2b17c1dc46f1..b45eecc53c4a 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -1566,7 +1566,7 @@ static void b43_release_firmware(struct b43_wldev *dev)
1566static void b43_print_fw_helptext(struct b43_wl *wl) 1566static void b43_print_fw_helptext(struct b43_wl *wl)
1567{ 1567{
1568 b43err(wl, "You must go to " 1568 b43err(wl, "You must go to "
1569 "http://linuxwireless.org/en/users/Drivers/bcm43xx#devicefirmware " 1569 "http://linuxwireless.org/en/users/Drivers/b43#devicefirmware "
1570 "and download the correct firmware (version 4).\n"); 1570 "and download the correct firmware (version 4).\n");
1571} 1571}
1572 1572
diff --git a/drivers/net/wireless/b43/phy.c b/drivers/net/wireless/b43/phy.c
index 3d4ed647c311..7ff091e69f05 100644
--- a/drivers/net/wireless/b43/phy.c
+++ b/drivers/net/wireless/b43/phy.c
@@ -2214,7 +2214,7 @@ int b43_phy_init_tssi2dbm_table(struct b43_wldev *dev)
2214 } 2214 }
2215 dyn_tssi2dbm = kmalloc(64, GFP_KERNEL); 2215 dyn_tssi2dbm = kmalloc(64, GFP_KERNEL);
2216 if (dyn_tssi2dbm == NULL) { 2216 if (dyn_tssi2dbm == NULL) {
2217 b43err(dev->wl, "Could not allocate memory" 2217 b43err(dev->wl, "Could not allocate memory "
2218 "for tssi2dbm table\n"); 2218 "for tssi2dbm table\n");
2219 return -ENOMEM; 2219 return -ENOMEM;
2220 } 2220 }
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
index 8cb3dc4c4745..83161d9af813 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -996,7 +996,7 @@ int b43legacy_dma_init(struct b43legacy_wldev *dev)
996 996
997 err = ssb_dma_set_mask(dev->dev, dmamask); 997 err = ssb_dma_set_mask(dev->dev, dmamask);
998 if (err) { 998 if (err) {
999#ifdef BCM43XX_PIO 999#ifdef CONFIG_B43LEGACY_PIO
1000 b43legacywarn(dev->wl, "DMA for this device not supported. " 1000 b43legacywarn(dev->wl, "DMA for this device not supported. "
1001 "Falling back to PIO\n"); 1001 "Falling back to PIO\n");
1002 dev->__using_pio = 1; 1002 dev->__using_pio = 1;
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index 3bde1e9ab428..32d5e1785bda 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -1419,7 +1419,7 @@ static void b43legacy_release_firmware(struct b43legacy_wldev *dev)
1419static void b43legacy_print_fw_helptext(struct b43legacy_wl *wl) 1419static void b43legacy_print_fw_helptext(struct b43legacy_wl *wl)
1420{ 1420{
1421 b43legacyerr(wl, "You must go to http://linuxwireless.org/en/users/" 1421 b43legacyerr(wl, "You must go to http://linuxwireless.org/en/users/"
1422 "Drivers/bcm43xx#devicefirmware " 1422 "Drivers/b43#devicefirmware "
1423 "and download the correct firmware (version 3).\n"); 1423 "and download the correct firmware (version 3).\n");
1424} 1424}
1425 1425
diff --git a/drivers/net/wireless/b43legacy/phy.c b/drivers/net/wireless/b43legacy/phy.c
index 22a4b3d0186d..491e518e4aeb 100644
--- a/drivers/net/wireless/b43legacy/phy.c
+++ b/drivers/net/wireless/b43legacy/phy.c
@@ -2020,7 +2020,7 @@ int b43legacy_phy_init_tssi2dbm_table(struct b43legacy_wldev *dev)
2020 phy->idle_tssi = 62; 2020 phy->idle_tssi = 62;
2021 dyn_tssi2dbm = kmalloc(64, GFP_KERNEL); 2021 dyn_tssi2dbm = kmalloc(64, GFP_KERNEL);
2022 if (dyn_tssi2dbm == NULL) { 2022 if (dyn_tssi2dbm == NULL) {
2023 b43legacyerr(dev->wl, "Could not allocate memory" 2023 b43legacyerr(dev->wl, "Could not allocate memory "
2024 "for tssi2dbm table\n"); 2024 "for tssi2dbm table\n");
2025 return -ENOMEM; 2025 return -ENOMEM;
2026 } 2026 }
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
index b37f1e348700..af3de3343650 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
@@ -2149,7 +2149,7 @@ int bcm43xx_phy_init_tssi2dbm_table(struct bcm43xx_private *bcm)
2149 } 2149 }
2150 dyn_tssi2dbm = kmalloc(64, GFP_KERNEL); 2150 dyn_tssi2dbm = kmalloc(64, GFP_KERNEL);
2151 if (dyn_tssi2dbm == NULL) { 2151 if (dyn_tssi2dbm == NULL) {
2152 printk(KERN_ERR PFX "Could not allocate memory" 2152 printk(KERN_ERR PFX "Could not allocate memory "
2153 "for tssi2dbm table\n"); 2153 "for tssi2dbm table\n");
2154 return -ENOMEM; 2154 return -ENOMEM;
2155 } 2155 }
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 465da4f67ce7..4bdf237f6adc 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -2915,6 +2915,10 @@ static void iwl_set_rate(struct iwl_priv *priv)
2915 int i; 2915 int i;
2916 2916
2917 hw = iwl_get_hw_mode(priv, priv->phymode); 2917 hw = iwl_get_hw_mode(priv, priv->phymode);
2918 if (!hw) {
2919 IWL_ERROR("Failed to set rate: unable to get hw mode\n");
2920 return;
2921 }
2918 2922
2919 priv->active_rate = 0; 2923 priv->active_rate = 0;
2920 priv->active_rate_basic = 0; 2924 priv->active_rate_basic = 0;
@@ -6936,13 +6940,10 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
6936 DECLARE_MAC_BUF(mac); 6940 DECLARE_MAC_BUF(mac);
6937 6941
6938 IWL_DEBUG_MAC80211("enter: id %d, type %d\n", conf->if_id, conf->type); 6942 IWL_DEBUG_MAC80211("enter: id %d, type %d\n", conf->if_id, conf->type);
6939 if (conf->mac_addr)
6940 IWL_DEBUG_MAC80211("enter: MAC %s\n",
6941 print_mac(mac, conf->mac_addr));
6942 6943
6943 if (priv->interface_id) { 6944 if (priv->interface_id) {
6944 IWL_DEBUG_MAC80211("leave - interface_id != 0\n"); 6945 IWL_DEBUG_MAC80211("leave - interface_id != 0\n");
6945 return 0; 6946 return -EOPNOTSUPP;
6946 } 6947 }
6947 6948
6948 spin_lock_irqsave(&priv->lock, flags); 6949 spin_lock_irqsave(&priv->lock, flags);
@@ -6951,6 +6952,12 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
6951 spin_unlock_irqrestore(&priv->lock, flags); 6952 spin_unlock_irqrestore(&priv->lock, flags);
6952 6953
6953 mutex_lock(&priv->mutex); 6954 mutex_lock(&priv->mutex);
6955
6956 if (conf->mac_addr) {
6957 IWL_DEBUG_MAC80211("Set: %s\n", print_mac(mac, conf->mac_addr));
6958 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
6959 }
6960
6954 iwl_set_mode(priv, conf->type); 6961 iwl_set_mode(priv, conf->type);
6955 6962
6956 IWL_DEBUG_MAC80211("leave\n"); 6963 IWL_DEBUG_MAC80211("leave\n");
@@ -8270,6 +8277,7 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
8270{ 8277{
8271 iwl_hw_cancel_deferred_work(priv); 8278 iwl_hw_cancel_deferred_work(priv);
8272 8279
8280 cancel_delayed_work_sync(&priv->init_alive_start);
8273 cancel_delayed_work(&priv->scan_check); 8281 cancel_delayed_work(&priv->scan_check);
8274 cancel_delayed_work(&priv->alive_start); 8282 cancel_delayed_work(&priv->alive_start);
8275 cancel_delayed_work(&priv->post_associate); 8283 cancel_delayed_work(&priv->post_associate);
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 9918780f5e86..8f85564ec6fa 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -3003,6 +3003,10 @@ static void iwl_set_rate(struct iwl_priv *priv)
3003 int i; 3003 int i;
3004 3004
3005 hw = iwl_get_hw_mode(priv, priv->phymode); 3005 hw = iwl_get_hw_mode(priv, priv->phymode);
3006 if (!hw) {
3007 IWL_ERROR("Failed to set rate: unable to get hw mode\n");
3008 return;
3009 }
3006 3010
3007 priv->active_rate = 0; 3011 priv->active_rate = 0;
3008 priv->active_rate_basic = 0; 3012 priv->active_rate_basic = 0;
@@ -7326,9 +7330,6 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
7326 DECLARE_MAC_BUF(mac); 7330 DECLARE_MAC_BUF(mac);
7327 7331
7328 IWL_DEBUG_MAC80211("enter: id %d, type %d\n", conf->if_id, conf->type); 7332 IWL_DEBUG_MAC80211("enter: id %d, type %d\n", conf->if_id, conf->type);
7329 if (conf->mac_addr)
7330 IWL_DEBUG_MAC80211("enter: MAC %s\n",
7331 print_mac(mac, conf->mac_addr));
7332 7333
7333 if (priv->interface_id) { 7334 if (priv->interface_id) {
7334 IWL_DEBUG_MAC80211("leave - interface_id != 0\n"); 7335 IWL_DEBUG_MAC80211("leave - interface_id != 0\n");
@@ -7341,6 +7342,11 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
7341 spin_unlock_irqrestore(&priv->lock, flags); 7342 spin_unlock_irqrestore(&priv->lock, flags);
7342 7343
7343 mutex_lock(&priv->mutex); 7344 mutex_lock(&priv->mutex);
7345
7346 if (conf->mac_addr) {
7347 IWL_DEBUG_MAC80211("Set %s\n", print_mac(mac, conf->mac_addr));
7348 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
7349 }
7344 iwl_set_mode(priv, conf->type); 7350 iwl_set_mode(priv, conf->type);
7345 7351
7346 IWL_DEBUG_MAC80211("leave\n"); 7352 IWL_DEBUG_MAC80211("leave\n");
@@ -8864,6 +8870,7 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
8864{ 8870{
8865 iwl_hw_cancel_deferred_work(priv); 8871 iwl_hw_cancel_deferred_work(priv);
8866 8872
8873 cancel_delayed_work_sync(&priv->init_alive_start);
8867 cancel_delayed_work(&priv->scan_check); 8874 cancel_delayed_work(&priv->scan_check);
8868 cancel_delayed_work(&priv->alive_start); 8875 cancel_delayed_work(&priv->alive_start);
8869 cancel_delayed_work(&priv->post_associate); 8876 cancel_delayed_work(&priv->post_associate);
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index ec89dabc412c..ba4fc2b3bf0a 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -170,7 +170,8 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
170#define IF_CS_H_IC_TX_OVER 0x0001 170#define IF_CS_H_IC_TX_OVER 0x0001
171#define IF_CS_H_IC_RX_OVER 0x0002 171#define IF_CS_H_IC_RX_OVER 0x0002
172#define IF_CS_H_IC_DNLD_OVER 0x0004 172#define IF_CS_H_IC_DNLD_OVER 0x0004
173#define IF_CS_H_IC_HOST_EVENT 0x0008 173#define IF_CS_H_IC_POWER_DOWN 0x0008
174#define IF_CS_H_IC_HOST_EVENT 0x0010
174#define IF_CS_H_IC_MASK 0x001f 175#define IF_CS_H_IC_MASK 0x001f
175 176
176#define IF_CS_H_INT_MASK 0x00000004 177#define IF_CS_H_INT_MASK 0x00000004
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 5ead08312e1e..1823b48a8ba7 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1165,8 +1165,6 @@ wlan_private *libertas_add_card(void *card, struct device *dmdev)
1165#ifdef WIRELESS_EXT 1165#ifdef WIRELESS_EXT
1166 dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def; 1166 dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def;
1167#endif 1167#endif
1168#define NETIF_F_DYNALLOC 16
1169 dev->features |= NETIF_F_DYNALLOC;
1170 dev->flags |= IFF_BROADCAST | IFF_MULTICAST; 1168 dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
1171 dev->set_multicast_list = libertas_set_multicast_list; 1169 dev->set_multicast_list = libertas_set_multicast_list;
1172 1170
@@ -1348,8 +1346,6 @@ int libertas_add_mesh(wlan_private *priv, struct device *dev)
1348#ifdef WIRELESS_EXT 1346#ifdef WIRELESS_EXT
1349 mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def; 1347 mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def;
1350#endif 1348#endif
1351#define NETIF_F_DYNALLOC 16
1352
1353 /* Register virtual mesh interface */ 1349 /* Register virtual mesh interface */
1354 ret = register_netdev(mesh_dev); 1350 ret = register_netdev(mesh_dev);
1355 if (ret) { 1351 if (ret) {
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index c6f5aa3cb465..395b7882d4d6 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -1528,7 +1528,7 @@ static int wlan_set_encodeext(struct net_device *dev,
1528 && (ext->key_len != KEY_LEN_WPA_TKIP)) 1528 && (ext->key_len != KEY_LEN_WPA_TKIP))
1529 || ((alg == IW_ENCODE_ALG_CCMP) 1529 || ((alg == IW_ENCODE_ALG_CCMP)
1530 && (ext->key_len != KEY_LEN_WPA_AES))) { 1530 && (ext->key_len != KEY_LEN_WPA_AES))) {
1531 lbs_deb_wext("invalid size %d for key of alg" 1531 lbs_deb_wext("invalid size %d for key of alg "
1532 "type %d\n", 1532 "type %d\n",
1533 ext->key_len, 1533 ext->key_len,
1534 alg); 1534 alg);
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 2402cb8dd328..d2fa079fbc4c 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -806,7 +806,7 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
806 for (i = 0; i < 6; i++) 806 for (i = 0; i < 6; i++)
807 dev->dev_addr[i] = readb(ramBase + NETWAVE_EREG_PA + i); 807 dev->dev_addr[i] = readb(ramBase + NETWAVE_EREG_PA + i);
808 808
809 printk(KERN_INFO "%s: Netwave: port %#3lx, irq %d, mem %lx" 809 printk(KERN_INFO "%s: Netwave: port %#3lx, irq %d, mem %lx, "
810 "id %c%c, hw_addr %s\n", 810 "id %c%c, hw_addr %s\n",
811 dev->name, dev->base_addr, dev->irq, 811 dev->name, dev->base_addr, dev->irq,
812 (u_long) ramBase, 812 (u_long) ramBase,
diff --git a/drivers/net/wireless/p54usb.c b/drivers/net/wireless/p54usb.c
index 755482a5a938..60d286eb0b8b 100644
--- a/drivers/net/wireless/p54usb.c
+++ b/drivers/net/wireless/p54usb.c
@@ -308,7 +308,7 @@ static int p54u_read_eeprom(struct ieee80211_hw *dev)
308 308
309 buf = kmalloc(0x2020, GFP_KERNEL); 309 buf = kmalloc(0x2020, GFP_KERNEL);
310 if (!buf) { 310 if (!buf) {
311 printk(KERN_ERR "prism54usb: cannot allocate memory for" 311 printk(KERN_ERR "prism54usb: cannot allocate memory for "
312 "eeprom readback!\n"); 312 "eeprom readback!\n");
313 return -ENOMEM; 313 return -ENOMEM;
314 } 314 }
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index f6cc0c5b5657..1ef417cca2db 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -66,7 +66,7 @@ struct slot {
66 char name[SLOT_NAME_SIZE]; 66 char name[SLOT_NAME_SIZE];
67}; 67};
68 68
69/** 69/*
70 * struct acpiphp_bridge - PCI bridge information 70 * struct acpiphp_bridge - PCI bridge information
71 * 71 *
72 * for each bridge device in ACPI namespace 72 * for each bridge device in ACPI namespace
@@ -97,7 +97,7 @@ struct acpiphp_bridge {
97}; 97};
98 98
99 99
100/** 100/*
101 * struct acpiphp_slot - PCI slot information 101 * struct acpiphp_slot - PCI slot information
102 * 102 *
103 * PCI slot information for each *physical* PCI slot 103 * PCI slot information for each *physical* PCI slot
@@ -118,7 +118,7 @@ struct acpiphp_slot {
118}; 118};
119 119
120 120
121/** 121/*
122 * struct acpiphp_func - PCI function information 122 * struct acpiphp_func - PCI function information
123 * 123 *
124 * PCI function information for each object in ACPI namespace 124 * PCI function information for each object in ACPI namespace
@@ -137,7 +137,7 @@ struct acpiphp_func {
137 u32 flags; /* see below */ 137 u32 flags; /* see below */
138}; 138};
139 139
140/** 140/*
141 * struct acpiphp_attention_info - device specific attention registration 141 * struct acpiphp_attention_info - device specific attention registration
142 * 142 *
143 * ACPI has no generic method of setting/getting attention status 143 * ACPI has no generic method of setting/getting attention status
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index a0ca63adad5a..c8c263875c21 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -91,10 +91,10 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
91 * acpiphp_register_attention - set attention LED callback 91 * acpiphp_register_attention - set attention LED callback
92 * @info: must be completely filled with LED callbacks 92 * @info: must be completely filled with LED callbacks
93 * 93 *
94 * Description: this is used to register a hardware specific ACPI 94 * Description: This is used to register a hardware specific ACPI
95 * driver that manipulates the attention LED. All the fields in 95 * driver that manipulates the attention LED. All the fields in
96 * info must be set. 96 * info must be set.
97 **/ 97 */
98int acpiphp_register_attention(struct acpiphp_attention_info *info) 98int acpiphp_register_attention(struct acpiphp_attention_info *info)
99{ 99{
100 int retval = -EINVAL; 100 int retval = -EINVAL;
@@ -112,10 +112,10 @@ int acpiphp_register_attention(struct acpiphp_attention_info *info)
112 * acpiphp_unregister_attention - unset attention LED callback 112 * acpiphp_unregister_attention - unset attention LED callback
113 * @info: must match the pointer used to register 113 * @info: must match the pointer used to register
114 * 114 *
115 * Description: this is used to un-register a hardware specific acpi 115 * Description: This is used to un-register a hardware specific acpi
116 * driver that manipulates the attention LED. The pointer to the 116 * driver that manipulates the attention LED. The pointer to the
117 * info struct must be the same as the one used to set it. 117 * info struct must be the same as the one used to set it.
118 **/ 118 */
119int acpiphp_unregister_attention(struct acpiphp_attention_info *info) 119int acpiphp_unregister_attention(struct acpiphp_attention_info *info)
120{ 120{
121 int retval = -EINVAL; 121 int retval = -EINVAL;
@@ -133,7 +133,6 @@ int acpiphp_unregister_attention(struct acpiphp_attention_info *info)
133 * @hotplug_slot: slot to enable 133 * @hotplug_slot: slot to enable
134 * 134 *
135 * Actual tasks are done in acpiphp_enable_slot() 135 * Actual tasks are done in acpiphp_enable_slot()
136 *
137 */ 136 */
138static int enable_slot(struct hotplug_slot *hotplug_slot) 137static int enable_slot(struct hotplug_slot *hotplug_slot)
139{ 138{
@@ -151,7 +150,6 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
151 * @hotplug_slot: slot to disable 150 * @hotplug_slot: slot to disable
152 * 151 *
153 * Actual tasks are done in acpiphp_disable_slot() 152 * Actual tasks are done in acpiphp_disable_slot()
154 *
155 */ 153 */
156static int disable_slot(struct hotplug_slot *hotplug_slot) 154static int disable_slot(struct hotplug_slot *hotplug_slot)
157{ 155{
@@ -168,15 +166,15 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
168} 166}
169 167
170 168
171 /** 169/**
172 * set_attention_status - set attention LED 170 * set_attention_status - set attention LED
173 * @hotplug_slot: slot to set attention LED on 171 * @hotplug_slot: slot to set attention LED on
174 * @status: value to set attention LED to (0 or 1) 172 * @status: value to set attention LED to (0 or 1)
175 * 173 *
176 * attention status LED, so we use a callback that 174 * attention status LED, so we use a callback that
177 * was registered with us. This allows hardware specific 175 * was registered with us. This allows hardware specific
178 * ACPI implementations to blink the light for us. 176 * ACPI implementations to blink the light for us.
179 **/ 177 */
180 static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) 178 static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
181 { 179 {
182 int retval = -ENODEV; 180 int retval = -ENODEV;
@@ -199,7 +197,6 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
199 * 197 *
200 * Some platforms may not implement _STA method properly. 198 * Some platforms may not implement _STA method properly.
201 * In that case, the value returned may not be reliable. 199 * In that case, the value returned may not be reliable.
202 *
203 */ 200 */
204static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) 201static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
205{ 202{
@@ -213,7 +210,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
213} 210}
214 211
215 212
216 /** 213/**
217 * get_attention_status - get attention LED status 214 * get_attention_status - get attention LED status
218 * @hotplug_slot: slot to get status from 215 * @hotplug_slot: slot to get status from
219 * @value: returns with value of attention LED 216 * @value: returns with value of attention LED
@@ -221,8 +218,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
221 * ACPI doesn't have known method to determine the state 218 * ACPI doesn't have known method to determine the state
222 * of the attention status LED, so we use a callback that 219 * of the attention status LED, so we use a callback that
223 * was registered with us. This allows hardware specific 220 * was registered with us. This allows hardware specific
224 * ACPI implementations to determine its state 221 * ACPI implementations to determine its state.
225 **/ 222 */
226static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) 223static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
227{ 224{
228 int retval = -EINVAL; 225 int retval = -EINVAL;
@@ -244,8 +241,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
244 * @value: pointer to store status 241 * @value: pointer to store status
245 * 242 *
246 * ACPI doesn't provide any formal means to access latch status. 243 * ACPI doesn't provide any formal means to access latch status.
247 * Instead, we fake latch status from _STA 244 * Instead, we fake latch status from _STA.
248 *
249 */ 245 */
250static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) 246static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
251{ 247{
@@ -265,8 +261,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
265 * @value: pointer to store status 261 * @value: pointer to store status
266 * 262 *
267 * ACPI doesn't provide any formal means to access adapter status. 263 * ACPI doesn't provide any formal means to access adapter status.
268 * Instead, we fake adapter status from _STA 264 * Instead, we fake adapter status from _STA.
269 *
270 */ 265 */
271static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) 266static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
272{ 267{
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 1e125b56c9a9..ff1b1c71291a 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -82,7 +82,6 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *contex
82 * 2. has _PS0 method 82 * 2. has _PS0 method
83 * 3. has _PS3 method 83 * 3. has _PS3 method
84 * 4. .. 84 * 4. ..
85 *
86 */ 85 */
87static int is_ejectable(acpi_handle handle) 86static int is_ejectable(acpi_handle handle)
88{ 87{
@@ -986,10 +985,8 @@ static int power_off_slot(struct acpiphp_slot *slot)
986 985
987 986
988/** 987/**
989 * acpiphp_max_busnr - return the highest reserved bus number under 988 * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
990 * the given bus.
991 * @bus: bus to start search with 989 * @bus: bus to start search with
992 *
993 */ 990 */
994static unsigned char acpiphp_max_busnr(struct pci_bus *bus) 991static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
995{ 992{
@@ -1018,7 +1015,6 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
1018/** 1015/**
1019 * acpiphp_bus_add - add a new bus to acpi subsystem 1016 * acpiphp_bus_add - add a new bus to acpi subsystem
1020 * @func: acpiphp_func of the bridge 1017 * @func: acpiphp_func of the bridge
1021 *
1022 */ 1018 */
1023static int acpiphp_bus_add(struct acpiphp_func *func) 1019static int acpiphp_bus_add(struct acpiphp_func *func)
1024{ 1020{
@@ -1063,7 +1059,6 @@ acpiphp_bus_add_out:
1063/** 1059/**
1064 * acpiphp_bus_trim - trim a bus from acpi subsystem 1060 * acpiphp_bus_trim - trim a bus from acpi subsystem
1065 * @handle: handle to acpi namespace 1061 * @handle: handle to acpi namespace
1066 *
1067 */ 1062 */
1068static int acpiphp_bus_trim(acpi_handle handle) 1063static int acpiphp_bus_trim(acpi_handle handle)
1069{ 1064{
@@ -1089,7 +1084,6 @@ static int acpiphp_bus_trim(acpi_handle handle)
1089 * 1084 *
1090 * This function should be called per *physical slot*, 1085 * This function should be called per *physical slot*,
1091 * not per each slot object in ACPI namespace. 1086 * not per each slot object in ACPI namespace.
1092 *
1093 */ 1087 */
1094static int enable_device(struct acpiphp_slot *slot) 1088static int enable_device(struct acpiphp_slot *slot)
1095{ 1089{
@@ -1185,6 +1179,7 @@ static void disable_bridges(struct pci_bus *bus)
1185 1179
1186/** 1180/**
1187 * disable_device - disable a slot 1181 * disable_device - disable a slot
1182 * @slot: ACPI PHP slot
1188 */ 1183 */
1189static int disable_device(struct acpiphp_slot *slot) 1184static int disable_device(struct acpiphp_slot *slot)
1190{ 1185{
@@ -1240,14 +1235,15 @@ static int disable_device(struct acpiphp_slot *slot)
1240 1235
1241/** 1236/**
1242 * get_slot_status - get ACPI slot status 1237 * get_slot_status - get ACPI slot status
1238 * @slot: ACPI PHP slot
1243 * 1239 *
1244 * if a slot has _STA for each function and if any one of them 1240 * If a slot has _STA for each function and if any one of them
1245 * returned non-zero status, return it 1241 * returned non-zero status, return it.
1246 * 1242 *
1247 * if a slot doesn't have _STA and if any one of its functions' 1243 * If a slot doesn't have _STA and if any one of its functions'
1248 * configuration space is configured, return 0x0f as a _STA 1244 * configuration space is configured, return 0x0f as a _STA.
1249 * 1245 *
1250 * otherwise return 0 1246 * Otherwise return 0.
1251 */ 1247 */
1252static unsigned int get_slot_status(struct acpiphp_slot *slot) 1248static unsigned int get_slot_status(struct acpiphp_slot *slot)
1253{ 1249{
@@ -1281,6 +1277,7 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot)
1281 1277
1282/** 1278/**
1283 * acpiphp_eject_slot - physically eject the slot 1279 * acpiphp_eject_slot - physically eject the slot
1280 * @slot: ACPI PHP slot
1284 */ 1281 */
1285int acpiphp_eject_slot(struct acpiphp_slot *slot) 1282int acpiphp_eject_slot(struct acpiphp_slot *slot)
1286{ 1283{
@@ -1314,6 +1311,7 @@ int acpiphp_eject_slot(struct acpiphp_slot *slot)
1314 1311
1315/** 1312/**
1316 * acpiphp_check_bridge - re-enumerate devices 1313 * acpiphp_check_bridge - re-enumerate devices
1314 * @bridge: where to begin re-enumeration
1317 * 1315 *
1318 * Iterate over all slots under this bridge and make sure that if a 1316 * Iterate over all slots under this bridge and make sure that if a
1319 * card is present they are enabled, and if not they are disabled. 1317 * card is present they are enabled, and if not they are disabled.
@@ -1538,13 +1536,11 @@ check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
1538 1536
1539/** 1537/**
1540 * handle_hotplug_event_bridge - handle ACPI event on bridges 1538 * handle_hotplug_event_bridge - handle ACPI event on bridges
1541 *
1542 * @handle: Notify()'ed acpi_handle 1539 * @handle: Notify()'ed acpi_handle
1543 * @type: Notify code 1540 * @type: Notify code
1544 * @context: pointer to acpiphp_bridge structure 1541 * @context: pointer to acpiphp_bridge structure
1545 * 1542 *
1546 * handles ACPI event notification on {host,p2p} bridges 1543 * Handles ACPI event notification on {host,p2p} bridges.
1547 *
1548 */ 1544 */
1549static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *context) 1545static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *context)
1550{ 1546{
@@ -1634,13 +1630,11 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont
1634 1630
1635/** 1631/**
1636 * handle_hotplug_event_func - handle ACPI event on functions (i.e. slots) 1632 * handle_hotplug_event_func - handle ACPI event on functions (i.e. slots)
1637 *
1638 * @handle: Notify()'ed acpi_handle 1633 * @handle: Notify()'ed acpi_handle
1639 * @type: Notify code 1634 * @type: Notify code
1640 * @context: pointer to acpiphp_func structure 1635 * @context: pointer to acpiphp_func structure
1641 * 1636 *
1642 * handles ACPI event notification on slots 1637 * Handles ACPI event notification on slots.
1643 *
1644 */ 1638 */
1645static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) 1639static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context)
1646{ 1640{
@@ -1705,7 +1699,6 @@ static struct acpi_pci_driver acpi_pci_hp_driver = {
1705 1699
1706/** 1700/**
1707 * acpiphp_glue_init - initializes all PCI hotplug - ACPI glue data structures 1701 * acpiphp_glue_init - initializes all PCI hotplug - ACPI glue data structures
1708 *
1709 */ 1702 */
1710int __init acpiphp_glue_init(void) 1703int __init acpiphp_glue_init(void)
1711{ 1704{
@@ -1726,7 +1719,7 @@ int __init acpiphp_glue_init(void)
1726/** 1719/**
1727 * acpiphp_glue_exit - terminates all PCI hotplug - ACPI glue data structures 1720 * acpiphp_glue_exit - terminates all PCI hotplug - ACPI glue data structures
1728 * 1721 *
1729 * This function frees all data allocated in acpiphp_glue_init() 1722 * This function frees all data allocated in acpiphp_glue_init().
1730 */ 1723 */
1731void acpiphp_glue_exit(void) 1724void acpiphp_glue_exit(void)
1732{ 1725{
@@ -1760,7 +1753,6 @@ int __init acpiphp_get_num_slots(void)
1760 * acpiphp_for_each_slot - call function for each slot 1753 * acpiphp_for_each_slot - call function for each slot
1761 * @fn: callback function 1754 * @fn: callback function
1762 * @data: context to be passed to callback function 1755 * @data: context to be passed to callback function
1763 *
1764 */ 1756 */
1765static int acpiphp_for_each_slot(acpiphp_callback fn, void *data) 1757static int acpiphp_for_each_slot(acpiphp_callback fn, void *data)
1766{ 1758{
@@ -1786,6 +1778,7 @@ static int acpiphp_for_each_slot(acpiphp_callback fn, void *data)
1786 1778
1787/** 1779/**
1788 * acpiphp_enable_slot - power on slot 1780 * acpiphp_enable_slot - power on slot
1781 * @slot: ACPI PHP slot
1789 */ 1782 */
1790int acpiphp_enable_slot(struct acpiphp_slot *slot) 1783int acpiphp_enable_slot(struct acpiphp_slot *slot)
1791{ 1784{
@@ -1815,6 +1808,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
1815 1808
1816/** 1809/**
1817 * acpiphp_disable_slot - power off slot 1810 * acpiphp_disable_slot - power off slot
1811 * @slot: ACPI PHP slot
1818 */ 1812 */
1819int acpiphp_disable_slot(struct acpiphp_slot *slot) 1813int acpiphp_disable_slot(struct acpiphp_slot *slot)
1820{ 1814{
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 56829f82be4a..47d26b65e99a 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -134,11 +134,11 @@ static struct acpiphp_attention_info ibm_attention_info =
134 * ibm_slot_from_id - workaround for bad ibm hardware 134 * ibm_slot_from_id - workaround for bad ibm hardware
135 * @id: the slot number that linux refers to the slot by 135 * @id: the slot number that linux refers to the slot by
136 * 136 *
137 * Description: this method returns the aCPI slot descriptor 137 * Description: This method returns the aCPI slot descriptor
138 * corresponding to the Linux slot number. This descriptor 138 * corresponding to the Linux slot number. This descriptor
139 * has info about the aPCI slot id and attention status. 139 * has info about the aPCI slot id and attention status.
140 * This descriptor must be freed using kfree when done. 140 * This descriptor must be freed using kfree when done.
141 **/ 141 */
142static union apci_descriptor *ibm_slot_from_id(int id) 142static union apci_descriptor *ibm_slot_from_id(int id)
143{ 143{
144 int ind = 0, size; 144 int ind = 0, size;
@@ -173,9 +173,9 @@ ibm_slot_done:
173 * @slot: the hotplug_slot to work with 173 * @slot: the hotplug_slot to work with
174 * @status: what to set the LED to (0 or 1) 174 * @status: what to set the LED to (0 or 1)
175 * 175 *
176 * Description: this method is registered with the acpiphp module as a 176 * Description: This method is registered with the acpiphp module as a
177 * callback to do the device specific task of setting the LED status 177 * callback to do the device specific task of setting the LED status.
178 **/ 178 */
179static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status) 179static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status)
180{ 180{
181 union acpi_object args[2]; 181 union acpi_object args[2];
@@ -213,13 +213,13 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status)
213 * @slot: the hotplug_slot to work with 213 * @slot: the hotplug_slot to work with
214 * @status: returns what the LED is set to (0 or 1) 214 * @status: returns what the LED is set to (0 or 1)
215 * 215 *
216 * Description: this method is registered with the acpiphp module as a 216 * Description: This method is registered with the acpiphp module as a
217 * callback to do the device specific task of getting the LED status 217 * callback to do the device specific task of getting the LED status.
218 * 218 *
219 * Because there is no direct method of getting the LED status directly 219 * Because there is no direct method of getting the LED status directly
220 * from an ACPI call, we read the aPCI table and parse out our 220 * from an ACPI call, we read the aPCI table and parse out our
221 * slot descriptor to read the status from that. 221 * slot descriptor to read the status from that.
222 **/ 222 */
223static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status) 223static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status)
224{ 224{
225 union apci_descriptor *ibm_slot; 225 union apci_descriptor *ibm_slot;
@@ -245,8 +245,8 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status)
245 * @event: the event info (device specific) 245 * @event: the event info (device specific)
246 * @context: passed context (our notification struct) 246 * @context: passed context (our notification struct)
247 * 247 *
248 * Description: this method is registered as a callback with the ACPI 248 * Description: This method is registered as a callback with the ACPI
249 * subsystem it is called when this device has an event to notify the OS of 249 * subsystem it is called when this device has an event to notify the OS of.
250 * 250 *
251 * The events actually come from the device as two events that get 251 * The events actually come from the device as two events that get
252 * synthesized into one event with data by this function. The event 252 * synthesized into one event with data by this function. The event
@@ -256,7 +256,7 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status)
256 * From section 5.6.2.2 of the ACPI 2.0 spec, I understand that the OSPM will 256 * From section 5.6.2.2 of the ACPI 2.0 spec, I understand that the OSPM will
257 * only re-enable the interrupt that causes this event AFTER this method 257 * only re-enable the interrupt that causes this event AFTER this method
258 * has returned, thereby enforcing serial access for the notification struct. 258 * has returned, thereby enforcing serial access for the notification struct.
259 **/ 259 */
260static void ibm_handle_events(acpi_handle handle, u32 event, void *context) 260static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
261{ 261{
262 u8 detail = event & 0x0f; 262 u8 detail = event & 0x0f;
@@ -279,16 +279,16 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
279 * ibm_get_table_from_acpi - reads the APLS buffer from ACPI 279 * ibm_get_table_from_acpi - reads the APLS buffer from ACPI
280 * @bufp: address to pointer to allocate for the table 280 * @bufp: address to pointer to allocate for the table
281 * 281 *
282 * Description: this method reads the APLS buffer in from ACPI and 282 * Description: This method reads the APLS buffer in from ACPI and
283 * stores the "stripped" table into a single buffer 283 * stores the "stripped" table into a single buffer
284 * it allocates and passes the address back in bufp 284 * it allocates and passes the address back in bufp.
285 * 285 *
286 * If NULL is passed in as buffer, this method only calculates 286 * If NULL is passed in as buffer, this method only calculates
287 * the size of the table and returns that without filling 287 * the size of the table and returns that without filling
288 * in the buffer 288 * in the buffer.
289 * 289 *
290 * returns < 0 on error or the size of the table on success 290 * Returns < 0 on error or the size of the table on success.
291 **/ 291 */
292static int ibm_get_table_from_acpi(char **bufp) 292static int ibm_get_table_from_acpi(char **bufp)
293{ 293{
294 union acpi_object *package; 294 union acpi_object *package;
@@ -349,17 +349,18 @@ read_table_done:
349/** 349/**
350 * ibm_read_apci_table - callback for the sysfs apci_table file 350 * ibm_read_apci_table - callback for the sysfs apci_table file
351 * @kobj: the kobject this binary attribute is a part of 351 * @kobj: the kobject this binary attribute is a part of
352 * @bin_attr: struct bin_attribute for this file
352 * @buffer: the kernel space buffer to fill 353 * @buffer: the kernel space buffer to fill
353 * @pos: the offset into the file 354 * @pos: the offset into the file
354 * @size: the number of bytes requested 355 * @size: the number of bytes requested
355 * 356 *
356 * Description: gets registered with sysfs as the reader callback 357 * Description: Gets registered with sysfs as the reader callback
357 * to be executed when /sys/bus/pci/slots/apci_table gets read 358 * to be executed when /sys/bus/pci/slots/apci_table gets read.
358 * 359 *
359 * Since we don't get notified on open and close for this file, 360 * Since we don't get notified on open and close for this file,
360 * things get really tricky here... 361 * things get really tricky here...
361 * our solution is to only allow reading the table in all at once 362 * our solution is to only allow reading the table in all at once.
362 **/ 363 */
363static ssize_t ibm_read_apci_table(struct kobject *kobj, 364static ssize_t ibm_read_apci_table(struct kobject *kobj,
364 struct bin_attribute *bin_attr, 365 struct bin_attribute *bin_attr,
365 char *buffer, loff_t pos, size_t size) 366 char *buffer, loff_t pos, size_t size)
@@ -385,10 +386,10 @@ static ssize_t ibm_read_apci_table(struct kobject *kobj,
385 * @context: a pointer to our handle to fill when we find the device 386 * @context: a pointer to our handle to fill when we find the device
386 * @rv: a return value to fill if desired 387 * @rv: a return value to fill if desired
387 * 388 *
388 * Description: used as a callback when calling acpi_walk_namespace 389 * Description: Used as a callback when calling acpi_walk_namespace
389 * to find our device. When this method returns non-zero 390 * to find our device. When this method returns non-zero
390 * acpi_walk_namespace quits its search and returns our value 391 * acpi_walk_namespace quits its search and returns our value.
391 **/ 392 */
392static acpi_status __init ibm_find_acpi_device(acpi_handle handle, 393static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
393 u32 lvl, void *context, void **rv) 394 u32 lvl, void *context, void **rv)
394{ 395{
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index a96b739b2d35..74178875b949 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -117,12 +117,10 @@ static inline int is_slot66mhz(struct slot *slot)
117 117
118/** 118/**
119 * detect_SMBIOS_pointer - find the System Management BIOS Table in mem region. 119 * detect_SMBIOS_pointer - find the System Management BIOS Table in mem region.
120 *
121 * @begin: begin pointer for region to be scanned. 120 * @begin: begin pointer for region to be scanned.
122 * @end: end pointer for region to be scanned. 121 * @end: end pointer for region to be scanned.
123 * 122 *
124 * Returns pointer to the head of the SMBIOS tables (or NULL) 123 * Returns pointer to the head of the SMBIOS tables (or %NULL).
125 *
126 */ 124 */
127static void __iomem * detect_SMBIOS_pointer(void __iomem *begin, void __iomem *end) 125static void __iomem * detect_SMBIOS_pointer(void __iomem *begin, void __iomem *end)
128{ 126{
@@ -157,9 +155,9 @@ static void __iomem * detect_SMBIOS_pointer(void __iomem *begin, void __iomem *e
157 155
158/** 156/**
159 * init_SERR - Initializes the per slot SERR generation. 157 * init_SERR - Initializes the per slot SERR generation.
158 * @ctrl: controller to use
160 * 159 *
161 * For unexpected switch opens 160 * For unexpected switch opens
162 *
163 */ 161 */
164static int init_SERR(struct controller * ctrl) 162static int init_SERR(struct controller * ctrl)
165{ 163{
@@ -224,14 +222,15 @@ static int pci_print_IRQ_route (void)
224 222
225/** 223/**
226 * get_subsequent_smbios_entry: get the next entry from bios table. 224 * get_subsequent_smbios_entry: get the next entry from bios table.
227 * 225 * @smbios_start: where to start in the SMBIOS table
228 * Gets the first entry if previous == NULL 226 * @smbios_table: location of the SMBIOS table
229 * Otherwise, returns the next entry
230 * Uses global SMBIOS Table pointer
231 *
232 * @curr: %NULL or pointer to previously returned structure 227 * @curr: %NULL or pointer to previously returned structure
233 * 228 *
234 * returns a pointer to an SMBIOS structure or NULL if none found 229 * Gets the first entry if previous == NULL;
230 * otherwise, returns the next entry.
231 * Uses global SMBIOS Table pointer.
232 *
233 * Returns a pointer to an SMBIOS structure or NULL if none found.
235 */ 234 */
236static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start, 235static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start,
237 void __iomem *smbios_table, 236 void __iomem *smbios_table,
@@ -272,17 +271,18 @@ static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start,
272 271
273 272
274/** 273/**
275 * get_SMBIOS_entry 274 * get_SMBIOS_entry - return the requested SMBIOS entry or %NULL
276 * 275 * @smbios_start: where to start in the SMBIOS table
277 * @type:SMBIOS structure type to be returned 276 * @smbios_table: location of the SMBIOS table
277 * @type: SMBIOS structure type to be returned
278 * @previous: %NULL or pointer to previously returned structure 278 * @previous: %NULL or pointer to previously returned structure
279 * 279 *
280 * Gets the first entry of the specified type if previous == NULL 280 * Gets the first entry of the specified type if previous == %NULL;
281 * Otherwise, returns the next entry of the given type. 281 * Otherwise, returns the next entry of the given type.
282 * Uses global SMBIOS Table pointer 282 * Uses global SMBIOS Table pointer.
283 * Uses get_subsequent_smbios_entry 283 * Uses get_subsequent_smbios_entry.
284 * 284 *
285 * returns a pointer to an SMBIOS structure or %NULL if none found 285 * Returns a pointer to an SMBIOS structure or %NULL if none found.
286 */ 286 */
287static void __iomem *get_SMBIOS_entry(void __iomem *smbios_start, 287static void __iomem *get_SMBIOS_entry(void __iomem *smbios_start,
288 void __iomem *smbios_table, 288 void __iomem *smbios_table,
@@ -581,7 +581,9 @@ get_slot_mapping(struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *slot)
581 581
582/** 582/**
583 * cpqhp_set_attention_status - Turns the Amber LED for a slot on or off 583 * cpqhp_set_attention_status - Turns the Amber LED for a slot on or off
584 * 584 * @ctrl: struct controller to use
585 * @func: PCI device/function info
586 * @status: LED control flag: 1 = LED on, 0 = LED off
585 */ 587 */
586static int 588static int
587cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, 589cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
@@ -621,7 +623,8 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
621 623
622/** 624/**
623 * set_attention_status - Turns the Amber LED for a slot on or off 625 * set_attention_status - Turns the Amber LED for a slot on or off
624 * 626 * @hotplug_slot: slot to change LED on
627 * @status: LED control flag
625 */ 628 */
626static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) 629static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
627{ 630{
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index 856d57b4d604..4018420c6f95 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -123,7 +123,7 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl)
123} 123}
124 124
125/** 125/**
126 * cpqhp_find_slot: find the struct slot of given device 126 * cpqhp_find_slot - find the struct slot of given device
127 * @ctrl: scan lots of this controller 127 * @ctrl: scan lots of this controller
128 * @device: the device id to find 128 * @device: the device id to find
129 */ 129 */
@@ -305,9 +305,8 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl)
305 305
306 306
307/** 307/**
308 * sort_by_size: sort nodes on the list by their length, smallest first. 308 * sort_by_size - sort nodes on the list by their length, smallest first.
309 * @head: list to sort 309 * @head: list to sort
310 *
311 */ 310 */
312static int sort_by_size(struct pci_resource **head) 311static int sort_by_size(struct pci_resource **head)
313{ 312{
@@ -354,9 +353,8 @@ static int sort_by_size(struct pci_resource **head)
354 353
355 354
356/** 355/**
357 * sort_by_max_size: sort nodes on the list by their length, largest first. 356 * sort_by_max_size - sort nodes on the list by their length, largest first.
358 * @head: list to sort 357 * @head: list to sort
359 *
360 */ 358 */
361static int sort_by_max_size(struct pci_resource **head) 359static int sort_by_max_size(struct pci_resource **head)
362{ 360{
@@ -403,8 +401,10 @@ static int sort_by_max_size(struct pci_resource **head)
403 401
404 402
405/** 403/**
406 * do_pre_bridge_resource_split: find node of resources that are unused 404 * do_pre_bridge_resource_split - find node of resources that are unused
407 * 405 * @head: new list head
406 * @orig_head: original list head
407 * @alignment: max node size (?)
408 */ 408 */
409static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **head, 409static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **head,
410 struct pci_resource **orig_head, u32 alignment) 410 struct pci_resource **orig_head, u32 alignment)
@@ -477,8 +477,9 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h
477 477
478 478
479/** 479/**
480 * do_bridge_resource_split: find one node of resources that aren't in use 480 * do_bridge_resource_split - find one node of resources that aren't in use
481 * 481 * @head: list head
482 * @alignment: max node size (?)
482 */ 483 */
483static struct pci_resource *do_bridge_resource_split(struct pci_resource **head, u32 alignment) 484static struct pci_resource *do_bridge_resource_split(struct pci_resource **head, u32 alignment)
484{ 485{
@@ -525,14 +526,13 @@ error:
525 526
526 527
527/** 528/**
528 * get_io_resource: find first node of given size not in ISA aliasing window. 529 * get_io_resource - find first node of given size not in ISA aliasing window.
529 * @head: list to search 530 * @head: list to search
530 * @size: size of node to find, must be a power of two. 531 * @size: size of node to find, must be a power of two.
531 * 532 *
532 * Description: this function sorts the resource list by size and then returns 533 * Description: This function sorts the resource list by size and then returns
533 * returns the first node of "size" length that is not in the ISA aliasing 534 * returns the first node of "size" length that is not in the ISA aliasing
534 * window. If it finds a node larger than "size" it will split it up. 535 * window. If it finds a node larger than "size" it will split it up.
535 *
536 */ 536 */
537static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size) 537static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size)
538{ 538{
@@ -620,7 +620,7 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
620 620
621 621
622/** 622/**
623 * get_max_resource: get largest node which has at least the given size. 623 * get_max_resource - get largest node which has at least the given size.
624 * @head: the list to search the node in 624 * @head: the list to search the node in
625 * @size: the minimum size of the node to find 625 * @size: the minimum size of the node to find
626 * 626 *
@@ -712,7 +712,7 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
712 712
713 713
714/** 714/**
715 * get_resource: find resource of given size and split up larger ones. 715 * get_resource - find resource of given size and split up larger ones.
716 * @head: the list to search for resources 716 * @head: the list to search for resources
717 * @size: the size limit to use 717 * @size: the size limit to use
718 * 718 *
@@ -804,14 +804,14 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
804 804
805 805
806/** 806/**
807 * cpqhp_resource_sort_and_combine: sort nodes by base addresses and clean up. 807 * cpqhp_resource_sort_and_combine - sort nodes by base addresses and clean up
808 * @head: the list to sort and clean up 808 * @head: the list to sort and clean up
809 * 809 *
810 * Description: Sorts all of the nodes in the list in ascending order by 810 * Description: Sorts all of the nodes in the list in ascending order by
811 * their base addresses. Also does garbage collection by 811 * their base addresses. Also does garbage collection by
812 * combining adjacent nodes. 812 * combining adjacent nodes.
813 * 813 *
814 * returns 0 if success 814 * Returns %0 if success.
815 */ 815 */
816int cpqhp_resource_sort_and_combine(struct pci_resource **head) 816int cpqhp_resource_sort_and_combine(struct pci_resource **head)
817{ 817{
@@ -951,9 +951,9 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data)
951 951
952/** 952/**
953 * cpqhp_slot_create - Creates a node and adds it to the proper bus. 953 * cpqhp_slot_create - Creates a node and adds it to the proper bus.
954 * @busnumber - bus where new node is to be located 954 * @busnumber: bus where new node is to be located
955 * 955 *
956 * Returns pointer to the new node or NULL if unsuccessful 956 * Returns pointer to the new node or %NULL if unsuccessful.
957 */ 957 */
958struct pci_func *cpqhp_slot_create(u8 busnumber) 958struct pci_func *cpqhp_slot_create(u8 busnumber)
959{ 959{
@@ -986,7 +986,7 @@ struct pci_func *cpqhp_slot_create(u8 busnumber)
986 * slot_remove - Removes a node from the linked list of slots. 986 * slot_remove - Removes a node from the linked list of slots.
987 * @old_slot: slot to remove 987 * @old_slot: slot to remove
988 * 988 *
989 * Returns 0 if successful, !0 otherwise. 989 * Returns %0 if successful, !0 otherwise.
990 */ 990 */
991static int slot_remove(struct pci_func * old_slot) 991static int slot_remove(struct pci_func * old_slot)
992{ 992{
@@ -1026,7 +1026,7 @@ static int slot_remove(struct pci_func * old_slot)
1026 * bridge_slot_remove - Removes a node from the linked list of slots. 1026 * bridge_slot_remove - Removes a node from the linked list of slots.
1027 * @bridge: bridge to remove 1027 * @bridge: bridge to remove
1028 * 1028 *
1029 * Returns 0 if successful, !0 otherwise. 1029 * Returns %0 if successful, !0 otherwise.
1030 */ 1030 */
1031static int bridge_slot_remove(struct pci_func *bridge) 1031static int bridge_slot_remove(struct pci_func *bridge)
1032{ 1032{
@@ -1071,7 +1071,7 @@ out:
1071 * cpqhp_slot_find - Looks for a node by bus, and device, multiple functions accessed 1071 * cpqhp_slot_find - Looks for a node by bus, and device, multiple functions accessed
1072 * @bus: bus to find 1072 * @bus: bus to find
1073 * @device: device to find 1073 * @device: device to find
1074 * @index: is 0 for first function found, 1 for the second... 1074 * @index: is %0 for first function found, %1 for the second...
1075 * 1075 *
1076 * Returns pointer to the node if successful, %NULL otherwise. 1076 * Returns pointer to the node if successful, %NULL otherwise.
1077 */ 1077 */
@@ -1115,16 +1115,13 @@ static int is_bridge(struct pci_func * func)
1115 1115
1116 1116
1117/** 1117/**
1118 * set_controller_speed - set the frequency and/or mode of a specific 1118 * set_controller_speed - set the frequency and/or mode of a specific controller segment.
1119 * controller segment.
1120 *
1121 * @ctrl: controller to change frequency/mode for. 1119 * @ctrl: controller to change frequency/mode for.
1122 * @adapter_speed: the speed of the adapter we want to match. 1120 * @adapter_speed: the speed of the adapter we want to match.
1123 * @hp_slot: the slot number where the adapter is installed. 1121 * @hp_slot: the slot number where the adapter is installed.
1124 * 1122 *
1125 * Returns 0 if we successfully change frequency and/or mode to match the 1123 * Returns %0 if we successfully change frequency and/or mode to match the
1126 * adapter speed. 1124 * adapter speed.
1127 *
1128 */ 1125 */
1129static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_slot) 1126static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_slot)
1130{ 1127{
@@ -1253,13 +1250,14 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
1253 1250
1254/** 1251/**
1255 * board_replaced - Called after a board has been replaced in the system. 1252 * board_replaced - Called after a board has been replaced in the system.
1253 * @func: PCI device/function information
1254 * @ctrl: hotplug controller
1256 * 1255 *
1257 * This is only used if we don't have resources for hot add 1256 * This is only used if we don't have resources for hot add.
1258 * Turns power on for the board 1257 * Turns power on for the board.
1259 * Checks to see if board is the same 1258 * Checks to see if board is the same.
1260 * If board is same, reconfigures it 1259 * If board is same, reconfigures it.
1261 * If board isn't same, turns it back off. 1260 * If board isn't same, turns it back off.
1262 *
1263 */ 1261 */
1264static u32 board_replaced(struct pci_func *func, struct controller *ctrl) 1262static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1265{ 1263{
@@ -1403,10 +1401,11 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1403 1401
1404/** 1402/**
1405 * board_added - Called after a board has been added to the system. 1403 * board_added - Called after a board has been added to the system.
1404 * @func: PCI device/function info
1405 * @ctrl: hotplug controller
1406 * 1406 *
1407 * Turns power on for the board 1407 * Turns power on for the board.
1408 * Configures board 1408 * Configures board.
1409 *
1410 */ 1409 */
1411static u32 board_added(struct pci_func *func, struct controller *ctrl) 1410static u32 board_added(struct pci_func *func, struct controller *ctrl)
1412{ 1411{
@@ -1607,8 +1606,10 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1607 1606
1608 1607
1609/** 1608/**
1610 * remove_board - Turns off slot and LED's 1609 * remove_board - Turns off slot and LEDs
1611 * 1610 * @func: PCI device/function info
1611 * @replace_flag: whether replacing or adding a new device
1612 * @ctrl: target controller
1612 */ 1613 */
1613static u32 remove_board(struct pci_func * func, u32 replace_flag, struct controller * ctrl) 1614static u32 remove_board(struct pci_func * func, u32 replace_flag, struct controller * ctrl)
1614{ 1615{
@@ -1902,11 +1903,11 @@ static void interrupt_event_handler(struct controller *ctrl)
1902 1903
1903 1904
1904/** 1905/**
1905 * cpqhp_pushbutton_thread 1906 * cpqhp_pushbutton_thread - handle pushbutton events
1907 * @slot: target slot (struct)
1906 * 1908 *
1907 * Scheduled procedure to handle blocking stuff for the pushbuttons 1909 * Scheduled procedure to handle blocking stuff for the pushbuttons.
1908 * Handles all pending events and exits. 1910 * Handles all pending events and exits.
1909 *
1910 */ 1911 */
1911void cpqhp_pushbutton_thread(unsigned long slot) 1912void cpqhp_pushbutton_thread(unsigned long slot)
1912{ 1913{
@@ -2137,9 +2138,10 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
2137} 2138}
2138 2139
2139/** 2140/**
2140 * switch_leds: switch the leds, go from one site to the other. 2141 * switch_leds - switch the leds, go from one site to the other.
2141 * @ctrl: controller to use 2142 * @ctrl: controller to use
2142 * @num_of_slots: number of slots to use 2143 * @num_of_slots: number of slots to use
2144 * @work_LED: LED control value
2143 * @direction: 1 to start from the left side, 0 to start right. 2145 * @direction: 1 to start from the left side, 0 to start right.
2144 */ 2146 */
2145static void switch_leds(struct controller *ctrl, const int num_of_slots, 2147static void switch_leds(struct controller *ctrl, const int num_of_slots,
@@ -2165,11 +2167,11 @@ static void switch_leds(struct controller *ctrl, const int num_of_slots,
2165} 2167}
2166 2168
2167/** 2169/**
2168 * hardware_test - runs hardware tests 2170 * cpqhp_hardware_test - runs hardware tests
2171 * @ctrl: target controller
2172 * @test_num: the number written to the "test" file in sysfs.
2169 * 2173 *
2170 * For hot plug ctrl folks to play with. 2174 * For hot plug ctrl folks to play with.
2171 * test_num is the number written to the "test" file in sysfs
2172 *
2173 */ 2175 */
2174int cpqhp_hardware_test(struct controller *ctrl, int test_num) 2176int cpqhp_hardware_test(struct controller *ctrl, int test_num)
2175{ 2177{
@@ -2249,14 +2251,12 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
2249 2251
2250/** 2252/**
2251 * configure_new_device - Configures the PCI header information of one board. 2253 * configure_new_device - Configures the PCI header information of one board.
2252 *
2253 * @ctrl: pointer to controller structure 2254 * @ctrl: pointer to controller structure
2254 * @func: pointer to function structure 2255 * @func: pointer to function structure
2255 * @behind_bridge: 1 if this is a recursive call, 0 if not 2256 * @behind_bridge: 1 if this is a recursive call, 0 if not
2256 * @resources: pointer to set of resource lists 2257 * @resources: pointer to set of resource lists
2257 * 2258 *
2258 * Returns 0 if success 2259 * Returns 0 if success.
2259 *
2260 */ 2260 */
2261static u32 configure_new_device(struct controller * ctrl, struct pci_func * func, 2261static u32 configure_new_device(struct controller * ctrl, struct pci_func * func,
2262 u8 behind_bridge, struct resource_lists * resources) 2262 u8 behind_bridge, struct resource_lists * resources)
@@ -2346,15 +2346,13 @@ static u32 configure_new_device(struct controller * ctrl, struct pci_func * func
2346 2346
2347/** 2347/**
2348 * configure_new_function - Configures the PCI header information of one device 2348 * configure_new_function - Configures the PCI header information of one device
2349 *
2350 * @ctrl: pointer to controller structure 2349 * @ctrl: pointer to controller structure
2351 * @func: pointer to function structure 2350 * @func: pointer to function structure
2352 * @behind_bridge: 1 if this is a recursive call, 0 if not 2351 * @behind_bridge: 1 if this is a recursive call, 0 if not
2353 * @resources: pointer to set of resource lists 2352 * @resources: pointer to set of resource lists
2354 * 2353 *
2355 * Calls itself recursively for bridged devices. 2354 * Calls itself recursively for bridged devices.
2356 * Returns 0 if success 2355 * Returns 0 if success.
2357 *
2358 */ 2356 */
2359static int configure_new_function(struct controller *ctrl, struct pci_func *func, 2357static int configure_new_function(struct controller *ctrl, struct pci_func *func,
2360 u8 behind_bridge, 2358 u8 behind_bridge,
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 027f6865d7e3..d7a293e3faf5 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -165,11 +165,11 @@ static void remove_slot(struct dummy_slot *dslot)
165} 165}
166 166
167/** 167/**
168 * Rescan slot. 168 * pci_rescan_slot - Rescan slot
169 * Tries hard not to re-enable already existing devices 169 * @temp: Device template. Should be set: bus and devfn.
170 * also handles scanning of subfunctions
171 * 170 *
172 * @param temp Device template. Should be set: bus and devfn. 171 * Tries hard not to re-enable already existing devices;
172 * also handles scanning of subfunctions.
173 */ 173 */
174static void pci_rescan_slot(struct pci_dev *temp) 174static void pci_rescan_slot(struct pci_dev *temp)
175{ 175{
@@ -229,10 +229,10 @@ static void pci_rescan_slot(struct pci_dev *temp)
229 229
230 230
231/** 231/**
232 * Rescan PCI bus. 232 * pci_rescan_bus - Rescan PCI bus
233 * call pci_rescan_slot for each possible function of the bus 233 * @bus: the PCI bus to rescan
234 * 234 *
235 * @param bus 235 * Call pci_rescan_slot for each possible function of the bus.
236 */ 236 */
237static void pci_rescan_bus(const struct pci_bus *bus) 237static void pci_rescan_bus(const struct pci_bus *bus)
238{ 238{
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index c8cb49c5a752..f1e0966cee95 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -208,10 +208,10 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
208 208
209/** 209/**
210 * board_added - Called after a board has been added to the system. 210 * board_added - Called after a board has been added to the system.
211 * @p_slot: &slot where board is added
211 * 212 *
212 * Turns power on for the board 213 * Turns power on for the board.
213 * Configures board 214 * Configures board.
214 *
215 */ 215 */
216static int board_added(struct slot *p_slot) 216static int board_added(struct slot *p_slot)
217{ 217{
@@ -276,8 +276,8 @@ err_exit:
276} 276}
277 277
278/** 278/**
279 * remove_board - Turns off slot and LED's 279 * remove_board - Turns off slot and LEDs
280 * 280 * @p_slot: slot where board is being removed
281 */ 281 */
282static int remove_board(struct slot *p_slot) 282static int remove_board(struct slot *p_slot)
283{ 283{
@@ -319,11 +319,11 @@ struct power_work_info {
319}; 319};
320 320
321/** 321/**
322 * pciehp_pushbutton_thread 322 * pciehp_power_thread - handle pushbutton events
323 * @work: &struct work_struct describing work to be done
323 * 324 *
324 * Scheduled procedure to handle blocking stuff for the pushbuttons 325 * Scheduled procedure to handle blocking stuff for the pushbuttons.
325 * Handles all pending events and exits. 326 * Handles all pending events and exits.
326 *
327 */ 327 */
328static void pciehp_power_thread(struct work_struct *work) 328static void pciehp_power_thread(struct work_struct *work)
329{ 329{
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index deb6b5e35feb..b169b0e2647f 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -100,6 +100,7 @@ static struct device_node *find_dlpar_node(char *drc_name, int *node_type)
100 100
101/** 101/**
102 * find_php_slot - return hotplug slot structure for device node 102 * find_php_slot - return hotplug slot structure for device node
103 * @dn: target &device_node
103 * 104 *
104 * This routine will return the hotplug slot structure 105 * This routine will return the hotplug slot structure
105 * for a given device node. Note that built-in PCI slots 106 * for a given device node. Note that built-in PCI slots
@@ -293,9 +294,8 @@ static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn)
293 * dlpar_add_slot - DLPAR add an I/O Slot 294 * dlpar_add_slot - DLPAR add an I/O Slot
294 * @drc_name: drc-name of newly added slot 295 * @drc_name: drc-name of newly added slot
295 * 296 *
296 * Make the hotplug module and the kernel aware 297 * Make the hotplug module and the kernel aware of a newly added I/O Slot.
297 * of a newly added I/O Slot. 298 * Return Codes:
298 * Return Codes -
299 * 0 Success 299 * 0 Success
300 * -ENODEV Not a valid drc_name 300 * -ENODEV Not a valid drc_name
301 * -EINVAL Slot already added 301 * -EINVAL Slot already added
@@ -339,9 +339,9 @@ exit:
339/** 339/**
340 * dlpar_remove_vio_slot - DLPAR remove a virtual I/O Slot 340 * dlpar_remove_vio_slot - DLPAR remove a virtual I/O Slot
341 * @drc_name: drc-name of newly added slot 341 * @drc_name: drc-name of newly added slot
342 * @dn: &device_node
342 * 343 *
343 * Remove the kernel and hotplug representations 344 * Remove the kernel and hotplug representations of an I/O Slot.
344 * of an I/O Slot.
345 * Return Codes: 345 * Return Codes:
346 * 0 Success 346 * 0 Success
347 * -EINVAL Vio dev doesn't exist 347 * -EINVAL Vio dev doesn't exist
@@ -359,11 +359,11 @@ static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn)
359} 359}
360 360
361/** 361/**
362 * dlpar_remove_slot - DLPAR remove a PCI I/O Slot 362 * dlpar_remove_pci_slot - DLPAR remove a PCI I/O Slot
363 * @drc_name: drc-name of newly added slot 363 * @drc_name: drc-name of newly added slot
364 * @dn: &device_node
364 * 365 *
365 * Remove the kernel and hotplug representations 366 * Remove the kernel and hotplug representations of a PCI I/O Slot.
366 * of a PCI I/O Slot.
367 * Return Codes: 367 * Return Codes:
368 * 0 Success 368 * 0 Success
369 * -ENODEV Not a valid drc_name 369 * -ENODEV Not a valid drc_name
@@ -405,8 +405,7 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
405 * dlpar_remove_slot - DLPAR remove an I/O Slot 405 * dlpar_remove_slot - DLPAR remove an I/O Slot
406 * @drc_name: drc-name of newly added slot 406 * @drc_name: drc-name of newly added slot
407 * 407 *
408 * Remove the kernel and hotplug representations 408 * Remove the kernel and hotplug representations of an I/O Slot.
409 * of an I/O Slot.
410 * Return Codes: 409 * Return Codes:
411 * 0 Success 410 * 0 Success
412 * -ENODEV Not a valid drc_name 411 * -ENODEV Not a valid drc_name
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 458c08ef2654..58f1a9927709 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -54,10 +54,12 @@ module_param(debug, bool, 0644);
54 54
55/** 55/**
56 * set_attention_status - set attention LED 56 * set_attention_status - set attention LED
57 * @hotplug_slot: target &hotplug_slot
58 * @value: LED control value
59 *
57 * echo 0 > attention -- set LED OFF 60 * echo 0 > attention -- set LED OFF
58 * echo 1 > attention -- set LED ON 61 * echo 1 > attention -- set LED ON
59 * echo 2 > attention -- set LED ID(identify, light is blinking) 62 * echo 2 > attention -- set LED ID(identify, light is blinking)
60 *
61 */ 63 */
62static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value) 64static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
63{ 65{
@@ -99,6 +101,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
99 101
100/** 102/**
101 * get_attention_status - get attention LED status 103 * get_attention_status - get attention LED status
104 * @hotplug_slot: slot to get status
105 * @value: pointer to store status
102 */ 106 */
103static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value) 107static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
104{ 108{
@@ -254,6 +258,11 @@ static int is_php_type(char *drc_type)
254 258
255/** 259/**
256 * is_php_dn() - return 1 if this is a hotpluggable pci slot, else 0 260 * is_php_dn() - return 1 if this is a hotpluggable pci slot, else 0
261 * @dn: target &device_node
262 * @indexes: passed to get_children_props()
263 * @names: passed to get_children_props()
264 * @types: returned from get_children_props()
265 * @power_domains:
257 * 266 *
258 * This routine will return true only if the device node is 267 * This routine will return true only if the device node is
259 * a hotpluggable slot. This routine will return false 268 * a hotpluggable slot. This routine will return false
@@ -279,7 +288,7 @@ static int is_php_dn(struct device_node *dn, const int **indexes,
279 288
280/** 289/**
281 * rpaphp_add_slot -- declare a hotplug slot to the hotplug subsystem. 290 * rpaphp_add_slot -- declare a hotplug slot to the hotplug subsystem.
282 * @dn device node of slot 291 * @dn: device node of slot
283 * 292 *
284 * This subroutine will register a hotplugable slot with the 293 * This subroutine will register a hotplugable slot with the
285 * PCI hotplug infrastructure. This routine is typicaly called 294 * PCI hotplug infrastructure. This routine is typicaly called
@@ -291,7 +300,7 @@ static int is_php_dn(struct device_node *dn, const int **indexes,
291 * routine will just return without doing anything, since embedded 300 * routine will just return without doing anything, since embedded
292 * slots cannot be hotplugged. 301 * slots cannot be hotplugged.
293 * 302 *
294 * To remove a slot, it suffices to call rpaphp_deregister_slot() 303 * To remove a slot, it suffices to call rpaphp_deregister_slot().
295 */ 304 */
296int rpaphp_add_slot(struct device_node *dn) 305int rpaphp_add_slot(struct device_node *dn)
297{ 306{
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 54ca8650d511..0de84533cd80 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -79,6 +79,7 @@ static void set_slot_name(struct slot *slot)
79 79
80/** 80/**
81 * rpaphp_enable_slot - record slot state, config pci device 81 * rpaphp_enable_slot - record slot state, config pci device
82 * @slot: target &slot
82 * 83 *
83 * Initialize values in the slot, and the hotplug_slot info 84 * Initialize values in the slot, and the hotplug_slot info
84 * structures to indicate if there is a pci card plugged into 85 * structures to indicate if there is a pci card plugged into
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index d2fc35598cdd..eb5cac6f08ae 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -231,10 +231,10 @@ static int fix_bus_speed(struct controller *ctrl, struct slot *pslot,
231 231
232/** 232/**
233 * board_added - Called after a board has been added to the system. 233 * board_added - Called after a board has been added to the system.
234 * @p_slot: target &slot
234 * 235 *
235 * Turns power on for the board 236 * Turns power on for the board.
236 * Configures board 237 * Configures board.
237 *
238 */ 238 */
239static int board_added(struct slot *p_slot) 239static int board_added(struct slot *p_slot)
240{ 240{
@@ -350,8 +350,8 @@ err_exit:
350 350
351 351
352/** 352/**
353 * remove_board - Turns off slot and LED's 353 * remove_board - Turns off slot and LEDs
354 * 354 * @p_slot: target &slot
355 */ 355 */
356static int remove_board(struct slot *p_slot) 356static int remove_board(struct slot *p_slot)
357{ 357{
@@ -397,11 +397,11 @@ struct pushbutton_work_info {
397}; 397};
398 398
399/** 399/**
400 * shpchp_pushbutton_thread 400 * shpchp_pushbutton_thread - handle pushbutton events
401 * @work: &struct work_struct to be handled
401 * 402 *
402 * Scheduled procedure to handle blocking stuff for the pushbuttons 403 * Scheduled procedure to handle blocking stuff for the pushbuttons.
403 * Handles all pending events and exits. 404 * Handles all pending events and exits.
404 *
405 */ 405 */
406static void shpchp_pushbutton_thread(struct work_struct *work) 406static void shpchp_pushbutton_thread(struct work_struct *work)
407{ 407{
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 1b7b2812bf2d..7d1877341aad 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -702,8 +702,10 @@ static int __init pci_sysfs_init(void)
702 sysfs_initialized = 1; 702 sysfs_initialized = 1;
703 for_each_pci_dev(pdev) { 703 for_each_pci_dev(pdev) {
704 retval = pci_create_sysfs_dev_files(pdev); 704 retval = pci_create_sysfs_dev_files(pdev);
705 if (retval) 705 if (retval) {
706 pci_dev_put(pdev);
706 return retval; 707 return retval;
708 }
707 } 709 }
708 710
709 return 0; 711 return 0;
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 92a8469b21ba..3c0d8d138f5a 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -168,11 +168,11 @@ static int find_device_iter(struct device *device, void *data)
168 168
169/** 169/**
170 * find_source_device - search through device hierarchy for source device 170 * find_source_device - search through device hierarchy for source device
171 * @p_dev: pointer to Root Port pci_dev data structure 171 * @parent: pointer to Root Port pci_dev data structure
172 * @id: device ID of agent who sends an error message to this Root Port 172 * @id: device ID of agent who sends an error message to this Root Port
173 * 173 *
174 * Invoked when error is detected at the Root Port. 174 * Invoked when error is detected at the Root Port.
175 **/ 175 */
176static struct device* find_source_device(struct pci_dev *parent, u16 id) 176static struct device* find_source_device(struct pci_dev *parent, u16 id)
177{ 177{
178 struct pci_dev *dev = parent; 178 struct pci_dev *dev = parent;
@@ -286,14 +286,15 @@ static void report_resume(struct pci_dev *dev, void *data)
286 286
287/** 287/**
288 * broadcast_error_message - handle message broadcast to downstream drivers 288 * broadcast_error_message - handle message broadcast to downstream drivers
289 * @device: pointer to from where in a hierarchy message is broadcasted down 289 * @dev: pointer to from where in a hierarchy message is broadcasted down
290 * @api: callback to be broadcasted
291 * @state: error state 290 * @state: error state
291 * @error_mesg: message to print
292 * @cb: callback to be broadcasted
292 * 293 *
293 * Invoked during error recovery process. Once being invoked, the content 294 * Invoked during error recovery process. Once being invoked, the content
294 * of error severity will be broadcasted to all downstream drivers in a 295 * of error severity will be broadcasted to all downstream drivers in a
295 * hierarchy in question. 296 * hierarchy in question.
296 **/ 297 */
297static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, 298static pci_ers_result_t broadcast_error_message(struct pci_dev *dev,
298 enum pci_channel_state state, 299 enum pci_channel_state state,
299 char *error_mesg, 300 char *error_mesg,
@@ -428,7 +429,7 @@ static pci_ers_result_t reset_link(struct pcie_device *aerdev,
428 * Invoked when an error is nonfatal/fatal. Once being invoked, broadcast 429 * Invoked when an error is nonfatal/fatal. Once being invoked, broadcast
429 * error detected message to all downstream drivers within a hierarchy in 430 * error detected message to all downstream drivers within a hierarchy in
430 * question and return the returned code. 431 * question and return the returned code.
431 **/ 432 */
432static pci_ers_result_t do_recovery(struct pcie_device *aerdev, 433static pci_ers_result_t do_recovery(struct pcie_device *aerdev,
433 struct pci_dev *dev, 434 struct pci_dev *dev,
434 int severity) 435 int severity)
@@ -488,7 +489,7 @@ static pci_ers_result_t do_recovery(struct pcie_device *aerdev,
488 * @info: comprehensive error information 489 * @info: comprehensive error information
489 * 490 *
490 * Invoked when an error being detected by Root Port. 491 * Invoked when an error being detected by Root Port.
491 **/ 492 */
492static void handle_error_source(struct pcie_device * aerdev, 493static void handle_error_source(struct pcie_device * aerdev,
493 struct pci_dev *dev, 494 struct pci_dev *dev,
494 struct aer_err_info info) 495 struct aer_err_info info)
@@ -521,7 +522,7 @@ static void handle_error_source(struct pcie_device * aerdev,
521 * @rpc: pointer to a Root Port data structure 522 * @rpc: pointer to a Root Port data structure
522 * 523 *
523 * Invoked when PCIE bus loads AER service driver. 524 * Invoked when PCIE bus loads AER service driver.
524 **/ 525 */
525void aer_enable_rootport(struct aer_rpc *rpc) 526void aer_enable_rootport(struct aer_rpc *rpc)
526{ 527{
527 struct pci_dev *pdev = rpc->rpd->port; 528 struct pci_dev *pdev = rpc->rpd->port;
@@ -569,7 +570,7 @@ void aer_enable_rootport(struct aer_rpc *rpc)
569 * @rpc: pointer to a Root Port data structure 570 * @rpc: pointer to a Root Port data structure
570 * 571 *
571 * Invoked when PCIE bus unloads AER service driver. 572 * Invoked when PCIE bus unloads AER service driver.
572 **/ 573 */
573static void disable_root_aer(struct aer_rpc *rpc) 574static void disable_root_aer(struct aer_rpc *rpc)
574{ 575{
575 struct pci_dev *pdev = rpc->rpd->port; 576 struct pci_dev *pdev = rpc->rpd->port;
@@ -590,7 +591,7 @@ static void disable_root_aer(struct aer_rpc *rpc)
590 * @rpc: pointer to the root port which holds an error 591 * @rpc: pointer to the root port which holds an error
591 * 592 *
592 * Invoked by DPC handler to consume an error. 593 * Invoked by DPC handler to consume an error.
593 **/ 594 */
594static struct aer_err_source* get_e_source(struct aer_rpc *rpc) 595static struct aer_err_source* get_e_source(struct aer_rpc *rpc)
595{ 596{
596 struct aer_err_source *e_source; 597 struct aer_err_source *e_source;
@@ -655,7 +656,7 @@ static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
655 * aer_isr_one_error - consume an error detected by root port 656 * aer_isr_one_error - consume an error detected by root port
656 * @p_device: pointer to error root port service device 657 * @p_device: pointer to error root port service device
657 * @e_src: pointer to an error source 658 * @e_src: pointer to an error source
658 **/ 659 */
659static void aer_isr_one_error(struct pcie_device *p_device, 660static void aer_isr_one_error(struct pcie_device *p_device,
660 struct aer_err_source *e_src) 661 struct aer_err_source *e_src)
661{ 662{
@@ -706,7 +707,7 @@ static void aer_isr_one_error(struct pcie_device *p_device,
706 * @work: definition of this work item 707 * @work: definition of this work item
707 * 708 *
708 * Invoked, as DPC, when root port records new detected error 709 * Invoked, as DPC, when root port records new detected error
709 **/ 710 */
710void aer_isr(struct work_struct *work) 711void aer_isr(struct work_struct *work)
711{ 712{
712 struct aer_rpc *rpc = container_of(work, struct aer_rpc, dpc_handler); 713 struct aer_rpc *rpc = container_of(work, struct aer_rpc, dpc_handler);
@@ -729,7 +730,7 @@ void aer_isr(struct work_struct *work)
729 * @rpc: pointer to a root port device being deleted 730 * @rpc: pointer to a root port device being deleted
730 * 731 *
731 * Invoked when AER service unloaded on a specific Root Port 732 * Invoked when AER service unloaded on a specific Root Port
732 **/ 733 */
733void aer_delete_rootport(struct aer_rpc *rpc) 734void aer_delete_rootport(struct aer_rpc *rpc)
734{ 735{
735 /* Disable root port AER itself */ 736 /* Disable root port AER itself */
@@ -743,7 +744,7 @@ void aer_delete_rootport(struct aer_rpc *rpc)
743 * @dev: pointer to AER pcie device 744 * @dev: pointer to AER pcie device
744 * 745 *
745 * Invoked when AER service driver is loaded. 746 * Invoked when AER service driver is loaded.
746 **/ 747 */
747int aer_init(struct pcie_device *dev) 748int aer_init(struct pcie_device *dev)
748{ 749{
749 if (aer_osc_setup(dev) && !forceload) 750 if (aer_osc_setup(dev) && !forceload)
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index df383645e366..26057f98f72e 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -217,7 +217,7 @@ static int slot_reset_iter(struct device *device, void *data)
217 217
218static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev) 218static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev)
219{ 219{
220 pci_ers_result_t status; 220 pci_ers_result_t status = PCI_ERS_RESULT_NONE;
221 int retval; 221 int retval;
222 222
223 /* If fatal, restore cfg space for possible link reset at upstream */ 223 /* If fatal, restore cfg space for possible link reset at upstream */
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index cd0a204d96d1..3c5eb374adf8 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -75,6 +75,7 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
75{ 75{
76 int i = 0; 76 int i = 0;
77 int irq; 77 int irq;
78 int p, t;
78 79
79 if (!valid_IRQ(gsi)) 80 if (!valid_IRQ(gsi))
80 return; 81 return;
@@ -82,18 +83,27 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
82 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && 83 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
83 i < PNP_MAX_IRQ) 84 i < PNP_MAX_IRQ)
84 i++; 85 i++;
85 if (i >= PNP_MAX_IRQ) 86 if (i >= PNP_MAX_IRQ) {
87 printk(KERN_ERR "pnpacpi: exceeded the max number of IRQ "
88 "resources: %d \n", PNP_MAX_IRQ);
86 return; 89 return;
87
88#ifdef CONFIG_X86
89 if (gsi < 16 && (triggering != ACPI_EDGE_SENSITIVE ||
90 polarity != ACPI_ACTIVE_HIGH)) {
91 pnp_warn("BIOS BUG: legacy PNP IRQ %d should be edge trigger, "
92 "active high", gsi);
93 triggering = ACPI_EDGE_SENSITIVE;
94 polarity = ACPI_ACTIVE_HIGH;
95 } 90 }
96#endif 91 /*
92 * in IO-APIC mode, use overrided attribute. Two reasons:
93 * 1. BIOS bug in DSDT
94 * 2. BIOS uses IO-APIC mode Interrupt Source Override
95 */
96 if (!acpi_get_override_irq(gsi, &t, &p)) {
97 t = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
98 p = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
99
100 if (triggering != t || polarity != p) {
101 pnp_warn("IRQ %d override to %s, %s",
102 gsi, t ? "edge":"level", p ? "low":"high");
103 triggering = t;
104 polarity = p;
105 }
106 }
97 107
98 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 108 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
99 res->irq_resource[i].flags |= irq_flags(triggering, polarity); 109 res->irq_resource[i].flags |= irq_flags(triggering, polarity);
@@ -173,6 +183,9 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res,
173 } 183 }
174 res->dma_resource[i].start = dma; 184 res->dma_resource[i].start = dma;
175 res->dma_resource[i].end = dma; 185 res->dma_resource[i].end = dma;
186 } else {
187 printk(KERN_ERR "pnpacpi: exceeded the max number of DMA "
188 "resources: %d \n", PNP_MAX_DMA);
176 } 189 }
177} 190}
178 191
@@ -194,6 +207,9 @@ static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
194 } 207 }
195 res->port_resource[i].start = io; 208 res->port_resource[i].start = io;
196 res->port_resource[i].end = io + len - 1; 209 res->port_resource[i].end = io + len - 1;
210 } else {
211 printk(KERN_ERR "pnpacpi: exceeded the max number of IO "
212 "resources: %d \n", PNP_MAX_PORT);
197 } 213 }
198} 214}
199 215
@@ -217,6 +233,9 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
217 233
218 res->mem_resource[i].start = mem; 234 res->mem_resource[i].start = mem;
219 res->mem_resource[i].end = mem + len - 1; 235 res->mem_resource[i].end = mem + len - 1;
236 } else {
237 printk(KERN_ERR "pnpacpi: exceeded the max number of mem "
238 "resources: %d\n", PNP_MAX_MEM);
220 } 239 }
221} 240}
222 241
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 41d73a5e9312..e50ebcffb962 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -367,8 +367,10 @@ int pnp_check_irq(struct pnp_dev *dev, int idx)
367 { 367 {
368 struct pci_dev *pci = NULL; 368 struct pci_dev *pci = NULL;
369 for_each_pci_dev(pci) { 369 for_each_pci_dev(pci) {
370 if (pci->irq == *irq) 370 if (pci->irq == *irq) {
371 pci_dev_put(pci);
371 return 0; 372 return 0;
373 }
372 } 374 }
373 } 375 }
374#endif 376#endif
diff --git a/drivers/ps3/Makefile b/drivers/ps3/Makefile
index 746031de2195..1f5a2d33bf5b 100644
--- a/drivers/ps3/Makefile
+++ b/drivers/ps3/Makefile
@@ -1,6 +1,6 @@
1obj-$(CONFIG_PS3_VUART) += vuart.o 1obj-$(CONFIG_PS3_VUART) += ps3-vuart.o
2obj-$(CONFIG_PS3_PS3AV) += ps3av_mod.o 2obj-$(CONFIG_PS3_PS3AV) += ps3av_mod.o
3ps3av_mod-objs += ps3av.o ps3av_cmd.o 3ps3av_mod-objs += ps3av.o ps3av_cmd.o
4obj-$(CONFIG_PPC_PS3) += sys-manager-core.o 4obj-$(CONFIG_PPC_PS3) += sys-manager-core.o
5obj-$(CONFIG_PS3_SYS_MANAGER) += sys-manager.o 5obj-$(CONFIG_PS3_SYS_MANAGER) += ps3-sys-manager.o
6obj-$(CONFIG_PS3_STORAGE) += ps3stor_lib.o 6obj-$(CONFIG_PS3_STORAGE) += ps3stor_lib.o
diff --git a/drivers/ps3/sys-manager.c b/drivers/ps3/ps3-sys-manager.c
index 8461b08ab9fb..8461b08ab9fb 100644
--- a/drivers/ps3/sys-manager.c
+++ b/drivers/ps3/ps3-sys-manager.c
diff --git a/drivers/ps3/vuart.c b/drivers/ps3/ps3-vuart.c
index 9dea585ef806..9dea585ef806 100644
--- a/drivers/ps3/vuart.c
+++ b/drivers/ps3/ps3-vuart.c
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index e5cdc0294aaa..1e6715ec51ef 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -447,7 +447,7 @@ config RTC_DRV_AT91RM9200
447 447
448config RTC_DRV_BFIN 448config RTC_DRV_BFIN
449 tristate "Blackfin On-Chip RTC" 449 tristate "Blackfin On-Chip RTC"
450 depends on BFIN 450 depends on BLACKFIN
451 help 451 help
452 If you say yes here you will get support for the 452 If you say yes here you will get support for the
453 Blackfin On-Chip Real Time Clock. 453 Blackfin On-Chip Real Time Clock.
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index de0da545c7a1..a4f56e95cf96 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -293,7 +293,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
293 return -EINVAL; 293 return -EINVAL;
294 294
295 /* Cannot register while the char dev is in use */ 295 /* Cannot register while the char dev is in use */
296 if (!(mutex_trylock(&rtc->char_lock))) 296 if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags))
297 return -EBUSY; 297 return -EBUSY;
298 298
299 spin_lock_irq(&rtc->irq_task_lock); 299 spin_lock_irq(&rtc->irq_task_lock);
@@ -303,7 +303,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
303 } 303 }
304 spin_unlock_irq(&rtc->irq_task_lock); 304 spin_unlock_irq(&rtc->irq_task_lock);
305 305
306 mutex_unlock(&rtc->char_lock); 306 clear_bit(RTC_DEV_BUSY, &rtc->flags);
307 307
308 return retval; 308 return retval;
309} 309}
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 814583bd2fe7..ae1bf177d625 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -26,10 +26,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
26 struct rtc_device, char_dev); 26 struct rtc_device, char_dev);
27 const struct rtc_class_ops *ops = rtc->ops; 27 const struct rtc_class_ops *ops = rtc->ops;
28 28
29 /* We keep the lock as long as the device is in use 29 if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags))
30 * and return immediately if busy
31 */
32 if (!(mutex_trylock(&rtc->char_lock)))
33 return -EBUSY; 30 return -EBUSY;
34 31
35 file->private_data = rtc; 32 file->private_data = rtc;
@@ -43,8 +40,8 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
43 return 0; 40 return 0;
44 } 41 }
45 42
46 /* something has gone wrong, release the lock */ 43 /* something has gone wrong */
47 mutex_unlock(&rtc->char_lock); 44 clear_bit(RTC_DEV_BUSY, &rtc->flags);
48 return err; 45 return err;
49} 46}
50 47
@@ -405,7 +402,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
405 if (rtc->ops->release) 402 if (rtc->ops->release)
406 rtc->ops->release(rtc->dev.parent); 403 rtc->ops->release(rtc->dev.parent);
407 404
408 mutex_unlock(&rtc->char_lock); 405 clear_bit(RTC_DEV_BUSY, &rtc->flags);
409 return 0; 406 return 0;
410} 407}
411 408
@@ -440,7 +437,6 @@ void rtc_dev_prepare(struct rtc_device *rtc)
440 437
441 rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id); 438 rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id);
442 439
443 mutex_init(&rtc->char_lock);
444#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 440#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
445 INIT_WORK(&rtc->uie_task, rtc_uie_task); 441 INIT_WORK(&rtc->uie_task, rtc_uie_task);
446 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc); 442 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc);
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 838f7ac0dc32..6db31089d2d7 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -483,7 +483,7 @@ static DECLARE_WORK(css_reprobe_work, reprobe_all);
483void css_schedule_reprobe(void) 483void css_schedule_reprobe(void)
484{ 484{
485 need_reprobe = 1; 485 need_reprobe = 1;
486 queue_work(ccw_device_work, &css_reprobe_work); 486 queue_work(slow_path_wq, &css_reprobe_work);
487} 487}
488 488
489EXPORT_SYMBOL_GPL(css_schedule_reprobe); 489EXPORT_SYMBOL_GPL(css_schedule_reprobe);
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index 8867443b8060..bfad421cda66 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -1034,7 +1034,7 @@ device_trigger_reprobe(struct subchannel *sch)
1034 if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) { 1034 if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) {
1035 PREPARE_WORK(&cdev->private->kick_work, 1035 PREPARE_WORK(&cdev->private->kick_work,
1036 ccw_device_move_to_orphanage); 1036 ccw_device_move_to_orphanage);
1037 queue_work(ccw_device_work, &cdev->private->kick_work); 1037 queue_work(slow_path_wq, &cdev->private->kick_work);
1038 } else 1038 } else
1039 ccw_device_start_id(cdev, 0); 1039 ccw_device_start_id(cdev, 0);
1040} 1040}
diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c
index f232832f2b22..2f6bf462425e 100644
--- a/drivers/s390/cio/device_id.c
+++ b/drivers/s390/cio/device_id.c
@@ -113,19 +113,10 @@ __ccw_device_sense_id_start(struct ccw_device *cdev)
113{ 113{
114 struct subchannel *sch; 114 struct subchannel *sch;
115 struct ccw1 *ccw; 115 struct ccw1 *ccw;
116 int ret;
117 116
118 sch = to_subchannel(cdev->dev.parent); 117 sch = to_subchannel(cdev->dev.parent);
119 /* Setup sense channel program. */ 118 /* Setup sense channel program. */
120 ccw = cdev->private->iccws; 119 ccw = cdev->private->iccws;
121 if (sch->schib.pmcw.pim != 0x80) {
122 /* more than one path installed. */
123 ccw->cmd_code = CCW_CMD_SUSPEND_RECONN;
124 ccw->cda = 0;
125 ccw->count = 0;
126 ccw->flags = CCW_FLAG_SLI | CCW_FLAG_CC;
127 ccw++;
128 }
129 ccw->cmd_code = CCW_CMD_SENSE_ID; 120 ccw->cmd_code = CCW_CMD_SENSE_ID;
130 ccw->cda = (__u32) __pa (&cdev->private->senseid); 121 ccw->cda = (__u32) __pa (&cdev->private->senseid);
131 ccw->count = sizeof (struct senseid); 122 ccw->count = sizeof (struct senseid);
@@ -133,25 +124,9 @@ __ccw_device_sense_id_start(struct ccw_device *cdev)
133 124
134 /* Reset device status. */ 125 /* Reset device status. */
135 memset(&cdev->private->irb, 0, sizeof(struct irb)); 126 memset(&cdev->private->irb, 0, sizeof(struct irb));
127 cdev->private->flags.intretry = 0;
136 128
137 /* Try on every path. */ 129 return cio_start(sch, ccw, LPM_ANYPATH);
138 ret = -ENODEV;
139 while (cdev->private->imask != 0) {
140 if ((sch->opm & cdev->private->imask) != 0 &&
141 cdev->private->iretry > 0) {
142 cdev->private->iretry--;
143 /* Reset internal retry indication. */
144 cdev->private->flags.intretry = 0;
145 ret = cio_start (sch, cdev->private->iccws,
146 cdev->private->imask);
147 /* ret is 0, -EBUSY, -EACCES or -ENODEV */
148 if (ret != -EACCES)
149 return ret;
150 }
151 cdev->private->imask >>= 1;
152 cdev->private->iretry = 5;
153 }
154 return ret;
155} 130}
156 131
157void 132void
@@ -161,8 +136,7 @@ ccw_device_sense_id_start(struct ccw_device *cdev)
161 136
162 memset (&cdev->private->senseid, 0, sizeof (struct senseid)); 137 memset (&cdev->private->senseid, 0, sizeof (struct senseid));
163 cdev->private->senseid.cu_type = 0xFFFF; 138 cdev->private->senseid.cu_type = 0xFFFF;
164 cdev->private->imask = 0x80; 139 cdev->private->iretry = 3;
165 cdev->private->iretry = 5;
166 ret = __ccw_device_sense_id_start(cdev); 140 ret = __ccw_device_sense_id_start(cdev);
167 if (ret && ret != -EBUSY) 141 if (ret && ret != -EBUSY)
168 ccw_device_sense_id_done(cdev, ret); 142 ccw_device_sense_id_done(cdev, ret);
@@ -278,14 +252,13 @@ ccw_device_sense_id_irq(struct ccw_device *cdev, enum dev_event dev_event)
278 ccw_device_sense_id_done(cdev, ret); 252 ccw_device_sense_id_done(cdev, ret);
279 break; 253 break;
280 case -EACCES: /* channel is not operational. */ 254 case -EACCES: /* channel is not operational. */
281 sch->lpm &= ~cdev->private->imask;
282 cdev->private->imask >>= 1;
283 cdev->private->iretry = 5;
284 /* fall through. */
285 case -EAGAIN: /* try again. */ 255 case -EAGAIN: /* try again. */
286 ret = __ccw_device_sense_id_start(cdev); 256 cdev->private->iretry--;
287 if (ret == 0 || ret == -EBUSY) 257 if (cdev->private->iretry > 0) {
288 break; 258 ret = __ccw_device_sense_id_start(cdev);
259 if (ret == 0 || ret == -EBUSY)
260 break;
261 }
289 /* fall through. */ 262 /* fall through. */
290 default: /* Sense ID failed. Try asking VM. */ 263 default: /* Sense ID failed. Try asking VM. */
291 if (MACHINE_IS_VM) { 264 if (MACHINE_IS_VM) {
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index 6bf3ebbe985a..b3b6f654365c 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -2782,35 +2782,14 @@ ctc_probe_device(struct ccwgroup_device *cgdev)
2782} 2782}
2783 2783
2784/** 2784/**
2785 * Initialize everything of the net device except the name and the 2785 * Device setup function called by alloc_netdev().
2786 * channel structs. 2786 *
2787 * @param dev Device to be setup.
2787 */ 2788 */
2788static struct net_device * 2789void ctc_init_netdevice(struct net_device * dev)
2789ctc_init_netdevice(struct net_device * dev, int alloc_device,
2790 struct ctc_priv *privptr)
2791{ 2790{
2792 if (!privptr)
2793 return NULL;
2794
2795 DBF_TEXT(setup, 3, __FUNCTION__); 2791 DBF_TEXT(setup, 3, __FUNCTION__);
2796 2792
2797 if (alloc_device) {
2798 dev = kzalloc(sizeof(struct net_device), GFP_KERNEL);
2799 if (!dev)
2800 return NULL;
2801 }
2802
2803 dev->priv = privptr;
2804 privptr->fsm = init_fsm("ctcdev", dev_state_names,
2805 dev_event_names, CTC_NR_DEV_STATES, CTC_NR_DEV_EVENTS,
2806 dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
2807 if (privptr->fsm == NULL) {
2808 if (alloc_device)
2809 kfree(dev);
2810 return NULL;
2811 }
2812 fsm_newstate(privptr->fsm, DEV_STATE_STOPPED);
2813 fsm_settimer(privptr->fsm, &privptr->restart_timer);
2814 if (dev->mtu == 0) 2793 if (dev->mtu == 0)
2815 dev->mtu = CTC_BUFSIZE_DEFAULT - LL_HEADER_LENGTH - 2; 2794 dev->mtu = CTC_BUFSIZE_DEFAULT - LL_HEADER_LENGTH - 2;
2816 dev->hard_start_xmit = ctc_tx; 2795 dev->hard_start_xmit = ctc_tx;
@@ -2823,7 +2802,7 @@ ctc_init_netdevice(struct net_device * dev, int alloc_device,
2823 dev->type = ARPHRD_SLIP; 2802 dev->type = ARPHRD_SLIP;
2824 dev->tx_queue_len = 100; 2803 dev->tx_queue_len = 100;
2825 dev->flags = IFF_POINTOPOINT | IFF_NOARP; 2804 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
2826 return dev; 2805 SET_MODULE_OWNER(dev);
2827} 2806}
2828 2807
2829 2808
@@ -2879,14 +2858,22 @@ ctc_new_device(struct ccwgroup_device *cgdev)
2879 "ccw_device_set_online (cdev[1]) failed with ret = %d\n", ret); 2858 "ccw_device_set_online (cdev[1]) failed with ret = %d\n", ret);
2880 } 2859 }
2881 2860
2882 dev = ctc_init_netdevice(NULL, 1, privptr); 2861 dev = alloc_netdev(0, "ctc%d", ctc_init_netdevice);
2883
2884 if (!dev) { 2862 if (!dev) {
2885 ctc_pr_warn("ctc_init_netdevice failed\n"); 2863 ctc_pr_warn("ctc_init_netdevice failed\n");
2886 goto out; 2864 goto out;
2887 } 2865 }
2866 dev->priv = privptr;
2888 2867
2889 strlcpy(dev->name, "ctc%d", IFNAMSIZ); 2868 privptr->fsm = init_fsm("ctcdev", dev_state_names,
2869 dev_event_names, CTC_NR_DEV_STATES, CTC_NR_DEV_EVENTS,
2870 dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
2871 if (privptr->fsm == NULL) {
2872 free_netdev(dev);
2873 goto out;
2874 }
2875 fsm_newstate(privptr->fsm, DEV_STATE_STOPPED);
2876 fsm_settimer(privptr->fsm, &privptr->restart_timer);
2890 2877
2891 for (direction = READ; direction <= WRITE; direction++) { 2878 for (direction = READ; direction <= WRITE; direction++) {
2892 privptr->channel[direction] = 2879 privptr->channel[direction] =
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 8d0244c2e7d4..7a835a35f21d 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -242,16 +242,6 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
242 } 242 }
243} 243}
244 244
245static void hexdump(u8 *x, int len)
246{
247 int i;
248
249 printk("[ ");
250 for (i = 0; i < len; i++)
251 printk("%x ", x[i]);
252 printk("]\n");
253}
254
255static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_command) 245static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_command)
256{ 246{
257 idescsi_scsi_t *scsi = drive_to_idescsi(drive); 247 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
@@ -282,7 +272,8 @@ static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_co
282 pc->scsi_cmd = ((idescsi_pc_t *) failed_command->special)->scsi_cmd; 272 pc->scsi_cmd = ((idescsi_pc_t *) failed_command->special)->scsi_cmd;
283 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { 273 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) {
284 printk ("ide-scsi: %s: queue cmd = ", drive->name); 274 printk ("ide-scsi: %s: queue cmd = ", drive->name);
285 hexdump(pc->c, 6); 275 print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, pc->c,
276 6, 0);
286 } 277 }
287 rq->rq_disk = scsi->disk; 278 rq->rq_disk = scsi->disk;
288 return ide_do_drive_cmd(drive, rq, ide_preempt); 279 return ide_do_drive_cmd(drive, rq, ide_preempt);
@@ -337,7 +328,8 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
337 idescsi_pc_t *opc = (idescsi_pc_t *) rq->buffer; 328 idescsi_pc_t *opc = (idescsi_pc_t *) rq->buffer;
338 if (log) { 329 if (log) {
339 printk ("ide-scsi: %s: wrap up check %lu, rst = ", drive->name, opc->scsi_cmd->serial_number); 330 printk ("ide-scsi: %s: wrap up check %lu, rst = ", drive->name, opc->scsi_cmd->serial_number);
340 hexdump(pc->buffer,16); 331 print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1,
332 pc->buffer, 16, 0);
341 } 333 }
342 memcpy((void *) opc->scsi_cmd->sense_buffer, pc->buffer, SCSI_SENSE_BUFFERSIZE); 334 memcpy((void *) opc->scsi_cmd->sense_buffer, pc->buffer, SCSI_SENSE_BUFFERSIZE);
343 kfree(pc->buffer); 335 kfree(pc->buffer);
@@ -816,10 +808,12 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
816 808
817 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { 809 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) {
818 printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number); 810 printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number);
819 hexdump(cmd->cmnd, cmd->cmd_len); 811 print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1,
812 cmd->cmnd, cmd->cmd_len, 0);
820 if (memcmp(pc->c, cmd->cmnd, cmd->cmd_len)) { 813 if (memcmp(pc->c, cmd->cmnd, cmd->cmd_len)) {
821 printk ("ide-scsi: %s: que %lu, tsl = ", drive->name, cmd->serial_number); 814 printk ("ide-scsi: %s: que %lu, tsl = ", drive->name, cmd->serial_number);
822 hexdump(pc->c, 12); 815 print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1,
816 pc->c, 12, 0);
823 } 817 }
824 } 818 }
825 819
diff --git a/drivers/scsi/zorro7xx.c b/drivers/scsi/zorro7xx.c
index ac67394c7373..64d40a2d4d4d 100644
--- a/drivers/scsi/zorro7xx.c
+++ b/drivers/scsi/zorro7xx.c
@@ -13,7 +13,10 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/zorro.h> 15#include <linux/zorro.h>
16
17#include <asm/amigahw.h>
16#include <asm/amigaints.h> 18#include <asm/amigaints.h>
19
17#include <scsi/scsi_host.h> 20#include <scsi/scsi_host.h>
18#include <scsi/scsi_transport_spi.h> 21#include <scsi/scsi_transport_spi.h>
19 22
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index ed438bc7e98d..d7e1996e2fec 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -600,7 +600,7 @@ config SERIAL_SA1100_CONSOLE
600 600
601config SERIAL_BFIN 601config SERIAL_BFIN
602 tristate "Blackfin serial port support" 602 tristate "Blackfin serial port support"
603 depends on BFIN 603 depends on BLACKFIN
604 select SERIAL_CORE 604 select SERIAL_CORE
605 select SERIAL_BFIN_UART0 if (BF531 || BF532 || BF533 || BF561) 605 select SERIAL_BFIN_UART0 if (BF531 || BF532 || BF533 || BF561)
606 help 606 help
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
index f3257f708ef9..9c95bc0398ad 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/serial/ip22zilog.c
@@ -45,8 +45,6 @@
45 45
46#include "ip22zilog.h" 46#include "ip22zilog.h"
47 47
48void ip22_do_break(void);
49
50/* 48/*
51 * On IP22 we need to delay after register accesses but we do not need to 49 * On IP22 we need to delay after register accesses but we do not need to
52 * flush writes. 50 * flush writes.
@@ -81,12 +79,9 @@ struct uart_ip22zilog_port {
81#define IP22ZILOG_FLAG_REGS_HELD 0x00000040 79#define IP22ZILOG_FLAG_REGS_HELD 0x00000040
82#define IP22ZILOG_FLAG_TX_STOPPED 0x00000080 80#define IP22ZILOG_FLAG_TX_STOPPED 0x00000080
83#define IP22ZILOG_FLAG_TX_ACTIVE 0x00000100 81#define IP22ZILOG_FLAG_TX_ACTIVE 0x00000100
82#define IP22ZILOG_FLAG_RESET_DONE 0x00000200
84 83
85 unsigned int cflag; 84 unsigned int tty_break;
86
87 /* L1-A keyboard break state. */
88 int kbd_id;
89 int l1_down;
90 85
91 unsigned char parity_mask; 86 unsigned char parity_mask;
92 unsigned char prev_status; 87 unsigned char prev_status;
@@ -250,13 +245,26 @@ static void ip22zilog_maybe_update_regs(struct uart_ip22zilog_port *up,
250 } 245 }
251} 246}
252 247
253static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, 248#define Rx_BRK 0x0100 /* BREAK event software flag. */
254 struct zilog_channel *channel) 249#define Rx_SYS 0x0200 /* SysRq event software flag. */
250
251static struct tty_struct *ip22zilog_receive_chars(struct uart_ip22zilog_port *up,
252 struct zilog_channel *channel)
255{ 253{
256 struct tty_struct *tty = up->port.info->tty; /* XXX info==NULL? */ 254 struct tty_struct *tty;
255 unsigned char ch, flag;
256 unsigned int r1;
257
258 tty = NULL;
259 if (up->port.info != NULL &&
260 up->port.info->tty != NULL)
261 tty = up->port.info->tty;
257 262
258 while (1) { 263 for (;;) {
259 unsigned char ch, r1, flag; 264 ch = readb(&channel->control);
265 ZSDELAY();
266 if (!(ch & Rx_CH_AV))
267 break;
260 268
261 r1 = read_zsreg(channel, R1); 269 r1 = read_zsreg(channel, R1);
262 if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) { 270 if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) {
@@ -265,43 +273,26 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up,
265 ZS_WSYNC(channel); 273 ZS_WSYNC(channel);
266 } 274 }
267 275
268 ch = readb(&channel->control);
269 ZSDELAY();
270
271 /* This funny hack depends upon BRK_ABRT not interfering
272 * with the other bits we care about in R1.
273 */
274 if (ch & BRK_ABRT)
275 r1 |= BRK_ABRT;
276
277 ch = readb(&channel->data); 276 ch = readb(&channel->data);
278 ZSDELAY(); 277 ZSDELAY();
279 278
280 ch &= up->parity_mask; 279 ch &= up->parity_mask;
281 280
282 if (ZS_IS_CONS(up) && (r1 & BRK_ABRT)) { 281 /* Handle the null char got when BREAK is removed. */
283 /* Wait for BREAK to deassert to avoid potentially 282 if (!ch)
284 * confusing the PROM. 283 r1 |= up->tty_break;
285 */
286 while (1) {
287 ch = readb(&channel->control);
288 ZSDELAY();
289 if (!(ch & BRK_ABRT))
290 break;
291 }
292 ip22_do_break();
293 return;
294 }
295 284
296 /* A real serial line, record the character and status. */ 285 /* A real serial line, record the character and status. */
297 flag = TTY_NORMAL; 286 flag = TTY_NORMAL;
298 up->port.icount.rx++; 287 up->port.icount.rx++;
299 if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) { 288 if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR | Rx_SYS | Rx_BRK)) {
300 if (r1 & BRK_ABRT) { 289 up->tty_break = 0;
301 r1 &= ~(PAR_ERR | CRC_ERR); 290
291 if (r1 & (Rx_SYS | Rx_BRK)) {
302 up->port.icount.brk++; 292 up->port.icount.brk++;
303 if (uart_handle_break(&up->port)) 293 if (r1 & Rx_SYS)
304 goto next_char; 294 continue;
295 r1 &= ~(PAR_ERR | CRC_ERR);
305 } 296 }
306 else if (r1 & PAR_ERR) 297 else if (r1 & PAR_ERR)
307 up->port.icount.parity++; 298 up->port.icount.parity++;
@@ -310,30 +301,21 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up,
310 if (r1 & Rx_OVR) 301 if (r1 & Rx_OVR)
311 up->port.icount.overrun++; 302 up->port.icount.overrun++;
312 r1 &= up->port.read_status_mask; 303 r1 &= up->port.read_status_mask;
313 if (r1 & BRK_ABRT) 304 if (r1 & Rx_BRK)
314 flag = TTY_BREAK; 305 flag = TTY_BREAK;
315 else if (r1 & PAR_ERR) 306 else if (r1 & PAR_ERR)
316 flag = TTY_PARITY; 307 flag = TTY_PARITY;
317 else if (r1 & CRC_ERR) 308 else if (r1 & CRC_ERR)
318 flag = TTY_FRAME; 309 flag = TTY_FRAME;
319 } 310 }
320 if (uart_handle_sysrq_char(&up->port, ch))
321 goto next_char;
322 311
323 if (up->port.ignore_status_mask == 0xff || 312 if (uart_handle_sysrq_char(&up->port, ch))
324 (r1 & up->port.ignore_status_mask) == 0) 313 continue;
325 tty_insert_flip_char(tty, ch, flag);
326 314
327 if (r1 & Rx_OVR) 315 if (tty)
328 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 316 uart_insert_char(&up->port, r1, Rx_OVR, ch, flag);
329 next_char:
330 ch = readb(&channel->control);
331 ZSDELAY();
332 if (!(ch & Rx_CH_AV))
333 break;
334 } 317 }
335 318 return tty;
336 tty_flip_buffer_push(tty);
337} 319}
338 320
339static void ip22zilog_status_handle(struct uart_ip22zilog_port *up, 321static void ip22zilog_status_handle(struct uart_ip22zilog_port *up,
@@ -348,6 +330,15 @@ static void ip22zilog_status_handle(struct uart_ip22zilog_port *up,
348 ZSDELAY(); 330 ZSDELAY();
349 ZS_WSYNC(channel); 331 ZS_WSYNC(channel);
350 332
333 if (up->curregs[R15] & BRKIE) {
334 if ((status & BRK_ABRT) && !(up->prev_status & BRK_ABRT)) {
335 if (uart_handle_break(&up->port))
336 up->tty_break = Rx_SYS;
337 else
338 up->tty_break = Rx_BRK;
339 }
340 }
341
351 if (ZS_WANTS_MODEM_STATUS(up)) { 342 if (ZS_WANTS_MODEM_STATUS(up)) {
352 if (status & SYNC) 343 if (status & SYNC)
353 up->port.icount.dsr++; 344 up->port.icount.dsr++;
@@ -356,10 +347,10 @@ static void ip22zilog_status_handle(struct uart_ip22zilog_port *up,
356 * But it does not tell us which bit has changed, we have to keep 347 * But it does not tell us which bit has changed, we have to keep
357 * track of this ourselves. 348 * track of this ourselves.
358 */ 349 */
359 if ((status & DCD) ^ up->prev_status) 350 if ((status ^ up->prev_status) ^ DCD)
360 uart_handle_dcd_change(&up->port, 351 uart_handle_dcd_change(&up->port,
361 (status & DCD)); 352 (status & DCD));
362 if ((status & CTS) ^ up->prev_status) 353 if ((status ^ up->prev_status) ^ CTS)
363 uart_handle_cts_change(&up->port, 354 uart_handle_cts_change(&up->port,
364 (status & CTS)); 355 (status & CTS));
365 356
@@ -447,19 +438,21 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id)
447 while (up) { 438 while (up) {
448 struct zilog_channel *channel 439 struct zilog_channel *channel
449 = ZILOG_CHANNEL_FROM_PORT(&up->port); 440 = ZILOG_CHANNEL_FROM_PORT(&up->port);
441 struct tty_struct *tty;
450 unsigned char r3; 442 unsigned char r3;
451 443
452 spin_lock(&up->port.lock); 444 spin_lock(&up->port.lock);
453 r3 = read_zsreg(channel, R3); 445 r3 = read_zsreg(channel, R3);
454 446
455 /* Channel A */ 447 /* Channel A */
448 tty = NULL;
456 if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { 449 if (r3 & (CHAEXT | CHATxIP | CHARxIP)) {
457 writeb(RES_H_IUS, &channel->control); 450 writeb(RES_H_IUS, &channel->control);
458 ZSDELAY(); 451 ZSDELAY();
459 ZS_WSYNC(channel); 452 ZS_WSYNC(channel);
460 453
461 if (r3 & CHARxIP) 454 if (r3 & CHARxIP)
462 ip22zilog_receive_chars(up, channel); 455 tty = ip22zilog_receive_chars(up, channel);
463 if (r3 & CHAEXT) 456 if (r3 & CHAEXT)
464 ip22zilog_status_handle(up, channel); 457 ip22zilog_status_handle(up, channel);
465 if (r3 & CHATxIP) 458 if (r3 & CHATxIP)
@@ -467,18 +460,22 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id)
467 } 460 }
468 spin_unlock(&up->port.lock); 461 spin_unlock(&up->port.lock);
469 462
463 if (tty)
464 tty_flip_buffer_push(tty);
465
470 /* Channel B */ 466 /* Channel B */
471 up = up->next; 467 up = up->next;
472 channel = ZILOG_CHANNEL_FROM_PORT(&up->port); 468 channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
473 469
474 spin_lock(&up->port.lock); 470 spin_lock(&up->port.lock);
471 tty = NULL;
475 if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { 472 if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) {
476 writeb(RES_H_IUS, &channel->control); 473 writeb(RES_H_IUS, &channel->control);
477 ZSDELAY(); 474 ZSDELAY();
478 ZS_WSYNC(channel); 475 ZS_WSYNC(channel);
479 476
480 if (r3 & CHBRxIP) 477 if (r3 & CHBRxIP)
481 ip22zilog_receive_chars(up, channel); 478 tty = ip22zilog_receive_chars(up, channel);
482 if (r3 & CHBEXT) 479 if (r3 & CHBEXT)
483 ip22zilog_status_handle(up, channel); 480 ip22zilog_status_handle(up, channel);
484 if (r3 & CHBTxIP) 481 if (r3 & CHBTxIP)
@@ -486,6 +483,9 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id)
486 } 483 }
487 spin_unlock(&up->port.lock); 484 spin_unlock(&up->port.lock);
488 485
486 if (tty)
487 tty_flip_buffer_push(tty);
488
489 up = up->next; 489 up = up->next;
490 } 490 }
491 491
@@ -681,11 +681,46 @@ static void ip22zilog_break_ctl(struct uart_port *port, int break_state)
681 spin_unlock_irqrestore(&port->lock, flags); 681 spin_unlock_irqrestore(&port->lock, flags);
682} 682}
683 683
684static void __ip22zilog_reset(struct uart_ip22zilog_port *up)
685{
686 struct zilog_channel *channel;
687 int i;
688
689 if (up->flags & IP22ZILOG_FLAG_RESET_DONE)
690 return;
691
692 /* Let pending transmits finish. */
693 channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
694 for (i = 0; i < 1000; i++) {
695 unsigned char stat = read_zsreg(channel, R1);
696 if (stat & ALL_SNT)
697 break;
698 udelay(100);
699 }
700
701 if (!ZS_IS_CHANNEL_A(up)) {
702 up++;
703 channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
704 }
705 write_zsreg(channel, R9, FHWRES);
706 ZSDELAY_LONG();
707 (void) read_zsreg(channel, R0);
708
709 up->flags |= IP22ZILOG_FLAG_RESET_DONE;
710 up->next->flags |= IP22ZILOG_FLAG_RESET_DONE;
711}
712
684static void __ip22zilog_startup(struct uart_ip22zilog_port *up) 713static void __ip22zilog_startup(struct uart_ip22zilog_port *up)
685{ 714{
686 struct zilog_channel *channel; 715 struct zilog_channel *channel;
687 716
688 channel = ZILOG_CHANNEL_FROM_PORT(&up->port); 717 channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
718
719 __ip22zilog_reset(up);
720
721 __load_zsregs(channel, up->curregs);
722 /* set master interrupt enable */
723 write_zsreg(channel, R9, up->curregs[R9]);
689 up->prev_status = readb(&channel->control); 724 up->prev_status = readb(&channel->control);
690 725
691 /* Enable receiver and transmitter. */ 726 /* Enable receiver and transmitter. */
@@ -859,8 +894,6 @@ ip22zilog_set_termios(struct uart_port *port, struct ktermios *termios,
859 else 894 else
860 up->flags &= ~IP22ZILOG_FLAG_MODEM_STATUS; 895 up->flags &= ~IP22ZILOG_FLAG_MODEM_STATUS;
861 896
862 up->cflag = termios->c_cflag;
863
864 ip22zilog_maybe_update_regs(up, ZILOG_CHANNEL_FROM_PORT(port)); 897 ip22zilog_maybe_update_regs(up, ZILOG_CHANNEL_FROM_PORT(port));
865 uart_update_timeout(port, termios->c_cflag, baud); 898 uart_update_timeout(port, termios->c_cflag, baud);
866 899
@@ -992,74 +1025,29 @@ ip22zilog_console_write(struct console *con, const char *s, unsigned int count)
992 spin_unlock_irqrestore(&up->port.lock, flags); 1025 spin_unlock_irqrestore(&up->port.lock, flags);
993} 1026}
994 1027
995void
996ip22serial_console_termios(struct console *con, char *options)
997{
998 int baud = 9600, bits = 8, cflag;
999 int parity = 'n';
1000 int flow = 'n';
1001
1002 if (options)
1003 uart_parse_options(options, &baud, &parity, &bits, &flow);
1004
1005 cflag = CREAD | HUPCL | CLOCAL;
1006
1007 switch (baud) {
1008 case 150: cflag |= B150; break;
1009 case 300: cflag |= B300; break;
1010 case 600: cflag |= B600; break;
1011 case 1200: cflag |= B1200; break;
1012 case 2400: cflag |= B2400; break;
1013 case 4800: cflag |= B4800; break;
1014 case 9600: cflag |= B9600; break;
1015 case 19200: cflag |= B19200; break;
1016 case 38400: cflag |= B38400; break;
1017 default: baud = 9600; cflag |= B9600; break;
1018 }
1019
1020 con->cflag = cflag | CS8; /* 8N1 */
1021
1022 uart_update_timeout(&ip22zilog_port_table[con->index].port, cflag, baud);
1023}
1024
1025static int __init ip22zilog_console_setup(struct console *con, char *options) 1028static int __init ip22zilog_console_setup(struct console *con, char *options)
1026{ 1029{
1027 struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index]; 1030 struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index];
1028 unsigned long flags; 1031 unsigned long flags;
1029 int baud, brg; 1032 int baud = 9600, bits = 8;
1030 1033 int parity = 'n';
1031 printk("Console: ttyS%d (IP22-Zilog)\n", con->index); 1034 int flow = 'n';
1032 1035
1033 /* Get firmware console settings. */ 1036 up->flags |= IP22ZILOG_FLAG_IS_CONS;
1034 ip22serial_console_termios(con, options);
1035 1037
1036 /* Firmware console speed is limited to 150-->38400 baud so 1038 printk(KERN_INFO "Console: ttyS%d (IP22-Zilog)\n", con->index);
1037 * this hackish cflag thing is OK.
1038 */
1039 switch (con->cflag & CBAUD) {
1040 case B150: baud = 150; break;
1041 case B300: baud = 300; break;
1042 case B600: baud = 600; break;
1043 case B1200: baud = 1200; break;
1044 case B2400: baud = 2400; break;
1045 case B4800: baud = 4800; break;
1046 default: case B9600: baud = 9600; break;
1047 case B19200: baud = 19200; break;
1048 case B38400: baud = 38400; break;
1049 };
1050
1051 brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR);
1052 1039
1053 spin_lock_irqsave(&up->port.lock, flags); 1040 spin_lock_irqsave(&up->port.lock, flags);
1054 1041
1055 up->curregs[R15] = BRKIE; 1042 up->curregs[R15] |= BRKIE;
1056 ip22zilog_convert_to_zs(up, con->cflag, 0, brg);
1057 1043
1058 __ip22zilog_startup(up); 1044 __ip22zilog_startup(up);
1059 1045
1060 spin_unlock_irqrestore(&up->port.lock, flags); 1046 spin_unlock_irqrestore(&up->port.lock, flags);
1061 1047
1062 return 0; 1048 if (options)
1049 uart_parse_options(options, &baud, &parity, &bits, &flow);
1050 return uart_set_options(&up->port, con, baud, parity, bits, flow);
1063} 1051}
1064 1052
1065static struct uart_driver ip22zilog_reg; 1053static struct uart_driver ip22zilog_reg;
@@ -1140,25 +1128,10 @@ static void __init ip22zilog_prepare(void)
1140 up[(chip * 2) + 1].port.line = (chip * 2) + 1; 1128 up[(chip * 2) + 1].port.line = (chip * 2) + 1;
1141 up[(chip * 2) + 1].flags |= IP22ZILOG_FLAG_IS_CHANNEL_A; 1129 up[(chip * 2) + 1].flags |= IP22ZILOG_FLAG_IS_CHANNEL_A;
1142 } 1130 }
1143}
1144
1145static void __init ip22zilog_init_hw(void)
1146{
1147 int i;
1148
1149 for (i = 0; i < NUM_CHANNELS; i++) {
1150 struct uart_ip22zilog_port *up = &ip22zilog_port_table[i];
1151 struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
1152 unsigned long flags;
1153 int baud, brg;
1154 1131
1155 spin_lock_irqsave(&up->port.lock, flags); 1132 for (channel = 0; channel < NUM_CHANNELS; channel++) {
1156 1133 struct uart_ip22zilog_port *up = &ip22zilog_port_table[channel];
1157 if (ZS_IS_CHANNEL_A(up)) { 1134 int brg;
1158 write_zsreg(channel, R9, FHWRES);
1159 ZSDELAY_LONG();
1160 (void) read_zsreg(channel, R0);
1161 }
1162 1135
1163 /* Normal serial TTY. */ 1136 /* Normal serial TTY. */
1164 up->parity_mask = 0xff; 1137 up->parity_mask = 0xff;
@@ -1169,16 +1142,10 @@ static void __init ip22zilog_init_hw(void)
1169 up->curregs[R9] = NV | MIE; 1142 up->curregs[R9] = NV | MIE;
1170 up->curregs[R10] = NRZ; 1143 up->curregs[R10] = NRZ;
1171 up->curregs[R11] = TCBR | RCBR; 1144 up->curregs[R11] = TCBR | RCBR;
1172 baud = 9600; 1145 brg = BPS_TO_BRG(9600, ZS_CLOCK / ZS_CLOCK_DIVISOR);
1173 brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR);
1174 up->curregs[R12] = (brg & 0xff); 1146 up->curregs[R12] = (brg & 0xff);
1175 up->curregs[R13] = (brg >> 8) & 0xff; 1147 up->curregs[R13] = (brg >> 8) & 0xff;
1176 up->curregs[R14] = BRENAB; 1148 up->curregs[R14] = BRENAB;
1177 __load_zsregs(channel, up->curregs);
1178 /* set master interrupt enable */
1179 write_zsreg(channel, R9, up->curregs[R9]);
1180
1181 spin_unlock_irqrestore(&up->port.lock, flags);
1182 } 1149 }
1183} 1150}
1184 1151
@@ -1195,8 +1162,6 @@ static int __init ip22zilog_ports_init(void)
1195 panic("IP22-Zilog: Unable to register zs interrupt handler.\n"); 1162 panic("IP22-Zilog: Unable to register zs interrupt handler.\n");
1196 } 1163 }
1197 1164
1198 ip22zilog_init_hw();
1199
1200 ret = uart_register_driver(&ip22zilog_reg); 1165 ret = uart_register_driver(&ip22zilog_reg);
1201 if (ret == 0) { 1166 if (ret == 0) {
1202 int i; 1167 int i;
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index af3a011b2b24..352fcb8926a6 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -585,11 +585,11 @@ serial_pxa_type(struct uart_port *port)
585 return up->name; 585 return up->name;
586} 586}
587 587
588#ifdef CONFIG_SERIAL_PXA_CONSOLE
589
590static struct uart_pxa_port *serial_pxa_ports[4]; 588static struct uart_pxa_port *serial_pxa_ports[4];
591static struct uart_driver serial_pxa_reg; 589static struct uart_driver serial_pxa_reg;
592 590
591#ifdef CONFIG_SERIAL_PXA_CONSOLE
592
593#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 593#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
594 594
595/* 595/*
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index a77ede598d34..abf05048c638 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -61,7 +61,7 @@ config SPI_ATMEL
61 61
62config SPI_BFIN 62config SPI_BFIN
63 tristate "SPI controller driver for ADI Blackfin5xx" 63 tristate "SPI controller driver for ADI Blackfin5xx"
64 depends on SPI_MASTER && BFIN 64 depends on SPI_MASTER && BLACKFIN
65 help 65 help
66 This is the SPI controller master driver for Blackfin 5xx processor. 66 This is the SPI controller master driver for Blackfin 5xx processor.
67 67
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 0d342dcdd302..ff6a14bf1280 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -497,7 +497,7 @@ static int atmel_spi_setup(struct spi_device *spi)
497 /* chipselect must have been muxed as GPIO (e.g. in board setup) */ 497 /* chipselect must have been muxed as GPIO (e.g. in board setup) */
498 npcs_pin = (unsigned int)spi->controller_data; 498 npcs_pin = (unsigned int)spi->controller_data;
499 if (!spi->controller_state) { 499 if (!spi->controller_state) {
500 ret = gpio_request(npcs_pin, "spi_npcs"); 500 ret = gpio_request(npcs_pin, spi->dev.bus_id);
501 if (ret) 501 if (ret)
502 return ret; 502 return ret;
503 spi->controller_state = (void *)npcs_pin; 503 spi->controller_state = (void *)npcs_pin;
diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c
index 0fa25e2e80fe..109d82c1abc0 100644
--- a/drivers/spi/spi_s3c24xx_gpio.c
+++ b/drivers/spi/spi_s3c24xx_gpio.c
@@ -96,6 +96,7 @@ static void s3c2410_spigpio_chipselect(struct spi_device *dev, int value)
96 96
97static int s3c2410_spigpio_probe(struct platform_device *dev) 97static int s3c2410_spigpio_probe(struct platform_device *dev)
98{ 98{
99 struct s3c2410_spigpio_info *info;
99 struct spi_master *master; 100 struct spi_master *master;
100 struct s3c2410_spigpio *sp; 101 struct s3c2410_spigpio *sp;
101 int ret; 102 int ret;
@@ -113,10 +114,11 @@ static int s3c2410_spigpio_probe(struct platform_device *dev)
113 platform_set_drvdata(dev, sp); 114 platform_set_drvdata(dev, sp);
114 115
115 /* copy in the plkatform data */ 116 /* copy in the plkatform data */
116 sp->info = dev->dev.platform_data; 117 info = sp->info = dev->dev.platform_data;
117 118
118 /* setup spi bitbang adaptor */ 119 /* setup spi bitbang adaptor */
119 sp->bitbang.master = spi_master_get(master); 120 sp->bitbang.master = spi_master_get(master);
121 sp->bitbang.master->bus_num = info->bus_num;
120 sp->bitbang.chipselect = s3c2410_spigpio_chipselect; 122 sp->bitbang.chipselect = s3c2410_spigpio_chipselect;
121 123
122 sp->bitbang.txrx_word[SPI_MODE_0] = s3c2410_spigpio_txrx_mode0; 124 sp->bitbang.txrx_word[SPI_MODE_0] = s3c2410_spigpio_txrx_mode0;
@@ -124,13 +126,18 @@ static int s3c2410_spigpio_probe(struct platform_device *dev)
124 sp->bitbang.txrx_word[SPI_MODE_2] = s3c2410_spigpio_txrx_mode2; 126 sp->bitbang.txrx_word[SPI_MODE_2] = s3c2410_spigpio_txrx_mode2;
125 sp->bitbang.txrx_word[SPI_MODE_3] = s3c2410_spigpio_txrx_mode3; 127 sp->bitbang.txrx_word[SPI_MODE_3] = s3c2410_spigpio_txrx_mode3;
126 128
127 /* set state of spi pins */ 129 /* set state of spi pins, always assume that the clock is
128 s3c2410_gpio_setpin(sp->info->pin_clk, 0); 130 * available, but do check the MOSI and MISO. */
129 s3c2410_gpio_setpin(sp->info->pin_mosi, 0); 131 s3c2410_gpio_setpin(info->pin_clk, 0);
132 s3c2410_gpio_cfgpin(info->pin_clk, S3C2410_GPIO_OUTPUT);
130 133
131 s3c2410_gpio_cfgpin(sp->info->pin_clk, S3C2410_GPIO_OUTPUT); 134 if (info->pin_mosi < S3C2410_GPH10) {
132 s3c2410_gpio_cfgpin(sp->info->pin_mosi, S3C2410_GPIO_OUTPUT); 135 s3c2410_gpio_setpin(info->pin_mosi, 0);
133 s3c2410_gpio_cfgpin(sp->info->pin_miso, S3C2410_GPIO_INPUT); 136 s3c2410_gpio_cfgpin(info->pin_mosi, S3C2410_GPIO_OUTPUT);
137 }
138
139 if (info->pin_miso != S3C2410_GPA0 && info->pin_miso < S3C2410_GPH10)
140 s3c2410_gpio_cfgpin(info->pin_miso, S3C2410_GPIO_INPUT);
134 141
135 ret = spi_bitbang_start(&sp->bitbang); 142 ret = spi_bitbang_start(&sp->bitbang);
136 if (ret) 143 if (ret)
diff --git a/drivers/usb/README b/drivers/usb/README
index 3c8434128554..284f46b3e1cc 100644
--- a/drivers/usb/README
+++ b/drivers/usb/README
@@ -39,12 +39,12 @@ first subdirectory in the list below that it fits into.
39 39
40image/ - This is for still image drivers, like scanners or 40image/ - This is for still image drivers, like scanners or
41 digital cameras. 41 digital cameras.
42input/ - This is for any driver that uses the input subsystem, 42../input/ - This is for any driver that uses the input subsystem,
43 like keyboard, mice, touchscreens, tablets, etc. 43 like keyboard, mice, touchscreens, tablets, etc.
44media/ - This is for multimedia drivers, like video cameras, 44../media/ - This is for multimedia drivers, like video cameras,
45 radios, and any other drivers that talk to the v4l 45 radios, and any other drivers that talk to the v4l
46 subsystem. 46 subsystem.
47net/ - This is for network drivers. 47../net/ - This is for network drivers.
48serial/ - This is for USB to serial drivers. 48serial/ - This is for USB to serial drivers.
49storage/ - This is for USB mass-storage drivers. 49storage/ - This is for USB mass-storage drivers.
50class/ - This is for all USB device drivers that do not fit 50class/ - This is for all USB device drivers that do not fit
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 8586817698ad..c51f8e9312e0 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -585,9 +585,6 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
585{ 585{
586 struct usb_device *usb_dev; 586 struct usb_device *usb_dev;
587 587
588 if (!dev)
589 return -ENODEV;
590
591 /* driver is often null here; dev_dbg() would oops */ 588 /* driver is often null here; dev_dbg() would oops */
592 pr_debug ("usb %s: uevent\n", dev->bus_id); 589 pr_debug ("usb %s: uevent\n", dev->bus_id);
593 590
@@ -631,14 +628,6 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
631 usb_dev->descriptor.bDeviceProtocol)) 628 usb_dev->descriptor.bDeviceProtocol))
632 return -ENOMEM; 629 return -ENOMEM;
633 630
634 if (add_uevent_var(env, "BUSNUM=%03d",
635 usb_dev->bus->busnum))
636 return -ENOMEM;
637
638 if (add_uevent_var(env, "DEVNUM=%03d",
639 usb_dev->devnum))
640 return -ENOMEM;
641
642 return 0; 631 return 0;
643} 632}
644 633
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index fea8256a18d6..d5ed3fa9e304 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1311,8 +1311,8 @@ void usb_hcd_flush_endpoint(struct usb_device *udev,
1311 hcd = bus_to_hcd(udev->bus); 1311 hcd = bus_to_hcd(udev->bus);
1312 1312
1313 /* No more submits can occur */ 1313 /* No more submits can occur */
1314rescan:
1315 spin_lock_irq(&hcd_urb_list_lock); 1314 spin_lock_irq(&hcd_urb_list_lock);
1315rescan:
1316 list_for_each_entry (urb, &ep->urb_list, urb_list) { 1316 list_for_each_entry (urb, &ep->urb_list, urb_list) {
1317 int is_in; 1317 int is_in;
1318 1318
@@ -1345,6 +1345,7 @@ rescan:
1345 usb_put_urb (urb); 1345 usb_put_urb (urb);
1346 1346
1347 /* list contents may have changed */ 1347 /* list contents may have changed */
1348 spin_lock(&hcd_urb_list_lock);
1348 goto rescan; 1349 goto rescan;
1349 } 1350 }
1350 spin_unlock_irq(&hcd_urb_list_lock); 1351 spin_unlock_irq(&hcd_urb_list_lock);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 036c3dea855e..13b326a13377 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -335,7 +335,7 @@ static void kick_khubd(struct usb_hub *hub)
335 to_usb_interface(hub->intfdev)->pm_usage_cnt = 1; 335 to_usb_interface(hub->intfdev)->pm_usage_cnt = 1;
336 336
337 spin_lock_irqsave(&hub_event_lock, flags); 337 spin_lock_irqsave(&hub_event_lock, flags);
338 if (!hub->disconnected & list_empty(&hub->event_list)) { 338 if (!hub->disconnected && list_empty(&hub->event_list)) {
339 list_add_tail(&hub->event_list, &hub_event_list); 339 list_add_tail(&hub->event_list, &hub_event_list);
340 wake_up(&khubd_wait); 340 wake_up(&khubd_wait);
341 } 341 }
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 316a746e0080..fcd40ecbeecc 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1172,7 +1172,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1172 struct usb_host_interface *alt; 1172 struct usb_host_interface *alt;
1173 int ret; 1173 int ret;
1174 int manual = 0; 1174 int manual = 0;
1175 int changed;
1176 1175
1177 if (dev->state == USB_STATE_SUSPENDED) 1176 if (dev->state == USB_STATE_SUSPENDED)
1178 return -EHOSTUNREACH; 1177 return -EHOSTUNREACH;
@@ -1212,8 +1211,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1212 */ 1211 */
1213 1212
1214 /* prevent submissions using previous endpoint settings */ 1213 /* prevent submissions using previous endpoint settings */
1215 changed = (iface->cur_altsetting != alt); 1214 if (iface->cur_altsetting != alt && device_is_registered(&iface->dev))
1216 if (changed && device_is_registered(&iface->dev))
1217 usb_remove_sysfs_intf_files(iface); 1215 usb_remove_sysfs_intf_files(iface);
1218 usb_disable_interface(dev, iface); 1216 usb_disable_interface(dev, iface);
1219 1217
@@ -1250,7 +1248,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1250 * (Likewise, EP0 never "halts" on well designed devices.) 1248 * (Likewise, EP0 never "halts" on well designed devices.)
1251 */ 1249 */
1252 usb_enable_interface(dev, iface); 1250 usb_enable_interface(dev, iface);
1253 if (changed && device_is_registered(&iface->dev)) 1251 if (device_is_registered(&iface->dev))
1254 usb_create_sysfs_intf_files(iface); 1252 usb_create_sysfs_intf_files(iface);
1255 1253
1256 return 0; 1254 return 0;
@@ -1348,34 +1346,10 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
1348 struct usb_interface *intf; 1346 struct usb_interface *intf;
1349 struct usb_host_interface *alt; 1347 struct usb_host_interface *alt;
1350 1348
1351 if (!dev)
1352 return -ENODEV;
1353
1354 /* driver is often null here; dev_dbg() would oops */
1355 pr_debug ("usb %s: uevent\n", dev->bus_id);
1356
1357 intf = to_usb_interface(dev); 1349 intf = to_usb_interface(dev);
1358 usb_dev = interface_to_usbdev(intf); 1350 usb_dev = interface_to_usbdev(intf);
1359 alt = intf->cur_altsetting; 1351 alt = intf->cur_altsetting;
1360 1352
1361#ifdef CONFIG_USB_DEVICEFS
1362 if (add_uevent_var(env, "DEVICE=/proc/bus/usb/%03d/%03d",
1363 usb_dev->bus->busnum, usb_dev->devnum))
1364 return -ENOMEM;
1365#endif
1366
1367 if (add_uevent_var(env, "PRODUCT=%x/%x/%x",
1368 le16_to_cpu(usb_dev->descriptor.idVendor),
1369 le16_to_cpu(usb_dev->descriptor.idProduct),
1370 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
1371 return -ENOMEM;
1372
1373 if (add_uevent_var(env, "TYPE=%d/%d/%d",
1374 usb_dev->descriptor.bDeviceClass,
1375 usb_dev->descriptor.bDeviceSubClass,
1376 usb_dev->descriptor.bDeviceProtocol))
1377 return -ENOMEM;
1378
1379 if (add_uevent_var(env, "INTERFACE=%d/%d/%d", 1353 if (add_uevent_var(env, "INTERFACE=%d/%d/%d",
1380 alt->desc.bInterfaceClass, 1354 alt->desc.bInterfaceClass,
1381 alt->desc.bInterfaceSubClass, 1355 alt->desc.bInterfaceSubClass,
@@ -1641,12 +1615,6 @@ free_interfaces:
1641 intf->dev.bus_id, ret); 1615 intf->dev.bus_id, ret);
1642 continue; 1616 continue;
1643 } 1617 }
1644
1645 /* The driver's probe method can call usb_set_interface(),
1646 * which would mean the interface's sysfs files are already
1647 * created. Just in case, we'll remove them first.
1648 */
1649 usb_remove_sysfs_intf_files(intf);
1650 usb_create_sysfs_intf_files(intf); 1618 usb_create_sysfs_intf_files(intf);
1651 } 1619 }
1652 1620
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index b04afd06e502..32bd130b1eed 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -735,6 +735,8 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
735 struct usb_host_interface *alt = intf->cur_altsetting; 735 struct usb_host_interface *alt = intf->cur_altsetting;
736 int retval; 736 int retval;
737 737
738 if (intf->sysfs_files_created)
739 return 0;
738 retval = sysfs_create_group(&dev->kobj, &intf_attr_grp); 740 retval = sysfs_create_group(&dev->kobj, &intf_attr_grp);
739 if (retval) 741 if (retval)
740 return retval; 742 return retval;
@@ -746,6 +748,7 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
746 if (intf->intf_assoc) 748 if (intf->intf_assoc)
747 retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp); 749 retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp);
748 usb_create_intf_ep_files(intf, udev); 750 usb_create_intf_ep_files(intf, udev);
751 intf->sysfs_files_created = 1;
749 return 0; 752 return 0;
750} 753}
751 754
@@ -753,8 +756,11 @@ void usb_remove_sysfs_intf_files(struct usb_interface *intf)
753{ 756{
754 struct device *dev = &intf->dev; 757 struct device *dev = &intf->dev;
755 758
759 if (!intf->sysfs_files_created)
760 return;
756 usb_remove_intf_ep_files(intf); 761 usb_remove_intf_ep_files(intf);
757 device_remove_file(dev, &dev_attr_interface); 762 device_remove_file(dev, &dev_attr_interface);
758 sysfs_remove_group(&dev->kobj, &intf_attr_grp); 763 sysfs_remove_group(&dev->kobj, &intf_attr_grp);
759 sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp); 764 sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp);
765 intf->sysfs_files_created = 0;
760} 766}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index c4a6f1095b8b..8f142370103d 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -192,9 +192,34 @@ static void usb_release_dev(struct device *dev)
192 kfree(udev); 192 kfree(udev);
193} 193}
194 194
195#ifdef CONFIG_HOTPLUG
196static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
197{
198 struct usb_device *usb_dev;
199
200 usb_dev = to_usb_device(dev);
201
202 if (add_uevent_var(env, "BUSNUM=%03d", usb_dev->bus->busnum))
203 return -ENOMEM;
204
205 if (add_uevent_var(env, "DEVNUM=%03d", usb_dev->devnum))
206 return -ENOMEM;
207
208 return 0;
209}
210
211#else
212
213static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
214{
215 return -ENODEV;
216}
217#endif /* CONFIG_HOTPLUG */
218
195struct device_type usb_device_type = { 219struct device_type usb_device_type = {
196 .name = "usb_device", 220 .name = "usb_device",
197 .release = usb_release_dev, 221 .release = usb_release_dev,
222 .uevent = usb_dev_uevent,
198}; 223};
199 224
200#ifdef CONFIG_PM 225#ifdef CONFIG_PM
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 87c4f50dfb61..d377154658b5 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -1241,14 +1241,14 @@ static void pullup_enable(struct omap_udc *udc)
1241 udc->gadget.dev.parent->power.power_state = PMSG_ON; 1241 udc->gadget.dev.parent->power.power_state = PMSG_ON;
1242 udc->gadget.dev.power.power_state = PMSG_ON; 1242 udc->gadget.dev.power.power_state = PMSG_ON;
1243 UDC_SYSCON1_REG |= UDC_PULLUP_EN; 1243 UDC_SYSCON1_REG |= UDC_PULLUP_EN;
1244 if (!gadget_is_otg(udc->gadget) && !cpu_is_omap15xx()) 1244 if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx())
1245 OTG_CTRL_REG |= OTG_BSESSVLD; 1245 OTG_CTRL_REG |= OTG_BSESSVLD;
1246 UDC_IRQ_EN_REG = UDC_DS_CHG_IE; 1246 UDC_IRQ_EN_REG = UDC_DS_CHG_IE;
1247} 1247}
1248 1248
1249static void pullup_disable(struct omap_udc *udc) 1249static void pullup_disable(struct omap_udc *udc)
1250{ 1250{
1251 if (!gadget_is_otg(udc->gadget) && !cpu_is_omap15xx()) 1251 if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx())
1252 OTG_CTRL_REG &= ~OTG_BSESSVLD; 1252 OTG_CTRL_REG &= ~OTG_BSESSVLD;
1253 UDC_IRQ_EN_REG = UDC_DS_CHG_IE; 1253 UDC_IRQ_EN_REG = UDC_DS_CHG_IE;
1254 UDC_SYSCON1_REG &= ~UDC_PULLUP_EN; 1254 UDC_SYSCON1_REG &= ~UDC_PULLUP_EN;
@@ -1386,7 +1386,7 @@ static void update_otg(struct omap_udc *udc)
1386{ 1386{
1387 u16 devstat; 1387 u16 devstat;
1388 1388
1389 if (!gadget_is_otg(udc->gadget)) 1389 if (!gadget_is_otg(&udc->gadget))
1390 return; 1390 return;
1391 1391
1392 if (OTG_CTRL_REG & OTG_ID) 1392 if (OTG_CTRL_REG & OTG_ID)
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index e3e90f8a75e7..4ce050c3d13f 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -52,10 +52,10 @@
52#include <asm/arch/irqs.h> 52#include <asm/arch/irqs.h>
53 53
54#include <asm/arch/hardware.h> 54#include <asm/arch/hardware.h>
55#include <asm/arch/regs-clock.h>
56#include <asm/arch/regs-gpio.h> 55#include <asm/arch/regs-gpio.h>
57#include <asm/arch/regs-udc.h> 56
58#include <asm/arch/udc.h> 57#include <asm/plat-s3c24xx/regs-udc.h>
58#include <asm/plat-s3c24xx/udc.h>
59 59
60#include <asm/mach-types.h> 60#include <asm/mach-types.h>
61 61
@@ -1511,7 +1511,11 @@ static irqreturn_t s3c2410_udc_vbus_irq(int irq, void *_dev)
1511 unsigned int value; 1511 unsigned int value;
1512 1512
1513 dprintk(DEBUG_NORMAL, "%s()\n", __func__); 1513 dprintk(DEBUG_NORMAL, "%s()\n", __func__);
1514
1515 /* some cpus cannot read from an line configured to IRQ! */
1516 s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_INPUT);
1514 value = s3c2410_gpio_getpin(udc_info->vbus_pin); 1517 value = s3c2410_gpio_getpin(udc_info->vbus_pin);
1518 s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_SFN2);
1515 1519
1516 if (udc_info->vbus_pin_inverted) 1520 if (udc_info->vbus_pin_inverted)
1517 value = !value; 1521 value = !value;
@@ -1872,9 +1876,9 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1872 if (udc_info && udc_info->vbus_pin > 0) { 1876 if (udc_info && udc_info->vbus_pin > 0) {
1873 irq = s3c2410_gpio_getirq(udc_info->vbus_pin); 1877 irq = s3c2410_gpio_getirq(udc_info->vbus_pin);
1874 retval = request_irq(irq, s3c2410_udc_vbus_irq, 1878 retval = request_irq(irq, s3c2410_udc_vbus_irq,
1875 IRQF_DISABLED | IRQF_TRIGGER_RISING 1879 IRQF_DISABLED | IRQF_TRIGGER_RISING
1876 | IRQF_TRIGGER_FALLING, 1880 | IRQF_TRIGGER_FALLING | IRQF_SHARED,
1877 gadget_name, udc); 1881 gadget_name, udc);
1878 1882
1879 if (retval != 0) { 1883 if (retval != 0) {
1880 dev_err(dev, "can't get vbus irq %i, err %d\n", 1884 dev_err(dev, "can't get vbus irq %i, err %d\n",
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 177e78ed241b..49a91c5ee51b 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -156,7 +156,7 @@ config USB_OHCI_HCD_PCI
156 156
157config USB_OHCI_HCD_SSB 157config USB_OHCI_HCD_SSB
158 bool "OHCI support for Broadcom SSB OHCI core" 158 bool "OHCI support for Broadcom SSB OHCI core"
159 depends on USB_OHCI_HCD && (SSB = y || SSB = CONFIG_USB_OHCI_HCD) && EXPERIMENTAL 159 depends on USB_OHCI_HCD && (SSB = y || SSB = USB_OHCI_HCD) && EXPERIMENTAL
160 default n 160 default n
161 ---help--- 161 ---help---
162 Support for the Sonics Silicon Backplane (SSB) attached 162 Support for the Sonics Silicon Backplane (SSB) attached
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c1514442883e..5f2d74ed5ad7 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -575,12 +575,15 @@ static int ehci_run (struct usb_hcd *hcd)
575 * from the companions to the EHCI controller. If any of the 575 * from the companions to the EHCI controller. If any of the
576 * companions are in the middle of a port reset at the time, it 576 * companions are in the middle of a port reset at the time, it
577 * could cause trouble. Write-locking ehci_cf_port_reset_rwsem 577 * could cause trouble. Write-locking ehci_cf_port_reset_rwsem
578 * guarantees that no resets are in progress. 578 * guarantees that no resets are in progress. After we set CF,
579 * a short delay lets the hardware catch up; new resets shouldn't
580 * be started before the port switching actions could complete.
579 */ 581 */
580 down_write(&ehci_cf_port_reset_rwsem); 582 down_write(&ehci_cf_port_reset_rwsem);
581 hcd->state = HC_STATE_RUNNING; 583 hcd->state = HC_STATE_RUNNING;
582 ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); 584 ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
583 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ 585 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
586 msleep(5);
584 up_write(&ehci_cf_port_reset_rwsem); 587 up_write(&ehci_cf_port_reset_rwsem);
585 588
586 temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); 589 temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase));
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 91e999c9f680..bc207e3c21f5 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -819,7 +819,7 @@ static int mts_usb_probe(struct usb_interface *intf,
819 goto out_kfree2; 819 goto out_kfree2;
820 820
821 new_desc->host->hostdata[0] = (unsigned long)new_desc; 821 new_desc->host->hostdata[0] = (unsigned long)new_desc;
822 if (scsi_add_host(new_desc->host, NULL)) { 822 if (scsi_add_host(new_desc->host, &dev->dev)) {
823 err_retval = -EIO; 823 err_retval = -EIO;
824 goto out_host_put; 824 goto out_host_put;
825 } 825 }
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index c567aa7a41ea..5a2c44e4c1f7 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -79,12 +79,22 @@ MODULE_DEVICE_TABLE(usb, device_table);
79 79
80#define COMMAND_TIMEOUT (2*HZ) /* 60 second timeout for a command */ 80#define COMMAND_TIMEOUT (2*HZ) /* 60 second timeout for a command */
81 81
82/*
83 * The locking scheme is a vanilla 3-lock:
84 * adu_device.buflock: A spinlock, covers what IRQs touch.
85 * adutux_mutex: A Static lock to cover open_count. It would also cover
86 * any globals, but we don't have them in 2.6.
87 * adu_device.mtx: A mutex to hold across sleepers like copy_from_user.
88 * It covers all of adu_device, except the open_count
89 * and what .buflock covers.
90 */
91
82/* Structure to hold all of our device specific stuff */ 92/* Structure to hold all of our device specific stuff */
83struct adu_device { 93struct adu_device {
84 struct mutex mtx; /* locks this structure */ 94 struct mutex mtx;
85 struct usb_device* udev; /* save off the usb device pointer */ 95 struct usb_device* udev; /* save off the usb device pointer */
86 struct usb_interface* interface; 96 struct usb_interface* interface;
87 unsigned char minor; /* the starting minor number for this device */ 97 unsigned int minor; /* the starting minor number for this device */
88 char serial_number[8]; 98 char serial_number[8];
89 99
90 int open_count; /* number of times this port has been opened */ 100 int open_count; /* number of times this port has been opened */
@@ -107,8 +117,11 @@ struct adu_device {
107 char* interrupt_out_buffer; 117 char* interrupt_out_buffer;
108 struct usb_endpoint_descriptor* interrupt_out_endpoint; 118 struct usb_endpoint_descriptor* interrupt_out_endpoint;
109 struct urb* interrupt_out_urb; 119 struct urb* interrupt_out_urb;
120 int out_urb_finished;
110}; 121};
111 122
123static DEFINE_MUTEX(adutux_mutex);
124
112static struct usb_driver adu_driver; 125static struct usb_driver adu_driver;
113 126
114static void adu_debug_data(int level, const char *function, int size, 127static void adu_debug_data(int level, const char *function, int size,
@@ -132,27 +145,31 @@ static void adu_debug_data(int level, const char *function, int size,
132 */ 145 */
133static void adu_abort_transfers(struct adu_device *dev) 146static void adu_abort_transfers(struct adu_device *dev)
134{ 147{
135 dbg(2," %s : enter", __FUNCTION__); 148 unsigned long flags;
136 149
137 if (dev == NULL) { 150 dbg(2," %s : enter", __FUNCTION__);
138 dbg(1," %s : dev is null", __FUNCTION__);
139 goto exit;
140 }
141 151
142 if (dev->udev == NULL) { 152 if (dev->udev == NULL) {
143 dbg(1," %s : udev is null", __FUNCTION__); 153 dbg(1," %s : udev is null", __FUNCTION__);
144 goto exit; 154 goto exit;
145 } 155 }
146 156
147 dbg(2," %s : udev state %d", __FUNCTION__, dev->udev->state);
148 if (dev->udev->state == USB_STATE_NOTATTACHED) {
149 dbg(1," %s : udev is not attached", __FUNCTION__);
150 goto exit;
151 }
152
153 /* shutdown transfer */ 157 /* shutdown transfer */
154 usb_unlink_urb(dev->interrupt_in_urb); 158
155 usb_unlink_urb(dev->interrupt_out_urb); 159 /* XXX Anchor these instead */
160 spin_lock_irqsave(&dev->buflock, flags);
161 if (!dev->read_urb_finished) {
162 spin_unlock_irqrestore(&dev->buflock, flags);
163 usb_kill_urb(dev->interrupt_in_urb);
164 } else
165 spin_unlock_irqrestore(&dev->buflock, flags);
166
167 spin_lock_irqsave(&dev->buflock, flags);
168 if (!dev->out_urb_finished) {
169 spin_unlock_irqrestore(&dev->buflock, flags);
170 usb_kill_urb(dev->interrupt_out_urb);
171 } else
172 spin_unlock_irqrestore(&dev->buflock, flags);
156 173
157exit: 174exit:
158 dbg(2," %s : leave", __FUNCTION__); 175 dbg(2," %s : leave", __FUNCTION__);
@@ -162,8 +179,6 @@ static void adu_delete(struct adu_device *dev)
162{ 179{
163 dbg(2, "%s enter", __FUNCTION__); 180 dbg(2, "%s enter", __FUNCTION__);
164 181
165 adu_abort_transfers(dev);
166
167 /* free data structures */ 182 /* free data structures */
168 usb_free_urb(dev->interrupt_in_urb); 183 usb_free_urb(dev->interrupt_in_urb);
169 usb_free_urb(dev->interrupt_out_urb); 184 usb_free_urb(dev->interrupt_out_urb);
@@ -239,7 +254,10 @@ static void adu_interrupt_out_callback(struct urb *urb)
239 goto exit; 254 goto exit;
240 } 255 }
241 256
242 wake_up_interruptible(&dev->write_wait); 257 spin_lock(&dev->buflock);
258 dev->out_urb_finished = 1;
259 wake_up(&dev->write_wait);
260 spin_unlock(&dev->buflock);
243exit: 261exit:
244 262
245 adu_debug_data(5, __FUNCTION__, urb->actual_length, 263 adu_debug_data(5, __FUNCTION__, urb->actual_length,
@@ -252,12 +270,17 @@ static int adu_open(struct inode *inode, struct file *file)
252 struct adu_device *dev = NULL; 270 struct adu_device *dev = NULL;
253 struct usb_interface *interface; 271 struct usb_interface *interface;
254 int subminor; 272 int subminor;
255 int retval = 0; 273 int retval;
256 274
257 dbg(2,"%s : enter", __FUNCTION__); 275 dbg(2,"%s : enter", __FUNCTION__);
258 276
259 subminor = iminor(inode); 277 subminor = iminor(inode);
260 278
279 if ((retval = mutex_lock_interruptible(&adutux_mutex))) {
280 dbg(2, "%s : mutex lock failed", __FUNCTION__);
281 goto exit_no_lock;
282 }
283
261 interface = usb_find_interface(&adu_driver, subminor); 284 interface = usb_find_interface(&adu_driver, subminor);
262 if (!interface) { 285 if (!interface) {
263 err("%s - error, can't find device for minor %d", 286 err("%s - error, can't find device for minor %d",
@@ -267,54 +290,54 @@ static int adu_open(struct inode *inode, struct file *file)
267 } 290 }
268 291
269 dev = usb_get_intfdata(interface); 292 dev = usb_get_intfdata(interface);
270 if (!dev) { 293 if (!dev || !dev->udev) {
271 retval = -ENODEV; 294 retval = -ENODEV;
272 goto exit_no_device; 295 goto exit_no_device;
273 } 296 }
274 297
275 /* lock this device */ 298 /* check that nobody else is using the device */
276 if ((retval = mutex_lock_interruptible(&dev->mtx))) { 299 if (dev->open_count) {
277 dbg(2, "%s : mutex lock failed", __FUNCTION__); 300 retval = -EBUSY;
278 goto exit_no_device; 301 goto exit_no_device;
279 } 302 }
280 303
281 /* increment our usage count for the device */
282 ++dev->open_count; 304 ++dev->open_count;
283 dbg(2,"%s : open count %d", __FUNCTION__, dev->open_count); 305 dbg(2,"%s : open count %d", __FUNCTION__, dev->open_count);
284 306
285 /* save device in the file's private structure */ 307 /* save device in the file's private structure */
286 file->private_data = dev; 308 file->private_data = dev;
287 309
288 if (dev->open_count == 1) { 310 /* initialize in direction */
289 /* initialize in direction */ 311 dev->read_buffer_length = 0;
290 dev->read_buffer_length = 0;
291 312
292 /* fixup first read by having urb waiting for it */ 313 /* fixup first read by having urb waiting for it */
293 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, 314 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
294 usb_rcvintpipe(dev->udev, 315 usb_rcvintpipe(dev->udev,
295 dev->interrupt_in_endpoint->bEndpointAddress), 316 dev->interrupt_in_endpoint->bEndpointAddress),
296 dev->interrupt_in_buffer, 317 dev->interrupt_in_buffer,
297 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), 318 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
298 adu_interrupt_in_callback, dev, 319 adu_interrupt_in_callback, dev,
299 dev->interrupt_in_endpoint->bInterval); 320 dev->interrupt_in_endpoint->bInterval);
300 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */ 321 dev->read_urb_finished = 0;
301 dev->read_urb_finished = 0; 322 if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL))
302 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL); 323 dev->read_urb_finished = 1;
303 if (retval) 324 /* we ignore failure */
304 --dev->open_count; 325 /* end of fixup for first read */
305 } 326
306 mutex_unlock(&dev->mtx); 327 /* initialize out direction */
328 dev->out_urb_finished = 1;
329
330 retval = 0;
307 331
308exit_no_device: 332exit_no_device:
333 mutex_unlock(&adutux_mutex);
334exit_no_lock:
309 dbg(2,"%s : leave, return value %d ", __FUNCTION__, retval); 335 dbg(2,"%s : leave, return value %d ", __FUNCTION__, retval);
310
311 return retval; 336 return retval;
312} 337}
313 338
314static int adu_release_internal(struct adu_device *dev) 339static void adu_release_internal(struct adu_device *dev)
315{ 340{
316 int retval = 0;
317
318 dbg(2," %s : enter", __FUNCTION__); 341 dbg(2," %s : enter", __FUNCTION__);
319 342
320 /* decrement our usage count for the device */ 343 /* decrement our usage count for the device */
@@ -326,12 +349,11 @@ static int adu_release_internal(struct adu_device *dev)
326 } 349 }
327 350
328 dbg(2," %s : leave", __FUNCTION__); 351 dbg(2," %s : leave", __FUNCTION__);
329 return retval;
330} 352}
331 353
332static int adu_release(struct inode *inode, struct file *file) 354static int adu_release(struct inode *inode, struct file *file)
333{ 355{
334 struct adu_device *dev = NULL; 356 struct adu_device *dev;
335 int retval = 0; 357 int retval = 0;
336 358
337 dbg(2," %s : enter", __FUNCTION__); 359 dbg(2," %s : enter", __FUNCTION__);
@@ -343,15 +365,13 @@ static int adu_release(struct inode *inode, struct file *file)
343 } 365 }
344 366
345 dev = file->private_data; 367 dev = file->private_data;
346
347 if (dev == NULL) { 368 if (dev == NULL) {
348 dbg(1," %s : object is NULL", __FUNCTION__); 369 dbg(1," %s : object is NULL", __FUNCTION__);
349 retval = -ENODEV; 370 retval = -ENODEV;
350 goto exit; 371 goto exit;
351 } 372 }
352 373
353 /* lock our device */ 374 mutex_lock(&adutux_mutex); /* not interruptible */
354 mutex_lock(&dev->mtx); /* not interruptible */
355 375
356 if (dev->open_count <= 0) { 376 if (dev->open_count <= 0) {
357 dbg(1," %s : device not opened", __FUNCTION__); 377 dbg(1," %s : device not opened", __FUNCTION__);
@@ -359,19 +379,15 @@ static int adu_release(struct inode *inode, struct file *file)
359 goto exit; 379 goto exit;
360 } 380 }
361 381
382 adu_release_internal(dev);
362 if (dev->udev == NULL) { 383 if (dev->udev == NULL) {
363 /* the device was unplugged before the file was released */ 384 /* the device was unplugged before the file was released */
364 mutex_unlock(&dev->mtx); 385 if (!dev->open_count) /* ... and we're the last user */
365 adu_delete(dev); 386 adu_delete(dev);
366 dev = NULL;
367 } else {
368 /* do the work */
369 retval = adu_release_internal(dev);
370 } 387 }
371 388
372exit: 389exit:
373 if (dev) 390 mutex_unlock(&adutux_mutex);
374 mutex_unlock(&dev->mtx);
375 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 391 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
376 return retval; 392 return retval;
377} 393}
@@ -393,12 +409,12 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
393 409
394 dev = file->private_data; 410 dev = file->private_data;
395 dbg(2," %s : dev=%p", __FUNCTION__, dev); 411 dbg(2," %s : dev=%p", __FUNCTION__, dev);
396 /* lock this object */ 412
397 if (mutex_lock_interruptible(&dev->mtx)) 413 if (mutex_lock_interruptible(&dev->mtx))
398 return -ERESTARTSYS; 414 return -ERESTARTSYS;
399 415
400 /* verify that the device wasn't unplugged */ 416 /* verify that the device wasn't unplugged */
401 if (dev->udev == NULL || dev->minor == 0) { 417 if (dev->udev == NULL) {
402 retval = -ENODEV; 418 retval = -ENODEV;
403 err("No device or device unplugged %d", retval); 419 err("No device or device unplugged %d", retval);
404 goto exit; 420 goto exit;
@@ -452,7 +468,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
452 should_submit = 1; 468 should_submit = 1;
453 } else { 469 } else {
454 /* even the primary was empty - we may need to do IO */ 470 /* even the primary was empty - we may need to do IO */
455 if (dev->interrupt_in_urb->status == -EINPROGRESS) { 471 if (!dev->read_urb_finished) {
456 /* somebody is doing IO */ 472 /* somebody is doing IO */
457 spin_unlock_irqrestore(&dev->buflock, flags); 473 spin_unlock_irqrestore(&dev->buflock, flags);
458 dbg(2," %s : submitted already", __FUNCTION__); 474 dbg(2," %s : submitted already", __FUNCTION__);
@@ -460,6 +476,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
460 /* we must initiate input */ 476 /* we must initiate input */
461 dbg(2," %s : initiate input", __FUNCTION__); 477 dbg(2," %s : initiate input", __FUNCTION__);
462 dev->read_urb_finished = 0; 478 dev->read_urb_finished = 0;
479 spin_unlock_irqrestore(&dev->buflock, flags);
463 480
464 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, 481 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
465 usb_rcvintpipe(dev->udev, 482 usb_rcvintpipe(dev->udev,
@@ -469,15 +486,12 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
469 adu_interrupt_in_callback, 486 adu_interrupt_in_callback,
470 dev, 487 dev,
471 dev->interrupt_in_endpoint->bInterval); 488 dev->interrupt_in_endpoint->bInterval);
472 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC); 489 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
473 if (!retval) { 490 if (retval) {
474 spin_unlock_irqrestore(&dev->buflock, flags); 491 dev->read_urb_finished = 1;
475 dbg(2," %s : submitted OK", __FUNCTION__);
476 } else {
477 if (retval == -ENOMEM) { 492 if (retval == -ENOMEM) {
478 retval = bytes_read ? bytes_read : -ENOMEM; 493 retval = bytes_read ? bytes_read : -ENOMEM;
479 } 494 }
480 spin_unlock_irqrestore(&dev->buflock, flags);
481 dbg(2," %s : submit failed", __FUNCTION__); 495 dbg(2," %s : submit failed", __FUNCTION__);
482 goto exit; 496 goto exit;
483 } 497 }
@@ -486,10 +500,14 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
486 /* we wait for I/O to complete */ 500 /* we wait for I/O to complete */
487 set_current_state(TASK_INTERRUPTIBLE); 501 set_current_state(TASK_INTERRUPTIBLE);
488 add_wait_queue(&dev->read_wait, &wait); 502 add_wait_queue(&dev->read_wait, &wait);
489 if (!dev->read_urb_finished) 503 spin_lock_irqsave(&dev->buflock, flags);
504 if (!dev->read_urb_finished) {
505 spin_unlock_irqrestore(&dev->buflock, flags);
490 timeout = schedule_timeout(COMMAND_TIMEOUT); 506 timeout = schedule_timeout(COMMAND_TIMEOUT);
491 else 507 } else {
508 spin_unlock_irqrestore(&dev->buflock, flags);
492 set_current_state(TASK_RUNNING); 509 set_current_state(TASK_RUNNING);
510 }
493 remove_wait_queue(&dev->read_wait, &wait); 511 remove_wait_queue(&dev->read_wait, &wait);
494 512
495 if (timeout <= 0) { 513 if (timeout <= 0) {
@@ -509,19 +527,23 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
509 527
510 retval = bytes_read; 528 retval = bytes_read;
511 /* if the primary buffer is empty then use it */ 529 /* if the primary buffer is empty then use it */
512 if (should_submit && !dev->interrupt_in_urb->status==-EINPROGRESS) { 530 spin_lock_irqsave(&dev->buflock, flags);
531 if (should_submit && dev->read_urb_finished) {
532 dev->read_urb_finished = 0;
533 spin_unlock_irqrestore(&dev->buflock, flags);
513 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, 534 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
514 usb_rcvintpipe(dev->udev, 535 usb_rcvintpipe(dev->udev,
515 dev->interrupt_in_endpoint->bEndpointAddress), 536 dev->interrupt_in_endpoint->bEndpointAddress),
516 dev->interrupt_in_buffer, 537 dev->interrupt_in_buffer,
517 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), 538 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
518 adu_interrupt_in_callback, 539 adu_interrupt_in_callback,
519 dev, 540 dev,
520 dev->interrupt_in_endpoint->bInterval); 541 dev->interrupt_in_endpoint->bInterval);
521 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */ 542 if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL) != 0)
522 dev->read_urb_finished = 0; 543 dev->read_urb_finished = 1;
523 usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
524 /* we ignore failure */ 544 /* we ignore failure */
545 } else {
546 spin_unlock_irqrestore(&dev->buflock, flags);
525 } 547 }
526 548
527exit: 549exit:
@@ -535,24 +557,24 @@ exit:
535static ssize_t adu_write(struct file *file, const __user char *buffer, 557static ssize_t adu_write(struct file *file, const __user char *buffer,
536 size_t count, loff_t *ppos) 558 size_t count, loff_t *ppos)
537{ 559{
560 DECLARE_WAITQUEUE(waita, current);
538 struct adu_device *dev; 561 struct adu_device *dev;
539 size_t bytes_written = 0; 562 size_t bytes_written = 0;
540 size_t bytes_to_write; 563 size_t bytes_to_write;
541 size_t buffer_size; 564 size_t buffer_size;
565 unsigned long flags;
542 int retval; 566 int retval;
543 int timeout = 0;
544 567
545 dbg(2," %s : enter, count = %Zd", __FUNCTION__, count); 568 dbg(2," %s : enter, count = %Zd", __FUNCTION__, count);
546 569
547 dev = file->private_data; 570 dev = file->private_data;
548 571
549 /* lock this object */
550 retval = mutex_lock_interruptible(&dev->mtx); 572 retval = mutex_lock_interruptible(&dev->mtx);
551 if (retval) 573 if (retval)
552 goto exit_nolock; 574 goto exit_nolock;
553 575
554 /* verify that the device wasn't unplugged */ 576 /* verify that the device wasn't unplugged */
555 if (dev->udev == NULL || dev->minor == 0) { 577 if (dev->udev == NULL) {
556 retval = -ENODEV; 578 retval = -ENODEV;
557 err("No device or device unplugged %d", retval); 579 err("No device or device unplugged %d", retval);
558 goto exit; 580 goto exit;
@@ -564,42 +586,37 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
564 goto exit; 586 goto exit;
565 } 587 }
566 588
567
568 while (count > 0) { 589 while (count > 0) {
569 if (dev->interrupt_out_urb->status == -EINPROGRESS) { 590 add_wait_queue(&dev->write_wait, &waita);
570 timeout = COMMAND_TIMEOUT; 591 set_current_state(TASK_INTERRUPTIBLE);
592 spin_lock_irqsave(&dev->buflock, flags);
593 if (!dev->out_urb_finished) {
594 spin_unlock_irqrestore(&dev->buflock, flags);
571 595
572 while (timeout > 0) { 596 mutex_unlock(&dev->mtx);
573 if (signal_pending(current)) { 597 if (signal_pending(current)) {
574 dbg(1," %s : interrupted", __FUNCTION__); 598 dbg(1," %s : interrupted", __FUNCTION__);
599 set_current_state(TASK_RUNNING);
575 retval = -EINTR; 600 retval = -EINTR;
576 goto exit; 601 goto exit_onqueue;
577 } 602 }
578 mutex_unlock(&dev->mtx); 603 if (schedule_timeout(COMMAND_TIMEOUT) == 0) {
579 timeout = interruptible_sleep_on_timeout(&dev->write_wait, timeout); 604 dbg(1, "%s - command timed out.", __FUNCTION__);
605 retval = -ETIMEDOUT;
606 goto exit_onqueue;
607 }
608 remove_wait_queue(&dev->write_wait, &waita);
580 retval = mutex_lock_interruptible(&dev->mtx); 609 retval = mutex_lock_interruptible(&dev->mtx);
581 if (retval) { 610 if (retval) {
582 retval = bytes_written ? bytes_written : retval; 611 retval = bytes_written ? bytes_written : retval;
583 goto exit_nolock; 612 goto exit_nolock;
584 } 613 }
585 if (timeout > 0) {
586 break;
587 }
588 dbg(1," %s : interrupted timeout: %d", __FUNCTION__, timeout);
589 }
590
591
592 dbg(1," %s : final timeout: %d", __FUNCTION__, timeout);
593
594 if (timeout == 0) {
595 dbg(1, "%s - command timed out.", __FUNCTION__);
596 retval = -ETIMEDOUT;
597 goto exit;
598 }
599
600 dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count);
601 614
615 dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count);
602 } else { 616 } else {
617 spin_unlock_irqrestore(&dev->buflock, flags);
618 set_current_state(TASK_RUNNING);
619 remove_wait_queue(&dev->write_wait, &waita);
603 dbg(4," %s : sending, count = %Zd", __FUNCTION__, count); 620 dbg(4," %s : sending, count = %Zd", __FUNCTION__, count);
604 621
605 /* write the data into interrupt_out_buffer from userspace */ 622 /* write the data into interrupt_out_buffer from userspace */
@@ -622,11 +639,12 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
622 bytes_to_write, 639 bytes_to_write,
623 adu_interrupt_out_callback, 640 adu_interrupt_out_callback,
624 dev, 641 dev,
625 dev->interrupt_in_endpoint->bInterval); 642 dev->interrupt_out_endpoint->bInterval);
626 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
627 dev->interrupt_out_urb->actual_length = bytes_to_write; 643 dev->interrupt_out_urb->actual_length = bytes_to_write;
644 dev->out_urb_finished = 0;
628 retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); 645 retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
629 if (retval < 0) { 646 if (retval < 0) {
647 dev->out_urb_finished = 1;
630 err("Couldn't submit interrupt_out_urb %d", retval); 648 err("Couldn't submit interrupt_out_urb %d", retval);
631 goto exit; 649 goto exit;
632 } 650 }
@@ -637,16 +655,17 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
637 bytes_written += bytes_to_write; 655 bytes_written += bytes_to_write;
638 } 656 }
639 } 657 }
640 658 mutex_unlock(&dev->mtx);
641 retval = bytes_written; 659 return bytes_written;
642 660
643exit: 661exit:
644 /* unlock the device */
645 mutex_unlock(&dev->mtx); 662 mutex_unlock(&dev->mtx);
646exit_nolock: 663exit_nolock:
647
648 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 664 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
665 return retval;
649 666
667exit_onqueue:
668 remove_wait_queue(&dev->write_wait, &waita);
650 return retval; 669 return retval;
651} 670}
652 671
@@ -831,25 +850,22 @@ static void adu_disconnect(struct usb_interface *interface)
831 dbg(2," %s : enter", __FUNCTION__); 850 dbg(2," %s : enter", __FUNCTION__);
832 851
833 dev = usb_get_intfdata(interface); 852 dev = usb_get_intfdata(interface);
834 usb_set_intfdata(interface, NULL);
835 853
854 mutex_lock(&dev->mtx); /* not interruptible */
855 dev->udev = NULL; /* poison */
836 minor = dev->minor; 856 minor = dev->minor;
837
838 /* give back our minor */
839 usb_deregister_dev(interface, &adu_class); 857 usb_deregister_dev(interface, &adu_class);
840 dev->minor = 0; 858 mutex_unlock(&dev->mtx);
841 859
842 mutex_lock(&dev->mtx); /* not interruptible */ 860 mutex_lock(&adutux_mutex);
861 usb_set_intfdata(interface, NULL);
843 862
844 /* if the device is not opened, then we clean up right now */ 863 /* if the device is not opened, then we clean up right now */
845 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count); 864 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count);
846 if (!dev->open_count) { 865 if (!dev->open_count)
847 mutex_unlock(&dev->mtx);
848 adu_delete(dev); 866 adu_delete(dev);
849 } else { 867
850 dev->udev = NULL; 868 mutex_unlock(&adutux_mutex);
851 mutex_unlock(&dev->mtx);
852 }
853 869
854 dev_info(&interface->dev, "ADU device adutux%d now disconnected\n", 870 dev_info(&interface->dev, "ADU device adutux%d now disconnected\n",
855 (minor - ADU_MINOR_BASE)); 871 (minor - ADU_MINOR_BASE));
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index 49c5c5c4c431..06cb71942dc7 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -144,12 +144,14 @@ static void led_disconnect(struct usb_interface *interface)
144 struct usb_led *dev; 144 struct usb_led *dev;
145 145
146 dev = usb_get_intfdata (interface); 146 dev = usb_get_intfdata (interface);
147 usb_set_intfdata (interface, NULL);
148 147
149 device_remove_file(&interface->dev, &dev_attr_blue); 148 device_remove_file(&interface->dev, &dev_attr_blue);
150 device_remove_file(&interface->dev, &dev_attr_red); 149 device_remove_file(&interface->dev, &dev_attr_red);
151 device_remove_file(&interface->dev, &dev_attr_green); 150 device_remove_file(&interface->dev, &dev_attr_green);
152 151
152 /* first remove the files, then set the pointer to NULL */
153 usb_set_intfdata (interface, NULL);
154
153 usb_put_dev(dev->udev); 155 usb_put_dev(dev->udev);
154 156
155 kfree(dev); 157 kfree(dev);
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 9eb4a65ee4d9..d41531139c55 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -327,6 +327,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
327 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 327 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
328 unsigned char *data = urb->transfer_buffer; 328 unsigned char *data = urb->transfer_buffer;
329 int status = urb->status; 329 int status = urb->status;
330 unsigned long flags;
330 331
331 dbg("%s - port %d", __FUNCTION__, port->number); 332 dbg("%s - port %d", __FUNCTION__, port->number);
332 333
@@ -339,11 +340,11 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
339 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 340 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
340 341
341 /* Throttle the device if requested by tty */ 342 /* Throttle the device if requested by tty */
342 spin_lock(&port->lock); 343 spin_lock_irqsave(&port->lock, flags);
343 if (!(port->throttled = port->throttle_req)) 344 if (!(port->throttled = port->throttle_req))
344 /* Handle data and continue reading from device */ 345 /* Handle data and continue reading from device */
345 flush_and_resubmit_read_urb(port); 346 flush_and_resubmit_read_urb(port);
346 spin_unlock(&port->lock); 347 spin_unlock_irqrestore(&port->lock, flags);
347} 348}
348EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); 349EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
349 350
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 1f7ab15df36d..feba9679ace8 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1215,12 +1215,14 @@ static int keyspan_chars_in_buffer (struct usb_serial_port *port)
1215 1215
1216static int keyspan_open (struct usb_serial_port *port, struct file *filp) 1216static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1217{ 1217{
1218 struct keyspan_port_private *p_priv; 1218 struct keyspan_port_private *p_priv;
1219 struct keyspan_serial_private *s_priv; 1219 struct keyspan_serial_private *s_priv;
1220 struct usb_serial *serial = port->serial; 1220 struct usb_serial *serial = port->serial;
1221 const struct keyspan_device_details *d_details; 1221 const struct keyspan_device_details *d_details;
1222 int i, err; 1222 int i, err;
1223 int baud_rate, device_port;
1223 struct urb *urb; 1224 struct urb *urb;
1225 unsigned int cflag;
1224 1226
1225 s_priv = usb_get_serial_data(serial); 1227 s_priv = usb_get_serial_data(serial);
1226 p_priv = usb_get_serial_port_data(port); 1228 p_priv = usb_get_serial_port_data(port);
@@ -1263,6 +1265,30 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1263 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ 1265 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */
1264 } 1266 }
1265 1267
1268 /* get the terminal config for the setup message now so we don't
1269 * need to send 2 of them */
1270
1271 cflag = port->tty->termios->c_cflag;
1272 device_port = port->number - port->serial->minor;
1273
1274 /* Baud rate calculation takes baud rate as an integer
1275 so other rates can be generated if desired. */
1276 baud_rate = tty_get_baud_rate(port->tty);
1277 /* If no match or invalid, leave as default */
1278 if (baud_rate >= 0
1279 && d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
1280 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
1281 p_priv->baud = baud_rate;
1282 }
1283
1284 /* set CTS/RTS handshake etc. */
1285 p_priv->cflag = cflag;
1286 p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
1287
1288 keyspan_send_setup(port, 1);
1289 //mdelay(100);
1290 //keyspan_set_termios(port, NULL);
1291
1266 return (0); 1292 return (0);
1267} 1293}
1268 1294
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index a5ced7e08cbf..c29c91271133 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2711,7 +2711,7 @@ static int mos7840_startup(struct usb_serial *serial)
2711 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); 2711 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
2712 if (status < 0) { 2712 if (status < 0) {
2713 dbg("Writing ZLP_REG5 failed status-0x%x\n", status); 2713 dbg("Writing ZLP_REG5 failed status-0x%x\n", status);
2714 return -1; 2714 goto error;
2715 } else 2715 } else
2716 dbg("ZLP_REG5 Writing success status%d\n", status); 2716 dbg("ZLP_REG5 Writing success status%d\n", status);
2717 2717
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 2cd3f1d4b687..cf8add91de05 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -86,6 +86,7 @@ static struct usb_device_id id_table [] = {
86 { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) }, 86 { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) },
87 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ID) }, 87 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ID) },
88 { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, 88 { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) },
89 { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) },
89 { } /* Terminating entry */ 90 { } /* Terminating entry */
90}; 91};
91 92
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index ed603e3decd6..d31f5d299989 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -104,3 +104,6 @@
104#define WS002IN_VENDOR_ID 0x11f6 104#define WS002IN_VENDOR_ID 0x11f6
105#define WS002IN_PRODUCT_ID 0x2001 105#define WS002IN_PRODUCT_ID 0x2001
106 106
107/* Corega CG-USBRS232R Serial Adapter */
108#define COREGA_VENDOR_ID 0x07aa
109#define COREGA_PRODUCT_ID 0x002a
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 833f6e1e3721..605ebccdcd51 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -136,6 +136,8 @@ static struct usb_device_id id_table_3port [] = {
136 { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ 136 { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */
137 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ 137 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
138 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 138 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
139 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
140 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
139 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 141 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
140 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ 142 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
141 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U*/ 143 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U*/
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 1ba19eaa1970..836a34ae6ec6 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -177,6 +177,10 @@ static int slave_configure(struct scsi_device *sdev)
177 * is an occasional series of retries that will all fail. */ 177 * is an occasional series of retries that will all fail. */
178 sdev->retry_hwerror = 1; 178 sdev->retry_hwerror = 1;
179 179
180 /* USB disks should allow restart. Some drives spin down
181 * automatically, requiring a START-STOP UNIT command. */
182 sdev->allow_restart = 1;
183
180 } else { 184 } else {
181 185
182 /* Non-disk-type devices don't need to blacklist any pages 186 /* Non-disk-type devices don't need to blacklist any pages
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 22ab2380367d..2c27721bd259 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -342,11 +342,11 @@ UNUSUAL_DEV( 0x04b0, 0x040d, 0x0100, 0x0100,
342 US_FL_FIX_CAPACITY), 342 US_FL_FIX_CAPACITY),
343 343
344/* Reported by Graber and Mike Pagano <mpagano-kernel@mpagano.com> */ 344/* Reported by Graber and Mike Pagano <mpagano-kernel@mpagano.com> */
345UNUSUAL_DEV( 0x04b0, 0x040f, 0x0200, 0x0200, 345UNUSUAL_DEV( 0x04b0, 0x040f, 0x0100, 0x0200,
346 "NIKON", 346 "NIKON",
347 "NIKON DSC D200", 347 "NIKON DSC D200",
348 US_SC_DEVICE, US_PR_DEVICE, NULL, 348 US_SC_DEVICE, US_PR_DEVICE, NULL,
349 US_FL_FIX_CAPACITY), 349 US_FL_FIX_CAPACITY),
350 350
351/* Reported by Emil Larsson <emil@swip.net> */ 351/* Reported by Emil Larsson <emil@swip.net> */
352UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0101, 352UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0101,
@@ -731,6 +731,13 @@ UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102,
731 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ), 731 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ),
732#endif 732#endif
733 733
734/* Reported by RTE <raszilki@yandex.ru> */
735UNUSUAL_DEV( 0x058f, 0x6387, 0x0141, 0x0141,
736 "JetFlash",
737 "TS1GJF2A/120",
738 US_SC_DEVICE, US_PR_DEVICE, NULL,
739 US_FL_MAX_SECTORS_64 ),
740
734/* Fabrizio Fellini <fello@libero.it> */ 741/* Fabrizio Fellini <fello@libero.it> */
735UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, 742UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210,
736 "Fujifilm", 743 "Fujifilm",
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 7d86e9eae915..5b3dbcfcda48 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -641,6 +641,17 @@ config FB_VESA
641 You will get a boot time penguin logo at no additional cost. Please 641 You will get a boot time penguin logo at no additional cost. Please
642 read <file:Documentation/fb/vesafb.txt>. If unsure, say Y. 642 read <file:Documentation/fb/vesafb.txt>. If unsure, say Y.
643 643
644config FB_EFI
645 bool "EFI-based Framebuffer Support"
646 depends on (FB = y) && X86
647 select FB_CFB_FILLRECT
648 select FB_CFB_COPYAREA
649 select FB_CFB_IMAGEBLIT
650 help
651 This is the EFI frame buffer device driver. If the firmware on
652 your platform is UEFI2.0, select Y to add support for
653 Graphics Output Protocol for early console messages to appear.
654
644config FB_IMAC 655config FB_IMAC
645 bool "Intel-based Macintosh Framebuffer Support" 656 bool "Intel-based Macintosh Framebuffer Support"
646 depends on (FB = y) && X86 && EFI 657 depends on (FB = y) && X86 && EFI
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 59d6c45a910d..83e02b3429b6 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -118,6 +118,7 @@ obj-$(CONFIG_FB_OMAP) += omap/
118obj-$(CONFIG_FB_UVESA) += uvesafb.o 118obj-$(CONFIG_FB_UVESA) += uvesafb.o
119obj-$(CONFIG_FB_VESA) += vesafb.o 119obj-$(CONFIG_FB_VESA) += vesafb.o
120obj-$(CONFIG_FB_IMAC) += imacfb.o 120obj-$(CONFIG_FB_IMAC) += imacfb.o
121obj-$(CONFIG_FB_EFI) += efifb.o
121obj-$(CONFIG_FB_VGA16) += vga16fb.o 122obj-$(CONFIG_FB_VGA16) += vga16fb.o
122obj-$(CONFIG_FB_OF) += offb.o 123obj-$(CONFIG_FB_OF) += offb.o
123obj-$(CONFIG_FB_BF54X_LQ043) += bf54x-lq043fb.o 124obj-$(CONFIG_FB_BF54X_LQ043) += bf54x-lq043fb.o
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 235b618b4117..11a3a222dfc3 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -268,6 +268,10 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
268 /* Turn off the LCD controller and the DMA controller */ 268 /* Turn off the LCD controller and the DMA controller */
269 lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET); 269 lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET);
270 270
271 /* Wait for the LCDC core to become idle */
272 while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY)
273 msleep(10);
274
271 lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0); 275 lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0);
272 276
273 if (info->var.bits_per_pixel == 1) 277 if (info->var.bits_per_pixel == 1)
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 1e32b3d13f2e..62867cb63fef 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -202,6 +202,7 @@ static struct pci_device_id radeonfb_pci_table[] = {
202 CHIP_DEF(PCI_CHIP_RV380_3154, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), 202 CHIP_DEF(PCI_CHIP_RV380_3154, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
203 CHIP_DEF(PCI_CHIP_RV370_5B60, RV380, CHIP_HAS_CRTC2), 203 CHIP_DEF(PCI_CHIP_RV370_5B60, RV380, CHIP_HAS_CRTC2),
204 CHIP_DEF(PCI_CHIP_RV370_5B62, RV380, CHIP_HAS_CRTC2), 204 CHIP_DEF(PCI_CHIP_RV370_5B62, RV380, CHIP_HAS_CRTC2),
205 CHIP_DEF(PCI_CHIP_RV370_5B63, RV380, CHIP_HAS_CRTC2),
205 CHIP_DEF(PCI_CHIP_RV370_5B64, RV380, CHIP_HAS_CRTC2), 206 CHIP_DEF(PCI_CHIP_RV370_5B64, RV380, CHIP_HAS_CRTC2),
206 CHIP_DEF(PCI_CHIP_RV370_5B65, RV380, CHIP_HAS_CRTC2), 207 CHIP_DEF(PCI_CHIP_RV370_5B65, RV380, CHIP_HAS_CRTC2),
207 CHIP_DEF(PCI_CHIP_RV370_5460, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), 208 CHIP_DEF(PCI_CHIP_RV370_5460, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 267422f66255..b87ed37ac0c1 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -6,7 +6,7 @@ menu "Console display driver support"
6 6
7config VGA_CONSOLE 7config VGA_CONSOLE
8 bool "VGA text console" if EMBEDDED || !X86 8 bool "VGA text console" if EMBEDDED || !X86
9 depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !ARCH_VERSATILE && !SUPERH && !BFIN 9 depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !ARCH_VERSATILE && !SUPERH && !BLACKFIN
10 default y 10 default y
11 help 11 help
12 Saying Y here will allow you to use Linux in text mode through a 12 Saying Y here will allow you to use Linux in text mode through a
diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
new file mode 100644
index 000000000000..bd779ae44b1e
--- /dev/null
+++ b/drivers/video/efifb.c
@@ -0,0 +1,232 @@
1/*
2 * Framebuffer driver for EFI/UEFI based system
3 *
4 * (c) 2006 Edgar Hucek <gimli@dark-green.com>
5 * Original efi driver written by Gerd Knorr <kraxel@goldbach.in-berlin.de>
6 *
7 */
8
9#include <linux/module.h>
10#include <linux/kernel.h>
11#include <linux/errno.h>
12#include <linux/fb.h>
13#include <linux/platform_device.h>
14#include <linux/screen_info.h>
15
16#include <video/vga.h>
17
18static struct fb_var_screeninfo efifb_defined __initdata = {
19 .activate = FB_ACTIVATE_NOW,
20 .height = -1,
21 .width = -1,
22 .right_margin = 32,
23 .upper_margin = 16,
24 .lower_margin = 4,
25 .vsync_len = 4,
26 .vmode = FB_VMODE_NONINTERLACED,
27};
28
29static struct fb_fix_screeninfo efifb_fix __initdata = {
30 .id = "EFI VGA",
31 .type = FB_TYPE_PACKED_PIXELS,
32 .accel = FB_ACCEL_NONE,
33 .visual = FB_VISUAL_TRUECOLOR,
34};
35
36static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green,
37 unsigned blue, unsigned transp,
38 struct fb_info *info)
39{
40 /*
41 * Set a single color register. The values supplied are
42 * already rounded down to the hardware's capabilities
43 * (according to the entries in the `var' structure). Return
44 * != 0 for invalid regno.
45 */
46
47 if (regno >= info->cmap.len)
48 return 1;
49
50 if (regno < 16) {
51 red >>= 8;
52 green >>= 8;
53 blue >>= 8;
54 ((u32 *)(info->pseudo_palette))[regno] =
55 (red << info->var.red.offset) |
56 (green << info->var.green.offset) |
57 (blue << info->var.blue.offset);
58 }
59 return 0;
60}
61
62static struct fb_ops efifb_ops = {
63 .owner = THIS_MODULE,
64 .fb_setcolreg = efifb_setcolreg,
65 .fb_fillrect = cfb_fillrect,
66 .fb_copyarea = cfb_copyarea,
67 .fb_imageblit = cfb_imageblit,
68};
69
70static int __init efifb_probe(struct platform_device *dev)
71{
72 struct fb_info *info;
73 int err;
74 unsigned int size_vmode;
75 unsigned int size_remap;
76 unsigned int size_total;
77
78 efifb_fix.smem_start = screen_info.lfb_base;
79 efifb_defined.bits_per_pixel = screen_info.lfb_depth;
80 efifb_defined.xres = screen_info.lfb_width;
81 efifb_defined.yres = screen_info.lfb_height;
82 efifb_fix.line_length = screen_info.lfb_linelength;
83
84 /* size_vmode -- that is the amount of memory needed for the
85 * used video mode, i.e. the minimum amount of
86 * memory we need. */
87 size_vmode = efifb_defined.yres * efifb_fix.line_length;
88
89 /* size_total -- all video memory we have. Used for
90 * entries, ressource allocation and bounds
91 * checking. */
92 size_total = screen_info.lfb_size;
93 if (size_total < size_vmode)
94 size_total = size_vmode;
95
96 /* size_remap -- the amount of video memory we are going to
97 * use for efifb. With modern cards it is no
98 * option to simply use size_total as that
99 * wastes plenty of kernel address space. */
100 size_remap = size_vmode * 2;
101 if (size_remap < size_vmode)
102 size_remap = size_vmode;
103 if (size_remap > size_total)
104 size_remap = size_total;
105 efifb_fix.smem_len = size_remap;
106
107 if (!request_mem_region(efifb_fix.smem_start, size_total, "efifb"))
108 /* We cannot make this fatal. Sometimes this comes from magic
109 spaces our resource handlers simply don't know about */
110 printk(KERN_WARNING
111 "efifb: cannot reserve video memory at 0x%lx\n",
112 efifb_fix.smem_start);
113
114 info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
115 if (!info) {
116 err = -ENOMEM;
117 goto err_release_mem;
118 }
119 info->pseudo_palette = info->par;
120 info->par = NULL;
121
122 info->screen_base = ioremap(efifb_fix.smem_start, efifb_fix.smem_len);
123 if (!info->screen_base) {
124 printk(KERN_ERR "efifb: abort, cannot ioremap video memory "
125 "0x%x @ 0x%lx\n",
126 efifb_fix.smem_len, efifb_fix.smem_start);
127 err = -EIO;
128 goto err_unmap;
129 }
130
131 printk(KERN_INFO "efifb: framebuffer at 0x%lx, mapped to 0x%p, "
132 "using %dk, total %dk\n",
133 efifb_fix.smem_start, info->screen_base,
134 size_remap/1024, size_total/1024);
135 printk(KERN_INFO "efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
136 efifb_defined.xres, efifb_defined.yres,
137 efifb_defined.bits_per_pixel, efifb_fix.line_length,
138 screen_info.pages);
139
140 efifb_defined.xres_virtual = efifb_defined.xres;
141 efifb_defined.yres_virtual = efifb_fix.smem_len /
142 efifb_fix.line_length;
143 printk(KERN_INFO "efifb: scrolling: redraw\n");
144 efifb_defined.yres_virtual = efifb_defined.yres;
145
146 /* some dummy values for timing to make fbset happy */
147 efifb_defined.pixclock = 10000000 / efifb_defined.xres *
148 1000 / efifb_defined.yres;
149 efifb_defined.left_margin = (efifb_defined.xres / 8) & 0xf8;
150 efifb_defined.hsync_len = (efifb_defined.xres / 8) & 0xf8;
151
152 efifb_defined.red.offset = screen_info.red_pos;
153 efifb_defined.red.length = screen_info.red_size;
154 efifb_defined.green.offset = screen_info.green_pos;
155 efifb_defined.green.length = screen_info.green_size;
156 efifb_defined.blue.offset = screen_info.blue_pos;
157 efifb_defined.blue.length = screen_info.blue_size;
158 efifb_defined.transp.offset = screen_info.rsvd_pos;
159 efifb_defined.transp.length = screen_info.rsvd_size;
160
161 printk(KERN_INFO "efifb: %s: "
162 "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
163 "Truecolor",
164 screen_info.rsvd_size,
165 screen_info.red_size,
166 screen_info.green_size,
167 screen_info.blue_size,
168 screen_info.rsvd_pos,
169 screen_info.red_pos,
170 screen_info.green_pos,
171 screen_info.blue_pos);
172
173 efifb_fix.ypanstep = 0;
174 efifb_fix.ywrapstep = 0;
175
176 info->fbops = &efifb_ops;
177 info->var = efifb_defined;
178 info->fix = efifb_fix;
179 info->flags = FBINFO_FLAG_DEFAULT;
180
181 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
182 err = -ENOMEM;
183 goto err_unmap;
184 }
185 if (register_framebuffer(info) < 0) {
186 err = -EINVAL;
187 goto err_fb_dealoc;
188 }
189 printk(KERN_INFO "fb%d: %s frame buffer device\n",
190 info->node, info->fix.id);
191 return 0;
192
193err_fb_dealoc:
194 fb_dealloc_cmap(&info->cmap);
195err_unmap:
196 iounmap(info->screen_base);
197 framebuffer_release(info);
198err_release_mem:
199 release_mem_region(efifb_fix.smem_start, size_total);
200 return err;
201}
202
203static struct platform_driver efifb_driver = {
204 .probe = efifb_probe,
205 .driver = {
206 .name = "efifb",
207 },
208};
209
210static struct platform_device efifb_device = {
211 .name = "efifb",
212};
213
214static int __init efifb_init(void)
215{
216 int ret;
217
218 if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
219 return -ENODEV;
220
221 ret = platform_driver_register(&efifb_driver);
222
223 if (!ret) {
224 ret = platform_device_register(&efifb_device);
225 if (ret)
226 platform_driver_unregister(&efifb_driver);
227 }
228 return ret;
229}
230module_init(efifb_init);
231
232MODULE_LICENSE("GPL");
diff --git a/drivers/video/fb_ddc.c b/drivers/video/fb_ddc.c
index f836137a0eda..a0df63289b5f 100644
--- a/drivers/video/fb_ddc.c
+++ b/drivers/video/fb_ddc.c
@@ -56,13 +56,12 @@ unsigned char *fb_ddc_read(struct i2c_adapter *adapter)
56 int i, j; 56 int i, j;
57 57
58 algo_data->setscl(algo_data->data, 1); 58 algo_data->setscl(algo_data->data, 1);
59 algo_data->setscl(algo_data->data, 0);
60 59
61 for (i = 0; i < 3; i++) { 60 for (i = 0; i < 3; i++) {
62 /* For some old monitors we need the 61 /* For some old monitors we need the
63 * following process to initialize/stop DDC 62 * following process to initialize/stop DDC
64 */ 63 */
65 algo_data->setsda(algo_data->data, 0); 64 algo_data->setsda(algo_data->data, 1);
66 msleep(13); 65 msleep(13);
67 66
68 algo_data->setscl(algo_data->data, 1); 67 algo_data->setscl(algo_data->data, 1);
@@ -97,14 +96,15 @@ unsigned char *fb_ddc_read(struct i2c_adapter *adapter)
97 algo_data->setsda(algo_data->data, 1); 96 algo_data->setsda(algo_data->data, 1);
98 msleep(15); 97 msleep(15);
99 algo_data->setscl(algo_data->data, 0); 98 algo_data->setscl(algo_data->data, 0);
99 algo_data->setsda(algo_data->data, 0);
100 if (edid) 100 if (edid)
101 break; 101 break;
102 } 102 }
103 /* Release the DDC lines when done or the Apple Cinema HD display 103 /* Release the DDC lines when done or the Apple Cinema HD display
104 * will switch off 104 * will switch off
105 */ 105 */
106 algo_data->setsda(algo_data->data, 0); 106 algo_data->setsda(algo_data->data, 1);
107 algo_data->setscl(algo_data->data, 0); 107 algo_data->setscl(algo_data->data, 1);
108 108
109 return edid; 109 return edid;
110} 110}
diff --git a/drivers/video/imacfb.c b/drivers/video/imacfb.c
index 6455fd2a39f2..9366ef2bb5f7 100644
--- a/drivers/video/imacfb.c
+++ b/drivers/video/imacfb.c
@@ -234,10 +234,6 @@ static int __init imacfb_probe(struct platform_device *dev)
234 size_remap = size_total; 234 size_remap = size_total;
235 imacfb_fix.smem_len = size_remap; 235 imacfb_fix.smem_len = size_remap;
236 236
237#ifndef __i386__
238 screen_info.imacpm_seg = 0;
239#endif
240
241 if (!request_mem_region(imacfb_fix.smem_start, size_total, "imacfb")) { 237 if (!request_mem_region(imacfb_fix.smem_start, size_total, "imacfb")) {
242 printk(KERN_WARNING 238 printk(KERN_WARNING
243 "imacfb: cannot reserve video memory at 0x%lx\n", 239 "imacfb: cannot reserve video memory at 0x%lx\n",
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 75836aa83191..9c56c492a693 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -51,7 +51,6 @@
51#define L1GPU_DISPLAY_SYNC_HSYNC 1 51#define L1GPU_DISPLAY_SYNC_HSYNC 1
52#define L1GPU_DISPLAY_SYNC_VSYNC 2 52#define L1GPU_DISPLAY_SYNC_VSYNC 2
53 53
54#define DDR_SIZE (0) /* used no ddr */
55#define GPU_CMD_BUF_SIZE (64 * 1024) 54#define GPU_CMD_BUF_SIZE (64 * 1024)
56#define GPU_IOIF (0x0d000000UL) 55#define GPU_IOIF (0x0d000000UL)
57#define GPU_ALIGN_UP(x) _ALIGN_UP((x), 64) 56#define GPU_ALIGN_UP(x) _ALIGN_UP((x), 64)
@@ -1060,6 +1059,7 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
1060 u64 xdr_lpar; 1059 u64 xdr_lpar;
1061 int status, res_index; 1060 int status, res_index;
1062 struct task_struct *task; 1061 struct task_struct *task;
1062 unsigned long max_ps3fb_size;
1063 1063
1064 status = ps3_open_hv_device(dev); 1064 status = ps3_open_hv_device(dev);
1065 if (status) { 1065 if (status) {
@@ -1085,8 +1085,15 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
1085 1085
1086 ps3fb_set_sync(&dev->core); 1086 ps3fb_set_sync(&dev->core);
1087 1087
1088 max_ps3fb_size = _ALIGN_UP(GPU_IOIF, 256*1024*1024) - GPU_IOIF;
1089 if (ps3fb_videomemory.size > max_ps3fb_size) {
1090 dev_info(&dev->core, "Limiting ps3fb mem size to %lu bytes\n",
1091 max_ps3fb_size);
1092 ps3fb_videomemory.size = max_ps3fb_size;
1093 }
1094
1088 /* get gpu context handle */ 1095 /* get gpu context handle */
1089 status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0, 1096 status = lv1_gpu_memory_allocate(ps3fb_videomemory.size, 0, 0, 0, 0,
1090 &ps3fb.memory_handle, &ddr_lpar); 1097 &ps3fb.memory_handle, &ddr_lpar);
1091 if (status) { 1098 if (status) {
1092 dev_err(&dev->core, "%s: lv1_gpu_memory_allocate failed: %d\n", 1099 dev_err(&dev->core, "%s: lv1_gpu_memory_allocate failed: %d\n",
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 15d7787dea87..69d7ea02cd48 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -96,10 +96,23 @@ static int virtio_dev_probe(struct device *_d)
96 return err; 96 return err;
97} 97}
98 98
99static int virtio_dev_remove(struct device *_d)
100{
101 struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
102 struct virtio_driver *drv = container_of(dev->dev.driver,
103 struct virtio_driver, driver);
104
105 dev->config->set_status(dev, dev->config->get_status(dev)
106 & ~VIRTIO_CONFIG_S_DRIVER);
107 drv->remove(dev);
108 return 0;
109}
110
99int register_virtio_driver(struct virtio_driver *driver) 111int register_virtio_driver(struct virtio_driver *driver)
100{ 112{
101 driver->driver.bus = &virtio_bus; 113 driver->driver.bus = &virtio_bus;
102 driver->driver.probe = virtio_dev_probe; 114 driver->driver.probe = virtio_dev_probe;
115 driver->driver.remove = virtio_dev_remove;
103 return driver_register(&driver->driver); 116 return driver_register(&driver->driver);
104} 117}
105EXPORT_SYMBOL_GPL(register_virtio_driver); 118EXPORT_SYMBOL_GPL(register_virtio_driver);
diff --git a/drivers/zorro/zorro-driver.c b/drivers/zorro/zorro-driver.c
index 067c07be928c..e6c4390d8bd6 100644
--- a/drivers/zorro/zorro-driver.c
+++ b/drivers/zorro/zorro-driver.c
@@ -60,6 +60,20 @@ static int zorro_device_probe(struct device *dev)
60} 60}
61 61
62 62
63static int zorro_device_remove(struct device *dev)
64{
65 struct zorro_dev *z = to_zorro_dev(dev);
66 struct zorro_driver *drv = to_zorro_driver(dev->driver);
67
68 if (drv) {
69 if (drv->remove)
70 drv->remove(z);
71 z->driver = NULL;
72 }
73 return 0;
74}
75
76
63 /** 77 /**
64 * zorro_register_driver - register a new Zorro driver 78 * zorro_register_driver - register a new Zorro driver
65 * @drv: the driver structure to register 79 * @drv: the driver structure to register
@@ -128,6 +142,7 @@ struct bus_type zorro_bus_type = {
128 .name = "zorro", 142 .name = "zorro",
129 .match = zorro_bus_match, 143 .match = zorro_bus_match,
130 .probe = zorro_device_probe, 144 .probe = zorro_device_probe,
145 .remove = zorro_device_remove,
131}; 146};
132 147
133 148