diff options
author | Tony Jones <tonyj@suse.de> | 2008-02-21 18:13:36 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-19 22:10:30 -0400 |
commit | f4e91eb4a81559da87a3843758a641b5cc590b65 (patch) | |
tree | 534335821d076764cbc072586b19c4b061710e3d /drivers/infiniband/core/sysfs.c | |
parent | c4c66cf1787d408066fbfc69209185701f5df15f (diff) |
IB: convert struct class_device to struct device
This converts the main ib_device to use struct device instead of struct
class_device as class_device is going away.
Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/infiniband/core/sysfs.c')
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 5a4b2e65534b..95756551cf7c 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -427,17 +427,17 @@ static struct kobj_type port_type = { | |||
427 | .default_attrs = port_default_attrs | 427 | .default_attrs = port_default_attrs |
428 | }; | 428 | }; |
429 | 429 | ||
430 | static void ib_device_release(struct class_device *cdev) | 430 | static void ib_device_release(struct device *device) |
431 | { | 431 | { |
432 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 432 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
433 | 433 | ||
434 | kfree(dev); | 434 | kfree(dev); |
435 | } | 435 | } |
436 | 436 | ||
437 | static int ib_device_uevent(struct class_device *cdev, | 437 | static int ib_device_uevent(struct device *device, |
438 | struct kobj_uevent_env *env) | 438 | struct kobj_uevent_env *env) |
439 | { | 439 | { |
440 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 440 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
441 | 441 | ||
442 | if (add_uevent_var(env, "NAME=%s", dev->name)) | 442 | if (add_uevent_var(env, "NAME=%s", dev->name)) |
443 | return -ENOMEM; | 443 | return -ENOMEM; |
@@ -567,9 +567,10 @@ err_put: | |||
567 | return ret; | 567 | return ret; |
568 | } | 568 | } |
569 | 569 | ||
570 | static ssize_t show_node_type(struct class_device *cdev, char *buf) | 570 | static ssize_t show_node_type(struct device *device, |
571 | struct device_attribute *attr, char *buf) | ||
571 | { | 572 | { |
572 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 573 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
573 | 574 | ||
574 | if (!ibdev_is_alive(dev)) | 575 | if (!ibdev_is_alive(dev)) |
575 | return -ENODEV; | 576 | return -ENODEV; |
@@ -583,9 +584,10 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf) | |||
583 | } | 584 | } |
584 | } | 585 | } |
585 | 586 | ||
586 | static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) | 587 | static ssize_t show_sys_image_guid(struct device *device, |
588 | struct device_attribute *dev_attr, char *buf) | ||
587 | { | 589 | { |
588 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 590 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
589 | struct ib_device_attr attr; | 591 | struct ib_device_attr attr; |
590 | ssize_t ret; | 592 | ssize_t ret; |
591 | 593 | ||
@@ -603,9 +605,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) | |||
603 | be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3])); | 605 | be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3])); |
604 | } | 606 | } |
605 | 607 | ||
606 | static ssize_t show_node_guid(struct class_device *cdev, char *buf) | 608 | static ssize_t show_node_guid(struct device *device, |
609 | struct device_attribute *attr, char *buf) | ||
607 | { | 610 | { |
608 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 611 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
609 | 612 | ||
610 | if (!ibdev_is_alive(dev)) | 613 | if (!ibdev_is_alive(dev)) |
611 | return -ENODEV; | 614 | return -ENODEV; |
@@ -617,17 +620,19 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf) | |||
617 | be16_to_cpu(((__be16 *) &dev->node_guid)[3])); | 620 | be16_to_cpu(((__be16 *) &dev->node_guid)[3])); |
618 | } | 621 | } |
619 | 622 | ||
620 | static ssize_t show_node_desc(struct class_device *cdev, char *buf) | 623 | static ssize_t show_node_desc(struct device *device, |
624 | struct device_attribute *attr, char *buf) | ||
621 | { | 625 | { |
622 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 626 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
623 | 627 | ||
624 | return sprintf(buf, "%.64s\n", dev->node_desc); | 628 | return sprintf(buf, "%.64s\n", dev->node_desc); |
625 | } | 629 | } |
626 | 630 | ||
627 | static ssize_t set_node_desc(struct class_device *cdev, const char *buf, | 631 | static ssize_t set_node_desc(struct device *device, |
628 | size_t count) | 632 | struct device_attribute *attr, |
633 | const char *buf, size_t count) | ||
629 | { | 634 | { |
630 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 635 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
631 | struct ib_device_modify desc = {}; | 636 | struct ib_device_modify desc = {}; |
632 | int ret; | 637 | int ret; |
633 | 638 | ||
@@ -642,44 +647,43 @@ static ssize_t set_node_desc(struct class_device *cdev, const char *buf, | |||
642 | return count; | 647 | return count; |
643 | } | 648 | } |
644 | 649 | ||
645 | static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); | 650 | static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); |
646 | static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); | 651 | static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); |
647 | static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); | 652 | static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); |
648 | static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, | 653 | static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc); |
649 | set_node_desc); | 654 | |
650 | 655 | static struct device_attribute *ib_class_attributes[] = { | |
651 | static struct class_device_attribute *ib_class_attributes[] = { | 656 | &dev_attr_node_type, |
652 | &class_device_attr_node_type, | 657 | &dev_attr_sys_image_guid, |
653 | &class_device_attr_sys_image_guid, | 658 | &dev_attr_node_guid, |
654 | &class_device_attr_node_guid, | 659 | &dev_attr_node_desc |
655 | &class_device_attr_node_desc | ||
656 | }; | 660 | }; |
657 | 661 | ||
658 | static struct class ib_class = { | 662 | static struct class ib_class = { |
659 | .name = "infiniband", | 663 | .name = "infiniband", |
660 | .release = ib_device_release, | 664 | .dev_release = ib_device_release, |
661 | .uevent = ib_device_uevent, | 665 | .dev_uevent = ib_device_uevent, |
662 | }; | 666 | }; |
663 | 667 | ||
664 | int ib_device_register_sysfs(struct ib_device *device) | 668 | int ib_device_register_sysfs(struct ib_device *device) |
665 | { | 669 | { |
666 | struct class_device *class_dev = &device->class_dev; | 670 | struct device *class_dev = &device->dev; |
667 | int ret; | 671 | int ret; |
668 | int i; | 672 | int i; |
669 | 673 | ||
670 | class_dev->class = &ib_class; | 674 | class_dev->class = &ib_class; |
671 | class_dev->class_data = device; | 675 | class_dev->driver_data = device; |
672 | class_dev->dev = device->dma_device; | 676 | class_dev->parent = device->dma_device; |
673 | strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE); | 677 | strlcpy(class_dev->bus_id, device->name, BUS_ID_SIZE); |
674 | 678 | ||
675 | INIT_LIST_HEAD(&device->port_list); | 679 | INIT_LIST_HEAD(&device->port_list); |
676 | 680 | ||
677 | ret = class_device_register(class_dev); | 681 | ret = device_register(class_dev); |
678 | if (ret) | 682 | if (ret) |
679 | goto err; | 683 | goto err; |
680 | 684 | ||
681 | for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) { | 685 | for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) { |
682 | ret = class_device_create_file(class_dev, ib_class_attributes[i]); | 686 | ret = device_create_file(class_dev, ib_class_attributes[i]); |
683 | if (ret) | 687 | if (ret) |
684 | goto err_unregister; | 688 | goto err_unregister; |
685 | } | 689 | } |
@@ -723,7 +727,7 @@ err_put: | |||
723 | kobject_put(&class_dev->kobj); | 727 | kobject_put(&class_dev->kobj); |
724 | 728 | ||
725 | err_unregister: | 729 | err_unregister: |
726 | class_device_unregister(class_dev); | 730 | device_unregister(class_dev); |
727 | 731 | ||
728 | err: | 732 | err: |
729 | return ret; | 733 | return ret; |
@@ -744,7 +748,7 @@ void ib_device_unregister_sysfs(struct ib_device *device) | |||
744 | } | 748 | } |
745 | 749 | ||
746 | kobject_put(device->ports_parent); | 750 | kobject_put(device->ports_parent); |
747 | class_device_unregister(&device->class_dev); | 751 | device_unregister(&device->dev); |
748 | } | 752 | } |
749 | 753 | ||
750 | int ib_sysfs_setup(void) | 754 | int ib_sysfs_setup(void) |