From: Viresh Kumar Date: Thu, 12 May 2016 06:50:02 +0000 (+0530) Subject: greybus: gpbridge: Expose protocol_id in sysfs X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~424 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=6f8a028fd17bbb3102c81dc4fd30f2d722234b5e;p=linux.git 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 Reviewed-by: Sandeep Patil Signed-off-by: Greg Kroah-Hartman --- 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);