aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorAlex Chiang <achiang@hp.com>2009-03-31 11:23:41 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-06-11 15:04:11 -0400
commit1d3ecf1376bf22be57c6138e7cdf425c6027b115 (patch)
tree9eb81bb3a16615b0a0c720a5a78eb46f5098885d /drivers/pci/hotplug
parent867556fe740d0d29a05fce99d2d960625077ed45 (diff)
PCI Hotplug: cpqphp: clean up cpqphp_ctrl.c
Style and whitespace cleanups, no functional change. Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c170
1 files changed, 79 insertions, 91 deletions
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index b02b8dddcf9f..2fa47af992a8 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -132,9 +132,8 @@ static struct slot *cpqhp_find_slot(struct controller *ctrl, u8 device)
132{ 132{
133 struct slot *slot = ctrl->slot; 133 struct slot *slot = ctrl->slot;
134 134
135 while (slot && (slot->device != device)) { 135 while (slot && (slot->device != device))
136 slot = slot->next; 136 slot = slot->next;
137 }
138 137
139 return slot; 138 return slot;
140} 139}
@@ -549,10 +548,10 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
549 if (!(*head)) 548 if (!(*head))
550 return NULL; 549 return NULL;
551 550
552 if ( cpqhp_resource_sort_and_combine(head) ) 551 if (cpqhp_resource_sort_and_combine(head))
553 return NULL; 552 return NULL;
554 553
555 if ( sort_by_size(head) ) 554 if (sort_by_size(head))
556 return NULL; 555 return NULL;
557 556
558 for (node = *head; node; node = node->next) { 557 for (node = *head; node; node = node->next) {
@@ -974,12 +973,8 @@ struct pci_func *cpqhp_slot_create(u8 busnumber)
974 struct pci_func *next; 973 struct pci_func *next;
975 974
976 new_slot = kzalloc(sizeof(*new_slot), GFP_KERNEL); 975 new_slot = kzalloc(sizeof(*new_slot), GFP_KERNEL);
977 if (new_slot == NULL) { 976 if (new_slot == NULL)
978 /* I'm not dead yet!
979 * You will be.
980 */
981 return new_slot; 977 return new_slot;
982 }
983 978
984 new_slot->next = NULL; 979 new_slot->next = NULL;
985 new_slot->configured = 1; 980 new_slot->configured = 1;
@@ -1010,10 +1005,8 @@ static int slot_remove(struct pci_func * old_slot)
1010 return 1; 1005 return 1;
1011 1006
1012 next = cpqhp_slot_list[old_slot->bus]; 1007 next = cpqhp_slot_list[old_slot->bus];
1013 1008 if (next == NULL)
1014 if (next == NULL) {
1015 return 1; 1009 return 1;
1016 }
1017 1010
1018 if (next == old_slot) { 1011 if (next == old_slot) {
1019 cpqhp_slot_list[old_slot->bus] = old_slot->next; 1012 cpqhp_slot_list[old_slot->bus] = old_slot->next;
@@ -1022,9 +1015,8 @@ static int slot_remove(struct pci_func * old_slot)
1022 return 0; 1015 return 0;
1023 } 1016 }
1024 1017
1025 while ((next->next != old_slot) && (next->next != NULL)) { 1018 while ((next->next != old_slot) && (next->next != NULL))
1026 next = next->next; 1019 next = next->next;
1027 }
1028 1020
1029 if (next->next == old_slot) { 1021 if (next->next == old_slot) {
1030 next->next = old_slot->next; 1022 next->next = old_slot->next;
@@ -1054,9 +1046,8 @@ static int bridge_slot_remove(struct pci_func *bridge)
1054 for (tempBus = secondaryBus; tempBus <= subordinateBus; tempBus++) { 1046 for (tempBus = secondaryBus; tempBus <= subordinateBus; tempBus++) {
1055 next = cpqhp_slot_list[tempBus]; 1047 next = cpqhp_slot_list[tempBus];
1056 1048
1057 while (!slot_remove(next)) { 1049 while (!slot_remove(next))
1058 next = cpqhp_slot_list[tempBus]; 1050 next = cpqhp_slot_list[tempBus];
1059 }
1060 } 1051 }
1061 1052
1062 next = cpqhp_slot_list[bridge->bus]; 1053 next = cpqhp_slot_list[bridge->bus];
@@ -1286,17 +1277,17 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1286 1277
1287 hp_slot = func->device - ctrl->slot_device_offset; 1278 hp_slot = func->device - ctrl->slot_device_offset;
1288 1279
1289 if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)) { 1280 /*
1290 /* 1281 * The switch is open.
1291 * The switch is open. 1282 */
1292 */ 1283 if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot))
1293 rc = INTERLOCK_OPEN; 1284 rc = INTERLOCK_OPEN;
1294 } else if (is_slot_enabled (ctrl, hp_slot)) { 1285 /*
1295 /* 1286 * The board is already on
1296 * The board is already on 1287 */
1297 */ 1288 else if (is_slot_enabled (ctrl, hp_slot))
1298 rc = CARD_FUNCTIONING; 1289 rc = CARD_FUNCTIONING;
1299 } else { 1290 else {
1300 mutex_lock(&ctrl->crit_sect); 1291 mutex_lock(&ctrl->crit_sect);
1301 1292
1302 /* turn on board without attaching to the bus */ 1293 /* turn on board without attaching to the bus */
@@ -1542,7 +1533,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1542 } 1533 }
1543 1534
1544 /* All F's is an empty slot or an invalid board */ 1535 /* All F's is an empty slot or an invalid board */
1545 if (temp_register != 0xFFFFFFFF) { /* Check for a board in the slot */ 1536 if (temp_register != 0xFFFFFFFF) {
1546 res_lists.io_head = ctrl->io_head; 1537 res_lists.io_head = ctrl->io_head;
1547 res_lists.mem_head = ctrl->mem_head; 1538 res_lists.mem_head = ctrl->mem_head;
1548 res_lists.p_mem_head = ctrl->p_mem_head; 1539 res_lists.p_mem_head = ctrl->p_mem_head;
@@ -1591,9 +1582,8 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1591 index = 0; 1582 index = 0;
1592 do { 1583 do {
1593 new_slot = cpqhp_slot_find(ctrl->bus, func->device, index++); 1584 new_slot = cpqhp_slot_find(ctrl->bus, func->device, index++);
1594 if (new_slot && !new_slot->pci_dev) { 1585 if (new_slot && !new_slot->pci_dev)
1595 cpqhp_configure_device(ctrl, new_slot); 1586 cpqhp_configure_device(ctrl, new_slot);
1596 }
1597 } while (new_slot); 1587 } while (new_slot);
1598 1588
1599 mutex_lock(&ctrl->crit_sect); 1589 mutex_lock(&ctrl->crit_sect);
@@ -2134,9 +2124,8 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
2134 2124
2135 /* If the VGA Enable bit is set, remove isn't 2125 /* If the VGA Enable bit is set, remove isn't
2136 * supported */ 2126 * supported */
2137 if (BCR & PCI_BRIDGE_CTL_VGA) { 2127 if (BCR & PCI_BRIDGE_CTL_VGA)
2138 rc = REMOVE_NOT_SUPPORTED; 2128 rc = REMOVE_NOT_SUPPORTED;
2139 }
2140 } 2129 }
2141 } 2130 }
2142 2131
@@ -2204,67 +2193,67 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
2204 num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0f; 2193 num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0f;
2205 2194
2206 switch (test_num) { 2195 switch (test_num) {
2207 case 1: 2196 case 1:
2208 /* Do stuff here! */ 2197 /* Do stuff here! */
2209 2198
2210 /* Do that funky LED thing */ 2199 /* Do that funky LED thing */
2211 /* so we can restore them later */ 2200 /* so we can restore them later */
2212 save_LED = readl(ctrl->hpc_reg + LED_CONTROL); 2201 save_LED = readl(ctrl->hpc_reg + LED_CONTROL);
2213 work_LED = 0x01010101; 2202 work_LED = 0x01010101;
2214 switch_leds(ctrl, num_of_slots, &work_LED, 0); 2203 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2215 switch_leds(ctrl, num_of_slots, &work_LED, 1); 2204 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2216 switch_leds(ctrl, num_of_slots, &work_LED, 0); 2205 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2217 switch_leds(ctrl, num_of_slots, &work_LED, 1); 2206 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2218 2207
2219 work_LED = 0x01010000; 2208 work_LED = 0x01010000;
2220 writel(work_LED, ctrl->hpc_reg + LED_CONTROL); 2209 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2221 switch_leds(ctrl, num_of_slots, &work_LED, 0); 2210 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2222 switch_leds(ctrl, num_of_slots, &work_LED, 1); 2211 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2223 work_LED = 0x00000101; 2212 work_LED = 0x00000101;
2224 writel(work_LED, ctrl->hpc_reg + LED_CONTROL); 2213 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2225 switch_leds(ctrl, num_of_slots, &work_LED, 0); 2214 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2226 switch_leds(ctrl, num_of_slots, &work_LED, 1); 2215 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2227 2216
2228 work_LED = 0x01010000; 2217 work_LED = 0x01010000;
2229 writel(work_LED, ctrl->hpc_reg + LED_CONTROL); 2218 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2230 for (loop = 0; loop < num_of_slots; loop++) { 2219 for (loop = 0; loop < num_of_slots; loop++) {
2231 set_SOGO(ctrl); 2220 set_SOGO(ctrl);
2232 2221
2233 /* Wait for SOGO interrupt */ 2222 /* Wait for SOGO interrupt */
2234 wait_for_ctrl_irq (ctrl); 2223 wait_for_ctrl_irq (ctrl);
2235 2224
2236 /* Get ready for next iteration */ 2225 /* Get ready for next iteration */
2237 long_delay((3*HZ)/10); 2226 long_delay((3*HZ)/10);
2238 work_LED = work_LED >> 16; 2227 work_LED = work_LED >> 16;
2239 writel(work_LED, ctrl->hpc_reg + LED_CONTROL); 2228 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2240 2229
2241 set_SOGO(ctrl); 2230 set_SOGO(ctrl);
2242 2231
2243 /* Wait for SOGO interrupt */ 2232 /* Wait for SOGO interrupt */
2244 wait_for_ctrl_irq (ctrl); 2233 wait_for_ctrl_irq (ctrl);
2245 2234
2246 /* Get ready for next iteration */ 2235 /* Get ready for next iteration */
2247 long_delay((3*HZ)/10); 2236 long_delay((3*HZ)/10);
2248 work_LED = work_LED << 16; 2237 work_LED = work_LED << 16;
2249 writel(work_LED, ctrl->hpc_reg + LED_CONTROL); 2238 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2250 work_LED = work_LED << 1; 2239 work_LED = work_LED << 1;
2251 writel(work_LED, ctrl->hpc_reg + LED_CONTROL); 2240 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2252 } 2241 }
2253 2242
2254 /* put it back the way it was */ 2243 /* put it back the way it was */
2255 writel(save_LED, ctrl->hpc_reg + LED_CONTROL); 2244 writel(save_LED, ctrl->hpc_reg + LED_CONTROL);
2256 2245
2257 set_SOGO(ctrl); 2246 set_SOGO(ctrl);
2258 2247
2259 /* Wait for SOBS to be unset */ 2248 /* Wait for SOBS to be unset */
2260 wait_for_ctrl_irq (ctrl); 2249 wait_for_ctrl_irq (ctrl);
2261 break; 2250 break;
2262 case 2: 2251 case 2:
2263 /* Do other stuff here! */ 2252 /* Do other stuff here! */
2264 break; 2253 break;
2265 case 3: 2254 case 3:
2266 /* and more... */ 2255 /* and more... */
2267 break; 2256 break;
2268 } 2257 }
2269 return 0; 2258 return 0;
2270} 2259}
@@ -2333,9 +2322,9 @@ static u32 configure_new_device(struct controller * ctrl, struct pci_func * func
2333 while ((function < max_functions) && (!stop_it)) { 2322 while ((function < max_functions) && (!stop_it)) {
2334 pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID); 2323 pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID);
2335 2324
2336 if (ID == 0xFFFFFFFF) { /* There's nothing there. */ 2325 if (ID == 0xFFFFFFFF) {
2337 function++; 2326 function++;
2338 } else { /* There's something there */ 2327 } else {
2339 /* Setup slot structure. */ 2328 /* Setup slot structure. */
2340 new_slot = cpqhp_slot_create(func->bus); 2329 new_slot = cpqhp_slot_create(func->bus);
2341 2330
@@ -2360,8 +2349,8 @@ static u32 configure_new_device(struct controller * ctrl, struct pci_func * func
2360 2349
2361 2350
2362/* 2351/*
2363 Configuration logic that involves the hotplug data structures and 2352 * Configuration logic that involves the hotplug data structures and
2364 their bookkeeping 2353 * their bookkeeping
2365 */ 2354 */
2366 2355
2367 2356
@@ -2414,7 +2403,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2414 if (rc) 2403 if (rc)
2415 return rc; 2404 return rc;
2416 2405
2417 if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */ 2406 if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
2418 /* set Primary bus */ 2407 /* set Primary bus */
2419 dbg("set Primary bus = %d\n", func->bus); 2408 dbg("set Primary bus = %d\n", func->bus);
2420 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus); 2409 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus);
@@ -2956,11 +2945,10 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2956 /* Program IRQ based on card type */ 2945 /* Program IRQ based on card type */
2957 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2946 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
2958 2947
2959 if (class_code == PCI_BASE_CLASS_STORAGE) { 2948 if (class_code == PCI_BASE_CLASS_STORAGE)
2960 IRQ = cpqhp_disk_irq; 2949 IRQ = cpqhp_disk_irq;
2961 } else { 2950 else
2962 IRQ = cpqhp_nic_irq; 2951 IRQ = cpqhp_nic_irq;
2963 }
2964 } 2952 }
2965 2953
2966 /* IRQ Line */ 2954 /* IRQ Line */