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>
This commit is contained in:
Johan Hovold 2016-04-13 19:19:04 +02:00 коммит произвёл Greg Kroah-Hartman
Родитель 7326e07b58
Коммит 7c8eb12dbb
6 изменённых файлов: 53 добавлений и 31 удалений

Просмотреть файл

@ -52,13 +52,6 @@ Contact: Greg Kroah-Hartman <greg@kroah.com>
Description: Description:
Product ID of a Greybus interface. 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 What: /sys/bus/greybus/device/N-I/vendor_id
Date: October 2015 Date: October 2015
KernelVersion: 4.XX KernelVersion: 4.XX
@ -66,13 +59,6 @@ Contact: Greg Kroah-Hartman <greg@kroah.com>
Description: Description:
Vendor ID of a Greybus interface. 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 What: /sys/bus/greybus/device/N-I/version
Date: October 2015 Date: October 2015
KernelVersion: 4.XX KernelVersion: 4.XX
@ -110,6 +96,20 @@ Description:
A bundle B on the Interface I, B is replaced by a 1-byte A bundle B on the Interface I, B is replaced by a 1-byte
number representing the bundle. 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 What: /sys/bus/greybus/device/N-I.B/bundle_class
Date: October 2015 Date: October 2015
KernelVersion: 4.XX KernelVersion: 4.XX

Просмотреть файл

@ -213,12 +213,40 @@ int gb_control_timesync_authoritative(struct gb_control *control,
NULL, 0); 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) static void gb_control_release(struct device *dev)
{ {
struct gb_control *control = to_gb_control(dev); struct gb_control *control = to_gb_control(dev);
gb_connection_destroy(control->connection); gb_connection_destroy(control->connection);
kfree(control->vendor_string);
kfree(control->product_string);
kfree(control); kfree(control);
} }
@ -249,6 +277,7 @@ struct gb_control *gb_control_create(struct gb_interface *intf)
control->dev.parent = &intf->dev; control->dev.parent = &intf->dev;
control->dev.bus = &greybus_bus_type; control->dev.bus = &greybus_bus_type;
control->dev.type = &greybus_control_type; control->dev.type = &greybus_control_type;
control->dev.groups = control_groups;
control->dev.dma_mask = intf->dev.dma_mask; control->dev.dma_mask = intf->dev.dma_mask;
device_initialize(&control->dev); device_initialize(&control->dev);
dev_set_name(&control->dev, "%s.ctrl", dev_name(&intf->dev)); dev_set_name(&control->dev, "%s.ctrl", dev_name(&intf->dev));

Просмотреть файл

@ -20,6 +20,9 @@ struct gb_control {
u8 protocol_minor; u8 protocol_minor;
bool has_bundle_version; bool has_bundle_version;
char *vendor_string;
char *product_string;
}; };
#define to_gb_control(d) container_of(d, struct gb_control, dev) #define to_gb_control(d) container_of(d, struct gb_control, dev)

Просмотреть файл

@ -249,8 +249,6 @@ gb_interface_attr(ddbl1_product_id, "0x%08x");
gb_interface_attr(interface_id, "%u"); gb_interface_attr(interface_id, "%u");
gb_interface_attr(vendor_id, "0x%08x"); gb_interface_attr(vendor_id, "0x%08x");
gb_interface_attr(product_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"); gb_interface_attr(serial_number, "0x%016llx");
static ssize_t version_show(struct device *dev, struct device_attribute *attr, 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_interface_id.attr,
&dev_attr_vendor_id.attr, &dev_attr_vendor_id.attr,
&dev_attr_product_id.attr, &dev_attr_product_id.attr,
&dev_attr_vendor_string.attr,
&dev_attr_product_string.attr,
&dev_attr_serial_number.attr, &dev_attr_serial_number.attr,
&dev_attr_version.attr, &dev_attr_version.attr,
&dev_attr_voltage_now.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); struct gb_interface *intf = to_gb_interface(dev);
kfree(intf->product_string);
kfree(intf->vendor_string);
if (intf->control) if (intf->control)
gb_control_put(intf->control); gb_control_put(intf->control);

Просмотреть файл

@ -25,10 +25,6 @@ struct gb_interface {
u8 interface_id; /* Physical location within the Endo */ u8 interface_id; /* Physical location within the Endo */
u8 device_id; u8 device_id;
/* Information taken from the manifest descriptor */
char *vendor_string;
char *product_string;
u32 ddbl1_manufacturer_id; u32 ddbl1_manufacturer_id;
u32 ddbl1_product_id; u32 ddbl1_product_id;
u32 vendor_id; u32 vendor_id;

Просмотреть файл

@ -384,18 +384,19 @@ static bool gb_manifest_parse_interface(struct gb_interface *intf,
struct manifest_desc *interface_desc) struct manifest_desc *interface_desc)
{ {
struct greybus_descriptor_interface *desc_intf = interface_desc->data; struct greybus_descriptor_interface *desc_intf = interface_desc->data;
struct gb_control *control = intf->control;
char *str; char *str;
/* Handle the strings first--they can fail */ /* Handle the strings first--they can fail */
str = gb_string_get(intf, desc_intf->vendor_stringid); str = gb_string_get(intf, desc_intf->vendor_stringid);
if (IS_ERR(str)) if (IS_ERR(str))
return false; return false;
intf->vendor_string = str; control->vendor_string = str;
str = gb_string_get(intf, desc_intf->product_stringid); str = gb_string_get(intf, desc_intf->product_stringid);
if (IS_ERR(str)) if (IS_ERR(str))
goto out_free_vendor_string; 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 the interface descriptor, now that we're done with it */
release_manifest_descriptor(interface_desc); release_manifest_descriptor(interface_desc);
@ -408,11 +409,11 @@ static bool gb_manifest_parse_interface(struct gb_interface *intf,
return true; return true;
out_err: out_err:
kfree(intf->product_string); kfree(control->product_string);
intf->product_string = NULL; control->product_string = NULL;
out_free_vendor_string: out_free_vendor_string:
kfree(intf->vendor_string); kfree(control->vendor_string);
intf->vendor_string = NULL; control->vendor_string = NULL;
return false; return false;
} }