From 7326e07b588cace823a36d4a563838b051b8b8a5 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 13 Apr 2016 19:19:03 +0200 Subject: [PATCH] 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/control.c | 21 +++++++++++++++++++++ drivers/staging/greybus/control.h | 2 ++ drivers/staging/greybus/interface.c | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/drivers/staging/greybus/control.c b/drivers/staging/greybus/control.c index c303bb2937bc..606361906482 100644 --- a/drivers/staging/greybus/control.c +++ b/drivers/staging/greybus/control.c @@ -294,6 +294,27 @@ void gb_control_disable(struct gb_control *control) 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) { put_device(&control->dev); diff --git a/drivers/staging/greybus/control.h b/drivers/staging/greybus/control.h index 697f901b34a7..102e937a982c 100644 --- a/drivers/staging/greybus/control.h +++ b/drivers/staging/greybus/control.h @@ -26,6 +26,8 @@ struct gb_control { struct gb_control *gb_control_create(struct gb_interface *intf); int gb_control_enable(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); int gb_control_get_bundle_versions(struct gb_control *control); diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index 56a320732ef9..e0e08731c055 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -537,6 +537,7 @@ void gb_interface_disable(struct gb_interface *intf) list_for_each_entry_safe(bundle, next, &intf->bundles, links) gb_bundle_destroy(bundle); + gb_control_del(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", 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) { ret = gb_bundle_add(bundle); if (ret) { -- 2.20.1