/*
* $Id: compat.c,v 1.1 1998/02/16 10:35:50 mj Exp $
*
* PCI Bus Services -- Function For Backward Compatibility
*
* Copyright 1998--2000 Martin Mares <mj@suse.cz>
*/
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/pci.h>
int
14 pcibios_present(void)
{
16 return !list_empty(&pci_devices);
}
int
20 pcibios_find_class(unsigned int class, unsigned short index, unsigned char *bus, unsigned char *devfn)
{
const struct pci_dev *dev = NULL;
int cnt = 0;
25 while ((dev = pci_find_class(class, dev)))
26 if (index == cnt++) {
*bus = dev->bus->number;
*devfn = dev->devfn;
29 return PCIBIOS_SUCCESSFUL;
}
31 return PCIBIOS_DEVICE_NOT_FOUND;
}
int
36 pcibios_find_device(unsigned short vendor, unsigned short device, unsigned short index,
unsigned char *bus, unsigned char *devfn)
{
const struct pci_dev *dev = NULL;
int cnt = 0;
42 while ((dev = pci_find_device(vendor, device, dev)))
43 if (index == cnt++) {
*bus = dev->bus->number;
*devfn = dev->devfn;
46 return PCIBIOS_SUCCESSFUL;
}
48 return PCIBIOS_DEVICE_NOT_FOUND;
}
#define PCI_OP(rw,size,type) \
int pcibios_##rw##_config_##size (unsigned char bus, unsigned char dev_fn, \
unsigned char where, unsigned type val) \
{ \
struct pci_dev *dev = pci_find_slot(bus, dev_fn); \
if (!dev) return PCIBIOS_DEVICE_NOT_FOUND; \
return pci_##rw##_config_##size(dev, where, val); \
}
60 PCI_OP(read, byte, char *)
61 PCI_OP(read, word, short *)
62 PCI_OP(read, dword, int *)
63 PCI_OP(write, byte, char)
64 PCI_OP(write, word, short)
65 PCI_OP(write, dword, int)