X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fpci%2Fhotplug%2Fcpqphp_pci.c;h=00b81a7bdd266a9513a6c39506236bb52c1c3622;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=72bb256aa8e2331cb8c00c23d8f09f32fccf7651;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c index 72bb256aa..00b81a7bd 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c @@ -51,10 +51,10 @@ static u16 unused_IRQ; * find the Hot Plug Resource Table in the specified region of memory. * */ -static void *detect_HRT_floating_pointer(void *begin, void *end) +static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iomem *end) { - void *fp; - void *endp; + void __iomem *fp; + void __iomem *endp; u8 temp1, temp2, temp3, temp4; int status = 0; @@ -151,18 +151,29 @@ static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 o */ int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num) { - int rc; - u16 temp_word; - struct pci_dev fakedev; - struct pci_bus fakebus; + int rc = 0; if (cpqhp_legacy_mode) { - fakedev.devfn = dev_num << 3; - fakedev.bus = &fakebus; - fakebus.number = bus_num; + struct pci_dev *fakedev; + struct pci_bus *fakebus; + u16 temp_word; + + fakedev = kmalloc(sizeof(*fakedev), GFP_KERNEL); + fakebus = kmalloc(sizeof(*fakebus), GFP_KERNEL); + if (!fakedev || !fakebus) { + kfree(fakedev); + kfree(fakebus); + return -ENOMEM; + } + + fakedev->devfn = dev_num << 3; + fakedev->bus = fakebus; + fakebus->number = bus_num; dbg("%s: dev %d, bus %d, pin %d, num %d\n", __FUNCTION__, dev_num, bus_num, int_pin, irq_num); - rc = pcibios_set_irq_routing(&fakedev, int_pin - 0x0a, irq_num); + rc = pcibios_set_irq_routing(fakedev, int_pin - 0x0a, irq_num); + kfree(fakedev); + kfree(fakebus); dbg("%s: rc %d\n", __FUNCTION__, rc); if (!rc) return !rc; @@ -176,9 +187,10 @@ int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num) // This should only be for x86 as it sets the Edge Level Control Register outb((u8) (temp_word & 0xFF), 0x4d0); outb((u8) ((temp_word & 0xFF00) >> 8), 0x4d1); + rc = 0; } - return 0; + return rc; } @@ -194,7 +206,7 @@ static int PCI_ScanBusNonBridge (u8 bus, u8 device) static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * dev_num) { - u8 tdevice; + u16 tdevice; u32 work; u8 tbus; @@ -247,8 +259,7 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num sizeof(struct irq_routing_table)) / sizeof(struct irq_info); // Make sure I got at least one entry if (len == 0) { - if (PCIIRQRoutingInfoLength != NULL) - kfree(PCIIRQRoutingInfoLength ); + kfree(PCIIRQRoutingInfoLength ); return -1; } @@ -263,8 +274,7 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num ctrl->pci_bus->number = tbus; pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work); if (!nobridge || (work == 0xffffffff)) { - if (PCIIRQRoutingInfoLength != NULL) - kfree(PCIIRQRoutingInfoLength ); + kfree(PCIIRQRoutingInfoLength ); return 0; } @@ -277,20 +287,17 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num dbg("Scan bus for Non Bridge: bus %d\n", tbus); if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) { *bus_num = tbus; - if (PCIIRQRoutingInfoLength != NULL) - kfree(PCIIRQRoutingInfoLength ); + kfree(PCIIRQRoutingInfoLength ); return 0; } } else { - if (PCIIRQRoutingInfoLength != NULL) - kfree(PCIIRQRoutingInfoLength ); + kfree(PCIIRQRoutingInfoLength ); return 0; } } } - if (PCIIRQRoutingInfoLength != NULL) - kfree(PCIIRQRoutingInfoLength ); + kfree(PCIIRQRoutingInfoLength ); return -1; } @@ -722,23 +729,23 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) devfn = PCI_DEVFN(func->device, func->function); // Save the command register - pci_bus_read_config_word (pci_bus, devfn, PCI_COMMAND, &save_command); + pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &save_command); // disable card command = 0x00; - pci_bus_write_config_word (pci_bus, devfn, PCI_COMMAND, command); + pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command); // Check for Bridge - pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); + pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type); if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { // PCI-PCI Bridge // Clear Bridge Control Register command = 0x00; - pci_bus_write_config_word (pci_bus, devfn, PCI_BRIDGE_CONTROL, command); - pci_bus_read_config_byte (pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus); - pci_bus_read_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, &temp_byte); + pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command); + pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus); + pci_bus_read_config_byte(pci_bus, devfn, PCI_SUBORDINATE_BUS, &temp_byte); - bus_node =(struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + bus_node = kmalloc(sizeof(*bus_node), GFP_KERNEL); if (!bus_node) return -ENOMEM; @@ -749,11 +756,11 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) func->bus_head = bus_node; // Save IO base and Limit registers - pci_bus_read_config_byte (pci_bus, devfn, PCI_IO_BASE, &b_base); - pci_bus_read_config_byte (pci_bus, devfn, PCI_IO_LIMIT, &b_length); + pci_bus_read_config_byte(pci_bus, devfn, PCI_IO_BASE, &b_base); + pci_bus_read_config_byte(pci_bus, devfn, PCI_IO_LIMIT, &b_length); if ((b_base <= b_length) && (save_command & 0x01)) { - io_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + io_node = kmalloc(sizeof(*io_node), GFP_KERNEL); if (!io_node) return -ENOMEM; @@ -765,11 +772,11 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) } // Save memory base and Limit registers - pci_bus_read_config_word (pci_bus, devfn, PCI_MEMORY_BASE, &w_base); - pci_bus_read_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, &w_length); + pci_bus_read_config_word(pci_bus, devfn, PCI_MEMORY_BASE, &w_base); + pci_bus_read_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, &w_length); if ((w_base <= w_length) && (save_command & 0x02)) { - mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + mem_node = kmalloc(sizeof(*mem_node), GFP_KERNEL); if (!mem_node) return -ENOMEM; @@ -781,11 +788,11 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) } // Save prefetchable memory base and Limit registers - pci_bus_read_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, &w_base); - pci_bus_read_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &w_length); + pci_bus_read_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, &w_base); + pci_bus_read_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &w_length); if ((w_base <= w_length) && (save_command & 0x02)) { - p_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + p_mem_node = kmalloc(sizeof(*p_mem_node), GFP_KERNEL); if (!p_mem_node) return -ENOMEM; @@ -800,8 +807,8 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) pci_bus_read_config_dword (pci_bus, devfn, cloop, &save_base); temp_register = 0xFFFFFFFF; - pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); - pci_bus_read_config_dword (pci_bus, devfn, cloop, &base); + pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register); + pci_bus_read_config_dword(pci_bus, devfn, cloop, &base); temp_register = base; @@ -813,7 +820,8 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) temp_register = base & 0xFFFFFFFE; temp_register = (~temp_register) + 1; - io_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + io_node = kmalloc(sizeof(*io_node), + GFP_KERNEL); if (!io_node) return -ENOMEM; @@ -830,7 +838,8 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) temp_register = base & 0xFFFFFFF0; temp_register = (~temp_register) + 1; - p_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + p_mem_node = kmalloc(sizeof(*p_mem_node), + GFP_KERNEL); if (!p_mem_node) return -ENOMEM; @@ -846,7 +855,8 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) temp_register = base & 0xFFFFFFF0; temp_register = (~temp_register) + 1; - mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + mem_node = kmalloc(sizeof(*mem_node), + GFP_KERNEL); if (!mem_node) return -ENOMEM; @@ -862,11 +872,11 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) } else if ((header_type & 0x7F) == 0x00) { // Standard header // Figure out IO and memory base lengths for (cloop = 0x10; cloop <= 0x24; cloop += 4) { - pci_bus_read_config_dword (pci_bus, devfn, cloop, &save_base); + pci_bus_read_config_dword(pci_bus, devfn, cloop, &save_base); temp_register = 0xFFFFFFFF; - pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); - pci_bus_read_config_dword (pci_bus, devfn, cloop, &base); + pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register); + pci_bus_read_config_dword(pci_bus, devfn, cloop, &base); temp_register = base; @@ -878,7 +888,8 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) temp_register = base & 0xFFFFFFFE; temp_register = (~temp_register) + 1; - io_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + io_node = kmalloc(sizeof(*io_node), + GFP_KERNEL); if (!io_node) return -ENOMEM; @@ -894,7 +905,8 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) temp_register = base & 0xFFFFFFF0; temp_register = (~temp_register) + 1; - p_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + p_mem_node = kmalloc(sizeof(*p_mem_node), + GFP_KERNEL); if (!p_mem_node) return -ENOMEM; @@ -910,7 +922,8 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func) temp_register = base & 0xFFFFFFF0; temp_register = (~temp_register) + 1; - mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + mem_node = kmalloc(sizeof(*mem_node), + GFP_KERNEL); if (!mem_node) return -ENOMEM; @@ -1156,12 +1169,13 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func * func) * * returns 0 if success */ -int cpqhp_find_available_resources (struct controller *ctrl, void *rom_start) +int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_start) { u8 temp; u8 populated_slot; u8 bridged_slot; - void *one_slot; + void __iomem *one_slot; + void __iomem *rom_resource_table; struct pci_func *func = NULL; int i = 10, index; u32 temp_dword, rc; @@ -1169,7 +1183,6 @@ int cpqhp_find_available_resources (struct controller *ctrl, void *rom_start) struct pci_resource *p_mem_node; struct pci_resource *io_node; struct pci_resource *bus_node; - void *rom_resource_table; rom_resource_table = detect_HRT_floating_pointer(rom_start, rom_start+0xffff); dbg("rom_resource_table = %p\n", rom_resource_table); @@ -1293,14 +1306,15 @@ int cpqhp_find_available_resources (struct controller *ctrl, void *rom_start) temp_dword = io_base + io_length; if ((io_base) && (temp_dword < 0x10000)) { - io_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + io_node = kmalloc(sizeof(*io_node), GFP_KERNEL); if (!io_node) return -ENOMEM; io_node->base = io_base; io_node->length = io_length; - dbg("found io_node(base, length) = %x, %x\n", io_node->base, io_node->length); + dbg("found io_node(base, length) = %x, %x\n", + io_node->base, io_node->length); dbg("populated slot =%d \n", populated_slot); if (!populated_slot) { io_node->next = ctrl->io_head; @@ -1314,7 +1328,7 @@ int cpqhp_find_available_resources (struct controller *ctrl, void *rom_start) // If we've got a valid memory base, use it temp_dword = mem_base + mem_length; if ((mem_base) && (temp_dword < 0x10000)) { - mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + mem_node = kmalloc(sizeof(*mem_node), GFP_KERNEL); if (!mem_node) return -ENOMEM; @@ -1322,7 +1336,8 @@ int cpqhp_find_available_resources (struct controller *ctrl, void *rom_start) mem_node->length = mem_length << 16; - dbg("found mem_node(base, length) = %x, %x\n", mem_node->base, mem_node->length); + dbg("found mem_node(base, length) = %x, %x\n", + mem_node->base, mem_node->length); dbg("populated slot =%d \n", populated_slot); if (!populated_slot) { mem_node->next = ctrl->mem_head; @@ -1337,14 +1352,15 @@ int cpqhp_find_available_resources (struct controller *ctrl, void *rom_start) // the base + length isn't greater than 0xFFFF temp_dword = pre_mem_base + pre_mem_length; if ((pre_mem_base) && (temp_dword < 0x10000)) { - p_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + p_mem_node = kmalloc(sizeof(*p_mem_node), GFP_KERNEL); if (!p_mem_node) return -ENOMEM; p_mem_node->base = pre_mem_base << 16; p_mem_node->length = pre_mem_length << 16; - dbg("found p_mem_node(base, length) = %x, %x\n", p_mem_node->base, p_mem_node->length); + dbg("found p_mem_node(base, length) = %x, %x\n", + p_mem_node->base, p_mem_node->length); dbg("populated slot =%d \n", populated_slot); if (!populated_slot) { @@ -1360,13 +1376,14 @@ int cpqhp_find_available_resources (struct controller *ctrl, void *rom_start) // The second condition is to ignore bus numbers on // populated slots that don't have PCI-PCI bridges if (secondary_bus && (secondary_bus != primary_bus)) { - bus_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + bus_node = kmalloc(sizeof(*bus_node), GFP_KERNEL); if (!bus_node) return -ENOMEM; bus_node->base = secondary_bus; bus_node->length = max_bus - secondary_bus + 1; - dbg("found bus_node(base, length) = %x, %x\n", bus_node->base, bus_node->length); + dbg("found bus_node(base, length) = %x, %x\n", + bus_node->base, bus_node->length); dbg("populated slot =%d \n", populated_slot); if (!populated_slot) { bus_node->next = ctrl->bus_head;