greybus: interface: register control device at hotplug

Make sure to register also the control device along with any bundles
when registering an interface.

Note that we currently ignore failures to register the control device
just as we do for bundle devices.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Johan Hovold 2016-04-13 19:19:03 +02:00 коммит произвёл Greg Kroah-Hartman
Родитель a6e5b014b8
Коммит 7326e07b58
3 изменённых файлов: 27 добавлений и 0 удалений

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

@ -294,6 +294,27 @@ void gb_control_disable(struct gb_control *control)
gb_connection_disable(control->connection); gb_connection_disable(control->connection);
} }
int gb_control_add(struct gb_control *control)
{
int ret;
ret = device_add(&control->dev);
if (ret) {
dev_err(&control->dev,
"failed to register control device: %d\n",
ret);
return ret;
}
return 0;
}
void gb_control_del(struct gb_control *control)
{
if (device_is_registered(&control->dev))
device_del(&control->dev);
}
void gb_control_put(struct gb_control *control) void gb_control_put(struct gb_control *control)
{ {
put_device(&control->dev); put_device(&control->dev);

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

@ -26,6 +26,8 @@ struct gb_control {
struct gb_control *gb_control_create(struct gb_interface *intf); struct gb_control *gb_control_create(struct gb_interface *intf);
int gb_control_enable(struct gb_control *control); int gb_control_enable(struct gb_control *control);
void gb_control_disable(struct gb_control *control); void gb_control_disable(struct gb_control *control);
int gb_control_add(struct gb_control *control);
void gb_control_del(struct gb_control *control);
void gb_control_put(struct gb_control *control); void gb_control_put(struct gb_control *control);
int gb_control_get_bundle_versions(struct gb_control *control); int gb_control_get_bundle_versions(struct gb_control *control);

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

@ -537,6 +537,7 @@ void gb_interface_disable(struct gb_interface *intf)
list_for_each_entry_safe(bundle, next, &intf->bundles, links) list_for_each_entry_safe(bundle, next, &intf->bundles, links)
gb_bundle_destroy(bundle); gb_bundle_destroy(bundle);
gb_control_del(intf->control);
gb_control_disable(intf->control); gb_control_disable(intf->control);
} }
@ -557,6 +558,9 @@ int gb_interface_add(struct gb_interface *intf)
dev_info(&intf->dev, "DDBL1 Manufacturer=0x%08x, Product=0x%08x\n", dev_info(&intf->dev, "DDBL1 Manufacturer=0x%08x, Product=0x%08x\n",
intf->ddbl1_manufacturer_id, intf->ddbl1_product_id); intf->ddbl1_manufacturer_id, intf->ddbl1_product_id);
/* NOTE: ignoring errors for now */
gb_control_add(intf->control);
list_for_each_entry_safe_reverse(bundle, tmp, &intf->bundles, links) { list_for_each_entry_safe_reverse(bundle, tmp, &intf->bundles, links) {
ret = gb_bundle_add(bundle); ret = gb_bundle_add(bundle);
if (ret) { if (ret) {