aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2016-05-12 12:20:02 +0530
committerGreg Kroah-Hartman <gregkh@google.com>2016-05-13 12:02:57 +0200
commit6f8a028fd17bbb3102c81dc4fd30f2d722234b5e (patch)
tree901c2f9c98b68e62fe72cc20747885dca24c3f48
parentgreybus: interface: remove unused interface-version quirk (diff)
greybus: gpbridge: Expose protocol_id in sysfs
Right now, userspace doesn't have any way to find what protocol does a gpbridge device implement. And this is essential for the scripts to know, to expect what kind of device will be present inside the gpbN directory. Expose 'protocol_id' in sysfs to fix that. Tested by checking that the field appears with GP module on EVT 1.5. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Sandeep Patil <sspatil@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
-rw-r--r--drivers/staging/greybus/gpbridge.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/staging/greybus/gpbridge.c b/drivers/staging/greybus/gpbridge.c
index 993cfacb65aa..64ab8ddf2212 100644
--- a/drivers/staging/greybus/gpbridge.c
+++ b/drivers/staging/greybus/gpbridge.c
@@ -26,6 +26,22 @@ struct gpbridge_host {
static DEFINE_IDA(gpbridge_id);
+static ssize_t protocol_id_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
+
+ return sprintf(buf, "0x%02x\n", gpbdev->cport_desc->protocol_id);
+}
+static DEVICE_ATTR_RO(protocol_id);
+
+static struct attribute *gpbdev_attrs[] = {
+ &dev_attr_protocol_id.attr,
+ NULL,
+};
+
+ATTRIBUTE_GROUPS(gpbdev);
+
static void gpbdev_release(struct device *dev)
{
struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
@@ -190,7 +206,7 @@ static struct gpbridge_device *gb_gpbridge_create_dev(struct gb_bundle *bundle,
gpbdev->dev.parent = &bundle->dev;
gpbdev->dev.bus = &gpbridge_bus_type;
gpbdev->dev.release = gpbdev_release;
- gpbdev->dev.groups = NULL;
+ gpbdev->dev.groups = gpbdev_groups;
gpbdev->dev.dma_mask = bundle->dev.dma_mask;
dev_set_name(&gpbdev->dev, "gpb%d", id);