aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/rpaphp_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/rpaphp_core.c')
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c38
1 files changed, 3 insertions, 35 deletions
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 4efdaa19e8f9..847936fe327e 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -39,7 +39,6 @@
39#include "rpaphp.h" 39#include "rpaphp.h"
40 40
41int debug; 41int debug;
42static struct semaphore rpaphp_sem;
43LIST_HEAD(rpaphp_slot_head); 42LIST_HEAD(rpaphp_slot_head);
44 43
45#define DRIVER_VERSION "0.1" 44#define DRIVER_VERSION "0.1"
@@ -66,7 +65,6 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
66 int rc; 65 int rc;
67 struct slot *slot = (struct slot *)hotplug_slot->private; 66 struct slot *slot = (struct slot *)hotplug_slot->private;
68 67
69 down(&rpaphp_sem);
70 switch (value) { 68 switch (value) {
71 case 0: 69 case 0:
72 case 1: 70 case 1:
@@ -76,7 +74,6 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
76 value = 1; 74 value = 1;
77 break; 75 break;
78 } 76 }
79 up(&rpaphp_sem);
80 77
81 rc = rtas_set_indicator(DR_INDICATOR, slot->index, value); 78 rc = rtas_set_indicator(DR_INDICATOR, slot->index, value);
82 if (!rc) 79 if (!rc)
@@ -95,11 +92,9 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
95 int retval, level; 92 int retval, level;
96 struct slot *slot = (struct slot *)hotplug_slot->private; 93 struct slot *slot = (struct slot *)hotplug_slot->private;
97 94
98 down(&rpaphp_sem);
99 retval = rtas_get_power_level (slot->power_domain, &level); 95 retval = rtas_get_power_level (slot->power_domain, &level);
100 if (!retval) 96 if (!retval)
101 *value = level; 97 *value = level;
102 up(&rpaphp_sem);
103 return retval; 98 return retval;
104} 99}
105 100
@@ -118,9 +113,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
118 struct slot *slot = (struct slot *)hotplug_slot->private; 113 struct slot *slot = (struct slot *)hotplug_slot->private;
119 int rc, state; 114 int rc, state;
120 115
121 down(&rpaphp_sem);
122 rc = rpaphp_get_sensor_state(slot, &state); 116 rc = rpaphp_get_sensor_state(slot, &state);
123 up(&rpaphp_sem);
124 117
125 *value = NOT_VALID; 118 *value = NOT_VALID;
126 if (rc) 119 if (rc)
@@ -138,7 +131,6 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
138{ 131{
139 struct slot *slot = (struct slot *)hotplug_slot->private; 132 struct slot *slot = (struct slot *)hotplug_slot->private;
140 133
141 down(&rpaphp_sem);
142 switch (slot->type) { 134 switch (slot->type) {
143 case 1: 135 case 1:
144 case 2: 136 case 2:
@@ -169,7 +161,6 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
169 break; 161 break;
170 162
171 } 163 }
172 up(&rpaphp_sem);
173 return 0; 164 return 0;
174} 165}
175 166
@@ -374,7 +365,6 @@ static int __init rpaphp_init(void)
374 struct device_node *dn = NULL; 365 struct device_node *dn = NULL;
375 366
376 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 367 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
377 init_MUTEX(&rpaphp_sem);
378 368
379 while ((dn = of_find_node_by_name(dn, "pci"))) 369 while ((dn = of_find_node_by_name(dn, "pci")))
380 rpaphp_add_slot(dn); 370 rpaphp_add_slot(dn);
@@ -387,8 +377,9 @@ static void __exit rpaphp_exit(void)
387 cleanup_slots(); 377 cleanup_slots();
388} 378}
389 379
390static int __enable_slot(struct slot *slot) 380static int enable_slot(struct hotplug_slot *hotplug_slot)
391{ 381{
382 struct slot *slot = (struct slot *)hotplug_slot->private;
392 int state; 383 int state;
393 int retval; 384 int retval;
394 385
@@ -412,20 +403,9 @@ static int __enable_slot(struct slot *slot)
412 return 0; 403 return 0;
413} 404}
414 405
415static int enable_slot(struct hotplug_slot *hotplug_slot) 406static int disable_slot(struct hotplug_slot *hotplug_slot)
416{ 407{
417 int retval;
418 struct slot *slot = (struct slot *)hotplug_slot->private; 408 struct slot *slot = (struct slot *)hotplug_slot->private;
419
420 down(&rpaphp_sem);
421 retval = __enable_slot(slot);
422 up(&rpaphp_sem);
423
424 return retval;
425}
426
427static inline int __disable_slot(struct slot *slot)
428{
429 if (slot->state == NOT_CONFIGURED) 409 if (slot->state == NOT_CONFIGURED)
430 return -EINVAL; 410 return -EINVAL;
431 411
@@ -434,18 +414,6 @@ static inline int __disable_slot(struct slot *slot)
434 return 0; 414 return 0;
435} 415}
436 416
437static int disable_slot(struct hotplug_slot *hotplug_slot)
438{
439 struct slot *slot = (struct slot *)hotplug_slot->private;
440 int retval;
441
442 down(&rpaphp_sem);
443 retval = __disable_slot (slot);
444 up(&rpaphp_sem);
445
446 return retval;
447}
448
449struct hotplug_slot_ops rpaphp_hotplug_slot_ops = { 417struct hotplug_slot_ops rpaphp_hotplug_slot_ops = {
450 .owner = THIS_MODULE, 418 .owner = THIS_MODULE,
451 .enable_slot = enable_slot, 419 .enable_slot = enable_slot,