aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/hotplug/shpchp.h9
-rw-r--r--drivers/pci/hotplug/shpchp_core.c38
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c48
3 files changed, 48 insertions, 47 deletions
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 8a026f750deb..4d9fed00e1d0 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -69,15 +69,13 @@ struct slot {
69 u8 state; 69 u8 state;
70 u8 presence_save; 70 u8 presence_save;
71 u8 pwr_save; 71 u8 pwr_save;
72 struct timer_list task_event;
73 u8 hp_slot;
74 struct controller *ctrl; 72 struct controller *ctrl;
75 struct hpc_ops *hpc_ops; 73 struct hpc_ops *hpc_ops;
76 struct hotplug_slot *hotplug_slot; 74 struct hotplug_slot *hotplug_slot;
77 struct list_head slot_list; 75 struct list_head slot_list;
78 char name[SLOT_NAME_SIZE];
79 struct delayed_work work; /* work for button event */ 76 struct delayed_work work; /* work for button event */
80 struct mutex lock; 77 struct mutex lock;
78 u8 hp_slot;
81}; 79};
82 80
83struct event_info { 81struct event_info {
@@ -169,6 +167,11 @@ extern void cleanup_slots(struct controller *ctrl);
169extern void shpchp_queue_pushbutton_work(struct work_struct *work); 167extern void shpchp_queue_pushbutton_work(struct work_struct *work);
170extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev); 168extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
171 169
170static inline const char *slot_name(struct slot *slot)
171{
172 return hotplug_slot_name(slot->hotplug_slot);
173}
174
172#ifdef CONFIG_ACPI 175#ifdef CONFIG_ACPI
173#include <linux/pci-acpi.h> 176#include <linux/pci-acpi.h>
174static inline int get_hp_params_from_firmware(struct pci_dev *dev, 177static inline int get_hp_params_from_firmware(struct pci_dev *dev,
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index cfdd07963641..7af9191df4d6 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -89,7 +89,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
89{ 89{
90 struct slot *slot = hotplug_slot->private; 90 struct slot *slot = hotplug_slot->private;
91 91
92 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 92 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
93 93
94 kfree(slot->hotplug_slot->info); 94 kfree(slot->hotplug_slot->info);
95 kfree(slot->hotplug_slot); 95 kfree(slot->hotplug_slot);
@@ -101,6 +101,7 @@ static int init_slots(struct controller *ctrl)
101 struct slot *slot; 101 struct slot *slot;
102 struct hotplug_slot *hotplug_slot; 102 struct hotplug_slot *hotplug_slot;
103 struct hotplug_slot_info *info; 103 struct hotplug_slot_info *info;
104 char name[SLOT_NAME_SIZE];
104 int retval = -ENOMEM; 105 int retval = -ENOMEM;
105 int i; 106 int i;
106 107
@@ -119,8 +120,6 @@ static int init_slots(struct controller *ctrl)
119 goto error_hpslot; 120 goto error_hpslot;
120 hotplug_slot->info = info; 121 hotplug_slot->info = info;
121 122
122 hotplug_slot->name = slot->name;
123
124 slot->hp_slot = i; 123 slot->hp_slot = i;
125 slot->ctrl = ctrl; 124 slot->ctrl = ctrl;
126 slot->bus = ctrl->pci_dev->subordinate->number; 125 slot->bus = ctrl->pci_dev->subordinate->number;
@@ -133,25 +132,24 @@ static int init_slots(struct controller *ctrl)
133 /* register this slot with the hotplug pci core */ 132 /* register this slot with the hotplug pci core */
134 hotplug_slot->private = slot; 133 hotplug_slot->private = slot;
135 hotplug_slot->release = &release_slot; 134 hotplug_slot->release = &release_slot;
136 snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number); 135 snprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
137 hotplug_slot->ops = &shpchp_hotplug_slot_ops; 136 hotplug_slot->ops = &shpchp_hotplug_slot_ops;
138 137
139 get_power_status(hotplug_slot, &info->power_status);
140 get_attention_status(hotplug_slot, &info->attention_status);
141 get_latch_status(hotplug_slot, &info->latch_status);
142 get_adapter_status(hotplug_slot, &info->adapter_status);
143
144 dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " 138 dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
145 "slot_device_offset=%x\n", slot->bus, slot->device, 139 "slot_device_offset=%x\n", slot->bus, slot->device,
146 slot->hp_slot, slot->number, ctrl->slot_device_offset); 140 slot->hp_slot, slot->number, ctrl->slot_device_offset);
147 retval = pci_hp_register(slot->hotplug_slot, 141 retval = pci_hp_register(slot->hotplug_slot,
148 ctrl->pci_dev->subordinate, slot->device, 142 ctrl->pci_dev->subordinate, slot->device, name);
149 hotplug_slot->name);
150 if (retval) { 143 if (retval) {
151 err("pci_hp_register failed with error %d\n", retval); 144 err("pci_hp_register failed with error %d\n", retval);
152 goto error_info; 145 goto error_info;
153 } 146 }
154 147
148 get_power_status(hotplug_slot, &info->power_status);
149 get_attention_status(hotplug_slot, &info->attention_status);
150 get_latch_status(hotplug_slot, &info->latch_status);
151 get_adapter_status(hotplug_slot, &info->adapter_status);
152
155 list_add(&slot->slot_list, &ctrl->slot_list); 153 list_add(&slot->slot_list, &ctrl->slot_list);
156 } 154 }
157 155
@@ -189,7 +187,7 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
189{ 187{
190 struct slot *slot = get_slot(hotplug_slot); 188 struct slot *slot = get_slot(hotplug_slot);
191 189
192 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 190 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
193 191
194 hotplug_slot->info->attention_status = status; 192 hotplug_slot->info->attention_status = status;
195 slot->hpc_ops->set_attention_status(slot, status); 193 slot->hpc_ops->set_attention_status(slot, status);
@@ -201,7 +199,7 @@ static int enable_slot (struct hotplug_slot *hotplug_slot)
201{ 199{
202 struct slot *slot = get_slot(hotplug_slot); 200 struct slot *slot = get_slot(hotplug_slot);
203 201
204 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 202 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
205 203
206 return shpchp_sysfs_enable_slot(slot); 204 return shpchp_sysfs_enable_slot(slot);
207} 205}
@@ -210,7 +208,7 @@ static int disable_slot (struct hotplug_slot *hotplug_slot)
210{ 208{
211 struct slot *slot = get_slot(hotplug_slot); 209 struct slot *slot = get_slot(hotplug_slot);
212 210
213 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 211 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
214 212
215 return shpchp_sysfs_disable_slot(slot); 213 return shpchp_sysfs_disable_slot(slot);
216} 214}
@@ -220,7 +218,7 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
220 struct slot *slot = get_slot(hotplug_slot); 218 struct slot *slot = get_slot(hotplug_slot);
221 int retval; 219 int retval;
222 220
223 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 221 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
224 222
225 retval = slot->hpc_ops->get_power_status(slot, value); 223 retval = slot->hpc_ops->get_power_status(slot, value);
226 if (retval < 0) 224 if (retval < 0)
@@ -234,7 +232,7 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value)
234 struct slot *slot = get_slot(hotplug_slot); 232 struct slot *slot = get_slot(hotplug_slot);
235 int retval; 233 int retval;
236 234
237 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 235 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
238 236
239 retval = slot->hpc_ops->get_attention_status(slot, value); 237 retval = slot->hpc_ops->get_attention_status(slot, value);
240 if (retval < 0) 238 if (retval < 0)
@@ -248,7 +246,7 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value)
248 struct slot *slot = get_slot(hotplug_slot); 246 struct slot *slot = get_slot(hotplug_slot);
249 int retval; 247 int retval;
250 248
251 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 249 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
252 250
253 retval = slot->hpc_ops->get_latch_status(slot, value); 251 retval = slot->hpc_ops->get_latch_status(slot, value);
254 if (retval < 0) 252 if (retval < 0)
@@ -262,7 +260,7 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
262 struct slot *slot = get_slot(hotplug_slot); 260 struct slot *slot = get_slot(hotplug_slot);
263 int retval; 261 int retval;
264 262
265 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 263 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
266 264
267 retval = slot->hpc_ops->get_adapter_status(slot, value); 265 retval = slot->hpc_ops->get_adapter_status(slot, value);
268 if (retval < 0) 266 if (retval < 0)
@@ -277,7 +275,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
277 struct slot *slot = get_slot(hotplug_slot); 275 struct slot *slot = get_slot(hotplug_slot);
278 int retval; 276 int retval;
279 277
280 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 278 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
281 279
282 retval = slot->hpc_ops->get_max_bus_speed(slot, value); 280 retval = slot->hpc_ops->get_max_bus_speed(slot, value);
283 if (retval < 0) 281 if (retval < 0)
@@ -291,7 +289,7 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
291 struct slot *slot = get_slot(hotplug_slot); 289 struct slot *slot = get_slot(hotplug_slot);
292 int retval; 290 int retval;
293 291
294 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); 292 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
295 293
296 retval = slot->hpc_ops->get_cur_bus_speed(slot, value); 294 retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
297 if (retval < 0) 295 if (retval < 0)
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index dfb53932dfbc..919b1ee44313 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -70,7 +70,7 @@ u8 shpchp_handle_attention_button(u8 hp_slot, struct controller *ctrl)
70 /* 70 /*
71 * Button pressed - See if need to TAKE ACTION!!! 71 * Button pressed - See if need to TAKE ACTION!!!
72 */ 72 */
73 info("Button pressed on Slot(%s)\n", p_slot->name); 73 info("Button pressed on Slot(%s)\n", slot_name(p_slot));
74 event_type = INT_BUTTON_PRESS; 74 event_type = INT_BUTTON_PRESS;
75 75
76 queue_interrupt_event(p_slot, event_type); 76 queue_interrupt_event(p_slot, event_type);
@@ -98,7 +98,7 @@ u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
98 /* 98 /*
99 * Switch opened 99 * Switch opened
100 */ 100 */
101 info("Latch open on Slot(%s)\n", p_slot->name); 101 info("Latch open on Slot(%s)\n", slot_name(p_slot));
102 event_type = INT_SWITCH_OPEN; 102 event_type = INT_SWITCH_OPEN;
103 if (p_slot->pwr_save && p_slot->presence_save) { 103 if (p_slot->pwr_save && p_slot->presence_save) {
104 event_type = INT_POWER_FAULT; 104 event_type = INT_POWER_FAULT;
@@ -108,7 +108,7 @@ u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
108 /* 108 /*
109 * Switch closed 109 * Switch closed
110 */ 110 */
111 info("Latch close on Slot(%s)\n", p_slot->name); 111 info("Latch close on Slot(%s)\n", slot_name(p_slot));
112 event_type = INT_SWITCH_CLOSE; 112 event_type = INT_SWITCH_CLOSE;
113 } 113 }
114 114
@@ -135,13 +135,13 @@ u8 shpchp_handle_presence_change(u8 hp_slot, struct controller *ctrl)
135 /* 135 /*
136 * Card Present 136 * Card Present
137 */ 137 */
138 info("Card present on Slot(%s)\n", p_slot->name); 138 info("Card present on Slot(%s)\n", slot_name(p_slot));
139 event_type = INT_PRESENCE_ON; 139 event_type = INT_PRESENCE_ON;
140 } else { 140 } else {
141 /* 141 /*
142 * Not Present 142 * Not Present
143 */ 143 */
144 info("Card not present on Slot(%s)\n", p_slot->name); 144 info("Card not present on Slot(%s)\n", slot_name(p_slot));
145 event_type = INT_PRESENCE_OFF; 145 event_type = INT_PRESENCE_OFF;
146 } 146 }
147 147
@@ -164,14 +164,14 @@ u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl)
164 /* 164 /*
165 * Power fault Cleared 165 * Power fault Cleared
166 */ 166 */
167 info("Power fault cleared on Slot(%s)\n", p_slot->name); 167 info("Power fault cleared on Slot(%s)\n", slot_name(p_slot));
168 p_slot->status = 0x00; 168 p_slot->status = 0x00;
169 event_type = INT_POWER_FAULT_CLEAR; 169 event_type = INT_POWER_FAULT_CLEAR;
170 } else { 170 } else {
171 /* 171 /*
172 * Power fault 172 * Power fault
173 */ 173 */
174 info("Power fault on Slot(%s)\n", p_slot->name); 174 info("Power fault on Slot(%s)\n", slot_name(p_slot));
175 event_type = INT_POWER_FAULT; 175 event_type = INT_POWER_FAULT;
176 /* set power fault status for this board */ 176 /* set power fault status for this board */
177 p_slot->status = 0xFF; 177 p_slot->status = 0xFF;
@@ -493,11 +493,11 @@ static void handle_button_press_event(struct slot *p_slot)
493 if (getstatus) { 493 if (getstatus) {
494 p_slot->state = BLINKINGOFF_STATE; 494 p_slot->state = BLINKINGOFF_STATE;
495 info("PCI slot #%s - powering off due to button " 495 info("PCI slot #%s - powering off due to button "
496 "press.\n", p_slot->name); 496 "press.\n", slot_name(p_slot));
497 } else { 497 } else {
498 p_slot->state = BLINKINGON_STATE; 498 p_slot->state = BLINKINGON_STATE;
499 info("PCI slot #%s - powering on due to button " 499 info("PCI slot #%s - powering on due to button "
500 "press.\n", p_slot->name); 500 "press.\n", slot_name(p_slot));
501 } 501 }
502 /* blink green LED and turn off amber */ 502 /* blink green LED and turn off amber */
503 p_slot->hpc_ops->green_led_blink(p_slot); 503 p_slot->hpc_ops->green_led_blink(p_slot);
@@ -512,7 +512,7 @@ static void handle_button_press_event(struct slot *p_slot)
512 * press the attention again before the 5 sec. limit 512 * press the attention again before the 5 sec. limit
513 * expires to cancel hot-add or hot-remove 513 * expires to cancel hot-add or hot-remove
514 */ 514 */
515 info("Button cancel on Slot(%s)\n", p_slot->name); 515 info("Button cancel on Slot(%s)\n", slot_name(p_slot));
516 dbg("%s: button cancel\n", __func__); 516 dbg("%s: button cancel\n", __func__);
517 cancel_delayed_work(&p_slot->work); 517 cancel_delayed_work(&p_slot->work);
518 if (p_slot->state == BLINKINGOFF_STATE) 518 if (p_slot->state == BLINKINGOFF_STATE)
@@ -521,7 +521,7 @@ static void handle_button_press_event(struct slot *p_slot)
521 p_slot->hpc_ops->green_led_off(p_slot); 521 p_slot->hpc_ops->green_led_off(p_slot);
522 p_slot->hpc_ops->set_attention_status(p_slot, 0); 522 p_slot->hpc_ops->set_attention_status(p_slot, 0);
523 info("PCI slot #%s - action canceled due to button press\n", 523 info("PCI slot #%s - action canceled due to button press\n",
524 p_slot->name); 524 slot_name(p_slot));
525 p_slot->state = STATIC_STATE; 525 p_slot->state = STATIC_STATE;
526 break; 526 break;
527 case POWEROFF_STATE: 527 case POWEROFF_STATE:
@@ -531,7 +531,7 @@ static void handle_button_press_event(struct slot *p_slot)
531 * this means that the previous attention button action 531 * this means that the previous attention button action
532 * to hot-add or hot-remove is undergoing 532 * to hot-add or hot-remove is undergoing
533 */ 533 */
534 info("Button ignore on Slot(%s)\n", p_slot->name); 534 info("Button ignore on Slot(%s)\n", slot_name(p_slot));
535 update_slot_info(p_slot); 535 update_slot_info(p_slot);
536 break; 536 break;
537 default: 537 default:
@@ -574,17 +574,17 @@ static int shpchp_enable_slot (struct slot *p_slot)
574 mutex_lock(&p_slot->ctrl->crit_sect); 574 mutex_lock(&p_slot->ctrl->crit_sect);
575 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 575 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
576 if (rc || !getstatus) { 576 if (rc || !getstatus) {
577 info("No adapter on slot(%s)\n", p_slot->name); 577 info("No adapter on slot(%s)\n", slot_name(p_slot));
578 goto out; 578 goto out;
579 } 579 }
580 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 580 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
581 if (rc || getstatus) { 581 if (rc || getstatus) {
582 info("Latch open on slot(%s)\n", p_slot->name); 582 info("Latch open on slot(%s)\n", slot_name(p_slot));
583 goto out; 583 goto out;
584 } 584 }
585 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 585 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
586 if (rc || getstatus) { 586 if (rc || getstatus) {
587 info("Already enabled on slot(%s)\n", p_slot->name); 587 info("Already enabled on slot(%s)\n", slot_name(p_slot));
588 goto out; 588 goto out;
589 } 589 }
590 590
@@ -633,17 +633,17 @@ static int shpchp_disable_slot (struct slot *p_slot)
633 633
634 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 634 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
635 if (rc || !getstatus) { 635 if (rc || !getstatus) {
636 info("No adapter on slot(%s)\n", p_slot->name); 636 info("No adapter on slot(%s)\n", slot_name(p_slot));
637 goto out; 637 goto out;
638 } 638 }
639 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 639 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
640 if (rc || getstatus) { 640 if (rc || getstatus) {
641 info("Latch open on slot(%s)\n", p_slot->name); 641 info("Latch open on slot(%s)\n", slot_name(p_slot));
642 goto out; 642 goto out;
643 } 643 }
644 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 644 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
645 if (rc || !getstatus) { 645 if (rc || !getstatus) {
646 info("Already disabled slot(%s)\n", p_slot->name); 646 info("Already disabled slot(%s)\n", slot_name(p_slot));
647 goto out; 647 goto out;
648 } 648 }
649 649
@@ -671,14 +671,14 @@ int shpchp_sysfs_enable_slot(struct slot *p_slot)
671 break; 671 break;
672 case POWERON_STATE: 672 case POWERON_STATE:
673 info("Slot %s is already in powering on state\n", 673 info("Slot %s is already in powering on state\n",
674 p_slot->name); 674 slot_name(p_slot));
675 break; 675 break;
676 case BLINKINGOFF_STATE: 676 case BLINKINGOFF_STATE:
677 case POWEROFF_STATE: 677 case POWEROFF_STATE:
678 info("Already enabled on slot %s\n", p_slot->name); 678 info("Already enabled on slot %s\n", slot_name(p_slot));
679 break; 679 break;
680 default: 680 default:
681 err("Not a valid state on slot %s\n", p_slot->name); 681 err("Not a valid state on slot %s\n", slot_name(p_slot));
682 break; 682 break;
683 } 683 }
684 mutex_unlock(&p_slot->lock); 684 mutex_unlock(&p_slot->lock);
@@ -703,14 +703,14 @@ int shpchp_sysfs_disable_slot(struct slot *p_slot)
703 break; 703 break;
704 case POWEROFF_STATE: 704 case POWEROFF_STATE:
705 info("Slot %s is already in powering off state\n", 705 info("Slot %s is already in powering off state\n",
706 p_slot->name); 706 slot_name(p_slot));
707 break; 707 break;
708 case BLINKINGON_STATE: 708 case BLINKINGON_STATE:
709 case POWERON_STATE: 709 case POWERON_STATE:
710 info("Already disabled on slot %s\n", p_slot->name); 710 info("Already disabled on slot %s\n", slot_name(p_slot));
711 break; 711 break;
712 default: 712 default:
713 err("Not a valid state on slot %s\n", p_slot->name); 713 err("Not a valid state on slot %s\n", slot_name(p_slot));
714 break; 714 break;
715 } 715 }
716 mutex_unlock(&p_slot->lock); 716 mutex_unlock(&p_slot->lock);