aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorJohn Rose <johnrose@austin.ibm.com>2005-07-25 11:16:42 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-08 17:57:22 -0400
commit5eeb8c63a38ff20285f3bbe7bcfe5e7c33c8ba14 (patch)
tree81827bae5ac66dd8ca51cfe60740a64ca53e0759 /drivers/pci
parentbde168412440084e649e7e04938bd1ab6e7bf978 (diff)
[PATCH] PCI Hotplug: rpaphp: Move VIO registration
Currently, rpaphp registers Virtual I/O slots as hotplug slots. The only purpose of this registration is to ensure that the VIO subsystem is notified of new VIO buses during DLPAR adds. Similarly, rpaphp notifies the VIO subsystem when a VIO bus is DLPAR-removed. The rpaphp module has special case code to fake results for attributes like power, adapter status, etc. The VIO register/unregister functions could just as easily be made from the DLPAR module. This patch moves the VIO registration calls to the DLPAR module, and removes the VIO fluff from rpaphp altogether. Signed-off-by: John Rose <johnrose@austin.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/hotplug/Makefile3
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c110
-rw-r--r--drivers/pci/hotplug/rpaphp.h16
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c77
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c15
-rw-r--r--drivers/pci/hotplug/rpaphp_slot.c9
-rw-r--r--drivers/pci/hotplug/rpaphp_vio.c129
7 files changed, 88 insertions, 271 deletions
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
index 246586a3d91a..3c71e3077ff1 100644
--- a/drivers/pci/hotplug/Makefile
+++ b/drivers/pci/hotplug/Makefile
@@ -41,8 +41,7 @@ acpiphp-objs := acpiphp_core.o \
41 41
42rpaphp-objs := rpaphp_core.o \ 42rpaphp-objs := rpaphp_core.o \
43 rpaphp_pci.o \ 43 rpaphp_pci.o \
44 rpaphp_slot.o \ 44 rpaphp_slot.o
45 rpaphp_vio.o
46 45
47rpadlpar_io-objs := rpadlpar_core.o \ 46rpadlpar_io-objs := rpadlpar_core.o \
48 rpadlpar_sysfs.o 47 rpadlpar_sysfs.o
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 86b384e42717..d7f1319f167a 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -19,6 +19,7 @@
19#include <asm/pci-bridge.h> 19#include <asm/pci-bridge.h>
20#include <asm/semaphore.h> 20#include <asm/semaphore.h>
21#include <asm/rtas.h> 21#include <asm/rtas.h>
22#include <asm/vio.h>
22#include "../pci.h" 23#include "../pci.h"
23#include "rpaphp.h" 24#include "rpaphp.h"
24#include "rpadlpar.h" 25#include "rpadlpar.h"
@@ -29,23 +30,23 @@ static DECLARE_MUTEX(rpadlpar_sem);
29#define NODE_TYPE_SLOT 2 30#define NODE_TYPE_SLOT 2
30#define NODE_TYPE_PHB 3 31#define NODE_TYPE_PHB 3
31 32
32static struct device_node *find_php_slot_vio_node(char *drc_name) 33static struct device_node *find_vio_slot_node(char *drc_name)
33{ 34{
34 struct device_node *child;
35 struct device_node *parent = of_find_node_by_name(NULL, "vdevice"); 35 struct device_node *parent = of_find_node_by_name(NULL, "vdevice");
36 char *loc_code; 36 struct device_node *dn = NULL;
37 char *name;
38 int rc;
37 39
38 if (!parent) 40 if (!parent)
39 return NULL; 41 return NULL;
40 42
41 for (child = of_get_next_child(parent, NULL); 43 while ((dn = of_get_next_child(parent, dn))) {
42 child; child = of_get_next_child(parent, child)) { 44 rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL);
43 loc_code = get_property(child, "ibm,loc-code", NULL); 45 if ((rc == 0) && (!strcmp(drc_name, name)))
44 if (loc_code && !strncmp(loc_code, drc_name, strlen(drc_name))) 46 break;
45 return child;
46 } 47 }
47 48
48 return NULL; 49 return dn;
49} 50}
50 51
51/* Find dlpar-capable pci node that contains the specified name and type */ 52/* Find dlpar-capable pci node that contains the specified name and type */
@@ -67,7 +68,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name,
67 return np; 68 return np;
68} 69}
69 70
70static struct device_node *find_newly_added_node(char *drc_name, int *node_type) 71static struct device_node *find_dlpar_node(char *drc_name, int *node_type)
71{ 72{
72 struct device_node *dn; 73 struct device_node *dn;
73 74
@@ -83,7 +84,7 @@ static struct device_node *find_newly_added_node(char *drc_name, int *node_type)
83 return dn; 84 return dn;
84 } 85 }
85 86
86 dn = find_php_slot_vio_node(drc_name); 87 dn = find_vio_slot_node(drc_name);
87 if (dn) { 88 if (dn) {
88 *node_type = NODE_TYPE_VIO; 89 *node_type = NODE_TYPE_VIO;
89 return dn; 90 return dn;
@@ -231,6 +232,12 @@ static inline int dlpar_add_pci_slot(char *drc_name, struct device_node *dn)
231 return -EIO; 232 return -EIO;
232 } 233 }
233 234
235 /* Add hotplug slot */
236 if (rpaphp_add_slot(dn)) {
237 printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
238 __FUNCTION__, drc_name);
239 return -EIO;
240 }
234 return 0; 241 return 0;
235} 242}
236 243
@@ -288,7 +295,7 @@ static int dlpar_remove_phb(struct slot *slot)
288 return 0; 295 return 0;
289} 296}
290 297
291static int dlpar_add_phb(struct device_node *dn) 298static int dlpar_add_phb(char *drc_name, struct device_node *dn)
292{ 299{
293 struct pci_controller *phb; 300 struct pci_controller *phb;
294 301
@@ -296,6 +303,11 @@ static int dlpar_add_phb(struct device_node *dn)
296 if (!phb) 303 if (!phb)
297 return -EINVAL; 304 return -EINVAL;
298 305
306 if (rpaphp_add_slot(dn)) {
307 printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
308 __FUNCTION__, drc_name);
309 return -EIO;
310 }
299 return 0; 311 return 0;
300} 312}
301 313
@@ -316,7 +328,7 @@ int dlpar_add_slot(char *drc_name)
316{ 328{
317 struct device_node *dn = NULL; 329 struct device_node *dn = NULL;
318 int node_type; 330 int node_type;
319 int rc = 0; 331 int rc;
320 332
321 if (down_interruptible(&rpadlpar_sem)) 333 if (down_interruptible(&rpadlpar_sem))
322 return -ERESTARTSYS; 334 return -ERESTARTSYS;
@@ -327,32 +339,39 @@ int dlpar_add_slot(char *drc_name)
327 goto exit; 339 goto exit;
328 } 340 }
329 341
330 dn = find_newly_added_node(drc_name, &node_type); 342 /* Find newly added node */
343 dn = find_dlpar_node(drc_name, &node_type);
331 if (!dn) { 344 if (!dn) {
332 rc = -ENODEV; 345 rc = -ENODEV;
333 goto exit; 346 goto exit;
334 } 347 }
335 348
349 rc = -EIO;
336 switch (node_type) { 350 switch (node_type) {
337 case NODE_TYPE_VIO: 351 case NODE_TYPE_VIO:
338 /* Just add hotplug slot */ 352 if (!vio_register_device_node(dn)) {
353 printk(KERN_ERR
354 "%s: failed to register vio node %s\n",
355 __FUNCTION__, drc_name);
356 goto exit;
357 }
339 break; 358 break;
340 case NODE_TYPE_SLOT: 359 case NODE_TYPE_SLOT:
341 rc = dlpar_add_pci_slot(drc_name, dn); 360 rc = dlpar_add_pci_slot(drc_name, dn);
361 if (rc)
362 goto exit;
342 break; 363 break;
343 case NODE_TYPE_PHB: 364 case NODE_TYPE_PHB:
344 rc = dlpar_add_phb(dn); 365 rc = dlpar_add_phb(drc_name, dn);
366 if (rc)
367 goto exit;
345 break; 368 break;
346 default: 369 default:
347 printk("%s: unexpected node type\n", __FUNCTION__); 370 printk("%s: unexpected node type\n", __FUNCTION__);
348 return -EIO; 371 goto exit;
349 } 372 }
350 373
351 if (!rc && rpaphp_add_slot(dn)) { 374 rc = 0;
352 printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
353 __FUNCTION__, drc_name);
354 rc = -EIO;
355 }
356exit: 375exit:
357 up(&rpadlpar_sem); 376 up(&rpadlpar_sem);
358 return rc; 377 return rc;
@@ -368,15 +387,18 @@ exit:
368 * 0 Success 387 * 0 Success
369 * -EIO Internal Error 388 * -EIO Internal Error
370 */ 389 */
371int dlpar_remove_vio_slot(struct slot *slot, char *drc_name) 390static int dlpar_remove_vio_slot(struct device_node *dn, char *drc_name)
372{ 391{
373 /* Remove hotplug slot */ 392 struct vio_dev *vio_dev;
374 393
375 if (rpaphp_remove_slot(slot)) { 394 vio_dev = vio_find_node(dn);
376 printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", 395 if (!vio_dev) {
377 __FUNCTION__, drc_name); 396 printk(KERN_ERR "%s: %s does not correspond to a vio dev\n",
397 __FUNCTION__, drc_name);
378 return -EIO; 398 return -EIO;
379 } 399 }
400
401 vio_unregister_device(vio_dev);
380 return 0; 402 return 0;
381} 403}
382 404
@@ -434,36 +456,34 @@ int dlpar_remove_pci_slot(struct slot *slot, char *drc_name)
434 */ 456 */
435int dlpar_remove_slot(char *drc_name) 457int dlpar_remove_slot(char *drc_name)
436{ 458{
459 struct device_node *dn;
437 struct slot *slot; 460 struct slot *slot;
461 int node_type;
438 int rc = 0; 462 int rc = 0;
439 463
440 if (down_interruptible(&rpadlpar_sem)) 464 if (down_interruptible(&rpadlpar_sem))
441 return -ERESTARTSYS; 465 return -ERESTARTSYS;
442 466
443 if (!find_php_slot_vio_node(drc_name) && 467 dn = find_dlpar_node(drc_name, &node_type);
444 !find_php_slot_pci_node(drc_name, "SLOT") && 468 if (!dn) {
445 !find_php_slot_pci_node(drc_name, "PHB")) {
446 rc = -ENODEV; 469 rc = -ENODEV;
447 goto exit; 470 goto exit;
448 } 471 }
449 472
450 slot = find_slot(drc_name); 473 if (node_type == NODE_TYPE_VIO) {
451 if (!slot) { 474 rc = dlpar_remove_vio_slot(dn, drc_name);
452 rc = -EINVAL;
453 goto exit;
454 }
455
456 if (slot->type == PHB) {
457 rc = dlpar_remove_phb(slot);
458 } else { 475 } else {
459 switch (slot->dev_type) { 476 slot = find_slot(drc_name);
460 case PCI_DEV: 477 if (!slot) {
461 rc = dlpar_remove_pci_slot(slot, drc_name); 478 rc = -EINVAL;
462 break; 479 goto exit;
480 }
463 481
464 case VIO_DEV: 482 if (node_type == NODE_TYPE_PHB)
465 rc = dlpar_remove_vio_slot(slot, drc_name); 483 rc = dlpar_remove_phb(slot);
466 break; 484 else {
485 /* NODE_TYPE_SLOT */
486 rc = dlpar_remove_pci_slot(slot, drc_name);
467 } 487 }
468 } 488 }
469exit: 489exit:
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 25bea00b4f14..2d9f420dfa4f 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -61,10 +61,6 @@ extern int debug;
61#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 61#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
62#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 62#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
63 63
64/* slot types */
65#define VIO_DEV 1
66#define PCI_DEV 2
67
68/* slot states */ 64/* slot states */
69 65
70#define NOT_VALID 3 66#define NOT_VALID 3
@@ -84,14 +80,10 @@ struct slot {
84 char *name; 80 char *name;
85 char *location; 81 char *location;
86 u8 removable; 82 u8 removable;
87 u8 dev_type; /* VIO or PCI */
88 struct device_node *dn; /* slot's device_node in OFDT */ 83 struct device_node *dn; /* slot's device_node in OFDT */
89 /* dn has phb info */ 84 /* dn has phb info */
90 struct pci_dev *bridge; /* slot's pci_dev in pci_devices */ 85 struct pci_dev *bridge; /* slot's pci_dev in pci_devices */
91 union { 86 struct list_head *pci_devs; /* pci_devs in PCI slot */
92 struct list_head *pci_devs; /* pci_devs in PCI slot */
93 struct vio_dev *vio_dev; /* vio_dev in VIO slot */
94 } dev;
95 struct hotplug_slot *hotplug_slot; 87 struct hotplug_slot *hotplug_slot;
96}; 88};
97 89
@@ -115,12 +107,6 @@ extern int rpaphp_remove_slot(struct slot *slot);
115extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, 107extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
116 char **drc_name, char **drc_type, int *drc_power_domain); 108 char **drc_name, char **drc_type, int *drc_power_domain);
117 109
118/* rpaphp_vio.c */
119extern int rpaphp_get_vio_adapter_status(struct slot *slot, int is_init, u8 * value);
120extern int rpaphp_unconfig_vio_adapter(struct slot *slot);
121extern int register_vio_slot(struct device_node *dn);
122extern int rpaphp_enable_vio_slot(struct slot *slot);
123
124/* rpaphp_slot.c */ 110/* rpaphp_slot.c */
125extern void dealloc_slot_struct(struct slot *slot); 111extern void dealloc_slot_struct(struct slot *slot);
126extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain); 112extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 29117a3a3287..22ec0993cf89 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -152,17 +152,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
152 int retval = 0; 152 int retval = 0;
153 153
154 down(&rpaphp_sem); 154 down(&rpaphp_sem);
155 /* have to go through this */ 155 retval = rpaphp_get_pci_adapter_status(slot, 0, value);
156 switch (slot->dev_type) {
157 case PCI_DEV:
158 retval = rpaphp_get_pci_adapter_status(slot, 0, value);
159 break;
160 case VIO_DEV:
161 retval = rpaphp_get_vio_adapter_status(slot, 0, value);
162 break;
163 default:
164 retval = -EINVAL;
165 }
166 up(&rpaphp_sem); 156 up(&rpaphp_sem);
167 return retval; 157 return retval;
168} 158}
@@ -362,12 +352,6 @@ int rpaphp_add_slot(struct device_node *dn)
362 352
363 dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name); 353 dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name);
364 354
365 if (dn->parent && is_vdevice_root(dn->parent)) {
366 /* register a VIO device */
367 retval = register_vio_slot(dn);
368 goto exit;
369 }
370
371 /* register PCI devices */ 355 /* register PCI devices */
372 if (dn->name != 0 && strcmp(dn->name, "pci") == 0) { 356 if (dn->name != 0 && strcmp(dn->name, "pci") == 0) {
373 if (is_php_dn(dn, &indexes, &names, &types, &power_domains)) 357 if (is_php_dn(dn, &indexes, &names, &types, &power_domains))
@@ -412,31 +396,6 @@ exit:
412 return retval; 396 return retval;
413} 397}
414 398
415/*
416 * init_slots - initialize 'struct slot' structures for each slot
417 *
418 */
419static void init_slots(void)
420{
421 struct device_node *dn;
422
423 for (dn = find_all_nodes(); dn; dn = dn->next)
424 rpaphp_add_slot(dn);
425}
426
427static int __init init_rpa(void)
428{
429
430 init_MUTEX(&rpaphp_sem);
431
432 /* initialize internal data structure etc. */
433 init_slots();
434 if (!num_slots)
435 return -ENODEV;
436
437 return 0;
438}
439
440static void __exit cleanup_slots(void) 399static void __exit cleanup_slots(void)
441{ 400{
442 struct list_head *tmp, *n; 401 struct list_head *tmp, *n;
@@ -458,10 +417,18 @@ static void __exit cleanup_slots(void)
458 417
459static int __init rpaphp_init(void) 418static int __init rpaphp_init(void)
460{ 419{
420 struct device_node *dn = NULL;
421
461 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 422 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
423 init_MUTEX(&rpaphp_sem);
424
425 while ((dn = of_find_node_by_type(dn, "pci")))
426 rpaphp_add_slot(dn);
427
428 if (!num_slots)
429 return -ENODEV;
462 430
463 /* read all the PRA info from the system */ 431 return 0;
464 return init_rpa();
465} 432}
466 433
467static void __exit rpaphp_exit(void) 434static void __exit rpaphp_exit(void)
@@ -481,16 +448,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
481 448
482 dbg("ENABLING SLOT %s\n", slot->name); 449 dbg("ENABLING SLOT %s\n", slot->name);
483 down(&rpaphp_sem); 450 down(&rpaphp_sem);
484 switch (slot->dev_type) { 451 retval = rpaphp_enable_pci_slot(slot);
485 case PCI_DEV:
486 retval = rpaphp_enable_pci_slot(slot);
487 break;
488 case VIO_DEV:
489 retval = rpaphp_enable_vio_slot(slot);
490 break;
491 default:
492 retval = -EINVAL;
493 }
494 up(&rpaphp_sem); 452 up(&rpaphp_sem);
495exit: 453exit:
496 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); 454 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
@@ -511,16 +469,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
511 469
512 dbg("DISABLING SLOT %s\n", slot->name); 470 dbg("DISABLING SLOT %s\n", slot->name);
513 down(&rpaphp_sem); 471 down(&rpaphp_sem);
514 switch (slot->dev_type) { 472 retval = rpaphp_unconfig_pci_adapter(slot);
515 case PCI_DEV:
516 retval = rpaphp_unconfig_pci_adapter(slot);
517 break;
518 case VIO_DEV:
519 retval = rpaphp_unconfig_vio_adapter(slot);
520 break;
521 default:
522 retval = -ENODEV;
523 }
524 up(&rpaphp_sem); 473 up(&rpaphp_sem);
525exit: 474exit:
526 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); 475 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index ab67d3d1a59c..30d10fcc24b2 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -265,11 +265,9 @@ static void print_slot_pci_funcs(struct slot *slot)
265{ 265{
266 struct pci_dev *dev; 266 struct pci_dev *dev;
267 267
268 if (slot->dev_type == PCI_DEV) { 268 dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, slot->name);
269 dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, slot->name); 269 list_for_each_entry (dev, slot->pci_devs, bus_list)
270 list_for_each_entry (dev, slot->dev.pci_devs, bus_list) 270 dbg("\t%s\n", pci_name(dev));
271 dbg("\t%s\n", pci_name(dev));
272 }
273 return; 271 return;
274} 272}
275 273
@@ -328,7 +326,7 @@ int rpaphp_unconfig_pci_adapter(struct slot *slot)
328 struct pci_dev *dev; 326 struct pci_dev *dev;
329 int retval = 0; 327 int retval = 0;
330 328
331 list_for_each_entry(dev, slot->dev.pci_devs, bus_list) 329 list_for_each_entry(dev, slot->pci_devs, bus_list)
332 rpaphp_eeh_remove_bus_device(dev); 330 rpaphp_eeh_remove_bus_device(dev);
333 331
334 pci_remove_behind_bridge(slot->bridge); 332 pci_remove_behind_bridge(slot->bridge);
@@ -401,7 +399,7 @@ static int setup_pci_slot(struct slot *slot)
401 bus = slot->bridge->subordinate; 399 bus = slot->bridge->subordinate;
402 if (!bus) 400 if (!bus)
403 goto exit_rc; 401 goto exit_rc;
404 slot->dev.pci_devs = &bus->devices; 402 slot->pci_devs = &bus->devices;
405 403
406 dbg("%s set slot->name to %s\n", __FUNCTION__, 404 dbg("%s set slot->name to %s\n", __FUNCTION__,
407 pci_name(slot->bridge)); 405 pci_name(slot->bridge));
@@ -434,7 +432,7 @@ static int setup_pci_slot(struct slot *slot)
434 goto exit_rc; 432 goto exit_rc;
435 } 433 }
436 print_slot_pci_funcs(slot); 434 print_slot_pci_funcs(slot);
437 if (!list_empty(slot->dev.pci_devs)) { 435 if (!list_empty(slot->pci_devs)) {
438 slot->state = CONFIGURED; 436 slot->state = CONFIGURED;
439 } else { 437 } else {
440 /* DLPAR add as opposed to 438 /* DLPAR add as opposed to
@@ -452,7 +450,6 @@ int register_pci_slot(struct slot *slot)
452{ 450{
453 int rc = -EINVAL; 451 int rc = -EINVAL;
454 452
455 slot->dev_type = PCI_DEV;
456 if ((slot->type == EMBEDDED) || (slot->type == PHB)) 453 if ((slot->type == EMBEDDED) || (slot->type == PHB))
457 slot->removable = 0; 454 slot->removable = 0;
458 else 455 else
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index ff2cbf0652d8..80402027c015 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -220,13 +220,8 @@ int register_slot(struct slot *slot)
220 __FUNCTION__, slot->name); 220 __FUNCTION__, slot->name);
221 221
222 list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head); 222 list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head);
223 223 info("Slot [%s](PCI location=%s) registered\n", slot->name,
224 if (slot->dev_type == VIO_DEV) 224 slot->location);
225 info("Slot [%s](VIO location=%s) registered\n",
226 slot->name, slot->location);
227 else
228 info("Slot [%s](PCI location=%s) registered\n",
229 slot->name, slot->location);
230 num_slots++; 225 num_slots++;
231 return 0; 226 return 0;
232} 227}
diff --git a/drivers/pci/hotplug/rpaphp_vio.c b/drivers/pci/hotplug/rpaphp_vio.c
deleted file mode 100644
index 74df6a305e64..000000000000
--- a/drivers/pci/hotplug/rpaphp_vio.c
+++ /dev/null
@@ -1,129 +0,0 @@
1/*
2 * RPA Hot Plug Virtual I/O device functions
3 * Copyright (C) 2004 Linda Xie <lxie@us.ibm.com>
4 *
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
15 * NON INFRINGEMENT. See the GNU General Public License for more
16 * details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * Send feedback to <lxie@us.ibm.com>
23 *
24 */
25#include <asm/vio.h>
26#include "rpaphp.h"
27
28/*
29 * get_vio_adapter_status - get the status of a slot
30 *
31 * status:
32 *
33 * 1-- adapter is configured
34 * 2-- adapter is not configured
35 * 3-- not valid
36 */
37inline int rpaphp_get_vio_adapter_status(struct slot *slot, int is_init, u8 *value)
38{
39 *value = slot->state;
40 return 0;
41}
42
43int rpaphp_unconfig_vio_adapter(struct slot *slot)
44{
45 int retval = 0;
46
47 dbg("Entry %s: slot[%s]\n", __FUNCTION__, slot->name);
48 if (!slot->dev.vio_dev) {
49 info("%s: no VIOA in slot[%s]\n", __FUNCTION__, slot->name);
50 retval = -EINVAL;
51 goto exit;
52 }
53 /* remove the device from the vio core */
54 vio_unregister_device(slot->dev.vio_dev);
55 slot->state = NOT_CONFIGURED;
56 info("%s: adapter in slot[%s] unconfigured.\n", __FUNCTION__, slot->name);
57exit:
58 dbg("Exit %s, rc=0x%x\n", __FUNCTION__, retval);
59 return retval;
60}
61
62static int setup_vio_hotplug_slot_info(struct slot *slot)
63{
64 slot->hotplug_slot->info->power_status = 1;
65 rpaphp_get_vio_adapter_status(slot, 1,
66 &slot->hotplug_slot->info->adapter_status);
67 return 0;
68}
69
70int register_vio_slot(struct device_node *dn)
71{
72 u32 *index;
73 char *name;
74 int rc = -EINVAL;
75 struct slot *slot = NULL;
76
77 rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL);
78 if (rc < 0)
79 goto exit_rc;
80 index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL);
81 if (!index)
82 goto exit_rc;
83 if (!(slot = alloc_slot_struct(dn, *index, name, 0))) {
84 rc = -ENOMEM;
85 goto exit_rc;
86 }
87 slot->dev_type = VIO_DEV;
88 slot->dev.vio_dev = vio_find_node(dn);
89 if (slot->dev.vio_dev) {
90 /*
91 * rpaphp is the only owner of vio devices and
92 * does not need extra reference taken by
93 * vio_find_node
94 */
95 put_device(&slot->dev.vio_dev->dev);
96 } else
97 slot->dev.vio_dev = vio_register_device_node(dn);
98 if (slot->dev.vio_dev)
99 slot->state = CONFIGURED;
100 else
101 slot->state = NOT_CONFIGURED;
102 if (setup_vio_hotplug_slot_info(slot))
103 goto exit_rc;
104 strcpy(slot->name, slot->dev.vio_dev->dev.bus_id);
105 info("%s: registered VIO device[name=%s vio_dev=%p]\n",
106 __FUNCTION__, slot->name, slot->dev.vio_dev);
107 rc = register_slot(slot);
108exit_rc:
109 if (rc && slot)
110 dealloc_slot_struct(slot);
111 return (rc);
112}
113
114int rpaphp_enable_vio_slot(struct slot *slot)
115{
116 int retval = 0;
117
118 if ((slot->dev.vio_dev = vio_register_device_node(slot->dn))) {
119 info("%s: VIO adapter %s in slot[%s] has been configured\n",
120 __FUNCTION__, slot->dn->name, slot->name);
121 slot->state = CONFIGURED;
122 } else {
123 info("%s: no vio_dev struct for adapter in slot[%s]\n",
124 __FUNCTION__, slot->name);
125 slot->state = NOT_CONFIGURED;
126 }
127
128 return retval;
129}