aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-01-09 21:41:42 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-09 21:41:42 -0500
commit977127174a7dff52d17faeeb4c4949a54221881f (patch)
treeb05b9d18a1256d7ed97bdfb537213a8d70ccca57
parent80c0531514516e43ae118ddf38424e06e5c3cb3c (diff)
parent93b47684f60cf25e8cefe19a21d94aa0257fdf36 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/pci-2.6
-rw-r--r--Documentation/filesystems/sysfs-pci.txt21
-rw-r--r--Documentation/pci-error-recovery.txt246
-rw-r--r--MAINTAINERS7
-rw-r--r--arch/alpha/kernel/sys_alcor.c3
-rw-r--r--arch/alpha/kernel/sys_sio.c6
-rw-r--r--arch/frv/mb93090-mb00/pci-frv.c8
-rw-r--r--arch/frv/mb93090-mb00/pci-irq.c4
-rw-r--r--arch/i386/kernel/scx200.c2
-rw-r--r--arch/i386/pci/acpi.c2
-rw-r--r--arch/i386/pci/fixup.c7
-rw-r--r--arch/i386/pci/irq.c42
-rw-r--r--arch/mips/vr41xx/common/vrc4173.c2
-rw-r--r--arch/ppc/kernel/pci.c21
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_cds_common.c11
-rw-r--r--arch/sparc64/kernel/ebus.c15
-rw-r--r--drivers/acpi/pci_irq.c7
-rw-r--r--drivers/block/DAC960.c2
-rw-r--r--drivers/block/cciss.c2
-rw-r--r--drivers/block/sx8.c2
-rw-r--r--drivers/block/umem.c2
-rw-r--r--drivers/hwmon/vt8231.c2
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c2
-rw-r--r--drivers/media/radio/radio-maxiradio.c2
-rw-r--r--drivers/parport/parport_serial.c2
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c6
-rw-r--r--drivers/pci/hotplug/cpqphp.h8
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c127
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c28
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c138
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c2
-rw-r--r--drivers/pci/hotplug/pciehp_core.c92
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c19
-rw-r--r--drivers/pci/hotplug/pciehp_pci.c52
-rw-r--r--drivers/pci/hotplug/pciehprm_acpi.c13
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c27
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c47
-rw-r--r--drivers/pci/hotplug/shpchp.h4
-rw-r--r--drivers/pci/hotplug/shpchp_core.c16
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c37
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c138
-rw-r--r--drivers/pci/hotplug/shpchp_pci.c19
-rw-r--r--drivers/pci/pci.c7
-rw-r--r--drivers/pci/pci.h5
-rw-r--r--drivers/pci/pcie/portdrv_core.c4
-rw-r--r--drivers/pci/probe.c49
-rw-r--r--drivers/pci/proc.c3
-rw-r--r--drivers/pci/quirks.c26
-rw-r--r--drivers/pci/remove.c3
-rw-r--r--drivers/pcmcia/vrc4173_cardu.c2
-rw-r--r--drivers/serial/serial_txx9.c2
-rw-r--r--drivers/video/cyblafb.c1
-rw-r--r--include/linux/pci.h69
-rw-r--r--sound/oss/ad1889.c2
-rw-r--r--sound/oss/btaudio.c2
-rw-r--r--sound/oss/cmpci.c2
-rw-r--r--sound/oss/cs4281/cs4281m.c2
-rw-r--r--sound/oss/cs46xx.c2
-rw-r--r--sound/oss/emu10k1/main.c2
-rw-r--r--sound/oss/es1370.c2
-rw-r--r--sound/oss/es1371.c2
-rw-r--r--sound/oss/ite8172.c2
-rw-r--r--sound/oss/kahlua.c2
-rw-r--r--sound/oss/maestro.c2
-rw-r--r--sound/oss/nec_vrc5477.c2
-rw-r--r--sound/oss/nm256_audio.c2
-rw-r--r--sound/oss/rme96xx.c2
-rw-r--r--sound/oss/sonicvibes.c2
-rw-r--r--sound/oss/ymfpci.c2
68 files changed, 954 insertions, 442 deletions
diff --git a/Documentation/filesystems/sysfs-pci.txt b/Documentation/filesystems/sysfs-pci.txt
index 988a62fae11f..7ba2baa165ff 100644
--- a/Documentation/filesystems/sysfs-pci.txt
+++ b/Documentation/filesystems/sysfs-pci.txt
@@ -1,4 +1,5 @@
1Accessing PCI device resources through sysfs 1Accessing PCI device resources through sysfs
2--------------------------------------------
2 3
3sysfs, usually mounted at /sys, provides access to PCI resources on platforms 4sysfs, usually mounted at /sys, provides access to PCI resources on platforms
4that support it. For example, a given bus might look like this: 5that support it. For example, a given bus might look like this:
@@ -47,14 +48,21 @@ files, each with their own function.
47 binary - file contains binary data 48 binary - file contains binary data
48 cpumask - file contains a cpumask type 49 cpumask - file contains a cpumask type
49 50
50The read only files are informational, writes to them will be ignored. 51The read only files are informational, writes to them will be ignored, with
51Writable files can be used to perform actions on the device (e.g. changing 52the exception of the 'rom' file. Writable files can be used to perform
52config space, detaching a device). mmapable files are available via an 53actions on the device (e.g. changing config space, detaching a device).
53mmap of the file at offset 0 and can be used to do actual device programming 54mmapable files are available via an mmap of the file at offset 0 and can be
54from userspace. Note that some platforms don't support mmapping of certain 55used to do actual device programming from userspace. Note that some platforms
55resources, so be sure to check the return value from any attempted mmap. 56don't support mmapping of certain resources, so be sure to check the return
57value from any attempted mmap.
58
59The 'rom' file is special in that it provides read-only access to the device's
60ROM file, if available. It's disabled by default, however, so applications
61should write the string "1" to the file to enable it before attempting a read
62call, and disable it following the access by writing "0" to the file.
56 63
57Accessing legacy resources through sysfs 64Accessing legacy resources through sysfs
65----------------------------------------
58 66
59Legacy I/O port and ISA memory resources are also provided in sysfs if the 67Legacy I/O port and ISA memory resources are also provided in sysfs if the
60underlying platform supports them. They're located in the PCI class heirarchy, 68underlying platform supports them. They're located in the PCI class heirarchy,
@@ -75,6 +83,7 @@ simply dereference the returned pointer (after checking for errors of course)
75to access legacy memory space. 83to access legacy memory space.
76 84
77Supporting PCI access on new platforms 85Supporting PCI access on new platforms
86--------------------------------------
78 87
79In order to support PCI resource mapping as described above, Linux platform 88In order to support PCI resource mapping as described above, Linux platform
80code must define HAVE_PCI_MMAP and provide a pci_mmap_page_range function. 89code must define HAVE_PCI_MMAP and provide a pci_mmap_page_range function.
diff --git a/Documentation/pci-error-recovery.txt b/Documentation/pci-error-recovery.txt
new file mode 100644
index 000000000000..d089967e4948
--- /dev/null
+++ b/Documentation/pci-error-recovery.txt
@@ -0,0 +1,246 @@
1
2 PCI Error Recovery
3 ------------------
4 May 31, 2005
5
6 Current document maintainer:
7 Linas Vepstas <linas@austin.ibm.com>
8
9
10Some PCI bus controllers are able to detect certain "hard" PCI errors
11on the bus, such as parity errors on the data and address busses, as
12well as SERR and PERR errors. These chipsets are then able to disable
13I/O to/from the affected device, so that, for example, a bad DMA
14address doesn't end up corrupting system memory. These same chipsets
15are also able to reset the affected PCI device, and return it to
16working condition. This document describes a generic API form
17performing error recovery.
18
19The core idea is that after a PCI error has been detected, there must
20be a way for the kernel to coordinate with all affected device drivers
21so that the pci card can be made operational again, possibly after
22performing a full electrical #RST of the PCI card. The API below
23provides a generic API for device drivers to be notified of PCI
24errors, and to be notified of, and respond to, a reset sequence.
25
26Preliminary sketch of API, cut-n-pasted-n-modified email from
27Ben Herrenschmidt, circa 5 april 2005
28
29The error recovery API support is exposed to the driver in the form of
30a structure of function pointers pointed to by a new field in struct
31pci_driver. The absence of this pointer in pci_driver denotes an
32"non-aware" driver, behaviour on these is platform dependant.
33Platforms like ppc64 can try to simulate pci hotplug remove/add.
34
35The definition of "pci_error_token" is not covered here. It is based on
36Seto's work on the synchronous error detection. We still need to define
37functions for extracting infos out of an opaque error token. This is
38separate from this API.
39
40This structure has the form:
41
42struct pci_error_handlers
43{
44 int (*error_detected)(struct pci_dev *dev, pci_error_token error);
45 int (*mmio_enabled)(struct pci_dev *dev);
46 int (*resume)(struct pci_dev *dev);
47 int (*link_reset)(struct pci_dev *dev);
48 int (*slot_reset)(struct pci_dev *dev);
49};
50
51A driver doesn't have to implement all of these callbacks. The
52only mandatory one is error_detected(). If a callback is not
53implemented, the corresponding feature is considered unsupported.
54For example, if mmio_enabled() and resume() aren't there, then the
55driver is assumed as not doing any direct recovery and requires
56a reset. If link_reset() is not implemented, the card is assumed as
57not caring about link resets, in which case, if recover is supported,
58the core can try recover (but not slot_reset() unless it really did
59reset the slot). If slot_reset() is not supported, link_reset() can
60be called instead on a slot reset.
61
62At first, the call will always be :
63
64 1) error_detected()
65
66 Error detected. This is sent once after an error has been detected. At
67this point, the device might not be accessible anymore depending on the
68platform (the slot will be isolated on ppc64). The driver may already
69have "noticed" the error because of a failing IO, but this is the proper
70"synchronisation point", that is, it gives a chance to the driver to
71cleanup, waiting for pending stuff (timers, whatever, etc...) to
72complete; it can take semaphores, schedule, etc... everything but touch
73the device. Within this function and after it returns, the driver
74shouldn't do any new IOs. Called in task context. This is sort of a
75"quiesce" point. See note about interrupts at the end of this doc.
76
77 Result codes:
78 - PCIERR_RESULT_CAN_RECOVER:
79 Driever returns this if it thinks it might be able to recover
80 the HW by just banging IOs or if it wants to be given
81 a chance to extract some diagnostic informations (see
82 below).
83 - PCIERR_RESULT_NEED_RESET:
84 Driver returns this if it thinks it can't recover unless the
85 slot is reset.
86 - PCIERR_RESULT_DISCONNECT:
87 Return this if driver thinks it won't recover at all,
88 (this will detach the driver ? or just leave it
89 dangling ? to be decided)
90
91So at this point, we have called error_detected() for all drivers
92on the segment that had the error. On ppc64, the slot is isolated. What
93happens now typically depends on the result from the drivers. If all
94drivers on the segment/slot return PCIERR_RESULT_CAN_RECOVER, we would
95re-enable IOs on the slot (or do nothing special if the platform doesn't
96isolate slots) and call 2). If not and we can reset slots, we go to 4),
97if neither, we have a dead slot. If it's an hotplug slot, we might
98"simulate" reset by triggering HW unplug/replug though.
99
100>>> Current ppc64 implementation assumes that a device driver will
101>>> *not* schedule or semaphore in this routine; the current ppc64
102>>> implementation uses one kernel thread to notify all devices;
103>>> thus, of one device sleeps/schedules, all devices are affected.
104>>> Doing better requires complex multi-threaded logic in the error
105>>> recovery implementation (e.g. waiting for all notification threads
106>>> to "join" before proceeding with recovery.) This seems excessively
107>>> complex and not worth implementing.
108
109>>> The current ppc64 implementation doesn't much care if the device
110>>> attempts i/o at this point, or not. I/O's will fail, returning
111>>> a value of 0xff on read, and writes will be dropped. If the device
112>>> driver attempts more than 10K I/O's to a frozen adapter, it will
113>>> assume that the device driver has gone into an infinite loop, and
114>>> it will panic the the kernel.
115
116 2) mmio_enabled()
117
118 This is the "early recovery" call. IOs are allowed again, but DMA is
119not (hrm... to be discussed, I prefer not), with some restrictions. This
120is NOT a callback for the driver to start operations again, only to
121peek/poke at the device, extract diagnostic information, if any, and
122eventually do things like trigger a device local reset or some such,
123but not restart operations. This is sent if all drivers on a segment
124agree that they can try to recover and no automatic link reset was
125performed by the HW. If the platform can't just re-enable IOs without
126a slot reset or a link reset, it doesn't call this callback and goes
127directly to 3) or 4). All IOs should be done _synchronously_ from
128within this callback, errors triggered by them will be returned via
129the normal pci_check_whatever() api, no new error_detected() callback
130will be issued due to an error happening here. However, such an error
131might cause IOs to be re-blocked for the whole segment, and thus
132invalidate the recovery that other devices on the same segment might
133have done, forcing the whole segment into one of the next states,
134that is link reset or slot reset.
135
136 Result codes:
137 - PCIERR_RESULT_RECOVERED
138 Driver returns this if it thinks the device is fully
139 functionnal and thinks it is ready to start
140 normal driver operations again. There is no
141 guarantee that the driver will actually be
142 allowed to proceed, as another driver on the
143 same segment might have failed and thus triggered a
144 slot reset on platforms that support it.
145
146 - PCIERR_RESULT_NEED_RESET
147 Driver returns this if it thinks the device is not
148 recoverable in it's current state and it needs a slot
149 reset to proceed.
150
151 - PCIERR_RESULT_DISCONNECT
152 Same as above. Total failure, no recovery even after
153 reset driver dead. (To be defined more precisely)
154
155>>> The current ppc64 implementation does not implement this callback.
156
157 3) link_reset()
158
159 This is called after the link has been reset. This is typically
160a PCI Express specific state at this point and is done whenever a
161non-fatal error has been detected that can be "solved" by resetting
162the link. This call informs the driver of the reset and the driver
163should check if the device appears to be in working condition.
164This function acts a bit like 2) mmio_enabled(), in that the driver
165is not supposed to restart normal driver I/O operations right away.
166Instead, it should just "probe" the device to check it's recoverability
167status. If all is right, then the core will call resume() once all
168drivers have ack'd link_reset().
169
170 Result codes:
171 (identical to mmio_enabled)
172
173>>> The current ppc64 implementation does not implement this callback.
174
175 4) slot_reset()
176
177 This is called after the slot has been soft or hard reset by the
178platform. A soft reset consists of asserting the adapter #RST line
179and then restoring the PCI BARs and PCI configuration header. If the
180platform supports PCI hotplug, then it might instead perform a hard
181reset by toggling power on the slot off/on. This call gives drivers
182the chance to re-initialize the hardware (re-download firmware, etc.),
183but drivers shouldn't restart normal I/O processing operations at
184this point. (See note about interrupts; interrupts aren't guaranteed
185to be delivered until the resume() callback has been called). If all
186device drivers report success on this callback, the patform will call
187resume() to complete the error handling and let the driver restart
188normal I/O processing.
189
190A driver can still return a critical failure for this function if
191it can't get the device operational after reset. If the platform
192previously tried a soft reset, it migh now try a hard reset (power
193cycle) and then call slot_reset() again. It the device still can't
194be recovered, there is nothing more that can be done; the platform
195will typically report a "permanent failure" in such a case. The
196device will be considered "dead" in this case.
197
198 Result codes:
199 - PCIERR_RESULT_DISCONNECT
200 Same as above.
201
202>>> The current ppc64 implementation does not try a power-cycle reset
203>>> if the driver returned PCIERR_RESULT_DISCONNECT. However, it should.
204
205 5) resume()
206
207 This is called if all drivers on the segment have returned
208PCIERR_RESULT_RECOVERED from one of the 3 prevous callbacks.
209That basically tells the driver to restart activity, tht everything
210is back and running. No result code is taken into account here. If
211a new error happens, it will restart a new error handling process.
212
213That's it. I think this covers all the possibilities. The way those
214callbacks are called is platform policy. A platform with no slot reset
215capability for example may want to just "ignore" drivers that can't
216recover (disconnect them) and try to let other cards on the same segment
217recover. Keep in mind that in most real life cases, though, there will
218be only one driver per segment.
219
220Now, there is a note about interrupts. If you get an interrupt and your
221device is dead or has been isolated, there is a problem :)
222
223After much thinking, I decided to leave that to the platform. That is,
224the recovery API only precies that:
225
226 - There is no guarantee that interrupt delivery can proceed from any
227device on the segment starting from the error detection and until the
228restart callback is sent, at which point interrupts are expected to be
229fully operational.
230
231 - There is no guarantee that interrupt delivery is stopped, that is, ad
232river that gets an interrupts after detecting an error, or that detects
233and error within the interrupt handler such that it prevents proper
234ack'ing of the interrupt (and thus removal of the source) should just
235return IRQ_NOTHANDLED. It's up to the platform to deal with taht
236condition, typically by masking the irq source during the duration of
237the error handling. It is expected that the platform "knows" which
238interrupts are routed to error-management capable slots and can deal
239with temporarily disabling that irq number during error processing (this
240isn't terribly complex). That means some IRQ latency for other devices
241sharing the interrupt, but there is simply no other way. High end
242platforms aren't supposed to share interrupts between many devices
243anyway :)
244
245
246Revised: 31 May 2005 Linas Vepstas <linas@austin.ibm.com>
diff --git a/MAINTAINERS b/MAINTAINERS
index 9b788d779472..07420161e669 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1987,6 +1987,13 @@ M: hch@infradead.org
1987L: linux-abi-devel@lists.sourceforge.net 1987L: linux-abi-devel@lists.sourceforge.net
1988S: Maintained 1988S: Maintained
1989 1989
1990PCI ERROR RECOVERY
1991P: Linas Vepstas
1992M: linas@austin.ibm.com
1993L: linux-kernel@vger.kernel.org
1994L: linux-pci@atrey.karlin.mff.cuni.cz
1995S: Supported
1996
1990PCI SOUND DRIVERS (ES1370, ES1371 and SONICVIBES) 1997PCI SOUND DRIVERS (ES1370, ES1371 and SONICVIBES)
1991P: Thomas Sailer 1998P: Thomas Sailer
1992M: sailer@ife.ee.ethz.ch 1999M: sailer@ife.ee.ethz.ch
diff --git a/arch/alpha/kernel/sys_alcor.c b/arch/alpha/kernel/sys_alcor.c
index 145dcde143ae..d7f0e97fe56f 100644
--- a/arch/alpha/kernel/sys_alcor.c
+++ b/arch/alpha/kernel/sys_alcor.c
@@ -254,7 +254,7 @@ alcor_init_pci(void)
254 * motherboard, by looking for a 21040 TULIP in slot 6, which is 254 * motherboard, by looking for a 21040 TULIP in slot 6, which is
255 * built into XLT and BRET/MAVERICK, but not available on ALCOR. 255 * built into XLT and BRET/MAVERICK, but not available on ALCOR.
256 */ 256 */
257 dev = pci_find_device(PCI_VENDOR_ID_DEC, 257 dev = pci_get_device(PCI_VENDOR_ID_DEC,
258 PCI_DEVICE_ID_DEC_TULIP, 258 PCI_DEVICE_ID_DEC_TULIP,
259 NULL); 259 NULL);
260 if (dev && dev->devfn == PCI_DEVFN(6,0)) { 260 if (dev && dev->devfn == PCI_DEVFN(6,0)) {
@@ -262,6 +262,7 @@ alcor_init_pci(void)
262 printk(KERN_INFO "%s: Detected AS500 or XLT motherboard.\n", 262 printk(KERN_INFO "%s: Detected AS500 or XLT motherboard.\n",
263 __FUNCTION__); 263 __FUNCTION__);
264 } 264 }
265 pci_dev_put(dev);
265} 266}
266 267
267 268
diff --git a/arch/alpha/kernel/sys_sio.c b/arch/alpha/kernel/sys_sio.c
index 47df48a6ddb7..131a2d9f79d3 100644
--- a/arch/alpha/kernel/sys_sio.c
+++ b/arch/alpha/kernel/sys_sio.c
@@ -105,7 +105,7 @@ sio_collect_irq_levels(void)
105 struct pci_dev *dev = NULL; 105 struct pci_dev *dev = NULL;
106 106
107 /* Iterate through the devices, collecting IRQ levels. */ 107 /* Iterate through the devices, collecting IRQ levels. */
108 while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 108 for_each_pci_dev(dev) {
109 if ((dev->class >> 16 == PCI_BASE_CLASS_BRIDGE) && 109 if ((dev->class >> 16 == PCI_BASE_CLASS_BRIDGE) &&
110 (dev->class >> 8 != PCI_CLASS_BRIDGE_PCMCIA)) 110 (dev->class >> 8 != PCI_CLASS_BRIDGE_PCMCIA))
111 continue; 111 continue;
@@ -229,8 +229,8 @@ alphabook1_init_pci(void)
229 */ 229 */
230 230
231 dev = NULL; 231 dev = NULL;
232 while ((dev = pci_find_device(PCI_VENDOR_ID_NCR, PCI_ANY_ID, dev))) { 232 while ((dev = pci_get_device(PCI_VENDOR_ID_NCR, PCI_ANY_ID, dev))) {
233 if (dev->device == PCI_DEVICE_ID_NCR_53C810 233 if (dev->device == PCI_DEVICE_ID_NCR_53C810
234 || dev->device == PCI_DEVICE_ID_NCR_53C815 234 || dev->device == PCI_DEVICE_ID_NCR_53C815
235 || dev->device == PCI_DEVICE_ID_NCR_53C820 235 || dev->device == PCI_DEVICE_ID_NCR_53C820
236 || dev->device == PCI_DEVICE_ID_NCR_53C825) { 236 || dev->device == PCI_DEVICE_ID_NCR_53C825) {
diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c
index 83e5489cf039..0a26bf6f1cd4 100644
--- a/arch/frv/mb93090-mb00/pci-frv.c
+++ b/arch/frv/mb93090-mb00/pci-frv.c
@@ -142,9 +142,7 @@ static void __init pcibios_allocate_resources(int pass)
142 u16 command; 142 u16 command;
143 struct resource *r, *pr; 143 struct resource *r, *pr;
144 144
145 while (dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev), 145 for_each_pci_dev(dev) {
146 dev != NULL
147 ) {
148 pci_read_config_word(dev, PCI_COMMAND, &command); 146 pci_read_config_word(dev, PCI_COMMAND, &command);
149 for(idx = 0; idx < 6; idx++) { 147 for(idx = 0; idx < 6; idx++) {
150 r = &dev->resource[idx]; 148 r = &dev->resource[idx];
@@ -188,9 +186,7 @@ static void __init pcibios_assign_resources(void)
188 int idx; 186 int idx;
189 struct resource *r; 187 struct resource *r;
190 188
191 while (dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev), 189 for_each_pci_dev(dev) {
192 dev != NULL
193 ) {
194 int class = dev->class >> 8; 190 int class = dev->class >> 8;
195 191
196 /* Don't touch classless devices and host bridges */ 192 /* Don't touch classless devices and host bridges */
diff --git a/arch/frv/mb93090-mb00/pci-irq.c b/arch/frv/mb93090-mb00/pci-irq.c
index 24622d89b1ca..c4a1144c98b0 100644
--- a/arch/frv/mb93090-mb00/pci-irq.c
+++ b/arch/frv/mb93090-mb00/pci-irq.c
@@ -48,9 +48,7 @@ void __init pcibios_fixup_irqs(void)
48 struct pci_dev *dev = NULL; 48 struct pci_dev *dev = NULL;
49 uint8_t line, pin; 49 uint8_t line, pin;
50 50
51 while (dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev), 51 for_each_pci_dev(dev) {
52 dev != NULL
53 ) {
54 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 52 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
55 if (pin) { 53 if (pin) {
56 dev->irq = pci_bus0_irq_routing[PCI_SLOT(dev->devfn)][pin - 1]; 54 dev->irq = pci_bus0_irq_routing[PCI_SLOT(dev->devfn)][pin - 1];
diff --git a/arch/i386/kernel/scx200.c b/arch/i386/kernel/scx200.c
index 9c968ae67c43..321f5fd26e75 100644
--- a/arch/i386/kernel/scx200.c
+++ b/arch/i386/kernel/scx200.c
@@ -143,7 +143,7 @@ static int __init scx200_init(void)
143{ 143{
144 printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n"); 144 printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n");
145 145
146 return pci_module_init(&scx200_pci_driver); 146 return pci_register_driver(&scx200_pci_driver);
147} 147}
148 148
149static void __exit scx200_cleanup(void) 149static void __exit scx200_cleanup(void)
diff --git a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c
index 4c4522b43be5..b33aea845f58 100644
--- a/arch/i386/pci/acpi.c
+++ b/arch/i386/pci/acpi.c
@@ -53,7 +53,7 @@ static int __init pci_acpi_init(void)
53 * don't use pci_enable_device(). 53 * don't use pci_enable_device().
54 */ 54 */
55 printk(KERN_INFO "PCI: Routing PCI interrupts for all devices because \"pci=routeirq\" specified\n"); 55 printk(KERN_INFO "PCI: Routing PCI interrupts for all devices because \"pci=routeirq\" specified\n");
56 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) 56 for_each_pci_dev(dev)
57 acpi_pci_irq_enable(dev); 57 acpi_pci_irq_enable(dev);
58 } else 58 } else
59 printk(KERN_INFO "PCI: If a device doesn't work, try \"pci=routeirq\". If it helps, post a report\n"); 59 printk(KERN_INFO "PCI: If a device doesn't work, try \"pci=routeirq\". If it helps, post a report\n");
diff --git a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
index eeb1b1f2d548..65f67070db64 100644
--- a/arch/i386/pci/fixup.c
+++ b/arch/i386/pci/fixup.c
@@ -413,6 +413,13 @@ static struct dmi_system_id __devinitdata toshiba_ohci1394_dmi_table[] = {
413 DMI_MATCH(DMI_PRODUCT_VERSION, "PSM4"), 413 DMI_MATCH(DMI_PRODUCT_VERSION, "PSM4"),
414 }, 414 },
415 }, 415 },
416 {
417 .ident = "Toshiba A40 based laptop",
418 .matches = {
419 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
420 DMI_MATCH(DMI_PRODUCT_VERSION, "PSA40U"),
421 },
422 },
416 { } 423 { }
417}; 424};
418 425
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index ee8e01697d96..e715aa930036 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -78,7 +78,7 @@ static inline struct irq_routing_table * pirq_check_routing_table(u8 *addr)
78 for (i=0; i < rt->size; i++) 78 for (i=0; i < rt->size; i++)
79 sum += addr[i]; 79 sum += addr[i];
80 if (!sum) { 80 if (!sum) {
81 DBG("PCI: Interrupt Routing Table found at 0x%p\n", rt); 81 DBG(KERN_DEBUG "PCI: Interrupt Routing Table found at 0x%p\n", rt);
82 return rt; 82 return rt;
83 } 83 }
84 return NULL; 84 return NULL;
@@ -128,7 +128,7 @@ static void __init pirq_peer_trick(void)
128#ifdef DEBUG 128#ifdef DEBUG
129 { 129 {
130 int j; 130 int j;
131 DBG("%02x:%02x slot=%02x", e->bus, e->devfn/8, e->slot); 131 DBG(KERN_DEBUG "%02x:%02x slot=%02x", e->bus, e->devfn/8, e->slot);
132 for(j=0; j<4; j++) 132 for(j=0; j<4; j++)
133 DBG(" %d:%02x/%04x", j, e->irq[j].link, e->irq[j].bitmap); 133 DBG(" %d:%02x/%04x", j, e->irq[j].link, e->irq[j].bitmap);
134 DBG("\n"); 134 DBG("\n");
@@ -160,10 +160,10 @@ void eisa_set_level_irq(unsigned int irq)
160 return; 160 return;
161 161
162 eisa_irq_mask |= (1 << irq); 162 eisa_irq_mask |= (1 << irq);
163 printk("PCI: setting IRQ %u as level-triggered\n", irq); 163 printk(KERN_DEBUG "PCI: setting IRQ %u as level-triggered\n", irq);
164 val = inb(port); 164 val = inb(port);
165 if (!(val & mask)) { 165 if (!(val & mask)) {
166 DBG(" -> edge"); 166 DBG(KERN_DEBUG " -> edge");
167 outb(val | mask, port); 167 outb(val | mask, port);
168 } 168 }
169} 169}
@@ -677,11 +677,11 @@ static __init int ali_router_probe(struct irq_router *r, struct pci_dev *router,
677 { 677 {
678 case PCI_DEVICE_ID_AL_M1533: 678 case PCI_DEVICE_ID_AL_M1533:
679 case PCI_DEVICE_ID_AL_M1563: 679 case PCI_DEVICE_ID_AL_M1563:
680 printk("PCI: Using ALI IRQ Router\n"); 680 printk(KERN_DEBUG "PCI: Using ALI IRQ Router\n");
681 r->name = "ALI"; 681 r->name = "ALI";
682 r->get = pirq_ali_get; 682 r->get = pirq_ali_get;
683 r->set = pirq_ali_set; 683 r->set = pirq_ali_set;
684 return 1; 684 return 1;
685 } 685 }
686 return 0; 686 return 0;
687} 687}
@@ -749,12 +749,13 @@ static void __init pirq_find_router(struct irq_router *r)
749 r->get = NULL; 749 r->get = NULL;
750 r->set = NULL; 750 r->set = NULL;
751 751
752 DBG("PCI: Attempting to find IRQ router for %04x:%04x\n", 752 DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for %04x:%04x\n",
753 rt->rtr_vendor, rt->rtr_device); 753 rt->rtr_vendor, rt->rtr_device);
754 754
755 pirq_router_dev = pci_find_slot(rt->rtr_bus, rt->rtr_devfn); 755 pirq_router_dev = pci_find_slot(rt->rtr_bus, rt->rtr_devfn);
756 if (!pirq_router_dev) { 756 if (!pirq_router_dev) {
757 DBG("PCI: Interrupt router not found at %02x:%02x\n", rt->rtr_bus, rt->rtr_devfn); 757 DBG(KERN_DEBUG "PCI: Interrupt router not found at "
758 "%02x:%02x\n", rt->rtr_bus, rt->rtr_devfn);
758 return; 759 return;
759 } 760 }
760 761
@@ -799,7 +800,7 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
799 /* Find IRQ pin */ 800 /* Find IRQ pin */
800 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 801 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
801 if (!pin) { 802 if (!pin) {
802 DBG(" -> no interrupt pin\n"); 803 DBG(KERN_DEBUG " -> no interrupt pin\n");
803 return 0; 804 return 0;
804 } 805 }
805 pin = pin - 1; 806 pin = pin - 1;
@@ -809,16 +810,16 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
809 if (!pirq_table) 810 if (!pirq_table)
810 return 0; 811 return 0;
811 812
812 DBG("IRQ for %s[%c]", pci_name(dev), 'A' + pin); 813 DBG(KERN_DEBUG "IRQ for %s[%c]", pci_name(dev), 'A' + pin);
813 info = pirq_get_info(dev); 814 info = pirq_get_info(dev);
814 if (!info) { 815 if (!info) {
815 DBG(" -> not found in routing table\n"); 816 DBG(" -> not found in routing table\n" KERN_DEBUG);
816 return 0; 817 return 0;
817 } 818 }
818 pirq = info->irq[pin].link; 819 pirq = info->irq[pin].link;
819 mask = info->irq[pin].bitmap; 820 mask = info->irq[pin].bitmap;
820 if (!pirq) { 821 if (!pirq) {
821 DBG(" -> not routed\n"); 822 DBG(" -> not routed\n" KERN_DEBUG);
822 return 0; 823 return 0;
823 } 824 }
824 DBG(" -> PIRQ %02x, mask %04x, excl %04x", pirq, mask, pirq_table->exclusive_irqs); 825 DBG(" -> PIRQ %02x, mask %04x, excl %04x", pirq, mask, pirq_table->exclusive_irqs);
@@ -848,7 +849,10 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
848 newirq = dev->irq; 849 newirq = dev->irq;
849 if (newirq && !((1 << newirq) & mask)) { 850 if (newirq && !((1 << newirq) & mask)) {
850 if ( pci_probe & PCI_USE_PIRQ_MASK) newirq = 0; 851 if ( pci_probe & PCI_USE_PIRQ_MASK) newirq = 0;
851 else printk(KERN_WARNING "PCI: IRQ %i for device %s doesn't match PIRQ mask - try pci=usepirqmask\n", newirq, pci_name(dev)); 852 else printk("\n" KERN_WARNING
853 "PCI: IRQ %i for device %s doesn't match PIRQ mask "
854 "- try pci=usepirqmask\n" KERN_DEBUG, newirq,
855 pci_name(dev));
852 } 856 }
853 if (!newirq && assign) { 857 if (!newirq && assign) {
854 for (i = 0; i < 16; i++) { 858 for (i = 0; i < 16; i++) {
@@ -923,14 +927,14 @@ static void __init pcibios_fixup_irqs(void)
923 struct pci_dev *dev = NULL; 927 struct pci_dev *dev = NULL;
924 u8 pin; 928 u8 pin;
925 929
926 DBG("PCI: IRQ fixup\n"); 930 DBG(KERN_DEBUG "PCI: IRQ fixup\n");
927 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 931 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
928 /* 932 /*
929 * If the BIOS has set an out of range IRQ number, just ignore it. 933 * If the BIOS has set an out of range IRQ number, just ignore it.
930 * Also keep track of which IRQ's are already in use. 934 * Also keep track of which IRQ's are already in use.
931 */ 935 */
932 if (dev->irq >= 16) { 936 if (dev->irq >= 16) {
933 DBG("%s: ignoring bogus IRQ %d\n", pci_name(dev), dev->irq); 937 DBG(KERN_DEBUG "%s: ignoring bogus IRQ %d\n", pci_name(dev), dev->irq);
934 dev->irq = 0; 938 dev->irq = 0;
935 } 939 }
936 /* If the IRQ is already assigned to a PCI device, ignore its ISA use penalty */ 940 /* If the IRQ is already assigned to a PCI device, ignore its ISA use penalty */
@@ -1039,7 +1043,7 @@ static struct dmi_system_id __initdata pciirq_dmi_table[] = {
1039 1043
1040static int __init pcibios_irq_init(void) 1044static int __init pcibios_irq_init(void)
1041{ 1045{
1042 DBG("PCI: IRQ init\n"); 1046 DBG(KERN_DEBUG "PCI: IRQ init\n");
1043 1047
1044 if (pcibios_enable_irq || raw_pci_ops == NULL) 1048 if (pcibios_enable_irq || raw_pci_ops == NULL)
1045 return 0; 1049 return 0;
diff --git a/arch/mips/vr41xx/common/vrc4173.c b/arch/mips/vr41xx/common/vrc4173.c
index 462a9af30eef..cc52e75e14e7 100644
--- a/arch/mips/vr41xx/common/vrc4173.c
+++ b/arch/mips/vr41xx/common/vrc4173.c
@@ -561,7 +561,7 @@ static int __devinit vrc4173_init(void)
561{ 561{
562 int err; 562 int err;
563 563
564 err = pci_module_init(&vrc4173_driver); 564 err = pci_register_driver(&vrc4173_driver);
565 if (err < 0) 565 if (err < 0)
566 return err; 566 return err;
567 567
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
index 50c75eec8874..704c846b2b0f 100644
--- a/arch/ppc/kernel/pci.c
+++ b/arch/ppc/kernel/pci.c
@@ -503,7 +503,7 @@ pcibios_allocate_resources(int pass)
503 u16 command; 503 u16 command;
504 struct resource *r; 504 struct resource *r;
505 505
506 while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 506 for_each_pci_dev(dev) {
507 pci_read_config_word(dev, PCI_COMMAND, &command); 507 pci_read_config_word(dev, PCI_COMMAND, &command);
508 for (idx = 0; idx < 6; idx++) { 508 for (idx = 0; idx < 6; idx++) {
509 r = &dev->resource[idx]; 509 r = &dev->resource[idx];
@@ -540,7 +540,7 @@ pcibios_assign_resources(void)
540 int idx; 540 int idx;
541 struct resource *r; 541 struct resource *r;
542 542
543 while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 543 for_each_pci_dev(dev) {
544 int class = dev->class >> 8; 544 int class = dev->class >> 8;
545 545
546 /* Don't touch classless devices and host bridges */ 546 /* Don't touch classless devices and host bridges */
@@ -867,14 +867,15 @@ pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
867 */ 867 */
868 if (!pci_to_OF_bus_map) 868 if (!pci_to_OF_bus_map)
869 return 0; 869 return 0;
870 while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 870
871 if (pci_to_OF_bus_map[dev->bus->number] != *bus) 871 for_each_pci_dev(dev)
872 continue; 872 if (pci_to_OF_bus_map[dev->bus->number] == *bus &&
873 if (dev->devfn != *devfn) 873 dev->devfn == *devfn) {
874 continue; 874 *bus = dev->bus->number;
875 *bus = dev->bus->number; 875 pci_dev_put(dev);
876 return 0; 876 return 0;
877 } 877 }
878
878 return -ENODEV; 879 return -ENODEV;
879} 880}
880EXPORT_SYMBOL(pci_device_from_OF_node); 881EXPORT_SYMBOL(pci_device_from_OF_node);
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
index 5e8cc5ec6ab5..2959e3c4083d 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
@@ -351,10 +351,10 @@ mpc85xx_cds_fixup_via(struct pci_controller *hose)
351void __init 351void __init
352mpc85xx_cds_pcibios_fixup(void) 352mpc85xx_cds_pcibios_fixup(void)
353{ 353{
354 struct pci_dev *dev = NULL; 354 struct pci_dev *dev;
355 u_char c; 355 u_char c;
356 356
357 if ((dev = pci_find_device(PCI_VENDOR_ID_VIA, 357 if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
358 PCI_DEVICE_ID_VIA_82C586_1, NULL))) { 358 PCI_DEVICE_ID_VIA_82C586_1, NULL))) {
359 /* 359 /*
360 * U-Boot does not set the enable bits 360 * U-Boot does not set the enable bits
@@ -371,21 +371,24 @@ mpc85xx_cds_pcibios_fixup(void)
371 */ 371 */
372 dev->irq = 14; 372 dev->irq = 14;
373 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 373 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
374 pci_dev_put(dev);
374 } 375 }
375 376
376 /* 377 /*
377 * Force legacy USB interrupt routing 378 * Force legacy USB interrupt routing
378 */ 379 */
379 if ((dev = pci_find_device(PCI_VENDOR_ID_VIA, 380 if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
380 PCI_DEVICE_ID_VIA_82C586_2, NULL))) { 381 PCI_DEVICE_ID_VIA_82C586_2, NULL))) {
381 dev->irq = 10; 382 dev->irq = 10;
382 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 10); 383 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 10);
384 pci_dev_put(dev);
383 } 385 }
384 386
385 if ((dev = pci_find_device(PCI_VENDOR_ID_VIA, 387 if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
386 PCI_DEVICE_ID_VIA_82C586_2, dev))) { 388 PCI_DEVICE_ID_VIA_82C586_2, dev))) {
387 dev->irq = 11; 389 dev->irq = 11;
388 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11); 390 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11);
391 pci_dev_put(dev);
389 } 392 }
390} 393}
391#endif /* CONFIG_PCI */ 394#endif /* CONFIG_PCI */
diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c
index 6ffbeb701940..7991e919d8ab 100644
--- a/arch/sparc64/kernel/ebus.c
+++ b/arch/sparc64/kernel/ebus.c
@@ -527,18 +527,12 @@ static struct pci_dev *find_next_ebus(struct pci_dev *start, int *is_rio_p)
527{ 527{
528 struct pci_dev *pdev = start; 528 struct pci_dev *pdev = start;
529 529
530 do { 530 while ((pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev)))
531 pdev = pci_find_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev); 531 if (pdev->device == PCI_DEVICE_ID_SUN_EBUS ||
532 if (pdev && 532 pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)
533 (pdev->device == PCI_DEVICE_ID_SUN_EBUS ||
534 pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS))
535 break; 533 break;
536 } while (pdev != NULL);
537 534
538 if (pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)) 535 *is_rio_p = !!(pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS));
539 *is_rio_p = 1;
540 else
541 *is_rio_p = 0;
542 536
543 return pdev; 537 return pdev;
544} 538}
@@ -637,6 +631,7 @@ void __init ebus_init(void)
637 ebus->is_rio = is_rio; 631 ebus->is_rio = is_rio;
638 ++num_ebus; 632 ++num_ebus;
639 } 633 }
634 pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */
640 635
641#ifdef CONFIG_SUN_AUXIO 636#ifdef CONFIG_SUN_AUXIO
642 auxio_probe(); 637 auxio_probe();
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 09567c2edcfb..e567c03b238e 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -361,8 +361,7 @@ acpi_pci_irq_derive(struct pci_dev *dev,
361 361
362 if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { 362 if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) {
363 /* PC card has the same IRQ as its cardbridge */ 363 /* PC card has the same IRQ as its cardbridge */
364 pci_read_config_byte(bridge, PCI_INTERRUPT_PIN, 364 bridge_pin = bridge->pin;
365 &bridge_pin);
366 if (!bridge_pin) { 365 if (!bridge_pin) {
367 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 366 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
368 "No interrupt pin configured for device %s\n", 367 "No interrupt pin configured for device %s\n",
@@ -412,7 +411,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
412 if (!dev) 411 if (!dev)
413 return_VALUE(-EINVAL); 412 return_VALUE(-EINVAL);
414 413
415 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 414 pin = dev->pin;
416 if (!pin) { 415 if (!pin) {
417 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 416 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
418 "No interrupt pin configured for device %s\n", 417 "No interrupt pin configured for device %s\n",
@@ -503,7 +502,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
503 if (!dev || !dev->bus) 502 if (!dev || !dev->bus)
504 return_VOID; 503 return_VOID;
505 504
506 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 505 pin = dev->pin;
507 if (!pin) 506 if (!pin)
508 return_VOID; 507 return_VOID;
509 pin--; 508 pin--;
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 4a7bb7dfce85..6ede1f352c29 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -7179,7 +7179,7 @@ static int DAC960_init_module(void)
7179{ 7179{
7180 int ret; 7180 int ret;
7181 7181
7182 ret = pci_module_init(&DAC960_pci_driver); 7182 ret = pci_register_driver(&DAC960_pci_driver);
7183#ifdef DAC960_GAM_MINOR 7183#ifdef DAC960_GAM_MINOR
7184 if (!ret) 7184 if (!ret)
7185 DAC960_gam_init(); 7185 DAC960_gam_init();
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index e4e9f255bd1f..12d7b9bdfa93 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3360,7 +3360,7 @@ static int __init cciss_init(void)
3360 printk(KERN_INFO DRIVER_NAME "\n"); 3360 printk(KERN_INFO DRIVER_NAME "\n");
3361 3361
3362 /* Register for our PCI devices */ 3362 /* Register for our PCI devices */
3363 return pci_module_init(&cciss_pci_driver); 3363 return pci_register_driver(&cciss_pci_driver);
3364} 3364}
3365 3365
3366static void __exit cciss_cleanup(void) 3366static void __exit cciss_cleanup(void)
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 4bdf95716e2b..2ae08b343b93 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -1755,7 +1755,7 @@ static void carm_remove_one (struct pci_dev *pdev)
1755 1755
1756static int __init carm_init(void) 1756static int __init carm_init(void)
1757{ 1757{
1758 return pci_module_init(&carm_driver); 1758 return pci_register_driver(&carm_driver);
1759} 1759}
1760 1760
1761static void __exit carm_exit(void) 1761static void __exit carm_exit(void)
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index 15299e7a1ade..a3614e6a68d0 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -1174,7 +1174,7 @@ static int __init mm_init(void)
1174 1174
1175 printk(KERN_INFO DRIVER_VERSION " : " DRIVER_DESC "\n"); 1175 printk(KERN_INFO DRIVER_VERSION " : " DRIVER_DESC "\n");
1176 1176
1177 retval = pci_module_init(&mm_pci_driver); 1177 retval = pci_register_driver(&mm_pci_driver);
1178 if (retval) 1178 if (retval)
1179 return -ENOMEM; 1179 return -ENOMEM;
1180 1180
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index d00a726d0239..3eb08f004c0f 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -841,7 +841,7 @@ static int __devinit vt8231_pci_probe(struct pci_dev *dev,
841 841
842static int __init sm_vt8231_init(void) 842static int __init sm_vt8231_init(void)
843{ 843{
844 return pci_module_init(&vt8231_pci_driver); 844 return pci_register_driver(&vt8231_pci_driver);
845} 845}
846 846
847static void __exit sm_vt8231_exit(void) 847static void __exit sm_vt8231_exit(void)
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 42c8fce04aa2..69ac8aa73eba 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -395,7 +395,7 @@ static struct pci_driver gemtek_pci_driver =
395 395
396static int __init gemtek_pci_init_module( void ) 396static int __init gemtek_pci_init_module( void )
397{ 397{
398 return pci_module_init( &gemtek_pci_driver ); 398 return pci_register_driver( &gemtek_pci_driver );
399} 399}
400 400
401static void __exit gemtek_pci_cleanup_module( void ) 401static void __exit gemtek_pci_cleanup_module( void )
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 30869308332a..c975ddd86cd5 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -338,7 +338,7 @@ static struct pci_driver maxiradio_driver = {
338 338
339static int __init maxiradio_radio_init(void) 339static int __init maxiradio_radio_init(void)
340{ 340{
341 return pci_module_init(&maxiradio_driver); 341 return pci_register_driver(&maxiradio_driver);
342} 342}
343 343
344static void __exit maxiradio_radio_exit(void) 344static void __exit maxiradio_radio_exit(void)
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index d3dad0aac7cb..76dd077e3184 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -464,7 +464,7 @@ static struct pci_driver parport_serial_pci_driver = {
464 464
465static int __init parport_serial_init (void) 465static int __init parport_serial_init (void)
466{ 466{
467 return pci_module_init (&parport_serial_pci_driver); 467 return pci_register_driver (&parport_serial_pci_driver);
468} 468}
469 469
470static void __exit parport_serial_exit (void) 470static void __exit parport_serial_exit (void)
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 8e21f6ab89a1..509a5b3ae998 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -794,12 +794,14 @@ static int enable_device(struct acpiphp_slot *slot)
794 if (PCI_SLOT(dev->devfn) != slot->device) 794 if (PCI_SLOT(dev->devfn) != slot->device)
795 continue; 795 continue;
796 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 796 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
797 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 797 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
798 max = pci_scan_bridge(bus, dev, max, pass); 798 max = pci_scan_bridge(bus, dev, max, pass);
799 if (pass && dev->subordinate)
800 pci_bus_size_bridges(dev->subordinate);
801 }
799 } 802 }
800 } 803 }
801 804
802 pci_bus_size_bridges(bus);
803 pci_bus_assign_resources(bus); 805 pci_bus_assign_resources(bus);
804 acpiphp_sanitize_bus(bus); 806 acpiphp_sanitize_bus(bus);
805 pci_enable_bridges(bus); 807 pci_enable_bridges(bus);
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index 092491e25ef2..cb88404c89fe 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -317,6 +317,7 @@ struct controller {
317 u16 vendor_id; 317 u16 vendor_id;
318 struct work_struct int_task_event; 318 struct work_struct int_task_event;
319 wait_queue_head_t queue; /* sleep & wake process */ 319 wait_queue_head_t queue; /* sleep & wake process */
320 struct dentry *dentry; /* debugfs dentry */
320}; 321};
321 322
322struct irq_mapping { 323struct irq_mapping {
@@ -399,8 +400,11 @@ struct resource_lists {
399#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n" 400#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n"
400 401
401 402
402/* sysfs functions for the hotplug controller info */ 403/* debugfs functions for the hotplug controller info */
403extern void cpqhp_create_ctrl_files (struct controller *ctrl); 404extern void cpqhp_initialize_debugfs (void);
405extern void cpqhp_shutdown_debugfs (void);
406extern void cpqhp_create_debugfs_files (struct controller *ctrl);
407extern void cpqhp_remove_debugfs_files (struct controller *ctrl);
404 408
405/* controller functions */ 409/* controller functions */
406extern void cpqhp_pushbutton_thread (unsigned long event_pointer); 410extern void cpqhp_pushbutton_thread (unsigned long event_pointer);
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 9aed8efe6a11..b3659ffccac9 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -327,7 +327,9 @@ static int ctrl_slot_setup(struct controller *ctrl,
327 void __iomem *smbios_start, 327 void __iomem *smbios_start,
328 void __iomem *smbios_table) 328 void __iomem *smbios_table)
329{ 329{
330 struct slot *new_slot; 330 struct slot *slot;
331 struct hotplug_slot *hotplug_slot;
332 struct hotplug_slot_info *hotplug_slot_info;
331 u8 number_of_slots; 333 u8 number_of_slots;
332 u8 slot_device; 334 u8 slot_device;
333 u8 slot_number; 335 u8 slot_number;
@@ -345,93 +347,105 @@ static int ctrl_slot_setup(struct controller *ctrl,
345 slot_number = ctrl->first_slot; 347 slot_number = ctrl->first_slot;
346 348
347 while (number_of_slots) { 349 while (number_of_slots) {
348 new_slot = kmalloc(sizeof(*new_slot), GFP_KERNEL); 350 slot = kmalloc(sizeof(*slot), GFP_KERNEL);
349 if (!new_slot) 351 if (!slot)
350 goto error; 352 goto error;
351 353
352 memset(new_slot, 0, sizeof(struct slot)); 354 memset(slot, 0, sizeof(struct slot));
353 new_slot->hotplug_slot = kmalloc(sizeof(*(new_slot->hotplug_slot)), 355 slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)),
354 GFP_KERNEL); 356 GFP_KERNEL);
355 if (!new_slot->hotplug_slot) 357 if (!slot->hotplug_slot)
356 goto error_slot; 358 goto error_slot;
357 memset(new_slot->hotplug_slot, 0, sizeof(struct hotplug_slot)); 359 hotplug_slot = slot->hotplug_slot;
360 memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
358 361
359 new_slot->hotplug_slot->info = 362 hotplug_slot->info =
360 kmalloc(sizeof(*(new_slot->hotplug_slot->info)), 363 kmalloc(sizeof(*(hotplug_slot->info)),
361 GFP_KERNEL); 364 GFP_KERNEL);
362 if (!new_slot->hotplug_slot->info) 365 if (!hotplug_slot->info)
363 goto error_hpslot; 366 goto error_hpslot;
364 memset(new_slot->hotplug_slot->info, 0, 367 hotplug_slot_info = hotplug_slot->info;
368 memset(hotplug_slot_info, 0,
365 sizeof(struct hotplug_slot_info)); 369 sizeof(struct hotplug_slot_info));
366 new_slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); 370 hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
367 if (!new_slot->hotplug_slot->name) 371
372 if (!hotplug_slot->name)
368 goto error_info; 373 goto error_info;
369 374
370 new_slot->ctrl = ctrl; 375 slot->ctrl = ctrl;
371 new_slot->bus = ctrl->bus; 376 slot->bus = ctrl->bus;
372 new_slot->device = slot_device; 377 slot->device = slot_device;
373 new_slot->number = slot_number; 378 slot->number = slot_number;
374 dbg("slot->number = %d\n",new_slot->number); 379 dbg("slot->number = %d\n", slot->number);
375 380
376 slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, 381 slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9,
377 slot_entry); 382 slot_entry);
378 383
379 while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) != new_slot->number)) { 384 while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) !=
385 slot->number)) {
380 slot_entry = get_SMBIOS_entry(smbios_start, 386 slot_entry = get_SMBIOS_entry(smbios_start,
381 smbios_table, 9, slot_entry); 387 smbios_table, 9, slot_entry);
382 } 388 }
383 389
384 new_slot->p_sm_slot = slot_entry; 390 slot->p_sm_slot = slot_entry;
385 391
386 init_timer(&new_slot->task_event); 392 init_timer(&slot->task_event);
387 new_slot->task_event.expires = jiffies + 5 * HZ; 393 slot->task_event.expires = jiffies + 5 * HZ;
388 new_slot->task_event.function = cpqhp_pushbutton_thread; 394 slot->task_event.function = cpqhp_pushbutton_thread;
389 395
390 //FIXME: these capabilities aren't used but if they are 396 //FIXME: these capabilities aren't used but if they are
391 // they need to be correctly implemented 397 // they need to be correctly implemented
392 new_slot->capabilities |= PCISLOT_REPLACE_SUPPORTED; 398 slot->capabilities |= PCISLOT_REPLACE_SUPPORTED;
393 new_slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED; 399 slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED;
394 400
395 if (is_slot64bit(new_slot)) 401 if (is_slot64bit(slot))
396 new_slot->capabilities |= PCISLOT_64_BIT_SUPPORTED; 402 slot->capabilities |= PCISLOT_64_BIT_SUPPORTED;
397 if (is_slot66mhz(new_slot)) 403 if (is_slot66mhz(slot))
398 new_slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED; 404 slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED;
399 if (ctrl->speed == PCI_SPEED_66MHz) 405 if (ctrl->speed == PCI_SPEED_66MHz)
400 new_slot->capabilities |= PCISLOT_66_MHZ_OPERATION; 406 slot->capabilities |= PCISLOT_66_MHZ_OPERATION;
401 407
402 ctrl_slot = slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4); 408 ctrl_slot =
409 slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4);
403 410
404 // Check presence 411 // Check presence
405 new_slot->capabilities |= ((((~tempdword) >> 23) | ((~tempdword) >> 15)) >> ctrl_slot) & 0x02; 412 slot->capabilities |=
413 ((((~tempdword) >> 23) |
414 ((~tempdword) >> 15)) >> ctrl_slot) & 0x02;
406 // Check the switch state 415 // Check the switch state
407 new_slot->capabilities |= ((~tempdword & 0xFF) >> ctrl_slot) & 0x01; 416 slot->capabilities |=
417 ((~tempdword & 0xFF) >> ctrl_slot) & 0x01;
408 // Check the slot enable 418 // Check the slot enable
409 new_slot->capabilities |= ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04; 419 slot->capabilities |=
420 ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04;
410 421
411 /* register this slot with the hotplug pci core */ 422 /* register this slot with the hotplug pci core */
412 new_slot->hotplug_slot->release = &release_slot; 423 hotplug_slot->release = &release_slot;
413 new_slot->hotplug_slot->private = new_slot; 424 hotplug_slot->private = slot;
414 make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); 425 make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot);
415 new_slot->hotplug_slot->ops = &cpqphp_hotplug_slot_ops; 426 hotplug_slot->ops = &cpqphp_hotplug_slot_ops;
416 427
417 new_slot->hotplug_slot->info->power_status = get_slot_enabled(ctrl, new_slot); 428 hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot);
418 new_slot->hotplug_slot->info->attention_status = cpq_get_attention_status(ctrl, new_slot); 429 hotplug_slot_info->attention_status =
419 new_slot->hotplug_slot->info->latch_status = cpq_get_latch_status(ctrl, new_slot); 430 cpq_get_attention_status(ctrl, slot);
420 new_slot->hotplug_slot->info->adapter_status = get_presence_status(ctrl, new_slot); 431 hotplug_slot_info->latch_status =
432 cpq_get_latch_status(ctrl, slot);
433 hotplug_slot_info->adapter_status =
434 get_presence_status(ctrl, slot);
421 435
422 dbg ("registering bus %d, dev %d, number %d, " 436 dbg("registering bus %d, dev %d, number %d, "
423 "ctrl->slot_device_offset %d, slot %d\n", 437 "ctrl->slot_device_offset %d, slot %d\n",
424 new_slot->bus, new_slot->device, 438 slot->bus, slot->device,
425 new_slot->number, ctrl->slot_device_offset, 439 slot->number, ctrl->slot_device_offset,
426 slot_number); 440 slot_number);
427 result = pci_hp_register (new_slot->hotplug_slot); 441 result = pci_hp_register(hotplug_slot);
428 if (result) { 442 if (result) {
429 err ("pci_hp_register failed with error %d\n", result); 443 err("pci_hp_register failed with error %d\n", result);
430 goto error_name; 444 goto error_name;
431 } 445 }
432 446
433 new_slot->next = ctrl->slot; 447 slot->next = ctrl->slot;
434 ctrl->slot = new_slot; 448 ctrl->slot = slot;
435 449
436 number_of_slots--; 450 number_of_slots--;
437 slot_device++; 451 slot_device++;
@@ -439,15 +453,14 @@ static int ctrl_slot_setup(struct controller *ctrl,
439 } 453 }
440 454
441 return 0; 455 return 0;
442
443error_name: 456error_name:
444 kfree(new_slot->hotplug_slot->name); 457 kfree(hotplug_slot->name);
445error_info: 458error_info:
446 kfree(new_slot->hotplug_slot->info); 459 kfree(hotplug_slot_info);
447error_hpslot: 460error_hpslot:
448 kfree(new_slot->hotplug_slot); 461 kfree(hotplug_slot);
449error_slot: 462error_slot:
450 kfree(new_slot); 463 kfree(slot);
451error: 464error:
452 return result; 465 return result;
453} 466}
@@ -466,6 +479,8 @@ static int ctrl_slot_cleanup (struct controller * ctrl)
466 old_slot = next_slot; 479 old_slot = next_slot;
467 } 480 }
468 481
482 cpqhp_remove_debugfs_files(ctrl);
483
469 //Free IRQ associated with hot plug device 484 //Free IRQ associated with hot plug device
470 free_irq(ctrl->interrupt, ctrl); 485 free_irq(ctrl->interrupt, ctrl);
471 //Unmap the memory 486 //Unmap the memory
@@ -1262,7 +1277,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1262 // Done with exclusive hardware access 1277 // Done with exclusive hardware access
1263 up(&ctrl->crit_sect); 1278 up(&ctrl->crit_sect);
1264 1279
1265 cpqhp_create_ctrl_files(ctrl); 1280 cpqhp_create_debugfs_files(ctrl);
1266 1281
1267 return 0; 1282 return 0;
1268 1283
@@ -1502,6 +1517,7 @@ static int __init cpqhpc_init(void)
1502 cpqhp_debug = debug; 1517 cpqhp_debug = debug;
1503 1518
1504 info (DRIVER_DESC " version: " DRIVER_VERSION "\n"); 1519 info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
1520 cpqhp_initialize_debugfs();
1505 result = pci_register_driver(&cpqhpc_driver); 1521 result = pci_register_driver(&cpqhpc_driver);
1506 dbg("pci_register_driver = %d\n", result); 1522 dbg("pci_register_driver = %d\n", result);
1507 return result; 1523 return result;
@@ -1515,6 +1531,7 @@ static void __exit cpqhpc_cleanup(void)
1515 1531
1516 dbg("pci_unregister_driver\n"); 1532 dbg("pci_unregister_driver\n");
1517 pci_unregister_driver(&cpqhpc_driver); 1533 pci_unregister_driver(&cpqhpc_driver);
1534 cpqhp_shutdown_debugfs();
1518} 1535}
1519 1536
1520 1537
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index 10a5a7674a8a..771ed34b1819 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -2630,29 +2630,15 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2630 hold_mem_node = NULL; 2630 hold_mem_node = NULL;
2631 } 2631 }
2632 2632
2633 /* If we have prefetchable memory resources copy them and 2633 memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource));
2634 * fill in the bridge's memory range registers. Otherwise, 2634 p_mem_node->next = NULL;
2635 * fill in the range registers with values that disable them. */
2636 if (p_mem_node) {
2637 memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource));
2638 p_mem_node->next = NULL;
2639
2640 /* set Pre Mem base and Limit registers */
2641 temp_word = p_mem_node->base >> 16;
2642 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2643
2644 temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16;
2645 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2646 } else {
2647 temp_word = 0xFFFF;
2648 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2649 2635
2650 temp_word = 0x0000; 2636 /* set Pre Mem base and Limit registers */
2651 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); 2637 temp_word = p_mem_node->base >> 16;
2638 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2652 2639
2653 kfree(hold_p_mem_node); 2640 temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16;
2654 hold_p_mem_node = NULL; 2641 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2655 }
2656 2642
2657 /* Adjust this to compensate for extra adjustment in first loop */ 2643 /* Adjust this to compensate for extra adjustment in first loop */
2658 irqs.barber_pole--; 2644 irqs.barber_pole--;
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index 4c11048ad51b..bbfeed767ff1 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -33,22 +33,15 @@
33#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
34#include <linux/workqueue.h> 34#include <linux/workqueue.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/debugfs.h>
36#include "cpqphp.h" 37#include "cpqphp.h"
37 38
38 39static int show_ctrl (struct controller *ctrl, char *buf)
39/* A few routines that create sysfs entries for the hot plug controller */
40
41static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf)
42{ 40{
43 struct pci_dev *pci_dev; 41 char *out = buf;
44 struct controller *ctrl;
45 char * out = buf;
46 int index; 42 int index;
47 struct pci_resource *res; 43 struct pci_resource *res;
48 44
49 pci_dev = container_of (dev, struct pci_dev, dev);
50 ctrl = pci_get_drvdata(pci_dev);
51
52 out += sprintf(buf, "Free resources: memory\n"); 45 out += sprintf(buf, "Free resources: memory\n");
53 index = 11; 46 index = 11;
54 res = ctrl->mem_head; 47 res = ctrl->mem_head;
@@ -80,22 +73,16 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
80 73
81 return out - buf; 74 return out - buf;
82} 75}
83static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL);
84 76
85static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char *buf) 77static int show_dev (struct controller *ctrl, char *buf)
86{ 78{
87 struct pci_dev *pci_dev;
88 struct controller *ctrl;
89 char * out = buf; 79 char * out = buf;
90 int index; 80 int index;
91 struct pci_resource *res; 81 struct pci_resource *res;
92 struct pci_func *new_slot; 82 struct pci_func *new_slot;
93 struct slot *slot; 83 struct slot *slot;
94 84
95 pci_dev = container_of (dev, struct pci_dev, dev); 85 slot = ctrl->slot;
96 ctrl = pci_get_drvdata(pci_dev);
97
98 slot=ctrl->slot;
99 86
100 while (slot) { 87 while (slot) {
101 new_slot = cpqhp_slot_find(slot->bus, slot->device, 0); 88 new_slot = cpqhp_slot_find(slot->bus, slot->device, 0);
@@ -134,10 +121,117 @@ static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char
134 121
135 return out - buf; 122 return out - buf;
136} 123}
137static DEVICE_ATTR (dev, S_IRUGO, show_dev, NULL);
138 124
139void cpqhp_create_ctrl_files (struct controller *ctrl) 125static int spew_debug_info(struct controller *ctrl, char *data, int size)
140{ 126{
141 device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl); 127 int used;
142 device_create_file (&ctrl->pci_dev->dev, &dev_attr_dev); 128
129 used = size - show_ctrl(ctrl, data);
130 used = (size - used) - show_dev(ctrl, &data[used]);
131 return used;
132}
133
134struct ctrl_dbg {
135 int size;
136 char *data;
137 struct controller *ctrl;
138};
139
140#define MAX_OUTPUT (4*PAGE_SIZE)
141
142static int open(struct inode *inode, struct file *file)
143{
144 struct controller *ctrl = inode->u.generic_ip;
145 struct ctrl_dbg *dbg;
146 int retval = -ENOMEM;
147
148 lock_kernel();
149 dbg = kmalloc(sizeof(*dbg), GFP_KERNEL);
150 if (!dbg)
151 goto exit;
152 dbg->data = kmalloc(MAX_OUTPUT, GFP_KERNEL);
153 if (!dbg->data) {
154 kfree(dbg);
155 goto exit;
156 }
157 dbg->size = spew_debug_info(ctrl, dbg->data, MAX_OUTPUT);
158 file->private_data = dbg;
159 retval = 0;
160exit:
161 unlock_kernel();
162 return retval;
163}
164
165static loff_t lseek(struct file *file, loff_t off, int whence)
166{
167 struct ctrl_dbg *dbg;
168 loff_t new = -1;
169
170 lock_kernel();
171 dbg = file->private_data;
172
173 switch (whence) {
174 case 0:
175 new = off;
176 break;
177 case 1:
178 new = file->f_pos + off;
179 break;
180 }
181 if (new < 0 || new > dbg->size) {
182 unlock_kernel();
183 return -EINVAL;
184 }
185 unlock_kernel();
186 return (file->f_pos = new);
143} 187}
188
189static ssize_t read(struct file *file, char __user *buf,
190 size_t nbytes, loff_t *ppos)
191{
192 struct ctrl_dbg *dbg = file->private_data;
193 return simple_read_from_buffer(buf, nbytes, ppos, dbg->data, dbg->size);
194}
195
196static int release(struct inode *inode, struct file *file)
197{
198 struct ctrl_dbg *dbg = file->private_data;
199
200 kfree(dbg->data);
201 kfree(dbg);
202 return 0;
203}
204
205static struct file_operations debug_ops = {
206 .owner = THIS_MODULE,
207 .open = open,
208 .llseek = lseek,
209 .read = read,
210 .release = release,
211};
212
213static struct dentry *root;
214
215void cpqhp_initialize_debugfs(void)
216{
217 if (!root)
218 root = debugfs_create_dir("cpqhp", NULL);
219}
220
221void cpqhp_shutdown_debugfs(void)
222{
223 debugfs_remove(root);
224}
225
226void cpqhp_create_debugfs_files(struct controller *ctrl)
227{
228 ctrl->dentry = debugfs_create_file(ctrl->pci_dev->dev.bus_id, S_IRUGO, root, ctrl, &debug_ops);
229}
230
231void cpqhp_remove_debugfs_files(struct controller *ctrl)
232{
233 if (ctrl->dentry)
234 debugfs_remove(ctrl->dentry);
235 ctrl->dentry = NULL;
236}
237
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index b1ba429e0a2d..155133fe5c12 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -969,7 +969,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
969 debug ("io 32\n"); 969 debug ("io 32\n");
970 need_io_upper = TRUE; 970 need_io_upper = TRUE;
971 } 971 }
972 if ((io_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { 972 if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) {
973 debug ("pfmem 64\n"); 973 debug ("pfmem 64\n");
974 need_pfmem_upper = TRUE; 974 need_pfmem_upper = TRUE;
975 } 975 }
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 8df704860348..4fb569018a24 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -103,7 +103,10 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
103 103
104static int init_slots(struct controller *ctrl) 104static int init_slots(struct controller *ctrl)
105{ 105{
106 struct slot *new_slot; 106 struct slot *slot;
107 struct hpc_ops *hpc_ops;
108 struct hotplug_slot *hotplug_slot;
109 struct hotplug_slot_info *hotplug_slot_info;
107 u8 number_of_slots; 110 u8 number_of_slots;
108 u8 slot_device; 111 u8 slot_device;
109 u32 slot_number; 112 u32 slot_number;
@@ -114,59 +117,66 @@ static int init_slots(struct controller *ctrl)
114 slot_number = ctrl->first_slot; 117 slot_number = ctrl->first_slot;
115 118
116 while (number_of_slots) { 119 while (number_of_slots) {
117 new_slot = kmalloc(sizeof(*new_slot), GFP_KERNEL); 120 slot = kmalloc(sizeof(*slot), GFP_KERNEL);
118 if (!new_slot) 121 if (!slot)
119 goto error; 122 goto error;
120 123
121 memset(new_slot, 0, sizeof(struct slot)); 124 memset(slot, 0, sizeof(struct slot));
122 new_slot->hotplug_slot = 125 slot->hotplug_slot =
123 kmalloc(sizeof(*(new_slot->hotplug_slot)), 126 kmalloc(sizeof(*(slot->hotplug_slot)),
124 GFP_KERNEL); 127 GFP_KERNEL);
125 if (!new_slot->hotplug_slot) 128 if (!slot->hotplug_slot)
126 goto error_slot; 129 goto error_slot;
127 memset(new_slot->hotplug_slot, 0, sizeof(struct hotplug_slot)); 130 hotplug_slot = slot->hotplug_slot;
131 memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
128 132
129 new_slot->hotplug_slot->info = 133 hotplug_slot->info =
130 kmalloc(sizeof(*(new_slot->hotplug_slot->info)), 134 kmalloc(sizeof(*(hotplug_slot->info)),
131 GFP_KERNEL); 135 GFP_KERNEL);
132 if (!new_slot->hotplug_slot->info) 136 if (!hotplug_slot->info)
133 goto error_hpslot; 137 goto error_hpslot;
134 memset(new_slot->hotplug_slot->info, 0, 138 hotplug_slot_info = hotplug_slot->info;
139 memset(hotplug_slot_info, 0,
135 sizeof(struct hotplug_slot_info)); 140 sizeof(struct hotplug_slot_info));
136 new_slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, 141 hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
137 GFP_KERNEL); 142 if (!hotplug_slot->name)
138 if (!new_slot->hotplug_slot->name)
139 goto error_info; 143 goto error_info;
140 144
141 new_slot->ctrl = ctrl; 145 slot->ctrl = ctrl;
142 new_slot->bus = ctrl->slot_bus; 146 slot->bus = ctrl->slot_bus;
143 new_slot->device = slot_device; 147 slot->device = slot_device;
144 new_slot->hpc_ops = ctrl->hpc_ops; 148 slot->hpc_ops = hpc_ops = ctrl->hpc_ops;
145 149
146 new_slot->number = ctrl->first_slot; 150 slot->number = ctrl->first_slot;
147 new_slot->hp_slot = slot_device - ctrl->slot_device_offset; 151 slot->hp_slot = slot_device - ctrl->slot_device_offset;
148 152
149 /* register this slot with the hotplug pci core */ 153 /* register this slot with the hotplug pci core */
150 new_slot->hotplug_slot->private = new_slot; 154 hotplug_slot->private = slot;
151 new_slot->hotplug_slot->release = &release_slot; 155 hotplug_slot->release = &release_slot;
152 make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); 156 make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot);
153 new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops; 157 hotplug_slot->ops = &pciehp_hotplug_slot_ops;
154 158
155 new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); 159 hpc_ops->get_power_status(slot,
156 new_slot->hpc_ops->get_attention_status(new_slot, &(new_slot->hotplug_slot->info->attention_status)); 160 &(hotplug_slot_info->power_status));
157 new_slot->hpc_ops->get_latch_status(new_slot, &(new_slot->hotplug_slot->info->latch_status)); 161 hpc_ops->get_attention_status(slot,
158 new_slot->hpc_ops->get_adapter_status(new_slot, &(new_slot->hotplug_slot->info->adapter_status)); 162 &(hotplug_slot_info->attention_status));
159 163 hpc_ops->get_latch_status(slot,
160 dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x slot_device_offset=%x\n", 164 &(hotplug_slot_info->latch_status));
161 new_slot->bus, new_slot->device, new_slot->hp_slot, new_slot->number, ctrl->slot_device_offset); 165 hpc_ops->get_adapter_status(slot,
162 result = pci_hp_register (new_slot->hotplug_slot); 166 &(hotplug_slot_info->adapter_status));
167
168 dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
169 "slot_device_offset=%x\n",
170 slot->bus, slot->device, slot->hp_slot, slot->number,
171 ctrl->slot_device_offset);
172 result = pci_hp_register(hotplug_slot);
163 if (result) { 173 if (result) {
164 err ("pci_hp_register failed with error %d\n", result); 174 err ("pci_hp_register failed with error %d\n", result);
165 goto error_name; 175 goto error_name;
166 } 176 }
167 177
168 new_slot->next = ctrl->slot; 178 slot->next = ctrl->slot;
169 ctrl->slot = new_slot; 179 ctrl->slot = slot;
170 180
171 number_of_slots--; 181 number_of_slots--;
172 slot_device++; 182 slot_device++;
@@ -176,13 +186,13 @@ static int init_slots(struct controller *ctrl)
176 return 0; 186 return 0;
177 187
178error_name: 188error_name:
179 kfree(new_slot->hotplug_slot->name); 189 kfree(hotplug_slot->name);
180error_info: 190error_info:
181 kfree(new_slot->hotplug_slot->info); 191 kfree(hotplug_slot_info);
182error_hpslot: 192error_hpslot:
183 kfree(new_slot->hotplug_slot); 193 kfree(hotplug_slot);
184error_slot: 194error_slot:
185 kfree(new_slot); 195 kfree(slot);
186error: 196error:
187 return result; 197 return result;
188} 198}
@@ -502,7 +512,7 @@ static void __exit unload_pciehpd(void)
502 512
503} 513}
504 514
505int hpdriver_context = 0; 515static int hpdriver_context = 0;
506 516
507static void pciehp_remove (struct pcie_device *device) 517static void pciehp_remove (struct pcie_device *device)
508{ 518{
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index ac1e495c314e..77e530321de2 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -787,8 +787,13 @@ static int hpc_power_on_slot(struct slot * slot)
787 787
788 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON; 788 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON;
789 789
790 /* Enable detection that we turned off at slot power-off time */
790 if (!pciehp_poll_mode) 791 if (!pciehp_poll_mode)
791 slot_cmd = slot_cmd | HP_INTR_ENABLE; 792 slot_cmd = slot_cmd |
793 PWR_FAULT_DETECT_ENABLE |
794 MRL_DETECT_ENABLE |
795 PRSN_DETECT_ENABLE |
796 HP_INTR_ENABLE;
792 797
793 retval = pcie_write_cmd(slot, slot_cmd); 798 retval = pcie_write_cmd(slot, slot_cmd);
794 799
@@ -833,8 +838,18 @@ static int hpc_power_off_slot(struct slot * slot)
833 838
834 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF; 839 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF;
835 840
841 /*
842 * If we get MRL or presence detect interrupts now, the isr
843 * will notice the sticky power-fault bit too and issue power
844 * indicator change commands. This will lead to an endless loop
845 * of command completions, since the power-fault bit remains on
846 * till the slot is powered on again.
847 */
836 if (!pciehp_poll_mode) 848 if (!pciehp_poll_mode)
837 slot_cmd = slot_cmd | HP_INTR_ENABLE; 849 slot_cmd = (slot_cmd &
850 ~PWR_FAULT_DETECT_ENABLE &
851 ~MRL_DETECT_ENABLE &
852 ~PRSN_DETECT_ENABLE) | HP_INTR_ENABLE;
838 853
839 retval = pcie_write_cmd(slot, slot_cmd); 854 retval = pcie_write_cmd(slot, slot_cmd);
840 855
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 647673a7d224..4017fb03a0b8 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -34,6 +34,31 @@
34#include "../pci.h" 34#include "../pci.h"
35#include "pciehp.h" 35#include "pciehp.h"
36 36
37static int pciehp_add_bridge(struct pci_dev *dev)
38{
39 struct pci_bus *parent = dev->bus;
40 int pass, busnr, start = parent->secondary;
41 int end = parent->subordinate;
42
43 for (busnr = start; busnr <= end; busnr++) {
44 if (!pci_find_bus(pci_domain_nr(parent), busnr))
45 break;
46 }
47 if (busnr-- > end) {
48 err("No bus number available for hot-added bridge %s\n",
49 pci_name(dev));
50 return -1;
51 }
52 for (pass = 0; pass < 2; pass++)
53 busnr = pci_scan_bridge(parent, dev, busnr, pass);
54 if (!dev->subordinate)
55 return -1;
56 pci_bus_size_bridges(dev->subordinate);
57 pci_bus_assign_resources(parent);
58 pci_enable_bridges(parent);
59 pci_bus_add_devices(parent);
60 return 0;
61}
37 62
38int pciehp_configure_device(struct slot *p_slot) 63int pciehp_configure_device(struct slot *p_slot)
39{ 64{
@@ -55,8 +80,8 @@ int pciehp_configure_device(struct slot *p_slot)
55 } 80 }
56 81
57 for (fn = 0; fn < 8; fn++) { 82 for (fn = 0; fn < 8; fn++) {
58 if (!(dev = pci_find_slot(p_slot->bus, 83 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn));
59 PCI_DEVFN(p_slot->device, fn)))) 84 if (!dev)
60 continue; 85 continue;
61 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { 86 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
62 err("Cannot hot-add display device %s\n", 87 err("Cannot hot-add display device %s\n",
@@ -65,27 +90,7 @@ int pciehp_configure_device(struct slot *p_slot)
65 } 90 }
66 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || 91 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
67 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { 92 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) {
68 /* Find an unused bus number for the new bridge */ 93 pciehp_add_bridge(dev);
69 struct pci_bus *child;
70 unsigned char busnr, start = parent->secondary;
71 unsigned char end = parent->subordinate;
72 for (busnr = start; busnr <= end; busnr++) {
73 if (!pci_find_bus(pci_domain_nr(parent),
74 busnr))
75 break;
76 }
77 if (busnr >= end) {
78 err("No free bus for hot-added bridge\n");
79 continue;
80 }
81 child = pci_add_new_bus(parent, dev, busnr);
82 if (!child) {
83 err("Cannot add new bus for %s\n",
84 pci_name(dev));
85 continue;
86 }
87 child->subordinate = pci_do_scan_bus(child);
88 pci_bus_size_bridges(child);
89 } 94 }
90 /* TBD: program firmware provided _HPP values */ 95 /* TBD: program firmware provided _HPP values */
91 /* program_fw_provided_values(dev); */ 96 /* program_fw_provided_values(dev); */
@@ -93,7 +98,6 @@ int pciehp_configure_device(struct slot *p_slot)
93 98
94 pci_bus_assign_resources(parent); 99 pci_bus_assign_resources(parent);
95 pci_bus_add_devices(parent); 100 pci_bus_add_devices(parent);
96 pci_enable_bridges(parent);
97 return 0; 101 return 0;
98} 102}
99 103
diff --git a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c
index ae244e218620..2bdb30f68bf8 100644
--- a/drivers/pci/hotplug/pciehprm_acpi.c
+++ b/drivers/pci/hotplug/pciehprm_acpi.c
@@ -174,7 +174,9 @@ int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
174 acpi_status status; 174 acpi_status status;
175 acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); 175 acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev));
176 struct pci_dev *pdev = dev; 176 struct pci_dev *pdev = dev;
177 struct pci_bus *parent;
177 u8 *path_name; 178 u8 *path_name;
179
178 /* 180 /*
179 * Per PCI firmware specification, we should run the ACPI _OSC 181 * Per PCI firmware specification, we should run the ACPI _OSC
180 * method to get control of hotplug hardware before using it. 182 * method to get control of hotplug hardware before using it.
@@ -190,17 +192,18 @@ int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
190 */ 192 */
191 if (!pdev || !pdev->bus->parent) 193 if (!pdev || !pdev->bus->parent)
192 break; 194 break;
195 parent = pdev->bus->parent;
193 dbg("Could not find %s in acpi namespace, trying parent\n", 196 dbg("Could not find %s in acpi namespace, trying parent\n",
194 pci_name(pdev)); 197 pci_name(pdev));
195 if (!pdev->bus->parent->self) 198 if (!parent->self)
196 /* Parent must be a host bridge */ 199 /* Parent must be a host bridge */
197 handle = acpi_get_pci_rootbridge_handle( 200 handle = acpi_get_pci_rootbridge_handle(
198 pci_domain_nr(pdev->bus->parent), 201 pci_domain_nr(parent),
199 pdev->bus->parent->number); 202 parent->number);
200 else 203 else
201 handle = DEVICE_ACPI_HANDLE( 204 handle = DEVICE_ACPI_HANDLE(
202 &(pdev->bus->parent->self->dev)); 205 &(parent->self->dev));
203 pdev = pdev->bus->parent->self; 206 pdev = parent->self;
204 } 207 }
205 208
206 while (handle) { 209 while (handle) {
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index cc03609f45d0..7d93dbaf628d 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -112,28 +112,6 @@ static struct slot *find_slot(struct device_node *dn)
112 return NULL; 112 return NULL;
113} 113}
114 114
115static void rpadlpar_claim_one_bus(struct pci_bus *b)
116{
117 struct list_head *ld;
118 struct pci_bus *child_bus;
119
120 for (ld = b->devices.next; ld != &b->devices; ld = ld->next) {
121 struct pci_dev *dev = pci_dev_b(ld);
122 int i;
123
124 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
125 struct resource *r = &dev->resource[i];
126
127 if (r->parent || !r->start || !r->flags)
128 continue;
129 rpaphp_claim_resource(dev, i);
130 }
131 }
132
133 list_for_each_entry(child_bus, &b->children, node)
134 rpadlpar_claim_one_bus(child_bus);
135}
136
137static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, 115static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent,
138 struct device_node *dev_dn) 116 struct device_node *dev_dn)
139{ 117{
@@ -154,7 +132,8 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
154 struct pci_controller *phb = pdn->phb; 132 struct pci_controller *phb = pdn->phb;
155 struct pci_dev *dev = NULL; 133 struct pci_dev *dev = NULL;
156 134
157 rpaphp_eeh_init_nodes(dn); 135 eeh_add_device_tree_early(dn);
136
158 /* Add EADS device to PHB bus, adding new entry to bus->devices */ 137 /* Add EADS device to PHB bus, adding new entry to bus->devices */
159 dev = of_create_pci_dev(dn, phb->bus, pdn->devfn); 138 dev = of_create_pci_dev(dn, phb->bus, pdn->devfn);
160 if (!dev) { 139 if (!dev) {
@@ -170,7 +149,7 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
170 rpaphp_init_new_devs(dev->subordinate); 149 rpaphp_init_new_devs(dev->subordinate);
171 150
172 /* Claim new bus resources */ 151 /* Claim new bus resources */
173 rpadlpar_claim_one_bus(dev->bus); 152 pcibios_claim_one_bus(dev->bus);
174 153
175 /* ioremap() for child bus, which may or may not succeed */ 154 /* ioremap() for child bus, which may or may not succeed */
176 (void) remap_bus_range(dev->bus); 155 (void) remap_bus_range(dev->bus);
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 4b35097b3d9f..396b54b0c847 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -62,28 +62,6 @@ struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn)
62} 62}
63EXPORT_SYMBOL_GPL(rpaphp_find_pci_bus); 63EXPORT_SYMBOL_GPL(rpaphp_find_pci_bus);
64 64
65int rpaphp_claim_resource(struct pci_dev *dev, int resource)
66{
67 struct resource *res = &dev->resource[resource];
68 struct resource *root = pci_find_parent_resource(dev, res);
69 char *dtype = resource < PCI_BRIDGE_RESOURCES ? "device" : "bridge";
70 int err = -EINVAL;
71
72 if (root != NULL) {
73 err = request_resource(root, res);
74 }
75
76 if (err) {
77 err("PCI: %s region %d of %s %s [%lx:%lx]\n",
78 root ? "Address space collision on" :
79 "No parent found for",
80 resource, dtype, pci_name(dev), res->start, res->end);
81 }
82 return err;
83}
84
85EXPORT_SYMBOL_GPL(rpaphp_claim_resource);
86
87static int rpaphp_get_sensor_state(struct slot *slot, int *state) 65static int rpaphp_get_sensor_state(struct slot *slot, int *state)
88{ 66{
89 int rc; 67 int rc;
@@ -177,7 +155,7 @@ void rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
177 155
178 if (r->parent || !r->start || !r->flags) 156 if (r->parent || !r->start || !r->flags)
179 continue; 157 continue;
180 rpaphp_claim_resource(dev, i); 158 pci_claim_resource(dev, i);
181 } 159 }
182 } 160 }
183 } 161 }
@@ -287,18 +265,6 @@ rpaphp_pci_config_slot(struct pci_bus *bus)
287 return dev; 265 return dev;
288} 266}
289 267
290void rpaphp_eeh_init_nodes(struct device_node *dn)
291{
292 struct device_node *sib;
293
294 for (sib = dn->child; sib; sib = sib->sibling)
295 rpaphp_eeh_init_nodes(sib);
296 eeh_add_device_early(dn);
297 return;
298
299}
300EXPORT_SYMBOL_GPL(rpaphp_eeh_init_nodes);
301
302static void print_slot_pci_funcs(struct pci_bus *bus) 268static void print_slot_pci_funcs(struct pci_bus *bus)
303{ 269{
304 struct device_node *dn; 270 struct device_node *dn;
@@ -324,7 +290,7 @@ int rpaphp_config_pci_adapter(struct pci_bus *bus)
324 if (!dn) 290 if (!dn)
325 goto exit; 291 goto exit;
326 292
327 rpaphp_eeh_init_nodes(dn); 293 eeh_add_device_tree_early(dn);
328 dev = rpaphp_pci_config_slot(bus); 294 dev = rpaphp_pci_config_slot(bus);
329 if (!dev) { 295 if (!dev) {
330 err("%s: can't find any devices.\n", __FUNCTION__); 296 err("%s: can't find any devices.\n", __FUNCTION__);
@@ -370,13 +336,14 @@ EXPORT_SYMBOL_GPL(rpaphp_unconfig_pci_adapter);
370 336
371static int setup_pci_hotplug_slot_info(struct slot *slot) 337static int setup_pci_hotplug_slot_info(struct slot *slot)
372{ 338{
339 struct hotplug_slot_info *hotplug_slot_info = slot->hotplug_slot->info;
340
373 dbg("%s Initilize the PCI slot's hotplug->info structure ...\n", 341 dbg("%s Initilize the PCI slot's hotplug->info structure ...\n",
374 __FUNCTION__); 342 __FUNCTION__);
375 rpaphp_get_power_status(slot, &slot->hotplug_slot->info->power_status); 343 rpaphp_get_power_status(slot, &hotplug_slot_info->power_status);
376 rpaphp_get_pci_adapter_status(slot, 1, 344 rpaphp_get_pci_adapter_status(slot, 1,
377 &slot->hotplug_slot->info-> 345 &hotplug_slot_info->adapter_status);
378 adapter_status); 346 if (hotplug_slot_info->adapter_status == NOT_VALID) {
379 if (slot->hotplug_slot->info->adapter_status == NOT_VALID) {
380 err("%s: NOT_VALID: skip dn->full_name=%s\n", 347 err("%s: NOT_VALID: skip dn->full_name=%s\n",
381 __FUNCTION__, slot->dn->full_name); 348 __FUNCTION__, slot->dn->full_name);
382 return -EINVAL; 349 return -EINVAL;
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 08ad26a0cae7..ce0e9b6ce833 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -98,6 +98,10 @@ struct controller {
98 enum pci_bus_speed speed; 98 enum pci_bus_speed speed;
99 u32 first_slot; /* First physical slot number */ 99 u32 first_slot; /* First physical slot number */
100 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 100 u8 slot_bus; /* Bus where the slots handled by this controller sit */
101 u32 cap_offset;
102 unsigned long mmio_base;
103 unsigned long mmio_size;
104 volatile int cmd_busy;
101}; 105};
102 106
103struct hotplug_params { 107struct hotplug_params {
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 63628e01dd43..a2b3f0010cec 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -65,6 +65,7 @@ static int get_power_status (struct hotplug_slot *slot, u8 *value);
65static int get_attention_status (struct hotplug_slot *slot, u8 *value); 65static int get_attention_status (struct hotplug_slot *slot, u8 *value);
66static int get_latch_status (struct hotplug_slot *slot, u8 *value); 66static int get_latch_status (struct hotplug_slot *slot, u8 *value);
67static int get_adapter_status (struct hotplug_slot *slot, u8 *value); 67static int get_adapter_status (struct hotplug_slot *slot, u8 *value);
68static int get_address (struct hotplug_slot *slot, u32 *value);
68static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); 69static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value);
69static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); 70static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value);
70 71
@@ -77,6 +78,7 @@ static struct hotplug_slot_ops shpchp_hotplug_slot_ops = {
77 .get_attention_status = get_attention_status, 78 .get_attention_status = get_attention_status,
78 .get_latch_status = get_latch_status, 79 .get_latch_status = get_latch_status,
79 .get_adapter_status = get_adapter_status, 80 .get_adapter_status = get_adapter_status,
81 .get_address = get_address,
80 .get_max_bus_speed = get_max_bus_speed, 82 .get_max_bus_speed = get_max_bus_speed,
81 .get_cur_bus_speed = get_cur_bus_speed, 83 .get_cur_bus_speed = get_cur_bus_speed,
82}; 84};
@@ -314,6 +316,18 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
314 return 0; 316 return 0;
315} 317}
316 318
319static int get_address (struct hotplug_slot *hotplug_slot, u32 *value)
320{
321 struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
322 struct pci_bus *bus = slot->ctrl->pci_dev->subordinate;
323
324 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
325
326 *value = (pci_domain_nr(bus) << 16) | (slot->bus << 8) | slot->device;
327
328 return 0;
329}
330
317static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) 331static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
318{ 332{
319 struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); 333 struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
@@ -377,8 +391,6 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
377 goto err_out_free_ctrl; 391 goto err_out_free_ctrl;
378 } 392 }
379 393
380 ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */
381
382 pci_set_drvdata(pdev, ctrl); 394 pci_set_drvdata(pdev, ctrl);
383 395
384 ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL); 396 ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL);
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 58619359ad08..25ccb0e47593 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -248,7 +248,6 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot,
248 up(&ctrl->crit_sect); 248 up(&ctrl->crit_sect);
249 return WRONG_BUS_FREQUENCY; 249 return WRONG_BUS_FREQUENCY;
250 } 250 }
251 wait_for_ctrl_irq (ctrl);
252 251
253 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { 252 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
254 err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", 253 err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
@@ -330,9 +329,6 @@ static int board_added(struct slot *p_slot)
330 up(&ctrl->crit_sect); 329 up(&ctrl->crit_sect);
331 return -1; 330 return -1;
332 } 331 }
333
334 /* Wait for the command to complete */
335 wait_for_ctrl_irq (ctrl);
336 332
337 rc = p_slot->hpc_ops->check_cmd_status(ctrl); 333 rc = p_slot->hpc_ops->check_cmd_status(ctrl);
338 if (rc) { 334 if (rc) {
@@ -352,7 +348,6 @@ static int board_added(struct slot *p_slot)
352 up(&ctrl->crit_sect); 348 up(&ctrl->crit_sect);
353 return WRONG_BUS_FREQUENCY; 349 return WRONG_BUS_FREQUENCY;
354 } 350 }
355 wait_for_ctrl_irq (ctrl);
356 351
357 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { 352 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
358 err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", 353 err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
@@ -367,7 +362,6 @@ static int board_added(struct slot *p_slot)
367 up(&ctrl->crit_sect); 362 up(&ctrl->crit_sect);
368 return rc; 363 return rc;
369 } 364 }
370 wait_for_ctrl_irq (ctrl);
371 365
372 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { 366 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
373 err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); 367 err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
@@ -494,7 +488,6 @@ static int board_added(struct slot *p_slot)
494 up(&ctrl->crit_sect); 488 up(&ctrl->crit_sect);
495 return rc; 489 return rc;
496 } 490 }
497 wait_for_ctrl_irq (ctrl);
498 491
499 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { 492 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
500 err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); 493 err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
@@ -532,9 +525,6 @@ static int board_added(struct slot *p_slot)
532 525
533 p_slot->hpc_ops->green_led_on(p_slot); 526 p_slot->hpc_ops->green_led_on(p_slot);
534 527
535 /* Wait for the command to complete */
536 wait_for_ctrl_irq (ctrl);
537
538 /* Done with exclusive hardware access */ 528 /* Done with exclusive hardware access */
539 up(&ctrl->crit_sect); 529 up(&ctrl->crit_sect);
540 530
@@ -552,8 +542,6 @@ err_exit:
552 up(&ctrl->crit_sect); 542 up(&ctrl->crit_sect);
553 return rc; 543 return rc;
554 } 544 }
555 /* Wait for the command to complete */
556 wait_for_ctrl_irq (ctrl);
557 545
558 rc = p_slot->hpc_ops->check_cmd_status(ctrl); 546 rc = p_slot->hpc_ops->check_cmd_status(ctrl);
559 if (rc) { 547 if (rc) {
@@ -603,8 +591,6 @@ static int remove_board(struct slot *p_slot)
603 up(&ctrl->crit_sect); 591 up(&ctrl->crit_sect);
604 return rc; 592 return rc;
605 } 593 }
606 /* Wait for the command to complete */
607 wait_for_ctrl_irq (ctrl);
608 594
609 rc = p_slot->hpc_ops->check_cmd_status(ctrl); 595 rc = p_slot->hpc_ops->check_cmd_status(ctrl);
610 if (rc) { 596 if (rc) {
@@ -621,8 +607,6 @@ static int remove_board(struct slot *p_slot)
621 up(&ctrl->crit_sect); 607 up(&ctrl->crit_sect);
622 return rc; 608 return rc;
623 } 609 }
624 /* Wait for the command to complete */
625 wait_for_ctrl_irq (ctrl);
626 610
627 /* Done with exclusive hardware access */ 611 /* Done with exclusive hardware access */
628 up(&ctrl->crit_sect); 612 up(&ctrl->crit_sect);
@@ -676,9 +660,6 @@ static void shpchp_pushbutton_thread (unsigned long slot)
676 660
677 p_slot->hpc_ops->green_led_off(p_slot); 661 p_slot->hpc_ops->green_led_off(p_slot);
678 662
679 /* Wait for the command to complete */
680 wait_for_ctrl_irq (p_slot->ctrl);
681
682 /* Done with exclusive hardware access */ 663 /* Done with exclusive hardware access */
683 up(&p_slot->ctrl->crit_sect); 664 up(&p_slot->ctrl->crit_sect);
684 } 665 }
@@ -790,14 +771,9 @@ static void interrupt_event_handler(struct controller *ctrl)
790 down(&ctrl->crit_sect); 771 down(&ctrl->crit_sect);
791 772
792 p_slot->hpc_ops->green_led_on(p_slot); 773 p_slot->hpc_ops->green_led_on(p_slot);
793 /* Wait for the command to complete */
794 wait_for_ctrl_irq (ctrl);
795 774
796 p_slot->hpc_ops->set_attention_status(p_slot, 0); 775 p_slot->hpc_ops->set_attention_status(p_slot, 0);
797 776
798 /* Wait for the command to complete */
799 wait_for_ctrl_irq (ctrl);
800
801 /* Done with exclusive hardware access */ 777 /* Done with exclusive hardware access */
802 up(&ctrl->crit_sect); 778 up(&ctrl->crit_sect);
803 break; 779 break;
@@ -806,12 +782,8 @@ static void interrupt_event_handler(struct controller *ctrl)
806 down(&ctrl->crit_sect); 782 down(&ctrl->crit_sect);
807 783
808 p_slot->hpc_ops->green_led_off(p_slot); 784 p_slot->hpc_ops->green_led_off(p_slot);
809 /* Wait for the command to complete */
810 wait_for_ctrl_irq (ctrl);
811 785
812 p_slot->hpc_ops->set_attention_status(p_slot, 0); 786 p_slot->hpc_ops->set_attention_status(p_slot, 0);
813 /* Wait for the command to complete */
814 wait_for_ctrl_irq (ctrl);
815 787
816 /* Done with exclusive hardware access */ 788 /* Done with exclusive hardware access */
817 up(&ctrl->crit_sect); 789 up(&ctrl->crit_sect);
@@ -845,14 +817,9 @@ static void interrupt_event_handler(struct controller *ctrl)
845 817
846 /* blink green LED and turn off amber */ 818 /* blink green LED and turn off amber */
847 p_slot->hpc_ops->green_led_blink(p_slot); 819 p_slot->hpc_ops->green_led_blink(p_slot);
848 /* Wait for the command to complete */
849 wait_for_ctrl_irq (ctrl);
850 820
851 p_slot->hpc_ops->set_attention_status(p_slot, 0); 821 p_slot->hpc_ops->set_attention_status(p_slot, 0);
852 822
853 /* Wait for the command to complete */
854 wait_for_ctrl_irq (ctrl);
855
856 /* Done with exclusive hardware access */ 823 /* Done with exclusive hardware access */
857 up(&ctrl->crit_sect); 824 up(&ctrl->crit_sect);
858 825
@@ -870,12 +837,8 @@ static void interrupt_event_handler(struct controller *ctrl)
870 down(&ctrl->crit_sect); 837 down(&ctrl->crit_sect);
871 838
872 p_slot->hpc_ops->set_attention_status(p_slot, 1); 839 p_slot->hpc_ops->set_attention_status(p_slot, 1);
873 /* Wait for the command to complete */
874 wait_for_ctrl_irq (ctrl);
875 840
876 p_slot->hpc_ops->green_led_off(p_slot); 841 p_slot->hpc_ops->green_led_off(p_slot);
877 /* Wait for the command to complete */
878 wait_for_ctrl_irq (ctrl);
879 842
880 /* Done with exclusive hardware access */ 843 /* Done with exclusive hardware access */
881 up(&ctrl->crit_sect); 844 up(&ctrl->crit_sect);
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 9987a6fd65b8..b4226ff3a854 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -275,6 +275,25 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds)
275 return; 275 return;
276} 276}
277 277
278static inline int shpc_wait_cmd(struct controller *ctrl)
279{
280 int retval = 0;
281 unsigned int timeout_msec = shpchp_poll_mode ? 2000 : 1000;
282 unsigned long timeout = msecs_to_jiffies(timeout_msec);
283 int rc = wait_event_interruptible_timeout(ctrl->queue,
284 !ctrl->cmd_busy, timeout);
285 if (!rc) {
286 retval = -EIO;
287 err("Command not completed in %d msec\n", timeout_msec);
288 } else if (rc < 0) {
289 retval = -EINTR;
290 info("Command was interrupted by a signal\n");
291 }
292 ctrl->cmd_busy = 0;
293
294 return retval;
295}
296
278static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) 297static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
279{ 298{
280 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; 299 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
@@ -314,8 +333,14 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
314 /* To make sure the Controller Busy bit is 0 before we send out the 333 /* To make sure the Controller Busy bit is 0 before we send out the
315 * command. 334 * command.
316 */ 335 */
336 slot->ctrl->cmd_busy = 1;
317 writew(temp_word, php_ctlr->creg + CMD); 337 writew(temp_word, php_ctlr->creg + CMD);
318 338
339 /*
340 * Wait for command completion.
341 */
342 retval = shpc_wait_cmd(slot->ctrl);
343
319 DBG_LEAVE_ROUTINE 344 DBG_LEAVE_ROUTINE
320 return retval; 345 return retval;
321} 346}
@@ -604,7 +629,7 @@ static int hpc_get_mode1_ECC_cap(struct slot *slot, u8 *mode)
604 sec_bus_status = readw(php_ctlr->creg + SEC_BUS_CONFIG); 629 sec_bus_status = readw(php_ctlr->creg + SEC_BUS_CONFIG);
605 630
606 if (pi == 2) { 631 if (pi == 2) {
607 *mode = (sec_bus_status & 0x0100) >> 7; 632 *mode = (sec_bus_status & 0x0100) >> 8;
608 } else { 633 } else {
609 retval = -1; 634 retval = -1;
610 } 635 }
@@ -791,7 +816,7 @@ static void hpc_release_ctlr(struct controller *ctrl)
791 } 816 }
792 if (php_ctlr->pci_dev) { 817 if (php_ctlr->pci_dev) {
793 iounmap(php_ctlr->creg); 818 iounmap(php_ctlr->creg);
794 release_mem_region(pci_resource_start(php_ctlr->pci_dev, 0), pci_resource_len(php_ctlr->pci_dev, 0)); 819 release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
795 php_ctlr->pci_dev = NULL; 820 php_ctlr->pci_dev = NULL;
796 } 821 }
797 822
@@ -1058,12 +1083,13 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1058 if (intr_loc & 0x0001) { 1083 if (intr_loc & 0x0001) {
1059 /* 1084 /*
1060 * Command Complete Interrupt Pending 1085 * Command Complete Interrupt Pending
1061 * RO only - clear by writing 0 to the Command Completion 1086 * RO only - clear by writing 1 to the Command Completion
1062 * Detect bit in Controller SERR-INT register 1087 * Detect bit in Controller SERR-INT register
1063 */ 1088 */
1064 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); 1089 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE);
1065 temp_dword &= 0xfffeffff; 1090 temp_dword &= 0xfffdffff;
1066 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE); 1091 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE);
1092 ctrl->cmd_busy = 0;
1067 wake_up_interruptible(&ctrl->queue); 1093 wake_up_interruptible(&ctrl->queue);
1068 } 1094 }
1069 1095
@@ -1121,7 +1147,6 @@ static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value)
1121 int retval = 0; 1147 int retval = 0;
1122 u8 pi; 1148 u8 pi;
1123 u32 slot_avail1, slot_avail2; 1149 u32 slot_avail1, slot_avail2;
1124 int slot_num;
1125 1150
1126 DBG_ENTER_ROUTINE 1151 DBG_ENTER_ROUTINE
1127 1152
@@ -1140,39 +1165,39 @@ static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value)
1140 slot_avail2 = readl(php_ctlr->creg + SLOT_AVAIL2); 1165 slot_avail2 = readl(php_ctlr->creg + SLOT_AVAIL2);
1141 1166
1142 if (pi == 2) { 1167 if (pi == 2) {
1143 if ((slot_num = ((slot_avail2 & SLOT_133MHZ_PCIX_533) >> 27) ) != 0 ) 1168 if (slot_avail2 & SLOT_133MHZ_PCIX_533)
1144 bus_speed = PCIX_133MHZ_533; 1169 bus_speed = PCIX_133MHZ_533;
1145 else if ((slot_num = ((slot_avail2 & SLOT_100MHZ_PCIX_533) >> 23) ) != 0 ) 1170 else if (slot_avail2 & SLOT_100MHZ_PCIX_533)
1146 bus_speed = PCIX_100MHZ_533; 1171 bus_speed = PCIX_100MHZ_533;
1147 else if ((slot_num = ((slot_avail2 & SLOT_66MHZ_PCIX_533) >> 19) ) != 0 ) 1172 else if (slot_avail2 & SLOT_66MHZ_PCIX_533)
1148 bus_speed = PCIX_66MHZ_533; 1173 bus_speed = PCIX_66MHZ_533;
1149 else if ((slot_num = ((slot_avail2 & SLOT_133MHZ_PCIX_266) >> 15) ) != 0 ) 1174 else if (slot_avail2 & SLOT_133MHZ_PCIX_266)
1150 bus_speed = PCIX_133MHZ_266; 1175 bus_speed = PCIX_133MHZ_266;
1151 else if ((slot_num = ((slot_avail2 & SLOT_100MHZ_PCIX_266) >> 11) ) != 0 ) 1176 else if (slot_avail2 & SLOT_100MHZ_PCIX_266)
1152 bus_speed = PCIX_100MHZ_266; 1177 bus_speed = PCIX_100MHZ_266;
1153 else if ((slot_num = ((slot_avail2 & SLOT_66MHZ_PCIX_266) >> 7) ) != 0 ) 1178 else if (slot_avail2 & SLOT_66MHZ_PCIX_266)
1154 bus_speed = PCIX_66MHZ_266; 1179 bus_speed = PCIX_66MHZ_266;
1155 else if ((slot_num = ((slot_avail1 & SLOT_133MHZ_PCIX) >> 23) ) != 0 ) 1180 else if (slot_avail1 & SLOT_133MHZ_PCIX)
1156 bus_speed = PCIX_133MHZ; 1181 bus_speed = PCIX_133MHZ;
1157 else if ((slot_num = ((slot_avail1 & SLOT_100MHZ_PCIX) >> 15) ) != 0 ) 1182 else if (slot_avail1 & SLOT_100MHZ_PCIX)
1158 bus_speed = PCIX_100MHZ; 1183 bus_speed = PCIX_100MHZ;
1159 else if ((slot_num = ((slot_avail1 & SLOT_66MHZ_PCIX) >> 7) ) != 0 ) 1184 else if (slot_avail1 & SLOT_66MHZ_PCIX)
1160 bus_speed = PCIX_66MHZ; 1185 bus_speed = PCIX_66MHZ;
1161 else if ((slot_num = (slot_avail2 & SLOT_66MHZ)) != 0 ) 1186 else if (slot_avail2 & SLOT_66MHZ)
1162 bus_speed = PCI_66MHZ; 1187 bus_speed = PCI_66MHZ;
1163 else if ((slot_num = (slot_avail1 & SLOT_33MHZ)) != 0 ) 1188 else if (slot_avail1 & SLOT_33MHZ)
1164 bus_speed = PCI_33MHZ; 1189 bus_speed = PCI_33MHZ;
1165 else bus_speed = PCI_SPEED_UNKNOWN; 1190 else bus_speed = PCI_SPEED_UNKNOWN;
1166 } else { 1191 } else {
1167 if ((slot_num = ((slot_avail1 & SLOT_133MHZ_PCIX) >> 23) ) != 0 ) 1192 if (slot_avail1 & SLOT_133MHZ_PCIX)
1168 bus_speed = PCIX_133MHZ; 1193 bus_speed = PCIX_133MHZ;
1169 else if ((slot_num = ((slot_avail1 & SLOT_100MHZ_PCIX) >> 15) ) != 0 ) 1194 else if (slot_avail1 & SLOT_100MHZ_PCIX)
1170 bus_speed = PCIX_100MHZ; 1195 bus_speed = PCIX_100MHZ;
1171 else if ((slot_num = ((slot_avail1 & SLOT_66MHZ_PCIX) >> 7) ) != 0 ) 1196 else if (slot_avail1 & SLOT_66MHZ_PCIX)
1172 bus_speed = PCIX_66MHZ; 1197 bus_speed = PCIX_66MHZ;
1173 else if ((slot_num = (slot_avail2 & SLOT_66MHZ)) != 0 ) 1198 else if (slot_avail2 & SLOT_66MHZ)
1174 bus_speed = PCI_66MHZ; 1199 bus_speed = PCI_66MHZ;
1175 else if ((slot_num = (slot_avail1 & SLOT_33MHZ)) != 0 ) 1200 else if (slot_avail1 & SLOT_33MHZ)
1176 bus_speed = PCI_33MHZ; 1201 bus_speed = PCI_33MHZ;
1177 else bus_speed = PCI_SPEED_UNKNOWN; 1202 else bus_speed = PCI_SPEED_UNKNOWN;
1178 } 1203 }
@@ -1321,19 +1346,34 @@ static struct hpc_ops shpchp_hpc_ops = {
1321 .check_cmd_status = hpc_check_cmd_status, 1346 .check_cmd_status = hpc_check_cmd_status,
1322}; 1347};
1323 1348
1349inline static int shpc_indirect_creg_read(struct controller *ctrl, int index,
1350 u32 *value)
1351{
1352 int rc;
1353 u32 cap_offset = ctrl->cap_offset;
1354 struct pci_dev *pdev = ctrl->pci_dev;
1355
1356 rc = pci_write_config_byte(pdev, cap_offset + DWORD_SELECT, index);
1357 if (rc)
1358 return rc;
1359 return pci_read_config_dword(pdev, cap_offset + DWORD_DATA, value);
1360}
1361
1324int shpc_init(struct controller * ctrl, struct pci_dev * pdev) 1362int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1325{ 1363{
1326 struct php_ctlr_state_s *php_ctlr, *p; 1364 struct php_ctlr_state_s *php_ctlr, *p;
1327 void *instance_id = ctrl; 1365 void *instance_id = ctrl;
1328 int rc; 1366 int rc, num_slots = 0;
1329 u8 hp_slot; 1367 u8 hp_slot;
1330 static int first = 1; 1368 static int first = 1;
1331 u32 shpc_cap_offset, shpc_base_offset; 1369 u32 shpc_base_offset;
1332 u32 tempdword, slot_reg; 1370 u32 tempdword, slot_reg;
1333 u8 i; 1371 u8 i;
1334 1372
1335 DBG_ENTER_ROUTINE 1373 DBG_ENTER_ROUTINE
1336 1374
1375 ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */
1376
1337 spin_lock_init(&list_lock); 1377 spin_lock_init(&list_lock);
1338 php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); 1378 php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL);
1339 1379
@@ -1348,41 +1388,45 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1348 1388
1349 if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == 1389 if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device ==
1350 PCI_DEVICE_ID_AMD_GOLAM_7450)) { 1390 PCI_DEVICE_ID_AMD_GOLAM_7450)) {
1351 shpc_base_offset = 0; /* amd shpc driver doesn't use this; assume 0 */ 1391 /* amd shpc driver doesn't use Base Offset; assume 0 */
1392 ctrl->mmio_base = pci_resource_start(pdev, 0);
1393 ctrl->mmio_size = pci_resource_len(pdev, 0);
1352 } else { 1394 } else {
1353 if ((shpc_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC)) == 0) { 1395 ctrl->cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC);
1354 err("%s : shpc_cap_offset == 0\n", __FUNCTION__); 1396 if (!ctrl->cap_offset) {
1397 err("%s : cap_offset == 0\n", __FUNCTION__);
1355 goto abort_free_ctlr; 1398 goto abort_free_ctlr;
1356 } 1399 }
1357 dbg("%s: shpc_cap_offset = %x\n", __FUNCTION__, shpc_cap_offset); 1400 dbg("%s: cap_offset = %x\n", __FUNCTION__, ctrl->cap_offset);
1358 1401
1359 rc = pci_write_config_byte(pdev, (u8)shpc_cap_offset + DWORD_SELECT , BASE_OFFSET); 1402 rc = shpc_indirect_creg_read(ctrl, 0, &shpc_base_offset);
1360 if (rc) { 1403 if (rc) {
1361 err("%s : pci_word_config_byte failed\n", __FUNCTION__); 1404 err("%s: cannot read base_offset\n", __FUNCTION__);
1362 goto abort_free_ctlr; 1405 goto abort_free_ctlr;
1363 } 1406 }
1364 1407
1365 rc = pci_read_config_dword(pdev, (u8)shpc_cap_offset + DWORD_DATA, &shpc_base_offset); 1408 rc = shpc_indirect_creg_read(ctrl, 3, &tempdword);
1366 if (rc) { 1409 if (rc) {
1367 err("%s : pci_read_config_dword failed\n", __FUNCTION__); 1410 err("%s: cannot read slot config\n", __FUNCTION__);
1368 goto abort_free_ctlr; 1411 goto abort_free_ctlr;
1369 } 1412 }
1413 num_slots = tempdword & SLOT_NUM;
1414 dbg("%s: num_slots (indirect) %x\n", __FUNCTION__, num_slots);
1370 1415
1371 for (i = 0; i <= 14; i++) { 1416 for (i = 0; i < 9 + num_slots; i++) {
1372 rc = pci_write_config_byte(pdev, (u8)shpc_cap_offset + DWORD_SELECT , i); 1417 rc = shpc_indirect_creg_read(ctrl, i, &tempdword);
1373 if (rc) {
1374 err("%s : pci_word_config_byte failed\n", __FUNCTION__);
1375 goto abort_free_ctlr;
1376 }
1377
1378 rc = pci_read_config_dword(pdev, (u8)shpc_cap_offset + DWORD_DATA, &tempdword);
1379 if (rc) { 1418 if (rc) {
1380 err("%s : pci_read_config_dword failed\n", __FUNCTION__); 1419 err("%s: cannot read creg (index = %d)\n",
1420 __FUNCTION__, i);
1381 goto abort_free_ctlr; 1421 goto abort_free_ctlr;
1382 } 1422 }
1383 dbg("%s: offset %d: value %x\n", __FUNCTION__,i, 1423 dbg("%s: offset %d: value %x\n", __FUNCTION__,i,
1384 tempdword); 1424 tempdword);
1385 } 1425 }
1426
1427 ctrl->mmio_base =
1428 pci_resource_start(pdev, 0) + shpc_base_offset;
1429 ctrl->mmio_size = 0x24 + 0x4 * num_slots;
1386 } 1430 }
1387 1431
1388 if (first) { 1432 if (first) {
@@ -1396,16 +1440,16 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1396 if (pci_enable_device(pdev)) 1440 if (pci_enable_device(pdev))
1397 goto abort_free_ctlr; 1441 goto abort_free_ctlr;
1398 1442
1399 if (!request_mem_region(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0), MY_NAME)) { 1443 if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) {
1400 err("%s: cannot reserve MMIO region\n", __FUNCTION__); 1444 err("%s: cannot reserve MMIO region\n", __FUNCTION__);
1401 goto abort_free_ctlr; 1445 goto abort_free_ctlr;
1402 } 1446 }
1403 1447
1404 php_ctlr->creg = ioremap(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0)); 1448 php_ctlr->creg = ioremap(ctrl->mmio_base, ctrl->mmio_size);
1405 if (!php_ctlr->creg) { 1449 if (!php_ctlr->creg) {
1406 err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__, pci_resource_len(pdev, 0), 1450 err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__,
1407 pci_resource_start(pdev, 0) + shpc_base_offset); 1451 ctrl->mmio_size, ctrl->mmio_base);
1408 release_mem_region(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0)); 1452 release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
1409 goto abort_free_ctlr; 1453 goto abort_free_ctlr;
1410 } 1454 }
1411 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); 1455 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg);
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index 38009bc0fd5d..19e1a5e1e30b 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -89,10 +89,11 @@ int shpchp_configure_device(struct slot *p_slot)
89 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; 89 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
90 int num, fn; 90 int num, fn;
91 91
92 dev = pci_find_slot(p_slot->bus, PCI_DEVFN(p_slot->device, 0)); 92 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
93 if (dev) { 93 if (dev) {
94 err("Device %s already exists at %x:%x, cannot hot-add\n", 94 err("Device %s already exists at %x:%x, cannot hot-add\n",
95 pci_name(dev), p_slot->bus, p_slot->device); 95 pci_name(dev), p_slot->bus, p_slot->device);
96 pci_dev_put(dev);
96 return -EINVAL; 97 return -EINVAL;
97 } 98 }
98 99
@@ -103,12 +104,13 @@ int shpchp_configure_device(struct slot *p_slot)
103 } 104 }
104 105
105 for (fn = 0; fn < 8; fn++) { 106 for (fn = 0; fn < 8; fn++) {
106 if (!(dev = pci_find_slot(p_slot->bus, 107 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn));
107 PCI_DEVFN(p_slot->device, fn)))) 108 if (!dev)
108 continue; 109 continue;
109 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { 110 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
110 err("Cannot hot-add display device %s\n", 111 err("Cannot hot-add display device %s\n",
111 pci_name(dev)); 112 pci_name(dev));
113 pci_dev_put(dev);
112 continue; 114 continue;
113 } 115 }
114 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || 116 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
@@ -124,18 +126,21 @@ int shpchp_configure_device(struct slot *p_slot)
124 } 126 }
125 if (busnr >= end) { 127 if (busnr >= end) {
126 err("No free bus for hot-added bridge\n"); 128 err("No free bus for hot-added bridge\n");
129 pci_dev_put(dev);
127 continue; 130 continue;
128 } 131 }
129 child = pci_add_new_bus(parent, dev, busnr); 132 child = pci_add_new_bus(parent, dev, busnr);
130 if (!child) { 133 if (!child) {
131 err("Cannot add new bus for %s\n", 134 err("Cannot add new bus for %s\n",
132 pci_name(dev)); 135 pci_name(dev));
136 pci_dev_put(dev);
133 continue; 137 continue;
134 } 138 }
135 child->subordinate = pci_do_scan_bus(child); 139 child->subordinate = pci_do_scan_bus(child);
136 pci_bus_size_bridges(child); 140 pci_bus_size_bridges(child);
137 } 141 }
138 program_fw_provided_values(dev); 142 program_fw_provided_values(dev);
143 pci_dev_put(dev);
139 } 144 }
140 145
141 pci_bus_assign_resources(parent); 146 pci_bus_assign_resources(parent);
@@ -149,17 +154,19 @@ int shpchp_unconfigure_device(struct slot *p_slot)
149 int rc = 0; 154 int rc = 0;
150 int j; 155 int j;
151 u8 bctl = 0; 156 u8 bctl = 0;
152 157 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
158
153 dbg("%s: bus/dev = %x/%x\n", __FUNCTION__, p_slot->bus, p_slot->device); 159 dbg("%s: bus/dev = %x/%x\n", __FUNCTION__, p_slot->bus, p_slot->device);
154 160
155 for (j=0; j<8 ; j++) { 161 for (j=0; j<8 ; j++) {
156 struct pci_dev* temp = pci_find_slot(p_slot->bus, 162 struct pci_dev* temp = pci_get_slot(parent,
157 (p_slot->device << 3) | j); 163 (p_slot->device << 3) | j);
158 if (!temp) 164 if (!temp)
159 continue; 165 continue;
160 if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { 166 if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
161 err("Cannot remove display device %s\n", 167 err("Cannot remove display device %s\n",
162 pci_name(temp)); 168 pci_name(temp));
169 pci_dev_put(temp);
163 continue; 170 continue;
164 } 171 }
165 if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 172 if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
@@ -167,10 +174,12 @@ int shpchp_unconfigure_device(struct slot *p_slot)
167 if (bctl & PCI_BRIDGE_CTL_VGA) { 174 if (bctl & PCI_BRIDGE_CTL_VGA) {
168 err("Cannot remove display device %s\n", 175 err("Cannot remove display device %s\n",
169 pci_name(temp)); 176 pci_name(temp));
177 pci_dev_put(temp);
170 continue; 178 continue;
171 } 179 }
172 } 180 }
173 pci_remove_bus_device(temp); 181 pci_remove_bus_device(temp);
182 pci_dev_put(temp);
174 } 183 }
175 return rc; 184 return rc;
176} 185}
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 8e287a828d5d..d2a633efa10a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -19,6 +19,7 @@
19#include <asm/dma.h> /* isa_dma_bridge_buggy */ 19#include <asm/dma.h> /* isa_dma_bridge_buggy */
20#include "pci.h" 20#include "pci.h"
21 21
22#if 0
22 23
23/** 24/**
24 * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children 25 * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children
@@ -63,6 +64,8 @@ pci_max_busnr(void)
63 return max; 64 return max;
64} 65}
65 66
67#endif /* 0 */
68
66static int __pci_find_next_cap(struct pci_bus *bus, unsigned int devfn, u8 pos, int cap) 69static int __pci_find_next_cap(struct pci_bus *bus, unsigned int devfn, u8 pos, int cap)
67{ 70{
68 u8 id; 71 u8 id;
@@ -587,7 +590,7 @@ pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
587{ 590{
588 u8 pin; 591 u8 pin;
589 592
590 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 593 pin = dev->pin;
591 if (!pin) 594 if (!pin)
592 return -1; 595 return -1;
593 pin--; 596 pin--;
@@ -917,8 +920,6 @@ EXPORT_SYMBOL_GPL(pci_restore_bars);
917EXPORT_SYMBOL(pci_enable_device_bars); 920EXPORT_SYMBOL(pci_enable_device_bars);
918EXPORT_SYMBOL(pci_enable_device); 921EXPORT_SYMBOL(pci_enable_device);
919EXPORT_SYMBOL(pci_disable_device); 922EXPORT_SYMBOL(pci_disable_device);
920EXPORT_SYMBOL(pci_max_busnr);
921EXPORT_SYMBOL(pci_bus_max_busnr);
922EXPORT_SYMBOL(pci_find_capability); 923EXPORT_SYMBOL(pci_find_capability);
923EXPORT_SYMBOL(pci_bus_find_capability); 924EXPORT_SYMBOL(pci_bus_find_capability);
924EXPORT_SYMBOL(pci_release_regions); 925EXPORT_SYMBOL(pci_release_regions);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 294849d24590..a6dfee2f6d2b 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -26,20 +26,15 @@ extern int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val);
26#ifdef CONFIG_PROC_FS 26#ifdef CONFIG_PROC_FS
27extern int pci_proc_attach_device(struct pci_dev *dev); 27extern int pci_proc_attach_device(struct pci_dev *dev);
28extern int pci_proc_detach_device(struct pci_dev *dev); 28extern int pci_proc_detach_device(struct pci_dev *dev);
29extern int pci_proc_attach_bus(struct pci_bus *bus);
30extern int pci_proc_detach_bus(struct pci_bus *bus); 29extern int pci_proc_detach_bus(struct pci_bus *bus);
31#else 30#else
32static inline int pci_proc_attach_device(struct pci_dev *dev) { return 0; } 31static inline int pci_proc_attach_device(struct pci_dev *dev) { return 0; }
33static inline int pci_proc_detach_device(struct pci_dev *dev) { return 0; } 32static inline int pci_proc_detach_device(struct pci_dev *dev) { return 0; }
34static inline int pci_proc_attach_bus(struct pci_bus *bus) { return 0; }
35static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; } 33static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }
36#endif 34#endif
37 35
38/* Functions for PCI Hotplug drivers to use */ 36/* Functions for PCI Hotplug drivers to use */
39extern unsigned int pci_do_scan_bus(struct pci_bus *bus); 37extern unsigned int pci_do_scan_bus(struct pci_bus *bus);
40extern int pci_remove_device_safe(struct pci_dev *dev);
41extern unsigned char pci_max_busnr(void);
42extern unsigned char pci_bus_max_busnr(struct pci_bus *bus);
43extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); 38extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);
44 39
45extern void pci_remove_legacy_files(struct pci_bus *bus); 40extern void pci_remove_legacy_files(struct pci_bus *bus);
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 467a4ceccf10..e4e5f1e8d816 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -238,8 +238,8 @@ static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev,
238 device->driver = NULL; 238 device->driver = NULL;
239 device->driver_data = NULL; 239 device->driver_data = NULL;
240 device->release = release_pcie_device; /* callback to free pcie dev */ 240 device->release = release_pcie_device; /* callback to free pcie dev */
241 sprintf(&device->bus_id[0], "pcie%02x", 241 snprintf(device->bus_id, sizeof(device->bus_id), "%s:pcie%02x",
242 get_descriptor_id(port_type, service_type)); 242 pci_name(parent), get_descriptor_id(port_type, service_type));
243 device->parent = &parent->dev; 243 device->parent = &parent->dev;
244} 244}
245 245
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index fce2cb2112d8..adfad4fd6a13 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -264,8 +264,10 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
264 264
265 if (base <= limit) { 265 if (base <= limit) {
266 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; 266 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO;
267 res->start = base; 267 if (!res->start)
268 res->end = limit + 0xfff; 268 res->start = base;
269 if (!res->end)
270 res->end = limit + 0xfff;
269 } 271 }
270 272
271 res = child->resource[1]; 273 res = child->resource[1];
@@ -431,7 +433,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
431{ 433{
432 struct pci_bus *child; 434 struct pci_bus *child;
433 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); 435 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
434 u32 buses, i; 436 u32 buses, i, j = 0;
435 u16 bctl; 437 u16 bctl;
436 438
437 pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); 439 pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
@@ -541,10 +543,29 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
541 * as cards with a PCI-to-PCI bridge can be 543 * as cards with a PCI-to-PCI bridge can be
542 * inserted later. 544 * inserted later.
543 */ 545 */
544 for (i=0; i<CARDBUS_RESERVE_BUSNR; i++) 546 for (i=0; i<CARDBUS_RESERVE_BUSNR; i++) {
547 struct pci_bus *parent = bus;
545 if (pci_find_bus(pci_domain_nr(bus), 548 if (pci_find_bus(pci_domain_nr(bus),
546 max+i+1)) 549 max+i+1))
547 break; 550 break;
551 while (parent->parent) {
552 if ((!pcibios_assign_all_busses()) &&
553 (parent->subordinate > max) &&
554 (parent->subordinate <= max+i)) {
555 j = 1;
556 }
557 parent = parent->parent;
558 }
559 if (j) {
560 /*
561 * Often, there are two cardbus bridges
562 * -- try to leave one valid bus number
563 * for each one.
564 */
565 i /= 2;
566 break;
567 }
568 }
548 max += i; 569 max += i;
549 pci_fixup_parent_subordinate_busnr(child, max); 570 pci_fixup_parent_subordinate_busnr(child, max);
550 } 571 }
@@ -559,6 +580,22 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
559 580
560 sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); 581 sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number);
561 582
583 while (bus->parent) {
584 if ((child->subordinate > bus->subordinate) ||
585 (child->number > bus->subordinate) ||
586 (child->number < bus->number) ||
587 (child->subordinate < bus->number)) {
588 printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) may be "
589 "hidden behind%s bridge #%02x (-#%02x)%s\n",
590 child->number, child->subordinate,
591 bus->self->transparent ? " transparent" : " ",
592 bus->number, bus->subordinate,
593 pcibios_assign_all_busses() ? " " :
594 " (try 'pci=assign-busses')");
595 }
596 bus = bus->parent;
597 }
598
562 return max; 599 return max;
563} 600}
564 601
@@ -571,6 +608,7 @@ static void pci_read_irq(struct pci_dev *dev)
571 unsigned char irq; 608 unsigned char irq;
572 609
573 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq); 610 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq);
611 dev->pin = irq;
574 if (irq) 612 if (irq)
575 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); 613 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
576 dev->irq = irq; 614 dev->irq = irq;
@@ -624,6 +662,7 @@ static int pci_setup_device(struct pci_dev * dev)
624 /* The PCI-to-PCI bridge spec requires that subtractive 662 /* The PCI-to-PCI bridge spec requires that subtractive
625 decoding (i.e. transparent) bridge must have programming 663 decoding (i.e. transparent) bridge must have programming
626 interface code of 0x01. */ 664 interface code of 0x01. */
665 pci_read_irq(dev);
627 dev->transparent = ((dev->class & 0xff) == 1); 666 dev->transparent = ((dev->class & 0xff) == 1);
628 pci_read_bases(dev, 2, PCI_ROM_ADDRESS1); 667 pci_read_bases(dev, 2, PCI_ROM_ADDRESS1);
629 break; 668 break;
@@ -678,7 +717,7 @@ static void pci_release_dev(struct device *dev)
678 * reading the dword at 0x100 which must either be 0 or a valid extended 717 * reading the dword at 0x100 which must either be 0 or a valid extended
679 * capability header. 718 * capability header.
680 */ 719 */
681static int pci_cfg_space_size(struct pci_dev *dev) 720int pci_cfg_space_size(struct pci_dev *dev)
682{ 721{
683 int pos; 722 int pos;
684 u32 status; 723 u32 status;
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 9cb6dd0834be..92a885760832 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -431,6 +431,7 @@ int pci_proc_detach_device(struct pci_dev *dev)
431 return 0; 431 return 0;
432} 432}
433 433
434#if 0
434int pci_proc_attach_bus(struct pci_bus* bus) 435int pci_proc_attach_bus(struct pci_bus* bus)
435{ 436{
436 struct proc_dir_entry *de = bus->procdir; 437 struct proc_dir_entry *de = bus->procdir;
@@ -447,6 +448,7 @@ int pci_proc_attach_bus(struct pci_bus* bus)
447 } 448 }
448 return 0; 449 return 0;
449} 450}
451#endif /* 0 */
450 452
451int pci_proc_detach_bus(struct pci_bus* bus) 453int pci_proc_detach_bus(struct pci_bus* bus)
452{ 454{
@@ -612,7 +614,6 @@ __initcall(pci_proc_init);
612 614
613#ifdef CONFIG_HOTPLUG 615#ifdef CONFIG_HOTPLUG
614EXPORT_SYMBOL(pci_proc_attach_device); 616EXPORT_SYMBOL(pci_proc_attach_device);
615EXPORT_SYMBOL(pci_proc_attach_bus);
616EXPORT_SYMBOL(pci_proc_detach_bus); 617EXPORT_SYMBOL(pci_proc_detach_bus);
617#endif 618#endif
618 619
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index f28ebdd3958a..605f0df0bfba 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1342,6 +1342,32 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev)
1342 pci_do_fixups(dev, start, end); 1342 pci_do_fixups(dev, start, end);
1343} 1343}
1344 1344
1345/* Enable 1k I/O space granularity on the Intel P64H2 */
1346static void __devinit quirk_p64h2_1k_io(struct pci_dev *dev)
1347{
1348 u16 en1k;
1349 u8 io_base_lo, io_limit_lo;
1350 unsigned long base, limit;
1351 struct resource *res = dev->resource + PCI_BRIDGE_RESOURCES;
1352
1353 pci_read_config_word(dev, 0x40, &en1k);
1354
1355 if (en1k & 0x200) {
1356 printk(KERN_INFO "PCI: Enable I/O Space to 1 KB Granularity\n");
1357
1358 pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo);
1359 pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo);
1360 base = (io_base_lo & (PCI_IO_RANGE_MASK | 0x0c)) << 8;
1361 limit = (io_limit_lo & (PCI_IO_RANGE_MASK | 0x0c)) << 8;
1362
1363 if (base <= limit) {
1364 res->start = base;
1365 res->end = limit + 0x3ff;
1366 }
1367 }
1368}
1369DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1460, quirk_p64h2_1k_io);
1370
1345EXPORT_SYMBOL(pcie_mch_quirk); 1371EXPORT_SYMBOL(pcie_mch_quirk);
1346#ifdef CONFIG_HOTPLUG 1372#ifdef CONFIG_HOTPLUG
1347EXPORT_SYMBOL(pci_fixup_device); 1373EXPORT_SYMBOL(pci_fixup_device);
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 27a294b6965d..1a6bf9de166f 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -48,6 +48,7 @@ static void pci_destroy_dev(struct pci_dev *dev)
48 * in question is not being used by a driver. 48 * in question is not being used by a driver.
49 * Returns 0 on success. 49 * Returns 0 on success.
50 */ 50 */
51#if 0
51int pci_remove_device_safe(struct pci_dev *dev) 52int pci_remove_device_safe(struct pci_dev *dev)
52{ 53{
53 if (pci_dev_driver(dev)) 54 if (pci_dev_driver(dev))
@@ -55,7 +56,7 @@ int pci_remove_device_safe(struct pci_dev *dev)
55 pci_destroy_dev(dev); 56 pci_destroy_dev(dev);
56 return 0; 57 return 0;
57} 58}
58EXPORT_SYMBOL(pci_remove_device_safe); 59#endif /* 0 */
59 60
60void pci_remove_bus(struct pci_bus *pci_bus) 61void pci_remove_bus(struct pci_bus *pci_bus)
61{ 62{
diff --git a/drivers/pcmcia/vrc4173_cardu.c b/drivers/pcmcia/vrc4173_cardu.c
index 1b277d2c1c96..b502db2790e0 100644
--- a/drivers/pcmcia/vrc4173_cardu.c
+++ b/drivers/pcmcia/vrc4173_cardu.c
@@ -561,7 +561,7 @@ static int __devinit vrc4173_cardu_init(void)
561{ 561{
562 vrc4173_cardu_slots = 0; 562 vrc4173_cardu_slots = 0;
563 563
564 return pci_module_init(&vrc4173_cardu_driver); 564 return pci_register_driver(&vrc4173_cardu_driver);
565} 565}
566 566
567static void __devexit vrc4173_cardu_exit(void) 567static void __devexit vrc4173_cardu_exit(void)
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index f10c86d60b64..995d9dd9ddd5 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -1195,7 +1195,7 @@ static int __init serial_txx9_init(void)
1195 serial_txx9_register_ports(&serial_txx9_reg); 1195 serial_txx9_register_ports(&serial_txx9_reg);
1196 1196
1197#ifdef ENABLE_SERIAL_TXX9_PCI 1197#ifdef ENABLE_SERIAL_TXX9_PCI
1198 ret = pci_module_init(&serial_txx9_pci_driver); 1198 ret = pci_register_driver(&serial_txx9_pci_driver);
1199#endif 1199#endif
1200 } 1200 }
1201 return ret; 1201 return ret;
diff --git a/drivers/video/cyblafb.c b/drivers/video/cyblafb.c
index e9f5dee67e3c..2b972461a030 100644
--- a/drivers/video/cyblafb.c
+++ b/drivers/video/cyblafb.c
@@ -1666,6 +1666,7 @@ static int __devinit cyblafb_init(void)
1666#endif 1666#endif
1667 output("CyblaFB version %s initializing\n", VERSION); 1667 output("CyblaFB version %s initializing\n", VERSION);
1668 return pci_module_init(&cyblafb_pci_driver); 1668 return pci_module_init(&cyblafb_pci_driver);
1669 return pci_register_driver(&cyblafb_pci_driver);
1669} 1670}
1670 1671
1671static void __exit cyblafb_exit(void) 1672static void __exit cyblafb_exit(void)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index de690ca73d58..0a44072383ec 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -78,6 +78,23 @@ typedef int __bitwise pci_power_t;
78#define PCI_UNKNOWN ((pci_power_t __force) 5) 78#define PCI_UNKNOWN ((pci_power_t __force) 5)
79#define PCI_POWER_ERROR ((pci_power_t __force) -1) 79#define PCI_POWER_ERROR ((pci_power_t __force) -1)
80 80
81/** The pci_channel state describes connectivity between the CPU and
82 * the pci device. If some PCI bus between here and the pci device
83 * has crashed or locked up, this info is reflected here.
84 */
85typedef unsigned int __bitwise pci_channel_state_t;
86
87enum pci_channel_state {
88 /* I/O channel is in normal state */
89 pci_channel_io_normal = (__force pci_channel_state_t) 1,
90
91 /* I/O to channel is blocked */
92 pci_channel_io_frozen = (__force pci_channel_state_t) 2,
93
94 /* PCI card is dead */
95 pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
96};
97
81/* 98/*
82 * The pci_dev structure is used to describe PCI devices. 99 * The pci_dev structure is used to describe PCI devices.
83 */ 100 */
@@ -98,6 +115,7 @@ struct pci_dev {
98 unsigned int class; /* 3 bytes: (base,sub,prog-if) */ 115 unsigned int class; /* 3 bytes: (base,sub,prog-if) */
99 u8 hdr_type; /* PCI header type (`multi' flag masked out) */ 116 u8 hdr_type; /* PCI header type (`multi' flag masked out) */
100 u8 rom_base_reg; /* which config register controls the ROM */ 117 u8 rom_base_reg; /* which config register controls the ROM */
118 u8 pin; /* which interrupt pin this device uses */
101 119
102 struct pci_driver *driver; /* which driver has allocated this device */ 120 struct pci_driver *driver; /* which driver has allocated this device */
103 u64 dma_mask; /* Mask of the bits of bus address this 121 u64 dma_mask; /* Mask of the bits of bus address this
@@ -110,6 +128,7 @@ struct pci_dev {
110 this is D0-D3, D0 being fully functional, 128 this is D0-D3, D0 being fully functional,
111 and D3 being off. */ 129 and D3 being off. */
112 130
131 pci_channel_state_t error_state; /* current connectivity state */
113 struct device dev; /* Generic device interface */ 132 struct device dev; /* Generic device interface */
114 133
115 /* device is compatible with these IDs */ 134 /* device is compatible with these IDs */
@@ -232,6 +251,54 @@ struct pci_dynids {
232 unsigned int use_driver_data:1; /* pci_driver->driver_data is used */ 251 unsigned int use_driver_data:1; /* pci_driver->driver_data is used */
233}; 252};
234 253
254/* ---------------------------------------------------------------- */
255/** PCI Error Recovery System (PCI-ERS). If a PCI device driver provides
256 * a set fof callbacks in struct pci_error_handlers, then that device driver
257 * will be notified of PCI bus errors, and will be driven to recovery
258 * when an error occurs.
259 */
260
261typedef unsigned int __bitwise pci_ers_result_t;
262
263enum pci_ers_result {
264 /* no result/none/not supported in device driver */
265 PCI_ERS_RESULT_NONE = (__force pci_ers_result_t) 1,
266
267 /* Device driver can recover without slot reset */
268 PCI_ERS_RESULT_CAN_RECOVER = (__force pci_ers_result_t) 2,
269
270 /* Device driver wants slot to be reset. */
271 PCI_ERS_RESULT_NEED_RESET = (__force pci_ers_result_t) 3,
272
273 /* Device has completely failed, is unrecoverable */
274 PCI_ERS_RESULT_DISCONNECT = (__force pci_ers_result_t) 4,
275
276 /* Device driver is fully recovered and operational */
277 PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5,
278};
279
280/* PCI bus error event callbacks */
281struct pci_error_handlers
282{
283 /* PCI bus error detected on this device */
284 pci_ers_result_t (*error_detected)(struct pci_dev *dev,
285 enum pci_channel_state error);
286
287 /* MMIO has been re-enabled, but not DMA */
288 pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev);
289
290 /* PCI Express link has been reset */
291 pci_ers_result_t (*link_reset)(struct pci_dev *dev);
292
293 /* PCI slot has been reset */
294 pci_ers_result_t (*slot_reset)(struct pci_dev *dev);
295
296 /* Device driver may resume normal operations */
297 void (*resume)(struct pci_dev *dev);
298};
299
300/* ---------------------------------------------------------------- */
301
235struct module; 302struct module;
236struct pci_driver { 303struct pci_driver {
237 struct list_head node; 304 struct list_head node;
@@ -244,6 +311,7 @@ struct pci_driver {
244 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ 311 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */
245 void (*shutdown) (struct pci_dev *dev); 312 void (*shutdown) (struct pci_dev *dev);
246 313
314 struct pci_error_handlers *err_handler;
247 struct device_driver driver; 315 struct device_driver driver;
248 struct pci_dynids dynids; 316 struct pci_dynids dynids;
249}; 317};
@@ -448,6 +516,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass
448 516
449void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), 517void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
450 void *userdata); 518 void *userdata);
519int pci_cfg_space_size(struct pci_dev *dev);
451 520
452/* kmem_cache style wrapper around pci_alloc_consistent() */ 521/* kmem_cache style wrapper around pci_alloc_consistent() */
453 522
diff --git a/sound/oss/ad1889.c b/sound/oss/ad1889.c
index 2cfd214e4c2a..a0d73f343100 100644
--- a/sound/oss/ad1889.c
+++ b/sound/oss/ad1889.c
@@ -1089,7 +1089,7 @@ static struct pci_driver ad1889_driver = {
1089 1089
1090static int __init ad1889_init_module(void) 1090static int __init ad1889_init_module(void)
1091{ 1091{
1092 return pci_module_init(&ad1889_driver); 1092 return pci_register_driver(&ad1889_driver);
1093} 1093}
1094 1094
1095static void ad1889_exit_module(void) 1095static void ad1889_exit_module(void)
diff --git a/sound/oss/btaudio.c b/sound/oss/btaudio.c
index a85093fec7be..4007a5680acb 100644
--- a/sound/oss/btaudio.c
+++ b/sound/oss/btaudio.c
@@ -1101,7 +1101,7 @@ static int btaudio_init_module(void)
1101 digital ? "digital" : "", 1101 digital ? "digital" : "",
1102 analog && digital ? "+" : "", 1102 analog && digital ? "+" : "",
1103 analog ? "analog" : ""); 1103 analog ? "analog" : "");
1104 return pci_module_init(&btaudio_pci_driver); 1104 return pci_register_driver(&btaudio_pci_driver);
1105} 1105}
1106 1106
1107static void btaudio_cleanup_module(void) 1107static void btaudio_cleanup_module(void)
diff --git a/sound/oss/cmpci.c b/sound/oss/cmpci.c
index 74dcca78c6c0..7cfbb08db537 100644
--- a/sound/oss/cmpci.c
+++ b/sound/oss/cmpci.c
@@ -3366,7 +3366,7 @@ static struct pci_driver cm_driver = {
3366static int __init init_cmpci(void) 3366static int __init init_cmpci(void)
3367{ 3367{
3368 printk(KERN_INFO "cmpci: version $Revision: 6.82 $ time " __TIME__ " " __DATE__ "\n"); 3368 printk(KERN_INFO "cmpci: version $Revision: 6.82 $ time " __TIME__ " " __DATE__ "\n");
3369 return pci_module_init(&cm_driver); 3369 return pci_register_driver(&cm_driver);
3370} 3370}
3371 3371
3372static void __exit cleanup_cmpci(void) 3372static void __exit cleanup_cmpci(void)
diff --git a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c
index 46dd41dc2a34..0720365f6438 100644
--- a/sound/oss/cs4281/cs4281m.c
+++ b/sound/oss/cs4281/cs4281m.c
@@ -4461,7 +4461,7 @@ static int __init cs4281_init_module(void)
4461 printk(KERN_INFO "cs4281: version v%d.%02d.%d time " __TIME__ " " 4461 printk(KERN_INFO "cs4281: version v%d.%02d.%d time " __TIME__ " "
4462 __DATE__ "\n", CS4281_MAJOR_VERSION, CS4281_MINOR_VERSION, 4462 __DATE__ "\n", CS4281_MAJOR_VERSION, CS4281_MINOR_VERSION,
4463 CS4281_ARCH); 4463 CS4281_ARCH);
4464 rtn = pci_module_init(&cs4281_pci_driver); 4464 rtn = pci_register_driver(&cs4281_pci_driver);
4465 4465
4466 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, 4466 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2,
4467 printk(KERN_INFO "cs4281: cs4281_init_module()- (%d)\n",rtn)); 4467 printk(KERN_INFO "cs4281: cs4281_init_module()- (%d)\n",rtn));
diff --git a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
index 0da4d93f04a6..58e25c82eaf2 100644
--- a/sound/oss/cs46xx.c
+++ b/sound/oss/cs46xx.c
@@ -5690,7 +5690,7 @@ static int __init cs46xx_init_module(void)
5690 int rtn = 0; 5690 int rtn = 0;
5691 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, printk(KERN_INFO 5691 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, printk(KERN_INFO
5692 "cs46xx: cs46xx_init_module()+ \n")); 5692 "cs46xx: cs46xx_init_module()+ \n"));
5693 rtn = pci_module_init(&cs46xx_pci_driver); 5693 rtn = pci_register_driver(&cs46xx_pci_driver);
5694 5694
5695 if(rtn == -ENODEV) 5695 if(rtn == -ENODEV)
5696 { 5696 {
diff --git a/sound/oss/emu10k1/main.c b/sound/oss/emu10k1/main.c
index 9b905bae423e..23241cbdd90f 100644
--- a/sound/oss/emu10k1/main.c
+++ b/sound/oss/emu10k1/main.c
@@ -1428,7 +1428,7 @@ static int __init emu10k1_init_module(void)
1428{ 1428{
1429 printk(KERN_INFO "Creative EMU10K1 PCI Audio Driver, version " DRIVER_VERSION ", " __TIME__ " " __DATE__ "\n"); 1429 printk(KERN_INFO "Creative EMU10K1 PCI Audio Driver, version " DRIVER_VERSION ", " __TIME__ " " __DATE__ "\n");
1430 1430
1431 return pci_module_init(&emu10k1_pci_driver); 1431 return pci_register_driver(&emu10k1_pci_driver);
1432} 1432}
1433 1433
1434static void __exit emu10k1_cleanup_module(void) 1434static void __exit emu10k1_cleanup_module(void)
diff --git a/sound/oss/es1370.c b/sound/oss/es1370.c
index 8538085086e7..ae55c536613a 100644
--- a/sound/oss/es1370.c
+++ b/sound/oss/es1370.c
@@ -2779,7 +2779,7 @@ static struct pci_driver es1370_driver = {
2779static int __init init_es1370(void) 2779static int __init init_es1370(void)
2780{ 2780{
2781 printk(KERN_INFO "es1370: version v0.38 time " __TIME__ " " __DATE__ "\n"); 2781 printk(KERN_INFO "es1370: version v0.38 time " __TIME__ " " __DATE__ "\n");
2782 return pci_module_init(&es1370_driver); 2782 return pci_register_driver(&es1370_driver);
2783} 2783}
2784 2784
2785static void __exit cleanup_es1370(void) 2785static void __exit cleanup_es1370(void)
diff --git a/sound/oss/es1371.c b/sound/oss/es1371.c
index 12a56d5ab498..5c697f162579 100644
--- a/sound/oss/es1371.c
+++ b/sound/oss/es1371.c
@@ -3090,7 +3090,7 @@ static struct pci_driver es1371_driver = {
3090static int __init init_es1371(void) 3090static int __init init_es1371(void)
3091{ 3091{
3092 printk(KERN_INFO PFX "version v0.32 time " __TIME__ " " __DATE__ "\n"); 3092 printk(KERN_INFO PFX "version v0.32 time " __TIME__ " " __DATE__ "\n");
3093 return pci_module_init(&es1371_driver); 3093 return pci_register_driver(&es1371_driver);
3094} 3094}
3095 3095
3096static void __exit cleanup_es1371(void) 3096static void __exit cleanup_es1371(void)
diff --git a/sound/oss/ite8172.c b/sound/oss/ite8172.c
index 26e5944b6ba8..8fd2f9a9e668 100644
--- a/sound/oss/ite8172.c
+++ b/sound/oss/ite8172.c
@@ -2206,7 +2206,7 @@ static struct pci_driver it8172_driver = {
2206static int __init init_it8172(void) 2206static int __init init_it8172(void)
2207{ 2207{
2208 info("version v0.5 time " __TIME__ " " __DATE__); 2208 info("version v0.5 time " __TIME__ " " __DATE__);
2209 return pci_module_init(&it8172_driver); 2209 return pci_register_driver(&it8172_driver);
2210} 2210}
2211 2211
2212static void __exit cleanup_it8172(void) 2212static void __exit cleanup_it8172(void)
diff --git a/sound/oss/kahlua.c b/sound/oss/kahlua.c
index 808c5ef969be..2835a7c038ef 100644
--- a/sound/oss/kahlua.c
+++ b/sound/oss/kahlua.c
@@ -218,7 +218,7 @@ static struct pci_driver kahlua_driver = {
218static int __init kahlua_init_module(void) 218static int __init kahlua_init_module(void)
219{ 219{
220 printk(KERN_INFO "Cyrix Kahlua VSA1 XpressAudio support (c) Copyright 2003 Red Hat Inc\n"); 220 printk(KERN_INFO "Cyrix Kahlua VSA1 XpressAudio support (c) Copyright 2003 Red Hat Inc\n");
221 return pci_module_init(&kahlua_driver); 221 return pci_register_driver(&kahlua_driver);
222} 222}
223 223
224static void __devexit kahlua_cleanup_module(void) 224static void __devexit kahlua_cleanup_module(void)
diff --git a/sound/oss/maestro.c b/sound/oss/maestro.c
index f9ac5b16f61a..d4b569acf764 100644
--- a/sound/oss/maestro.c
+++ b/sound/oss/maestro.c
@@ -3624,7 +3624,7 @@ static int __init init_maestro(void)
3624{ 3624{
3625 int rc; 3625 int rc;
3626 3626
3627 rc = pci_module_init(&maestro_pci_driver); 3627 rc = pci_register_driver(&maestro_pci_driver);
3628 if (rc < 0) 3628 if (rc < 0)
3629 return rc; 3629 return rc;
3630 3630
diff --git a/sound/oss/nec_vrc5477.c b/sound/oss/nec_vrc5477.c
index 9ac4bf7e1e89..fbb9170e8e0a 100644
--- a/sound/oss/nec_vrc5477.c
+++ b/sound/oss/nec_vrc5477.c
@@ -2045,7 +2045,7 @@ static struct pci_driver vrc5477_ac97_driver = {
2045static int __init init_vrc5477_ac97(void) 2045static int __init init_vrc5477_ac97(void)
2046{ 2046{
2047 printk("Vrc5477 AC97 driver: version v0.2 time " __TIME__ " " __DATE__ " by Jun Sun\n"); 2047 printk("Vrc5477 AC97 driver: version v0.2 time " __TIME__ " " __DATE__ " by Jun Sun\n");
2048 return pci_module_init(&vrc5477_ac97_driver); 2048 return pci_register_driver(&vrc5477_ac97_driver);
2049} 2049}
2050 2050
2051static void __exit cleanup_vrc5477_ac97(void) 2051static void __exit cleanup_vrc5477_ac97(void)
diff --git a/sound/oss/nm256_audio.c b/sound/oss/nm256_audio.c
index 42d8f05689c2..7de079b202f2 100644
--- a/sound/oss/nm256_audio.c
+++ b/sound/oss/nm256_audio.c
@@ -1644,7 +1644,7 @@ module_param(force_load, bool, 0);
1644static int __init do_init_nm256(void) 1644static int __init do_init_nm256(void)
1645{ 1645{
1646 printk (KERN_INFO "NeoMagic 256AV/256ZX audio driver, version 1.1p\n"); 1646 printk (KERN_INFO "NeoMagic 256AV/256ZX audio driver, version 1.1p\n");
1647 return pci_module_init(&nm256_pci_driver); 1647 return pci_register_driver(&nm256_pci_driver);
1648} 1648}
1649 1649
1650static void __exit cleanup_nm256 (void) 1650static void __exit cleanup_nm256 (void)
diff --git a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
index 318dc51009fe..faa0b7919b65 100644
--- a/sound/oss/rme96xx.c
+++ b/sound/oss/rme96xx.c
@@ -1095,7 +1095,7 @@ static int __init init_rme96xx(void)
1095 devices = ((devices-1) & RME96xx_MASK_DEVS) + 1; 1095 devices = ((devices-1) & RME96xx_MASK_DEVS) + 1;
1096 printk(KERN_INFO RME_MESS" reserving %d dsp device(s)\n",devices); 1096 printk(KERN_INFO RME_MESS" reserving %d dsp device(s)\n",devices);
1097 numcards = 0; 1097 numcards = 0;
1098 return pci_module_init(&rme96xx_driver); 1098 return pci_register_driver(&rme96xx_driver);
1099} 1099}
1100 1100
1101static void __exit cleanup_rme96xx(void) 1101static void __exit cleanup_rme96xx(void)
diff --git a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
index 17d0e461f8d8..71b05e2f6977 100644
--- a/sound/oss/sonicvibes.c
+++ b/sound/oss/sonicvibes.c
@@ -2765,7 +2765,7 @@ static int __init init_sonicvibes(void)
2765 if (!(wavetable_mem = __get_free_pages(GFP_KERNEL, 20-PAGE_SHIFT))) 2765 if (!(wavetable_mem = __get_free_pages(GFP_KERNEL, 20-PAGE_SHIFT)))
2766 printk(KERN_INFO "sv: cannot allocate 1MB of contiguous nonpageable memory for wavetable data\n"); 2766 printk(KERN_INFO "sv: cannot allocate 1MB of contiguous nonpageable memory for wavetable data\n");
2767#endif 2767#endif
2768 return pci_module_init(&sv_driver); 2768 return pci_register_driver(&sv_driver);
2769} 2769}
2770 2770
2771static void __exit cleanup_sonicvibes(void) 2771static void __exit cleanup_sonicvibes(void)
diff --git a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
index 8dae59bd05a2..f8bd72e46f57 100644
--- a/sound/oss/ymfpci.c
+++ b/sound/oss/ymfpci.c
@@ -2680,7 +2680,7 @@ static struct pci_driver ymfpci_driver = {
2680 2680
2681static int __init ymf_init_module(void) 2681static int __init ymf_init_module(void)
2682{ 2682{
2683 return pci_module_init(&ymfpci_driver); 2683 return pci_register_driver(&ymfpci_driver);
2684} 2684}
2685 2685
2686static void __exit ymf_cleanup_module (void) 2686static void __exit ymf_cleanup_module (void)