1
0
Fork 0

greybus: interface: device_id belongs to the interface

While introducing bundles, the device_id also got moved to the bundle,
whereas it identifies an interface block to the AP.

Move it back to interface instead of bundle.

Calls to gb_bundle(s)_init() are dropped as connections will be
initialized while they are created now, as device_id will be valid.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
hifive-unleashed-5.1
Viresh Kumar 2015-07-01 12:13:58 +05:30 committed by Greg Kroah-Hartman
parent 7e9017d482
commit c3add7883c
6 changed files with 27 additions and 50 deletions

View File

@ -105,6 +105,13 @@ Contact: Greg Kroah-Hartman <greg@kroah.com>
Description: Description:
Vendor ID string of a Greybus interface block. Vendor ID string of a Greybus interface block.
What: /sys/bus/greybus/device/.../device_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The device ID of a Greybus interface block.
What: /sys/bus/greybus/device/.../state What: /sys/bus/greybus/device/.../state
Date: October 2015 Date: October 2015
KernelVersion: 4.XX KernelVersion: 4.XX
@ -126,13 +133,6 @@ Contact: Greg Kroah-Hartman <greg@kroah.com>
Description: Description:
The protocol ID of a Greybus connection. The protocol ID of a Greybus connection.
What: /sys/bus/greybus/device/.../device_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The device ID of a Greybus bundle.
What: /sys/bus/greybus/device/.../state What: /sys/bus/greybus/device/.../state
Date: October 2015 Date: October 2015
KernelVersion: 4.XX KernelVersion: 4.XX

View File

