[U-Boot] [PATCH] usb: Alloc buffer for USB descriptor dynamically

Stefan Bruens stefan.bruens at rwth-aachen.de
Sat Dec 19 16:23:18 CET 2015


On Friday 18 December 2015 15:41:10 Simon Glass wrote:
> Hi,
> 
> On 17 December 2015 at 18:07, Stefan Brüns <stefan.bruens at rwth-aachen.de> 
wrote:
> > The configuration descriptor includes all interface, endpoint and
> > auxiliary descriptors (e.g. report, union) so 512 bytes may not be enough.
> > 
> > Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
> > ---
> > 
> >  common/usb.c  | 41 +++++++++++++++++++++++++++--------------
> >  include/usb.h |  5 +++--
> >  2 files changed, 30 insertions(+), 16 deletions(-)
> 
> Won't this call malloc() on every request? Can we avoid that?

This only affects the configuration descriptor, so one allocation per device.

One could use a stack allocated buffer for small, e.g. 512 bytes, descriptors, 
and use dynamic allocation only for larger one, but I don't think this is 
worth the effort.

Kind regards,

Stefan

-- 
Stefan Brüns  /  Bergstraße 21  /  52062 Aachen
home: +49 241 53809034     mobile: +49 151 50412019
work: +49 2405 49936-424


More information about the U-Boot mailing list