patch-2.3.37 linux/include/linux/pci.h
Next file: linux/include/linux/random.h
Previous file: linux/include/linux/fs.h
Back to the patch index
Back to the overall index
- Lines: 101
- Date:
Thu Jan 6 11:42:18 2000
- Orig file:
v2.3.36/linux/include/linux/pci.h
- Orig date:
Tue Jan 4 13:57:21 2000
diff -u --recursive --new-file v2.3.36/linux/include/linux/pci.h linux/include/linux/pci.h
@@ -283,6 +283,7 @@
#include <linux/types.h>
#include <linux/config.h>
#include <linux/ioport.h>
+#include <linux/list.h>
#include <asm/pci.h>
@@ -295,13 +296,10 @@
* The pci_dev structure is used to describe both PCI and ISAPnP devices.
*/
struct pci_dev {
- int active; /* device is active */
- int ro; /* Read/Only */
-
+ struct list_head global_list; /* node in list of all PCI devices */
+ struct list_head bus_list; /* node in per-bus list */
struct pci_bus *bus; /* bus this device is on */
struct pci_bus *subordinate; /* bus this device bridges to */
- struct pci_dev *sibling; /* next device on this bus */
- struct pci_dev *next; /* chain of all devices */
void *sysdata; /* hook for sys-specific extension */
struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
@@ -332,12 +330,17 @@
char name[48]; /* Device name */
char slot_name[8]; /* Slot name */
+ int active; /* device is active */
+ int ro; /* Read/Only */
int (*prepare)(struct pci_dev *dev);
int (*activate)(struct pci_dev *dev);
int (*deactivate)(struct pci_dev *dev);
};
+#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)
+#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
+
/*
* For PCI devices, the region numbers are assigned this way:
*
@@ -353,16 +356,14 @@
#define PCI_REGION_FLAG_MASK 0x0f /* These bits of resource flags tell us the PCI region flags */
struct pci_bus {
+ struct list_head node; /* node in list of buses */
struct pci_bus *parent; /* parent bus this bridge is on */
- struct pci_bus *children; /* chain of P2P bridges on this bus */
- struct pci_bus *next; /* chain of all PCI buses */
- struct pci_ops *ops; /* configuration access functions */
-
+ struct list_head children; /* list of child buses */
+ struct list_head devices; /* list of devices on this bus */
struct pci_dev *self; /* bridge device as seen by parent */
- struct pci_dev *devices; /* devices behind this bridge */
- struct pci_dev **last_dev_p; /* where should next device be linked to */
struct resource *resource[4]; /* address space routed to this bus */
+ struct pci_ops *ops; /* configuration access functions */
void *sysdata; /* hook for sys-specific extension */
struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
@@ -381,8 +382,10 @@
unsigned char pad1;
};
-extern struct pci_bus *pci_root; /* root bus */
-extern struct pci_dev *pci_devices; /* list of all devices */
+#define pci_bus_b(n) list_entry(n, struct pci_bus, node)
+
+extern struct list_head pci_root_buses; /* list of all known PCI buses */
+extern struct list_head pci_devices; /* list of all devices */
/*
* Error values that may be returned by PCI functions.
@@ -458,6 +461,7 @@
char *pci_class_name(u32 class);
void pci_read_bridge_bases(struct pci_bus *child);
struct resource *pci_find_parent_resource(struct pci_dev *dev, struct resource *res);
+int pci_setup_device(struct pci_dev * dev);
/* Generic PCI functions exported to card drivers */
@@ -478,11 +482,15 @@
int pci_write_config_word(struct pci_dev *dev, int where, u16 val);
int pci_write_config_dword(struct pci_dev *dev, int where, u32 val);
-int pci_setup_device(struct pci_dev * dev);
int pci_enable_device(struct pci_dev *dev);
void pci_set_master(struct pci_dev *dev);
int pci_set_power_state(struct pci_dev *dev, int state);
int pci_assign_resource(struct pci_dev *dev, int i);
+
+#define __pcidev(entry) list_entry(entry, struct pci_dev, global_list)
+
+#define pci_for_each_dev(dev) \
+ for(dev = __pcidev(pci_devices.next); dev != __pcidev(&pci_devices); dev = __pcidev(dev->global_list.next))
/* Helper functions for low-level code (drivers/pci/setup.c) */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)