From: Stefan Bruens Date: Sat, 19 Dec 2015 16:23:18 +0100 Subject: [U-Boot] [PATCH] usb: Alloc buffer for USB descriptor dynamically In-Reply-To: References: <201512131949.30977.marex@denx.de> <1450400841-22457-1-git-send-email-stefan.bruens@rwth-aachen.de> Message-ID: <3109782.Zl1M3lA0IY@pebbles.site> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Friday 18 December 2015 15:41:10 Simon Glass wrote: > Hi, > > On 17 December 2015 at 18:07, Stefan Br?ns 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 > > --- > > > > 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