summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/control.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2016-04-13 19:19:04 +0200
committerGreg Kroah-Hartman <gregkh@google.com>2016-04-21 10:09:03 +0900
commit7c8eb12dbb4c1b43ce705a8ba1a5c9c1191e75d8 (patch)
tree3fce31fc4978c18503e4bf101708416f586f21c8 /drivers/staging/greybus/control.c
parent7326e07b588cace823a36d4a563838b051b8b8a5 (diff)
downloadop-kernel-dev-7c8eb12dbb4c1b43ce705a8ba1a5c9c1191e75d8.zip
op-kernel-dev-7c8eb12dbb4c1b43ce705a8ba1a5c9c1191e75d8.tar.gz
greybus: interface: move vendor and product strings to control device
The control device is an abstraction of the control connection over which a greybus manifest is retrieved. As interfaces switch modes (e.g. after boot-over-unipro) they expose new manifests, which can contain different vendor and product strings. Eventually control devices will be deregistered and recreated after an interface mode switch, while the interface itself remains registered. Note that only interfaces of type greybus will have control devices. Specifically, dummy interfaces will not. Signed-off-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/control.c')
-rw-r--r--drivers/staging/greybus/control.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/staging/greybus/control.c b/drivers/staging/greybus/control.c
index 6063619..58a3d60 100644
--- a/drivers/staging/greybus/control.c
+++ b/drivers/staging/greybus/control.c
@@ -213,12 +213,40 @@ int gb_control_timesync_authoritative(struct gb_control *control,
NULL, 0);
}
+static ssize_t vendor_string_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct gb_control *control = to_gb_control(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n", control->vendor_string);
+}
+static DEVICE_ATTR_RO(vendor_string);
+
+static ssize_t product_string_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct gb_control *control = to_gb_control(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n", control->product_string);
+}
+static DEVICE_ATTR_RO(product_string);
+
+static struct attribute *control_attrs[] = {
+ &dev_attr_vendor_string.attr,
+ &dev_attr_product_string.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(control);
+
static void gb_control_release(struct device *dev)
{
struct gb_control *control = to_gb_control(dev);
gb_connection_destroy(control->connection);
+ kfree(control->vendor_string);
+ kfree(control->product_string);
+
kfree(control);
}
@@ -249,6 +277,7 @@ struct gb_control *gb_control_create(struct gb_interface *intf)
control->dev.parent = &intf->dev;
control->dev.bus = &greybus_bus_type;
control->dev.type = &greybus_control_type;
+ control->dev.groups = control_groups;
control->dev.dma_mask = intf->dev.dma_mask;
device_initialize(&control->dev);
dev_set_name(&control->dev, "%s.ctrl", dev_name(&intf->dev));
OpenPOWER on IntegriCloud