aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>2009-09-15 04:30:48 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-09-17 13:06:31 -0400
commit82a9e79ef132cbf77de58aae35c1a14237f2fcde (patch)
tree1ca6f0dc69cb7e92df48d4f05b595b032e03e206 /drivers/pci/hotplug
parent385e24917ed8eeba25dddd8e63bf3fe3d53eafc5 (diff)
PCI: pciehp: remove hpc_ops
The struct hpc_ops seems a set of hooks to controller specific routines. But, it is meaningless because no hotplug controller driver follows this framework. Acked-by: Alex Chiang <achiang@hp.com> Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/pciehp.h42
-rw-r--r--drivers/pci/hotplug/pciehp_core.c26
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c75
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c60
-rw-r--r--drivers/pci/hotplug/pciehp_pci.c2
5 files changed, 87 insertions, 118 deletions
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index b23f8ca03d82..b7054cb885cf 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -75,7 +75,6 @@ struct slot {
75 u8 state; 75 u8 state;
76 u32 number; 76 u32 number;
77 struct controller *ctrl; 77 struct controller *ctrl;
78 struct hpc_ops *hpc_ops;
79 struct hotplug_slot *hotplug_slot; 78 struct hotplug_slot *hotplug_slot;
80 struct delayed_work work; /* work for button event */ 79 struct delayed_work work; /* work for button event */
81 struct mutex lock; 80 struct mutex lock;
@@ -91,7 +90,6 @@ struct controller {
91 struct mutex ctrl_lock; /* controller lock */ 90 struct mutex ctrl_lock; /* controller lock */
92 struct pcie_device *pcie; /* PCI Express port service */ 91 struct pcie_device *pcie; /* PCI Express port service */
93 struct slot *slot; 92 struct slot *slot;
94 struct hpc_ops *hpc_ops;
95 wait_queue_head_t queue; /* sleep & wake process */ 93 wait_queue_head_t queue; /* sleep & wake process */
96 u32 slot_cap; 94 u32 slot_cap;
97 u8 cap_base; 95 u8 cap_base;
@@ -154,7 +152,7 @@ struct controller {
154extern int pciehp_sysfs_enable_slot(struct slot *slot); 152extern int pciehp_sysfs_enable_slot(struct slot *slot);
155extern int pciehp_sysfs_disable_slot(struct slot *slot); 153extern int pciehp_sysfs_disable_slot(struct slot *slot);
156extern u8 pciehp_handle_attention_button(struct slot *p_slot); 154extern u8 pciehp_handle_attention_button(struct slot *p_slot);
157 extern u8 pciehp_handle_switch_change(struct slot *p_slot); 155extern u8 pciehp_handle_switch_change(struct slot *p_slot);
158extern u8 pciehp_handle_presence_change(struct slot *p_slot); 156extern u8 pciehp_handle_presence_change(struct slot *p_slot);
159extern u8 pciehp_handle_power_fault(struct slot *p_slot); 157extern u8 pciehp_handle_power_fault(struct slot *p_slot);
160extern int pciehp_configure_device(struct slot *p_slot); 158extern int pciehp_configure_device(struct slot *p_slot);
@@ -165,32 +163,30 @@ int pcie_init_notification(struct controller *ctrl);
165int pciehp_enable_slot(struct slot *p_slot); 163int pciehp_enable_slot(struct slot *p_slot);
166int pciehp_disable_slot(struct slot *p_slot); 164int pciehp_disable_slot(struct slot *p_slot);
167int pcie_enable_notification(struct controller *ctrl); 165int pcie_enable_notification(struct controller *ctrl);
166int pciehp_power_on_slot(struct slot *slot);
167int pciehp_power_off_slot(struct slot *slot);
168int pciehp_get_power_status(struct slot *slot, u8 *status);
169int pciehp_get_attention_status(struct slot *slot, u8 *status);
170
171int pciehp_set_attention_status(struct slot *slot, u8 status);
172int pciehp_get_latch_status(struct slot *slot, u8 *status);
173int pciehp_get_adapter_status(struct slot *slot, u8 *status);
174int pciehp_get_max_link_speed(struct slot *slot, enum pci_bus_speed *speed);
175int pciehp_get_max_link_width(struct slot *slot, enum pcie_link_width *val);
176int pciehp_get_cur_link_speed(struct slot *slot, enum pci_bus_speed *speed);
177int pciehp_get_cur_link_width(struct slot *slot, enum pcie_link_width *val);
178int pciehp_query_power_fault(struct slot *slot);
179void pciehp_green_led_on(struct slot *slot);
180void pciehp_green_led_off(struct slot *slot);
181void pciehp_green_led_blink(struct slot *slot);
182int pciehp_check_link_status(struct controller *ctrl);
183void pciehp_release_ctrl(struct controller *ctrl);
168 184
169static inline const char *slot_name(struct slot *slot) 185static inline const char *slot_name(struct slot *slot)
170{ 186{
171 return hotplug_slot_name(slot->hotplug_slot); 187 return hotplug_slot_name(slot->hotplug_slot);
172} 188}
173 189
174struct hpc_ops {
175 int (*power_on_slot)(struct slot *slot);
176 int (*power_off_slot)(struct slot *slot);
177 int (*get_power_status)(struct slot *slot, u8 *status);
178 int (*get_attention_status)(struct slot *slot, u8 *status);
179 int (*set_attention_status)(struct slot *slot, u8 status);
180 int (*get_latch_status)(struct slot *slot, u8 *status);
181 int (*get_adapter_status)(struct slot *slot, u8 *status);
182 int (*get_max_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
183 int (*get_cur_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
184 int (*get_max_lnk_width)(struct slot *slot, enum pcie_link_width *val);
185 int (*get_cur_lnk_width)(struct slot *slot, enum pcie_link_width *val);
186 int (*query_power_fault)(struct slot *slot);
187 void (*green_led_on)(struct slot *slot);
188 void (*green_led_off)(struct slot *slot);
189 void (*green_led_blink)(struct slot *slot);
190 void (*release_ctlr)(struct controller *ctrl);
191 int (*check_lnk_status)(struct controller *ctrl);
192};
193
194#ifdef CONFIG_ACPI 190#ifdef CONFIG_ACPI
195#include <acpi/acpi.h> 191#include <acpi/acpi.h>
196#include <acpi/acpi_bus.h> 192#include <acpi/acpi_bus.h>
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index f82dc036ab34..2c6d94fcf9aa 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -163,7 +163,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
163 hotplug_slot->info->attention_status = status; 163 hotplug_slot->info->attention_status = status;
164 164
165 if (ATTN_LED(slot->ctrl)) 165 if (ATTN_LED(slot->ctrl))
166 slot->hpc_ops->set_attention_status(slot, status); 166 pciehp_set_attention_status(slot, status);
167 167
168 return 0; 168 return 0;
169} 169}
@@ -198,7 +198,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
198 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 198 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
199 __func__, slot_name(slot)); 199 __func__, slot_name(slot));
200 200
201 retval = slot->hpc_ops->get_power_status(slot, value); 201 retval = pciehp_get_power_status(slot, value);
202 if (retval < 0) 202 if (retval < 0)
203 *value = hotplug_slot->info->power_status; 203 *value = hotplug_slot->info->power_status;
204 204
@@ -213,7 +213,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
213 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 213 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
214 __func__, slot_name(slot)); 214 __func__, slot_name(slot));
215 215
216 retval = slot->hpc_ops->get_attention_status(slot, value); 216 retval = pciehp_get_attention_status(slot, value);
217 if (retval < 0) 217 if (retval < 0)
218 *value = hotplug_slot->info->attention_status; 218 *value = hotplug_slot->info->attention_status;
219 219
@@ -228,7 +228,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
228 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 228 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
229 __func__, slot_name(slot)); 229 __func__, slot_name(slot));
230 230
231 retval = slot->hpc_ops->get_latch_status(slot, value); 231 retval = pciehp_get_latch_status(slot, value);
232 if (retval < 0) 232 if (retval < 0)
233 *value = hotplug_slot->info->latch_status; 233 *value = hotplug_slot->info->latch_status;
234 234
@@ -243,7 +243,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
243 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 243 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
244 __func__, slot_name(slot)); 244 __func__, slot_name(slot));
245 245
246 retval = slot->hpc_ops->get_adapter_status(slot, value); 246 retval = pciehp_get_adapter_status(slot, value);
247 if (retval < 0) 247 if (retval < 0)
248 *value = hotplug_slot->info->adapter_status; 248 *value = hotplug_slot->info->adapter_status;
249 249
@@ -259,7 +259,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
259 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 259 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
260 __func__, slot_name(slot)); 260 __func__, slot_name(slot));
261 261
262 retval = slot->hpc_ops->get_max_bus_speed(slot, value); 262 retval = pciehp_get_max_link_speed(slot, value);
263 if (retval < 0) 263 if (retval < 0)
264 *value = PCI_SPEED_UNKNOWN; 264 *value = PCI_SPEED_UNKNOWN;
265 265
@@ -274,7 +274,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
274 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 274 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
275 __func__, slot_name(slot)); 275 __func__, slot_name(slot));
276 276
277 retval = slot->hpc_ops->get_cur_bus_speed(slot, value); 277 retval = pciehp_get_cur_link_speed(slot, value);
278 if (retval < 0) 278 if (retval < 0)
279 *value = PCI_SPEED_UNKNOWN; 279 *value = PCI_SPEED_UNKNOWN;
280 280
@@ -323,14 +323,14 @@ static int pciehp_probe(struct pcie_device *dev)
323 323
324 /* Check if slot is occupied */ 324 /* Check if slot is occupied */
325 slot = ctrl->slot; 325 slot = ctrl->slot;
326 slot->hpc_ops->get_adapter_status(slot, &value); 326 pciehp_get_adapter_status(slot, &value);
327 if (value) { 327 if (value) {
328 if (pciehp_force) 328 if (pciehp_force)
329 pciehp_enable_slot(slot); 329 pciehp_enable_slot(slot);
330 } else { 330 } else {
331 /* Power off slot if not occupied */ 331 /* Power off slot if not occupied */
332 if (POWER_CTRL(ctrl)) { 332 if (POWER_CTRL(ctrl)) {
333 rc = slot->hpc_ops->power_off_slot(slot); 333 rc = pciehp_power_off_slot(slot);
334 if (rc) 334 if (rc)
335 goto err_out_free_ctrl_slot; 335 goto err_out_free_ctrl_slot;
336 } 336 }
@@ -341,17 +341,17 @@ static int pciehp_probe(struct pcie_device *dev)
341err_out_free_ctrl_slot: 341err_out_free_ctrl_slot:
342 cleanup_slot(ctrl); 342 cleanup_slot(ctrl);
343err_out_release_ctlr: 343err_out_release_ctlr:
344 ctrl->hpc_ops->release_ctlr(ctrl); 344 pciehp_release_ctrl(ctrl);
345err_out_none: 345err_out_none:
346 return -ENODEV; 346 return -ENODEV;
347} 347}
348 348
349static void pciehp_remove (struct pcie_device *dev) 349static void pciehp_remove(struct pcie_device *dev)
350{ 350{
351 struct controller *ctrl = get_service_data(dev); 351 struct controller *ctrl = get_service_data(dev);
352 352
353 cleanup_slot(ctrl); 353 cleanup_slot(ctrl);
354 ctrl->hpc_ops->release_ctlr(ctrl); 354 pciehp_release_ctrl(ctrl);
355} 355}
356 356
357#ifdef CONFIG_PM 357#ifdef CONFIG_PM
@@ -375,7 +375,7 @@ static int pciehp_resume (struct pcie_device *dev)
375 slot = ctrl->slot; 375 slot = ctrl->slot;
376 376
377 /* Check if slot is occupied */ 377 /* Check if slot is occupied */
378 slot->hpc_ops->get_adapter_status(slot, &status); 378 pciehp_get_adapter_status(slot, &status);
379 if (status) 379 if (status)
380 pciehp_enable_slot(slot); 380 pciehp_enable_slot(slot);
381 else 381 else
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index c3e5ca57af7c..81c322de137d 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -82,7 +82,7 @@ u8 pciehp_handle_switch_change(struct slot *p_slot)
82 /* Switch Change */ 82 /* Switch Change */
83 ctrl_dbg(ctrl, "Switch interrupt received\n"); 83 ctrl_dbg(ctrl, "Switch interrupt received\n");
84 84
85 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 85 pciehp_get_latch_status(p_slot, &getstatus);
86 if (getstatus) { 86 if (getstatus) {
87 /* 87 /*
88 * Switch opened 88 * Switch opened
@@ -114,7 +114,7 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
114 /* Switch is open, assume a presence change 114 /* Switch is open, assume a presence change
115 * Save the presence state 115 * Save the presence state
116 */ 116 */
117 p_slot->hpc_ops->get_adapter_status(p_slot, &presence_save); 117 pciehp_get_adapter_status(p_slot, &presence_save);
118 if (presence_save) { 118 if (presence_save) {
119 /* 119 /*
120 * Card Present 120 * Card Present
@@ -143,7 +143,7 @@ u8 pciehp_handle_power_fault(struct slot *p_slot)
143 /* power fault */ 143 /* power fault */
144 ctrl_dbg(ctrl, "Power fault interrupt received\n"); 144 ctrl_dbg(ctrl, "Power fault interrupt received\n");
145 145
146 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { 146 if (!pciehp_query_power_fault(p_slot)) {
147 /* 147 /*
148 * power fault Cleared 148 * power fault Cleared
149 */ 149 */
@@ -172,7 +172,7 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
172{ 172{
173 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ 173 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
174 if (POWER_CTRL(ctrl)) { 174 if (POWER_CTRL(ctrl)) {
175 if (pslot->hpc_ops->power_off_slot(pslot)) { 175 if (pciehp_power_off_slot(pslot)) {
176 ctrl_err(ctrl, 176 ctrl_err(ctrl,
177 "Issue of Slot Power Off command failed\n"); 177 "Issue of Slot Power Off command failed\n");
178 return; 178 return;
@@ -186,10 +186,10 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
186 } 186 }
187 187
188 if (PWR_LED(ctrl)) 188 if (PWR_LED(ctrl))
189 pslot->hpc_ops->green_led_off(pslot); 189 pciehp_green_led_off(pslot);
190 190
191 if (ATTN_LED(ctrl)) { 191 if (ATTN_LED(ctrl)) {
192 if (pslot->hpc_ops->set_attention_status(pslot, 1)) { 192 if (pciehp_set_attention_status(pslot, 1)) {
193 ctrl_err(ctrl, 193 ctrl_err(ctrl,
194 "Issue of Set Attention Led command failed\n"); 194 "Issue of Set Attention Led command failed\n");
195 return; 195 return;
@@ -212,16 +212,16 @@ static int board_added(struct slot *p_slot)
212 212
213 if (POWER_CTRL(ctrl)) { 213 if (POWER_CTRL(ctrl)) {
214 /* Power on slot */ 214 /* Power on slot */
215 retval = p_slot->hpc_ops->power_on_slot(p_slot); 215 retval = pciehp_power_on_slot(p_slot);
216 if (retval) 216 if (retval)
217 return retval; 217 return retval;
218 } 218 }
219 219
220 if (PWR_LED(ctrl)) 220 if (PWR_LED(ctrl))
221 p_slot->hpc_ops->green_led_blink(p_slot); 221 pciehp_green_led_blink(p_slot);
222 222
223 /* Check link training status */ 223 /* Check link training status */
224 retval = p_slot->hpc_ops->check_lnk_status(ctrl); 224 retval = pciehp_check_link_status(ctrl);
225 if (retval) { 225 if (retval) {
226 ctrl_err(ctrl, "Failed to check link status\n"); 226 ctrl_err(ctrl, "Failed to check link status\n");
227 set_slot_off(ctrl, p_slot); 227 set_slot_off(ctrl, p_slot);
@@ -229,7 +229,7 @@ static int board_added(struct slot *p_slot)
229 } 229 }
230 230
231 /* Check for a power fault */ 231 /* Check for a power fault */
232 if (p_slot->hpc_ops->query_power_fault(p_slot)) { 232 if (pciehp_query_power_fault(p_slot)) {
233 ctrl_dbg(ctrl, "Power fault detected\n"); 233 ctrl_dbg(ctrl, "Power fault detected\n");
234 retval = POWER_FAILURE; 234 retval = POWER_FAILURE;
235 goto err_exit; 235 goto err_exit;
@@ -243,7 +243,7 @@ static int board_added(struct slot *p_slot)
243 } 243 }
244 244
245 if (PWR_LED(ctrl)) 245 if (PWR_LED(ctrl))
246 p_slot->hpc_ops->green_led_on(p_slot); 246 pciehp_green_led_on(p_slot);
247 247
248 return 0; 248 return 0;
249 249
@@ -267,7 +267,7 @@ static int remove_board(struct slot *p_slot)
267 267
268 if (POWER_CTRL(ctrl)) { 268 if (POWER_CTRL(ctrl)) {
269 /* power off slot */ 269 /* power off slot */
270 retval = p_slot->hpc_ops->power_off_slot(p_slot); 270 retval = pciehp_power_off_slot(p_slot);
271 if (retval) { 271 if (retval) {
272 ctrl_err(ctrl, 272 ctrl_err(ctrl,
273 "Issue of Slot Disable command failed\n"); 273 "Issue of Slot Disable command failed\n");
@@ -281,9 +281,9 @@ static int remove_board(struct slot *p_slot)
281 msleep(1000); 281 msleep(1000);
282 } 282 }
283 283
284 /* turn off Green LED */
284 if (PWR_LED(ctrl)) 285 if (PWR_LED(ctrl))
285 /* turn off Green LED */ 286 pciehp_green_led_off(p_slot);
286 p_slot->hpc_ops->green_led_off(p_slot);
287 287
288 return 0; 288 return 0;
289} 289}
@@ -320,9 +320,8 @@ static void pciehp_power_thread(struct work_struct *work)
320 break; 320 break;
321 case POWERON_STATE: 321 case POWERON_STATE:
322 mutex_unlock(&p_slot->lock); 322 mutex_unlock(&p_slot->lock);
323 if (pciehp_enable_slot(p_slot) && 323 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl))
324 PWR_LED(p_slot->ctrl)) 324 pciehp_green_led_off(p_slot);
325 p_slot->hpc_ops->green_led_off(p_slot);
326 mutex_lock(&p_slot->lock); 325 mutex_lock(&p_slot->lock);
327 p_slot->state = STATIC_STATE; 326 p_slot->state = STATIC_STATE;
328 break; 327 break;
@@ -373,10 +372,10 @@ static int update_slot_info(struct slot *slot)
373 if (!info) 372 if (!info)
374 return -ENOMEM; 373 return -ENOMEM;
375 374
376 slot->hpc_ops->get_power_status(slot, &(info->power_status)); 375 pciehp_get_power_status(slot, &info->power_status);
377 slot->hpc_ops->get_attention_status(slot, &(info->attention_status)); 376 pciehp_get_attention_status(slot, &info->attention_status);
378 slot->hpc_ops->get_latch_status(slot, &(info->latch_status)); 377 pciehp_get_latch_status(slot, &info->latch_status);
379 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status)); 378 pciehp_get_adapter_status(slot, &info->adapter_status);
380 379
381 result = pci_hp_change_slot_info(slot->hotplug_slot, info); 380 result = pci_hp_change_slot_info(slot->hotplug_slot, info);
382 kfree (info); 381 kfree (info);
@@ -393,7 +392,7 @@ static void handle_button_press_event(struct slot *p_slot)
393 392
394 switch (p_slot->state) { 393 switch (p_slot->state) {
395 case STATIC_STATE: 394 case STATIC_STATE:
396 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 395 pciehp_get_power_status(p_slot, &getstatus);
397 if (getstatus) { 396 if (getstatus) {
398 p_slot->state = BLINKINGOFF_STATE; 397 p_slot->state = BLINKINGOFF_STATE;
399 ctrl_info(ctrl, 398 ctrl_info(ctrl,
@@ -407,9 +406,9 @@ static void handle_button_press_event(struct slot *p_slot)
407 } 406 }
408 /* blink green LED and turn off amber */ 407 /* blink green LED and turn off amber */
409 if (PWR_LED(ctrl)) 408 if (PWR_LED(ctrl))
410 p_slot->hpc_ops->green_led_blink(p_slot); 409 pciehp_green_led_blink(p_slot);
411 if (ATTN_LED(ctrl)) 410 if (ATTN_LED(ctrl))
412 p_slot->hpc_ops->set_attention_status(p_slot, 0); 411 pciehp_set_attention_status(p_slot, 0);
413 412
414 schedule_delayed_work(&p_slot->work, 5*HZ); 413 schedule_delayed_work(&p_slot->work, 5*HZ);
415 break; 414 break;
@@ -424,13 +423,13 @@ static void handle_button_press_event(struct slot *p_slot)
424 cancel_delayed_work(&p_slot->work); 423 cancel_delayed_work(&p_slot->work);
425 if (p_slot->state == BLINKINGOFF_STATE) { 424 if (p_slot->state == BLINKINGOFF_STATE) {
426 if (PWR_LED(ctrl)) 425 if (PWR_LED(ctrl))
427 p_slot->hpc_ops->green_led_on(p_slot); 426 pciehp_green_led_on(p_slot);
428 } else { 427 } else {
429 if (PWR_LED(ctrl)) 428 if (PWR_LED(ctrl))
430 p_slot->hpc_ops->green_led_off(p_slot); 429 pciehp_green_led_off(p_slot);
431 } 430 }
432 if (ATTN_LED(ctrl)) 431 if (ATTN_LED(ctrl))
433 p_slot->hpc_ops->set_attention_status(p_slot, 0); 432 pciehp_set_attention_status(p_slot, 0);
434 ctrl_info(ctrl, "PCI slot #%s - action canceled " 433 ctrl_info(ctrl, "PCI slot #%s - action canceled "
435 "due to button press\n", slot_name(p_slot)); 434 "due to button press\n", slot_name(p_slot));
436 p_slot->state = STATIC_STATE; 435 p_slot->state = STATIC_STATE;
@@ -468,7 +467,7 @@ static void handle_surprise_event(struct slot *p_slot)
468 info->p_slot = p_slot; 467 info->p_slot = p_slot;
469 INIT_WORK(&info->work, pciehp_power_thread); 468 INIT_WORK(&info->work, pciehp_power_thread);
470 469
471 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 470 pciehp_get_adapter_status(p_slot, &getstatus);
472 if (!getstatus) 471 if (!getstatus)
473 p_slot->state = POWEROFF_STATE; 472 p_slot->state = POWEROFF_STATE;
474 else 473 else
@@ -492,9 +491,9 @@ static void interrupt_event_handler(struct work_struct *work)
492 if (!POWER_CTRL(ctrl)) 491 if (!POWER_CTRL(ctrl))
493 break; 492 break;
494 if (ATTN_LED(ctrl)) 493 if (ATTN_LED(ctrl))
495 p_slot->hpc_ops->set_attention_status(p_slot, 1); 494 pciehp_set_attention_status(p_slot, 1);
496 if (PWR_LED(ctrl)) 495 if (PWR_LED(ctrl))
497 p_slot->hpc_ops->green_led_off(p_slot); 496 pciehp_green_led_off(p_slot);
498 break; 497 break;
499 case INT_PRESENCE_ON: 498 case INT_PRESENCE_ON:
500 case INT_PRESENCE_OFF: 499 case INT_PRESENCE_OFF:
@@ -519,13 +518,13 @@ int pciehp_enable_slot(struct slot *p_slot)
519 int rc; 518 int rc;
520 struct controller *ctrl = p_slot->ctrl; 519 struct controller *ctrl = p_slot->ctrl;
521 520
522 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 521 rc = pciehp_get_adapter_status(p_slot, &getstatus);
523 if (rc || !getstatus) { 522 if (rc || !getstatus) {
524 ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot)); 523 ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot));
525 return -ENODEV; 524 return -ENODEV;
526 } 525 }
527 if (MRL_SENS(p_slot->ctrl)) { 526 if (MRL_SENS(p_slot->ctrl)) {
528 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 527 rc = pciehp_get_latch_status(p_slot, &getstatus);
529 if (rc || getstatus) { 528 if (rc || getstatus) {
530 ctrl_info(ctrl, "Latch open on slot(%s)\n", 529 ctrl_info(ctrl, "Latch open on slot(%s)\n",
531 slot_name(p_slot)); 530 slot_name(p_slot));
@@ -534,7 +533,7 @@ int pciehp_enable_slot(struct slot *p_slot)
534 } 533 }
535 534
536 if (POWER_CTRL(p_slot->ctrl)) { 535 if (POWER_CTRL(p_slot->ctrl)) {
537 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 536 rc = pciehp_get_power_status(p_slot, &getstatus);
538 if (rc || getstatus) { 537 if (rc || getstatus) {
539 ctrl_info(ctrl, "Already enabled on slot(%s)\n", 538 ctrl_info(ctrl, "Already enabled on slot(%s)\n",
540 slot_name(p_slot)); 539 slot_name(p_slot));
@@ -542,11 +541,11 @@ int pciehp_enable_slot(struct slot *p_slot)
542 } 541 }
543 } 542 }
544 543
545 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 544 pciehp_get_latch_status(p_slot, &getstatus);
546 545
547 rc = board_added(p_slot); 546 rc = board_added(p_slot);
548 if (rc) { 547 if (rc) {
549 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 548 pciehp_get_latch_status(p_slot, &getstatus);
550 } 549 }
551 550
552 update_slot_info(p_slot); 551 update_slot_info(p_slot);
@@ -565,7 +564,7 @@ int pciehp_disable_slot(struct slot *p_slot)
565 return 1; 564 return 1;
566 565
567 if (!HP_SUPR_RM(p_slot->ctrl)) { 566 if (!HP_SUPR_RM(p_slot->ctrl)) {
568 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 567 ret = pciehp_get_adapter_status(p_slot, &getstatus);
569 if (ret || !getstatus) { 568 if (ret || !getstatus) {
570 ctrl_info(ctrl, "No adapter on slot(%s)\n", 569 ctrl_info(ctrl, "No adapter on slot(%s)\n",
571 slot_name(p_slot)); 570 slot_name(p_slot));
@@ -574,7 +573,7 @@ int pciehp_disable_slot(struct slot *p_slot)
574 } 573 }
575 574
576 if (MRL_SENS(p_slot->ctrl)) { 575 if (MRL_SENS(p_slot->ctrl)) {
577 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 576 ret = pciehp_get_latch_status(p_slot, &getstatus);
578 if (ret || getstatus) { 577 if (ret || getstatus) {
579 ctrl_info(ctrl, "Latch open on slot(%s)\n", 578 ctrl_info(ctrl, "Latch open on slot(%s)\n",
580 slot_name(p_slot)); 579 slot_name(p_slot));
@@ -583,7 +582,7 @@ int pciehp_disable_slot(struct slot *p_slot)
583 } 582 }
584 583
585 if (POWER_CTRL(p_slot->ctrl)) { 584 if (POWER_CTRL(p_slot->ctrl)) {
586 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 585 ret = pciehp_get_power_status(p_slot, &getstatus);
587 if (ret || !getstatus) { 586 if (ret || !getstatus) {
588 ctrl_info(ctrl, "Already disabled on slot(%s)\n", 587 ctrl_info(ctrl, "Already disabled on slot(%s)\n",
589 slot_name(p_slot)); 588 slot_name(p_slot));
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 3867d9c47ebd..8c34e84fc0c7 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -266,7 +266,7 @@ static void pcie_wait_link_active(struct controller *ctrl)
266 ctrl_dbg(ctrl, "Data Link Layer Link Active not set in 1000 msec\n"); 266 ctrl_dbg(ctrl, "Data Link Layer Link Active not set in 1000 msec\n");
267} 267}
268 268
269static int hpc_check_lnk_status(struct controller *ctrl) 269int pciehp_check_link_status(struct controller *ctrl)
270{ 270{
271 u16 lnk_status; 271 u16 lnk_status;
272 int retval = 0; 272 int retval = 0;
@@ -305,7 +305,7 @@ static int hpc_check_lnk_status(struct controller *ctrl)
305 return retval; 305 return retval;
306} 306}
307 307
308static int hpc_get_attention_status(struct slot *slot, u8 *status) 308int pciehp_get_attention_status(struct slot *slot, u8 *status)
309{ 309{
310 struct controller *ctrl = slot->ctrl; 310 struct controller *ctrl = slot->ctrl;
311 u16 slot_ctrl; 311 u16 slot_ctrl;
@@ -344,7 +344,7 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
344 return 0; 344 return 0;
345} 345}
346 346
347static int hpc_get_power_status(struct slot *slot, u8 *status) 347int pciehp_get_power_status(struct slot *slot, u8 *status)
348{ 348{
349 struct controller *ctrl = slot->ctrl; 349 struct controller *ctrl = slot->ctrl;
350 u16 slot_ctrl; 350 u16 slot_ctrl;
@@ -376,7 +376,7 @@ static int hpc_get_power_status(struct slot *slot, u8 *status)
376 return retval; 376 return retval;
377} 377}
378 378
379static int hpc_get_latch_status(struct slot *slot, u8 *status) 379int pciehp_get_latch_status(struct slot *slot, u8 *status)
380{ 380{
381 struct controller *ctrl = slot->ctrl; 381 struct controller *ctrl = slot->ctrl;
382 u16 slot_status; 382 u16 slot_status;
@@ -392,7 +392,7 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status)
392 return 0; 392 return 0;
393} 393}
394 394
395static int hpc_get_adapter_status(struct slot *slot, u8 *status) 395int pciehp_get_adapter_status(struct slot *slot, u8 *status)
396{ 396{
397 struct controller *ctrl = slot->ctrl; 397 struct controller *ctrl = slot->ctrl;
398 u16 slot_status; 398 u16 slot_status;
@@ -408,7 +408,7 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status)
408 return 0; 408 return 0;
409} 409}
410 410
411static int hpc_query_power_fault(struct slot *slot) 411int pciehp_query_power_fault(struct slot *slot)
412{ 412{
413 struct controller *ctrl = slot->ctrl; 413 struct controller *ctrl = slot->ctrl;
414 u16 slot_status; 414 u16 slot_status;
@@ -422,7 +422,7 @@ static int hpc_query_power_fault(struct slot *slot)
422 return !!(slot_status & PCI_EXP_SLTSTA_PFD); 422 return !!(slot_status & PCI_EXP_SLTSTA_PFD);
423} 423}
424 424
425static int hpc_set_attention_status(struct slot *slot, u8 value) 425int pciehp_set_attention_status(struct slot *slot, u8 value)
426{ 426{
427 struct controller *ctrl = slot->ctrl; 427 struct controller *ctrl = slot->ctrl;
428 u16 slot_cmd; 428 u16 slot_cmd;
@@ -450,7 +450,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
450 return rc; 450 return rc;
451} 451}
452 452
453static void hpc_set_green_led_on(struct slot *slot) 453void pciehp_green_led_on(struct slot *slot)
454{ 454{
455 struct controller *ctrl = slot->ctrl; 455 struct controller *ctrl = slot->ctrl;
456 u16 slot_cmd; 456 u16 slot_cmd;
@@ -463,7 +463,7 @@ static void hpc_set_green_led_on(struct slot *slot)
463 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd); 463 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
464} 464}
465 465
466static void hpc_set_green_led_off(struct slot *slot) 466void pciehp_green_led_off(struct slot *slot)
467{ 467{
468 struct controller *ctrl = slot->ctrl; 468 struct controller *ctrl = slot->ctrl;
469 u16 slot_cmd; 469 u16 slot_cmd;
@@ -476,7 +476,7 @@ static void hpc_set_green_led_off(struct slot *slot)
476 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd); 476 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
477} 477}
478 478
479static void hpc_set_green_led_blink(struct slot *slot) 479void pciehp_green_led_blink(struct slot *slot)
480{ 480{
481 struct controller *ctrl = slot->ctrl; 481 struct controller *ctrl = slot->ctrl;
482 u16 slot_cmd; 482 u16 slot_cmd;
@@ -489,7 +489,7 @@ static void hpc_set_green_led_blink(struct slot *slot)
489 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd); 489 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
490} 490}
491 491
492static int hpc_power_on_slot(struct slot * slot) 492int pciehp_power_on_slot(struct slot * slot)
493{ 493{
494 struct controller *ctrl = slot->ctrl; 494 struct controller *ctrl = slot->ctrl;
495 u16 slot_cmd; 495 u16 slot_cmd;
@@ -568,7 +568,7 @@ static inline void pcie_unmask_bad_dllp(struct controller *ctrl)
568 pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, reg); 568 pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, reg);
569} 569}
570 570
571static int hpc_power_off_slot(struct slot * slot) 571int pciehp_power_off_slot(struct slot * slot)
572{ 572{
573 struct controller *ctrl = slot->ctrl; 573 struct controller *ctrl = slot->ctrl;
574 u16 slot_cmd; 574 u16 slot_cmd;
@@ -672,7 +672,7 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
672 return IRQ_HANDLED; 672 return IRQ_HANDLED;
673} 673}
674 674
675static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value) 675int pciehp_get_max_link_speed(struct slot *slot, enum pci_bus_speed *value)
676{ 676{
677 struct controller *ctrl = slot->ctrl; 677 struct controller *ctrl = slot->ctrl;
678 enum pcie_link_speed lnk_speed; 678 enum pcie_link_speed lnk_speed;
@@ -703,7 +703,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
703 return retval; 703 return retval;
704} 704}
705 705
706static int hpc_get_max_lnk_width(struct slot *slot, 706int pciehp_get_max_lnk_width(struct slot *slot,
707 enum pcie_link_width *value) 707 enum pcie_link_width *value)
708{ 708{
709 struct controller *ctrl = slot->ctrl; 709 struct controller *ctrl = slot->ctrl;
@@ -753,7 +753,7 @@ static int hpc_get_max_lnk_width(struct slot *slot,
753 return retval; 753 return retval;
754} 754}
755 755
756static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value) 756int pciehp_get_cur_link_speed(struct slot *slot, enum pci_bus_speed *value)
757{ 757{
758 struct controller *ctrl = slot->ctrl; 758 struct controller *ctrl = slot->ctrl;
759 enum pcie_link_speed lnk_speed = PCI_SPEED_UNKNOWN; 759 enum pcie_link_speed lnk_speed = PCI_SPEED_UNKNOWN;
@@ -785,7 +785,7 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
785 return retval; 785 return retval;
786} 786}
787 787
788static int hpc_get_cur_lnk_width(struct slot *slot, 788int pciehp_get_cur_lnk_width(struct slot *slot,
789 enum pcie_link_width *value) 789 enum pcie_link_width *value)
790{ 790{
791 struct controller *ctrl = slot->ctrl; 791 struct controller *ctrl = slot->ctrl;
@@ -836,30 +836,6 @@ static int hpc_get_cur_lnk_width(struct slot *slot,
836 return retval; 836 return retval;
837} 837}
838 838
839static void pcie_release_ctrl(struct controller *ctrl);
840static struct hpc_ops pciehp_hpc_ops = {
841 .power_on_slot = hpc_power_on_slot,
842 .power_off_slot = hpc_power_off_slot,
843 .set_attention_status = hpc_set_attention_status,
844 .get_power_status = hpc_get_power_status,
845 .get_attention_status = hpc_get_attention_status,
846 .get_latch_status = hpc_get_latch_status,
847 .get_adapter_status = hpc_get_adapter_status,
848
849 .get_max_bus_speed = hpc_get_max_lnk_speed,
850 .get_cur_bus_speed = hpc_get_cur_lnk_speed,
851 .get_max_lnk_width = hpc_get_max_lnk_width,
852 .get_cur_lnk_width = hpc_get_cur_lnk_width,
853
854 .query_power_fault = hpc_query_power_fault,
855 .green_led_on = hpc_set_green_led_on,
856 .green_led_off = hpc_set_green_led_off,
857 .green_led_blink = hpc_set_green_led_blink,
858
859 .release_ctlr = pcie_release_ctrl,
860 .check_lnk_status = hpc_check_lnk_status,
861};
862
863int pcie_enable_notification(struct controller *ctrl) 839int pcie_enable_notification(struct controller *ctrl)
864{ 840{
865 u16 cmd, mask; 841 u16 cmd, mask;
@@ -925,7 +901,6 @@ static int pcie_init_slot(struct controller *ctrl)
925 return -ENOMEM; 901 return -ENOMEM;
926 902
927 slot->ctrl = ctrl; 903 slot->ctrl = ctrl;
928 slot->hpc_ops = ctrl->hpc_ops;
929 slot->number = PSN(ctrl); 904 slot->number = PSN(ctrl);
930 mutex_init(&slot->lock); 905 mutex_init(&slot->lock);
931 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); 906 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
@@ -1015,7 +990,6 @@ struct controller *pcie_init(struct pcie_device *dev)
1015 } 990 }
1016 991
1017 ctrl->slot_cap = slot_cap; 992 ctrl->slot_cap = slot_cap;
1018 ctrl->hpc_ops = &pciehp_hpc_ops;
1019 mutex_init(&ctrl->ctrl_lock); 993 mutex_init(&ctrl->ctrl_lock);
1020 init_waitqueue_head(&ctrl->queue); 994 init_waitqueue_head(&ctrl->queue);
1021 dbg_ctrl(ctrl); 995 dbg_ctrl(ctrl);
@@ -1071,7 +1045,7 @@ abort:
1071 return NULL; 1045 return NULL;
1072} 1046}
1073 1047
1074void pcie_release_ctrl(struct controller *ctrl) 1048void pciehp_release_ctrl(struct controller *ctrl)
1075{ 1049{
1076 pcie_shutdown_notification(ctrl); 1050 pcie_shutdown_notification(ctrl);
1077 pcie_cleanup_slot(ctrl); 1051 pcie_cleanup_slot(ctrl);
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 002a72d9ad71..21733108adde 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -117,7 +117,7 @@ int pciehp_unconfigure_device(struct slot *p_slot)
117 117
118 ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n", 118 ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
119 __func__, pci_domain_nr(parent), parent->number); 119 __func__, pci_domain_nr(parent), parent->number);
120 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence); 120 ret = pciehp_get_adapter_status(p_slot, &presence);
121 if (ret) 121 if (ret)
122 presence = 0; 122 presence = 0;
123 123