@ -13,15 +13,6 @@ static void gb_bundle_connections_exit(struct gb_bundle *bundle);
static int gb_bundle_connections_init(struct gb_bundle *bundle); static int gb_bundle_connections_init(struct gb_bundle *bundle);
static ssize_t device_id_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct gb_bundle *bundle = to_gb_bundle(dev);
return sprintf(buf, "%d\n", bundle->device_id);
}
static DEVICE_ATTR_RO(device_id);
static ssize_t class_show(struct device *dev, struct device_attribute *attr, static ssize_t class_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
@ -61,7 +52,6 @@ static DEVICE_ATTR_RW(state);
static struct attribute *bundle_attrs[] = { static struct attribute *bundle_attrs[] = {
&dev_attr_device_id.attr,
&dev_attr_class.attr, &dev_attr_class.attr,
&dev_attr_state.attr, &dev_attr_state.attr,
NULL, NULL,
@ -184,9 +174,6 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
bundle->class = class; bundle->class = class;
INIT_LIST_HEAD(&bundle->connections); INIT_LIST_HEAD(&bundle->connections);
/* Invalid device id to start with */
bundle->device_id = GB_DEVICE_ID_BAD;
/* Build up the bundle device structures and register it with the /* Build up the bundle device structures and register it with the
* driver core */ * driver core */
bundle->dev.parent = &intf->dev; bundle->dev.parent = &intf->dev;
@ -225,7 +212,7 @@ void gb_bundle_destroy(struct gb_bundle *bundle)
device_unregister(&bundle->dev); device_unregister(&bundle->dev);
} }
int gb_bundle_init(struct gb_bundle *bundle, u8 device_id) int gb_bundle_init(struct gb_bundle *bundle)
{ {
struct gb_interface *intf = bundle->intf; struct gb_interface *intf = bundle->intf;
int ret; int ret;
@ -234,8 +221,6 @@ int gb_bundle_init(struct gb_bundle *bundle, u8 device_id)
if (intf->control && bundle->id == GB_CONTROL_BUNDLE_ID) if (intf->control && bundle->id == GB_CONTROL_BUNDLE_ID)
return 0; return 0;
bundle->device_id = device_id;
ret = gb_bundle_connections_init(bundle); ret = gb_bundle_connections_init(bundle);
if (ret) { if (ret) {
dev_err(intf->hd->parent, "interface bundle init error %d\n", dev_err(intf->hd->parent, "interface bundle init error %d\n",
@ -247,13 +232,13 @@ int gb_bundle_init(struct gb_bundle *bundle, u8 device_id)
return 0; return 0;
} }
int gb_bundles_init(struct gb_interface *intf, u8 device_id) int gb_bundles_init(struct gb_interface *intf)
{ {
struct gb_bundle *bundle; struct gb_bundle *bundle;
int ret = 0; int ret = 0;
list_for_each_entry(bundle, &intf->bundles, links) { list_for_each_entry(bundle, &intf->bundles, links) {
ret = gb_bundle_init(bundle, device_id); ret = gb_bundle_init(bundle);
if (ret) { if (ret) {
dev_err(intf->hd->parent, dev_err(intf->hd->parent,
"Failed to initialize bundle %hhu\n", "Failed to initialize bundle %hhu\n",

View File

@ -18,7 +18,6 @@ struct gb_bundle {
struct gb_interface *intf; struct gb_interface *intf;
u8 id; u8 id;
u8 class; u8 class;
u8 device_id;
struct list_head connections; struct list_head connections;
u8 *state; u8 *state;
@ -32,8 +31,8 @@ struct gb_bundle {
struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id, struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
u8 class); u8 class);
void gb_bundle_destroy(struct gb_bundle *bundle); void gb_bundle_destroy(struct gb_bundle *bundle);
int gb_bundle_init(struct gb_bundle *bundle, u8 device_id); int gb_bundle_init(struct gb_bundle *bundle);
int gb_bundles_init(struct gb_interface *intf, u8 device_id); int gb_bundles_init(struct gb_interface *intf);
struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id); struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id);
void gb_bundle_bind_protocols(void); void gb_bundle_bind_protocols(void);

View File

@ -102,7 +102,7 @@ struct device_type greybus_connection_type = {
void gb_connection_bind_protocol(struct gb_connection *connection) void gb_connection_bind_protocol(struct gb_connection *connection)
{ {
struct gb_bundle *bundle; struct gb_interface *intf;
struct gb_protocol *protocol; struct gb_protocol *protocol;
/* If we already have a protocol bound here, just return */ /* If we already have a protocol bound here, just return */
@ -117,11 +117,11 @@ void gb_connection_bind_protocol(struct gb_connection *connection)
connection->protocol = protocol; connection->protocol = protocol;
/* /*
* If we have a valid device_id for the bundle, then we have an active * If we have a valid device_id for the interface block, then we have an
* device, so bring up the connection at the same time. * active device, so bring up the connection at the same time.
* */ * */
bundle = connection->bundle; intf = connection->bundle->intf;
if (bundle->device_id != GB_DEVICE_ID_BAD) if (intf->device_id != GB_DEVICE_ID_BAD)
gb_connection_init(connection); gb_connection_init(connection);
} }

View File

@ -20,6 +20,7 @@ static ssize_t field##_show(struct device *dev, \
} \ } \
static DEVICE_ATTR_RO(field) static DEVICE_ATTR_RO(field)
gb_interface_attr(device_id, d);
gb_interface_attr(vendor, x); gb_interface_attr(vendor, x);
gb_interface_attr(product, x); gb_interface_attr(product, x);
gb_interface_attr(unique_id, llX); gb_interface_attr(unique_id, llX);
@ -27,6 +28,7 @@ gb_interface_attr(vendor_string, s);
gb_interface_attr(product_string, s); gb_interface_attr(product_string, s);
static struct attribute *interface_attrs[] = { static struct attribute *interface_attrs[] = {
&dev_attr_device_id.attr,
&dev_attr_vendor.attr, &dev_attr_vendor.attr,
&dev_attr_product.attr, &dev_attr_product.attr,
&dev_attr_unique_id.attr, &dev_attr_unique_id.attr,
@ -71,10 +73,9 @@ struct device_type greybus_interface_type = {
* managing control CPort. Also initialize the bundle, which will request SVC to * managing control CPort. Also initialize the bundle, which will request SVC to
* set route and will initialize the control protocol for this connection. * set route and will initialize the control protocol for this connection.
*/ */
static int gb_create_control_connection(struct gb_interface *intf, u8 device_id) static int gb_create_control_connection(struct gb_interface *intf)
{ {
struct gb_bundle *bundle; struct gb_bundle *bundle;
int ret;
bundle = gb_bundle_create(intf, GB_CONTROL_BUNDLE_ID, bundle = gb_bundle_create(intf, GB_CONTROL_BUNDLE_ID,
GREYBUS_CLASS_CONTROL); GREYBUS_CLASS_CONTROL);
@ -85,14 +86,6 @@ static int gb_create_control_connection(struct gb_interface *intf, u8 device_id)
GREYBUS_PROTOCOL_CONTROL)) GREYBUS_PROTOCOL_CONTROL))
return -EINVAL; return -EINVAL;
ret = gb_bundle_init(bundle, device_id);
if (ret) {
dev_err(&intf->dev,
"error %d initializing bundles for interface %hu\n",
ret, intf->interface_id);
return ret;
}
return 0; return 0;
} }
@ -136,6 +129,9 @@ struct gb_interface *gb_interface_create(struct greybus_host_device *hd,
INIT_LIST_HEAD(&intf->bundles); INIT_LIST_HEAD(&intf->bundles);
INIT_LIST_HEAD(&intf->manifest_descs); INIT_LIST_HEAD(&intf->manifest_descs);
/* Invalid device id to start with */
intf->device_id = GB_DEVICE_ID_BAD;
intf->dev.parent = &module->dev; intf->dev.parent = &module->dev;
intf->dev.bus = &greybus_bus_type; intf->dev.bus = &greybus_bus_type;
intf->dev.type = &greybus_interface_type; intf->dev.type = &greybus_interface_type;
@ -204,8 +200,10 @@ int gb_interface_init(struct gb_interface *intf, u8 device_id)
int ret, size; int ret, size;
void *manifest; void *manifest;
intf->device_id = device_id;
/* Establish control CPort connection */ /* Establish control CPort connection */
ret = gb_create_control_connection(intf, device_id); ret = gb_create_control_connection(intf);
if (ret) { if (ret) {
dev_err(&intf->dev, "Failed to create control CPort connection (%d)\n", ret); dev_err(&intf->dev, "Failed to create control CPort connection (%d)\n", ret);
return ret; return ret;
@ -243,12 +241,6 @@ int gb_interface_init(struct gb_interface *intf, u8 device_id)
goto free_manifest; goto free_manifest;
} }
ret = gb_bundles_init(intf, device_id);
if (ret)
dev_err(&intf->dev,
"Error %d initializing bundles for interface %hu\n",
ret, intf->interface_id);
/* /*
* XXX * XXX
* We've successfully parsed the manifest. Now we need to * We've successfully parsed the manifest. Now we need to

View File

@ -19,6 +19,7 @@ struct gb_interface {
struct list_head links; /* greybus_host_device->interfaces */ struct list_head links; /* greybus_host_device->interfaces */
struct list_head manifest_descs; struct list_head manifest_descs;
u8 interface_id; /* Physical location within the Endo */ u8 interface_id; /* Physical location within the Endo */
u8 device_id; /* Device id allocated for the interface block by the SVC */
/* Information taken from the manifest descriptor */ /* Information taken from the manifest descriptor */
u16 vendor; u16 vendor;