greybus: bundle: add bundle_id attribute
authorJohan Hovold <johan@hovoldconsulting.com>
Wed, 25 Nov 2015 14:59:01 +0000 (15:59 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 25 Nov 2015 23:27:06 +0000 (15:27 -0800)
Add a bundle_id attribute for the interface-unique id of a bundle that
user space can use for matching.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/Documentation/sysfs-bus-greybus
drivers/staging/greybus/bundle.c

index 88ed2d8905ccede334c9cd5f68bee9772b52cfb0..9329a31647cd7e9f5d20854c598253b9cf4bad11 100644 (file)
@@ -104,6 +104,13 @@ Contact:   Greg Kroah-Hartman <greg@kroah.com>
 Description:
                The greybus class of the bundle B.
 
+What:          /sys/bus/greybus/device/N-I.B/bundle_id
+Date:          October 2015
+KernelVersion: 4.XX
+Contact:       Greg Kroah-Hartman <greg@kroah.com>
+Description:
+               The interface-unique id of the bundle B.
+
 What:          /sys/bus/greybus/device/N-I.B/state
 Date:          October 2015
 KernelVersion: 4.XX
index 61c9a6d68561a7a5086dc7594fa1f072fdf254f1..f746438bc9625748d1c81277b4e126efb7b5bb85 100644 (file)
@@ -18,6 +18,15 @@ static ssize_t bundle_class_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(bundle_class);
 
+static ssize_t bundle_id_show(struct device *dev,
+                             struct device_attribute *attr, char *buf)
+{
+       struct gb_bundle *bundle = to_gb_bundle(dev);
+
+       return sprintf(buf, "%u\n", bundle->id);
+}
+static DEVICE_ATTR_RO(bundle_id);
+
 static ssize_t state_show(struct device *dev, struct device_attribute *attr,
                          char *buf)
 {
@@ -49,6 +58,7 @@ static DEVICE_ATTR_RW(state);
 
 static struct attribute *bundle_attrs[] = {
        &dev_attr_bundle_class.attr,
+       &dev_attr_bundle_id.attr,
        &dev_attr_state.attr,
        NULL,
 };