aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb/usb-xhci.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2015-11-25 20:58:16 +0100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2015-12-01 17:02:04 +1100
commitedd582383f9800e61b48669f7515e5d334ef961b (patch)
treea85976b28a1216b53028cc36f7ff0de604d933b3 /lib/libusb/usb-xhci.c
parent3d5e62eea27cab3deaa1f9399dd619ad1638fa89 (diff)
downloadSLOF-edd582383f9800e61b48669f7515e5d334ef961b.zip
SLOF-edd582383f9800e61b48669f7515e5d334ef961b.tar.gz
SLOF-edd582383f9800e61b48669f7515e5d334ef961b.tar.bz2
Stack optimization in libusb: split up setup_new_device()
When scanning hubs, the code in libusb can be called recursively, for example usb_hub_init() calls setup_new_device(), which then calls slof_usb_handle() to execute Forth code for the next device. If that next device is a hub, we end up recursively in usb_hub_init() again. Since stack space is limited in SLOF, we can optimize here a little bit by splitting up the setup_new_device() function into the part that retrieves the descriptors (which takes most of the stack space in this code path since the descriptors are placed on the stack), and the part that populates the the device tree node of the new device (which is responsible for the recursion). Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'lib/libusb/usb-xhci.c')
-rw-r--r--lib/libusb/usb-xhci.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c
index 7683c51..858cd12 100644
--- a/lib/libusb/usb-xhci.c
+++ b/lib/libusb/usb-xhci.c
@@ -608,8 +608,10 @@ static bool xhci_alloc_dev(struct xhci_hcd *xhcd, uint32_t slot_id, uint32_t por
dev->port = newport;
dev->priv = xdev;
xdev->dev = dev;
- if (setup_new_device(dev, newport))
+ if (usb_setup_new_device(dev, newport)) {
+ usb_slof_populate_new_device(dev);
return true;
+ }
xhci_free_ctx(&xdev->out_ctx, XHCI_CTX_BUF_SIZE);
fail_control_seg: