diff options
author | Joachim Fenkes <fenkes@de.ibm.com> | 2007-05-09 07:48:25 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-05-14 16:40:45 -0400 |
commit | bba9b6013e604fadb298191c058149acf1cdfced (patch) | |
tree | c23803b89b94e22c394e4fba2a4195544d348088 /drivers/infiniband | |
parent | c7a14939e78e75dd90b54cb0df371019bc6d3e89 (diff) |
IB/ehca: Beautify sysfs attribute code and fix compiler warnings
eHCA's sysfs attributes are now being created via sysfs_create_group(),
making the process neatly table-driven. The return value is checked, thus
fixing a few compiler warnings.
Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/ehca/ehca_main.c | 86 |
1 files changed, 37 insertions, 49 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c index b917cc130e48..7d276e034e47 100644 --- a/drivers/infiniband/hw/ehca/ehca_main.c +++ b/drivers/infiniband/hw/ehca/ehca_main.c | |||
@@ -454,15 +454,14 @@ static ssize_t ehca_store_debug_level(struct device_driver *ddp, | |||
454 | DRIVER_ATTR(debug_level, S_IRUSR | S_IWUSR, | 454 | DRIVER_ATTR(debug_level, S_IRUSR | S_IWUSR, |
455 | ehca_show_debug_level, ehca_store_debug_level); | 455 | ehca_show_debug_level, ehca_store_debug_level); |
456 | 456 | ||
457 | void ehca_create_driver_sysfs(struct ibmebus_driver *drv) | 457 | static struct attribute *ehca_drv_attrs[] = { |
458 | { | 458 | &driver_attr_debug_level.attr, |
459 | driver_create_file(&drv->driver, &driver_attr_debug_level); | 459 | NULL |
460 | } | 460 | }; |
461 | 461 | ||
462 | void ehca_remove_driver_sysfs(struct ibmebus_driver *drv) | 462 | static struct attribute_group ehca_drv_attr_grp = { |
463 | { | 463 | .attrs = ehca_drv_attrs |
464 | driver_remove_file(&drv->driver, &driver_attr_debug_level); | 464 | }; |
465 | } | ||
466 | 465 | ||
467 | #define EHCA_RESOURCE_ATTR(name) \ | 466 | #define EHCA_RESOURCE_ATTR(name) \ |
468 | static ssize_t ehca_show_##name(struct device *dev, \ | 467 | static ssize_t ehca_show_##name(struct device *dev, \ |
@@ -524,44 +523,28 @@ static ssize_t ehca_show_adapter_handle(struct device *dev, | |||
524 | } | 523 | } |
525 | static DEVICE_ATTR(adapter_handle, S_IRUGO, ehca_show_adapter_handle, NULL); | 524 | static DEVICE_ATTR(adapter_handle, S_IRUGO, ehca_show_adapter_handle, NULL); |
526 | 525 | ||
526 | static struct attribute *ehca_dev_attrs[] = { | ||
527 | &dev_attr_adapter_handle.attr, | ||
528 | &dev_attr_num_ports.attr, | ||
529 | &dev_attr_hw_ver.attr, | ||
530 | &dev_attr_max_eq.attr, | ||
531 | &dev_attr_cur_eq.attr, | ||
532 | &dev_attr_max_cq.attr, | ||
533 | &dev_attr_cur_cq.attr, | ||
534 | &dev_attr_max_qp.attr, | ||
535 | &dev_attr_cur_qp.attr, | ||
536 | &dev_attr_max_mr.attr, | ||
537 | &dev_attr_cur_mr.attr, | ||
538 | &dev_attr_max_mw.attr, | ||
539 | &dev_attr_cur_mw.attr, | ||
540 | &dev_attr_max_pd.attr, | ||
541 | &dev_attr_max_ah.attr, | ||
542 | NULL | ||
543 | }; | ||
527 | 544 | ||
528 | void ehca_create_device_sysfs(struct ibmebus_dev *dev) | 545 | static struct attribute_group ehca_dev_attr_grp = { |
529 | { | 546 | .attrs = ehca_dev_attrs |
530 | device_create_file(&dev->ofdev.dev, &dev_attr_adapter_handle); | 547 | }; |
531 | device_create_file(&dev->ofdev.dev, &dev_attr_num_ports); | ||
532 | device_create_file(&dev->ofdev.dev, &dev_attr_hw_ver); | ||
533 | device_create_file(&dev->ofdev.dev, &dev_attr_max_eq); | ||
534 | device_create_file(&dev->ofdev.dev, &dev_attr_cur_eq); | ||
535 | device_create_file(&dev->ofdev.dev, &dev_attr_max_cq); | ||
536 | device_create_file(&dev->ofdev.dev, &dev_attr_cur_cq); | ||
537 | device_create_file(&dev->ofdev.dev, &dev_attr_max_qp); | ||
538 | device_create_file(&dev->ofdev.dev, &dev_attr_cur_qp); | ||
539 | device_create_file(&dev->ofdev.dev, &dev_attr_max_mr); | ||
540 | device_create_file(&dev->ofdev.dev, &dev_attr_cur_mr); | ||
541 | device_create_file(&dev->ofdev.dev, &dev_attr_max_mw); | ||
542 | device_create_file(&dev->ofdev.dev, &dev_attr_cur_mw); | ||
543 | device_create_file(&dev->ofdev.dev, &dev_attr_max_pd); | ||
544 | device_create_file(&dev->ofdev.dev, &dev_attr_max_ah); | ||
545 | } | ||
546 | |||
547 | void ehca_remove_device_sysfs(struct ibmebus_dev *dev) | ||
548 | { | ||
549 | device_remove_file(&dev->ofdev.dev, &dev_attr_adapter_handle); | ||
550 | device_remove_file(&dev->ofdev.dev, &dev_attr_num_ports); | ||
551 | device_remove_file(&dev->ofdev.dev, &dev_attr_hw_ver); | ||
552 | device_remove_file(&dev->ofdev.dev, &dev_attr_max_eq); | ||
553 | device_remove_file(&dev->ofdev.dev, &dev_attr_cur_eq); | ||
554 | device_remove_file(&dev->ofdev.dev, &dev_attr_max_cq); | ||
555 | device_remove_file(&dev->ofdev.dev, &dev_attr_cur_cq); | ||
556 | device_remove_file(&dev->ofdev.dev, &dev_attr_max_qp); | ||
557 | device_remove_file(&dev->ofdev.dev, &dev_attr_cur_qp); | ||
558 | device_remove_file(&dev->ofdev.dev, &dev_attr_max_mr); | ||
559 | device_remove_file(&dev->ofdev.dev, &dev_attr_cur_mr); | ||
560 | device_remove_file(&dev->ofdev.dev, &dev_attr_max_mw); | ||
561 | device_remove_file(&dev->ofdev.dev, &dev_attr_cur_mw); | ||
562 | device_remove_file(&dev->ofdev.dev, &dev_attr_max_pd); | ||
563 | device_remove_file(&dev->ofdev.dev, &dev_attr_max_ah); | ||
564 | } | ||
565 | 548 | ||
566 | static int __devinit ehca_probe(struct ibmebus_dev *dev, | 549 | static int __devinit ehca_probe(struct ibmebus_dev *dev, |
567 | const struct of_device_id *id) | 550 | const struct of_device_id *id) |
@@ -669,7 +652,10 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev, | |||
669 | } | 652 | } |
670 | } | 653 | } |
671 | 654 | ||
672 | ehca_create_device_sysfs(dev); | 655 | ret = sysfs_create_group(&dev->ofdev.dev.kobj, &ehca_dev_attr_grp); |
656 | if (ret) /* only complain; we can live without attributes */ | ||
657 | ehca_err(&shca->ib_device, | ||
658 | "Cannot create device attributes ret=%d", ret); | ||
673 | 659 | ||
674 | spin_lock(&shca_list_lock); | 660 | spin_lock(&shca_list_lock); |
675 | list_add(&shca->shca_list, &shca_list); | 661 | list_add(&shca->shca_list, &shca_list); |
@@ -721,7 +707,7 @@ static int __devexit ehca_remove(struct ibmebus_dev *dev) | |||
721 | struct ehca_shca *shca = dev->ofdev.dev.driver_data; | 707 | struct ehca_shca *shca = dev->ofdev.dev.driver_data; |
722 | int ret; | 708 | int ret; |
723 | 709 | ||
724 | ehca_remove_device_sysfs(dev); | 710 | sysfs_remove_group(&dev->ofdev.dev.kobj, &ehca_dev_attr_grp); |
725 | 711 | ||
726 | if (ehca_open_aqp1 == 1) { | 712 | if (ehca_open_aqp1 == 1) { |
727 | int i; | 713 | int i; |
@@ -840,7 +826,9 @@ int __init ehca_module_init(void) | |||
840 | goto module_init2; | 826 | goto module_init2; |
841 | } | 827 | } |
842 | 828 | ||
843 | ehca_create_driver_sysfs(&ehca_driver); | 829 | ret = sysfs_create_group(&ehca_driver.driver.kobj, &ehca_drv_attr_grp); |
830 | if (ret) /* only complain; we can live without attributes */ | ||
831 | ehca_gen_err("Cannot create driver attributes ret=%d", ret); | ||
844 | 832 | ||
845 | if (ehca_poll_all_eqs != 1) { | 833 | if (ehca_poll_all_eqs != 1) { |
846 | ehca_gen_err("WARNING!!!"); | 834 | ehca_gen_err("WARNING!!!"); |
@@ -867,7 +855,7 @@ void __exit ehca_module_exit(void) | |||
867 | if (ehca_poll_all_eqs == 1) | 855 | if (ehca_poll_all_eqs == 1) |
868 | del_timer_sync(&poll_eqs_timer); | 856 | del_timer_sync(&poll_eqs_timer); |
869 | 857 | ||
870 | ehca_remove_driver_sysfs(&ehca_driver); | 858 | sysfs_remove_group(&ehca_driver.driver.kobj, &ehca_drv_attr_grp); |
871 | ibmebus_unregister_driver(&ehca_driver); | 859 | ibmebus_unregister_driver(&ehca_driver); |
872 | 860 | ||
873 | ehca_destroy_slab_caches(); | 861 | ehca_destroy_slab_caches(); |