diff options
author | Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> | 2006-01-25 19:56:53 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 17:35:11 -0500 |
commit | dfcd5f68ec916414532e88583d1557b6ac0197f5 (patch) | |
tree | 989e7bf165c50bfbe4dfbcbb579e532a111c7731 | |
parent | 926030f6af856d5681af7940239da2b0269cd755 (diff) |
[PATCH] shpchp - cleanup shpchp_core.c
This patch cleanups some codes in shpchp_core.c. This patch has no
functional changes.
Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/pci/hotplug/shpchp_core.c | 84 |
1 files changed, 36 insertions, 48 deletions
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 29261b8824c8..7f2e775534eb 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c | |||
@@ -213,9 +213,12 @@ static int get_ctlr_slot_config(struct controller *ctrl) | |||
213 | int rc; | 213 | int rc; |
214 | int flags; | 214 | int flags; |
215 | 215 | ||
216 | rc = shpc_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &updown, &flags); | 216 | rc = shpc_get_ctlr_slot_config(ctrl, &num_ctlr_slots, |
217 | &first_device_num, &physical_slot_num, | ||
218 | &updown, &flags); | ||
217 | if (rc) { | 219 | if (rc) { |
218 | err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl->bus, ctrl->device); | 220 | err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", |
221 | __FUNCTION__, ctrl->bus, ctrl->device); | ||
219 | return -1; | 222 | return -1; |
220 | } | 223 | } |
221 | 224 | ||
@@ -224,19 +227,19 @@ static int get_ctlr_slot_config(struct controller *ctrl) | |||
224 | ctrl->first_slot = physical_slot_num; | 227 | ctrl->first_slot = physical_slot_num; |
225 | ctrl->slot_num_inc = updown; /* either -1 or 1 */ | 228 | ctrl->slot_num_inc = updown; /* either -1 or 1 */ |
226 | 229 | ||
227 | dbg("%s: num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d (%x:%x)\n", | 230 | dbg("%s: num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d " |
228 | __FUNCTION__, num_ctlr_slots, first_device_num, physical_slot_num, updown, ctrl->bus, ctrl->device); | 231 | "(%x:%x)\n", __FUNCTION__, num_ctlr_slots, first_device_num, |
232 | physical_slot_num, updown, ctrl->bus, ctrl->device); | ||
229 | 233 | ||
230 | return 0; | 234 | return 0; |
231 | } | 235 | } |
232 | 236 | ||
233 | |||
234 | /* | 237 | /* |
235 | * set_attention_status - Turns the Amber LED for a slot on, off or blink | 238 | * set_attention_status - Turns the Amber LED for a slot on, off or blink |
236 | */ | 239 | */ |
237 | static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | 240 | static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) |
238 | { | 241 | { |
239 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 242 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
240 | 243 | ||
241 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 244 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
242 | 245 | ||
@@ -246,20 +249,18 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | |||
246 | return 0; | 249 | return 0; |
247 | } | 250 | } |
248 | 251 | ||
249 | |||
250 | static int enable_slot (struct hotplug_slot *hotplug_slot) | 252 | static int enable_slot (struct hotplug_slot *hotplug_slot) |
251 | { | 253 | { |
252 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 254 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
253 | 255 | ||
254 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 256 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
255 | 257 | ||
256 | return shpchp_enable_slot(slot); | 258 | return shpchp_enable_slot(slot); |
257 | } | 259 | } |
258 | 260 | ||
259 | |||
260 | static int disable_slot (struct hotplug_slot *hotplug_slot) | 261 | static int disable_slot (struct hotplug_slot *hotplug_slot) |
261 | { | 262 | { |
262 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 263 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
263 | 264 | ||
264 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 265 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
265 | 266 | ||
@@ -268,7 +269,7 @@ static int disable_slot (struct hotplug_slot *hotplug_slot) | |||
268 | 269 | ||
269 | static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) | 270 | static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) |
270 | { | 271 | { |
271 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 272 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
272 | int retval; | 273 | int retval; |
273 | 274 | ||
274 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 275 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -282,7 +283,7 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
282 | 283 | ||
283 | static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) | 284 | static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) |
284 | { | 285 | { |
285 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 286 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
286 | int retval; | 287 | int retval; |
287 | 288 | ||
288 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 289 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -296,7 +297,7 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
296 | 297 | ||
297 | static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) | 298 | static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) |
298 | { | 299 | { |
299 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 300 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
300 | int retval; | 301 | int retval; |
301 | 302 | ||
302 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 303 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -310,7 +311,7 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
310 | 311 | ||
311 | static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) | 312 | static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) |
312 | { | 313 | { |
313 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 314 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
314 | int retval; | 315 | int retval; |
315 | 316 | ||
316 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 317 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -324,7 +325,7 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
324 | 325 | ||
325 | static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) | 326 | static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) |
326 | { | 327 | { |
327 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 328 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
328 | struct pci_bus *bus = slot->ctrl->pci_dev->subordinate; | 329 | struct pci_bus *bus = slot->ctrl->pci_dev->subordinate; |
329 | 330 | ||
330 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 331 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -336,11 +337,11 @@ static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) | |||
336 | 337 | ||
337 | static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) | 338 | static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) |
338 | { | 339 | { |
339 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 340 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
340 | int retval; | 341 | int retval; |
341 | 342 | ||
342 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 343 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
343 | 344 | ||
344 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); | 345 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); |
345 | if (retval < 0) | 346 | if (retval < 0) |
346 | *value = PCI_SPEED_UNKNOWN; | 347 | *value = PCI_SPEED_UNKNOWN; |
@@ -350,11 +351,11 @@ static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp | |||
350 | 351 | ||
351 | static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) | 352 | static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) |
352 | { | 353 | { |
353 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 354 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
354 | int retval; | 355 | int retval; |
355 | 356 | ||
356 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 357 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
357 | 358 | ||
358 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); | 359 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); |
359 | if (retval < 0) | 360 | if (retval < 0) |
360 | *value = PCI_SPEED_UNKNOWN; | 361 | *value = PCI_SPEED_UNKNOWN; |
@@ -378,13 +379,13 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
378 | int rc; | 379 | int rc; |
379 | struct controller *ctrl; | 380 | struct controller *ctrl; |
380 | struct slot *t_slot; | 381 | struct slot *t_slot; |
381 | int first_device_num; /* first PCI device number supported by this SHPC */ | 382 | int first_device_num; /* first PCI device number */ |
382 | int num_ctlr_slots; /* number of slots supported by this SHPC */ | 383 | int num_ctlr_slots; /* number of slots implemented */ |
383 | 384 | ||
384 | if (!is_shpc_capable(pdev)) | 385 | if (!is_shpc_capable(pdev)) |
385 | return -ENODEV; | 386 | return -ENODEV; |
386 | 387 | ||
387 | ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); | 388 | ctrl = kmalloc(sizeof(struct controller), GFP_KERNEL); |
388 | if (!ctrl) { | 389 | if (!ctrl) { |
389 | err("%s : out of memory\n", __FUNCTION__); | 390 | err("%s : out of memory\n", __FUNCTION__); |
390 | goto err_out_none; | 391 | goto err_out_none; |
@@ -393,31 +394,32 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
393 | 394 | ||
394 | rc = shpc_init(ctrl, pdev); | 395 | rc = shpc_init(ctrl, pdev); |
395 | if (rc) { | 396 | if (rc) { |
396 | dbg("%s: controller initialization failed\n", SHPC_MODULE_NAME); | 397 | dbg("%s: controller initialization failed\n", |
398 | SHPC_MODULE_NAME); | ||
397 | goto err_out_free_ctrl; | 399 | goto err_out_free_ctrl; |
398 | } | 400 | } |
399 | 401 | ||
400 | pci_set_drvdata(pdev, ctrl); | 402 | pci_set_drvdata(pdev, ctrl); |
401 | 403 | ||
402 | ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL); | 404 | ctrl->pci_bus = kmalloc(sizeof (*ctrl->pci_bus), GFP_KERNEL); |
403 | if (!ctrl->pci_bus) { | 405 | if (!ctrl->pci_bus) { |
404 | err("out of memory\n"); | 406 | err("out of memory\n"); |
405 | rc = -ENOMEM; | 407 | rc = -ENOMEM; |
406 | goto err_out_unmap_mmio_region; | 408 | goto err_out_unmap_mmio_region; |
407 | } | 409 | } |
408 | 410 | ||
409 | memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus)); | 411 | memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus)); |
410 | ctrl->bus = pdev->bus->number; | 412 | ctrl->bus = pdev->bus->number; |
411 | ctrl->slot_bus = pdev->subordinate->number; | 413 | ctrl->slot_bus = pdev->subordinate->number; |
412 | |||
413 | ctrl->device = PCI_SLOT(pdev->devfn); | 414 | ctrl->device = PCI_SLOT(pdev->devfn); |
414 | ctrl->function = PCI_FUNC(pdev->devfn); | 415 | ctrl->function = PCI_FUNC(pdev->devfn); |
415 | dbg("ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", ctrl->bus, ctrl->device, ctrl->function, pdev->irq); | 416 | |
417 | dbg("ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", | ||
418 | ctrl->bus, ctrl->device, ctrl->function, pdev->irq); | ||
416 | 419 | ||
417 | /* | 420 | /* |
418 | * Save configuration headers for this and subordinate PCI buses | 421 | * Save configuration headers for this and subordinate PCI buses |
419 | */ | 422 | */ |
420 | |||
421 | rc = get_ctlr_slot_config(ctrl); | 423 | rc = get_ctlr_slot_config(ctrl); |
422 | if (rc) { | 424 | if (rc) { |
423 | err(msg_initialization_err, rc); | 425 | err(msg_initialization_err, rc); |
@@ -427,7 +429,7 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
427 | num_ctlr_slots = ctrl->num_slots; | 429 | num_ctlr_slots = ctrl->num_slots; |
428 | 430 | ||
429 | ctrl->add_support = 1; | 431 | ctrl->add_support = 1; |
430 | 432 | ||
431 | /* Setup the slot information structures */ | 433 | /* Setup the slot information structures */ |
432 | rc = init_slots(ctrl); | 434 | rc = init_slots(ctrl); |
433 | if (rc) { | 435 | if (rc) { |
@@ -443,7 +445,8 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
443 | dbg("%s: t_slot->hp_slot %x\n", __FUNCTION__,t_slot->hp_slot); | 445 | dbg("%s: t_slot->hp_slot %x\n", __FUNCTION__,t_slot->hp_slot); |
444 | 446 | ||
445 | if (rc || ctrl->speed == PCI_SPEED_UNKNOWN) { | 447 | if (rc || ctrl->speed == PCI_SPEED_UNKNOWN) { |
446 | err(SHPC_MODULE_NAME ": Can't get current bus speed. Set to 33MHz PCI.\n"); | 448 | err(SHPC_MODULE_NAME ": Can't get current bus speed. " |
449 | "Set to 33MHz PCI.\n"); | ||
447 | ctrl->speed = PCI_SPEED_33MHz; | 450 | ctrl->speed = PCI_SPEED_33MHz; |
448 | } | 451 | } |
449 | 452 | ||
@@ -474,11 +477,10 @@ err_out_none: | |||
474 | return -ENODEV; | 477 | return -ENODEV; |
475 | } | 478 | } |
476 | 479 | ||
477 | |||
478 | static int shpc_start_thread(void) | 480 | static int shpc_start_thread(void) |
479 | { | 481 | { |
480 | int retval = 0; | 482 | int retval = 0; |
481 | 483 | ||
482 | dbg("Initialize + Start the notification/polling mechanism \n"); | 484 | dbg("Initialize + Start the notification/polling mechanism \n"); |
483 | 485 | ||
484 | retval = shpchp_event_start_thread(); | 486 | retval = shpchp_event_start_thread(); |
@@ -515,24 +517,12 @@ static void __exit unload_shpchpd(void) | |||
515 | 517 | ||
516 | } | 518 | } |
517 | 519 | ||
518 | |||
519 | static struct pci_device_id shpcd_pci_tbl[] = { | 520 | static struct pci_device_id shpcd_pci_tbl[] = { |
520 | { | 521 | {PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0)}, |
521 | .class = ((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), | ||
522 | .class_mask = ~0, | ||
523 | .vendor = PCI_ANY_ID, | ||
524 | .device = PCI_ANY_ID, | ||
525 | .subvendor = PCI_ANY_ID, | ||
526 | .subdevice = PCI_ANY_ID, | ||
527 | }, | ||
528 | |||
529 | { /* end: all zeroes */ } | 522 | { /* end: all zeroes */ } |
530 | }; | 523 | }; |
531 | |||
532 | MODULE_DEVICE_TABLE(pci, shpcd_pci_tbl); | 524 | MODULE_DEVICE_TABLE(pci, shpcd_pci_tbl); |
533 | 525 | ||
534 | |||
535 | |||
536 | static struct pci_driver shpc_driver = { | 526 | static struct pci_driver shpc_driver = { |
537 | .name = SHPC_MODULE_NAME, | 527 | .name = SHPC_MODULE_NAME, |
538 | .id_table = shpcd_pci_tbl, | 528 | .id_table = shpcd_pci_tbl, |
@@ -540,8 +530,6 @@ static struct pci_driver shpc_driver = { | |||
540 | /* remove: shpc_remove_one, */ | 530 | /* remove: shpc_remove_one, */ |
541 | }; | 531 | }; |
542 | 532 | ||
543 | |||
544 | |||
545 | static int __init shpcd_init(void) | 533 | static int __init shpcd_init(void) |
546 | { | 534 | { |
547 | int retval = 0; | 535 | int retval = 0; |