summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/hd.c
diff options
context:
space:
mode:
authorSandeep Patil <sspatil@google.com>2016-04-29 07:13:23 -0700
committerGreg Kroah-Hartman <gregkh@google.com>2016-04-29 14:09:44 -0700
commitfbbd2b7c0876550b20c6ac0ee2df90ecc262712c (patch)
tree74171bfbe71b1c29c81f66ff82d234b07a3b6124 /drivers/staging/greybus/hd.c
parent6ddbed576606a454353638dbbbcc2f66f0fc712d (diff)
downloadop-kernel-dev-fbbd2b7c0876550b20c6ac0ee2df90ecc262712c.zip
op-kernel-dev-fbbd2b7c0876550b20c6ac0ee2df90ecc262712c.tar.gz
greybus: hd: add bus_id attribute
The greybus host device id can only be read by parsing the uevent if one wants to identify a specific host device 'or' bus. This is 'lsgb' uses today. This change adds a bus_id attribute so libraries can identify multiple host devices 'or' bus if they exist. Testing Done: Tested on Arche, 'cat /sys/bus/greybus/devices/greysbus1/bus_id' Signed-off-by: Sandeep Patil <sspatil@google.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/hd.c')
-rw-r--r--drivers/staging/greybus/hd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/staging/greybus/hd.c b/drivers/staging/greybus/hd.c
index 762cc03..2863472 100644
--- a/drivers/staging/greybus/hd.c
+++ b/drivers/staging/greybus/hd.c
@@ -24,6 +24,21 @@ int gb_hd_output(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
}
EXPORT_SYMBOL_GPL(gb_hd_output);
+static ssize_t bus_id_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct gb_host_device *hd = to_gb_host_device(dev);
+
+ return sprintf(buf, "%d\n", hd->bus_id);
+}
+static DEVICE_ATTR_RO(bus_id);
+
+static struct attribute *bus_attrs[] = {
+ &dev_attr_bus_id.attr,
+ NULL
+};
+ATTRIBUTE_GROUPS(bus);
+
static void gb_hd_release(struct device *dev)
{
struct gb_host_device *hd = to_gb_host_device(dev);
@@ -98,6 +113,7 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,
hd->dev.parent = parent;
hd->dev.bus = &greybus_bus_type;
hd->dev.type = &greybus_hd_type;
+ hd->dev.groups = bus_groups;
hd->dev.dma_mask = hd->dev.parent->dma_mask;
device_initialize(&hd->dev);
dev_set_name(&hd->dev, "greybus%d", hd->bus_id);
OpenPOWER on IntegriCloud