diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2016-04-13 19:19:04 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-04-21 10:09:03 +0900 |
commit | 7c8eb12dbb4c1b43ce705a8ba1a5c9c1191e75d8 (patch) | |
tree | 3fce31fc4978c18503e4bf101708416f586f21c8 /drivers | |
parent | 7326e07b588cace823a36d4a563838b051b8b8a5 (diff) | |
download | op-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')
-rw-r--r-- | drivers/staging/greybus/Documentation/sysfs-bus-greybus | 28 | ||||
-rw-r--r-- | drivers/staging/greybus/control.c | 29 | ||||
-rw-r--r-- | drivers/staging/greybus/control.h | 3 | ||||
-rw-r--r-- | drivers/staging/greybus/interface.c | 7 | ||||
-rw-r--r-- | drivers/staging/greybus/interface.h | 4 | ||||
-rw-r--r-- | drivers/staging/greybus/manifest.c | 13 |
6 files changed, 53 insertions, 31 deletions
diff --git a/drivers/staging/greybus/Documentation/sysfs-bus-greybus b/drivers/staging/greybus/Documentation/sysfs-bus-greybus index d8bf30e..4831efb 100644 --- a/drivers/staging/greybus/Documentation/sysfs-bus-greybus +++ b/drivers/staging/greybus/Documentation/sysfs-bus-greybus @@ -52,13 +52,6 @@ Contact: Greg Kroah-Hartman <greg@kroah.com> Description: Product ID of a Greybus interface. -What: /sys/bus/greybus/device/N-I/product_string -Date: October 2015 -KernelVersion: 4.XX -Contact: Greg Kroah-Hartman <greg@kroah.com> -Description: - Product ID string of a Greybus interface. - What: /sys/bus/greybus/device/N-I/vendor_id Date: October 2015 KernelVersion: 4.XX @@ -66,13 +59,6 @@ Contact: Greg Kroah-Hartman <greg@kroah.com> Description: Vendor ID of a Greybus interface. -What: /sys/bus/greybus/device/N-I/vendor_string -Date: October 2015 -KernelVersion: 4.XX -Contact: Greg Kroah-Hartman <greg@kroah.com> -Description: - Vendor ID string of a Greybus interface block. - What: /sys/bus/greybus/device/N-I/version Date: October 2015 KernelVersion: 4.XX @@ -110,6 +96,20 @@ Description: A bundle B on the Interface I, B is replaced by a 1-byte number representing the bundle. +What: /sys/bus/greybus/device/N-I.ctrl/product_string +Date: October 2015 +KernelVersion: 4.XX +Contact: Greg Kroah-Hartman <greg@kroah.com> +Description: + Product ID string of a Greybus interface. + +What: /sys/bus/greybus/device/N-I.ctrl/vendor_string +Date: October 2015 +KernelVersion: 4.XX +Contact: Greg Kroah-Hartman <greg@kroah.com> +Description: + Vendor ID string of a Greybus interface. + What: /sys/bus/greybus/device/N-I.B/bundle_class Date: October 2015 KernelVersion: 4.XX 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)); diff --git a/drivers/staging/greybus/control.h b/drivers/staging/greybus/control.h index 102e937..56fa259 100644 --- a/drivers/staging/greybus/control.h +++ b/drivers/staging/greybus/control.h @@ -20,6 +20,9 @@ struct gb_control { u8 protocol_minor; bool has_bundle_version; + + char *vendor_string; + char *product_string; }; #define to_gb_control(d) container_of(d, struct gb_control, dev) diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index e0e0873..ed56f2d 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -249,8 +249,6 @@ gb_interface_attr(ddbl1_product_id, "0x%08x"); gb_interface_attr(interface_id, "%u"); gb_interface_attr(vendor_id, "0x%08x"); gb_interface_attr(product_id, "0x%08x"); -gb_interface_attr(vendor_string, "%s"); -gb_interface_attr(product_string, "%s"); gb_interface_attr(serial_number, "0x%016llx"); static ssize_t version_show(struct device *dev, struct device_attribute *attr, @@ -326,8 +324,6 @@ static struct attribute *interface_attrs[] = { &dev_attr_interface_id.attr, &dev_attr_vendor_id.attr, &dev_attr_product_id.attr, - &dev_attr_vendor_string.attr, - &dev_attr_product_string.attr, &dev_attr_serial_number.attr, &dev_attr_version.attr, &dev_attr_voltage_now.attr, @@ -356,9 +352,6 @@ static void gb_interface_release(struct device *dev) { struct gb_interface *intf = to_gb_interface(dev); - kfree(intf->product_string); - kfree(intf->vendor_string); - if (intf->control) gb_control_put(intf->control); diff --git a/drivers/staging/greybus/interface.h b/drivers/staging/greybus/interface.h index 15c687f..567b6c8 100644 --- a/drivers/staging/greybus/interface.h +++ b/drivers/staging/greybus/interface.h @@ -25,10 +25,6 @@ struct gb_interface { u8 interface_id; /* Physical location within the Endo */ u8 device_id; - /* Information taken from the manifest descriptor */ - char *vendor_string; - char *product_string; - u32 ddbl1_manufacturer_id; u32 ddbl1_product_id; u32 vendor_id; diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c index cca4592..886c5fb 100644 --- a/drivers/staging/greybus/manifest.c +++ b/drivers/staging/greybus/manifest.c @@ -384,18 +384,19 @@ static bool gb_manifest_parse_interface(struct gb_interface *intf, struct manifest_desc *interface_desc) { struct greybus_descriptor_interface *desc_intf = interface_desc->data; + struct gb_control *control = intf->control; char *str; /* Handle the strings first--they can fail */ str = gb_string_get(intf, desc_intf->vendor_stringid); if (IS_ERR(str)) return false; - intf->vendor_string = str; + control->vendor_string = str; str = gb_string_get(intf, desc_intf->product_stringid); if (IS_ERR(str)) goto out_free_vendor_string; - intf->product_string = str; + control->product_string = str; /* Release the interface descriptor, now that we're done with it */ release_manifest_descriptor(interface_desc); @@ -408,11 +409,11 @@ static bool gb_manifest_parse_interface(struct gb_interface *intf, return true; out_err: - kfree(intf->product_string); - intf->product_string = NULL; + kfree(control->product_string); + control->product_string = NULL; out_free_vendor_string: - kfree(intf->vendor_string); - intf->vendor_string = NULL; + kfree(control->vendor_string); + control->vendor_string = NULL; return false; } |