Commit d9a26363 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

PCI: hotplug core cleanup to get pci hotplug working again

- removed pci_announce_device_to_drivers() prototype as the function is long gone
- always call /sbin/hotplug when pci devices are added to the system if
  so configured (this includes during the system bring up.)
parent ccf7dd29
...@@ -6,10 +6,8 @@ export-objs := access.o hotplug.o pci-driver.o pci.o pool.o \ ...@@ -6,10 +6,8 @@ export-objs := access.o hotplug.o pci-driver.o pci.o pool.o \
probe.o proc.o search.o compat.o probe.o proc.o search.o compat.o
obj-y += access.o probe.o pci.o pool.o quirks.o \ obj-y += access.o probe.o pci.o pool.o quirks.o \
compat.o names.o pci-driver.o search.o compat.o names.o pci-driver.o search.o hotplug.o
obj-$(CONFIG_PM) += power.o obj-$(CONFIG_PM) += power.o
obj-$(CONFIG_HOTPLUG) += hotplug.o
obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_PROC_FS) += proc.o
ifndef CONFIG_SPARC64 ifndef CONFIG_SPARC64
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#define TRUE (!FALSE) #define TRUE (!FALSE)
#endif #endif
static void #ifdef CONFIG_HOTPLUG
run_sbin_hotplug(struct pci_dev *pdev, int insert) static void run_sbin_hotplug(struct pci_dev *pdev, int insert)
{ {
int i; int i;
char *argv[3], *envp[8]; char *argv[3], *envp[8];
...@@ -45,13 +45,18 @@ run_sbin_hotplug(struct pci_dev *pdev, int insert) ...@@ -45,13 +45,18 @@ run_sbin_hotplug(struct pci_dev *pdev, int insert)
call_usermodehelper (argv [0], argv, envp); call_usermodehelper (argv [0], argv, envp);
} }
#else
static void run_sbin_hotplug(struct pci_dev *pdev, int insert) { }
#endif
/** /**
* pci_insert_device - insert a hotplug device * pci_insert_device - insert a pci device
* @dev: the device to insert * @dev: the device to insert
* @bus: where to insert it * @bus: where to insert it
* *
* Add a new device to the device lists and notify userspace (/sbin/hotplug). * Link the device to both the global PCI device chain and the
* per-bus list of devices, add the /proc entry, and notify
* userspace (/sbin/hotplug).
*/ */
void void
pci_insert_device(struct pci_dev *dev, struct pci_bus *bus) pci_insert_device(struct pci_dev *dev, struct pci_bus *bus)
...@@ -78,11 +83,11 @@ pci_free_resources(struct pci_dev *dev) ...@@ -78,11 +83,11 @@ pci_free_resources(struct pci_dev *dev)
} }
/** /**
* pci_remove_device - remove a hotplug device * pci_remove_device - remove a pci device
* @dev: the device to remove * @dev: the device to remove
* *
* Delete the device structure from the device lists and * Delete the device structure from the device lists,
* notify userspace (/sbin/hotplug). * remove the /proc entry, and notify userspace (/sbin/hotplug).
*/ */
void void
pci_remove_device(struct pci_dev *dev) pci_remove_device(struct pci_dev *dev)
...@@ -94,10 +99,11 @@ pci_remove_device(struct pci_dev *dev) ...@@ -94,10 +99,11 @@ pci_remove_device(struct pci_dev *dev)
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
pci_proc_detach_device(dev); pci_proc_detach_device(dev);
#endif #endif
/* notify userspace of hotplug device removal */ /* notify userspace of hotplug device removal */
run_sbin_hotplug(dev, FALSE); run_sbin_hotplug(dev, FALSE);
} }
#ifdef CONFIG_HOTPLUG
EXPORT_SYMBOL(pci_insert_device); EXPORT_SYMBOL(pci_insert_device);
EXPORT_SYMBOL(pci_remove_device); EXPORT_SYMBOL(pci_remove_device);
#endif
...@@ -479,10 +479,10 @@ struct pci_dev * __devinit pci_scan_slot(struct pci_dev *temp) ...@@ -479,10 +479,10 @@ struct pci_dev * __devinit pci_scan_slot(struct pci_dev *temp)
/* /*
* Link the device to both the global PCI device chain and * Link the device to both the global PCI device chain and
* the per-bus list of devices. * the per-bus list of devices and call /sbin/hotplug if we
* should.
*/ */
list_add_tail(&dev->global_list, &pci_devices); pci_insert_device (dev, bus);
list_add_tail(&dev->bus_list, &bus->devices);
/* Fix up broken headers */ /* Fix up broken headers */
pci_fixup_device(PCI_FIXUP_HEADER, dev); pci_fixup_device(PCI_FIXUP_HEADER, dev);
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#define PCI_CFG_SPACE_SIZE 256 #define PCI_CFG_SPACE_SIZE 256
static int proc_initialized; /* = 0 */
static loff_t static loff_t
proc_bus_pci_lseek(struct file *file, loff_t off, int whence) proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
{ {
...@@ -410,6 +412,9 @@ int pci_proc_attach_device(struct pci_dev *dev) ...@@ -410,6 +412,9 @@ int pci_proc_attach_device(struct pci_dev *dev)
struct proc_dir_entry *de, *e; struct proc_dir_entry *de, *e;
char name[16]; char name[16];
if (!proc_initialized)
return -EACCES;
if (!(de = bus->procdir)) { if (!(de = bus->procdir)) {
sprintf(name, "%02x", bus->number); sprintf(name, "%02x", bus->number);
de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir); de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir);
...@@ -446,6 +451,9 @@ int pci_proc_attach_bus(struct pci_bus* bus) ...@@ -446,6 +451,9 @@ int pci_proc_attach_bus(struct pci_bus* bus)
{ {
struct proc_dir_entry *de = bus->procdir; struct proc_dir_entry *de = bus->procdir;
if (!proc_initialized)
return -EACCES;
if (!de) { if (!de) {
char name[16]; char name[16];
sprintf(name, "%02x", bus->number); sprintf(name, "%02x", bus->number);
...@@ -595,6 +603,7 @@ static int __init pci_proc_init(void) ...@@ -595,6 +603,7 @@ static int __init pci_proc_init(void)
entry = create_proc_entry("devices", 0, proc_bus_pci_dir); entry = create_proc_entry("devices", 0, proc_bus_pci_dir);
if (entry) if (entry)
entry->proc_fops = &proc_bus_pci_dev_operations; entry->proc_fops = &proc_bus_pci_dev_operations;
proc_initialized = 1;
pci_for_each_dev(dev) { pci_for_each_dev(dev) {
pci_proc_attach_device(dev); pci_proc_attach_device(dev);
} }
......
...@@ -634,7 +634,6 @@ void pci_insert_device(struct pci_dev *, struct pci_bus *); ...@@ -634,7 +634,6 @@ void pci_insert_device(struct pci_dev *, struct pci_bus *);
void pci_remove_device(struct pci_dev *); void pci_remove_device(struct pci_dev *);
struct pci_driver *pci_dev_driver(const struct pci_dev *); struct pci_driver *pci_dev_driver(const struct pci_dev *);
const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev); const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev);
void pci_announce_device_to_drivers(struct pci_dev *);
unsigned int pci_do_scan_bus(struct pci_bus *bus); unsigned int pci_do_scan_bus(struct pci_bus *bus);
struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment