aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/feature-removal-schedule.txt7
-rw-r--r--Documentation/pci.txt12
-rw-r--r--Documentation/power/pci.txt2
-rw-r--r--arch/alpha/kernel/err_common.c1
-rw-r--r--arch/alpha/kernel/err_ev6.c1
-rw-r--r--arch/alpha/kernel/err_ev7.c1
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/i386/Kconfig1
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-lib.c1
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-smi.c2
-rw-r--r--arch/i386/kernel/io_apic.c4
-rw-r--r--arch/i386/pci/fixup.c2
-rw-r--r--arch/i386/pci/i386.c4
-rw-r--r--arch/ia64/Kconfig1
-rw-r--r--arch/ia64/sn/kernel/huberror.c1
-rw-r--r--arch/ia64/sn/kernel/msi_sn.c4
-rw-r--r--arch/ia64/sn/kernel/xpnet.c1
-rw-r--r--arch/m68knommu/kernel/dma.c1
-rw-r--r--arch/mips/lib/iomap.c1
-rw-r--r--arch/powerpc/kernel/pci_64.c2
-rw-r--r--arch/powerpc/platforms/pseries/ras.c1
-rw-r--r--arch/ppc/8260_io/enet.c1
-rw-r--r--arch/ppc/8260_io/fcc_enet.c1
-rw-r--r--arch/ppc/8xx_io/enet.c1
-rw-r--r--arch/ppc/syslib/ppc4xx_sgdma.c1
-rw-r--r--arch/sh64/mach-cayman/iomap.c1
-rw-r--r--arch/sparc64/Kconfig1
-rw-r--r--arch/sparc64/kernel/pci.c4
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c4
-rw-r--r--arch/x86_64/Kconfig1
-rw-r--r--arch/x86_64/kernel/io_apic.c4
-rw-r--r--arch/xtensa/kernel/xtensa_ksyms.c1
-rw-r--r--arch/xtensa/platform-iss/setup.c1
-rw-r--r--drivers/atm/adummy.c1
-rw-r--r--drivers/base/dd.c41
-rw-r--r--drivers/char/agp/alpha-agp.c2
-rw-r--r--drivers/char/agp/parisc-agp.c2
-rw-r--r--drivers/char/hw_random/via-rng.c1
-rw-r--r--drivers/char/pcmcia/synclink_cs.c1
-rw-r--r--drivers/char/tpm/tpm.h1
-rw-r--r--drivers/char/watchdog/sc1200wdt.c1
-rw-r--r--drivers/char/watchdog/scx200_wdt.c2
-rw-r--r--drivers/i2c/busses/i2c-at91.c1
-rw-r--r--drivers/i2c/busses/i2c-mpc.c1
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c1
-rw-r--r--drivers/ieee1394/hosts.c1
-rw-r--r--drivers/infiniband/core/cm.c1
-rw-r--r--drivers/infiniband/core/iwcm.c1
-rw-r--r--drivers/infiniband/core/mad_priv.h1
-rw-r--r--drivers/infiniband/core/multicast.c1
-rw-r--r--drivers/infiniband/core/sa_query.c1
-rw-r--r--drivers/infiniband/core/user_mad.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_fs.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_layer.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_stats.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sysfs.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.h1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h1
-rw-r--r--drivers/isdn/hisax/netjet.c1
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c1
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c2
-rw-r--r--drivers/media/video/adv7170.c1
-rw-r--r--drivers/media/video/adv7175.c1
-rw-r--r--drivers/media/video/bt819.c1
-rw-r--r--drivers/media/video/bt856.c1
-rw-r--r--drivers/media/video/bt866.c1
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c1
-rw-r--r--drivers/media/video/saa7111.c1
-rw-r--r--drivers/media/video/saa7114.c1
-rw-r--r--drivers/media/video/saa711x.c1
-rw-r--r--drivers/media/video/saa7185.c1
-rw-r--r--drivers/misc/hdpuftrs/hdpu_cpustate.c1
-rw-r--r--drivers/misc/hdpuftrs/hdpu_nexus.c1
-rw-r--r--drivers/mtd/devices/doc2000.c1
-rw-r--r--drivers/mtd/devices/doc2001.c1
-rw-r--r--drivers/mtd/devices/doc2001plus.c1
-rw-r--r--drivers/mtd/devices/docecc.c1
-rw-r--r--drivers/mtd/inftlmount.c1
-rw-r--r--drivers/mtd/nand/cs553x_nand.c1
-rw-r--r--drivers/mtd/nftlcore.c1
-rw-r--r--drivers/net/atl1/atl1_param.c1
-rw-r--r--drivers/net/au1000_eth.c1
-rw-r--r--drivers/net/fec_8xx/fec_main.c1
-rw-r--r--drivers/net/fec_8xx/fec_mii.c1
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c1
-rw-r--r--drivers/net/fs_enet/mac-fcc.c1
-rw-r--r--drivers/net/fs_enet/mac-fec.c1
-rw-r--r--drivers/net/fs_enet/mac-scc.c1
-rw-r--r--drivers/net/fs_enet/mii-bitbang.c1
-rw-r--r--drivers/net/fs_enet/mii-fec.c1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c1
-rw-r--r--drivers/net/ixgb/ixgb_osdep.h1
-rw-r--r--drivers/net/lasi_82596.c1
-rw-r--r--drivers/net/tokenring/madgemc.c1
-rw-r--r--drivers/net/tokenring/smctr.c1
-rw-r--r--drivers/net/tulip/21142.c1
-rw-r--r--drivers/net/tulip/pnic.c1
-rw-r--r--drivers/net/tulip/pnic2.c1
-rw-r--r--drivers/net/tulip/timer.c1
-rw-r--r--drivers/net/tulip/tulip.h1
-rw-r--r--drivers/net/wan/lmc/lmc_media.c1
-rw-r--r--drivers/net/wan/lmc/lmc_proto.c1
-rw-r--r--drivers/net/wan/pc300_tty.c1
-rw-r--r--drivers/parisc/hppb.c2
-rw-r--r--drivers/pci/Kconfig31
-rw-r--r--drivers/pci/bus.c4
-rw-r--r--drivers/pci/hotplug/Kconfig25
-rw-r--r--drivers/pci/hotplug/cpcihp_zt5550.c6
-rw-r--r--drivers/pci/hotplug/fakephp.c2
-rw-r--r--drivers/pci/hotplug/pciehp.h19
-rw-r--r--drivers/pci/hotplug/pciehp_core.c82
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c616
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c34
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c27
-rw-r--r--drivers/pci/hotplug/rpaphp.h8
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c200
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c167
-rw-r--r--drivers/pci/hotplug/rpaphp_slot.c49
-rw-r--r--drivers/pci/hotplug/shpchp.h2
-rw-r--r--drivers/pci/hotplug/shpchp_core.c2
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c2
-rw-r--r--drivers/pci/msi.c398
-rw-r--r--drivers/pci/pci-driver.c19
-rw-r--r--drivers/pci/pci-sysfs.c9
-rw-r--r--drivers/pci/pci.c34
-rw-r--r--drivers/pci/pci.h2
-rw-r--r--drivers/pci/probe.c42
-rw-r--r--drivers/pci/quirks.c2
-rw-r--r--drivers/pci/search.c3
-rw-r--r--drivers/pci/setup-bus.c21
-rw-r--r--drivers/pci/setup-res.c6
-rw-r--r--drivers/pcmcia/cs.c1
-rw-r--r--drivers/pcmcia/socket_sysfs.c1
-rw-r--r--drivers/sbus/sbus.c1
-rw-r--r--drivers/scsi/aacraid/dpcsup.c1
-rw-r--r--drivers/scsi/aacraid/sa.c1
-rw-r--r--drivers/scsi/aha1542.c1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c1
-rw-r--r--drivers/scsi/arcmsr/arcmsr_attr.c1
-rw-r--r--drivers/scsi/libsas/sas_expander.c1
-rw-r--r--drivers/scsi/libsrp.c1
-rw-r--r--drivers/scsi/megaraid.c2
-rw-r--r--drivers/usb/net/kaweth.c1
-rw-r--r--drivers/video/aty/radeon_i2c.c1
-rw-r--r--drivers/video/g364fb.c1
-rw-r--r--drivers/video/platinumfb.c1
-rw-r--r--drivers/video/stifb.c1
-rw-r--r--drivers/video/valkyriefb.c1
-rw-r--r--include/asm-alpha/scatterlist.h1
-rw-r--r--include/asm-arm/arch-ixp4xx/dma.h1
-rw-r--r--include/asm-avr32/scatterlist.h2
-rw-r--r--include/asm-frv/scatterlist.h2
-rw-r--r--include/asm-h8300/scatterlist.h2
-rw-r--r--include/asm-i386/scatterlist.h2
-rw-r--r--include/asm-ia64/scatterlist.h2
-rw-r--r--include/asm-m32r/scatterlist.h2
-rw-r--r--include/asm-m68knommu/scatterlist.h1
-rw-r--r--include/asm-mips/scatterlist.h2
-rw-r--r--include/asm-parisc/scatterlist.h1
-rw-r--r--include/asm-sh/scatterlist.h2
-rw-r--r--include/asm-sh64/scatterlist.h2
-rw-r--r--include/asm-sparc64/scatterlist.h1
-rw-r--r--include/asm-v850/scatterlist.h2
-rw-r--r--include/asm-x86_64/scatterlist.h2
-rw-r--r--include/asm-xtensa/scatterlist.h2
-rw-r--r--include/linux/device.h1
-rw-r--r--include/linux/msi.h11
-rw-r--r--include/linux/pci.h27
-rw-r--r--include/rdma/ib_mad.h2
-rw-r--r--kernel/irq/chip.c3
-rw-r--r--sound/core/init.c1
-rw-r--r--sound/oss/au1550_ac97.c1
-rw-r--r--sound/oss/soundcard.c1
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c2
-rw-r--r--sound/pci/ca0106/ca0106_proc.c2
-rw-r--r--sound/pci/cs46xx/dsp_spos.c1
-rw-r--r--sound/pci/cs46xx/dsp_spos_scb_lib.c1
-rw-r--r--sound/pci/hda/hda_generic.c1
-rw-r--r--sound/pci/hda/hda_proc.c1
-rw-r--r--sound/pci/hda/patch_atihdmi.c1
-rw-r--r--sound/pci/hda/patch_si3054.c1
-rw-r--r--sound/pci/hda/patch_via.c1
183 files changed, 881 insertions, 1226 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 7d252dbe7d17..5f96cb33743e 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -117,13 +117,6 @@ Who: Adrian Bunk <bunk@stusta.de>
117 117
118--------------------------- 118---------------------------
119 119
120What: pci_module_init(driver)
121When: January 2007
122Why: Is replaced by pci_register_driver(pci_driver).
123Who: Richard Knutsson <ricknu-0@student.ltu.se> and Greg Kroah-Hartman <gregkh@suse.de>
124
125---------------------------
126
127What: Usage of invalid timevals in setitimer 120What: Usage of invalid timevals in setitimer
128When: March 2007 121When: March 2007
129Why: POSIX requires to validate timevals in the setitimer call. This 122Why: POSIX requires to validate timevals in the setitimer call. This
diff --git a/Documentation/pci.txt b/Documentation/pci.txt
index cdf2f3c0ab14..e2c9d0a0c43d 100644
--- a/Documentation/pci.txt
+++ b/Documentation/pci.txt
@@ -124,10 +124,6 @@ initialization with a pointer to a structure describing the driver
124 124
125 err_handler See Documentation/pci-error-recovery.txt 125 err_handler See Documentation/pci-error-recovery.txt
126 126
127 multithread_probe Enable multi-threaded probe/scan. Driver must
128 provide its own locking/syncronization for init
129 operations if this is enabled.
130
131 127
132The ID table is an array of struct pci_device_id entries ending with an 128The ID table is an array of struct pci_device_id entries ending with an
133all-zero entry. Each entry consists of: 129all-zero entry. Each entry consists of:
@@ -163,9 +159,9 @@ echo "vendor device subvendor subdevice class class_mask driver_data" > \
163/sys/bus/pci/drivers/{driver}/new_id 159/sys/bus/pci/drivers/{driver}/new_id
164 160
165All fields are passed in as hexadecimal values (no leading 0x). 161All fields are passed in as hexadecimal values (no leading 0x).
166Users need pass only as many fields as necessary: 162The vendor and device fields are mandatory, the others are optional. Users
167 o vendor, device, subvendor, and subdevice fields default 163need pass only as many optional fields as necessary:
168 to PCI_ANY_ID (FFFFFFFF), 164 o subvendor and subdevice fields default to PCI_ANY_ID (FFFFFFFF)
169 o class and classmask fields default to 0 165 o class and classmask fields default to 0
170 o driver_data defaults to 0UL. 166 o driver_data defaults to 0UL.
171 167
@@ -549,8 +545,6 @@ pci_find_slot() Find pci_dev corresponding to given bus and
549pci_set_power_state() Set PCI Power Management state (0=D0 ... 3=D3) 545pci_set_power_state() Set PCI Power Management state (0=D0 ... 3=D3)
550pci_find_capability() Find specified capability in device's capability 546pci_find_capability() Find specified capability in device's capability
551 list. 547 list.
552pci_module_init() Inline helper function for ensuring correct
553 pci_driver initialization and error handling.
554pci_resource_start() Returns bus start address for a given PCI region 548pci_resource_start() Returns bus start address for a given PCI region
555pci_resource_end() Returns bus end address for a given PCI region 549pci_resource_end() Returns bus end address for a given PCI region
556pci_resource_len() Returns the byte length of a PCI region 550pci_resource_len() Returns the byte length of a PCI region
diff --git a/Documentation/power/pci.txt b/Documentation/power/pci.txt
index b6a3cbf7e846..e00b099a4b86 100644
--- a/Documentation/power/pci.txt
+++ b/Documentation/power/pci.txt
@@ -203,7 +203,7 @@ resume
203 203
204Usage: 204Usage:
205 205
206if (dev->driver && dev->driver->suspend) 206if (dev->driver && dev->driver->resume)
207 dev->driver->resume(dev) 207 dev->driver->resume(dev)
208 208
209The resume callback may be called from any power state, and is always meant to 209The resume callback may be called from any power state, and is always meant to
diff --git a/arch/alpha/kernel/err_common.c b/arch/alpha/kernel/err_common.c
index 687580b16b41..13d53b1c9657 100644
--- a/arch/alpha/kernel/err_common.c
+++ b/arch/alpha/kernel/err_common.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/pci.h>
11#include <linux/sched.h> 10#include <linux/sched.h>
12 11
13#include <asm/io.h> 12#include <asm/io.h>
diff --git a/arch/alpha/kernel/err_ev6.c b/arch/alpha/kernel/err_ev6.c
index 69b5f4ea7355..11aee012a8ae 100644
--- a/arch/alpha/kernel/err_ev6.c
+++ b/arch/alpha/kernel/err_ev6.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/pci.h>
11#include <linux/sched.h> 10#include <linux/sched.h>
12 11
13#include <asm/io.h> 12#include <asm/io.h>
diff --git a/arch/alpha/kernel/err_ev7.c b/arch/alpha/kernel/err_ev7.c
index 95463ab1cf35..bc799f72d8c1 100644
--- a/arch/alpha/kernel/err_ev7.c
+++ b/arch/alpha/kernel/err_ev7.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/pci.h>
11#include <linux/sched.h> 10#include <linux/sched.h>
12 11
13#include <asm/io.h> 12#include <asm/io.h>
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e7baca29f3fb..db00376aca15 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -255,6 +255,7 @@ config ARCH_IOP13XX
255 depends on MMU 255 depends on MMU
256 select PLAT_IOP 256 select PLAT_IOP
257 select PCI 257 select PCI
258 select ARCH_SUPPORTS_MSI
258 help 259 help
259 Support for Intel's IOP13XX (XScale) family of processors. 260 Support for Intel's IOP13XX (XScale) family of processors.
260 261
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 53d62373a524..bcf2fc408a1a 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -1073,6 +1073,7 @@ config PCI
1073 bool "PCI support" if !X86_VISWS 1073 bool "PCI support" if !X86_VISWS
1074 depends on !X86_VOYAGER 1074 depends on !X86_VOYAGER
1075 default y if X86_VISWS 1075 default y if X86_VISWS
1076 select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC)
1076 help 1077 help
1077 Find out whether you have a PCI motherboard. PCI is the name of a 1078 Find out whether you have a PCI motherboard. PCI is the name of a
1078 bus system, i.e. the way the CPU talks to the other stuff inside 1079 bus system, i.e. the way the CPU talks to the other stuff inside
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
index d59277c00911..b1acc8ce3167 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
@@ -13,7 +13,6 @@
13#include <linux/moduleparam.h> 13#include <linux/moduleparam.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/cpufreq.h> 15#include <linux/cpufreq.h>
16#include <linux/pci.h>
17#include <linux/slab.h> 16#include <linux/slab.h>
18 17
19#include <asm/msr.h> 18#include <asm/msr.h>
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
index ff0d89806114..e1c509aa3054 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
@@ -17,10 +17,10 @@
17#include <linux/moduleparam.h> 17#include <linux/moduleparam.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/cpufreq.h> 19#include <linux/cpufreq.h>
20#include <linux/pci.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <asm/ist.h> 22#include <asm/ist.h>
23#include <asm/io.h>
24 24
25#include "speedstep-lib.h" 25#include "speedstep-lib.h"
26 26
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index b3ab8ffebd27..89d85d244926 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -2611,19 +2611,19 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
2611 if (irq < 0) 2611 if (irq < 0)
2612 return irq; 2612 return irq;
2613 2613
2614 set_irq_msi(irq, desc);
2615 ret = msi_compose_msg(dev, irq, &msg); 2614 ret = msi_compose_msg(dev, irq, &msg);
2616 if (ret < 0) { 2615 if (ret < 0) {
2617 destroy_irq(irq); 2616 destroy_irq(irq);
2618 return ret; 2617 return ret;
2619 } 2618 }
2620 2619
2620 set_irq_msi(irq, desc);
2621 write_msi_msg(irq, &msg); 2621 write_msi_msg(irq, &msg);
2622 2622
2623 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, 2623 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq,
2624 "edge"); 2624 "edge");
2625 2625
2626 return irq; 2626 return 0;
2627} 2627}
2628 2628
2629void arch_teardown_msi_irq(unsigned int irq) 2629void arch_teardown_msi_irq(unsigned int irq)
diff --git a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
index 8053b17ab647..b62eafb997bc 100644
--- a/arch/i386/pci/fixup.c
+++ b/arch/i386/pci/fixup.c
@@ -354,7 +354,7 @@ static void __devinit pci_fixup_video(struct pci_dev *pdev)
354 printk(KERN_DEBUG "Boot video device is %s\n", pci_name(pdev)); 354 printk(KERN_DEBUG "Boot video device is %s\n", pci_name(pdev));
355 } 355 }
356} 356}
357DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video); 357DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);
358 358
359/* 359/*
360 * Some Toshiba laptops need extra code to enable their TI TSB43AB22/A. 360 * Some Toshiba laptops need extra code to enable their TI TSB43AB22/A.
diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c
index 43005f044424..bcd2f94b732c 100644
--- a/arch/i386/pci/i386.c
+++ b/arch/i386/pci/i386.c
@@ -246,8 +246,8 @@ int pcibios_enable_resources(struct pci_dev *dev, int mask)
246 continue; 246 continue;
247 if (!r->start && r->end) { 247 if (!r->start && r->end) {
248 printk(KERN_ERR "PCI: Device %s not available " 248 printk(KERN_ERR "PCI: Device %s not available "
249 "because of resource collisions\n", 249 "because of resource %d collisions\n",
250 pci_name(dev)); 250 pci_name(dev), idx);
251 return -EINVAL; 251 return -EINVAL;
252 } 252 }
253 if (r->flags & IORESOURCE_IO) 253 if (r->flags & IORESOURCE_IO)
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index e19185d26554..3b71f97d0b60 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -14,6 +14,7 @@ config IA64
14 select PCI if (!IA64_HP_SIM) 14 select PCI if (!IA64_HP_SIM)
15 select ACPI if (!IA64_HP_SIM) 15 select ACPI if (!IA64_HP_SIM)
16 select PM if (!IA64_HP_SIM) 16 select PM if (!IA64_HP_SIM)
17 select ARCH_SUPPORTS_MSI
17 default y 18 default y
18 help 19 help
19 The Itanium Processor Family is Intel's 64-bit successor to 20 The Itanium Processor Family is Intel's 64-bit successor to
diff --git a/arch/ia64/sn/kernel/huberror.c b/arch/ia64/sn/kernel/huberror.c
index fcf7f93c4b61..2c3f9dfca78b 100644
--- a/arch/ia64/sn/kernel/huberror.c
+++ b/arch/ia64/sn/kernel/huberror.c
@@ -8,7 +8,6 @@
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/pci.h>
12#include <asm/delay.h> 11#include <asm/delay.h>
13#include <asm/sn/sn_sal.h> 12#include <asm/sn/sn_sal.h>
14#include "ioerror.h" 13#include "ioerror.h"
diff --git a/arch/ia64/sn/kernel/msi_sn.c b/arch/ia64/sn/kernel/msi_sn.c
index 49873aa4a37d..83f190ffe350 100644
--- a/arch/ia64/sn/kernel/msi_sn.c
+++ b/arch/ia64/sn/kernel/msi_sn.c
@@ -87,7 +87,6 @@ int sn_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *entry)
87 if (irq < 0) 87 if (irq < 0)
88 return irq; 88 return irq;
89 89
90 set_irq_msi(irq, entry);
91 /* 90 /*
92 * Set up the vector plumbing. Let the prom (via sn_intr_alloc) 91 * Set up the vector plumbing. Let the prom (via sn_intr_alloc)
93 * decide which cpu to direct this msi at by default. 92 * decide which cpu to direct this msi at by default.
@@ -144,10 +143,11 @@ int sn_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *entry)
144 */ 143 */
145 msg.data = 0x100 + irq; 144 msg.data = 0x100 + irq;
146 145
146 set_irq_msi(irq, entry);
147 write_msi_msg(irq, &msg); 147 write_msi_msg(irq, &msg);
148 set_irq_chip_and_handler(irq, &sn_msi_chip, handle_edge_irq); 148 set_irq_chip_and_handler(irq, &sn_msi_chip, handle_edge_irq);
149 149
150 return irq; 150 return 0;
151} 151}
152 152
153#ifdef CONFIG_SMP 153#ifdef CONFIG_SMP
diff --git a/arch/ia64/sn/kernel/xpnet.c b/arch/ia64/sn/kernel/xpnet.c
index 5419acb89a8c..88fad85ceeff 100644
--- a/arch/ia64/sn/kernel/xpnet.c
+++ b/arch/ia64/sn/kernel/xpnet.c
@@ -24,7 +24,6 @@
24 24
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/pci.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/ioport.h> 28#include <linux/ioport.h>
30#include <linux/netdevice.h> 29#include <linux/netdevice.h>
diff --git a/arch/m68knommu/kernel/dma.c b/arch/m68knommu/kernel/dma.c
index 14b19c4161f4..0a25874a2aae 100644
--- a/arch/m68knommu/kernel/dma.c
+++ b/arch/m68knommu/kernel/dma.c
@@ -8,7 +8,6 @@
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/pci.h>
12#include <asm/io.h> 11#include <asm/io.h>
13 12
14void *dma_alloc_coherent(struct device *dev, size_t size, 13void *dma_alloc_coherent(struct device *dev, size_t size,
diff --git a/arch/mips/lib/iomap.c b/arch/mips/lib/iomap.c
index d51d5cb0a4a9..e3acb2dad33a 100644
--- a/arch/mips/lib/iomap.c
+++ b/arch/mips/lib/iomap.c
@@ -6,7 +6,6 @@
6 * (C) Copyright 2007 MIPS Technologies, Inc. 6 * (C) Copyright 2007 MIPS Technologies, Inc.
7 * written by Ralf Baechle <ralf@linux-mips.org> 7 * written by Ralf Baechle <ralf@linux-mips.org>
8 */ 8 */
9#include <linux/pci.h>
10#include <linux/module.h> 9#include <linux/module.h>
11#include <asm/io.h> 10#include <asm/io.h>
12 11
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 60d7d4baa227..7138092826aa 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -340,7 +340,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
340 struct pci_dev *dev; 340 struct pci_dev *dev;
341 const char *type; 341 const char *type;
342 342
343 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); 343 dev = alloc_pci_dev();
344 if (!dev) 344 if (!dev)
345 return NULL; 345 return NULL;
346 type = of_get_property(node, "device_type", NULL); 346 type = of_get_property(node, "device_type", NULL);
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 53aa04101ced..3a393c7f390e 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -31,7 +31,6 @@
31#include <linux/timex.h> 31#include <linux/timex.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/pci.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/irq.h> 35#include <linux/irq.h>
37#include <linux/random.h> 36#include <linux/random.h>
diff --git a/arch/ppc/8260_io/enet.c b/arch/ppc/8260_io/enet.c
index 48ce84f5be93..4c0a7d732f69 100644
--- a/arch/ppc/8260_io/enet.c
+++ b/arch/ppc/8260_io/enet.c
@@ -32,7 +32,6 @@
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/pci.h>
36#include <linux/init.h> 35#include <linux/init.h>
37#include <linux/delay.h> 36#include <linux/delay.h>
38#include <linux/netdevice.h> 37#include <linux/netdevice.h>
diff --git a/arch/ppc/8260_io/fcc_enet.c b/arch/ppc/8260_io/fcc_enet.c
index 9db825fe37f0..cab395da25da 100644
--- a/arch/ppc/8260_io/fcc_enet.c
+++ b/arch/ppc/8260_io/fcc_enet.c
@@ -29,7 +29,6 @@
29#include <linux/ioport.h> 29#include <linux/ioport.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/pci.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/delay.h> 33#include <linux/delay.h>
35#include <linux/netdevice.h> 34#include <linux/netdevice.h>
diff --git a/arch/ppc/8xx_io/enet.c b/arch/ppc/8xx_io/enet.c
index bfa3f52996d1..e58288e14369 100644
--- a/arch/ppc/8xx_io/enet.c
+++ b/arch/ppc/8xx_io/enet.c
@@ -30,7 +30,6 @@
30#include <linux/ioport.h> 30#include <linux/ioport.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/pci.h>
34#include <linux/init.h> 33#include <linux/init.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/netdevice.h> 35#include <linux/netdevice.h>
diff --git a/arch/ppc/syslib/ppc4xx_sgdma.c b/arch/ppc/syslib/ppc4xx_sgdma.c
index 939abe3c1f45..5dadca3e0d61 100644
--- a/arch/ppc/syslib/ppc4xx_sgdma.c
+++ b/arch/ppc/syslib/ppc4xx_sgdma.c
@@ -23,7 +23,6 @@
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/pci.h>
27 26
28#include <asm/system.h> 27#include <asm/system.h>
29#include <asm/io.h> 28#include <asm/io.h>
diff --git a/arch/sh64/mach-cayman/iomap.c b/arch/sh64/mach-cayman/iomap.c
index 2d06e9a55137..a5c645f02d57 100644
--- a/arch/sh64/mach-cayman/iomap.c
+++ b/arch/sh64/mach-cayman/iomap.c
@@ -9,7 +9,6 @@
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details. 10 * for more details.
11 */ 11 */
12#include <linux/pci.h>
13#include <asm/io.h> 12#include <asm/io.h>
14#include <asm/cayman.h> 13#include <asm/cayman.h>
15 14
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index 590a41b864b9..be9e10b94ef8 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -306,6 +306,7 @@ config SUN_IO
306 306
307config PCI 307config PCI
308 bool "PCI support" 308 bool "PCI support"
309 select ARCH_SUPPORTS_MSI
309 help 310 help
310 Find out whether you have a PCI motherboard. PCI is the name of a 311 Find out whether you have a PCI motherboard. PCI is the name of a
311 bus system, i.e. the way the CPU talks to the other stuff inside 312 bus system, i.e. the way the CPU talks to the other stuff inside
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index 023af41ad68d..9a549547cb2b 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -1092,10 +1092,10 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1092 return -EINVAL; 1092 return -EINVAL;
1093 1093
1094 err = p->setup_msi_irq(&virt_irq, pdev, desc); 1094 err = p->setup_msi_irq(&virt_irq, pdev, desc);
1095 if (err < 0) 1095 if (err)
1096 return err; 1096 return err;
1097 1097
1098 return virt_irq; 1098 return 0;
1099} 1099}
1100 1100
1101void arch_teardown_msi_irq(unsigned int virt_irq) 1101void arch_teardown_msi_irq(unsigned int virt_irq)
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 94295c219329..1ccf4c9a9a43 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -1169,8 +1169,6 @@ static int pci_sun4v_setup_msi_irq(unsigned int *virt_irq_p,
1169 if (!devino) 1169 if (!devino)
1170 goto out_err; 1170 goto out_err;
1171 1171
1172 set_irq_msi(*virt_irq_p, entry);
1173
1174 msiqid = ((devino - pbm->msiq_first_devino) + 1172 msiqid = ((devino - pbm->msiq_first_devino) +
1175 pbm->msiq_first); 1173 pbm->msiq_first);
1176 1174
@@ -1204,6 +1202,8 @@ static int pci_sun4v_setup_msi_irq(unsigned int *virt_irq_p,
1204 msg.address_lo = pbm->msi32_start; 1202 msg.address_lo = pbm->msi32_start;
1205 } 1203 }
1206 msg.data = msi_num; 1204 msg.data = msi_num;
1205
1206 set_irq_msi(*virt_irq_p, entry);
1207 write_msi_msg(*virt_irq_p, &msg); 1207 write_msi_msg(*virt_irq_p, &msg);
1208 1208
1209 irq_install_pre_handler(*virt_irq_p, 1209 irq_install_pre_handler(*virt_irq_p,
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 56eb14c98475..e9b4f058a49a 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -676,6 +676,7 @@ menu "Bus options (PCI etc.)"
676 676
677config PCI 677config PCI
678 bool "PCI support" 678 bool "PCI support"
679 select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC)
679 680
680# x86-64 doesn't support PCI BIOS access from long mode so always go direct. 681# x86-64 doesn't support PCI BIOS access from long mode so always go direct.
681config PCI_DIRECT 682config PCI_DIRECT
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index c6a5bc7e8118..b7d2b76b92d4 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -1983,18 +1983,18 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
1983 if (irq < 0) 1983 if (irq < 0)
1984 return irq; 1984 return irq;
1985 1985
1986 set_irq_msi(irq, desc);
1987 ret = msi_compose_msg(dev, irq, &msg); 1986 ret = msi_compose_msg(dev, irq, &msg);
1988 if (ret < 0) { 1987 if (ret < 0) {
1989 destroy_irq(irq); 1988 destroy_irq(irq);
1990 return ret; 1989 return ret;
1991 } 1990 }
1992 1991
1992 set_irq_msi(irq, desc);
1993 write_msi_msg(irq, &msg); 1993 write_msi_msg(irq, &msg);
1994 1994
1995 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); 1995 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge");
1996 1996
1997 return irq; 1997 return 0;
1998} 1998}
1999 1999
2000void arch_teardown_msi_irq(unsigned int irq) 2000void arch_teardown_msi_irq(unsigned int irq)
diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
index 0b4cb93db5a3..cd7e6a020602 100644
--- a/arch/xtensa/kernel/xtensa_ksyms.c
+++ b/arch/xtensa/kernel/xtensa_ksyms.c
@@ -18,7 +18,6 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <asm/irq.h> 19#include <asm/irq.h>
20#include <linux/in6.h> 20#include <linux/in6.h>
21#include <linux/pci.h>
22#include <linux/ide.h> 21#include <linux/ide.h>
23 22
24#include <asm/uaccess.h> 23#include <asm/uaccess.h>
diff --git a/arch/xtensa/platform-iss/setup.c b/arch/xtensa/platform-iss/setup.c
index c8a42b60c57a..f60c8cf6dfbe 100644
--- a/arch/xtensa/platform-iss/setup.c
+++ b/arch/xtensa/platform-iss/setup.c
@@ -20,7 +20,6 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/reboot.h> 22#include <linux/reboot.h>
23#include <linux/pci.h>
24#include <linux/kdev_t.h> 23#include <linux/kdev_t.h>
25#include <linux/types.h> 24#include <linux/types.h>
26#include <linux/major.h> 25#include <linux/major.h>
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 8d60c4eb54fe..2ebd07f2ef81 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -6,7 +6,6 @@
6#include <linux/version.h> 6#include <linux/version.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/skbuff.h> 8#include <linux/skbuff.h>
9#include <linux/pci.h>
10#include <linux/errno.h> 9#include <linux/errno.h>
11#include <linux/types.h> 10#include <linux/types.h>
12#include <linux/string.h> 11#include <linux/string.h>
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 18dba8e78da7..92428e55b0c2 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -226,12 +226,10 @@ static int device_probe_drivers(void *data)
226 * 226 *
227 * Walk the list of drivers that the bus has and call 227 * Walk the list of drivers that the bus has and call
228 * driver_probe_device() for each pair. If a compatible 228 * driver_probe_device() for each pair. If a compatible
229 * pair is found, break out and return. If the bus specifies 229 * pair is found, break out and return.
230 * multithreaded probing, walking the list of drivers is done
231 * on a probing thread.
232 * 230 *
233 * Returns 1 if the device was bound to a driver; 231 * Returns 1 if the device was bound to a driver;
234 * 0 if no matching device was found or multithreaded probing is done; 232 * 0 if no matching device was found;
235 * -ENODEV if the device is not registered. 233 * -ENODEV if the device is not registered.
236 * 234 *
237 * When called for a USB interface, @dev->parent->sem must be held. 235 * When called for a USB interface, @dev->parent->sem must be held.
@@ -239,7 +237,6 @@ static int device_probe_drivers(void *data)
239int device_attach(struct device * dev) 237int device_attach(struct device * dev)
240{ 238{
241 int ret = 0; 239 int ret = 0;
242 struct task_struct *probe_task = ERR_PTR(-ENOMEM);
243 240
244 down(&dev->sem); 241 down(&dev->sem);
245 if (dev->driver) { 242 if (dev->driver) {
@@ -251,12 +248,7 @@ int device_attach(struct device * dev)
251 ret = 0; 248 ret = 0;
252 } 249 }
253 } else { 250 } else {
254 if (dev->bus->multithread_probe) 251 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
255 probe_task = kthread_run(device_probe_drivers, dev,
256 "probe-%s", dev->bus_id);
257 if(IS_ERR(probe_task))
258 ret = bus_for_each_drv(dev->bus, NULL, dev,
259 __device_attach);
260 } 252 }
261 up(&dev->sem); 253 up(&dev->sem);
262 return ret; 254 return ret;
@@ -383,33 +375,6 @@ void driver_detach(struct device_driver * drv)
383 } 375 }
384} 376}
385 377
386#ifdef CONFIG_PCI_MULTITHREAD_PROBE
387static int __init wait_for_probes(void)
388{
389 DEFINE_WAIT(wait);
390
391 printk(KERN_INFO "%s: waiting for %d threads\n", __FUNCTION__,
392 atomic_read(&probe_count));
393 if (!atomic_read(&probe_count))
394 return 0;
395 while (atomic_read(&probe_count)) {
396 prepare_to_wait(&probe_waitqueue, &wait, TASK_UNINTERRUPTIBLE);
397 if (atomic_read(&probe_count))
398 schedule();
399 }
400 finish_wait(&probe_waitqueue, &wait);
401 return 0;
402}
403
404core_initcall_sync(wait_for_probes);
405postcore_initcall_sync(wait_for_probes);
406arch_initcall_sync(wait_for_probes);
407subsys_initcall_sync(wait_for_probes);
408fs_initcall_sync(wait_for_probes);
409device_initcall_sync(wait_for_probes);
410late_initcall_sync(wait_for_probes);
411#endif
412
413EXPORT_SYMBOL_GPL(device_bind_driver); 378EXPORT_SYMBOL_GPL(device_bind_driver);
414EXPORT_SYMBOL_GPL(device_release_driver); 379EXPORT_SYMBOL_GPL(device_release_driver);
415EXPORT_SYMBOL_GPL(device_attach); 380EXPORT_SYMBOL_GPL(device_attach);
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index b0acf41c0db9..aa8f3a39a704 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -173,7 +173,7 @@ alpha_core_agp_setup(void)
173 /* 173 /*
174 * Build a fake pci_dev struct 174 * Build a fake pci_dev struct
175 */ 175 */
176 pdev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); 176 pdev = alloc_pci_dev();
177 if (!pdev) 177 if (!pdev)
178 return -ENOMEM; 178 return -ENOMEM;
179 pdev->vendor = 0xffff; 179 pdev->vendor = 0xffff;
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 3d83b461ccad..f4562cc22343 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -329,7 +329,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
329 struct agp_bridge_data *bridge; 329 struct agp_bridge_data *bridge;
330 int error = 0; 330 int error = 0;
331 331
332 fake_bridge_dev = kmalloc(sizeof (struct pci_dev), GFP_KERNEL); 332 fake_bridge_dev = alloc_pci_dev();
333 if (!fake_bridge_dev) { 333 if (!fake_bridge_dev) {
334 error = -ENOMEM; 334 error = -ENOMEM;
335 goto fail; 335 goto fail;
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index 9ebf84d18655..ec435cb25c4f 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -26,7 +26,6 @@
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/pci.h>
30#include <linux/hw_random.h> 29#include <linux/hw_random.h>
31#include <asm/io.h> 30#include <asm/io.h>
32#include <asm/msr.h> 31#include <asm/msr.h>
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 157b1d09ab55..13808f6083a0 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -42,7 +42,6 @@
42#include <linux/timer.h> 42#include <linux/timer.h>
43#include <linux/time.h> 43#include <linux/time.h>
44#include <linux/interrupt.h> 44#include <linux/interrupt.h>
45#include <linux/pci.h>
46#include <linux/tty.h> 45#include <linux/tty.h>
47#include <linux/tty_flip.h> 46#include <linux/tty_flip.h>
48#include <linux/serial.h> 47#include <linux/serial.h>
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index bb9a43c6cf3d..9f273f032b0f 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -19,7 +19,6 @@
19 * 19 *
20 */ 20 */
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/pci.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
24#include <linux/fs.h> 23#include <linux/fs.h>
25#include <linux/sched.h> 24#include <linux/sched.h>
diff --git a/drivers/char/watchdog/sc1200wdt.c b/drivers/char/watchdog/sc1200wdt.c
index 1e4a8d751a71..2f7ba7a514fe 100644
--- a/drivers/char/watchdog/sc1200wdt.c
+++ b/drivers/char/watchdog/sc1200wdt.c
@@ -38,7 +38,6 @@
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/pnp.h> 39#include <linux/pnp.h>
40#include <linux/fs.h> 40#include <linux/fs.h>
41#include <linux/pci.h>
42 41
43#include <asm/semaphore.h> 42#include <asm/semaphore.h>
44#include <asm/io.h> 43#include <asm/io.h>
diff --git a/drivers/char/watchdog/scx200_wdt.c b/drivers/char/watchdog/scx200_wdt.c
index fc0e0347f9d2..d4fd0fa2f176 100644
--- a/drivers/char/watchdog/scx200_wdt.c
+++ b/drivers/char/watchdog/scx200_wdt.c
@@ -25,7 +25,7 @@
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include <linux/reboot.h> 26#include <linux/reboot.h>
27#include <linux/fs.h> 27#include <linux/fs.h>
28#include <linux/pci.h> 28#include <linux/ioport.h>
29#include <linux/scx200.h> 29#include <linux/scx200.h>
30 30
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 67f91bdda089..f35156c58922 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -17,7 +17,6 @@
17#include <linux/version.h> 17#include <linux/version.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/pci.h>
21#include <linux/types.h> 20#include <linux/types.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/i2c.h> 22#include <linux/i2c.h>
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index ee65aa1be13a..c6b6898592b1 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,6 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/pci.h>
21#include <linux/platform_device.h> 20#include <linux/platform_device.h>
22 21
23#include <asm/io.h> 22#include <asm/io.h>
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index 5f94e617fe0c..5161aaf9341b 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -25,7 +25,6 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/pci.h>
29#include <linux/wait.h> 28#include <linux/wait.h>
30 29
31#include <linux/isa.h> 30#include <linux/isa.h>
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index 6164a9a83396..bd0755c789c5 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -15,7 +15,6 @@
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/pci.h>
19#include <linux/timer.h> 18#include <linux/timer.h>
20#include <linux/jiffies.h> 19#include <linux/jiffies.h>
21#include <linux/mutex.h> 20#include <linux/mutex.h>
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 842cd0b53e91..eff591deeb46 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -40,7 +40,6 @@
40#include <linux/err.h> 40#include <linux/err.h>
41#include <linux/idr.h> 41#include <linux/idr.h>
42#include <linux/interrupt.h> 42#include <linux/interrupt.h>
43#include <linux/pci.h>
44#include <linux/random.h> 43#include <linux/random.h>
45#include <linux/rbtree.h> 44#include <linux/rbtree.h>
46#include <linux/spinlock.h> 45#include <linux/spinlock.h>
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 891d1fa7b2eb..223b1aa7d92b 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -39,7 +39,6 @@
39#include <linux/err.h> 39#include <linux/err.h>
40#include <linux/idr.h> 40#include <linux/idr.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/pci.h>
43#include <linux/rbtree.h> 42#include <linux/rbtree.h>
44#include <linux/spinlock.h> 43#include <linux/spinlock.h>
45#include <linux/workqueue.h> 44#include <linux/workqueue.h>
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index de89717f49fe..9be5cc00a3a9 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -39,7 +39,6 @@
39 39
40#include <linux/completion.h> 40#include <linux/completion.h>
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/pci.h>
43#include <linux/workqueue.h> 42#include <linux/workqueue.h>
44#include <rdma/ib_mad.h> 43#include <rdma/ib_mad.h>
45#include <rdma/ib_smi.h> 44#include <rdma/ib_smi.h>
diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c
index 4a579b3a1c90..1e13ab42b70b 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -34,7 +34,6 @@
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/pci.h>
38#include <linux/bitops.h> 37#include <linux/bitops.h>
39#include <linux/random.h> 38#include <linux/random.h>
40 39
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 9a7eaadb1688..6469406ea9d8 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -40,7 +40,6 @@
40#include <linux/random.h> 40#include <linux/random.h>
41#include <linux/spinlock.h> 41#include <linux/spinlock.h>
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/pci.h>
44#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
45#include <linux/kref.h> 44#include <linux/kref.h>
46#include <linux/idr.h> 45#include <linux/idr.h>
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 8199b83052a9..d97ded25c4ff 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -40,7 +40,6 @@
40#include <linux/err.h> 40#include <linux/err.h>
41#include <linux/fs.h> 41#include <linux/fs.h>
42#include <linux/cdev.h> 42#include <linux/cdev.h>
43#include <linux/pci.h>
44#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
45#include <linux/poll.h> 44#include <linux/poll.h>
46#include <linux/rwsem.h> 45#include <linux/rwsem.h>
diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c
index ed55979bfd34..036ed1ef1796 100644
--- a/drivers/infiniband/hw/ipath/ipath_fs.c
+++ b/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -38,7 +38,6 @@
38#include <linux/pagemap.h> 38#include <linux/pagemap.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/namei.h> 40#include <linux/namei.h>
41#include <linux/pci.h>
42 41
43#include "ipath_kernel.h" 42#include "ipath_kernel.h"
44 43
diff --git a/drivers/infiniband/hw/ipath/ipath_layer.c b/drivers/infiniband/hw/ipath/ipath_layer.c
index e46aa4ed2a7e..05a1d2b01d9d 100644
--- a/drivers/infiniband/hw/ipath/ipath_layer.c
+++ b/drivers/infiniband/hw/ipath/ipath_layer.c
@@ -37,7 +37,6 @@
37 */ 37 */
38 38
39#include <linux/io.h> 39#include <linux/io.h>
40#include <linux/pci.h>
41#include <asm/byteorder.h> 40#include <asm/byteorder.h>
42 41
43#include "ipath_kernel.h" 42#include "ipath_kernel.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_stats.c b/drivers/infiniband/hw/ipath/ipath_stats.c
index 9307f7187ca5..d8b5e4cefe25 100644
--- a/drivers/infiniband/hw/ipath/ipath_stats.c
+++ b/drivers/infiniband/hw/ipath/ipath_stats.c
@@ -31,8 +31,6 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33 33
34#include <linux/pci.h>
35
36#include "ipath_kernel.h" 34#include "ipath_kernel.h"
37 35
38struct infinipath_stats ipath_stats; 36struct infinipath_stats ipath_stats;
diff --git a/drivers/infiniband/hw/ipath/ipath_sysfs.c b/drivers/infiniband/hw/ipath/ipath_sysfs.c
index ffa6318ad0cc..4dc398d5e011 100644
--- a/drivers/infiniband/hw/ipath/ipath_sysfs.c
+++ b/drivers/infiniband/hw/ipath/ipath_sysfs.c
@@ -32,7 +32,6 @@
32 */ 32 */
33 33
34#include <linux/ctype.h> 34#include <linux/ctype.h>
35#include <linux/pci.h>
36 35
37#include "ipath_kernel.h" 36#include "ipath_kernel.h"
38#include "ipath_common.h" 37#include "ipath_common.h"
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.h b/drivers/infiniband/hw/mthca/mthca_memfree.h
index 594144145f45..a1ab06847b75 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.h
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.h
@@ -38,7 +38,6 @@
38#define MTHCA_MEMFREE_H 38#define MTHCA_MEMFREE_H
39 39
40#include <linux/list.h> 40#include <linux/list.h>
41#include <linux/pci.h>
42#include <linux/mutex.h> 41#include <linux/mutex.h>
43 42
44#define MTHCA_ICM_CHUNK_LEN \ 43#define MTHCA_ICM_CHUNK_LEN \
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index fd558267d1cb..d8f6bb4f53fc 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -41,7 +41,6 @@
41#include <linux/skbuff.h> 41#include <linux/skbuff.h>
42#include <linux/netdevice.h> 42#include <linux/netdevice.h>
43#include <linux/workqueue.h> 43#include <linux/workqueue.h>
44#include <linux/pci.h>
45#include <linux/kref.h> 44#include <linux/kref.h>
46#include <linux/if_infiniband.h> 45#include <linux/if_infiniband.h>
47#include <linux/mutex.h> 46#include <linux/mutex.h>
diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
index 38f648f9b0ed..02c6fbaeccf8 100644
--- a/drivers/isdn/hisax/netjet.c
+++ b/drivers/isdn/hisax/netjet.c
@@ -19,7 +19,6 @@
19#include "isac.h" 19#include "isac.h"
20#include "hscx.h" 20#include "hscx.h"
21#include "isdnl1.h" 21#include "isdnl1.h"
22#include <linux/pci.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/ppp_defs.h> 23#include <linux/ppp_defs.h>
25#include <asm/io.h> 24#include <asm/io.h>
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index f7e83a86f444..4c7dedac0e51 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -13,7 +13,6 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/poll.h> 14#include <linux/poll.h>
15#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
16#include <linux/pci.h>
17#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
18 17
19#include "hysdn_defs.h" 18#include "hysdn_defs.h"
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index a6cbbdd262d6..34d7abc900d7 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -26,11 +26,11 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/pci.h>
30#include <linux/input.h> 29#include <linux/input.h>
31#include <linux/dvb/frontend.h> 30#include <linux/dvb/frontend.h>
32#include <linux/mutex.h> 31#include <linux/mutex.h>
33#include <linux/mm.h> 32#include <linux/mm.h>
33#include <asm/io.h>
34 34
35#include "dmxdev.h" 35#include "dmxdev.h"
36#include "dvb_demux.h" 36#include "dvb_demux.h"
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 2aa9ce920607..823cd6cc471e 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -37,7 +37,6 @@
37#include <linux/major.h> 37#include <linux/major.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/pci.h>
41#include <linux/signal.h> 40#include <linux/signal.h>
42#include <asm/io.h> 41#include <asm/io.h>
43#include <asm/pgtable.h> 42#include <asm/pgtable.h>
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index a3246a283aa4..05c7820fe53e 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -33,7 +33,6 @@
33#include <linux/major.h> 33#include <linux/major.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/pci.h>
37#include <linux/signal.h> 36#include <linux/signal.h>
38#include <asm/io.h> 37#include <asm/io.h>
39#include <asm/pgtable.h> 38#include <asm/pgtable.h>
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 68673863d5c9..59a43603b5cb 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -37,7 +37,6 @@
37#include <linux/major.h> 37#include <linux/major.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/pci.h>
41#include <linux/signal.h> 40#include <linux/signal.h>
42#include <asm/io.h> 41#include <asm/io.h>
43#include <asm/pgtable.h> 42#include <asm/pgtable.h>
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 42e2299dcb22..853b1a3d6a1d 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -37,7 +37,6 @@
37#include <linux/major.h> 37#include <linux/major.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/pci.h>
41#include <linux/signal.h> 40#include <linux/signal.h>
42#include <asm/io.h> 41#include <asm/io.h>
43#include <asm/pgtable.h> 42#include <asm/pgtable.h>
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c
index 772fd52d551a..2e4cf1efdd21 100644
--- a/drivers/media/video/bt866.c
+++ b/drivers/media/video/bt866.c
@@ -37,7 +37,6 @@
37#include <linux/major.h> 37#include <linux/major.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/pci.h>
41#include <linux/signal.h> 40#include <linux/signal.h>
42#include <asm/io.h> 41#include <asm/io.h>
43#include <asm/pgtable.h> 42#include <asm/pgtable.h>
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 97ef421dd093..e627062fde3a 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -43,7 +43,6 @@
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/mm.h> 44#include <linux/mm.h>
45#include <linux/poll.h> 45#include <linux/poll.h>
46#include <linux/pci.h>
47#include <linux/signal.h> 46#include <linux/signal.h>
48#include <linux/ioport.h> 47#include <linux/ioport.h>
49#include <linux/types.h> 48#include <linux/types.h>
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index ed882ebc7b95..418ea8b7f85a 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -23,7 +23,6 @@
23 23
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/pci.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
28#include <linux/i2c.h> 27#include <linux/i2c.h>
29#include <linux/usb.h> 28#include <linux/usb.h>
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index 44dc7479119c..74839f98b7c4 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -36,7 +36,6 @@
36#include <linux/major.h> 36#include <linux/major.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/pci.h>
40#include <linux/signal.h> 39#include <linux/signal.h>
41#include <asm/io.h> 40#include <asm/io.h>
42#include <asm/pgtable.h> 41#include <asm/pgtable.h>
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index 2ce3321ab995..87c3144ec7fc 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -39,7 +39,6 @@
39#include <linux/slab.h> 39#include <linux/slab.h>
40 40
41#include <linux/mm.h> 41#include <linux/mm.h>
42#include <linux/pci.h>
43#include <linux/signal.h> 42#include <linux/signal.h>
44#include <asm/io.h> 43#include <asm/io.h>
45#include <asm/pgtable.h> 44#include <asm/pgtable.h>
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c
index 269d7114a93a..80bf91187856 100644
--- a/drivers/media/video/saa711x.c
+++ b/drivers/media/video/saa711x.c
@@ -30,7 +30,6 @@
30#include <linux/major.h> 30#include <linux/major.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/mm.h> 32#include <linux/mm.h>
33#include <linux/pci.h>
34#include <linux/signal.h> 33#include <linux/signal.h>
35#include <asm/io.h> 34#include <asm/io.h>
36#include <asm/pgtable.h> 35#include <asm/pgtable.h>
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index e0fdb1ab7580..339592e7722d 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -33,7 +33,6 @@
33#include <linux/major.h> 33#include <linux/major.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/pci.h>
37#include <linux/signal.h> 36#include <linux/signal.h>
38#include <asm/io.h> 37#include <asm/io.h>
39#include <asm/pgtable.h> 38#include <asm/pgtable.h>
diff --git a/drivers/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c
index ca86f113f36a..276ba3c5143f 100644
--- a/drivers/misc/hdpuftrs/hdpu_cpustate.c
+++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c
@@ -18,7 +18,6 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/pci.h>
22#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
23#include <linux/platform_device.h> 22#include <linux/platform_device.h>
24#include <asm/uaccess.h> 23#include <asm/uaccess.h>
diff --git a/drivers/misc/hdpuftrs/hdpu_nexus.c b/drivers/misc/hdpuftrs/hdpu_nexus.c
index 6a51e99a8079..60c8b26f0678 100644
--- a/drivers/misc/hdpuftrs/hdpu_nexus.c
+++ b/drivers/misc/hdpuftrs/hdpu_nexus.c
@@ -18,7 +18,6 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/hdpu_features.h> 20#include <linux/hdpu_features.h>
21#include <linux/pci.h>
22 21
23#include <linux/platform_device.h> 22#include <linux/platform_device.h>
24 23
diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
index 8a0c4dec6351..c73e96bfafc6 100644
--- a/drivers/mtd/devices/doc2000.c
+++ b/drivers/mtd/devices/doc2000.c
@@ -13,7 +13,6 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <linux/miscdevice.h> 15#include <linux/miscdevice.h>
16#include <linux/pci.h>
17#include <linux/delay.h> 16#include <linux/delay.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19#include <linux/sched.h> 18#include <linux/sched.h>
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
index 6f368aec5d5d..6413efc045e0 100644
--- a/drivers/mtd/devices/doc2001.c
+++ b/drivers/mtd/devices/doc2001.c
@@ -13,7 +13,6 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <linux/miscdevice.h> 15#include <linux/miscdevice.h>
16#include <linux/pci.h>
17#include <linux/delay.h> 16#include <linux/delay.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19#include <linux/init.h> 18#include <linux/init.h>
diff --git a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c
index 88ba82df0fbb..2b30b587c6e8 100644
--- a/drivers/mtd/devices/doc2001plus.c
+++ b/drivers/mtd/devices/doc2001plus.c
@@ -17,7 +17,6 @@
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
20#include <linux/pci.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23#include <linux/init.h> 22#include <linux/init.h>
diff --git a/drivers/mtd/devices/docecc.c b/drivers/mtd/devices/docecc.c
index 52b5d638077f..fd8a8daba3a8 100644
--- a/drivers/mtd/devices/docecc.c
+++ b/drivers/mtd/devices/docecc.c
@@ -29,7 +29,6 @@
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/uaccess.h> 30#include <asm/uaccess.h>
31#include <linux/miscdevice.h> 31#include <linux/miscdevice.h>
32#include <linux/pci.h>
33#include <linux/delay.h> 32#include <linux/delay.h>
34#include <linux/slab.h> 33#include <linux/slab.h>
35#include <linux/init.h> 34#include <linux/init.h>
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index acf3ba223298..ecac0e438f49 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -31,7 +31,6 @@
31#include <asm/io.h> 31#include <asm/io.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include <linux/miscdevice.h> 33#include <linux/miscdevice.h>
34#include <linux/pci.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
37#include <linux/init.h> 36#include <linux/init.h>
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c
index 8296305c8297..89deff007116 100644
--- a/drivers/mtd/nand/cs553x_nand.c
+++ b/drivers/mtd/nand/cs553x_nand.c
@@ -20,7 +20,6 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/pci.h>
24#include <linux/mtd/mtd.h> 23#include <linux/mtd/mtd.h>
25#include <linux/mtd/nand.h> 24#include <linux/mtd/nand.h>
26#include <linux/mtd/nand_ecc.h> 25#include <linux/mtd/nand_ecc.h>
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
index e6ef7d7f9f14..0c9ce19ea27a 100644
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -17,7 +17,6 @@
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
20#include <linux/pci.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23#include <linux/init.h> 22#include <linux/init.h>
diff --git a/drivers/net/atl1/atl1_param.c b/drivers/net/atl1/atl1_param.c
index c407214339f6..bcd0bd891722 100644
--- a/drivers/net/atl1/atl1_param.c
+++ b/drivers/net/atl1/atl1_param.c
@@ -22,7 +22,6 @@
22 */ 22 */
23 23
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/pci.h>
26#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
27#include "atl1.h" 26#include "atl1.h"
28 27
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index d10fb80e9a63..c39ab803c5d8 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -45,7 +45,6 @@
45#include <linux/bitops.h> 45#include <linux/bitops.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/interrupt.h> 47#include <linux/interrupt.h>
48#include <linux/pci.h>
49#include <linux/init.h> 48#include <linux/init.h>
50#include <linux/netdevice.h> 49#include <linux/netdevice.h>
51#include <linux/etherdevice.h> 50#include <linux/etherdevice.h>
diff --git a/drivers/net/fec_8xx/fec_main.c b/drivers/net/fec_8xx/fec_main.c
index e824d5d231af..88efe9731bab 100644
--- a/drivers/net/fec_8xx/fec_main.c
+++ b/drivers/net/fec_8xx/fec_main.c
@@ -19,7 +19,6 @@
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/pci.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25#include <linux/netdevice.h> 24#include <linux/netdevice.h>
diff --git a/drivers/net/fec_8xx/fec_mii.c b/drivers/net/fec_8xx/fec_mii.c
index e79700abf7b6..b3fa0d6a159c 100644
--- a/drivers/net/fec_8xx/fec_mii.c
+++ b/drivers/net/fec_8xx/fec_mii.c
@@ -19,7 +19,6 @@
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/pci.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25#include <linux/netdevice.h> 24#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index e2ddd617493a..a4a2a0ea43d3 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -24,7 +24,6 @@
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/pci.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/netdevice.h> 29#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index 8545e84fc9a0..5603121132cd 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -21,7 +21,6 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/pci.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/netdevice.h> 26#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index cdcfb96f360f..04b4f80a1cde 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -21,7 +21,6 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/pci.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/netdevice.h> 26#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index 65925b5a224f..d0f28981b55a 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -21,7 +21,6 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/pci.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/netdevice.h> 26#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c
index f91447837fd4..d3840108ffbd 100644
--- a/drivers/net/fs_enet/mii-bitbang.c
+++ b/drivers/net/fs_enet/mii-bitbang.c
@@ -22,7 +22,6 @@
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/pci.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
28#include <linux/netdevice.h> 27#include <linux/netdevice.h>
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c
index 235b177fb9ac..0a563a83016f 100644
--- a/drivers/net/fs_enet/mii-fec.c
+++ b/drivers/net/fs_enet/mii-fec.c
@@ -21,7 +21,6 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/pci.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/netdevice.h> 26#include <linux/netdevice.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index 3d82d46f4998..50035ebd4f52 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -27,7 +27,6 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/pci.h>
31#include <linux/netdevice.h> 30#include <linux/netdevice.h>
32#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
33#include <linux/skbuff.h> 32#include <linux/skbuff.h>
diff --git a/drivers/net/ixgb/ixgb_osdep.h b/drivers/net/ixgb/ixgb_osdep.h
index 8434d752fd81..9e04a6b3ae0d 100644
--- a/drivers/net/ixgb/ixgb_osdep.h
+++ b/drivers/net/ixgb/ixgb_osdep.h
@@ -34,7 +34,6 @@
34#define _IXGB_OSDEP_H_ 34#define _IXGB_OSDEP_H_
35 35
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/pci.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <asm/io.h> 38#include <asm/io.h>
40#include <linux/interrupt.h> 39#include <linux/interrupt.h>
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index 0edcd125fd61..6b49fc4bd1a1 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -81,7 +81,6 @@
81#include <linux/etherdevice.h> 81#include <linux/etherdevice.h>
82#include <linux/skbuff.h> 82#include <linux/skbuff.h>
83#include <linux/init.h> 83#include <linux/init.h>
84#include <linux/pci.h>
85#include <linux/types.h> 84#include <linux/types.h>
86#include <linux/bitops.h> 85#include <linux/bitops.h>
87 86
diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index ed274d6909d0..f8f4d74f01f1 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -23,7 +23,6 @@ static const char version[] = "madgemc.c: v0.91 23/01/2000 by Adam Fritzler\n";
23#include <linux/mca.h> 23#include <linux/mca.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/pci.h>
27#include <linux/init.h> 26#include <linux/init.h>
28#include <linux/netdevice.h> 27#include <linux/netdevice.h>
29#include <linux/trdevice.h> 28#include <linux/trdevice.h>
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index 9bbea5c8acf4..58d7e5d452fa 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -41,7 +41,6 @@
41#include <linux/time.h> 41#include <linux/time.h>
42#include <linux/errno.h> 42#include <linux/errno.h>
43#include <linux/init.h> 43#include <linux/init.h>
44#include <linux/pci.h>
45#include <linux/mca-legacy.h> 44#include <linux/mca-legacy.h>
46#include <linux/delay.h> 45#include <linux/delay.h>
47#include <linux/netdevice.h> 46#include <linux/netdevice.h>
diff --git a/drivers/net/tulip/21142.c b/drivers/net/tulip/21142.c
index 942b839ccc5b..6c400ccd38b4 100644
--- a/drivers/net/tulip/21142.c
+++ b/drivers/net/tulip/21142.c
@@ -14,7 +14,6 @@
14 14
15*/ 15*/
16 16
17#include <linux/pci.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include "tulip.h" 18#include "tulip.h"
20 19
diff --git a/drivers/net/tulip/pnic.c b/drivers/net/tulip/pnic.c
index 85a521e0d052..be82a2effee3 100644
--- a/drivers/net/tulip/pnic.c
+++ b/drivers/net/tulip/pnic.c
@@ -15,7 +15,6 @@
15*/ 15*/
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/pci.h>
19#include <linux/jiffies.h> 18#include <linux/jiffies.h>
20#include "tulip.h" 19#include "tulip.h"
21 20
diff --git a/drivers/net/tulip/pnic2.c b/drivers/net/tulip/pnic2.c
index c31be0e377a8..4e4a879c3fa5 100644
--- a/drivers/net/tulip/pnic2.c
+++ b/drivers/net/tulip/pnic2.c
@@ -76,7 +76,6 @@
76 76
77 77
78 78
79#include <linux/pci.h>
80#include "tulip.h" 79#include "tulip.h"
81#include <linux/delay.h> 80#include <linux/delay.h>
82 81
diff --git a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c
index df326fe1cc8f..d2c1f42109b0 100644
--- a/drivers/net/tulip/timer.c
+++ b/drivers/net/tulip/timer.c
@@ -14,7 +14,6 @@
14 14
15*/ 15*/
16 16
17#include <linux/pci.h>
18#include "tulip.h" 17#include "tulip.h"
19 18
20 19
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
index c840d2e67b23..16f26a8364f0 100644
--- a/drivers/net/tulip/tulip.h
+++ b/drivers/net/tulip/tulip.h
@@ -22,6 +22,7 @@
22#include <linux/netdevice.h> 22#include <linux/netdevice.h>
23#include <linux/timer.h> 23#include <linux/timer.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/pci.h>
25#include <asm/io.h> 26#include <asm/io.h>
26#include <asm/irq.h> 27#include <asm/irq.h>
27 28
diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
index ae01555d24cf..574737b55f39 100644
--- a/drivers/net/wan/lmc/lmc_media.c
+++ b/drivers/net/wan/lmc/lmc_media.c
@@ -8,7 +8,6 @@
8#include <linux/ioport.h> 8#include <linux/ioport.h>
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/pci.h>
12#include <linux/in.h> 11#include <linux/in.h>
13#include <linux/if_arp.h> 12#include <linux/if_arp.h>
14#include <linux/netdevice.h> 13#include <linux/netdevice.h>
diff --git a/drivers/net/wan/lmc/lmc_proto.c b/drivers/net/wan/lmc/lmc_proto.c
index 74876c0073e8..31e1799571ad 100644
--- a/drivers/net/wan/lmc/lmc_proto.c
+++ b/drivers/net/wan/lmc/lmc_proto.c
@@ -27,7 +27,6 @@
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/pci.h>
31#include <linux/in.h> 30#include <linux/in.h>
32#include <linux/if_arp.h> 31#include <linux/if_arp.h>
33#include <linux/netdevice.h> 32#include <linux/netdevice.h>
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 07dbdfbfc15d..e24a7b095dd6 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -38,7 +38,6 @@
38 38
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/pci.h>
42#include <linux/errno.h> 41#include <linux/errno.h>
43#include <linux/string.h> 42#include <linux/string.h>
44#include <linux/init.h> 43#include <linux/init.h>
diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c
index 9bb4db552f3c..a68b3b3761a2 100644
--- a/drivers/parisc/hppb.c
+++ b/drivers/parisc/hppb.c
@@ -22,8 +22,6 @@
22#include <asm/hardware.h> 22#include <asm/hardware.h>
23#include <asm/parisc-device.h> 23#include <asm/parisc-device.h>
24 24
25#include <linux/pci.h>
26
27struct hppb_card { 25struct hppb_card {
28 unsigned long hpa; 26 unsigned long hpa;
29 struct resource mmio_region; 27 struct resource mmio_region;
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 5ea5bc70cb82..7a1d6d512837 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -1,10 +1,14 @@
1# 1#
2# PCI configuration 2# PCI configuration
3# 3#
4config ARCH_SUPPORTS_MSI
5 bool
6 default n
7
4config PCI_MSI 8config PCI_MSI
5 bool "Message Signaled Interrupts (MSI and MSI-X)" 9 bool "Message Signaled Interrupts (MSI and MSI-X)"
6 depends on PCI 10 depends on PCI
7 depends on (X86_LOCAL_APIC && X86_IO_APIC) || IA64 || SPARC64 11 depends on ARCH_SUPPORTS_MSI
8 help 12 help
9 This allows device drivers to enable MSI (Message Signaled 13 This allows device drivers to enable MSI (Message Signaled
10 Interrupts). Message Signaled Interrupts enable a device to 14 Interrupts). Message Signaled Interrupts enable a device to
@@ -17,31 +21,6 @@ config PCI_MSI
17 21
18 If you don't know what to do here, say N. 22 If you don't know what to do here, say N.
19 23
20config PCI_MULTITHREAD_PROBE
21 bool "PCI Multi-threaded probe (EXPERIMENTAL)"
22 depends on PCI && EXPERIMENTAL && BROKEN
23 help
24 Say Y here if you want the PCI core to spawn a new thread for
25 every PCI device that is probed. This can cause a huge
26 speedup in boot times on multiprocessor machines, and even a
27 smaller speedup on single processor machines.
28
29 But it can also cause lots of bad things to happen. A number
30 of PCI drivers cannot properly handle running in this way,
31 some will just not work properly at all, while others might
32 decide to blow up power supplies with a huge load all at once,
33 so use this option at your own risk.
34
35 It is very unwise to use this option if you are not using a
36 boot process that can handle devices being created in any
37 order. A program that can create persistent block and network
38 device names (like udev) is a good idea if you wish to use
39 this option.
40
41 Again, use this option at your own risk, you have been warned!
42
43 When in doubt, say N.
44
45config PCI_DEBUG 24config PCI_DEBUG
46 bool "PCI Debugging" 25 bool "PCI Debugging"
47 depends on PCI && DEBUG_KERNEL 26 depends on PCI && DEBUG_KERNEL
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index aadaa3c8096b..9e5ea074ad20 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -77,7 +77,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
77 * This adds a single pci device to the global 77 * This adds a single pci device to the global
78 * device list and adds sysfs and procfs entries 78 * device list and adds sysfs and procfs entries
79 */ 79 */
80int __devinit pci_bus_add_device(struct pci_dev *dev) 80int pci_bus_add_device(struct pci_dev *dev)
81{ 81{
82 int retval; 82 int retval;
83 retval = device_add(&dev->dev); 83 retval = device_add(&dev->dev);
@@ -105,7 +105,7 @@ int __devinit pci_bus_add_device(struct pci_dev *dev)
105 * 105 *
106 * Call hotplug for each new devices. 106 * Call hotplug for each new devices.
107 */ 107 */
108void __devinit pci_bus_add_devices(struct pci_bus *bus) 108void pci_bus_add_devices(struct pci_bus *bus)
109{ 109{
110 struct pci_dev *dev; 110 struct pci_dev *dev;
111 int retval; 111 int retval;
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig
index be92695a7833..63d62752fb91 100644
--- a/drivers/pci/hotplug/Kconfig
+++ b/drivers/pci/hotplug/Kconfig
@@ -2,9 +2,7 @@
2# PCI Hotplug support 2# PCI Hotplug support
3# 3#
4 4
5menu "PCI Hotplug Support" 5menuconfig HOTPLUG_PCI
6
7config HOTPLUG_PCI
8 tristate "Support for PCI Hotplug (EXPERIMENTAL)" 6 tristate "Support for PCI Hotplug (EXPERIMENTAL)"
9 depends on PCI && EXPERIMENTAL && HOTPLUG 7 depends on PCI && EXPERIMENTAL && HOTPLUG
10 ---help--- 8 ---help---
@@ -17,9 +15,10 @@ config HOTPLUG_PCI
17 15
18 When in doubt, say N. 16 When in doubt, say N.
19 17
18if HOTPLUG_PCI
19
20config HOTPLUG_PCI_FAKE 20config HOTPLUG_PCI_FAKE
21 tristate "Fake PCI Hotplug driver" 21 tristate "Fake PCI Hotplug driver"
22 depends on HOTPLUG_PCI
23 help 22 help
24 Say Y here if you want to use the fake PCI hotplug driver. It can 23 Say Y here if you want to use the fake PCI hotplug driver. It can
25 be used to simulate PCI hotplug events if even if your system is 24 be used to simulate PCI hotplug events if even if your system is
@@ -42,7 +41,7 @@ config HOTPLUG_PCI_FAKE
42 41
43config HOTPLUG_PCI_COMPAQ 42config HOTPLUG_PCI_COMPAQ
44 tristate "Compaq PCI Hotplug driver" 43 tristate "Compaq PCI Hotplug driver"
45 depends on HOTPLUG_PCI && X86 && PCI_BIOS 44 depends on X86 && PCI_BIOS
46 help 45 help
47 Say Y here if you have a motherboard with a Compaq PCI Hotplug 46 Say Y here if you have a motherboard with a Compaq PCI Hotplug
48 controller. 47 controller.
@@ -64,7 +63,7 @@ config HOTPLUG_PCI_COMPAQ_NVRAM
64 63
65config HOTPLUG_PCI_IBM 64config HOTPLUG_PCI_IBM
66 tristate "IBM PCI Hotplug driver" 65 tristate "IBM PCI Hotplug driver"
67 depends on HOTPLUG_PCI && X86_IO_APIC && X86 && PCI_BIOS 66 depends on X86_IO_APIC && X86 && PCI_BIOS
68 help 67 help
69 Say Y here if you have a motherboard with a IBM PCI Hotplug 68 Say Y here if you have a motherboard with a IBM PCI Hotplug
70 controller. 69 controller.
@@ -76,7 +75,6 @@ config HOTPLUG_PCI_IBM
76 75
77config HOTPLUG_PCI_ACPI 76config HOTPLUG_PCI_ACPI
78 tristate "ACPI PCI Hotplug driver" 77 tristate "ACPI PCI Hotplug driver"
79 depends on HOTPLUG_PCI
80 depends on (!ACPI_DOCK && ACPI) || (ACPI_DOCK) 78 depends on (!ACPI_DOCK && ACPI) || (ACPI_DOCK)
81 help 79 help
82 Say Y here if you have a system that supports PCI Hotplug using 80 Say Y here if you have a system that supports PCI Hotplug using
@@ -101,7 +99,6 @@ config HOTPLUG_PCI_ACPI_IBM
101 99
102config HOTPLUG_PCI_CPCI 100config HOTPLUG_PCI_CPCI
103 bool "CompactPCI Hotplug driver" 101 bool "CompactPCI Hotplug driver"
104 depends on HOTPLUG_PCI
105 help 102 help
106 Say Y here if you have a CompactPCI system card with CompactPCI 103 Say Y here if you have a CompactPCI system card with CompactPCI
107 hotswap support per the PICMG 2.1 specification. 104 hotswap support per the PICMG 2.1 specification.
@@ -110,7 +107,7 @@ config HOTPLUG_PCI_CPCI
110 107
111config HOTPLUG_PCI_CPCI_ZT5550 108config HOTPLUG_PCI_CPCI_ZT5550
112 tristate "Ziatech ZT5550 CompactPCI Hotplug driver" 109 tristate "Ziatech ZT5550 CompactPCI Hotplug driver"
113 depends on HOTPLUG_PCI && HOTPLUG_PCI_CPCI && X86 110 depends on HOTPLUG_PCI_CPCI && X86
114 help 111 help
115 Say Y here if you have an Performance Technologies (formerly Intel, 112 Say Y here if you have an Performance Technologies (formerly Intel,
116 formerly just Ziatech) Ziatech ZT5550 CompactPCI system card. 113 formerly just Ziatech) Ziatech ZT5550 CompactPCI system card.
@@ -122,7 +119,7 @@ config HOTPLUG_PCI_CPCI_ZT5550
122 119
123config HOTPLUG_PCI_CPCI_GENERIC 120config HOTPLUG_PCI_CPCI_GENERIC
124 tristate "Generic port I/O CompactPCI Hotplug driver" 121 tristate "Generic port I/O CompactPCI Hotplug driver"
125 depends on HOTPLUG_PCI && HOTPLUG_PCI_CPCI && X86 122 depends on HOTPLUG_PCI_CPCI && X86
126 help 123 help
127 Say Y here if you have a CompactPCI system card that exposes the #ENUM 124 Say Y here if you have a CompactPCI system card that exposes the #ENUM
128 hotswap signal as a bit in a system register that can be read through 125 hotswap signal as a bit in a system register that can be read through
@@ -135,7 +132,6 @@ config HOTPLUG_PCI_CPCI_GENERIC
135 132
136config HOTPLUG_PCI_SHPC 133config HOTPLUG_PCI_SHPC
137 tristate "SHPC PCI Hotplug driver" 134 tristate "SHPC PCI Hotplug driver"
138 depends on HOTPLUG_PCI
139 help 135 help
140 Say Y here if you have a motherboard with a SHPC PCI Hotplug 136 Say Y here if you have a motherboard with a SHPC PCI Hotplug
141 controller. 137 controller.
@@ -147,7 +143,7 @@ config HOTPLUG_PCI_SHPC
147 143
148config HOTPLUG_PCI_RPA 144config HOTPLUG_PCI_RPA
149 tristate "RPA PCI Hotplug driver" 145 tristate "RPA PCI Hotplug driver"
150 depends on HOTPLUG_PCI && PPC_PSERIES && PPC64 && !HOTPLUG_PCI_FAKE 146 depends on PPC_PSERIES && PPC64 && !HOTPLUG_PCI_FAKE
151 help 147 help
152 Say Y here if you have a RPA system that supports PCI Hotplug. 148 Say Y here if you have a RPA system that supports PCI Hotplug.
153 149
@@ -170,12 +166,11 @@ config HOTPLUG_PCI_RPA_DLPAR
170 166
171config HOTPLUG_PCI_SGI 167config HOTPLUG_PCI_SGI
172 tristate "SGI PCI Hotplug Support" 168 tristate "SGI PCI Hotplug Support"
173 depends on HOTPLUG_PCI && (IA64_SGI_SN2 || IA64_GENERIC) 169 depends on IA64_SGI_SN2 || IA64_GENERIC
174 help 170 help
175 Say Y here if you want to use the SGI Altix Hotplug 171 Say Y here if you want to use the SGI Altix Hotplug
176 Driver for PCI devices. 172 Driver for PCI devices.
177 173
178 When in doubt, say N. 174 When in doubt, say N.
179 175
180endmenu 176endif # HOTPLUG_PCI
181
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
index 1c12e9171097..41f6a8d79c81 100644
--- a/drivers/pci/hotplug/cpcihp_zt5550.c
+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
@@ -296,13 +296,17 @@ static struct pci_driver zt5550_hc_driver = {
296static int __init zt5550_init(void) 296static int __init zt5550_init(void)
297{ 297{
298 struct resource* r; 298 struct resource* r;
299 int rc;
299 300
300 info(DRIVER_DESC " version: " DRIVER_VERSION); 301 info(DRIVER_DESC " version: " DRIVER_VERSION);
301 r = request_region(ENUM_PORT, 1, "#ENUM hotswap signal register"); 302 r = request_region(ENUM_PORT, 1, "#ENUM hotswap signal register");
302 if(!r) 303 if(!r)
303 return -EBUSY; 304 return -EBUSY;
304 305
305 return pci_register_driver(&zt5550_hc_driver); 306 rc = pci_register_driver(&zt5550_hc_driver);
307 if(rc < 0)
308 release_region(ENUM_PORT, 1);
309 return rc;
306} 310}
307 311
308static void __exit 312static void __exit
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index e27907c91d92..027f6865d7e3 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -238,7 +238,7 @@ static void pci_rescan_bus(const struct pci_bus *bus)
238{ 238{
239 unsigned int devfn; 239 unsigned int devfn;
240 struct pci_dev *dev; 240 struct pci_dev *dev;
241 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); 241 dev = alloc_pci_dev();
242 if (!dev) 242 if (!dev)
243 return; 243 return;
244 244
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index d19fcae8a7c0..ccc57627201e 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -43,6 +43,7 @@ extern int pciehp_poll_mode;
43extern int pciehp_poll_time; 43extern int pciehp_poll_time;
44extern int pciehp_debug; 44extern int pciehp_debug;
45extern int pciehp_force; 45extern int pciehp_force;
46extern struct workqueue_struct *pciehp_wq;
46 47
47#define dbg(format, arg...) \ 48#define dbg(format, arg...) \
48 do { \ 49 do { \
@@ -70,14 +71,16 @@ struct slot {
70 struct list_head slot_list; 71 struct list_head slot_list;
71 char name[SLOT_NAME_SIZE]; 72 char name[SLOT_NAME_SIZE];
72 unsigned long last_emi_toggle; 73 unsigned long last_emi_toggle;
74 struct delayed_work work; /* work for button event */
75 struct mutex lock;
73}; 76};
74 77
75struct event_info { 78struct event_info {
76 u32 event_type; 79 u32 event_type;
77 u8 hp_slot; 80 struct slot *p_slot;
81 struct work_struct work;
78}; 82};
79 83
80#define MAX_EVENTS 10
81struct controller { 84struct controller {
82 struct controller *next; 85 struct controller *next;
83 struct mutex crit_sect; /* critical section mutex */ 86 struct mutex crit_sect; /* critical section mutex */
@@ -86,11 +89,9 @@ struct controller {
86 int slot_num_inc; /* 1 or -1 */ 89 int slot_num_inc; /* 1 or -1 */
87 struct pci_dev *pci_dev; 90 struct pci_dev *pci_dev;
88 struct list_head slot_list; 91 struct list_head slot_list;
89 struct event_info event_queue[MAX_EVENTS];
90 struct slot *slot; 92 struct slot *slot;
91 struct hpc_ops *hpc_ops; 93 struct hpc_ops *hpc_ops;
92 wait_queue_head_t queue; /* sleep & wake process */ 94 wait_queue_head_t queue; /* sleep & wake process */
93 u8 next_event;
94 u8 bus; 95 u8 bus;
95 u8 device; 96 u8 device;
96 u8 function; 97 u8 function;
@@ -149,21 +150,17 @@ struct controller {
149#define HP_SUPR_RM(cap) (cap & HP_SUPR_RM_SUP) 150#define HP_SUPR_RM(cap) (cap & HP_SUPR_RM_SUP)
150#define EMI(cap) (cap & EMI_PRSN) 151#define EMI(cap) (cap & EMI_PRSN)
151 152
152extern int pciehp_event_start_thread(void); 153extern int pciehp_sysfs_enable_slot(struct slot *slot);
153extern void pciehp_event_stop_thread(void); 154extern int pciehp_sysfs_disable_slot(struct slot *slot);
154extern int pciehp_enable_slot(struct slot *slot);
155extern int pciehp_disable_slot(struct slot *slot);
156extern u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl); 155extern u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl);
157extern u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl); 156extern u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl);
158extern u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl); 157extern u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl);
159extern u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl); 158extern u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl);
160extern int pciehp_configure_device(struct slot *p_slot); 159extern int pciehp_configure_device(struct slot *p_slot);
161extern int pciehp_unconfigure_device(struct slot *p_slot); 160extern int pciehp_unconfigure_device(struct slot *p_slot);
161extern void pciehp_queue_pushbutton_work(struct work_struct *work);
162int pcie_init(struct controller *ctrl, struct pcie_device *dev); 162int pcie_init(struct controller *ctrl, struct pcie_device *dev);
163 163
164/* Global variables */
165extern struct controller *pciehp_ctrl_list;
166
167static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) 164static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
168{ 165{
169 struct slot *slot; 166 struct slot *slot;
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index a92eda6e02f6..e5d3f0b4f45a 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -41,7 +41,7 @@ int pciehp_debug;
41int pciehp_poll_mode; 41int pciehp_poll_mode;
42int pciehp_poll_time; 42int pciehp_poll_time;
43int pciehp_force; 43int pciehp_force;
44struct controller *pciehp_ctrl_list; 44struct workqueue_struct *pciehp_wq;
45 45
46#define DRIVER_VERSION "0.4" 46#define DRIVER_VERSION "0.4"
47#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" 47#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
@@ -62,7 +62,6 @@ MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing"
62 62
63#define PCIE_MODULE_NAME "pciehp" 63#define PCIE_MODULE_NAME "pciehp"
64 64
65static int pcie_start_thread (void);
66static int set_attention_status (struct hotplug_slot *slot, u8 value); 65static int set_attention_status (struct hotplug_slot *slot, u8 value);
67static int enable_slot (struct hotplug_slot *slot); 66static int enable_slot (struct hotplug_slot *slot);
68static int disable_slot (struct hotplug_slot *slot); 67static int disable_slot (struct hotplug_slot *slot);
@@ -229,6 +228,8 @@ static int init_slots(struct controller *ctrl)
229 slot->device = ctrl->slot_device_offset + i; 228 slot->device = ctrl->slot_device_offset + i;
230 slot->hpc_ops = ctrl->hpc_ops; 229 slot->hpc_ops = ctrl->hpc_ops;
231 slot->number = ctrl->first_slot; 230 slot->number = ctrl->first_slot;
231 mutex_init(&slot->lock);
232 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
232 233
233 /* register this slot with the hotplug pci core */ 234 /* register this slot with the hotplug pci core */
234 hotplug_slot->private = slot; 235 hotplug_slot->private = slot;
@@ -286,6 +287,9 @@ static void cleanup_slots(struct controller *ctrl)
286 if (EMI(ctrl->ctrlcap)) 287 if (EMI(ctrl->ctrlcap))
287 sysfs_remove_file(&slot->hotplug_slot->kobj, 288 sysfs_remove_file(&slot->hotplug_slot->kobj,
288 &hotplug_slot_attr_lock.attr); 289 &hotplug_slot_attr_lock.attr);
290 cancel_delayed_work(&slot->work);
291 flush_scheduled_work();
292 flush_workqueue(pciehp_wq);
289 pci_hp_deregister(slot->hotplug_slot); 293 pci_hp_deregister(slot->hotplug_slot);
290 } 294 }
291} 295}
@@ -314,7 +318,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
314 318
315 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 319 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
316 320
317 return pciehp_enable_slot(slot); 321 return pciehp_sysfs_enable_slot(slot);
318} 322}
319 323
320 324
@@ -324,7 +328,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
324 328
325 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 329 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
326 330
327 return pciehp_disable_slot(slot); 331 return pciehp_sysfs_disable_slot(slot);
328} 332}
329 333
330static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) 334static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
@@ -466,17 +470,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
466 470
467 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset); 471 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset);
468 472
469 /* Finish setting up the hot plug ctrl device */
470 ctrl->next_event = 0;
471
472 if (!pciehp_ctrl_list) {
473 pciehp_ctrl_list = ctrl;
474 ctrl->next = NULL;
475 } else {
476 ctrl->next = pciehp_ctrl_list;
477 pciehp_ctrl_list = ctrl;
478 }
479
480 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ 473 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
481 if ((POWER_CTRL(ctrl->ctrlcap)) && !value) { 474 if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
482 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ 475 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
@@ -496,48 +489,14 @@ err_out_none:
496 return -ENODEV; 489 return -ENODEV;
497} 490}
498 491
499 492static void pciehp_remove (struct pcie_device *dev)
500static int pcie_start_thread(void)
501{ 493{
502 int retval = 0; 494 struct pci_dev *pdev = dev->port;
503 495 struct controller *ctrl = pci_get_drvdata(pdev);
504 dbg("Initialize + Start the notification/polling mechanism \n");
505
506 retval = pciehp_event_start_thread();
507 if (retval) {
508 dbg("pciehp_event_start_thread() failed\n");
509 return retval;
510 }
511
512 return retval;
513}
514
515static void __exit unload_pciehpd(void)
516{
517 struct controller *ctrl;
518 struct controller *tctrl;
519
520 ctrl = pciehp_ctrl_list;
521
522 while (ctrl) {
523 cleanup_slots(ctrl);
524 496
525 ctrl->hpc_ops->release_ctlr(ctrl); 497 cleanup_slots(ctrl);
526 498 ctrl->hpc_ops->release_ctlr(ctrl);
527 tctrl = ctrl; 499 kfree(ctrl);
528 ctrl = ctrl->next;
529
530 kfree(tctrl);
531 }
532
533 /* Stop the notification mechanism */
534 pciehp_event_stop_thread();
535
536}
537
538static void pciehp_remove (struct pcie_device *device)
539{
540 /* XXX - Needs to be adapted to device driver model */
541} 500}
542 501
543#ifdef CONFIG_PM 502#ifdef CONFIG_PM
@@ -585,31 +544,18 @@ static int __init pcied_init(void)
585 pciehp_poll_mode = 1; 544 pciehp_poll_mode = 1;
586#endif 545#endif
587 546
588 retval = pcie_start_thread();
589 if (retval)
590 goto error_hpc_init;
591
592 retval = pcie_port_service_register(&hpdriver_portdrv); 547 retval = pcie_port_service_register(&hpdriver_portdrv);
593 dbg("pcie_port_service_register = %d\n", retval); 548 dbg("pcie_port_service_register = %d\n", retval);
594 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 549 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
595 if (retval) 550 if (retval)
596 dbg("%s: Failure to register service\n", __FUNCTION__); 551 dbg("%s: Failure to register service\n", __FUNCTION__);
597
598error_hpc_init:
599 if (retval) {
600 pciehp_event_stop_thread();
601 };
602
603 return retval; 552 return retval;
604} 553}
605 554
606static void __exit pcied_cleanup(void) 555static void __exit pcied_cleanup(void)
607{ 556{
608 dbg("unload_pciehpd()\n"); 557 dbg("unload_pciehpd()\n");
609 unload_pciehpd();
610
611 pcie_port_service_unregister(&hpdriver_portdrv); 558 pcie_port_service_unregister(&hpdriver_portdrv);
612
613 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); 559 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
614} 560}
615 561
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 4283ef56dbd9..7f22caa70178 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -32,92 +32,61 @@
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/workqueue.h>
35#include "../pci.h" 36#include "../pci.h"
36#include "pciehp.h" 37#include "pciehp.h"
37 38
38static void interrupt_event_handler(struct controller *ctrl); 39static void interrupt_event_handler(struct work_struct *work);
40static int pciehp_enable_slot(struct slot *p_slot);
41static int pciehp_disable_slot(struct slot *p_slot);
39 42
40static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ 43static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
41static struct semaphore event_exit; /* guard ensure thread has exited before calling it quits */
42static int event_finished;
43static unsigned long pushbutton_pending; /* = 0 */
44static unsigned long surprise_rm_pending; /* = 0 */
45
46static inline char *slot_name(struct slot *p_slot)
47{ 44{
48 return p_slot->hotplug_slot->name; 45 struct event_info *info;
46
47 info = kmalloc(sizeof(*info), GFP_ATOMIC);
48 if (!info)
49 return -ENOMEM;
50
51 info->event_type = event_type;
52 info->p_slot = p_slot;
53 INIT_WORK(&info->work, interrupt_event_handler);
54
55 schedule_work(&info->work);
56
57 return 0;
49} 58}
50 59
51u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl) 60u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl)
52{ 61{
53 struct slot *p_slot; 62 struct slot *p_slot;
54 u8 rc = 0; 63 u32 event_type;
55 u8 getstatus;
56 struct event_info *taskInfo;
57 64
58 /* Attention Button Change */ 65 /* Attention Button Change */
59 dbg("pciehp: Attention button interrupt received.\n"); 66 dbg("pciehp: Attention button interrupt received.\n");
60
61 /* This is the structure that tells the worker thread what to do */
62 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
63 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
64
65 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
66
67 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
68 taskInfo->hp_slot = hp_slot;
69 67
70 rc++; 68 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
71 69
72 /* 70 /*
73 * Button pressed - See if need to TAKE ACTION!!! 71 * Button pressed - See if need to TAKE ACTION!!!
74 */ 72 */
75 info("Button pressed on Slot(%s)\n", slot_name(p_slot)); 73 info("Button pressed on Slot(%s)\n", p_slot->name);
76 taskInfo->event_type = INT_BUTTON_PRESS; 74 event_type = INT_BUTTON_PRESS;
77
78 if ((p_slot->state == BLINKINGON_STATE)
79 || (p_slot->state == BLINKINGOFF_STATE)) {
80 /* Cancel if we are still blinking; this means that we press the
81 * attention again before the 5 sec. limit expires to cancel hot-add
82 * or hot-remove
83 */
84 taskInfo->event_type = INT_BUTTON_CANCEL;
85 info("Button cancel on Slot(%s)\n", slot_name(p_slot));
86 } else if ((p_slot->state == POWERON_STATE)
87 || (p_slot->state == POWEROFF_STATE)) {
88 /* Ignore if the slot is on power-on or power-off state; this
89 * means that the previous attention button action to hot-add or
90 * hot-remove is undergoing
91 */
92 taskInfo->event_type = INT_BUTTON_IGNORE;
93 info("Button ignore on Slot(%s)\n", slot_name(p_slot));
94 }
95 75
96 if (rc) 76 queue_interrupt_event(p_slot, event_type);
97 up(&event_semaphore); /* signal event thread that new event is posted */
98 77
99 return 0; 78 return 0;
100
101} 79}
102 80
103u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl) 81u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
104{ 82{
105 struct slot *p_slot; 83 struct slot *p_slot;
106 u8 rc = 0;
107 u8 getstatus; 84 u8 getstatus;
108 struct event_info *taskInfo; 85 u32 event_type;
109 86
110 /* Switch Change */ 87 /* Switch Change */
111 dbg("pciehp: Switch interrupt received.\n"); 88 dbg("pciehp: Switch interrupt received.\n");
112 89
113 /* This is the structure that tells the worker thread
114 * what to do
115 */
116 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
117 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
118 taskInfo->hp_slot = hp_slot;
119
120 rc++;
121 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 90 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
122 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 91 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
123 92
@@ -125,39 +94,30 @@ u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
125 /* 94 /*
126 * Switch opened 95 * Switch opened
127 */ 96 */
128 info("Latch open on Slot(%s)\n", slot_name(p_slot)); 97 info("Latch open on Slot(%s)\n", p_slot->name);
129 taskInfo->event_type = INT_SWITCH_OPEN; 98 event_type = INT_SWITCH_OPEN;
130 } else { 99 } else {
131 /* 100 /*
132 * Switch closed 101 * Switch closed
133 */ 102 */
134 info("Latch close on Slot(%s)\n", slot_name(p_slot)); 103 info("Latch close on Slot(%s)\n", p_slot->name);
135 taskInfo->event_type = INT_SWITCH_CLOSE; 104 event_type = INT_SWITCH_CLOSE;
136 } 105 }
137 106
138 if (rc) 107 queue_interrupt_event(p_slot, event_type);
139 up(&event_semaphore); /* signal event thread that new event is posted */
140 108
141 return rc; 109 return 1;
142} 110}
143 111
144u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl) 112u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl)
145{ 113{
146 struct slot *p_slot; 114 struct slot *p_slot;
147 u8 presence_save, rc = 0; 115 u32 event_type;
148 struct event_info *taskInfo; 116 u8 presence_save;
149 117
150 /* Presence Change */ 118 /* Presence Change */
151 dbg("pciehp: Presence/Notify input change.\n"); 119 dbg("pciehp: Presence/Notify input change.\n");
152 120
153 /* This is the structure that tells the worker thread
154 * what to do
155 */
156 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
157 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
158 taskInfo->hp_slot = hp_slot;
159
160 rc++;
161 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 121 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
162 122
163 /* Switch is open, assume a presence change 123 /* Switch is open, assume a presence change
@@ -168,59 +128,49 @@ u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl)
168 /* 128 /*
169 * Card Present 129 * Card Present
170 */ 130 */
171 info("Card present on Slot(%s)\n", slot_name(p_slot)); 131 info("Card present on Slot(%s)\n", p_slot->name);
172 taskInfo->event_type = INT_PRESENCE_ON; 132 event_type = INT_PRESENCE_ON;
173 } else { 133 } else {
174 /* 134 /*
175 * Not Present 135 * Not Present
176 */ 136 */
177 info("Card not present on Slot(%s)\n", slot_name(p_slot)); 137 info("Card not present on Slot(%s)\n", p_slot->name);
178 taskInfo->event_type = INT_PRESENCE_OFF; 138 event_type = INT_PRESENCE_OFF;
179 } 139 }
180 140
181 if (rc) 141 queue_interrupt_event(p_slot, event_type);
182 up(&event_semaphore); /* signal event thread that new event is posted */
183 142
184 return rc; 143 return 1;
185} 144}
186 145
187u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl) 146u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl)
188{ 147{
189 struct slot *p_slot; 148 struct slot *p_slot;
190 u8 rc = 0; 149 u32 event_type;
191 struct event_info *taskInfo;
192 150
193 /* power fault */ 151 /* power fault */
194 dbg("pciehp: Power fault interrupt received.\n"); 152 dbg("pciehp: Power fault interrupt received.\n");
195 153
196 /* this is the structure that tells the worker thread
197 * what to do
198 */
199 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
200 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
201 taskInfo->hp_slot = hp_slot;
202
203 rc++;
204 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 154 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
205 155
206 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { 156 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
207 /* 157 /*
208 * power fault Cleared 158 * power fault Cleared
209 */ 159 */
210 info("Power fault cleared on Slot(%s)\n", slot_name(p_slot)); 160 info("Power fault cleared on Slot(%s)\n", p_slot->name);
211 taskInfo->event_type = INT_POWER_FAULT_CLEAR; 161 event_type = INT_POWER_FAULT_CLEAR;
212 } else { 162 } else {
213 /* 163 /*
214 * power fault 164 * power fault
215 */ 165 */
216 info("Power fault on Slot(%s)\n", slot_name(p_slot)); 166 info("Power fault on Slot(%s)\n", p_slot->name);
217 taskInfo->event_type = INT_POWER_FAULT; 167 event_type = INT_POWER_FAULT;
218 info("power fault bit %x set\n", hp_slot); 168 info("power fault bit %x set\n", hp_slot);
219 } 169 }
220 if (rc)
221 up(&event_semaphore); /* signal event thread that new event is posted */
222 170
223 return rc; 171 queue_interrupt_event(p_slot, event_type);
172
173 return 1;
224} 174}
225 175
226/* The following routines constitute the bulk of the 176/* The following routines constitute the bulk of the
@@ -357,13 +307,10 @@ static int remove_board(struct slot *p_slot)
357 return 0; 307 return 0;
358} 308}
359 309
360 310struct power_work_info {
361static void pushbutton_helper_thread(unsigned long data) 311 struct slot *p_slot;
362{ 312 struct work_struct work;
363 pushbutton_pending = data; 313};
364
365 up(&event_semaphore);
366}
367 314
368/** 315/**
369 * pciehp_pushbutton_thread 316 * pciehp_pushbutton_thread
@@ -372,276 +319,214 @@ static void pushbutton_helper_thread(unsigned long data)
372 * Handles all pending events and exits. 319 * Handles all pending events and exits.
373 * 320 *
374 */ 321 */
375static void pciehp_pushbutton_thread(unsigned long slot) 322static void pciehp_power_thread(struct work_struct *work)
376{ 323{
377 struct slot *p_slot = (struct slot *) slot; 324 struct power_work_info *info =
378 u8 getstatus; 325 container_of(work, struct power_work_info, work);
379 326 struct slot *p_slot = info->p_slot;
380 pushbutton_pending = 0; 327
381 328 mutex_lock(&p_slot->lock);
382 if (!p_slot) { 329 switch (p_slot->state) {
383 dbg("%s: Error! slot NULL\n", __FUNCTION__); 330 case POWEROFF_STATE:
384 return; 331 mutex_unlock(&p_slot->lock);
385 } 332 dbg("%s: disabling bus:device(%x:%x)\n",
386 333 __FUNCTION__, p_slot->bus, p_slot->device);
387 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
388 if (getstatus) {
389 p_slot->state = POWEROFF_STATE;
390 dbg("%s: disabling bus:device(%x:%x)\n", __FUNCTION__,
391 p_slot->bus, p_slot->device);
392
393 pciehp_disable_slot(p_slot); 334 pciehp_disable_slot(p_slot);
335 mutex_lock(&p_slot->lock);
394 p_slot->state = STATIC_STATE; 336 p_slot->state = STATIC_STATE;
395 } else { 337 break;
396 p_slot->state = POWERON_STATE; 338 case POWERON_STATE:
397 dbg("%s: adding bus:device(%x:%x)\n", __FUNCTION__, 339 mutex_unlock(&p_slot->lock);
398 p_slot->bus, p_slot->device);
399
400 if (pciehp_enable_slot(p_slot) && 340 if (pciehp_enable_slot(p_slot) &&
401 PWR_LED(p_slot->ctrl->ctrlcap)) 341 PWR_LED(p_slot->ctrl->ctrlcap))
402 p_slot->hpc_ops->green_led_off(p_slot); 342 p_slot->hpc_ops->green_led_off(p_slot);
403 343 mutex_lock(&p_slot->lock);
404 p_slot->state = STATIC_STATE; 344 p_slot->state = STATIC_STATE;
345 break;
346 default:
347 break;
405 } 348 }
349 mutex_unlock(&p_slot->lock);
406 350
407 return; 351 kfree(info);
408} 352}
409 353
410/** 354void pciehp_queue_pushbutton_work(struct work_struct *work)
411 * pciehp_surprise_rm_thread
412 *
413 * Scheduled procedure to handle blocking stuff for the surprise removal
414 * Handles all pending events and exits.
415 *
416 */
417static void pciehp_surprise_rm_thread(unsigned long slot)
418{ 355{
419 struct slot *p_slot = (struct slot *) slot; 356 struct slot *p_slot = container_of(work, struct slot, work.work);
420 u8 getstatus; 357 struct power_work_info *info;
421
422 surprise_rm_pending = 0;
423 358
424 if (!p_slot) { 359 info = kmalloc(sizeof(*info), GFP_KERNEL);
425 dbg("%s: Error! slot NULL\n", __FUNCTION__); 360 if (!info) {
361 err("%s: Cannot allocate memory\n", __FUNCTION__);
426 return; 362 return;
427 } 363 }
364 info->p_slot = p_slot;
365 INIT_WORK(&info->work, pciehp_power_thread);
428 366
429 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 367 mutex_lock(&p_slot->lock);
430 if (!getstatus) { 368 switch (p_slot->state) {
369 case BLINKINGOFF_STATE:
431 p_slot->state = POWEROFF_STATE; 370 p_slot->state = POWEROFF_STATE;
432 dbg("%s: removing bus:device(%x:%x)\n", 371 break;
433 __FUNCTION__, p_slot->bus, p_slot->device); 372 case BLINKINGON_STATE:
434
435 pciehp_disable_slot(p_slot);
436 p_slot->state = STATIC_STATE;
437 } else {
438 p_slot->state = POWERON_STATE; 373 p_slot->state = POWERON_STATE;
439 dbg("%s: adding bus:device(%x:%x)\n", 374 break;
440 __FUNCTION__, p_slot->bus, p_slot->device); 375 default:
441 376 goto out;
442 if (pciehp_enable_slot(p_slot) &&
443 PWR_LED(p_slot->ctrl->ctrlcap))
444 p_slot->hpc_ops->green_led_off(p_slot);
445
446 p_slot->state = STATIC_STATE;
447 } 377 }
448 378 queue_work(pciehp_wq, &info->work);
449 return; 379 out:
380 mutex_unlock(&p_slot->lock);
450} 381}
451 382
452
453
454/* this is the main worker thread */
455static int event_thread(void* data)
456{
457 struct controller *ctrl;
458 lock_kernel();
459 daemonize("pciehpd_event");
460
461 unlock_kernel();
462
463 while (1) {
464 dbg("!!!!event_thread sleeping\n");
465 down_interruptible (&event_semaphore);
466 dbg("event_thread woken finished = %d\n", event_finished);
467 if (event_finished || signal_pending(current))
468 break;
469 /* Do stuff here */
470 if (pushbutton_pending)
471 pciehp_pushbutton_thread(pushbutton_pending);
472 else if (surprise_rm_pending)
473 pciehp_surprise_rm_thread(surprise_rm_pending);
474 else
475 for (ctrl = pciehp_ctrl_list; ctrl; ctrl=ctrl->next)
476 interrupt_event_handler(ctrl);
477 }
478 dbg("event_thread signals exit\n");
479 up(&event_exit);
480 return 0;
481}
482
483int pciehp_event_start_thread(void)
484{
485 int pid;
486
487 /* initialize our semaphores */
488 init_MUTEX_LOCKED(&event_exit);
489 event_finished=0;
490
491 init_MUTEX_LOCKED(&event_semaphore);
492 pid = kernel_thread(event_thread, NULL, 0);
493
494 if (pid < 0) {
495 err ("Can't start up our event thread\n");
496 return -1;
497 }
498 return 0;
499}
500
501
502void pciehp_event_stop_thread(void)
503{
504 event_finished = 1;
505 up(&event_semaphore);
506 down(&event_exit);
507}
508
509
510static int update_slot_info(struct slot *slot) 383static int update_slot_info(struct slot *slot)
511{ 384{
512 struct hotplug_slot_info *info; 385 struct hotplug_slot_info *info;
513 /* char buffer[SLOT_NAME_SIZE]; */
514 int result; 386 int result;
515 387
516 info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); 388 info = kmalloc(sizeof(*info), GFP_KERNEL);
517 if (!info) 389 if (!info)
518 return -ENOMEM; 390 return -ENOMEM;
519 391
520 /* make_slot_name (&buffer[0], SLOT_NAME_SIZE, slot); */
521
522 slot->hpc_ops->get_power_status(slot, &(info->power_status)); 392 slot->hpc_ops->get_power_status(slot, &(info->power_status));
523 slot->hpc_ops->get_attention_status(slot, &(info->attention_status)); 393 slot->hpc_ops->get_attention_status(slot, &(info->attention_status));
524 slot->hpc_ops->get_latch_status(slot, &(info->latch_status)); 394 slot->hpc_ops->get_latch_status(slot, &(info->latch_status));
525 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status)); 395 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status));
526 396
527 /* result = pci_hp_change_slot_info(buffer, info); */
528 result = pci_hp_change_slot_info(slot->hotplug_slot, info); 397 result = pci_hp_change_slot_info(slot->hotplug_slot, info);
529 kfree (info); 398 kfree (info);
530 return result; 399 return result;
531} 400}
532 401
533static void interrupt_event_handler(struct controller *ctrl) 402/*
403 * Note: This function must be called with slot->lock held
404 */
405static void handle_button_press_event(struct slot *p_slot)
534{ 406{
535 int loop = 0; 407 struct controller *ctrl = p_slot->ctrl;
536 int change = 1;
537 u8 hp_slot;
538 u8 getstatus; 408 u8 getstatus;
539 struct slot *p_slot;
540 409
541 while (change) { 410 switch (p_slot->state) {
542 change = 0; 411 case STATIC_STATE:
543 412 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
544 for (loop = 0; loop < MAX_EVENTS; loop++) { 413 if (getstatus) {
545 if (ctrl->event_queue[loop].event_type != 0) { 414 p_slot->state = BLINKINGOFF_STATE;
546 hp_slot = ctrl->event_queue[loop].hp_slot; 415 info("PCI slot #%s - powering off due to button "
547 416 "press.\n", p_slot->name);
548 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 417 } else {
549 418 p_slot->state = BLINKINGON_STATE;
550 if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) { 419 info("PCI slot #%s - powering on due to button "
551 dbg("button cancel\n"); 420 "press.\n", p_slot->name);
552 del_timer(&p_slot->task_event); 421 }
553 422 /* blink green LED and turn off amber */
554 switch (p_slot->state) { 423 if (PWR_LED(ctrl->ctrlcap))
555 case BLINKINGOFF_STATE: 424 p_slot->hpc_ops->green_led_blink(p_slot);
556 if (PWR_LED(ctrl->ctrlcap)) 425 if (ATTN_LED(ctrl->ctrlcap))
557 p_slot->hpc_ops->green_led_on(p_slot); 426 p_slot->hpc_ops->set_attention_status(p_slot, 0);
558 427
559 if (ATTN_LED(ctrl->ctrlcap)) 428 schedule_delayed_work(&p_slot->work, 5*HZ);
560 p_slot->hpc_ops->set_attention_status(p_slot, 0); 429 break;
561 break; 430 case BLINKINGOFF_STATE:
562 case BLINKINGON_STATE: 431 case BLINKINGON_STATE:
563 if (PWR_LED(ctrl->ctrlcap)) 432 /*
564 p_slot->hpc_ops->green_led_off(p_slot); 433 * Cancel if we are still blinking; this means that we
565 434 * press the attention again before the 5 sec. limit
566 if (ATTN_LED(ctrl->ctrlcap)) 435 * expires to cancel hot-add or hot-remove
567 p_slot->hpc_ops->set_attention_status(p_slot, 0); 436 */
568 break; 437 info("Button cancel on Slot(%s)\n", p_slot->name);
569 default: 438 dbg("%s: button cancel\n", __FUNCTION__);
570 warn("Not a valid state\n"); 439 cancel_delayed_work(&p_slot->work);
571 return; 440 if (p_slot->state == BLINKINGOFF_STATE) {
572 } 441 if (PWR_LED(ctrl->ctrlcap))
573 info("PCI slot #%s - action canceled due to button press.\n", slot_name(p_slot)); 442 p_slot->hpc_ops->green_led_on(p_slot);
574 p_slot->state = STATIC_STATE; 443 } else {
575 } 444 if (PWR_LED(ctrl->ctrlcap))
576 /* ***********Button Pressed (No action on 1st press...) */ 445 p_slot->hpc_ops->green_led_off(p_slot);
577 else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) { 446 }
578 447 if (ATTN_LED(ctrl->ctrlcap))
579 if (ATTN_BUTTN(ctrl->ctrlcap)) { 448 p_slot->hpc_ops->set_attention_status(p_slot, 0);
580 dbg("Button pressed\n"); 449 info("PCI slot #%s - action canceled due to button press\n",
581 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 450 p_slot->name);
582 if (getstatus) { 451 p_slot->state = STATIC_STATE;
583 /* slot is on */ 452 break;
584 dbg("slot is on\n"); 453 case POWEROFF_STATE:
585 p_slot->state = BLINKINGOFF_STATE; 454 case POWERON_STATE:
586 info("PCI slot #%s - powering off due to button press.\n", slot_name(p_slot)); 455 /*
587 } else { 456 * Ignore if the slot is on power-on or power-off state;
588 /* slot is off */ 457 * this means that the previous attention button action
589 dbg("slot is off\n"); 458 * to hot-add or hot-remove is undergoing
590 p_slot->state = BLINKINGON_STATE; 459 */
591 info("PCI slot #%s - powering on due to button press.\n", slot_name(p_slot)); 460 info("Button ignore on Slot(%s)\n", p_slot->name);
592 } 461 update_slot_info(p_slot);
593 462 break;
594 /* blink green LED and turn off amber */ 463 default:
595 if (PWR_LED(ctrl->ctrlcap)) 464 warn("Not a valid state\n");
596 p_slot->hpc_ops->green_led_blink(p_slot); 465 break;
597
598 if (ATTN_LED(ctrl->ctrlcap))
599 p_slot->hpc_ops->set_attention_status(p_slot, 0);
600
601 init_timer(&p_slot->task_event);
602 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
603 p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
604 p_slot->task_event.data = (unsigned long) p_slot;
605
606 add_timer(&p_slot->task_event);
607 }
608 }
609 /***********POWER FAULT********************/
610 else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
611 if (POWER_CTRL(ctrl->ctrlcap)) {
612 dbg("power fault\n");
613 if (ATTN_LED(ctrl->ctrlcap))
614 p_slot->hpc_ops->set_attention_status(p_slot, 1);
615
616 if (PWR_LED(ctrl->ctrlcap))
617 p_slot->hpc_ops->green_led_off(p_slot);
618 }
619 }
620 /***********SURPRISE REMOVAL********************/
621 else if ((ctrl->event_queue[loop].event_type == INT_PRESENCE_ON) ||
622 (ctrl->event_queue[loop].event_type == INT_PRESENCE_OFF)) {
623 if (HP_SUPR_RM(ctrl->ctrlcap)) {
624 dbg("Surprise Removal\n");
625 if (p_slot) {
626 surprise_rm_pending = (unsigned long) p_slot;
627 up(&event_semaphore);
628 update_slot_info(p_slot);
629 }
630 }
631 } else {
632 /* refresh notification */
633 if (p_slot)
634 update_slot_info(p_slot);
635 }
636
637 ctrl->event_queue[loop].event_type = 0;
638
639 change = 1;
640 }
641 } /* End of FOR loop */
642 } 466 }
643} 467}
644 468
469/*
470 * Note: This function must be called with slot->lock held
471 */
472static void handle_surprise_event(struct slot *p_slot)
473{
474 u8 getstatus;
475 struct power_work_info *info;
476
477 info = kmalloc(sizeof(*info), GFP_KERNEL);
478 if (!info) {
479 err("%s: Cannot allocate memory\n", __FUNCTION__);
480 return;
481 }
482 info->p_slot = p_slot;
483 INIT_WORK(&info->work, pciehp_power_thread);
484
485 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
486 if (!getstatus)
487 p_slot->state = POWEROFF_STATE;
488 else
489 p_slot->state = POWERON_STATE;
490
491 queue_work(pciehp_wq, &info->work);
492}
493
494static void interrupt_event_handler(struct work_struct *work)
495{
496 struct event_info *info = container_of(work, struct event_info, work);
497 struct slot *p_slot = info->p_slot;
498 struct controller *ctrl = p_slot->ctrl;
499
500 mutex_lock(&p_slot->lock);
501 switch (info->event_type) {
502 case INT_BUTTON_PRESS:
503 handle_button_press_event(p_slot);
504 break;
505 case INT_POWER_FAULT:
506 if (!POWER_CTRL(ctrl->ctrlcap))
507 break;
508 if (ATTN_LED(ctrl->ctrlcap))
509 p_slot->hpc_ops->set_attention_status(p_slot, 1);
510 if (PWR_LED(ctrl->ctrlcap))
511 p_slot->hpc_ops->green_led_off(p_slot);
512 break;
513 case INT_PRESENCE_ON:
514 case INT_PRESENCE_OFF:
515 if (!HP_SUPR_RM(ctrl->ctrlcap))
516 break;
517 dbg("Surprise Removal\n");
518 update_slot_info(p_slot);
519 handle_surprise_event(p_slot);
520 break;
521 default:
522 update_slot_info(p_slot);
523 break;
524 }
525 mutex_unlock(&p_slot->lock);
526
527 kfree(info);
528}
529
645int pciehp_enable_slot(struct slot *p_slot) 530int pciehp_enable_slot(struct slot *p_slot)
646{ 531{
647 u8 getstatus = 0; 532 u8 getstatus = 0;
@@ -653,7 +538,7 @@ int pciehp_enable_slot(struct slot *p_slot)
653 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 538 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
654 if (rc || !getstatus) { 539 if (rc || !getstatus) {
655 info("%s: no adapter on slot(%s)\n", __FUNCTION__, 540 info("%s: no adapter on slot(%s)\n", __FUNCTION__,
656 slot_name(p_slot)); 541 p_slot->name);
657 mutex_unlock(&p_slot->ctrl->crit_sect); 542 mutex_unlock(&p_slot->ctrl->crit_sect);
658 return -ENODEV; 543 return -ENODEV;
659 } 544 }
@@ -661,7 +546,7 @@ int pciehp_enable_slot(struct slot *p_slot)
661 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 546 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
662 if (rc || getstatus) { 547 if (rc || getstatus) {
663 info("%s: latch open on slot(%s)\n", __FUNCTION__, 548 info("%s: latch open on slot(%s)\n", __FUNCTION__,
664 slot_name(p_slot)); 549 p_slot->name);
665 mutex_unlock(&p_slot->ctrl->crit_sect); 550 mutex_unlock(&p_slot->ctrl->crit_sect);
666 return -ENODEV; 551 return -ENODEV;
667 } 552 }
@@ -671,7 +556,7 @@ int pciehp_enable_slot(struct slot *p_slot)
671 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 556 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
672 if (rc || getstatus) { 557 if (rc || getstatus) {
673 info("%s: already enabled on slot(%s)\n", __FUNCTION__, 558 info("%s: already enabled on slot(%s)\n", __FUNCTION__,
674 slot_name(p_slot)); 559 p_slot->name);
675 mutex_unlock(&p_slot->ctrl->crit_sect); 560 mutex_unlock(&p_slot->ctrl->crit_sect);
676 return -EINVAL; 561 return -EINVAL;
677 } 562 }
@@ -706,7 +591,7 @@ int pciehp_disable_slot(struct slot *p_slot)
706 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 591 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
707 if (ret || !getstatus) { 592 if (ret || !getstatus) {
708 info("%s: no adapter on slot(%s)\n", __FUNCTION__, 593 info("%s: no adapter on slot(%s)\n", __FUNCTION__,
709 slot_name(p_slot)); 594 p_slot->name);
710 mutex_unlock(&p_slot->ctrl->crit_sect); 595 mutex_unlock(&p_slot->ctrl->crit_sect);
711 return -ENODEV; 596 return -ENODEV;
712 } 597 }
@@ -716,7 +601,7 @@ int pciehp_disable_slot(struct slot *p_slot)
716 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 601 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
717 if (ret || getstatus) { 602 if (ret || getstatus) {
718 info("%s: latch open on slot(%s)\n", __FUNCTION__, 603 info("%s: latch open on slot(%s)\n", __FUNCTION__,
719 slot_name(p_slot)); 604 p_slot->name);
720 mutex_unlock(&p_slot->ctrl->crit_sect); 605 mutex_unlock(&p_slot->ctrl->crit_sect);
721 return -ENODEV; 606 return -ENODEV;
722 } 607 }
@@ -726,7 +611,7 @@ int pciehp_disable_slot(struct slot *p_slot)
726 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 611 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
727 if (ret || !getstatus) { 612 if (ret || !getstatus) {
728 info("%s: already disabled slot(%s)\n", __FUNCTION__, 613 info("%s: already disabled slot(%s)\n", __FUNCTION__,
729 slot_name(p_slot)); 614 p_slot->name);
730 mutex_unlock(&p_slot->ctrl->crit_sect); 615 mutex_unlock(&p_slot->ctrl->crit_sect);
731 return -EINVAL; 616 return -EINVAL;
732 } 617 }
@@ -739,3 +624,66 @@ int pciehp_disable_slot(struct slot *p_slot)
739 return ret; 624 return ret;
740} 625}
741 626
627int pciehp_sysfs_enable_slot(struct slot *p_slot)
628{
629 int retval = -ENODEV;
630
631 mutex_lock(&p_slot->lock);
632 switch (p_slot->state) {
633 case BLINKINGON_STATE:
634 cancel_delayed_work(&p_slot->work);
635 case STATIC_STATE:
636 p_slot->state = POWERON_STATE;
637 mutex_unlock(&p_slot->lock);
638 retval = pciehp_enable_slot(p_slot);
639 mutex_lock(&p_slot->lock);
640 p_slot->state = STATIC_STATE;
641 break;
642 case POWERON_STATE:
643 info("Slot %s is already in powering on state\n",
644 p_slot->name);
645 break;
646 case BLINKINGOFF_STATE:
647 case POWEROFF_STATE:
648 info("Already enabled on slot %s\n", p_slot->name);
649 break;
650 default:
651 err("Not a valid state on slot %s\n", p_slot->name);
652 break;
653 }
654 mutex_unlock(&p_slot->lock);
655
656 return retval;
657}
658
659int pciehp_sysfs_disable_slot(struct slot *p_slot)
660{
661 int retval = -ENODEV;
662
663 mutex_lock(&p_slot->lock);
664 switch (p_slot->state) {
665 case BLINKINGOFF_STATE:
666 cancel_delayed_work(&p_slot->work);
667 case STATIC_STATE:
668 p_slot->state = POWEROFF_STATE;
669 mutex_unlock(&p_slot->lock);
670 retval = pciehp_disable_slot(p_slot);
671 mutex_lock(&p_slot->lock);
672 p_slot->state = STATIC_STATE;
673 break;
674 case POWEROFF_STATE:
675 info("Slot %s is already in powering off state\n",
676 p_slot->name);
677 break;
678 case BLINKINGON_STATE:
679 case POWERON_STATE:
680 info("Already disabled on slot %s\n", p_slot->name);
681 break;
682 default:
683 err("Not a valid state on slot %s\n", p_slot->name);
684 break;
685 }
686 mutex_unlock(&p_slot->lock);
687
688 return retval;
689}
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index fbc64aa2dd68..9aac6a87eb53 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -71,6 +71,8 @@
71#define DBG_LEAVE_ROUTINE 71#define DBG_LEAVE_ROUTINE
72#endif /* DEBUG */ 72#endif /* DEBUG */
73 73
74static atomic_t pciehp_num_controllers = ATOMIC_INIT(0);
75
74struct ctrl_reg { 76struct ctrl_reg {
75 u8 cap_id; 77 u8 cap_id;
76 u8 nxt_ptr; 78 u8 nxt_ptr;
@@ -219,10 +221,7 @@ static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value)
219#define EMI_STATE 0x0080 221#define EMI_STATE 0x0080
220#define EMI_STATUS_BIT 7 222#define EMI_STATUS_BIT 7
221 223
222static spinlock_t hpc_event_lock;
223
224DEFINE_DBG_BUFFER /* Debug string buffer for entire HPC defined here */ 224DEFINE_DBG_BUFFER /* Debug string buffer for entire HPC defined here */
225static int ctlr_seq_num = 0; /* Controller sequence # */
226 225
227static irqreturn_t pcie_isr(int irq, void *dev_id); 226static irqreturn_t pcie_isr(int irq, void *dev_id);
228static void start_int_poll_timer(struct controller *ctrl, int sec); 227static void start_int_poll_timer(struct controller *ctrl, int sec);
@@ -656,6 +655,13 @@ static void hpc_release_ctlr(struct controller *ctrl)
656 else 655 else
657 free_irq(ctrl->pci_dev->irq, ctrl); 656 free_irq(ctrl->pci_dev->irq, ctrl);
658 657
658 /*
659 * If this is the last controller to be released, destroy the
660 * pciehp work queue
661 */
662 if (atomic_dec_and_test(&pciehp_num_controllers))
663 destroy_workqueue(pciehp_wq);
664
659 DBG_LEAVE_ROUTINE 665 DBG_LEAVE_ROUTINE
660} 666}
661 667
@@ -1152,7 +1158,6 @@ int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev)
1152int pcie_init(struct controller * ctrl, struct pcie_device *dev) 1158int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1153{ 1159{
1154 int rc; 1160 int rc;
1155 static int first = 1;
1156 u16 temp_word; 1161 u16 temp_word;
1157 u16 cap_reg; 1162 u16 cap_reg;
1158 u16 intr_enable = 0; 1163 u16 intr_enable = 0;
@@ -1221,11 +1226,6 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1221 dbg("%s: SLOTCTRL offset %x slot_ctrl %x\n", 1226 dbg("%s: SLOTCTRL offset %x slot_ctrl %x\n",
1222 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_ctrl); 1227 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_ctrl);
1223 1228
1224 if (first) {
1225 spin_lock_init(&hpc_event_lock);
1226 first = 0;
1227 }
1228
1229 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++) 1229 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++)
1230 if (pci_resource_len(pdev, rc) > 0) 1230 if (pci_resource_len(pdev, rc) > 0)
1231 dbg("pci resource[%d] start=0x%llx(len=0x%llx)\n", rc, 1231 dbg("pci resource[%d] start=0x%llx(len=0x%llx)\n", rc,
@@ -1286,7 +1286,8 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1286 rc = request_irq(ctrl->pci_dev->irq, pcie_isr, IRQF_SHARED, 1286 rc = request_irq(ctrl->pci_dev->irq, pcie_isr, IRQF_SHARED,
1287 MY_NAME, (void *)ctrl); 1287 MY_NAME, (void *)ctrl);
1288 dbg("%s: request_irq %d for hpc%d (returns %d)\n", 1288 dbg("%s: request_irq %d for hpc%d (returns %d)\n",
1289 __FUNCTION__, ctrl->pci_dev->irq, ctlr_seq_num, rc); 1289 __FUNCTION__, ctrl->pci_dev->irq,
1290 atomic_read(&pciehp_num_controllers), rc);
1290 if (rc) { 1291 if (rc) {
1291 err("Can't get irq %d for the hotplug controller\n", 1292 err("Can't get irq %d for the hotplug controller\n",
1292 ctrl->pci_dev->irq); 1293 ctrl->pci_dev->irq);
@@ -1296,6 +1297,18 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1296 dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev->bus->number, 1297 dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev->bus->number,
1297 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq); 1298 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq);
1298 1299
1300 /*
1301 * If this is the first controller to be initialized,
1302 * initialize the pciehp work queue
1303 */
1304 if (atomic_add_return(1, &pciehp_num_controllers) == 1) {
1305 pciehp_wq = create_singlethread_workqueue("pciehpd");
1306 if (!pciehp_wq) {
1307 rc = -ENOMEM;
1308 goto abort_free_irq;
1309 }
1310 }
1311
1299 rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word); 1312 rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word);
1300 if (rc) { 1313 if (rc) {
1301 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__); 1314 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
@@ -1349,7 +1362,6 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1349 goto abort_disable_intr; 1362 goto abort_disable_intr;
1350 } 1363 }
1351 1364
1352 ctlr_seq_num++;
1353 ctrl->hpc_ops = &pciehp_hpc_ops; 1365 ctrl->hpc_ops = &pciehp_hpc_ops;
1354 1366
1355 DBG_LEAVE_ROUTINE 1367 DBG_LEAVE_ROUTINE
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 72383467a0d5..bb3c101c2c5a 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -98,7 +98,15 @@ static struct device_node *find_dlpar_node(char *drc_name, int *node_type)
98 return NULL; 98 return NULL;
99} 99}
100 100
101static struct slot *find_slot(struct device_node *dn) 101/**
102 * find_php_slot - return hotplug slot structure for device node
103 *
104 * This routine will return the hotplug slot structure
105 * for a given device node. Note that built-in PCI slots
106 * may be dlpar-able, but not hot-pluggable, so this routine
107 * will return NULL for built-in PCI slots.
108 */
109static struct slot *find_php_slot(struct device_node *dn)
102{ 110{
103 struct list_head *tmp, *n; 111 struct list_head *tmp, *n;
104 struct slot *slot; 112 struct slot *slot;
@@ -224,9 +232,9 @@ static int dlpar_remove_phb(char *drc_name, struct device_node *dn)
224 if (!pcibios_find_pci_bus(dn)) 232 if (!pcibios_find_pci_bus(dn))
225 return -EINVAL; 233 return -EINVAL;
226 234
227 slot = find_slot(dn); 235 /* If pci slot is hotplugable, use hotplug to remove it */
236 slot = find_php_slot(dn);
228 if (slot) { 237 if (slot) {
229 /* Remove hotplug slot */
230 if (rpaphp_deregister_slot(slot)) { 238 if (rpaphp_deregister_slot(slot)) {
231 printk(KERN_ERR 239 printk(KERN_ERR
232 "%s: unable to remove hotplug slot %s\n", 240 "%s: unable to remove hotplug slot %s\n",
@@ -370,22 +378,17 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
370 if (!bus) 378 if (!bus)
371 return -EINVAL; 379 return -EINVAL;
372 380
373 slot = find_slot(dn); 381 /* If pci slot is hotplugable, use hotplug to remove it */
382 slot = find_php_slot(dn);
374 if (slot) { 383 if (slot) {
375 /* Remove hotplug slot */
376 if (rpaphp_deregister_slot(slot)) { 384 if (rpaphp_deregister_slot(slot)) {
377 printk(KERN_ERR 385 printk(KERN_ERR
378 "%s: unable to remove hotplug slot %s\n", 386 "%s: unable to remove hotplug slot %s\n",
379 __FUNCTION__, drc_name); 387 __FUNCTION__, drc_name);
380 return -EIO; 388 return -EIO;
381 } 389 }
382 } else { 390 } else
383 struct pci_dev *dev, *tmp; 391 pcibios_remove_pci_devices(bus);
384 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
385 eeh_remove_bus_device(dev);
386 pci_remove_bus_device(dev);
387 }
388 }
389 392
390 if (unmap_bus_range(bus)) { 393 if (unmap_bus_range(bus)) {
391 printk(KERN_ERR "%s: failed to unmap bus range\n", 394 printk(KERN_ERR "%s: failed to unmap bus range\n",
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 2e7accf0f734..c822a779653f 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -83,19 +83,15 @@ struct slot {
83 83
84extern struct hotplug_slot_ops rpaphp_hotplug_slot_ops; 84extern struct hotplug_slot_ops rpaphp_hotplug_slot_ops;
85extern struct list_head rpaphp_slot_head; 85extern struct list_head rpaphp_slot_head;
86extern int num_slots;
87 86
88/* function prototypes */ 87/* function prototypes */
89 88
90/* rpaphp_pci.c */ 89/* rpaphp_pci.c */
91extern int rpaphp_enable_pci_slot(struct slot *slot); 90extern int rpaphp_enable_slot(struct slot *slot);
92extern int rpaphp_register_pci_slot(struct slot *slot);
93extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value);
94extern int rpaphp_get_sensor_state(struct slot *slot, int *state); 91extern int rpaphp_get_sensor_state(struct slot *slot, int *state);
95 92
96/* rpaphp_core.c */ 93/* rpaphp_core.c */
97extern int rpaphp_add_slot(struct device_node *dn); 94extern int rpaphp_add_slot(struct device_node *dn);
98extern int rpaphp_remove_slot(struct slot *slot);
99extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, 95extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
100 char **drc_name, char **drc_type, int *drc_power_domain); 96 char **drc_name, char **drc_type, int *drc_power_domain);
101 97
@@ -104,7 +100,5 @@ extern void dealloc_slot_struct(struct slot *slot);
104extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain); 100extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
105extern int rpaphp_register_slot(struct slot *slot); 101extern int rpaphp_register_slot(struct slot *slot);
106extern int rpaphp_deregister_slot(struct slot *slot); 102extern int rpaphp_deregister_slot(struct slot *slot);
107extern int rpaphp_get_power_status(struct slot *slot, u8 * value);
108extern int rpaphp_set_attention_status(struct slot *slot, u8 status);
109 103
110#endif /* _PPC64PHP_H */ 104#endif /* _PPC64PHP_H */
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 71a2cb8baa4a..847936fe327e 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -39,9 +39,7 @@
39#include "rpaphp.h" 39#include "rpaphp.h"
40 40
41int debug; 41int debug;
42static struct semaphore rpaphp_sem;
43LIST_HEAD(rpaphp_slot_head); 42LIST_HEAD(rpaphp_slot_head);
44int num_slots;
45 43
46#define DRIVER_VERSION "0.1" 44#define DRIVER_VERSION "0.1"
47#define DRIVER_AUTHOR "Linda Xie <lxie@us.ibm.com>" 45#define DRIVER_AUTHOR "Linda Xie <lxie@us.ibm.com>"
@@ -55,11 +53,6 @@ MODULE_LICENSE("GPL");
55 53
56module_param(debug, bool, 0644); 54module_param(debug, bool, 0644);
57 55
58static int rpaphp_get_attention_status(struct slot *slot)
59{
60 return slot->hotplug_slot->info->attention_status;
61}
62
63/** 56/**
64 * set_attention_status - set attention LED 57 * set_attention_status - set attention LED
65 * echo 0 > attention -- set LED OFF 58 * echo 0 > attention -- set LED OFF
@@ -69,79 +62,75 @@ static int rpaphp_get_attention_status(struct slot *slot)
69 */ 62 */
70static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value) 63static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
71{ 64{
72 int retval = 0; 65 int rc;
73 struct slot *slot = (struct slot *)hotplug_slot->private; 66 struct slot *slot = (struct slot *)hotplug_slot->private;
74 67
75 down(&rpaphp_sem);
76 switch (value) { 68 switch (value) {
77 case 0: 69 case 0:
78 retval = rpaphp_set_attention_status(slot, LED_OFF);
79 hotplug_slot->info->attention_status = 0;
80 break;
81 case 1: 70 case 1:
82 default:
83 retval = rpaphp_set_attention_status(slot, LED_ON);
84 hotplug_slot->info->attention_status = 1;
85 break;
86 case 2: 71 case 2:
87 retval = rpaphp_set_attention_status(slot, LED_ID); 72 break;
88 hotplug_slot->info->attention_status = 2; 73 default:
74 value = 1;
89 break; 75 break;
90 } 76 }
91 up(&rpaphp_sem); 77
92 return retval; 78 rc = rtas_set_indicator(DR_INDICATOR, slot->index, value);
79 if (!rc)
80 hotplug_slot->info->attention_status = value;
81
82 return rc;
93} 83}
94 84
95/** 85/**
96 * get_power_status - get power status of a slot 86 * get_power_status - get power status of a slot
97 * @hotplug_slot: slot to get status 87 * @hotplug_slot: slot to get status
98 * @value: pointer to store status 88 * @value: pointer to store status
99 *
100 *
101 */ 89 */
102static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value) 90static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
103{ 91{
104 int retval; 92 int retval, level;
105 struct slot *slot = (struct slot *)hotplug_slot->private; 93 struct slot *slot = (struct slot *)hotplug_slot->private;
106 94
107 down(&rpaphp_sem); 95 retval = rtas_get_power_level (slot->power_domain, &level);
108 retval = rpaphp_get_power_status(slot, value); 96 if (!retval)
109 up(&rpaphp_sem); 97 *value = level;
110 return retval; 98 return retval;
111} 99}
112 100
113/** 101/**
114 * get_attention_status - get attention LED status 102 * get_attention_status - get attention LED status
115 *
116 *
117 */ 103 */
118static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value) 104static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
119{ 105{
120 int retval = 0;
121 struct slot *slot = (struct slot *)hotplug_slot->private; 106 struct slot *slot = (struct slot *)hotplug_slot->private;
122 107 *value = slot->hotplug_slot->info->attention_status;
123 down(&rpaphp_sem); 108 return 0;
124 *value = rpaphp_get_attention_status(slot);
125 up(&rpaphp_sem);
126 return retval;
127} 109}
128 110
129static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value) 111static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
130{ 112{
131 struct slot *slot = (struct slot *)hotplug_slot->private; 113 struct slot *slot = (struct slot *)hotplug_slot->private;
132 int retval = 0; 114 int rc, state;
133 115
134 down(&rpaphp_sem); 116 rc = rpaphp_get_sensor_state(slot, &state);
135 retval = rpaphp_get_pci_adapter_status(slot, 0, value); 117
136 up(&rpaphp_sem); 118 *value = NOT_VALID;
137 return retval; 119 if (rc)
120 return rc;
121
122 if (state == EMPTY)
123 *value = EMPTY;
124 else if (state == PRESENT)
125 *value = slot->state;
126
127 return 0;
138} 128}
139 129
140static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) 130static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
141{ 131{
142 struct slot *slot = (struct slot *)hotplug_slot->private; 132 struct slot *slot = (struct slot *)hotplug_slot->private;
143 133
144 down(&rpaphp_sem);
145 switch (slot->type) { 134 switch (slot->type) {
146 case 1: 135 case 1:
147 case 2: 136 case 2:
@@ -172,7 +161,6 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
172 break; 161 break;
173 162
174 } 163 }
175 up(&rpaphp_sem);
176 return 0; 164 return 0;
177} 165}
178 166
@@ -265,6 +253,14 @@ static int is_php_type(char *drc_type)
265 return 1; 253 return 1;
266} 254}
267 255
256/**
257 * is_php_dn() - return 1 if this is a hotpluggable pci slot, else 0
258 *
259 * This routine will return true only if the device node is
260 * a hotpluggable slot. This routine will return false
261 * for built-in pci slots (even when the built-in slots are
262 * dlparable.)
263 */
268static int is_php_dn(struct device_node *dn, const int **indexes, 264static int is_php_dn(struct device_node *dn, const int **indexes,
269 const int **names, const int **types, const int **power_domains) 265 const int **names, const int **types, const int **power_domains)
270{ 266{
@@ -272,24 +268,31 @@ static int is_php_dn(struct device_node *dn, const int **indexes,
272 int rc; 268 int rc;
273 269
274 rc = get_children_props(dn, indexes, names, &drc_types, power_domains); 270 rc = get_children_props(dn, indexes, names, &drc_types, power_domains);
275 if (rc >= 0) { 271 if (rc < 0)
276 if (is_php_type((char *) &drc_types[1])) { 272 return 0;
277 *types = drc_types;
278 return 1;
279 }
280 }
281 273
282 return 0; 274 if (!is_php_type((char *) &drc_types[1]))
275 return 0;
276
277 *types = drc_types;
278 return 1;
283} 279}
284 280
285/** 281/**
286 * rpaphp_add_slot -- add hotplug or dlpar slot 282 * rpaphp_add_slot -- declare a hotplug slot to the hotplug subsystem.
283 * @dn device node of slot
284 *
285 * This subroutine will register a hotplugable slot with the
286 * PCI hotplug infrastructure. This routine is typicaly called
287 * during boot time, if the hotplug slots are present at boot time,
288 * or is called later, by the dlpar add code, if the slot is
289 * being dynamically added during runtime.
290 *
291 * If the device node points at an embedded (built-in) slot, this
292 * routine will just return without doing anything, since embedded
293 * slots cannot be hotplugged.
287 * 294 *
288 * rpaphp not only registers PCI hotplug slots(HOTPLUG), 295 * To remove a slot, it suffices to call rpaphp_deregister_slot()
289 * but also logical DR slots(EMBEDDED).
290 * HOTPLUG slot: An adapter can be physically added/removed.
291 * EMBEDDED slot: An adapter can be logically removed/added
292 * from/to a partition with the slot.
293 */ 296 */
294int rpaphp_add_slot(struct device_node *dn) 297int rpaphp_add_slot(struct device_node *dn)
295{ 298{
@@ -299,34 +302,42 @@ int rpaphp_add_slot(struct device_node *dn)
299 const int *indexes, *names, *types, *power_domains; 302 const int *indexes, *names, *types, *power_domains;
300 char *name, *type; 303 char *name, *type;
301 304
305 if (!dn->name || strcmp(dn->name, "pci"))
306 return 0;
307
308 /* If this is not a hotplug slot, return without doing anything. */
309 if (!is_php_dn(dn, &indexes, &names, &types, &power_domains))
310 return 0;
311
302 dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name); 312 dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name);
303 313
304 /* register PCI devices */ 314 /* register PCI devices */
305 if (dn->name != 0 && strcmp(dn->name, "pci") == 0) { 315 name = (char *) &names[1];
306 if (!is_php_dn(dn, &indexes, &names, &types, &power_domains)) 316 type = (char *) &types[1];
307 goto exit; 317 for (i = 0; i < indexes[0]; i++) {
308 318
309 name = (char *) &names[1]; 319 slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]);
310 type = (char *) &types[1]; 320 if (!slot)
311 for (i = 0; i < indexes[0]; i++, 321 return -ENOMEM;
312 name += (strlen(name) + 1), type += (strlen(type) + 1)) { 322
313 323 slot->type = simple_strtoul(type, NULL, 10);
314 if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name,
315 power_domains[i + 1]))) {
316 retval = -ENOMEM;
317 goto exit;
318 }
319 slot->type = simple_strtoul(type, NULL, 10);
320 324
321 dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n", 325 dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n",
322 indexes[i + 1], name, type); 326 indexes[i + 1], name, type);
323 327
324 retval = rpaphp_register_pci_slot(slot); 328 retval = rpaphp_enable_slot(slot);
325 } 329 if (!retval)
330 retval = rpaphp_register_slot(slot);
331
332 if (retval)
333 dealloc_slot_struct(slot);
334
335 name += strlen(name) + 1;
336 type += strlen(type) + 1;
326 } 337 }
327exit: 338 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
328 dbg("%s - Exit: num_slots=%d rc[%d]\n", 339
329 __FUNCTION__, num_slots, retval); 340 /* XXX FIXME: reports a failure only if last entry in loop failed */
330 return retval; 341 return retval;
331} 342}
332 343
@@ -354,7 +365,6 @@ static int __init rpaphp_init(void)
354 struct device_node *dn = NULL; 365 struct device_node *dn = NULL;
355 366
356 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 367 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
357 init_MUTEX(&rpaphp_sem);
358 368
359 while ((dn = of_find_node_by_name(dn, "pci"))) 369 while ((dn = of_find_node_by_name(dn, "pci")))
360 rpaphp_add_slot(dn); 370 rpaphp_add_slot(dn);
@@ -367,8 +377,9 @@ static void __exit rpaphp_exit(void)
367 cleanup_slots(); 377 cleanup_slots();
368} 378}
369 379
370static int __enable_slot(struct slot *slot) 380static int enable_slot(struct hotplug_slot *hotplug_slot)
371{ 381{
382 struct slot *slot = (struct slot *)hotplug_slot->private;
372 int state; 383 int state;
373 int retval; 384 int retval;
374 385
@@ -392,46 +403,17 @@ static int __enable_slot(struct slot *slot)
392 return 0; 403 return 0;
393} 404}
394 405
395static int enable_slot(struct hotplug_slot *hotplug_slot) 406static int disable_slot(struct hotplug_slot *hotplug_slot)
396{ 407{
397 int retval;
398 struct slot *slot = (struct slot *)hotplug_slot->private; 408 struct slot *slot = (struct slot *)hotplug_slot->private;
399
400 down(&rpaphp_sem);
401 retval = __enable_slot(slot);
402 up(&rpaphp_sem);
403
404 return retval;
405}
406
407static int __disable_slot(struct slot *slot)
408{
409 struct pci_dev *dev, *tmp;
410
411 if (slot->state == NOT_CONFIGURED) 409 if (slot->state == NOT_CONFIGURED)
412 return -EINVAL; 410 return -EINVAL;
413 411
414 list_for_each_entry_safe(dev, tmp, &slot->bus->devices, bus_list) { 412 pcibios_remove_pci_devices(slot->bus);
415 eeh_remove_bus_device(dev);
416 pci_remove_bus_device(dev);
417 }
418
419 slot->state = NOT_CONFIGURED; 413 slot->state = NOT_CONFIGURED;
420 return 0; 414 return 0;
421} 415}
422 416
423static int disable_slot(struct hotplug_slot *hotplug_slot)
424{
425 struct slot *slot = (struct slot *)hotplug_slot->private;
426 int retval;
427
428 down(&rpaphp_sem);
429 retval = __disable_slot (slot);
430 up(&rpaphp_sem);
431
432 return retval;
433}
434
435struct hotplug_slot_ops rpaphp_hotplug_slot_ops = { 417struct hotplug_slot_ops rpaphp_hotplug_slot_ops = {
436 .owner = THIS_MODULE, 418 .owner = THIS_MODULE,
437 .enable_slot = enable_slot, 419 .enable_slot = enable_slot,
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 6f6cbede5135..54ca8650d511 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -64,75 +64,6 @@ int rpaphp_get_sensor_state(struct slot *slot, int *state)
64 return rc; 64 return rc;
65} 65}
66 66
67/**
68 * get_pci_adapter_status - get the status of a slot
69 *
70 * 0-- slot is empty
71 * 1-- adapter is configured
72 * 2-- adapter is not configured
73 * 3-- not valid
74 */
75int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value)
76{
77 struct pci_bus *bus;
78 int state, rc;
79
80 *value = NOT_VALID;
81 rc = rpaphp_get_sensor_state(slot, &state);
82 if (rc)
83 goto exit;
84
85 if (state == EMPTY)
86 *value = EMPTY;
87 else if (state == PRESENT) {
88 if (!is_init) {
89 /* at run-time slot->state can be changed by */
90 /* config/unconfig adapter */
91 *value = slot->state;
92 } else {
93 bus = pcibios_find_pci_bus(slot->dn);
94 if (bus && !list_empty(&bus->devices))
95 *value = CONFIGURED;
96 else
97 *value = NOT_CONFIGURED;
98 }
99 }
100exit:
101 return rc;
102}
103
104static void print_slot_pci_funcs(struct pci_bus *bus)
105{
106 struct device_node *dn;
107 struct pci_dev *dev;
108
109 dn = pci_bus_to_OF_node(bus);
110 if (!dn)
111 return;
112
113 dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, dn->full_name);
114 list_for_each_entry (dev, &bus->devices, bus_list)
115 dbg("\t%s\n", pci_name(dev));
116 return;
117}
118
119static int setup_pci_hotplug_slot_info(struct slot *slot)
120{
121 struct hotplug_slot_info *hotplug_slot_info = slot->hotplug_slot->info;
122
123 dbg("%s Initilize the PCI slot's hotplug->info structure ...\n",
124 __FUNCTION__);
125 rpaphp_get_power_status(slot, &hotplug_slot_info->power_status);
126 rpaphp_get_pci_adapter_status(slot, 1,
127 &hotplug_slot_info->adapter_status);
128 if (hotplug_slot_info->adapter_status == NOT_VALID) {
129 err("%s: NOT_VALID: skip dn->full_name=%s\n",
130 __FUNCTION__, slot->dn->full_name);
131 return -EINVAL;
132 }
133 return 0;
134}
135
136static void set_slot_name(struct slot *slot) 67static void set_slot_name(struct slot *slot)
137{ 68{
138 struct pci_bus *bus = slot->bus; 69 struct pci_bus *bus = slot->bus;
@@ -146,69 +77,73 @@ static void set_slot_name(struct slot *slot)
146 bus->number); 77 bus->number);
147} 78}
148 79
149static int setup_pci_slot(struct slot *slot) 80/**
81 * rpaphp_enable_slot - record slot state, config pci device
82 *
83 * Initialize values in the slot, and the hotplug_slot info
84 * structures to indicate if there is a pci card plugged into
85 * the slot. If the slot is not empty, run the pcibios routine
86 * to get pcibios stuff correctly set up.
87 */
88int rpaphp_enable_slot(struct slot *slot)
150{ 89{
151 struct device_node *dn = slot->dn; 90 int rc, level, state;
152 struct pci_bus *bus; 91 struct pci_bus *bus;
92 struct hotplug_slot_info *info = slot->hotplug_slot->info;
93
94 info->adapter_status = NOT_VALID;
95 slot->state = EMPTY;
96
97 /* Find out if the power is turned on for the slot */
98 rc = rtas_get_power_level(slot->power_domain, &level);
99 if (rc)
100 return rc;
101 info->power_status = level;
102
103 /* Figure out if there is an adapter in the slot */
104 rc = rpaphp_get_sensor_state(slot, &state);
105 if (rc)
106 return rc;
153 107
154 BUG_ON(!dn); 108 bus = pcibios_find_pci_bus(slot->dn);
155 bus = pcibios_find_pci_bus(dn);
156 if (!bus) { 109 if (!bus) {
157 err("%s: no pci_bus for dn %s\n", __FUNCTION__, dn->full_name); 110 err("%s: no pci_bus for dn %s\n", __FUNCTION__, slot->dn->full_name);
158 goto exit_rc; 111 return -EINVAL;
159 } 112 }
160 113
114 info->adapter_status = EMPTY;
161 slot->bus = bus; 115 slot->bus = bus;
162 slot->pci_devs = &bus->devices; 116 slot->pci_devs = &bus->devices;
163 set_slot_name(slot); 117 set_slot_name(slot);
164 118
165 /* find slot's pci_dev if it's not empty */ 119 /* if there's an adapter in the slot, go add the pci devices */
166 if (slot->hotplug_slot->info->adapter_status == EMPTY) { 120 if (state == PRESENT) {
167 slot->state = EMPTY; /* slot is empty */ 121 info->adapter_status = NOT_CONFIGURED;
168 } else { 122 slot->state = NOT_CONFIGURED;
169 /* slot is occupied */ 123
170 if (!dn->child) { 124 /* non-empty slot has to have child */
171 /* non-empty slot has to have child */ 125 if (!slot->dn->child) {
172 err("%s: slot[%s]'s device_node doesn't have child for adapter\n", 126 err("%s: slot[%s]'s device_node doesn't have child for adapter\n",
173 __FUNCTION__, slot->name); 127 __FUNCTION__, slot->name);
174 goto exit_rc; 128 return -EINVAL;
175 } 129 }
176 130
177 if (slot->hotplug_slot->info->adapter_status == NOT_CONFIGURED) { 131 if (list_empty(&bus->devices))
178 dbg("%s CONFIGURING pci adapter in slot[%s]\n", 132 pcibios_add_pci_devices(bus);
179 __FUNCTION__, slot->name);
180 pcibios_add_pci_devices(slot->bus);
181 133
182 } else if (slot->hotplug_slot->info->adapter_status != CONFIGURED) { 134 if (!list_empty(&bus->devices)) {
183 err("%s: slot[%s]'s adapter_status is NOT_VALID.\n", 135 info->adapter_status = CONFIGURED;
184 __FUNCTION__, slot->name);
185 goto exit_rc;
186 }
187 print_slot_pci_funcs(slot->bus);
188 if (!list_empty(slot->pci_devs)) {
189 slot->state = CONFIGURED; 136 slot->state = CONFIGURED;
190 } else { 137 }
191 /* DLPAR add as opposed to 138
192 * boot time */ 139 if (debug) {
193 slot->state = NOT_CONFIGURED; 140 struct pci_dev *dev;
141 dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, slot->dn->full_name);
142 list_for_each_entry (dev, &bus->devices, bus_list)
143 dbg("\t%s\n", pci_name(dev));
194 } 144 }
195 } 145 }
196 return 0;
197exit_rc:
198 dealloc_slot_struct(slot);
199 return -EINVAL;
200}
201 146
202int rpaphp_register_pci_slot(struct slot *slot) 147 return 0;
203{
204 int rc = -EINVAL;
205
206 if (setup_pci_hotplug_slot_info(slot))
207 goto exit_rc;
208 if (setup_pci_slot(slot))
209 goto exit_rc;
210 rc = rpaphp_register_slot(slot);
211exit_rc:
212 return rc;
213} 148}
214 149
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 3009193f0058..d4ee8723fcb3 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -56,7 +56,6 @@ static struct hotplug_slot_attribute php_attr_location = {
56static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot) 56static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot)
57{ 57{
58 struct slot *slot = (struct slot *) hotplug_slot->private; 58 struct slot *slot = (struct slot *) hotplug_slot->private;
59
60 dealloc_slot_struct(slot); 59 dealloc_slot_struct(slot);
61} 60}
62 61
@@ -65,12 +64,12 @@ void dealloc_slot_struct(struct slot *slot)
65 kfree(slot->hotplug_slot->info); 64 kfree(slot->hotplug_slot->info);
66 kfree(slot->hotplug_slot->name); 65 kfree(slot->hotplug_slot->name);
67 kfree(slot->hotplug_slot); 66 kfree(slot->hotplug_slot);
67 kfree(slot->location);
68 kfree(slot); 68 kfree(slot);
69 return;
70} 69}
71 70
72struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, 71struct slot *alloc_slot_struct(struct device_node *dn,
73 int power_domain) 72 int drc_index, char *drc_name, int power_domain)
74{ 73{
75 struct slot *slot; 74 struct slot *slot;
76 75
@@ -115,7 +114,7 @@ error_nomem:
115 114
116static int is_registered(struct slot *slot) 115static int is_registered(struct slot *slot)
117{ 116{
118 struct slot *tmp_slot; 117 struct slot *tmp_slot;
119 118
120 list_for_each_entry(tmp_slot, &rpaphp_slot_head, rpaphp_slot_list) { 119 list_for_each_entry(tmp_slot, &rpaphp_slot_head, rpaphp_slot_list) {
121 if (!strcmp(tmp_slot->name, slot->name)) 120 if (!strcmp(tmp_slot->name, slot->name))
@@ -140,8 +139,6 @@ int rpaphp_deregister_slot(struct slot *slot)
140 retval = pci_hp_deregister(php_slot); 139 retval = pci_hp_deregister(php_slot);
141 if (retval) 140 if (retval)
142 err("Problem unregistering a slot %s\n", slot->name); 141 err("Problem unregistering a slot %s\n", slot->name);
143 else
144 num_slots--;
145 142
146 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); 143 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
147 return retval; 144 return retval;
@@ -160,14 +157,13 @@ int rpaphp_register_slot(struct slot *slot)
160 /* should not try to register the same slot twice */ 157 /* should not try to register the same slot twice */
161 if (is_registered(slot)) { 158 if (is_registered(slot)) {
162 err("rpaphp_register_slot: slot[%s] is already registered\n", slot->name); 159 err("rpaphp_register_slot: slot[%s] is already registered\n", slot->name);
163 retval = -EAGAIN; 160 return -EAGAIN;
164 goto register_fail;
165 } 161 }
166 162
167 retval = pci_hp_register(php_slot); 163 retval = pci_hp_register(php_slot);
168 if (retval) { 164 if (retval) {
169 err("pci_hp_register failed with error %d\n", retval); 165 err("pci_hp_register failed with error %d\n", retval);
170 goto register_fail; 166 return retval;
171 } 167 }
172 168
173 /* create "phy_location" file */ 169 /* create "phy_location" file */
@@ -181,43 +177,10 @@ int rpaphp_register_slot(struct slot *slot)
181 list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head); 177 list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head);
182 info("Slot [%s](PCI location=%s) registered\n", slot->name, 178 info("Slot [%s](PCI location=%s) registered\n", slot->name,
183 slot->location); 179 slot->location);
184 num_slots++;
185 return 0; 180 return 0;
186 181
187sysfs_fail: 182sysfs_fail:
188 pci_hp_deregister(php_slot); 183 pci_hp_deregister(php_slot);
189register_fail:
190 rpaphp_release_slot(php_slot);
191 return retval; 184 return retval;
192} 185}
193 186
194int rpaphp_get_power_status(struct slot *slot, u8 * value)
195{
196 int rc = 0, level;
197
198 rc = rtas_get_power_level(slot->power_domain, &level);
199 if (rc < 0) {
200 err("failed to get power-level for slot(%s), rc=0x%x\n",
201 slot->location, rc);
202 return rc;
203 }
204
205 dbg("%s the power level of slot %s(pwd-domain:0x%x) is %d\n",
206 __FUNCTION__, slot->name, slot->power_domain, level);
207 *value = level;
208
209 return rc;
210}
211
212int rpaphp_set_attention_status(struct slot *slot, u8 status)
213{
214 int rc;
215
216 /* status: LED_OFF or LED_ON */
217 rc = rtas_set_indicator(DR_INDICATOR, slot->index, status);
218 if (rc < 0)
219 err("slot(name=%s location=%s index=0x%x) set attention-status(%d) failed! rc=0x%x\n",
220 slot->name, slot->location, slot->index, status, rc);
221
222 return rc;
223}
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 01d31a1f697c..37ed0884b972 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -166,7 +166,7 @@ extern u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl);
166extern int shpchp_configure_device(struct slot *p_slot); 166extern int shpchp_configure_device(struct slot *p_slot);
167extern int shpchp_unconfigure_device(struct slot *p_slot); 167extern int shpchp_unconfigure_device(struct slot *p_slot);
168extern void cleanup_slots(struct controller *ctrl); 168extern void cleanup_slots(struct controller *ctrl);
169extern void queue_pushbutton_work(struct work_struct *work); 169extern void shpchp_queue_pushbutton_work(struct work_struct *work);
170extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev); 170extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
171 171
172#ifdef CONFIG_ACPI 172#ifdef CONFIG_ACPI
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 5f4bc08a633a..80dec9796b31 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -136,7 +136,7 @@ static int init_slots(struct controller *ctrl)
136 slot->hpc_ops = ctrl->hpc_ops; 136 slot->hpc_ops = ctrl->hpc_ops;
137 slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i); 137 slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i);
138 mutex_init(&slot->lock); 138 mutex_init(&slot->lock);
139 INIT_DELAYED_WORK(&slot->work, queue_pushbutton_work); 139 INIT_DELAYED_WORK(&slot->work, shpchp_queue_pushbutton_work);
140 140
141 /* register this slot with the hotplug pci core */ 141 /* register this slot with the hotplug pci core */
142 hotplug_slot->private = slot; 142 hotplug_slot->private = slot;
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index b746bd265bc6..2c94d44279a3 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -433,7 +433,7 @@ static void shpchp_pushbutton_thread(struct work_struct *work)
433 kfree(info); 433 kfree(info);
434} 434}
435 435
436void queue_pushbutton_work(struct work_struct *work) 436void shpchp_queue_pushbutton_work(struct work_struct *work)
437{ 437{
438 struct slot *p_slot = container_of(work, struct slot, work.work); 438 struct slot *p_slot = container_of(work, struct slot, work.work);
439 struct pushbutton_work_info *info; 439 struct pushbutton_work_info *info;
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 435c1958a7b7..9e1321d0d5e6 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -24,20 +24,8 @@
24#include "pci.h" 24#include "pci.h"
25#include "msi.h" 25#include "msi.h"
26 26
27static struct kmem_cache* msi_cachep;
28
29static int pci_msi_enable = 1; 27static int pci_msi_enable = 1;
30 28
31static int msi_cache_init(void)
32{
33 msi_cachep = kmem_cache_create("msi_cache", sizeof(struct msi_desc),
34 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
35 if (!msi_cachep)
36 return -ENOMEM;
37
38 return 0;
39}
40
41static void msi_set_enable(struct pci_dev *dev, int enable) 29static void msi_set_enable(struct pci_dev *dev, int enable)
42{ 30{
43 int pos; 31 int pos;
@@ -68,6 +56,29 @@ static void msix_set_enable(struct pci_dev *dev, int enable)
68 } 56 }
69} 57}
70 58
59static void msix_flush_writes(unsigned int irq)
60{
61 struct msi_desc *entry;
62
63 entry = get_irq_msi(irq);
64 BUG_ON(!entry || !entry->dev);
65 switch (entry->msi_attrib.type) {
66 case PCI_CAP_ID_MSI:
67 /* nothing to do */
68 break;
69 case PCI_CAP_ID_MSIX:
70 {
71 int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
72 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET;
73 readl(entry->mask_base + offset);
74 break;
75 }
76 default:
77 BUG();
78 break;
79 }
80}
81
71static void msi_set_mask_bit(unsigned int irq, int flag) 82static void msi_set_mask_bit(unsigned int irq, int flag)
72{ 83{
73 struct msi_desc *entry; 84 struct msi_desc *entry;
@@ -187,41 +198,28 @@ void write_msi_msg(unsigned int irq, struct msi_msg *msg)
187void mask_msi_irq(unsigned int irq) 198void mask_msi_irq(unsigned int irq)
188{ 199{
189 msi_set_mask_bit(irq, 1); 200 msi_set_mask_bit(irq, 1);
201 msix_flush_writes(irq);
190} 202}
191 203
192void unmask_msi_irq(unsigned int irq) 204void unmask_msi_irq(unsigned int irq)
193{ 205{
194 msi_set_mask_bit(irq, 0); 206 msi_set_mask_bit(irq, 0);
207 msix_flush_writes(irq);
195} 208}
196 209
197static int msi_free_irq(struct pci_dev* dev, int irq); 210static int msi_free_irqs(struct pci_dev* dev);
198
199static int msi_init(void)
200{
201 static int status = -ENOMEM;
202
203 if (!status)
204 return status;
205 211
206 status = msi_cache_init();
207 if (status < 0) {
208 pci_msi_enable = 0;
209 printk(KERN_WARNING "PCI: MSI cache init failed\n");
210 return status;
211 }
212
213 return status;
214}
215 212
216static struct msi_desc* alloc_msi_entry(void) 213static struct msi_desc* alloc_msi_entry(void)
217{ 214{
218 struct msi_desc *entry; 215 struct msi_desc *entry;
219 216
220 entry = kmem_cache_zalloc(msi_cachep, GFP_KERNEL); 217 entry = kzalloc(sizeof(struct msi_desc), GFP_KERNEL);
221 if (!entry) 218 if (!entry)
222 return NULL; 219 return NULL;
223 220
224 entry->link.tail = entry->link.head = 0; /* single message */ 221 INIT_LIST_HEAD(&entry->list);
222 entry->irq = 0;
225 entry->dev = NULL; 223 entry->dev = NULL;
226 224
227 return entry; 225 return entry;
@@ -256,7 +254,6 @@ static void __pci_restore_msi_state(struct pci_dev *dev)
256static void __pci_restore_msix_state(struct pci_dev *dev) 254static void __pci_restore_msix_state(struct pci_dev *dev)
257{ 255{
258 int pos; 256 int pos;
259 int irq, head, tail = 0;
260 struct msi_desc *entry; 257 struct msi_desc *entry;
261 u16 control; 258 u16 control;
262 259
@@ -266,18 +263,15 @@ static void __pci_restore_msix_state(struct pci_dev *dev)
266 /* route the table */ 263 /* route the table */
267 pci_intx(dev, 0); /* disable intx */ 264 pci_intx(dev, 0); /* disable intx */
268 msix_set_enable(dev, 0); 265 msix_set_enable(dev, 0);
269 irq = head = dev->first_msi_irq;
270 entry = get_irq_msi(irq);
271 pos = entry->msi_attrib.pos;
272 while (head != tail) {
273 entry = get_irq_msi(irq);
274 write_msi_msg(irq, &entry->msg);
275 msi_set_mask_bit(irq, entry->msi_attrib.masked);
276 266
277 tail = entry->link.tail; 267 list_for_each_entry(entry, &dev->msi_list, list) {
278 irq = tail; 268 write_msi_msg(entry->irq, &entry->msg);
269 msi_set_mask_bit(entry->irq, entry->msi_attrib.masked);
279 } 270 }
280 271
272 BUG_ON(list_empty(&dev->msi_list));
273 entry = list_entry(dev->msi_list.next, struct msi_desc, list);
274 pos = entry->msi_attrib.pos;
281 pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control); 275 pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control);
282 control &= ~PCI_MSIX_FLAGS_MASKALL; 276 control &= ~PCI_MSIX_FLAGS_MASKALL;
283 control |= PCI_MSIX_FLAGS_ENABLE; 277 control |= PCI_MSIX_FLAGS_ENABLE;
@@ -303,7 +297,7 @@ void pci_restore_msi_state(struct pci_dev *dev)
303static int msi_capability_init(struct pci_dev *dev) 297static int msi_capability_init(struct pci_dev *dev)
304{ 298{
305 struct msi_desc *entry; 299 struct msi_desc *entry;
306 int pos, irq; 300 int pos, ret;
307 u16 control; 301 u16 control;
308 302
309 msi_set_enable(dev, 0); /* Ensure msi is disabled as I set it up */ 303 msi_set_enable(dev, 0); /* Ensure msi is disabled as I set it up */
@@ -340,23 +334,21 @@ static int msi_capability_init(struct pci_dev *dev)
340 msi_mask_bits_reg(pos, is_64bit_address(control)), 334 msi_mask_bits_reg(pos, is_64bit_address(control)),
341 maskbits); 335 maskbits);
342 } 336 }
337 list_add(&entry->list, &dev->msi_list);
338
343 /* Configure MSI capability structure */ 339 /* Configure MSI capability structure */
344 irq = arch_setup_msi_irq(dev, entry); 340 ret = arch_setup_msi_irqs(dev, 1, PCI_CAP_ID_MSI);
345 if (irq < 0) { 341 if (ret) {
346 kmem_cache_free(msi_cachep, entry); 342 msi_free_irqs(dev);
347 return irq; 343 return ret;
348 } 344 }
349 entry->link.head = irq;
350 entry->link.tail = irq;
351 dev->first_msi_irq = irq;
352 set_irq_msi(irq, entry);
353 345
354 /* Set MSI enabled bits */ 346 /* Set MSI enabled bits */
355 pci_intx(dev, 0); /* disable intx */ 347 pci_intx(dev, 0); /* disable intx */
356 msi_set_enable(dev, 1); 348 msi_set_enable(dev, 1);
357 dev->msi_enabled = 1; 349 dev->msi_enabled = 1;
358 350
359 dev->irq = irq; 351 dev->irq = entry->irq;
360 return 0; 352 return 0;
361} 353}
362 354
@@ -373,8 +365,8 @@ static int msi_capability_init(struct pci_dev *dev)
373static int msix_capability_init(struct pci_dev *dev, 365static int msix_capability_init(struct pci_dev *dev,
374 struct msix_entry *entries, int nvec) 366 struct msix_entry *entries, int nvec)
375{ 367{
376 struct msi_desc *head = NULL, *tail = NULL, *entry = NULL; 368 struct msi_desc *entry;
377 int irq, pos, i, j, nr_entries, temp = 0; 369 int pos, i, j, nr_entries, ret;
378 unsigned long phys_addr; 370 unsigned long phys_addr;
379 u32 table_offset; 371 u32 table_offset;
380 u16 control; 372 u16 control;
@@ -413,44 +405,34 @@ static int msix_capability_init(struct pci_dev *dev,
413 entry->dev = dev; 405 entry->dev = dev;
414 entry->mask_base = base; 406 entry->mask_base = base;
415 407
416 /* Configure MSI-X capability structure */ 408 list_add(&entry->list, &dev->msi_list);
417 irq = arch_setup_msi_irq(dev, entry);
418 if (irq < 0) {
419 kmem_cache_free(msi_cachep, entry);
420 break;
421 }
422 entries[i].vector = irq;
423 if (!head) {
424 entry->link.head = irq;
425 entry->link.tail = irq;
426 head = entry;
427 } else {
428 entry->link.head = temp;
429 entry->link.tail = tail->link.tail;
430 tail->link.tail = irq;
431 head->link.head = irq;
432 }
433 temp = irq;
434 tail = entry;
435
436 set_irq_msi(irq, entry);
437 } 409 }
438 if (i != nvec) { 410
439 int avail = i - 1; 411 ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
440 i--; 412 if (ret) {
441 for (; i >= 0; i--) { 413 int avail = 0;
442 irq = (entries + i)->vector; 414 list_for_each_entry(entry, &dev->msi_list, list) {
443 msi_free_irq(dev, irq); 415 if (entry->irq != 0) {
444 (entries + i)->vector = 0; 416 avail++;
417 }
445 } 418 }
419
420 msi_free_irqs(dev);
421
446 /* If we had some success report the number of irqs 422 /* If we had some success report the number of irqs
447 * we succeeded in setting up. 423 * we succeeded in setting up.
448 */ 424 */
449 if (avail <= 0) 425 if (avail == 0)
450 avail = -EBUSY; 426 avail = ret;
451 return avail; 427 return avail;
452 } 428 }
453 dev->first_msi_irq = entries[0].vector; 429
430 i = 0;
431 list_for_each_entry(entry, &dev->msi_list, list) {
432 entries[i].vector = entry->irq;
433 set_irq_msi(entry->irq, entry);
434 i++;
435 }
454 /* Set MSI-X enabled bits */ 436 /* Set MSI-X enabled bits */
455 pci_intx(dev, 0); /* disable intx */ 437 pci_intx(dev, 0); /* disable intx */
456 msix_set_enable(dev, 1); 438 msix_set_enable(dev, 1);
@@ -460,21 +442,32 @@ static int msix_capability_init(struct pci_dev *dev,
460} 442}
461 443
462/** 444/**
463 * pci_msi_supported - check whether MSI may be enabled on device 445 * pci_msi_check_device - check whether MSI may be enabled on a device
464 * @dev: pointer to the pci_dev data structure of MSI device function 446 * @dev: pointer to the pci_dev data structure of MSI device function
447 * @nvec: how many MSIs have been requested ?
448 * @type: are we checking for MSI or MSI-X ?
465 * 449 *
466 * Look at global flags, the device itself, and its parent busses 450 * Look at global flags, the device itself, and its parent busses
467 * to return 0 if MSI are supported for the device. 451 * to determine if MSI/-X are supported for the device. If MSI/-X is
452 * supported return 0, else return an error code.
468 **/ 453 **/
469static 454static int pci_msi_check_device(struct pci_dev* dev, int nvec, int type)
470int pci_msi_supported(struct pci_dev * dev)
471{ 455{
472 struct pci_bus *bus; 456 struct pci_bus *bus;
457 int ret;
473 458
474 /* MSI must be globally enabled and supported by the device */ 459 /* MSI must be globally enabled and supported by the device */
475 if (!pci_msi_enable || !dev || dev->no_msi) 460 if (!pci_msi_enable || !dev || dev->no_msi)
476 return -EINVAL; 461 return -EINVAL;
477 462
463 /*
464 * You can't ask to have 0 or less MSIs configured.
465 * a) it's stupid ..
466 * b) the list manipulation code assumes nvec >= 1.
467 */
468 if (nvec < 1)
469 return -ERANGE;
470
478 /* Any bridge which does NOT route MSI transactions from it's 471 /* Any bridge which does NOT route MSI transactions from it's
479 * secondary bus to it's primary bus must set NO_MSI flag on 472 * secondary bus to it's primary bus must set NO_MSI flag on
480 * the secondary pci_bus. 473 * the secondary pci_bus.
@@ -485,6 +478,13 @@ int pci_msi_supported(struct pci_dev * dev)
485 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI) 478 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
486 return -EINVAL; 479 return -EINVAL;
487 480
481 ret = arch_msi_check_device(dev, nvec, type);
482 if (ret)
483 return ret;
484
485 if (!pci_find_capability(dev, type))
486 return -EINVAL;
487
488 return 0; 488 return 0;
489} 489}
490 490
@@ -500,19 +500,12 @@ int pci_msi_supported(struct pci_dev * dev)
500 **/ 500 **/
501int pci_enable_msi(struct pci_dev* dev) 501int pci_enable_msi(struct pci_dev* dev)
502{ 502{
503 int pos, status; 503 int status;
504
505 if (pci_msi_supported(dev) < 0)
506 return -EINVAL;
507 504
508 status = msi_init(); 505 status = pci_msi_check_device(dev, 1, PCI_CAP_ID_MSI);
509 if (status < 0) 506 if (status)
510 return status; 507 return status;
511 508
512 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
513 if (!pos)
514 return -EINVAL;
515
516 WARN_ON(!!dev->msi_enabled); 509 WARN_ON(!!dev->msi_enabled);
517 510
518 /* Check whether driver already requested for MSI-X irqs */ 511 /* Check whether driver already requested for MSI-X irqs */
@@ -525,69 +518,54 @@ int pci_enable_msi(struct pci_dev* dev)
525 status = msi_capability_init(dev); 518 status = msi_capability_init(dev);
526 return status; 519 return status;
527} 520}
521EXPORT_SYMBOL(pci_enable_msi);
528 522
529void pci_disable_msi(struct pci_dev* dev) 523void pci_disable_msi(struct pci_dev* dev)
530{ 524{
531 struct msi_desc *entry; 525 struct msi_desc *entry;
532 int default_irq; 526 int default_irq;
533 527
534 if (!pci_msi_enable) 528 if (!pci_msi_enable || !dev || !dev->msi_enabled)
535 return;
536 if (!dev)
537 return;
538
539 if (!dev->msi_enabled)
540 return; 529 return;
541 530
542 msi_set_enable(dev, 0); 531 msi_set_enable(dev, 0);
543 pci_intx(dev, 1); /* enable intx */ 532 pci_intx(dev, 1); /* enable intx */
544 dev->msi_enabled = 0; 533 dev->msi_enabled = 0;
545 534
546 entry = get_irq_msi(dev->first_msi_irq); 535 BUG_ON(list_empty(&dev->msi_list));
547 if (!entry || !entry->dev || entry->msi_attrib.type != PCI_CAP_ID_MSI) { 536 entry = list_entry(dev->msi_list.next, struct msi_desc, list);
537 if (!entry->dev || entry->msi_attrib.type != PCI_CAP_ID_MSI) {
548 return; 538 return;
549 } 539 }
550 if (irq_has_action(dev->first_msi_irq)) { 540
551 printk(KERN_WARNING "PCI: %s: pci_disable_msi() called without " 541 default_irq = entry->msi_attrib.default_irq;
552 "free_irq() on MSI irq %d\n", 542 msi_free_irqs(dev);
553 pci_name(dev), dev->first_msi_irq); 543
554 BUG_ON(irq_has_action(dev->first_msi_irq)); 544 /* Restore dev->irq to its default pin-assertion irq */
555 } else { 545 dev->irq = default_irq;
556 default_irq = entry->msi_attrib.default_irq;
557 msi_free_irq(dev, dev->first_msi_irq);
558
559 /* Restore dev->irq to its default pin-assertion irq */
560 dev->irq = default_irq;
561 }
562 dev->first_msi_irq = 0;
563} 546}
547EXPORT_SYMBOL(pci_disable_msi);
564 548
565static int msi_free_irq(struct pci_dev* dev, int irq) 549static int msi_free_irqs(struct pci_dev* dev)
566{ 550{
567 struct msi_desc *entry; 551 struct msi_desc *entry, *tmp;
568 int head, entry_nr, type;
569 void __iomem *base;
570 552
571 entry = get_irq_msi(irq); 553 list_for_each_entry(entry, &dev->msi_list, list)
572 if (!entry || entry->dev != dev) { 554 BUG_ON(irq_has_action(entry->irq));
573 return -EINVAL; 555
574 } 556 arch_teardown_msi_irqs(dev);
575 type = entry->msi_attrib.type; 557
576 entry_nr = entry->msi_attrib.entry_nr; 558 list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) {
577 head = entry->link.head; 559 if (entry->msi_attrib.type == PCI_CAP_ID_MSIX) {
578 base = entry->mask_base; 560 if (list_is_last(&entry->list, &dev->msi_list))
579 get_irq_msi(entry->link.head)->link.tail = entry->link.tail; 561 iounmap(entry->mask_base);
580 get_irq_msi(entry->link.tail)->link.head = entry->link.head; 562
581 563 writel(1, entry->mask_base + entry->msi_attrib.entry_nr
582 arch_teardown_msi_irq(irq); 564 * PCI_MSIX_ENTRY_SIZE
583 kmem_cache_free(msi_cachep, entry); 565 + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
584 566 }
585 if (type == PCI_CAP_ID_MSIX) { 567 list_del(&entry->list);
586 writel(1, base + entry_nr * PCI_MSIX_ENTRY_SIZE + 568 kfree(entry);
587 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
588
589 if (head == irq)
590 iounmap(base);
591 } 569 }
592 570
593 return 0; 571 return 0;
@@ -614,17 +592,14 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
614 int i, j; 592 int i, j;
615 u16 control; 593 u16 control;
616 594
617 if (!entries || pci_msi_supported(dev) < 0) 595 if (!entries)
618 return -EINVAL; 596 return -EINVAL;
619 597
620 status = msi_init(); 598 status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX);
621 if (status < 0) 599 if (status)
622 return status; 600 return status;
623 601
624 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); 602 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
625 if (!pos)
626 return -EINVAL;
627
628 pci_read_config_word(dev, msi_control_reg(pos), &control); 603 pci_read_config_word(dev, msi_control_reg(pos), &control);
629 nr_entries = multi_msix_capable(control); 604 nr_entries = multi_msix_capable(control);
630 if (nvec > nr_entries) 605 if (nvec > nr_entries)
@@ -651,41 +626,25 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
651 status = msix_capability_init(dev, entries, nvec); 626 status = msix_capability_init(dev, entries, nvec);
652 return status; 627 return status;
653} 628}
629EXPORT_SYMBOL(pci_enable_msix);
654 630
655void pci_disable_msix(struct pci_dev* dev) 631static void msix_free_all_irqs(struct pci_dev *dev)
656{ 632{
657 int irq, head, tail = 0, warning = 0; 633 msi_free_irqs(dev);
658 634}
659 if (!pci_msi_enable)
660 return;
661 if (!dev)
662 return;
663 635
664 if (!dev->msix_enabled) 636void pci_disable_msix(struct pci_dev* dev)
637{
638 if (!pci_msi_enable || !dev || !dev->msix_enabled)
665 return; 639 return;
666 640
667 msix_set_enable(dev, 0); 641 msix_set_enable(dev, 0);
668 pci_intx(dev, 1); /* enable intx */ 642 pci_intx(dev, 1); /* enable intx */
669 dev->msix_enabled = 0; 643 dev->msix_enabled = 0;
670 644
671 irq = head = dev->first_msi_irq; 645 msix_free_all_irqs(dev);
672 while (head != tail) {
673 tail = get_irq_msi(irq)->link.tail;
674 if (irq_has_action(irq))
675 warning = 1;
676 else if (irq != head) /* Release MSI-X irq */
677 msi_free_irq(dev, irq);
678 irq = tail;
679 }
680 msi_free_irq(dev, irq);
681 if (warning) {
682 printk(KERN_WARNING "PCI: %s: pci_disable_msix() called without "
683 "free_irq() on all MSI-X irqs\n",
684 pci_name(dev));
685 BUG_ON(warning > 0);
686 }
687 dev->first_msi_irq = 0;
688} 646}
647EXPORT_SYMBOL(pci_disable_msix);
689 648
690/** 649/**
691 * msi_remove_pci_irq_vectors - reclaim MSI(X) irqs to unused state 650 * msi_remove_pci_irq_vectors - reclaim MSI(X) irqs to unused state
@@ -701,38 +660,11 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
701 if (!pci_msi_enable || !dev) 660 if (!pci_msi_enable || !dev)
702 return; 661 return;
703 662
704 if (dev->msi_enabled) { 663 if (dev->msi_enabled)
705 if (irq_has_action(dev->first_msi_irq)) { 664 msi_free_irqs(dev);
706 printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() " 665
707 "called without free_irq() on MSI irq %d\n", 666 if (dev->msix_enabled)
708 pci_name(dev), dev->first_msi_irq); 667 msix_free_all_irqs(dev);
709 BUG_ON(irq_has_action(dev->first_msi_irq));
710 } else /* Release MSI irq assigned to this device */
711 msi_free_irq(dev, dev->first_msi_irq);
712 }
713 if (dev->msix_enabled) {
714 int irq, head, tail = 0, warning = 0;
715 void __iomem *base = NULL;
716
717 irq = head = dev->first_msi_irq;
718 while (head != tail) {
719 tail = get_irq_msi(irq)->link.tail;
720 base = get_irq_msi(irq)->mask_base;
721 if (irq_has_action(irq))
722 warning = 1;
723 else if (irq != head) /* Release MSI-X irq */
724 msi_free_irq(dev, irq);
725 irq = tail;
726 }
727 msi_free_irq(dev, irq);
728 if (warning) {
729 iounmap(base);
730 printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() "
731 "called without free_irq() on all MSI-X irqs\n",
732 pci_name(dev));
733 BUG_ON(warning > 0);
734 }
735 }
736} 668}
737 669
738void pci_no_msi(void) 670void pci_no_msi(void)
@@ -740,7 +672,53 @@ void pci_no_msi(void)
740 pci_msi_enable = 0; 672 pci_msi_enable = 0;
741} 673}
742 674
743EXPORT_SYMBOL(pci_enable_msi); 675void pci_msi_init_pci_dev(struct pci_dev *dev)
744EXPORT_SYMBOL(pci_disable_msi); 676{
745EXPORT_SYMBOL(pci_enable_msix); 677 INIT_LIST_HEAD(&dev->msi_list);
746EXPORT_SYMBOL(pci_disable_msix); 678}
679
680
681/* Arch hooks */
682
683int __attribute__ ((weak))
684arch_msi_check_device(struct pci_dev* dev, int nvec, int type)
685{
686 return 0;
687}
688
689int __attribute__ ((weak))
690arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *entry)
691{
692 return 0;
693}
694
695int __attribute__ ((weak))
696arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
697{
698 struct msi_desc *entry;
699 int ret;
700
701 list_for_each_entry(entry, &dev->msi_list, list) {
702 ret = arch_setup_msi_irq(dev, entry);
703 if (ret)
704 return ret;
705 }
706
707 return 0;
708}
709
710void __attribute__ ((weak)) arch_teardown_msi_irq(unsigned int irq)
711{
712 return;
713}
714
715void __attribute__ ((weak))
716arch_teardown_msi_irqs(struct pci_dev *dev)
717{
718 struct msi_desc *entry;
719
720 list_for_each_entry(entry, &dev->msi_list, list) {
721 if (entry->irq != 0)
722 arch_teardown_msi_irq(entry->irq);
723 }
724}
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 39e80fcef4b3..3bb7739d26a5 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -14,20 +14,6 @@
14#include "pci.h" 14#include "pci.h"
15 15
16/* 16/*
17 * Registration of PCI drivers and handling of hot-pluggable devices.
18 */
19
20/* multithreaded probe logic */
21static int pci_multithread_probe =
22#ifdef CONFIG_PCI_MULTITHREAD_PROBE
23 1;
24#else
25 0;
26#endif
27__module_param_call("", pci_multithread_probe, param_set_bool, param_get_bool, &pci_multithread_probe, 0644);
28
29
30/*
31 * Dynamic device IDs are disabled for !CONFIG_HOTPLUG 17 * Dynamic device IDs are disabled for !CONFIG_HOTPLUG
32 */ 18 */
33 19
@@ -52,7 +38,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
52{ 38{
53 struct pci_dynid *dynid; 39 struct pci_dynid *dynid;
54 struct pci_driver *pdrv = to_pci_driver(driver); 40 struct pci_driver *pdrv = to_pci_driver(driver);
55 __u32 vendor=PCI_ANY_ID, device=PCI_ANY_ID, subvendor=PCI_ANY_ID, 41 __u32 vendor, device, subvendor=PCI_ANY_ID,
56 subdevice=PCI_ANY_ID, class=0, class_mask=0; 42 subdevice=PCI_ANY_ID, class=0, class_mask=0;
57 unsigned long driver_data=0; 43 unsigned long driver_data=0;
58 int fields=0; 44 int fields=0;
@@ -61,7 +47,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
61 fields = sscanf(buf, "%x %x %x %x %x %x %lux", 47 fields = sscanf(buf, "%x %x %x %x %x %x %lux",
62 &vendor, &device, &subvendor, &subdevice, 48 &vendor, &device, &subvendor, &subdevice,
63 &class, &class_mask, &driver_data); 49 &class, &class_mask, &driver_data);
64 if (fields < 0) 50 if (fields < 2)
65 return -EINVAL; 51 return -EINVAL;
66 52
67 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 53 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
@@ -569,7 +555,6 @@ struct bus_type pci_bus_type = {
569 555
570static int __init pci_driver_init(void) 556static int __init pci_driver_init(void)
571{ 557{
572 pci_bus_type.multithread_probe = pci_multithread_probe;
573 return bus_register(&pci_bus_type); 558 return bus_register(&pci_bus_type);
574} 559}
575 560
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index cd913a2a416f..284e83a527f9 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -620,7 +620,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
620 goto err_bin_file; 620 goto err_bin_file;
621 621
622 /* If the device has a ROM, try to expose it in sysfs. */ 622 /* If the device has a ROM, try to expose it in sysfs. */
623 if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { 623 if (pci_resource_len(pdev, PCI_ROM_RESOURCE) ||
624 (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW)) {
624 rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); 625 rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC);
625 if (rom_attr) { 626 if (rom_attr) {
626 pdev->rom_attr = rom_attr; 627 pdev->rom_attr = rom_attr;
@@ -635,7 +636,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
635 goto err_rom; 636 goto err_rom;
636 } else { 637 } else {
637 retval = -ENOMEM; 638 retval = -ENOMEM;
638 goto err_bin_file; 639 goto err_resource_files;
639 } 640 }
640 } 641 }
641 /* add platform-specific attributes */ 642 /* add platform-specific attributes */
@@ -645,6 +646,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
645 646
646err_rom: 647err_rom:
647 kfree(rom_attr); 648 kfree(rom_attr);
649err_resource_files:
650 pci_remove_resource_files(pdev);
648err_bin_file: 651err_bin_file:
649 if (pdev->cfg_size < 4096) 652 if (pdev->cfg_size < 4096)
650 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); 653 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
@@ -695,4 +698,4 @@ static int __init pci_sysfs_init(void)
695 return 0; 698 return 0;
696} 699}
697 700
698__initcall(pci_sysfs_init); 701late_initcall(pci_sysfs_init);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2a458279327a..fd47ac0c4730 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -35,8 +35,7 @@ unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE;
35 * Given a PCI bus, returns the highest PCI bus number present in the set 35 * Given a PCI bus, returns the highest PCI bus number present in the set
36 * including the given PCI bus and its list of child PCI buses. 36 * including the given PCI bus and its list of child PCI buses.
37 */ 37 */
38unsigned char __devinit 38unsigned char pci_bus_max_busnr(struct pci_bus* bus)
39pci_bus_max_busnr(struct pci_bus* bus)
40{ 39{
41 struct list_head *tmp; 40 struct list_head *tmp;
42 unsigned char max, n; 41 unsigned char max, n;
@@ -892,6 +891,34 @@ pci_disable_device(struct pci_dev *dev)
892} 891}
893 892
894/** 893/**
894 * pcibios_set_pcie_reset_state - set reset state for device dev
895 * @dev: the PCI-E device reset
896 * @state: Reset state to enter into
897 *
898 *
899 * Sets the PCI-E reset state for the device. This is the default
900 * implementation. Architecture implementations can override this.
901 */
902int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
903 enum pcie_reset_state state)
904{
905 return -EINVAL;
906}
907
908/**
909 * pci_set_pcie_reset_state - set reset state for device dev
910 * @dev: the PCI-E device reset
911 * @state: Reset state to enter into
912 *
913 *
914 * Sets the PCI reset state for the device.
915 */
916int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
917{
918 return pcibios_set_pcie_reset_state(dev, state);
919}
920
921/**
895 * pci_enable_wake - enable PCI device as wakeup event source 922 * pci_enable_wake - enable PCI device as wakeup event source
896 * @dev: PCI device affected 923 * @dev: PCI device affected
897 * @state: PCI state from which device will issue wakeup events 924 * @state: PCI state from which device will issue wakeup events
@@ -1295,7 +1322,7 @@ pci_intx(struct pci_dev *pdev, int enable)
1295 1322
1296/** 1323/**
1297 * pci_msi_off - disables any msi or msix capabilities 1324 * pci_msi_off - disables any msi or msix capabilities
1298 * @pdev: the PCI device to operate on 1325 * @dev: the PCI device to operate on
1299 * 1326 *
1300 * If you want to use msi see pci_enable_msi and friends. 1327 * If you want to use msi see pci_enable_msi and friends.
1301 * This is a lower level primitive that allows us to disable 1328 * This is a lower level primitive that allows us to disable
@@ -1427,4 +1454,5 @@ EXPORT_SYMBOL(pci_set_power_state);
1427EXPORT_SYMBOL(pci_save_state); 1454EXPORT_SYMBOL(pci_save_state);
1428EXPORT_SYMBOL(pci_restore_state); 1455EXPORT_SYMBOL(pci_restore_state);
1429EXPORT_SYMBOL(pci_enable_wake); 1456EXPORT_SYMBOL(pci_enable_wake);
1457EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
1430 1458
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 62ea04c8af64..3fec13d3add7 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -47,8 +47,10 @@ extern unsigned int pci_pm_d3_delay;
47 47
48#ifdef CONFIG_PCI_MSI 48#ifdef CONFIG_PCI_MSI
49void pci_no_msi(void); 49void pci_no_msi(void);
50extern void pci_msi_init_pci_dev(struct pci_dev *dev);
50#else 51#else
51static inline void pci_no_msi(void) { } 52static inline void pci_no_msi(void) { }
53static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { }
52#endif 54#endif
53 55
54#if defined(CONFIG_PCI_MSI) && defined(CONFIG_PM) 56#if defined(CONFIG_PCI_MSI) && defined(CONFIG_PM)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 2fe1d690eb13..e48fcf089621 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -364,7 +364,7 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
364 } 364 }
365} 365}
366 366
367static struct pci_bus * __devinit pci_alloc_bus(void) 367static struct pci_bus * pci_alloc_bus(void)
368{ 368{
369 struct pci_bus *b; 369 struct pci_bus *b;
370 370
@@ -432,7 +432,7 @@ error_register:
432 return NULL; 432 return NULL;
433} 433}
434 434
435struct pci_bus * __devinit pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr) 435struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr)
436{ 436{
437 struct pci_bus *child; 437 struct pci_bus *child;
438 438
@@ -461,7 +461,7 @@ static void pci_enable_crs(struct pci_dev *dev)
461 pci_write_config_word(dev, rpcap + PCI_EXP_RTCTL, rpctl); 461 pci_write_config_word(dev, rpcap + PCI_EXP_RTCTL, rpctl);
462} 462}
463 463
464static void __devinit pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max) 464static void pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max)
465{ 465{
466 struct pci_bus *parent = child->parent; 466 struct pci_bus *parent = child->parent;
467 467
@@ -477,7 +477,7 @@ static void __devinit pci_fixup_parent_subordinate_busnr(struct pci_bus *child,
477 } 477 }
478} 478}
479 479
480unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus); 480unsigned int pci_scan_child_bus(struct pci_bus *bus);
481 481
482/* 482/*
483 * If it's a bridge, configure it and scan the bus behind it. 483 * If it's a bridge, configure it and scan the bus behind it.
@@ -489,7 +489,7 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus);
489 * them, we proceed to assigning numbers to the remaining buses in 489 * them, we proceed to assigning numbers to the remaining buses in
490 * order to avoid overlaps between old and new bus numbers. 490 * order to avoid overlaps between old and new bus numbers.
491 */ 491 */
492int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass) 492int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass)
493{ 493{
494 struct pci_bus *child; 494 struct pci_bus *child;
495 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); 495 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
@@ -846,6 +846,23 @@ static void pci_release_bus_bridge_dev(struct device *dev)
846 kfree(dev); 846 kfree(dev);
847} 847}
848 848
849struct pci_dev *alloc_pci_dev(void)
850{
851 struct pci_dev *dev;
852
853 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
854 if (!dev)
855 return NULL;
856
857 INIT_LIST_HEAD(&dev->global_list);
858 INIT_LIST_HEAD(&dev->bus_list);
859
860 pci_msi_init_pci_dev(dev);
861
862 return dev;
863}
864EXPORT_SYMBOL(alloc_pci_dev);
865
849/* 866/*
850 * Read the config data for a PCI device, sanity-check it 867 * Read the config data for a PCI device, sanity-check it
851 * and fill in the dev structure... 868 * and fill in the dev structure...
@@ -885,7 +902,7 @@ pci_scan_device(struct pci_bus *bus, int devfn)
885 if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) 902 if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type))
886 return NULL; 903 return NULL;
887 904
888 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); 905 dev = alloc_pci_dev();
889 if (!dev) 906 if (!dev)
890 return NULL; 907 return NULL;
891 908
@@ -912,7 +929,7 @@ pci_scan_device(struct pci_bus *bus, int devfn)
912 return dev; 929 return dev;
913} 930}
914 931
915void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus) 932void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
916{ 933{
917 device_initialize(&dev->dev); 934 device_initialize(&dev->dev);
918 dev->dev.release = pci_release_dev; 935 dev->dev.release = pci_release_dev;
@@ -935,8 +952,7 @@ void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
935 up_write(&pci_bus_sem); 952 up_write(&pci_bus_sem);
936} 953}
937 954
938struct pci_dev * __devinit 955struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn)
939pci_scan_single_device(struct pci_bus *bus, int devfn)
940{ 956{
941 struct pci_dev *dev; 957 struct pci_dev *dev;
942 958
@@ -958,7 +974,7 @@ pci_scan_single_device(struct pci_bus *bus, int devfn)
958 * discovered devices to the @bus->devices list. New devices 974 * discovered devices to the @bus->devices list. New devices
959 * will have an empty dev->global_list head. 975 * will have an empty dev->global_list head.
960 */ 976 */
961int __devinit pci_scan_slot(struct pci_bus *bus, int devfn) 977int pci_scan_slot(struct pci_bus *bus, int devfn)
962{ 978{
963 int func, nr = 0; 979 int func, nr = 0;
964 int scan_all_fns; 980 int scan_all_fns;
@@ -991,7 +1007,7 @@ int __devinit pci_scan_slot(struct pci_bus *bus, int devfn)
991 return nr; 1007 return nr;
992} 1008}
993 1009
994unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) 1010unsigned int pci_scan_child_bus(struct pci_bus *bus)
995{ 1011{
996 unsigned int devfn, pass, max = bus->secondary; 1012 unsigned int devfn, pass, max = bus->secondary;
997 struct pci_dev *dev; 1013 struct pci_dev *dev;
@@ -1041,7 +1057,7 @@ unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus)
1041 return max; 1057 return max;
1042} 1058}
1043 1059
1044struct pci_bus * __devinit pci_create_bus(struct device *parent, 1060struct pci_bus * pci_create_bus(struct device *parent,
1045 int bus, struct pci_ops *ops, void *sysdata) 1061 int bus, struct pci_ops *ops, void *sysdata)
1046{ 1062{
1047 int error; 1063 int error;
@@ -1119,7 +1135,7 @@ err_out:
1119} 1135}
1120EXPORT_SYMBOL_GPL(pci_create_bus); 1136EXPORT_SYMBOL_GPL(pci_create_bus);
1121 1137
1122struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, 1138struct pci_bus *pci_scan_bus_parented(struct device *parent,
1123 int bus, struct pci_ops *ops, void *sysdata) 1139 int bus, struct pci_ops *ops, void *sysdata)
1124{ 1140{
1125 struct pci_bus *b; 1141 struct pci_bus *b;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 3411483240cd..147d86f8edbf 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1648,6 +1648,8 @@ static void __devinit quirk_disable_msi(struct pci_dev *dev)
1648 } 1648 }
1649} 1649}
1650DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi); 1650DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi);
1651DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_msi);
1652DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS480, quirk_disable_msi);
1651 1653
1652/* Go through the list of Hypertransport capabilities and 1654/* Go through the list of Hypertransport capabilities and
1653 * return 1 if a HT MSI capability is found and enabled */ 1655 * return 1 if a HT MSI capability is found and enabled */
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 2dd8681d6b31..b137a27472c7 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -15,8 +15,7 @@
15 15
16DECLARE_RWSEM(pci_bus_sem); 16DECLARE_RWSEM(pci_bus_sem);
17 17
18static struct pci_bus * 18static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
19pci_do_find_bus(struct pci_bus* bus, unsigned char busnr)
20{ 19{
21 struct pci_bus* child; 20 struct pci_bus* child;
22 struct list_head *tmp; 21 struct list_head *tmp;
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 3554f3948814..5ec297d7a5b4 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -36,8 +36,7 @@
36 36
37#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1)) 37#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
38 38
39static void __devinit 39static void pbus_assign_resources_sorted(struct pci_bus *bus)
40pbus_assign_resources_sorted(struct pci_bus *bus)
41{ 40{
42 struct pci_dev *dev; 41 struct pci_dev *dev;
43 struct resource *res; 42 struct resource *res;
@@ -220,8 +219,7 @@ pci_setup_bridge(struct pci_bus *bus)
220/* Check whether the bridge supports optional I/O and 219/* Check whether the bridge supports optional I/O and
221 prefetchable memory ranges. If not, the respective 220 prefetchable memory ranges. If not, the respective
222 base/limit registers must be read-only and read as 0. */ 221 base/limit registers must be read-only and read as 0. */
223static void __devinit 222static void pci_bridge_check_ranges(struct pci_bus *bus)
224pci_bridge_check_ranges(struct pci_bus *bus)
225{ 223{
226 u16 io; 224 u16 io;
227 u32 pmem; 225 u32 pmem;
@@ -259,8 +257,7 @@ pci_bridge_check_ranges(struct pci_bus *bus)
259 bus resource of a given type. Note: we intentionally skip 257 bus resource of a given type. Note: we intentionally skip
260 the bus resources which have already been assigned (that is, 258 the bus resources which have already been assigned (that is,
261 have non-NULL parent resource). */ 259 have non-NULL parent resource). */
262static struct resource * __devinit 260static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned long type)
263find_free_bus_resource(struct pci_bus *bus, unsigned long type)
264{ 261{
265 int i; 262 int i;
266 struct resource *r; 263 struct resource *r;
@@ -281,8 +278,7 @@ find_free_bus_resource(struct pci_bus *bus, unsigned long type)
281 since these windows have 4K granularity and the IO ranges 278 since these windows have 4K granularity and the IO ranges
282 of non-bridge PCI devices are limited to 256 bytes. 279 of non-bridge PCI devices are limited to 256 bytes.
283 We must be careful with the ISA aliasing though. */ 280 We must be careful with the ISA aliasing though. */
284static void __devinit 281static void pbus_size_io(struct pci_bus *bus)
285pbus_size_io(struct pci_bus *bus)
286{ 282{
287 struct pci_dev *dev; 283 struct pci_dev *dev;
288 struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO); 284 struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
@@ -326,8 +322,7 @@ pbus_size_io(struct pci_bus *bus)
326 322
327/* Calculate the size of the bus and minimal alignment which 323/* Calculate the size of the bus and minimal alignment which
328 guarantees that all child resources fit in this size. */ 324 guarantees that all child resources fit in this size. */
329static int __devinit 325static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type)
330pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type)
331{ 326{
332 struct pci_dev *dev; 327 struct pci_dev *dev;
333 unsigned long min_align, align, size; 328 unsigned long min_align, align, size;
@@ -447,8 +442,7 @@ pci_bus_size_cardbus(struct pci_bus *bus)
447 } 442 }
448} 443}
449 444
450void __devinit 445void pci_bus_size_bridges(struct pci_bus *bus)
451pci_bus_size_bridges(struct pci_bus *bus)
452{ 446{
453 struct pci_dev *dev; 447 struct pci_dev *dev;
454 unsigned long mask, prefmask; 448 unsigned long mask, prefmask;
@@ -498,8 +492,7 @@ pci_bus_size_bridges(struct pci_bus *bus)
498} 492}
499EXPORT_SYMBOL(pci_bus_size_bridges); 493EXPORT_SYMBOL(pci_bus_size_bridges);
500 494
501void __devinit 495void pci_bus_assign_resources(struct pci_bus *bus)
502pci_bus_assign_resources(struct pci_bus *bus)
503{ 496{
504 struct pci_bus *b; 497 struct pci_bus *b;
505 struct pci_dev *dev; 498 struct pci_dev *dev;
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index cb4ced3560e9..6dfd86167e39 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -101,8 +101,7 @@ pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
101 new & ~PCI_REGION_FLAG_MASK); 101 new & ~PCI_REGION_FLAG_MASK);
102} 102}
103 103
104int __devinit 104int pci_claim_resource(struct pci_dev *dev, int resource)
105pci_claim_resource(struct pci_dev *dev, int resource)
106{ 105{
107 struct resource *res = &dev->resource[resource]; 106 struct resource *res = &dev->resource[resource];
108 struct resource *root = NULL; 107 struct resource *root = NULL;
@@ -212,8 +211,7 @@ EXPORT_SYMBOL_GPL(pci_assign_resource_fixed);
212#endif 211#endif
213 212
214/* Sort resources by alignment */ 213/* Sort resources by alignment */
215void __devinit 214void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
216pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
217{ 215{
218 int i; 216 int i;
219 217
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index ac004248324a..50cad3a59a6c 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -26,7 +26,6 @@
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/pm.h> 28#include <linux/pm.h>
29#include <linux/pci.h>
30#include <linux/device.h> 29#include <linux/device.h>
31#include <linux/kthread.h> 30#include <linux/kthread.h>
32#include <linux/freezer.h> 31#include <linux/freezer.h>
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index ea5765c3bdc0..a2bb46526b56 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -22,7 +22,6 @@
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/pm.h> 24#include <linux/pm.h>
25#include <linux/pci.h>
26#include <linux/device.h> 25#include <linux/device.h>
27#include <linux/mutex.h> 26#include <linux/mutex.h>
28#include <asm/system.h> 27#include <asm/system.h>
diff --git a/drivers/sbus/sbus.c b/drivers/sbus/sbus.c
index eee590a51d8a..002643392d42 100644
--- a/drivers/sbus/sbus.c
+++ b/drivers/sbus/sbus.c
@@ -6,7 +6,6 @@
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/slab.h> 7#include <linux/slab.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/pci.h>
10#include <linux/device.h> 9#include <linux/device.h>
11 10
12#include <asm/system.h> 11#include <asm/system.h>
diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c
index d38b628be1ad..66aeb57dcc2d 100644
--- a/drivers/scsi/aacraid/dpcsup.c
+++ b/drivers/scsi/aacraid/dpcsup.c
@@ -32,7 +32,6 @@
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/pci.h>
36#include <linux/spinlock.h> 35#include <linux/spinlock.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38#include <linux/completion.h> 37#include <linux/completion.h>
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
index 6f1a1780efce..f4b5e9742ab0 100644
--- a/drivers/scsi/aacraid/sa.c
+++ b/drivers/scsi/aacraid/sa.c
@@ -31,7 +31,6 @@
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/pci.h>
35#include <linux/spinlock.h> 34#include <linux/spinlock.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
37#include <linux/blkdev.h> 36#include <linux/blkdev.h>
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 1d239f6c0103..cbbfbc9f3e0f 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -35,7 +35,6 @@
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <linux/pci.h>
39#include <linux/isapnp.h> 38#include <linux/isapnp.h>
40#include <linux/blkdev.h> 39#include <linux/blkdev.h>
41#include <linux/mca.h> 40#include <linux/mca.h>
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index 8f43ff772f23..db6ab1a3b81e 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -24,7 +24,6 @@
24 * 24 *
25 */ 25 */
26 26
27#include <linux/pci.h>
28#include <scsi/scsi_host.h> 27#include <scsi/scsi_host.h>
29 28
30#include "aic94xx.h" 29#include "aic94xx.h"
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c
index 12497da5529d..03bfed61bffc 100644
--- a/drivers/scsi/arcmsr/arcmsr_attr.c
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c
@@ -49,7 +49,6 @@
49#include <linux/init.h> 49#include <linux/init.h>
50#include <linux/errno.h> 50#include <linux/errno.h>
51#include <linux/delay.h> 51#include <linux/delay.h>
52#include <linux/pci.h>
53 52
54#include <scsi/scsi_cmnd.h> 53#include <scsi/scsi_cmnd.h>
55#include <scsi/scsi_device.h> 54#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index dc70c180e115..e34442e405e8 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <linux/pci.h>
26#include <linux/scatterlist.h> 25#include <linux/scatterlist.h>
27 26
28#include "sas_internal.h" 27#include "sas_internal.h"
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
index 89403b00e042..6335830df810 100644
--- a/drivers/scsi/libsrp.c
+++ b/drivers/scsi/libsrp.c
@@ -22,7 +22,6 @@
22#include <linux/kfifo.h> 22#include <linux/kfifo.h>
23#include <linux/scatterlist.h> 23#include <linux/scatterlist.h>
24#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
25#include <linux/pci.h>
26#include <scsi/scsi.h> 25#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h> 26#include <scsi/scsi_cmnd.h>
28#include <scsi/scsi_tcq.h> 27#include <scsi/scsi_tcq.h>
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 0aa3304f6b9b..7fc6e06ea7e1 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -2088,7 +2088,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
2088static inline int 2088static inline int
2089make_local_pdev(adapter_t *adapter, struct pci_dev **pdev) 2089make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
2090{ 2090{
2091 *pdev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); 2091 *pdev = alloc_pci_dev();
2092 2092
2093 if( *pdev == NULL ) return -1; 2093 if( *pdev == NULL ) return -1;
2094 2094
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index a0cc05d21a6a..60d29440f316 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -55,7 +55,6 @@
55#include <linux/usb.h> 55#include <linux/usb.h>
56#include <linux/types.h> 56#include <linux/types.h>
57#include <linux/ethtool.h> 57#include <linux/ethtool.h>
58#include <linux/pci.h>
59#include <linux/dma-mapping.h> 58#include <linux/dma-mapping.h>
60#include <linux/wait.h> 59#include <linux/wait.h>
61#include <asm/uaccess.h> 60#include <asm/uaccess.h>
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c
index 508479920705..7db9de681716 100644
--- a/drivers/video/aty/radeon_i2c.c
+++ b/drivers/video/aty/radeon_i2c.c
@@ -1,7 +1,6 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include <linux/delay.h> 3#include <linux/delay.h>
4#include <linux/pci.h>
5#include <linux/fb.h> 4#include <linux/fb.h>
6 5
7 6
diff --git a/drivers/video/g364fb.c b/drivers/video/g364fb.c
index ca93a75f2997..b7655c05da53 100644
--- a/drivers/video/g364fb.c
+++ b/drivers/video/g364fb.c
@@ -26,7 +26,6 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/fb.h> 27#include <linux/fb.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/pci.h>
30#include <asm/io.h> 29#include <asm/io.h>
31#include <asm/jazz.h> 30#include <asm/jazz.h>
32 31
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 233871655824..e64f8b5d0056 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -28,7 +28,6 @@
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/fb.h> 29#include <linux/fb.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/pci.h>
32#include <linux/nvram.h> 31#include <linux/nvram.h>
33#include <asm/io.h> 32#include <asm/io.h>
34#include <asm/prom.h> 33#include <asm/prom.h>
diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c
index 69f3b264a22e..c97709ecbad0 100644
--- a/drivers/video/stifb.c
+++ b/drivers/video/stifb.c
@@ -64,7 +64,6 @@
64#include <linux/fb.h> 64#include <linux/fb.h>
65#include <linux/init.h> 65#include <linux/init.h>
66#include <linux/ioport.h> 66#include <linux/ioport.h>
67#include <linux/pci.h>
68 67
69#include <asm/grfioctl.h> /* for HP-UX compatibility */ 68#include <asm/grfioctl.h> /* for HP-UX compatibility */
70#include <asm/uaccess.h> 69#include <asm/uaccess.h>
diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c
index 06fc19a61192..ad66f070acb8 100644
--- a/drivers/video/valkyriefb.c
+++ b/drivers/video/valkyriefb.c
@@ -51,7 +51,6 @@
51#include <linux/fb.h> 51#include <linux/fb.h>
52#include <linux/selection.h> 52#include <linux/selection.h>
53#include <linux/init.h> 53#include <linux/init.h>
54#include <linux/pci.h>
55#include <linux/nvram.h> 54#include <linux/nvram.h>
56#include <linux/adb.h> 55#include <linux/adb.h>
57#include <linux/cuda.h> 56#include <linux/cuda.h>
diff --git a/include/asm-alpha/scatterlist.h b/include/asm-alpha/scatterlist.h
index 6afb8bd3aaf9..917365405e83 100644
--- a/include/asm-alpha/scatterlist.h
+++ b/include/asm-alpha/scatterlist.h
@@ -2,6 +2,7 @@
2#define _ALPHA_SCATTERLIST_H 2#define _ALPHA_SCATTERLIST_H
3 3
4#include <asm/page.h> 4#include <asm/page.h>
5#include <asm/types.h>
5 6
6struct scatterlist { 7struct scatterlist {
7 struct page *page; 8 struct page *page;
diff --git a/include/asm-arm/arch-ixp4xx/dma.h b/include/asm-arm/arch-ixp4xx/dma.h
index 789f7f53c357..2c7f5327d80f 100644
--- a/include/asm-arm/arch-ixp4xx/dma.h
+++ b/include/asm-arm/arch-ixp4xx/dma.h
@@ -12,7 +12,6 @@
12#define __ASM_ARCH_DMA_H 12#define __ASM_ARCH_DMA_H
13 13
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/pci.h>
16#include <asm/page.h> 15#include <asm/page.h>
17#include <asm/sizes.h> 16#include <asm/sizes.h>
18#include <asm/hardware.h> 17#include <asm/hardware.h>
diff --git a/include/asm-avr32/scatterlist.h b/include/asm-avr32/scatterlist.h
index bfe7d753423c..c6d5ce3b3a25 100644
--- a/include/asm-avr32/scatterlist.h
+++ b/include/asm-avr32/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_AVR32_SCATTERLIST_H 1#ifndef __ASM_AVR32_SCATTERLIST_H
2#define __ASM_AVR32_SCATTERLIST_H 2#define __ASM_AVR32_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page *page; 7 struct page *page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-frv/scatterlist.h b/include/asm-frv/scatterlist.h
index fb38fd329a5f..8e827fa853f1 100644
--- a/include/asm-frv/scatterlist.h
+++ b/include/asm-frv/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _ASM_SCATTERLIST_H 1#ifndef _ASM_SCATTERLIST_H
2#define _ASM_SCATTERLIST_H 2#define _ASM_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4/* 6/*
5 * Drivers must set either ->address or (preferred) ->page and ->offset 7 * Drivers must set either ->address or (preferred) ->page and ->offset
6 * to indicate where data must be transferred to/from. 8 * to indicate where data must be transferred to/from.
diff --git a/include/asm-h8300/scatterlist.h b/include/asm-h8300/scatterlist.h
index 7627f0cd1a2f..985fdf54eaca 100644
--- a/include/asm-h8300/scatterlist.h
+++ b/include/asm-h8300/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _H8300_SCATTERLIST_H 1#ifndef _H8300_SCATTERLIST_H
2#define _H8300_SCATTERLIST_H 2#define _H8300_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page *page; 7 struct page *page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-i386/scatterlist.h b/include/asm-i386/scatterlist.h
index 55d6c953a76e..d7e45a8f1aae 100644
--- a/include/asm-i386/scatterlist.h
+++ b/include/asm-i386/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _I386_SCATTERLIST_H 1#ifndef _I386_SCATTERLIST_H
2#define _I386_SCATTERLIST_H 2#define _I386_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page *page; 7 struct page *page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-ia64/scatterlist.h b/include/asm-ia64/scatterlist.h
index 9dbea8844d5e..a452ea24205a 100644
--- a/include/asm-ia64/scatterlist.h
+++ b/include/asm-ia64/scatterlist.h
@@ -6,6 +6,8 @@
6 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co 6 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
7 */ 7 */
8 8
9#include <asm/types.h>
10
9struct scatterlist { 11struct scatterlist {
10 struct page *page; 12 struct page *page;
11 unsigned int offset; 13 unsigned int offset;
diff --git a/include/asm-m32r/scatterlist.h b/include/asm-m32r/scatterlist.h
index c2de96cb69ed..352415ff5eb9 100644
--- a/include/asm-m32r/scatterlist.h
+++ b/include/asm-m32r/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _ASM_M32R_SCATTERLIST_H 1#ifndef _ASM_M32R_SCATTERLIST_H
2#define _ASM_M32R_SCATTERLIST_H 2#define _ASM_M32R_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 char * address; /* Location data is to be transferred to, NULL for 7 char * address; /* Location data is to be transferred to, NULL for
6 * highmem page */ 8 * highmem page */
diff --git a/include/asm-m68knommu/scatterlist.h b/include/asm-m68knommu/scatterlist.h
index 2085d6ff8782..4da79d3d3f34 100644
--- a/include/asm-m68knommu/scatterlist.h
+++ b/include/asm-m68knommu/scatterlist.h
@@ -2,6 +2,7 @@
2#define _M68KNOMMU_SCATTERLIST_H 2#define _M68KNOMMU_SCATTERLIST_H
3 3
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <asm/types.h>
5 6
6struct scatterlist { 7struct scatterlist {
7 struct page *page; 8 struct page *page;
diff --git a/include/asm-mips/scatterlist.h b/include/asm-mips/scatterlist.h
index 22634706e9d5..7af104c95b20 100644
--- a/include/asm-mips/scatterlist.h
+++ b/include/asm-mips/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_SCATTERLIST_H 1#ifndef __ASM_SCATTERLIST_H
2#define __ASM_SCATTERLIST_H 2#define __ASM_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page * page; 7 struct page * page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-parisc/scatterlist.h b/include/asm-parisc/scatterlist.h
index 236c1d0fba33..e7211c748446 100644
--- a/include/asm-parisc/scatterlist.h
+++ b/include/asm-parisc/scatterlist.h
@@ -2,6 +2,7 @@
2#define _ASM_PARISC_SCATTERLIST_H 2#define _ASM_PARISC_SCATTERLIST_H
3 3
4#include <asm/page.h> 4#include <asm/page.h>
5#include <asm/types.h>
5 6
6struct scatterlist { 7struct scatterlist {
7 struct page *page; 8 struct page *page;
diff --git a/include/asm-sh/scatterlist.h b/include/asm-sh/scatterlist.h
index d19e7cd3b023..b9ae53c38365 100644
--- a/include/asm-sh/scatterlist.h
+++ b/include/asm-sh/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_SH_SCATTERLIST_H 1#ifndef __ASM_SH_SCATTERLIST_H
2#define __ASM_SH_SCATTERLIST_H 2#define __ASM_SH_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page * page; /* Location for highmem page, if any */ 7 struct page * page; /* Location for highmem page, if any */
6 unsigned int offset;/* for highmem, page offset */ 8 unsigned int offset;/* for highmem, page offset */
diff --git a/include/asm-sh64/scatterlist.h b/include/asm-sh64/scatterlist.h
index 5d8fa32d2e9d..1c723f2d7a95 100644
--- a/include/asm-sh64/scatterlist.h
+++ b/include/asm-sh64/scatterlist.h
@@ -11,6 +11,8 @@
11#ifndef __ASM_SH64_SCATTERLIST_H 11#ifndef __ASM_SH64_SCATTERLIST_H
12#define __ASM_SH64_SCATTERLIST_H 12#define __ASM_SH64_SCATTERLIST_H
13 13
14#include <asm/types.h>
15
14struct scatterlist { 16struct scatterlist {
15 struct page * page; /* Location for highmem page, if any */ 17 struct page * page; /* Location for highmem page, if any */
16 unsigned int offset;/* for highmem, page offset */ 18 unsigned int offset;/* for highmem, page offset */
diff --git a/include/asm-sparc64/scatterlist.h b/include/asm-sparc64/scatterlist.h
index ec4f3c63fe98..048fdb40e81d 100644
--- a/include/asm-sparc64/scatterlist.h
+++ b/include/asm-sparc64/scatterlist.h
@@ -3,6 +3,7 @@
3#define _SPARC64_SCATTERLIST_H 3#define _SPARC64_SCATTERLIST_H
4 4
5#include <asm/page.h> 5#include <asm/page.h>
6#include <asm/types.h>
6 7
7struct scatterlist { 8struct scatterlist {
8 struct page *page; 9 struct page *page;
diff --git a/include/asm-v850/scatterlist.h b/include/asm-v850/scatterlist.h
index af1cba69a526..56f402920db9 100644
--- a/include/asm-v850/scatterlist.h
+++ b/include/asm-v850/scatterlist.h
@@ -14,6 +14,8 @@
14#ifndef __V850_SCATTERLIST_H__ 14#ifndef __V850_SCATTERLIST_H__
15#define __V850_SCATTERLIST_H__ 15#define __V850_SCATTERLIST_H__
16 16
17#include <asm/types.h>
18
17struct scatterlist { 19struct scatterlist {
18 struct page *page; 20 struct page *page;
19 unsigned offset; 21 unsigned offset;
diff --git a/include/asm-x86_64/scatterlist.h b/include/asm-x86_64/scatterlist.h
index 49d89f8129cd..eaf7ada27e14 100644
--- a/include/asm-x86_64/scatterlist.h
+++ b/include/asm-x86_64/scatterlist.h
@@ -1,6 +1,8 @@
1#ifndef _X8664_SCATTERLIST_H 1#ifndef _X8664_SCATTERLIST_H
2#define _X8664_SCATTERLIST_H 2#define _X8664_SCATTERLIST_H
3 3
4#include <asm/types.h>
5
4struct scatterlist { 6struct scatterlist {
5 struct page *page; 7 struct page *page;
6 unsigned int offset; 8 unsigned int offset;
diff --git a/include/asm-xtensa/scatterlist.h b/include/asm-xtensa/scatterlist.h
index 38a2b9acd658..ca337a294290 100644
--- a/include/asm-xtensa/scatterlist.h
+++ b/include/asm-xtensa/scatterlist.h
@@ -11,6 +11,8 @@
11#ifndef _XTENSA_SCATTERLIST_H 11#ifndef _XTENSA_SCATTERLIST_H
12#define _XTENSA_SCATTERLIST_H 12#define _XTENSA_SCATTERLIST_H
13 13
14#include <asm/types.h>
15
14struct scatterlist { 16struct scatterlist {
15 struct page *page; 17 struct page *page;
16 unsigned int offset; 18 unsigned int offset;
diff --git a/include/linux/device.h b/include/linux/device.h
index a0cd2ced31a9..ff83b61d283d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -80,7 +80,6 @@ struct bus_type {
80 int (*resume)(struct device * dev); 80 int (*resume)(struct device * dev);
81 81
82 unsigned int drivers_autoprobe:1; 82 unsigned int drivers_autoprobe:1;
83 unsigned int multithread_probe:1;
84}; 83};
85 84
86extern int __must_check bus_register(struct bus_type * bus); 85extern int __must_check bus_register(struct bus_type * bus);
diff --git a/include/linux/msi.h b/include/linux/msi.h
index e38fe6822cb4..94bb46d82efd 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -1,6 +1,8 @@
1#ifndef LINUX_MSI_H 1#ifndef LINUX_MSI_H
2#define LINUX_MSI_H 2#define LINUX_MSI_H
3 3
4#include <linux/list.h>
5
4struct msi_msg { 6struct msi_msg {
5 u32 address_lo; /* low 32 bits of msi message address */ 7 u32 address_lo; /* low 32 bits of msi message address */
6 u32 address_hi; /* high 32 bits of msi message address */ 8 u32 address_hi; /* high 32 bits of msi message address */
@@ -24,10 +26,8 @@ struct msi_desc {
24 unsigned default_irq; /* default pre-assigned irq */ 26 unsigned default_irq; /* default pre-assigned irq */
25 }msi_attrib; 27 }msi_attrib;
26 28
27 struct { 29 unsigned int irq;
28 __u16 head; 30 struct list_head list;
29 __u16 tail;
30 }link;
31 31
32 void __iomem *mask_base; 32 void __iomem *mask_base;
33 struct pci_dev *dev; 33 struct pci_dev *dev;
@@ -41,6 +41,9 @@ struct msi_desc {
41 */ 41 */
42int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc); 42int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
43void arch_teardown_msi_irq(unsigned int irq); 43void arch_teardown_msi_irq(unsigned int irq);
44extern int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
45extern void arch_teardown_msi_irqs(struct pci_dev *dev);
46extern int arch_msi_check_device(struct pci_dev* dev, int nvec, int type);
44 47
45 48
46#endif /* LINUX_MSI_H */ 49#endif /* LINUX_MSI_H */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 972491089ac9..fbf3766dac1e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -96,6 +96,19 @@ enum pci_channel_state {
96 pci_channel_io_perm_failure = (__force pci_channel_state_t) 3, 96 pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
97}; 97};
98 98
99typedef unsigned int __bitwise pcie_reset_state_t;
100
101enum pcie_reset_state {
102 /* Reset is NOT asserted (Use to deassert reset) */
103 pcie_deassert_reset = (__force pcie_reset_state_t) 1,
104
105 /* Use #PERST to reset PCI-E device */
106 pcie_warm_reset = (__force pcie_reset_state_t) 2,
107
108 /* Use PCI-E Hot Reset to reset device */
109 pcie_hot_reset = (__force pcie_reset_state_t) 3
110};
111
99typedef unsigned short __bitwise pci_bus_flags_t; 112typedef unsigned short __bitwise pci_bus_flags_t;
100enum pci_bus_flags { 113enum pci_bus_flags {
101 PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1, 114 PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
@@ -176,10 +189,12 @@ struct pci_dev {
176 int rom_attr_enabled; /* has display of the rom attribute been enabled? */ 189 int rom_attr_enabled; /* has display of the rom attribute been enabled? */
177 struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */ 190 struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */
178#ifdef CONFIG_PCI_MSI 191#ifdef CONFIG_PCI_MSI
179 unsigned int first_msi_irq; 192 struct list_head msi_list;
180#endif 193#endif
181}; 194};
182 195
196extern struct pci_dev *alloc_pci_dev(void);
197
183#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list) 198#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)
184#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) 199#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
185#define to_pci_dev(n) container_of(n, struct pci_dev, dev) 200#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
@@ -392,12 +407,6 @@ struct pci_driver {
392 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \ 407 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
393 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID 408 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
394 409
395/*
396 * pci_module_init is obsolete, this stays here till we fix up all usages of it
397 * in the tree.
398 */
399#define pci_module_init pci_register_driver
400
401/** 410/**
402 * PCI_VDEVICE - macro used to describe a specific pci device in short form 411 * PCI_VDEVICE - macro used to describe a specific pci device in short form
403 * @vend: the vendor name 412 * @vend: the vendor name
@@ -532,6 +541,7 @@ static inline int pci_is_managed(struct pci_dev *pdev)
532 541
533void pci_disable_device(struct pci_dev *dev); 542void pci_disable_device(struct pci_dev *dev);
534void pci_set_master(struct pci_dev *dev); 543void pci_set_master(struct pci_dev *dev);
544int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
535#define HAVE_PCI_SET_MWI 545#define HAVE_PCI_SET_MWI
536int __must_check pci_set_mwi(struct pci_dev *dev); 546int __must_check pci_set_mwi(struct pci_dev *dev);
537void pci_clear_mwi(struct pci_dev *dev); 547void pci_clear_mwi(struct pci_dev *dev);
@@ -730,6 +740,9 @@ static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) {
730static inline pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) { return PCI_D0; } 740static inline pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) { return PCI_D0; }
731static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; } 741static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; }
732 742
743static inline int pci_request_regions(struct pci_dev *dev, const char *res_name) { return -EIO; }
744static inline void pci_release_regions(struct pci_dev *dev) { }
745
733#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) 746#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0)
734 747
735static inline void pci_block_user_cfg_access(struct pci_dev *dev) { } 748static inline void pci_block_user_cfg_access(struct pci_dev *dev) { }
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 585d28e960dd..739fa4d0e539 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -39,8 +39,6 @@
39#if !defined( IB_MAD_H ) 39#if !defined( IB_MAD_H )
40#define IB_MAD_H 40#define IB_MAD_H
41 41
42#include <linux/pci.h>
43
44#include <rdma/ib_verbs.h> 42#include <rdma/ib_verbs.h>
45 43
46/* Management base version */ 44/* Management base version */
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 0133f4f9e9f0..615ce97c6cfd 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/msi.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/kernel_stat.h> 17#include <linux/kernel_stat.h>
@@ -185,6 +186,8 @@ int set_irq_msi(unsigned int irq, struct msi_desc *entry)
185 desc = irq_desc + irq; 186 desc = irq_desc + irq;
186 spin_lock_irqsave(&desc->lock, flags); 187 spin_lock_irqsave(&desc->lock, flags);
187 desc->msi_desc = entry; 188 desc->msi_desc = entry;
189 if (entry)
190 entry->irq = irq;
188 spin_unlock_irqrestore(&desc->lock, flags); 191 spin_unlock_irqrestore(&desc->lock, flags);
189 return 0; 192 return 0;
190} 193}
diff --git a/sound/core/init.c b/sound/core/init.c
index 4a431e3ea3a2..f2fe35737186 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -26,7 +26,6 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/pci.h>
30#include <linux/pm.h> 29#include <linux/pm.h>
31 30
32#include <sound/core.h> 31#include <sound/core.h>
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index a339f0c0d512..23018a7c063a 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -47,7 +47,6 @@
47#include <linux/interrupt.h> 47#include <linux/interrupt.h>
48#include <linux/kernel.h> 48#include <linux/kernel.h>
49#include <linux/poll.h> 49#include <linux/poll.h>
50#include <linux/pci.h>
51#include <linux/bitops.h> 50#include <linux/bitops.h>
52#include <linux/spinlock.h> 51#include <linux/spinlock.h>
53#include <linux/smp_lock.h> 52#include <linux/smp_lock.h>
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index dcd8d6d2f56f..a9c23b2502ad 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -44,6 +44,7 @@
44#include <linux/smp_lock.h> 44#include <linux/smp_lock.h>
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/mm.h> 46#include <linux/mm.h>
47#include <linux/device.h>
47 48
48/* 49/*
49 * This ought to be moved into include/asm/dma.h 50 * This ought to be moved into include/asm/dma.h
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index b913a1fb8c21..9c3a9c8d1dc2 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -62,7 +62,6 @@
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/init.h> 63#include <linux/init.h>
64#include <linux/interrupt.h> 64#include <linux/interrupt.h>
65#include <linux/pci.h>
66#include <linux/slab.h> 65#include <linux/slab.h>
67#include <linux/moduleparam.h> 66#include <linux/moduleparam.h>
68#include <sound/core.h> 67#include <sound/core.h>
@@ -71,6 +70,7 @@
71#include <sound/ac97_codec.h> 70#include <sound/ac97_codec.h>
72#include <sound/info.h> 71#include <sound/info.h>
73#include <sound/tlv.h> 72#include <sound/tlv.h>
73#include <asm/io.h>
74 74
75#include "ca0106.h" 75#include "ca0106.h"
76 76
diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c
index 75ca421eb3a1..ae80f51d8c4f 100644
--- a/sound/pci/ca0106/ca0106_proc.c
+++ b/sound/pci/ca0106/ca0106_proc.c
@@ -64,7 +64,6 @@
64#include <linux/delay.h> 64#include <linux/delay.h>
65#include <linux/init.h> 65#include <linux/init.h>
66#include <linux/interrupt.h> 66#include <linux/interrupt.h>
67#include <linux/pci.h>
68#include <linux/slab.h> 67#include <linux/slab.h>
69#include <linux/moduleparam.h> 68#include <linux/moduleparam.h>
70#include <sound/core.h> 69#include <sound/core.h>
@@ -73,6 +72,7 @@
73#include <sound/ac97_codec.h> 72#include <sound/ac97_codec.h>
74#include <sound/info.h> 73#include <sound/info.h>
75#include <sound/asoundef.h> 74#include <sound/asoundef.h>
75#include <asm/io.h>
76 76
77#include "ca0106.h" 77#include "ca0106.h"
78 78
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index 89c402770a1d..336e77e2600c 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -23,7 +23,6 @@
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <asm/io.h> 24#include <asm/io.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/pci.h>
27#include <linux/pm.h> 26#include <linux/pm.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
index 343f51d5311b..57e357de1500 100644
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
@@ -24,7 +24,6 @@
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <asm/io.h> 25#include <asm/io.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/pci.h>
28#include <linux/pm.h> 27#include <linux/pm.h>
29#include <linux/init.h> 28#include <linux/init.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 1589d2f2917f..1e5ff0cd3709 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -23,7 +23,6 @@
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h>
27#include <sound/core.h> 26#include <sound/core.h>
28#include "hda_codec.h" 27#include "hda_codec.h"
29#include "hda_local.h" 28#include "hda_local.h"
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index 17df4d0fe135..e313e685f161 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -23,7 +23,6 @@
23 23
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/pci.h>
27#include <sound/core.h> 26#include <sound/core.h>
28#include "hda_codec.h" 27#include "hda_codec.h"
29#include "hda_local.h" 28#include "hda_local.h"
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index 7333f275decd..831469d3a923 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -25,7 +25,6 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/pci.h>
29#include <sound/core.h> 28#include <sound/core.h>
30#include "hda_codec.h" 29#include "hda_codec.h"
31#include "hda_local.h" 30#include "hda_local.h"
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index ed5e45e35963..6fcda9bcf0cf 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -26,7 +26,6 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h> 29#include <sound/core.h>
31#include "hda_codec.h" 30#include "hda_codec.h"
32#include "hda_local.h" 31#include "hda_local.h"
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 4c839b031729..2b11ac8689b9 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -35,7 +35,6 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/pci.h>
39#include <sound/core.h> 38#include <sound/core.h>
40#include "hda_codec.h" 39#include "hda_codec.h"
41#include "hda_local.h" 40#include "hda_local.h"