This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / include / linux / pci.h
index b1c5cef..bb3707a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     pci.h
+ *     $Id: pci.h,v 1.87 1998/10/11 15:13:12 mj Exp $
  *
  *     PCI defines and function prototypes
  *     Copyright 1994, Drew Eckhardt
@@ -537,8 +537,6 @@ struct pci_dev {
        unsigned int    is_busmaster:1; /* device is busmaster */
        
        u32             saved_config_space[16]; /* config space saved at suspend time */
-       struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */
-       int rom_attr_enabled;           /* has display of the rom attribute been enabled? */
 #ifdef CONFIG_PCI_NAMES
 #define PCI_NAME_SIZE  96
 #define PCI_NAME_HALF  __stringify(43) /* less than half to handle slop */
@@ -549,7 +547,6 @@ struct pci_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)
 #define        to_pci_dev(n) container_of(n, struct pci_dev, dev)
-#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
 
 /*
  *  For PCI devices, the region numbers are assigned this way:
@@ -634,11 +631,9 @@ struct pci_dynids {
        unsigned int use_driver_data:1; /* pci_driver->driver_data is used */
 };
 
-struct module;
 struct pci_driver {
        struct list_head node;
        char *name;
-       struct module *owner;
        const struct pci_device_id *id_table;   /* must be non-NULL for probe to be called */
        int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);   /* New device inserted */
        void (*remove) (struct pci_dev *dev);   /* Device removed (NULL if not a hot-plug capable driver) */
@@ -679,12 +674,6 @@ struct pci_driver {
        .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
        .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
 
-/* 
- * pci_module_init is obsolete, this stays here till we fix up all usages of it
- * in the tree.
- */
-#define pci_module_init        pci_register_driver
-
 /* these external functions are only available when PCI support is enabled */
 #ifdef CONFIG_PCI
 
@@ -715,7 +704,6 @@ static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *s
 int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
 unsigned int pci_scan_child_bus(struct pci_bus *bus);
-void pci_bus_add_device(struct pci_dev *dev);
 void pci_bus_add_devices(struct pci_bus *bus);
 void pci_name_device(struct pci_dev *dev);
 char *pci_class_name(u32 class);
@@ -731,6 +719,10 @@ extern void pci_remove_bus_device(struct pci_dev *dev);
 
 struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from);
 struct pci_dev *pci_find_device_reverse (unsigned int vendor, unsigned int device, const struct pci_dev *from);
+struct pci_dev *pci_find_subsys (unsigned int vendor, unsigned int device,
+                                unsigned int ss_vendor, unsigned int ss_device,
+                                const struct pci_dev *from);
+struct pci_dev *pci_find_class (unsigned int class, const struct pci_dev *from);
 struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);
 int pci_find_capability (struct pci_dev *dev, int cap);
 int pci_find_ext_capability (struct pci_dev *dev, int cap);
@@ -741,8 +733,6 @@ struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device,
                                unsigned int ss_vendor, unsigned int ss_device,
                                struct pci_dev *from);
 struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn);
-struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from);
-int pci_dev_present(const struct pci_device_id *ids);
 
 int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val);
 int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val);
@@ -788,15 +778,9 @@ int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask);
 int __must_check pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
 int pci_assign_resource(struct pci_dev *dev, int i);
 
-/* ROM control related routines */
-void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size);
-void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size);
-void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
-void pci_remove_rom(struct pci_dev *pdev);
-
 /* Power management related routines */
-int pci_save_state(struct pci_dev *dev);
-int pci_restore_state(struct pci_dev *dev);
+int pci_save_state(struct pci_dev *dev, u32 *buffer);
+int pci_restore_state(struct pci_dev *dev, u32 *buffer);
 int pci_set_power_state(struct pci_dev *dev, int state);
 int pci_enable_wake(struct pci_dev *dev, u32 state, int enable);
 
@@ -876,6 +860,10 @@ extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
 
 #include <asm/pci.h>
 
