aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pciehp_ctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/pciehp_ctrl.c')
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c59
1 files changed, 9 insertions, 50 deletions
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 84487d126e4d..8f58148be044 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/slab.h>
33#include <linux/pci.h> 34#include <linux/pci.h>
34#include <linux/workqueue.h> 35#include <linux/workqueue.h>
35#include "../pci.h" 36#include "../pci.h"
@@ -142,23 +143,9 @@ u8 pciehp_handle_power_fault(struct slot *p_slot)
142 143
143 /* power fault */ 144 /* power fault */
144 ctrl_dbg(ctrl, "Power fault interrupt received\n"); 145 ctrl_dbg(ctrl, "Power fault interrupt received\n");
145 146 ctrl_err(ctrl, "Power fault on slot %s\n", slot_name(p_slot));
146 if (!pciehp_query_power_fault(p_slot)) { 147 event_type = INT_POWER_FAULT;
147 /* 148 ctrl_info(ctrl, "Power fault bit %x set\n", 0);
148 * power fault Cleared
149 */
150 ctrl_info(ctrl, "Power fault cleared on Slot(%s)\n",
151 slot_name(p_slot));
152 event_type = INT_POWER_FAULT_CLEAR;
153 } else {
154 /*
155 * power fault
156 */
157 ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot));
158 event_type = INT_POWER_FAULT;
159 ctrl_info(ctrl, "Power fault bit %x set\n", 0);
160 }
161
162 queue_interrupt_event(p_slot, event_type); 149 queue_interrupt_event(p_slot, event_type);
163 150
164 return 1; 151 return 1;
@@ -224,13 +211,12 @@ static int board_added(struct slot *p_slot)
224 retval = pciehp_check_link_status(ctrl); 211 retval = pciehp_check_link_status(ctrl);
225 if (retval) { 212 if (retval) {
226 ctrl_err(ctrl, "Failed to check link status\n"); 213 ctrl_err(ctrl, "Failed to check link status\n");
227 set_slot_off(ctrl, p_slot); 214 goto err_exit;
228 return retval;
229 } 215 }
230 216
231 /* Check for a power fault */ 217 /* Check for a power fault */
232 if (pciehp_query_power_fault(p_slot)) { 218 if (ctrl->power_fault_detected || pciehp_query_power_fault(p_slot)) {
233 ctrl_dbg(ctrl, "Power fault detected\n"); 219 ctrl_err(ctrl, "Power fault on slot %s\n", slot_name(p_slot));
234 retval = -EIO; 220 retval = -EIO;
235 goto err_exit; 221 goto err_exit;
236 } 222 }
@@ -356,6 +342,7 @@ void pciehp_queue_pushbutton_work(struct work_struct *work)
356 p_slot->state = POWERON_STATE; 342 p_slot->state = POWERON_STATE;
357 break; 343 break;
358 default: 344 default:
345 kfree(info);
359 goto out; 346 goto out;
360 } 347 }
361 queue_work(pciehp_wq, &info->work); 348 queue_work(pciehp_wq, &info->work);
@@ -363,25 +350,6 @@ void pciehp_queue_pushbutton_work(struct work_struct *work)
363 mutex_unlock(&p_slot->lock); 350 mutex_unlock(&p_slot->lock);
364} 351}
365 352
366static int update_slot_info(struct slot *slot)
367{
368 struct hotplug_slot_info *info;
369 int result;
370
371 info = kmalloc(sizeof(*info), GFP_KERNEL);
372 if (!info)
373 return -ENOMEM;
374
375 pciehp_get_power_status(slot, &info->power_status);
376 pciehp_get_attention_status(slot, &info->attention_status);
377 pciehp_get_latch_status(slot, &info->latch_status);
378 pciehp_get_adapter_status(slot, &info->adapter_status);
379
380 result = pci_hp_change_slot_info(slot->hotplug_slot, info);
381 kfree (info);
382 return result;
383}
384
385/* 353/*
386 * Note: This function must be called with slot->lock held 354 * Note: This function must be called with slot->lock held
387 */ 355 */
@@ -442,7 +410,6 @@ static void handle_button_press_event(struct slot *p_slot)
442 * to hot-add or hot-remove is undergoing 410 * to hot-add or hot-remove is undergoing
443 */ 411 */
444 ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot)); 412 ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot));
445 update_slot_info(p_slot);
446 break; 413 break;
447 default: 414 default:
448 ctrl_warn(ctrl, "Not a valid state\n"); 415 ctrl_warn(ctrl, "Not a valid state\n");
@@ -500,11 +467,9 @@ static void interrupt_event_handler(struct work_struct *work)
500 if (!HP_SUPR_RM(ctrl)) 467 if (!HP_SUPR_RM(ctrl))
501 break; 468 break;
502 ctrl_dbg(ctrl, "Surprise Removal\n"); 469 ctrl_dbg(ctrl, "Surprise Removal\n");
503 update_slot_info(p_slot);
504 handle_surprise_event(p_slot); 470 handle_surprise_event(p_slot);
505 break; 471 break;
506 default: 472 default:
507 update_slot_info(p_slot);
508 break; 473 break;
509 } 474 }
510 mutex_unlock(&p_slot->lock); 475 mutex_unlock(&p_slot->lock);
@@ -547,9 +512,6 @@ int pciehp_enable_slot(struct slot *p_slot)
547 if (rc) { 512 if (rc) {
548 pciehp_get_latch_status(p_slot, &getstatus); 513 pciehp_get_latch_status(p_slot, &getstatus);
549 } 514 }
550
551 update_slot_info(p_slot);
552
553 return rc; 515 return rc;
554} 516}
555 517
@@ -590,10 +552,7 @@ int pciehp_disable_slot(struct slot *p_slot)
590 } 552 }
591 } 553 }
592 554
593 ret = remove_board(p_slot); 555 return remove_board(p_slot);
594 update_slot_info(p_slot);
595
596 return ret;
597} 556}
598 557
599int pciehp_sysfs_enable_slot(struct slot *p_slot) 558int pciehp_sysfs_enable_slot(struct slot *p_slot)