diff options
author | Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> | 2009-10-05 04:42:59 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-11-04 12:01:59 -0500 |
commit | 445f798555e218a5601222ca5849e8553ddd866a (patch) | |
tree | 54437d660ae3a98b5480050e48f6ecf4051cb660 /drivers/pci/hotplug | |
parent | 586f1d6688c68a6c7fa4e6a00fa3968b16daef75 (diff) |
PCI: pciehp: return error on read/write failure
Current pciehp returns successfully on read/write failure with dummy
state values. It should return error instead.
With this patch, pciehp no longer uses hotplug_slot_info data
structure. So this also removes hotplug_slot_info related code. But
note that it still allocates hotplug_slot_info because it is required
by pci hotplug core.
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_core.c | 55 | ||||
-rw-r--r-- | drivers/pci/hotplug/pciehp_ctrl.c | 30 | ||||
-rw-r--r-- | drivers/pci/hotplug/pciehp_hpc.c | 29 |
3 files changed, 22 insertions, 92 deletions
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 77feafd39e29..d19f87594df4 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -135,15 +135,9 @@ static int init_slot(struct controller *ctrl) | |||
135 | ctrl->pcie->port->subordinate->number, PSN(ctrl)); | 135 | ctrl->pcie->port->subordinate->number, PSN(ctrl)); |
136 | retval = pci_hp_register(hotplug, | 136 | retval = pci_hp_register(hotplug, |
137 | ctrl->pcie->port->subordinate, 0, name); | 137 | ctrl->pcie->port->subordinate, 0, name); |
138 | if (retval) { | 138 | if (retval) |
139 | ctrl_err(ctrl, | 139 | ctrl_err(ctrl, |
140 | "pci_hp_register failed with error %d\n", retval); | 140 | "pci_hp_register failed with error %d\n", retval); |
141 | goto out; | ||
142 | } | ||
143 | get_power_status(hotplug, &info->power_status); | ||
144 | get_attention_status(hotplug, &info->attention_status); | ||
145 | get_latch_status(hotplug, &info->latch_status); | ||
146 | get_adapter_status(hotplug, &info->adapter_status); | ||
147 | out: | 141 | out: |
148 | if (retval) { | 142 | if (retval) { |
149 | kfree(ops); | 143 | kfree(ops); |
@@ -168,10 +162,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) | |||
168 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", | 162 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
169 | __func__, slot_name(slot)); | 163 | __func__, slot_name(slot)); |
170 | 164 | ||
171 | hotplug_slot->info->attention_status = status; | 165 | return pciehp_set_attention_status(slot, status); |
172 | pciehp_set_attention_status(slot, status); | ||
173 | |||
174 | return 0; | ||
175 | } | 166 | } |
176 | 167 | ||
177 | 168 | ||
@@ -199,92 +190,62 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) | |||
199 | static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) | 190 | static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) |
200 | { | 191 | { |
201 | struct slot *slot = hotplug_slot->private; | 192 | struct slot *slot = hotplug_slot->private; |
202 | int retval; | ||
203 | 193 | ||
204 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", | 194 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
205 | __func__, slot_name(slot)); | 195 | __func__, slot_name(slot)); |
206 | 196 | ||
207 | retval = pciehp_get_power_status(slot, value); | 197 | return pciehp_get_power_status(slot, value); |
208 | if (retval < 0) | ||
209 | *value = hotplug_slot->info->power_status; | ||
210 | |||
211 | return 0; | ||
212 | } | 198 | } |
213 | 199 | ||
214 | static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) | 200 | static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) |
215 | { | 201 | { |
216 | struct slot *slot = hotplug_slot->private; | 202 | struct slot *slot = hotplug_slot->private; |
217 | int retval; | ||
218 | 203 | ||
219 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", | 204 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
220 | __func__, slot_name(slot)); | 205 | __func__, slot_name(slot)); |
221 | 206 | ||
222 | retval = pciehp_get_attention_status(slot, value); | 207 | return pciehp_get_attention_status(slot, value); |
223 | if (retval < 0) | ||
224 | *value = hotplug_slot->info->attention_status; | ||
225 | |||
226 | return 0; | ||
227 | } | 208 | } |
228 | 209 | ||
229 | static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) | 210 | static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) |
230 | { | 211 | { |
231 | struct slot *slot = hotplug_slot->private; | 212 | struct slot *slot = hotplug_slot->private; |
232 | int retval; | ||
233 | 213 | ||
234 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", | 214 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
235 | __func__, slot_name(slot)); | 215 | __func__, slot_name(slot)); |
236 | 216 | ||
237 | retval = pciehp_get_latch_status(slot, value); | 217 | return pciehp_get_latch_status(slot, value); |
238 | if (retval < 0) | ||
239 | *value = hotplug_slot->info->latch_status; | ||
240 | |||
241 | return 0; | ||
242 | } | 218 | } |
243 | 219 | ||
244 | static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) | 220 | static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) |
245 | { | 221 | { |
246 | struct slot *slot = hotplug_slot->private; | 222 | struct slot *slot = hotplug_slot->private; |
247 | int retval; | ||
248 | 223 | ||
249 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", | 224 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
250 | __func__, slot_name(slot)); | 225 | __func__, slot_name(slot)); |
251 | 226 | ||
252 | retval = pciehp_get_adapter_status(slot, value); | 227 | return pciehp_get_adapter_status(slot, value); |
253 | if (retval < 0) | ||
254 | *value = hotplug_slot->info->adapter_status; | ||
255 | |||
256 | return 0; | ||
257 | } | 228 | } |
258 | 229 | ||
259 | static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, | 230 | static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, |
260 | enum pci_bus_speed *value) | 231 | enum pci_bus_speed *value) |
261 | { | 232 | { |
262 | struct slot *slot = hotplug_slot->private; | 233 | struct slot *slot = hotplug_slot->private; |
263 | int retval; | ||
264 | 234 | ||
265 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", | 235 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
266 | __func__, slot_name(slot)); | 236 | __func__, slot_name(slot)); |
267 | 237 | ||
268 | retval = pciehp_get_max_link_speed(slot, value); | 238 | return pciehp_get_max_link_speed(slot, value); |
269 | if (retval < 0) | ||
270 | *value = PCI_SPEED_UNKNOWN; | ||
271 | |||
272 | return 0; | ||
273 | } | 239 | } |
274 | 240 | ||
275 | static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) | 241 | static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) |
276 | { | 242 | { |
277 | struct slot *slot = hotplug_slot->private; | 243 | struct slot *slot = hotplug_slot->private; |
278 | int retval; | ||
279 | 244 | ||
280 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", | 245 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
281 | __func__, slot_name(slot)); | 246 | __func__, slot_name(slot)); |
282 | 247 | ||
283 | retval = pciehp_get_cur_link_speed(slot, value); | 248 | return pciehp_get_cur_link_speed(slot, value); |
284 | if (retval < 0) | ||
285 | *value = PCI_SPEED_UNKNOWN; | ||
286 | |||
287 | return 0; | ||
288 | } | 249 | } |
289 | 250 | ||
290 | static int pciehp_probe(struct pcie_device *dev) | 251 | static int pciehp_probe(struct pcie_device *dev) |
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 84487d126e4d..15ce2a3cc0f1 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -363,25 +363,6 @@ void pciehp_queue_pushbutton_work(struct work_struct *work) | |||
363 | mutex_unlock(&p_slot->lock); | 363 | mutex_unlock(&p_slot->lock); |
364 | } | 364 | } |
365 | 365 | ||
366 | static int update_slot_info(struct slot *slot) | ||
367 | { | ||
368 | struct hotplug_slot_info *info; | ||
369 | int result; | ||
370 | |||
371 | info = kmalloc(sizeof(*info), GFP_KERNEL); | ||
372 | if (!info) | ||
373 | return -ENOMEM; | ||
374 | |||
375 | pciehp_get_power_status(slot, &info->power_status); | ||
376 | pciehp_get_attention_status(slot, &info->attention_status); | ||
377 | pciehp_get_latch_status(slot, &info->latch_status); | ||
378 | pciehp_get_adapter_status(slot, &info->adapter_status); | ||
379 | |||
380 | result = pci_hp_change_slot_info(slot->hotplug_slot, info); | ||
381 | kfree (info); | ||
382 | return result; | ||
383 | } | ||
384 | |||
385 | /* | 366 | /* |
386 | * Note: This function must be called with slot->lock held | 367 | * Note: This function must be called with slot->lock held |
387 | */ | 368 | */ |
@@ -442,7 +423,6 @@ static void handle_button_press_event(struct slot *p_slot) | |||
442 | * to hot-add or hot-remove is undergoing | 423 | * to hot-add or hot-remove is undergoing |
443 | */ | 424 | */ |
444 | ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot)); | 425 | ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot)); |
445 | update_slot_info(p_slot); | ||
446 | break; | 426 | break; |
447 | default: | 427 | default: |
448 | ctrl_warn(ctrl, "Not a valid state\n"); | 428 | ctrl_warn(ctrl, "Not a valid state\n"); |
@@ -500,11 +480,9 @@ static void interrupt_event_handler(struct work_struct *work) | |||
500 | if (!HP_SUPR_RM(ctrl)) | 480 | if (!HP_SUPR_RM(ctrl)) |
501 | break; | 481 | break; |
502 | ctrl_dbg(ctrl, "Surprise Removal\n"); | 482 | ctrl_dbg(ctrl, "Surprise Removal\n"); |
503 | update_slot_info(p_slot); | ||
504 | handle_surprise_event(p_slot); | 483 | handle_surprise_event(p_slot); |
505 | break; | 484 | break; |
506 | default: | 485 | default: |
507 | update_slot_info(p_slot); | ||
508 | break; | 486 | break; |
509 | } | 487 | } |
510 | mutex_unlock(&p_slot->lock); | 488 | mutex_unlock(&p_slot->lock); |
@@ -547,9 +525,6 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
547 | if (rc) { | 525 | if (rc) { |
548 | pciehp_get_latch_status(p_slot, &getstatus); | 526 | pciehp_get_latch_status(p_slot, &getstatus); |
549 | } | 527 | } |
550 | |||
551 | update_slot_info(p_slot); | ||
552 | |||
553 | return rc; | 528 | return rc; |
554 | } | 529 | } |
555 | 530 | ||
@@ -590,10 +565,7 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
590 | } | 565 | } |
591 | } | 566 | } |
592 | 567 | ||
593 | ret = remove_board(p_slot); | 568 | return remove_board(p_slot); |
594 | update_slot_info(p_slot); | ||
595 | |||
596 | return ret; | ||
597 | } | 569 | } |
598 | 570 | ||
599 | int pciehp_sysfs_enable_slot(struct slot *p_slot) | 571 | int pciehp_sysfs_enable_slot(struct slot *p_slot) |
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 88b654ec5afc..7f35aff22362 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -427,27 +427,24 @@ int pciehp_set_attention_status(struct slot *slot, u8 value) | |||
427 | struct controller *ctrl = slot->ctrl; | 427 | struct controller *ctrl = slot->ctrl; |
428 | u16 slot_cmd; | 428 | u16 slot_cmd; |
429 | u16 cmd_mask; | 429 | u16 cmd_mask; |
430 | int rc; | ||
431 | 430 | ||
432 | cmd_mask = PCI_EXP_SLTCTL_AIC; | 431 | cmd_mask = PCI_EXP_SLTCTL_AIC; |
433 | switch (value) { | 432 | switch (value) { |
434 | case 0 : /* turn off */ | 433 | case 0 : /* turn off */ |
435 | slot_cmd = 0x00C0; | 434 | slot_cmd = 0x00C0; |
436 | break; | 435 | break; |
437 | case 1: /* turn on */ | 436 | case 1: /* turn on */ |
438 | slot_cmd = 0x0040; | 437 | slot_cmd = 0x0040; |
439 | break; | 438 | break; |
440 | case 2: /* turn blink */ | 439 | case 2: /* turn blink */ |
441 | slot_cmd = 0x0080; | 440 | slot_cmd = 0x0080; |
442 | break; | 441 | break; |
443 | default: | 442 | default: |
444 | return -1; | 443 | return -EINVAL; |
445 | } | 444 | } |
446 | rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); | ||
447 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", | 445 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", |
448 | __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd); | 446 | __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd); |
449 | 447 | return pcie_write_cmd(ctrl, slot_cmd, cmd_mask); | |
450 | return rc; | ||
451 | } | 448 | } |
452 | 449 | ||
453 | void pciehp_green_led_on(struct slot *slot) | 450 | void pciehp_green_led_on(struct slot *slot) |