aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/core/sysfs.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 5982d687a000..49601bb8475b 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -628,14 +628,42 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf)
628 be16_to_cpu(((__be16 *) &dev->node_guid)[3])); 628 be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
629} 629}
630 630
631static ssize_t show_node_desc(struct class_device *cdev, char *buf)
632{
633 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
634
635 return sprintf(buf, "%.64s\n", dev->node_desc);
636}
637
638static ssize_t set_node_desc(struct class_device *cdev, const char *buf,
639 size_t count)
640{
641 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
642 struct ib_device_modify desc = {};
643 int ret;
644
645 if (!dev->modify_device)
646 return -EIO;
647
648 memcpy(desc.node_desc, buf, min_t(int, count, 64));
649 ret = ib_modify_device(dev, IB_DEVICE_MODIFY_NODE_DESC, &desc);
650 if (ret)
651 return ret;
652
653 return count;
654}
655
631static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); 656static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
632static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); 657static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
633static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); 658static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
659static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc,
660 set_node_desc);
634 661
635static struct class_device_attribute *ib_class_attributes[] = { 662static struct class_device_attribute *ib_class_attributes[] = {
636 &class_device_attr_node_type, 663 &class_device_attr_node_type,
637 &class_device_attr_sys_image_guid, 664 &class_device_attr_sys_image_guid,
638 &class_device_attr_node_guid 665 &class_device_attr_node_guid,
666 &class_device_attr_node_desc
639}; 667};
640 668
641static struct class ib_class = { 669static struct class ib_class = {