aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/cpqphp_ctrl.c
diff options
context:
space:
mode:
authorAlex Chiang <achiang@hp.com>2009-03-31 11:23:16 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-06-11 15:04:08 -0400
commit427438c61b0083a60bb953cb36cfdc5841f0bb03 (patch)
tree4583b0f23eed091006324bc1f3f61ed7fcd8a7ac /drivers/pci/hotplug/cpqphp_ctrl.c
parent861fefbf550d41e7a4f44584f3ec35977fa08bf1 (diff)
PCI Hotplug: cpqphp: fix comment style
Fix up comments from C++ to C-style, wrapping if necessary, etc. Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/hotplug/cpqphp_ctrl.c')
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c131
1 files changed, 77 insertions, 54 deletions
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index ec3a76519af2..b02b8dddcf9f 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -81,14 +81,15 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl)
81 81
82 for (hp_slot = 0; hp_slot < 6; hp_slot++) { 82 for (hp_slot = 0; hp_slot < 6; hp_slot++) {
83 if (change & (0x1L << hp_slot)) { 83 if (change & (0x1L << hp_slot)) {
84 /********************************** 84 /*
85 * this one changed. 85 * this one changed.
86 **********************************/ 86 */
87 func = cpqhp_slot_find(ctrl->bus, 87 func = cpqhp_slot_find(ctrl->bus,
88 (hp_slot + ctrl->slot_device_offset), 0); 88 (hp_slot + ctrl->slot_device_offset), 0);
89 89
90 /* this is the structure that tells the worker thread 90 /* this is the structure that tells the worker thread
91 *what to do */ 91 * what to do
92 */
92 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 93 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
93 ctrl->next_event = (ctrl->next_event + 1) % 10; 94 ctrl->next_event = (ctrl->next_event + 1) % 10;
94 taskInfo->hp_slot = hp_slot; 95 taskInfo->hp_slot = hp_slot;
@@ -100,17 +101,17 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl)
100 func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02; 101 func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
101 102
102 if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) { 103 if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
103 /********************************** 104 /*
104 * Switch opened 105 * Switch opened
105 **********************************/ 106 */
106 107
107 func->switch_save = 0; 108 func->switch_save = 0;
108 109
109 taskInfo->event_type = INT_SWITCH_OPEN; 110 taskInfo->event_type = INT_SWITCH_OPEN;
110 } else { 111 } else {
111 /********************************** 112 /*
112 * Switch closed 113 * Switch closed
113 **********************************/ 114 */
114 115
115 func->switch_save = 0x10; 116 func->switch_save = 0x10;
116 117
@@ -152,17 +153,17 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
152 if (!change) 153 if (!change)
153 return 0; 154 return 0;
154 155
155 /********************************** 156 /*
156 * Presence Change 157 * Presence Change
157 **********************************/ 158 */
158 dbg("cpqsbd: Presence/Notify input change.\n"); 159 dbg("cpqsbd: Presence/Notify input change.\n");
159 dbg(" Changed bits are 0x%4.4x\n", change ); 160 dbg(" Changed bits are 0x%4.4x\n", change );
160 161
161 for (hp_slot = 0; hp_slot < 6; hp_slot++) { 162 for (hp_slot = 0; hp_slot < 6; hp_slot++) {
162 if (change & (0x0101 << hp_slot)) { 163 if (change & (0x0101 << hp_slot)) {
163 /********************************** 164 /*
164 * this one changed. 165 * this one changed.
165 **********************************/ 166 */
166 func = cpqhp_slot_find(ctrl->bus, 167 func = cpqhp_slot_find(ctrl->bus,
167 (hp_slot + ctrl->slot_device_offset), 0); 168 (hp_slot + ctrl->slot_device_offset), 0);
168 169
@@ -177,22 +178,23 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
177 return 0; 178 return 0;
178 179
179 /* If the switch closed, must be a button 180 /* If the switch closed, must be a button
180 * If not in button mode, nevermind */ 181 * If not in button mode, nevermind
182 */
181 if (func->switch_save && (ctrl->push_button == 1)) { 183 if (func->switch_save && (ctrl->push_button == 1)) {
182 temp_word = ctrl->ctrl_int_comp >> 16; 184 temp_word = ctrl->ctrl_int_comp >> 16;
183 temp_byte = (temp_word >> hp_slot) & 0x01; 185 temp_byte = (temp_word >> hp_slot) & 0x01;
184 temp_byte |= (temp_word >> (hp_slot + 7)) & 0x02; 186 temp_byte |= (temp_word >> (hp_slot + 7)) & 0x02;
185 187
186 if (temp_byte != func->presence_save) { 188 if (temp_byte != func->presence_save) {
187 /************************************** 189 /*
188 * button Pressed (doesn't do anything) 190 * button Pressed (doesn't do anything)
189 **************************************/ 191 */
190 dbg("hp_slot %d button pressed\n", hp_slot); 192 dbg("hp_slot %d button pressed\n", hp_slot);
191 taskInfo->event_type = INT_BUTTON_PRESS; 193 taskInfo->event_type = INT_BUTTON_PRESS;
192 } else { 194 } else {
193 /********************************** 195 /*
194 * button Released - TAKE ACTION!!!! 196 * button Released - TAKE ACTION!!!!
195 **********************************/ 197 */
196 dbg("hp_slot %d button released\n", hp_slot); 198 dbg("hp_slot %d button released\n", hp_slot);
197 taskInfo->event_type = INT_BUTTON_RELEASE; 199 taskInfo->event_type = INT_BUTTON_RELEASE;
198 200
@@ -210,7 +212,8 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
210 } 212 }
211 } else { 213 } else {
212 /* Switch is open, assume a presence change 214 /* Switch is open, assume a presence change
213 * Save the presence state */ 215 * Save the presence state
216 */
214 temp_word = ctrl->ctrl_int_comp >> 16; 217 temp_word = ctrl->ctrl_int_comp >> 16;
215 func->presence_save = (temp_word >> hp_slot) & 0x01; 218 func->presence_save = (temp_word >> hp_slot) & 0x01;
216 func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02; 219 func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
@@ -241,17 +244,17 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl)
241 if (!change) 244 if (!change)
242 return 0; 245 return 0;
243 246
244 /********************************** 247 /*
245 * power fault 248 * power fault
246 **********************************/ 249 */
247 250
248 info("power fault interrupt\n"); 251 info("power fault interrupt\n");
249 252
250 for (hp_slot = 0; hp_slot < 6; hp_slot++) { 253 for (hp_slot = 0; hp_slot < 6; hp_slot++) {
251 if (change & (0x01 << hp_slot)) { 254 if (change & (0x01 << hp_slot)) {
252 /********************************** 255 /*
253 * this one changed. 256 * this one changed.
254 **********************************/ 257 */
255 func = cpqhp_slot_find(ctrl->bus, 258 func = cpqhp_slot_find(ctrl->bus,
256 (hp_slot + ctrl->slot_device_offset), 0); 259 (hp_slot + ctrl->slot_device_offset), 0);
257 260
@@ -262,16 +265,16 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl)
262 rc++; 265 rc++;
263 266
264 if (ctrl->ctrl_int_comp & (0x00000100 << hp_slot)) { 267 if (ctrl->ctrl_int_comp & (0x00000100 << hp_slot)) {
265 /********************************** 268 /*
266 * power fault Cleared 269 * power fault Cleared
267 **********************************/ 270 */
268 func->status = 0x00; 271 func->status = 0x00;
269 272
270 taskInfo->event_type = INT_POWER_FAULT_CLEAR; 273 taskInfo->event_type = INT_POWER_FAULT_CLEAR;
271 } else { 274 } else {
272 /********************************** 275 /*
273 * power fault 276 * power fault
274 **********************************/ 277 */
275 taskInfo->event_type = INT_POWER_FAULT; 278 taskInfo->event_type = INT_POWER_FAULT;
276 279
277 if (ctrl->rev < 4) { 280 if (ctrl->rev < 4) {
@@ -432,13 +435,15 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h
432 435
433 436
434 /* If we got here, there the bridge requires some of the resource, but 437 /* If we got here, there the bridge requires some of the resource, but
435 * we may be able to split some off of the front */ 438 * we may be able to split some off of the front
439 */
436 440
437 node = *head; 441 node = *head;
438 442
439 if (node->length & (alignment -1)) { 443 if (node->length & (alignment -1)) {
440 /* this one isn't an aligned length, so we'll make a new entry 444 /* this one isn't an aligned length, so we'll make a new entry
441 * and split it up. */ 445 * and split it up.
446 */
442 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); 447 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
443 448
444 if (!split_node) 449 if (!split_node)
@@ -556,7 +561,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
556 561
557 if (node->base & (size - 1)) { 562 if (node->base & (size - 1)) {
558 /* this one isn't base aligned properly 563 /* this one isn't base aligned properly
559 * so we'll make a new entry and split it up */ 564 * so we'll make a new entry and split it up
565 */
560 temp_dword = (node->base | (size-1)) + 1; 566 temp_dword = (node->base | (size-1)) + 1;
561 567
562 /* Short circuit if adjusted size is too small */ 568 /* Short circuit if adjusted size is too small */
@@ -581,7 +587,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
581 /* Don't need to check if too small since we already did */ 587 /* Don't need to check if too small since we already did */
582 if (node->length > size) { 588 if (node->length > size) {
583 /* this one is longer than we need 589 /* this one is longer than we need
584 * so we'll make a new entry and split it up */ 590 * so we'll make a new entry and split it up
591 */
585 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); 592 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
586 593
587 if (!split_node) 594 if (!split_node)
@@ -601,7 +608,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
601 continue; 608 continue;
602 609
603 /* If we got here, then it is the right size 610 /* If we got here, then it is the right size
604 * Now take it out of the list and break */ 611 * Now take it out of the list and break
612 */
605 if (*head == node) { 613 if (*head == node) {
606 *head = node->next; 614 *head = node->next;
607 } else { 615 } else {
@@ -643,13 +651,15 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
643 651
644 for (max = *head; max; max = max->next) { 652 for (max = *head; max; max = max->next) {
645 /* If not big enough we could probably just bail, 653 /* If not big enough we could probably just bail,
646 * instead we'll continue to the next. */ 654 * instead we'll continue to the next.
655 */
647 if (max->length < size) 656 if (max->length < size)
648 continue; 657 continue;
649 658
650 if (max->base & (size - 1)) { 659 if (max->base & (size - 1)) {
651 /* this one isn't base aligned properly 660 /* this one isn't base aligned properly
652 * so we'll make a new entry and split it up */ 661 * so we'll make a new entry and split it up
662 */
653 temp_dword = (max->base | (size-1)) + 1; 663 temp_dword = (max->base | (size-1)) + 1;
654 664
655 /* Short circuit if adjusted size is too small */ 665 /* Short circuit if adjusted size is too small */
@@ -672,7 +682,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
672 682
673 if ((max->base + max->length) & (size - 1)) { 683 if ((max->base + max->length) & (size - 1)) {
674 /* this one isn't end aligned properly at the top 684 /* this one isn't end aligned properly at the top
675 * so we'll make a new entry and split it up */ 685 * so we'll make a new entry and split it up
686 */
676 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); 687 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
677 688
678 if (!split_node) 689 if (!split_node)
@@ -744,7 +755,8 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
744 if (node->base & (size - 1)) { 755 if (node->base & (size - 1)) {
745 dbg("%s: not aligned\n", __func__); 756 dbg("%s: not aligned\n", __func__);
746 /* this one isn't base aligned properly 757 /* this one isn't base aligned properly
747 * so we'll make a new entry and split it up */ 758 * so we'll make a new entry and split it up
759 */
748 temp_dword = (node->base | (size-1)) + 1; 760 temp_dword = (node->base | (size-1)) + 1;
749 761
750 /* Short circuit if adjusted size is too small */ 762 /* Short circuit if adjusted size is too small */
@@ -769,7 +781,8 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
769 if (node->length > size) { 781 if (node->length > size) {
770 dbg("%s: too big\n", __func__); 782 dbg("%s: too big\n", __func__);
771 /* this one is longer than we need 783 /* this one is longer than we need
772 * so we'll make a new entry and split it up */ 784 * so we'll make a new entry and split it up
785 */
773 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); 786 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
774 787
775 if (!split_node) 788 if (!split_node)
@@ -888,17 +901,17 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data)
888 901
889 902
890 misc = readw(ctrl->hpc_reg + MISC); 903 misc = readw(ctrl->hpc_reg + MISC);
891 /*************************************** 904 /*
892 * Check to see if it was our interrupt 905 * Check to see if it was our interrupt
893 ***************************************/ 906 */
894 if (!(misc & 0x000C)) { 907 if (!(misc & 0x000C)) {
895 return IRQ_NONE; 908 return IRQ_NONE;
896 } 909 }
897 910
898 if (misc & 0x0004) { 911 if (misc & 0x0004) {
899 /********************************** 912 /*
900 * Serial Output interrupt Pending 913 * Serial Output interrupt Pending
901 **********************************/ 914 */
902 915
903 /* Clear the interrupt */ 916 /* Clear the interrupt */
904 misc |= 0x0004; 917 misc |= 0x0004;
@@ -963,7 +976,8 @@ struct pci_func *cpqhp_slot_create(u8 busnumber)
963 new_slot = kzalloc(sizeof(*new_slot), GFP_KERNEL); 976 new_slot = kzalloc(sizeof(*new_slot), GFP_KERNEL);
964 if (new_slot == NULL) { 977 if (new_slot == NULL) {
965 /* I'm not dead yet! 978 /* I'm not dead yet!
966 * You will be. */ 979 * You will be.
980 */
967 return new_slot; 981 return new_slot;
968 } 982 }
969 983
@@ -1135,7 +1149,8 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
1135 return 0; 1149 return 0;
1136 1150
1137 /* We don't allow freq/mode changes if we find another adapter running 1151 /* We don't allow freq/mode changes if we find another adapter running
1138 * in another slot on this controller */ 1152 * in another slot on this controller
1153 */
1139 for(slot = ctrl->slot; slot; slot = slot->next) { 1154 for(slot = ctrl->slot; slot; slot = slot->next) {
1140 if (slot->device == (hp_slot + ctrl->slot_device_offset)) 1155 if (slot->device == (hp_slot + ctrl->slot_device_offset))
1141 continue; 1156 continue;
@@ -1145,7 +1160,8 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
1145 continue; 1160 continue;
1146 /* If another adapter is running on the same segment but at a 1161 /* If another adapter is running on the same segment but at a
1147 * lower speed/mode, we allow the new adapter to function at 1162 * lower speed/mode, we allow the new adapter to function at
1148 * this rate if supported */ 1163 * this rate if supported
1164 */
1149 if (ctrl->speed < adapter_speed) 1165 if (ctrl->speed < adapter_speed)
1150 return 0; 1166 return 0;
1151 1167
@@ -1153,7 +1169,8 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
1153 } 1169 }
1154 1170
1155 /* If the controller doesn't support freq/mode changes and the 1171 /* If the controller doesn't support freq/mode changes and the
1156 * controller is running at a higher mode, we bail */ 1172 * controller is running at a higher mode, we bail
1173 */
1157 if ((ctrl->speed > adapter_speed) && (!ctrl->pcix_speed_capability)) 1174 if ((ctrl->speed > adapter_speed) && (!ctrl->pcix_speed_capability))
1158 return 1; 1175 return 1;
1159 1176
@@ -1162,7 +1179,8 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
1162 return 0; 1179 return 0;
1163 1180
1164 /* We try to set the max speed supported by both the adapter and 1181 /* We try to set the max speed supported by both the adapter and
1165 * controller */ 1182 * controller
1183 */
1166 if (ctrl->speed_capability < adapter_speed) { 1184 if (ctrl->speed_capability < adapter_speed) {
1167 if (ctrl->speed == ctrl->speed_capability) 1185 if (ctrl->speed == ctrl->speed_capability)
1168 return 0; 1186 return 0;
@@ -1244,7 +1262,7 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
1244} 1262}
1245 1263
1246/* the following routines constitute the bulk of the 1264/* the following routines constitute the bulk of the
1247 hotplug controller logic 1265 * hotplug controller logic
1248 */ 1266 */
1249 1267
1250 1268
@@ -1269,14 +1287,14 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1269 hp_slot = func->device - ctrl->slot_device_offset; 1287 hp_slot = func->device - ctrl->slot_device_offset;
1270 1288
1271 if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)) { 1289 if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)) {
1272 /********************************** 1290 /*
1273 * The switch is open. 1291 * The switch is open.
1274 **********************************/ 1292 */
1275 rc = INTERLOCK_OPEN; 1293 rc = INTERLOCK_OPEN;
1276 } else if (is_slot_enabled (ctrl, hp_slot)) { 1294 } else if (is_slot_enabled (ctrl, hp_slot)) {
1277 /********************************** 1295 /*
1278 * The board is already on 1296 * The board is already on
1279 **********************************/ 1297 */
1280 rc = CARD_FUNCTIONING; 1298 rc = CARD_FUNCTIONING;
1281 } else { 1299 } else {
1282 mutex_lock(&ctrl->crit_sect); 1300 mutex_lock(&ctrl->crit_sect);
@@ -1352,7 +1370,8 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1352 * Get slot won't work for devices behind 1370 * Get slot won't work for devices behind
1353 * bridges, but in this case it will always be 1371 * bridges, but in this case it will always be
1354 * called for the "base" bus/dev/func of an 1372 * called for the "base" bus/dev/func of an
1355 * adapter. */ 1373 * adapter.
1374 */
1356 1375
1357 mutex_lock(&ctrl->crit_sect); 1376 mutex_lock(&ctrl->crit_sect);
1358 1377
@@ -1377,7 +1396,8 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1377 1396
1378 * Get slot won't work for devices behind bridges, but 1397 * Get slot won't work for devices behind bridges, but
1379 * in this case it will always be called for the "base" 1398 * in this case it will always be called for the "base"
1380 * bus/dev/func of an adapter. */ 1399 * bus/dev/func of an adapter.
1400 */
1381 1401
1382 mutex_lock(&ctrl->crit_sect); 1402 mutex_lock(&ctrl->crit_sect);
1383 1403
@@ -1434,7 +1454,8 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1434 wait_for_ctrl_irq (ctrl); 1454 wait_for_ctrl_irq (ctrl);
1435 1455
1436 /* Change bits in slot power register to force another shift out 1456 /* Change bits in slot power register to force another shift out
1437 * NOTE: this is to work around the timer bug */ 1457 * NOTE: this is to work around the timer bug
1458 */
1438 temp_byte = readb(ctrl->hpc_reg + SLOT_POWER); 1459 temp_byte = readb(ctrl->hpc_reg + SLOT_POWER);
1439 writeb(0x00, ctrl->hpc_reg + SLOT_POWER); 1460 writeb(0x00, ctrl->hpc_reg + SLOT_POWER);
1440 writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER); 1461 writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER);
@@ -2484,7 +2505,8 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2484 temp_resources.irqs = &irqs; 2505 temp_resources.irqs = &irqs;
2485 2506
2486 /* Make copies of the nodes we are going to pass down so that 2507 /* Make copies of the nodes we are going to pass down so that
2487 * if there is a problem,we can just use these to free resources */ 2508 * if there is a problem,we can just use these to free resources
2509 */
2488 hold_bus_node = kmalloc(sizeof(*hold_bus_node), GFP_KERNEL); 2510 hold_bus_node = kmalloc(sizeof(*hold_bus_node), GFP_KERNEL);
2489 hold_IO_node = kmalloc(sizeof(*hold_IO_node), GFP_KERNEL); 2511 hold_IO_node = kmalloc(sizeof(*hold_IO_node), GFP_KERNEL);
2490 hold_mem_node = kmalloc(sizeof(*hold_mem_node), GFP_KERNEL); 2512 hold_mem_node = kmalloc(sizeof(*hold_mem_node), GFP_KERNEL);
@@ -2556,7 +2578,8 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2556 temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16; 2578 temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16;
2557 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); 2579 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2558 2580
2559 /* Adjust this to compensate for extra adjustment in first loop */ 2581 /* Adjust this to compensate for extra adjustment in first loop
2582 */
2560 irqs.barber_pole--; 2583 irqs.barber_pole--;
2561 2584
2562 rc = 0; 2585 rc = 0;