diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2015-11-04 18:55:22 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-11-04 20:35:18 -0800 |
commit | c1700479845bc36cb48719b2ae341d4df89a73f6 (patch) | |
tree | 60aefe5a11e470a52aa53cc81e5962422df262b9 /drivers/staging/greybus/hd.c | |
parent | b4bd3617ed069a0aae701ed451cb6ec370fbd45f (diff) |
greybus: hd: fix host-device life time issues
Fix host-device life time issues by separating host-device allocation
from registration.
This is needed both to make sure that all host-device resources are
available before registering the device and to prevent such resources
from being deallocated while the device is still in use during device
removal.
This specifically fixes the following warnings during es1 and es2
disconnect:
usb 1-1.1: No free CPort OUT urbs, having to dynamically allocate one!
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/hd.c')
-rw-r--r-- | drivers/staging/greybus/hd.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/staging/greybus/hd.c b/drivers/staging/greybus/hd.c index 6f29eb49993a..b22d5470508a 100644 --- a/drivers/staging/greybus/hd.c +++ b/drivers/staging/greybus/hd.c @@ -77,6 +77,12 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver, hd->buffer_size_max = buffer_size_max; hd->num_cports = num_cports; + return hd; +} +EXPORT_SYMBOL_GPL(gb_hd_create); + +int gb_hd_add(struct gb_host_device *hd) +{ /* * Initialize AP's SVC protocol connection: * @@ -87,16 +93,14 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver, * time we will create a fully initialized svc-connection, as we need * endo-id and AP's interface id for that. */ - if (!gb_ap_svc_connection_create(hd)) { - kref_put_mutex(&hd->kref, free_hd, &hd_mutex); - return ERR_PTR(-ENOMEM); - } + if (!gb_ap_svc_connection_create(hd)) + return -ENOMEM; - return hd; + return 0; } -EXPORT_SYMBOL_GPL(gb_hd_create); +EXPORT_SYMBOL_GPL(gb_hd_add); -void gb_hd_remove(struct gb_host_device *hd) +void gb_hd_del(struct gb_host_device *hd) { /* * Tear down all interfaces, modules, and the endo that is associated @@ -109,7 +113,11 @@ void gb_hd_remove(struct gb_host_device *hd) /* Is the SVC still using the partially uninitialized connection ? */ if (hd->initial_svc_connection) gb_connection_destroy(hd->initial_svc_connection); +} +EXPORT_SYMBOL_GPL(gb_hd_del); +void gb_hd_put(struct gb_host_device *hd) +{ kref_put_mutex(&hd->kref, free_hd, &hd_mutex); } -EXPORT_SYMBOL_GPL(gb_hd_remove); +EXPORT_SYMBOL_GPL(gb_hd_put); |