aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>2009-06-15 22:00:47 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-06-16 17:30:11 -0400
commit498a8faf2c7eb974f70b7c5a60a31f0d48c35d44 (patch)
treeb7703de6971327eacbb5471bb251a05b9c3f56ea
parentbd3d99c17039fd05a29587db3f4a180c48da115a (diff)
PCI hotplug: fix return value of has_foo() functions
Current has_foo() functions in pci_hotplug_core.c returns 0 if the "foo" property is true. It would cause misunderstanding. In addition, the error code of those functions is never checked, so this patch changes those functions' error code to 'bool' and return true if the property "foo" is true. Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Reviewed-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c132
1 files changed, 68 insertions, 64 deletions
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 535fce0f07f9..ff32c6b4ae13 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -347,125 +347,126 @@ static struct pci_slot_attribute hotplug_slot_attr_test = {
347 .store = test_write_file 347 .store = test_write_file
348}; 348};
349 349
350static int has_power_file(struct pci_slot *pci_slot) 350static bool has_power_file(struct pci_slot *pci_slot)
351{ 351{
352 struct hotplug_slot *slot = pci_slot->hotplug; 352 struct hotplug_slot *slot = pci_slot->hotplug;
353 if ((!slot) || (!slot->ops)) 353 if ((!slot) || (!slot->ops))
354 return -ENODEV; 354 return false;
355 if ((slot->ops->enable_slot) || 355 if ((slot->ops->enable_slot) ||
356 (slot->ops->disable_slot) || 356 (slot->ops->disable_slot) ||
357 (slot->ops->get_power_status)) 357 (slot->ops->get_power_status))
358 return 0; 358 return true;
359 return -ENOENT; 359 return false;
360} 360}
361 361
362static int has_attention_file(struct pci_slot *pci_slot) 362static bool has_attention_file(struct pci_slot *pci_slot)
363{ 363{
364 struct hotplug_slot *slot = pci_slot->hotplug; 364 struct hotplug_slot *slot = pci_slot->hotplug;
365 if ((!slot) || (!slot->ops)) 365 if ((!slot) || (!slot->ops))
366 return -ENODEV; 366 return false;
367 if ((slot->ops->set_attention_status) || 367 if ((slot->ops->set_attention_status) ||
368 (slot->ops->get_attention_status)) 368 (slot->ops->get_attention_status))
369 return 0; 369 return true;
370 return -ENOENT; 370 return false;
371} 371}
372 372
373static int has_latch_file(struct pci_slot *pci_slot) 373static bool has_latch_file(struct pci_slot *pci_slot)
374{ 374{
375 struct hotplug_slot *slot = pci_slot->hotplug; 375 struct hotplug_slot *slot = pci_slot->hotplug;
376 if ((!slot) || (!slot->ops)) 376 if ((!slot) || (!slot->ops))
377 return -ENODEV; 377 return false;
378 if (slot->ops->get_latch_status) 378 if (slot->ops->get_latch_status)
379 return 0; 379 return true;
380 return -ENOENT; 380 return false;
381} 381}
382 382
383static int has_adapter_file(struct pci_slot *pci_slot) 383static bool has_adapter_file(struct pci_slot *pci_slot)
384{ 384{
385 struct hotplug_slot *slot = pci_slot->hotplug; 385 struct hotplug_slot *slot = pci_slot->hotplug;
386 if ((!slot) || (!slot->ops)) 386 if ((!slot) || (!slot->ops))
387 return -ENODEV; 387 return false;
388 if (slot->ops->get_adapter_status) 388 if (slot->ops->get_adapter_status)
389 return 0; 389 return true;
390 return -ENOENT; 390 return false;
391} 391}
392 392
393static int has_max_bus_speed_file(struct pci_slot *pci_slot) 393static bool has_max_bus_speed_file(struct pci_slot *pci_slot)
394{ 394{
395 struct hotplug_slot *slot = pci_slot->hotplug; 395 struct hotplug_slot *slot = pci_slot->hotplug;
396 if ((!slot) || (!slot->ops)) 396 if ((!slot) || (!slot->ops))
397 return -ENODEV; 397 return false;
398 if (slot->ops->get_max_bus_speed) 398 if (slot->ops->get_max_bus_speed)
399 return 0; 399 return true;
400 return -ENOENT; 400 return false;
401} 401}
402 402
403static int has_cur_bus_speed_file(struct pci_slot *pci_slot) 403static bool has_cur_bus_speed_file(struct pci_slot *pci_slot)
404{ 404{
405 struct hotplug_slot *slot = pci_slot->hotplug; 405 struct hotplug_slot *slot = pci_slot->hotplug;
406 if ((!slot) || (!slot->ops)) 406 if ((!slot) || (!slot->ops))
407 return -ENODEV; 407 return false;
408 if (slot->ops->get_cur_bus_speed) 408 if (slot->ops->get_cur_bus_speed)
409 return 0; 409 return true;
410 return -ENOENT; 410 return false;
411} 411}
412 412
413static int has_test_file(struct pci_slot *pci_slot) 413static bool has_test_file(struct pci_slot *pci_slot)
414{ 414{
415 struct hotplug_slot *slot = pci_slot->hotplug; 415 struct hotplug_slot *slot = pci_slot->hotplug;
416 if ((!slot) || (!slot->ops)) 416 if ((!slot) || (!slot->ops))
417 return -ENODEV; 417 return false;
418 if (slot->ops->hardware_test) 418 if (slot->ops->hardware_test)
419 return 0; 419 return true;
420 return -ENOENT; 420 return false;
421} 421}
422 422
423static int fs_add_slot(struct pci_slot *slot) 423static int fs_add_slot(struct pci_slot *slot)
424{ 424{
425 int retval = 0; 425 int retval = 0;
426 426
427 if (has_power_file(slot) == 0) { 427 if (has_power_file(slot)) {
428 retval = sysfs_create_file(&slot->kobj, &hotplug_slot_attr_power.attr); 428 retval = sysfs_create_file(&slot->kobj,
429 &hotplug_slot_attr_power.attr);
429 if (retval) 430 if (retval)
430 goto exit_power; 431 goto exit_power;
431 } 432 }
432 433
433 if (has_attention_file(slot) == 0) { 434 if (has_attention_file(slot)) {
434 retval = sysfs_create_file(&slot->kobj, 435 retval = sysfs_create_file(&slot->kobj,
435 &hotplug_slot_attr_attention.attr); 436 &hotplug_slot_attr_attention.attr);
436 if (retval) 437 if (retval)
437 goto exit_attention; 438 goto exit_attention;
438 } 439 }
439 440
440 if (has_latch_file(slot) == 0) { 441 if (has_latch_file(slot)) {
441 retval = sysfs_create_file(&slot->kobj, 442 retval = sysfs_create_file(&slot->kobj,
442 &hotplug_slot_attr_latch.attr); 443 &hotplug_slot_attr_latch.attr);
443 if (retval) 444 if (retval)
444 goto exit_latch; 445 goto exit_latch;
445 } 446 }
446 447
447 if (has_adapter_file(slot) == 0) { 448 if (has_adapter_file(slot)) {
448 retval = sysfs_create_file(&slot->kobj, 449 retval = sysfs_create_file(&slot->kobj,
449 &hotplug_slot_attr_presence.attr); 450 &hotplug_slot_attr_presence.attr);
450 if (retval) 451 if (retval)
451 goto exit_adapter; 452 goto exit_adapter;
452 } 453 }
453 454
454 if (has_max_bus_speed_file(slot) == 0) { 455 if (has_max_bus_speed_file(slot)) {
455 retval = sysfs_create_file(&slot->kobj, 456 retval = sysfs_create_file(&slot->kobj,
456 &hotplug_slot_attr_max_bus_speed.attr); 457 &hotplug_slot_attr_max_bus_speed.attr);
457 if (retval) 458 if (retval)
458 goto exit_max_speed; 459 goto exit_max_speed;
459 } 460 }
460 461
461 if (has_cur_bus_speed_file(slot) == 0) { 462 if (has_cur_bus_speed_file(slot)) {
462 retval = sysfs_create_file(&slot->kobj, 463 retval = sysfs_create_file(&slot->kobj,
463 &hotplug_slot_attr_cur_bus_speed.attr); 464 &hotplug_slot_attr_cur_bus_speed.attr);
464 if (retval) 465 if (retval)
465 goto exit_cur_speed; 466 goto exit_cur_speed;
466 } 467 }
467 468
468 if (has_test_file(slot) == 0) { 469 if (has_test_file(slot)) {
469 retval = sysfs_create_file(&slot->kobj, 470 retval = sysfs_create_file(&slot->kobj,
470 &hotplug_slot_attr_test.attr); 471 &hotplug_slot_attr_test.attr);
471 if (retval) 472 if (retval)
@@ -475,27 +476,26 @@ static int fs_add_slot(struct pci_slot *slot)
475 goto exit; 476 goto exit;
476 477
477exit_test: 478exit_test:
478 if (has_cur_bus_speed_file(slot) == 0) 479 if (has_cur_bus_speed_file(slot))
479 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr); 480 sysfs_remove_file(&slot->kobj,
480 481 &hotplug_slot_attr_cur_bus_speed.attr);
481exit_cur_speed: 482exit_cur_speed:
482 if (has_max_bus_speed_file(slot) == 0) 483 if (has_max_bus_speed_file(slot))
483 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); 484 sysfs_remove_file(&slot->kobj,
484 485 &hotplug_slot_attr_max_bus_speed.attr);
485exit_max_speed: 486exit_max_speed:
486 if (has_adapter_file(slot) == 0) 487 if (has_adapter_file(slot))
487 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr); 488 sysfs_remove_file(&slot->kobj,
488 489 &hotplug_slot_attr_presence.attr);
489exit_adapter: 490exit_adapter:
490 if (has_latch_file(slot) == 0) 491 if (has_latch_file(slot))
491 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr); 492 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
492
493exit_latch: 493exit_latch:
494 if (has_attention_file(slot) == 0) 494 if (has_attention_file(slot))
495 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_attention.attr); 495 sysfs_remove_file(&slot->kobj,
496 496 &hotplug_slot_attr_attention.attr);
497exit_attention: 497exit_attention:
498 if (has_power_file(slot) == 0) 498 if (has_power_file(slot))
499 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr); 499 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr);
500exit_power: 500exit_power:
501exit: 501exit:
@@ -504,25 +504,29 @@ exit:
504 504
505static void fs_remove_slot(struct pci_slot *slot) 505static void fs_remove_slot(struct pci_slot *slot)
506{ 506{
507 if (has_power_file(slot) == 0) 507 if (has_power_file(slot))
508 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr); 508 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr);
509 509
510 if (has_attention_file(slot) == 0) 510 if (has_attention_file(slot))
511 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_attention.attr); 511 sysfs_remove_file(&slot->kobj,
512 &hotplug_slot_attr_attention.attr);
512 513
513 if (has_latch_file(slot) == 0) 514 if (has_latch_file(slot))
514 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr); 515 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
515 516
516 if (has_adapter_file(slot) == 0) 517 if (has_adapter_file(slot))
517 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr); 518 sysfs_remove_file(&slot->kobj,
519 &hotplug_slot_attr_presence.attr);
518 520
519 if (has_max_bus_speed_file(slot) == 0) 521 if (has_max_bus_speed_file(slot))
520 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); 522 sysfs_remove_file(&slot->kobj,
523 &hotplug_slot_attr_max_bus_speed.attr);
521 524
522 if (has_cur_bus_speed_file(slot) == 0) 525 if (has_cur_bus_speed_file(slot))
523 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr); 526 sysfs_remove_file(&slot->kobj,
527 &hotplug_slot_attr_cur_bus_speed.attr);
524 528
525 if (has_test_file(slot) == 0) 529 if (has_test_file(slot))
526 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_test.attr); 530 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_test.attr);
527} 531}
528 532