static int prep_write_config(struct pci_bus *bus, unsigned int devfn, int offset, int len, u32 val) { struct pci_controller *hose = bus->sysdata; volatile void __iomem *cfg_data; if (bus->number != 0 || DEVNO(devfn) < MIN_DEVNR || DEVNO(devfn) > MAX_DEVNR) return PCIBIOS_DEVICE_NOT_FOUND; /* * Note: the caller has already checked that offset is * suitably aligned and that len is 1, 2 or 4. */ cfg_data = hose->cfg_data + CFGADDR(devfn) + offset; switch (len) { case 1: out_8(cfg_data, val); break; case 2: out_le16(cfg_data, val); break; default: out_le32(cfg_data, val); break; } return PCIBIOS_SUCCESSFUL; }
__prep int prep_pcibios_write_config_byte (unsigned char bus, unsigned char dev, unsigned char offset, unsigned char val) { unsigned char _val; unsigned char *ptr; _val = val; if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) { return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned char *)CFGPTR(dev); *ptr = _val; } return PCIBIOS_SUCCESSFUL; }
__prep int prep_pcibios_write_config_word (unsigned char bus, unsigned char dev, unsigned char offset, unsigned short val) { unsigned short _val; unsigned short *ptr; _val = le16_to_cpu(val); if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) { return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned short *)CFGPTR(dev); *ptr = _val; } return PCIBIOS_SUCCESSFUL; }
__prep int prep_pcibios_read_config_byte (unsigned char bus, unsigned char dev, unsigned char offset, unsigned char *val) { unsigned char _val; unsigned char *ptr; if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) { *val = 0xFF; return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned char *)CFGPTR(dev); _val = *ptr; } *val = _val; return PCIBIOS_SUCCESSFUL; }
__prep int prep_pcibios_read_config_word (unsigned char bus, unsigned char dev, unsigned char offset, unsigned short *val) { unsigned short _val; unsigned short *ptr; if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) { *val = 0xFFFF; return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned short *)CFGPTR(dev); _val = le16_to_cpu(*ptr); } *val = _val; return PCIBIOS_SUCCESSFUL; }