+/* Backwards compat, remove in 2.7.x */
+#define pci_dma_sync_single    pci_dma_sync_single_for_cpu
+#define pci_dma_sync_sg                pci_dma_sync_sg_for_cpu
+
 /*
  *  If the system does not have PCI, clearly these return errors.  Define
  *  these as simple inline functions to avoid hair in drivers.
@@ -894,9 +882,16 @@ _PCI_NOP_ALL(write,)
 static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from)
 { return NULL; }
 
+static inline struct pci_dev *pci_find_class(unsigned int class, const struct pci_dev *from)
+{ return NULL; }
+
 static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn)
 { return NULL; }
 
+static inline struct pci_dev *pci_find_subsys(unsigned int vendor, unsigned int device,
+unsigned int ss_vendor, unsigned int ss_device, const struct pci_dev *from)
+{ return NULL; }
+
 static inline struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from)
 { return NULL; }
 
@@ -904,15 +899,10 @@ static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int
 unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from)
 { return NULL; }
 
-static inline struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
-{ return NULL; }
-
-#define pci_dev_present(ids)   (0)
-#define pci_dev_put(dev)       do { } while (0)
-
 static inline void pci_set_master(struct pci_dev *dev) { }
 static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
 static inline void pci_disable_device(struct pci_dev *dev) { }
+static inline int pci_module_init(struct pci_driver *drv) { return -ENODEV; }
 static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
 static inline int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
 static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;}
@@ -923,8 +913,8 @@ static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return
 static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; }
 
 /* Power management related routines */
-static inline int pci_save_state(struct pci_dev *dev) { return 0; }
-static inline int pci_restore_state(struct pci_dev *dev) { return 0; }
+static inline int pci_save_state(struct pci_dev *dev, u32 *buffer) { return 0; }
+static inline int pci_restore_state(struct pci_dev *dev, u32 *buffer) { return 0; }
 static inline int pci_set_power_state(struct pci_dev *dev, int state) { return 0; }
 static inline int pci_enable_wake(struct pci_dev *dev, u32 state, int enable) { return 0; }
 
@@ -932,6 +922,19 @@ static inline int pci_enable_wake(struct pci_dev *dev, u32 state, int enable) {
 
 #else
 
+/*
+ * a helper function which helps ensure correct pci_driver
+ * setup and cleanup for commonly-encountered hotplug/modular cases
+ *
+ * This MUST stay in a header, as it checks for -DMODULE
+ */
+static inline int pci_module_init(struct pci_driver *drv)
+{
+       int rc = pci_register_driver (drv);
+
+       return rc < 0 ? rc : 0;
+}
+
 /*
  * PCI domain support.  Sometimes called PCI segment (eg by ACPI),
  * a PCI domain is defined to be a set of PCI busses which share
@@ -998,34 +1001,25 @@ static inline char *pci_name(struct pci_dev *pdev)
  */
 
 struct pci_fixup {
-       u16 vendor, device;     /* You can use PCI_ANY_ID here of course */
+       u16 vendor, device;                     /* You can use PCI_ANY_ID here of course */
        void (*hook)(struct pci_dev *dev);
 };
 
 enum pci_fixup_pass {
-       pci_fixup_early,        /* Before probing BARs */
-       pci_fixup_header,       /* After reading configuration header */
+       pci_fixup_header,       /* Called immediately after reading configuration header */
        pci_fixup_final,        /* Final phase of device fixups */
-       pci_fixup_enable,       /* pci_enable_device() time */
 };
 
 /* Anonymous variables would be nice... */
-#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \
-       static struct pci_fixup __pci_fixup_##name __attribute_used__   \
-       __attribute__((__section__(#section))) = { vendor, device, hook };
-#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook)                  \
-       DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early,                     \
-                       vendor##device##hook, vendor, device, hook)
-#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook)                 \
-       DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header,                    \
-                       vendor##device##hook, vendor, device, hook)
-#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook)                  \
-       DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final,                     \
-                       vendor##device##hook, vendor, device, hook)
-#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook)                 \
-       DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable,                    \
-                       vendor##device##hook, vendor, device, hook)
-
+#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook)                                 \
+       static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__   \
+       __attribute__((__section__(".pci_fixup_header"))) = {                           \
+               vendor, device, hook };
+
+#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook)                          \
+       static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__   \
+       __attribute__((__section__(".pci_fixup_final"))) = {                            \
+               vendor, device, hook };
 
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);