aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorLinas Vepstas <linas@austin.ibm.com>2007-04-13 18:34:14 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-05-02 22:02:39 -0400
commitbf0af511fcc856649a2a39c627828695b580d124 (patch)
treef921e091364da84b19741e9054600695491a9707 /drivers/pci
parent427310ff02e80cc80826407c0121cec3694c9e7d (diff)
PCI: rpaphp: Remove another wrappered function
Remove another stove-pipe; this funcion was called from two different places, with a compile-time const that is then run-time checked to perform two different things. Signed-off-by: Linas Vepstas <linas@austin.ibm.com> Cc: John Rose <johnrose@austin.ibm.com> Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/hotplug/rpaphp.h1
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c16
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c59
3 files changed, 29 insertions, 47 deletions
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index fdd99b2ebe5..a2b22575cf7 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -89,7 +89,6 @@ extern struct list_head rpaphp_slot_head;
89/* rpaphp_pci.c */ 89/* rpaphp_pci.c */
90extern int rpaphp_enable_pci_slot(struct slot *slot); 90extern int rpaphp_enable_pci_slot(struct slot *slot);
91extern int rpaphp_register_pci_slot(struct slot *slot); 91extern int rpaphp_register_pci_slot(struct slot *slot);
92extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value);
93extern int rpaphp_get_sensor_state(struct slot *slot, int *state); 92extern int rpaphp_get_sensor_state(struct slot *slot, int *state);
94 93
95/* rpaphp_core.c */ 94/* rpaphp_core.c */
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 2d919fb1931..cab7cee6574 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -130,12 +130,22 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
130static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value) 130static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
131{ 131{
132 struct slot *slot = (struct slot *)hotplug_slot->private; 132 struct slot *slot = (struct slot *)hotplug_slot->private;
133 int retval = 0; 133 int rc, state;
134 134
135 down(&rpaphp_sem); 135 down(&rpaphp_sem);
136 retval = rpaphp_get_pci_adapter_status(slot, 0, value); 136 rc = rpaphp_get_sensor_state(slot, &state);
137 up(&rpaphp_sem); 137 up(&rpaphp_sem);
138 return retval; 138
139 *value = NOT_VALID;
140 if (rc)
141 return rc;
142
143 if (state == EMPTY)
144 *value = EMPTY;
145 else if (state == PRESENT)
146 *value = slot->state;
147
148 return 0;
139} 149}
140 150
141static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) 151static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index ba8c83770ab..b6a991ab9b7 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -64,43 +64,6 @@ int rpaphp_get_sensor_state(struct slot *slot, int *state)
64 return rc; 64 return rc;
65} 65}
66 66
67/**
68 * get_pci_adapter_status - get the status of a slot
69 *
70 * 0-- slot is empty
71 * 1-- adapter is configured
72 * 2-- adapter is not configured
73 * 3-- not valid
74 */
75int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value)
76{
77 struct pci_bus *bus;
78 int state, rc;
79
80 *value = NOT_VALID;
81 rc = rpaphp_get_sensor_state(slot, &state);
82 if (rc)
83 goto exit;
84
85 if (state == EMPTY)
86 *value = EMPTY;
87 else if (state == PRESENT) {
88 if (!is_init) {
89 /* at run-time slot->state can be changed by */
90 /* config/unconfig adapter */
91 *value = slot->state;
92 } else {
93 bus = pcibios_find_pci_bus(slot->dn);
94 if (bus && !list_empty(&bus->devices))
95 *value = CONFIGURED;
96 else
97 *value = NOT_CONFIGURED;
98 }
99 }
100exit:
101 return rc;
102}
103
104static void print_slot_pci_funcs(struct pci_bus *bus) 67static void print_slot_pci_funcs(struct pci_bus *bus)
105{ 68{
106 struct device_node *dn; 69 struct device_node *dn;
@@ -183,20 +146,30 @@ exit_rc:
183 146
184int rpaphp_register_pci_slot(struct slot *slot) 147int rpaphp_register_pci_slot(struct slot *slot)
185{ 148{
186 int rc, level; 149 int rc, level, state;
150 struct pci_bus *bus;
187 struct hotplug_slot_info *info = slot->hotplug_slot->info; 151 struct hotplug_slot_info *info = slot->hotplug_slot->info;
188 152
153 /* Find out if the power is turned on for the slot */
189 rc = rtas_get_power_level(slot->power_domain, &level); 154 rc = rtas_get_power_level(slot->power_domain, &level);
190 if (rc) 155 if (rc)
191 return rc; 156 return rc;
192 info->power_status = level; 157 info->power_status = level;
193 158
194 rpaphp_get_pci_adapter_status(slot, 1, &info->adapter_status); 159 /* Figure out if there is an adapter in the slot */
160 info->adapter_status = NOT_VALID;
161 rc = rpaphp_get_sensor_state(slot, &state);
162 if (rc)
163 return rc;
195 164
196 if (info->adapter_status == NOT_VALID) { 165 if (state == EMPTY)
197 err("%s: NOT_VALID: skip dn->full_name=%s\n", 166 info->adapter_status = EMPTY;
198 __FUNCTION__, slot->dn->full_name); 167 else if (state == PRESENT) {
199 return -EINVAL; 168 bus = pcibios_find_pci_bus(slot->dn);
169 if (bus && !list_empty(&bus->devices))
170 info->adapter_status = CONFIGURED;
171 else
172 info->adapter_status = NOT_CONFIGURED;
200 } 173 }
201 174
202 if (setup_pci_slot(slot)) 175 if (setup_pci_slot(slot))