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

[PATCH] PCI: add pci_bus_* functions to replace the pci_read_* and pci_write_* functions.

add pci_bus_* functions to replace the pci_read_* and pci_write_* functions.
parent 894b156c
...@@ -71,16 +71,16 @@ static int __pci_conf1_write (int seg, int bus, int dev, int fn, int reg, int le ...@@ -71,16 +71,16 @@ static int __pci_conf1_write (int seg, int bus, int dev, int fn, int reg, int le
#undef PCI_CONF1_ADDRESS #undef PCI_CONF1_ADDRESS
static int pci_conf1_read(struct pci_dev *dev, int where, int size, u32 *value) static int pci_conf1_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
{ {
return __pci_conf1_read(0, dev->bus->number, PCI_SLOT(dev->devfn), return __pci_conf1_read(0, bus->number, PCI_SLOT(devfn),
PCI_FUNC(dev->devfn), where, size, value); PCI_FUNC(devfn), where, size, value);
} }
static int pci_conf1_write(struct pci_dev *dev, int where, int size, u32 value) static int pci_conf1_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
{ {
return __pci_conf1_write(0, dev->bus->number, PCI_SLOT(dev->devfn), return __pci_conf1_write(0, bus->number, PCI_SLOT(devfn),
PCI_FUNC(dev->devfn), where, size, value); PCI_FUNC(devfn), where, size, value);
} }
static struct pci_ops pci_direct_conf1 = { static struct pci_ops pci_direct_conf1 = {
...@@ -165,16 +165,16 @@ static int __pci_conf2_write (int seg, int bus, int dev, int fn, int reg, int le ...@@ -165,16 +165,16 @@ static int __pci_conf2_write (int seg, int bus, int dev, int fn, int reg, int le
#undef PCI_CONF2_ADDRESS #undef PCI_CONF2_ADDRESS
static int pci_conf2_read(struct pci_dev *dev, int where, int size, u32 *value) static int pci_conf2_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
{ {
return __pci_conf2_read(0, dev->bus->number, PCI_SLOT(dev->devfn), return __pci_conf2_read(0, bus->number, PCI_SLOT(devfn),
PCI_FUNC(dev->devfn), where, size, value); PCI_FUNC(devfn), where, size, value);
} }
static int pci_conf2_write(struct pci_dev *dev, int where, int size, u32 value) static int pci_conf2_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
{ {
return __pci_conf2_write(0, dev->bus->number, PCI_SLOT(dev->devfn), return __pci_conf2_write(0, bus->number, PCI_SLOT(devfn),
PCI_FUNC(dev->devfn), where, size, value); PCI_FUNC(devfn), where, size, value);
} }
static struct pci_ops pci_direct_conf2 = { static struct pci_ops pci_direct_conf2 = {
...@@ -204,9 +204,9 @@ static int __devinit pci_sanity_check(struct pci_ops *o) ...@@ -204,9 +204,9 @@ static int __devinit pci_sanity_check(struct pci_ops *o)
bus.number = 0; bus.number = 0;
dev.bus = &bus; dev.bus = &bus;
for(dev.devfn=0; dev.devfn < 0x100; dev.devfn++) for(dev.devfn=0; dev.devfn < 0x100; dev.devfn++)
if ((!o->read(&dev, PCI_CLASS_DEVICE, 2, &x) && if ((!o->read(&bus, dev.devfn, PCI_CLASS_DEVICE, 2, &x) &&
(x == PCI_CLASS_BRIDGE_HOST || x == PCI_CLASS_DISPLAY_VGA)) || (x == PCI_CLASS_BRIDGE_HOST || x == PCI_CLASS_DISPLAY_VGA)) ||
(!o->read(&dev, PCI_VENDOR_ID, 2, &x) && (!o->read(&bus, dev.devfn, PCI_VENDOR_ID, 2, &x) &&
(x == PCI_VENDOR_ID_INTEL || x == PCI_VENDOR_ID_COMPAQ))) (x == PCI_VENDOR_ID_INTEL || x == PCI_VENDOR_ID_COMPAQ)))
return 1; return 1;
DBG("PCI: Sanity check failed\n"); DBG("PCI: Sanity check failed\n");
......
...@@ -295,16 +295,16 @@ static int __pci_bios_write (int seg, int bus, int dev, int fn, int reg, int len ...@@ -295,16 +295,16 @@ static int __pci_bios_write (int seg, int bus, int dev, int fn, int reg, int len
return (int)((result & 0xff00) >> 8); return (int)((result & 0xff00) >> 8);
} }
static int pci_bios_read(struct pci_dev *dev, int where, int size, u32 *value) static int pci_bios_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
{ {
return __pci_bios_read(0, dev->bus->number, PCI_SLOT(dev->devfn), return __pci_bios_read(0, bus->number, PCI_SLOT(devfn),
PCI_FUNC(dev->devfn), where, size, value); PCI_FUNC(devfn), where, size, value);
} }
static int pci_bios_write(struct pci_dev *dev, int where, int size, u32 value) static int pci_bios_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
{ {
return __pci_bios_write(0, dev->bus->number, PCI_SLOT(dev->devfn), return __pci_bios_write(0, bus->number, PCI_SLOT(devfn),
PCI_FUNC(dev->devfn), where, size, value); PCI_FUNC(devfn), where, size, value);
} }
......
...@@ -20,27 +20,29 @@ spinlock_t pci_lock = SPIN_LOCK_UNLOCKED; ...@@ -20,27 +20,29 @@ spinlock_t pci_lock = SPIN_LOCK_UNLOCKED;
#define PCI_dword_BAD (pos & 3) #define PCI_dword_BAD (pos & 3)
#define PCI_OP_READ(size,type,len) \ #define PCI_OP_READ(size,type,len) \
int pci_read_config_##size (struct pci_dev *dev, int pos, type *value) \ int pci_bus_read_config_##size \
(struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
{ \ { \
int res; \ int res; \
unsigned long flags; \ unsigned long flags; \
u32 data = 0; \ u32 data = 0; \
if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
spin_lock_irqsave(&pci_lock, flags); \ spin_lock_irqsave(&pci_lock, flags); \
res = dev->bus->ops->read(dev, pos, len, &data); \ res = bus->ops->read(bus, devfn, pos, len, &data); \
*value = (type)data; \ *value = (type)data; \
spin_unlock_irqrestore(&pci_lock, flags); \ spin_unlock_irqrestore(&pci_lock, flags); \
return res; \ return res; \
} }
#define PCI_OP_WRITE(size,type,len) \ #define PCI_OP_WRITE(size,type,len) \
int pci_write_config_##size (struct pci_dev *dev, int pos, type value) \ int pci_bus_write_config_##size \
(struct pci_bus *bus, unsigned int devfn, int pos, type value) \
{ \ { \
int res; \ int res; \
unsigned long flags; \ unsigned long flags; \
if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
spin_lock_irqsave(&pci_lock, flags); \ spin_lock_irqsave(&pci_lock, flags); \
res = dev->bus->ops->write(dev, pos, len, value); \ res = bus->ops->write(bus, devfn, pos, len, value); \
spin_unlock_irqrestore(&pci_lock, flags); \ spin_unlock_irqrestore(&pci_lock, flags); \
return res; \ return res; \
} }
...@@ -52,10 +54,10 @@ PCI_OP_WRITE(byte, u8, 1) ...@@ -52,10 +54,10 @@ PCI_OP_WRITE(byte, u8, 1)
PCI_OP_WRITE(word, u16, 2) PCI_OP_WRITE(word, u16, 2)
PCI_OP_WRITE(dword, u32, 4) PCI_OP_WRITE(dword, u32, 4)
EXPORT_SYMBOL(pci_read_config_byte); EXPORT_SYMBOL(pci_bus_read_config_byte);
EXPORT_SYMBOL(pci_read_config_word); EXPORT_SYMBOL(pci_bus_read_config_word);
EXPORT_SYMBOL(pci_read_config_dword); EXPORT_SYMBOL(pci_bus_read_config_dword);
EXPORT_SYMBOL(pci_write_config_byte); EXPORT_SYMBOL(pci_bus_write_config_byte);
EXPORT_SYMBOL(pci_write_config_word); EXPORT_SYMBOL(pci_bus_write_config_word);
EXPORT_SYMBOL(pci_write_config_dword); EXPORT_SYMBOL(pci_bus_write_config_dword);
EXPORT_SYMBOL(pci_lock); EXPORT_SYMBOL(pci_lock);
...@@ -456,8 +456,8 @@ extern struct bus_type pci_bus_type; ...@@ -456,8 +456,8 @@ extern struct bus_type pci_bus_type;
/* Low-level architecture-dependent routines */ /* Low-level architecture-dependent routines */
struct pci_ops { struct pci_ops {
int (*read)(struct pci_dev *, int where, int size, u32 *val); int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
int (*write)(struct pci_dev *, int where, int size, u32 val); int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
}; };
struct pbus_set_ranges_data struct pbus_set_ranges_data
...@@ -556,12 +556,37 @@ struct pci_dev *pci_find_class (unsigned int class, const struct pci_dev *from); ...@@ -556,12 +556,37 @@ 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); 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_capability (struct pci_dev *dev, int cap);
int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val); int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val);
int pci_read_config_word(struct pci_dev *dev, int where, u16 *val); int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val);
int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val); int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val);
int pci_write_config_byte(struct pci_dev *dev, int where, u8 val); int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val);
int pci_write_config_word(struct pci_dev *dev, int where, u16 val); int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val);
int pci_write_config_dword(struct pci_dev *dev, int where, u32 val); int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val);
static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val)
{
return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val);
}
static int inline pci_read_config_word(struct pci_dev *dev, int where, u16 *val)
{
return pci_bus_read_config_word (dev->bus, dev->devfn, where, val);
}
static int inline pci_read_config_dword(struct pci_dev *dev, int where, u32 *val)
{
return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val);
}
static int inline pci_write_config_byte(struct pci_dev *dev, int where, u8 val)
{
return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val);
}
static int inline pci_write_config_word(struct pci_dev *dev, int where, u16 val)
{
return pci_bus_write_config_word (dev->bus, dev->devfn, where, val);
}
static int inline pci_write_config_dword(struct pci_dev *dev, int where, u32 val)
{
return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val);
}
extern spinlock_t pci_lock; extern spinlock_t pci_lock;
......
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