From: Stefan Bruens <stefan.bruens@rwth-aachen.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] usb: Alloc buffer for USB descriptor dynamically
Date: Sat, 19 Dec 2015 22:23:25 +0100 [thread overview]
Message-ID: <12735461.N5aXaCtTTG@pebbles.site> (raw)
In-Reply-To: <CAPnjgZ3cYcpW3A3ampZqfT1U1BbDqTrbYxmWJj9GUgOMZPqY6Q@mail.gmail.com>
On Saturday 19 December 2015 13:29:38 Simon Glass wrote:
> Hi Stafan,
>
> On 19 December 2015 at 08:23, Stefan Bruens
>
> <stefan.bruens@rwth-aachen.de> wrote:
> > On Friday 18 December 2015 15:41:10 Simon Glass wrote:
> >> Hi,
> >>
> >> On 17 December 2015 at 18:07, Stefan Br?ns <stefan.bruens@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@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
>
> Another approach would be to have a single buffer for the USB stack
> and increase its size as needed. But if this is only once per device
> it does not seem worth it either.
>
> Don't you need to free the buffer if usb_get_configuration_no()
> returns an error?
Yes, there's a free() missing in the error path.
Kind regards,
Stefan
--
Stefan Br?ns / Bergstra?e 21 / 52062 Aachen
home: +49 241 53809034 mobile: +49 151 50412019
work: +49 2405 49936-424
prev parent reply other threads:[~2015-12-19 21:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-13 4:47 [U-Boot] [PATCH 1/7] usb: increase USB descriptor buffer size Stefan Brüns
2015-12-13 4:49 ` Marek Vasut
2015-12-13 18:35 ` Stefan Bruens
2015-12-13 18:49 ` Marek Vasut
2015-12-18 1:07 ` [U-Boot] [PATCH] usb: Alloc buffer for USB descriptor dynamically Stefan Brüns
2015-12-18 20:19 ` Marek Vasut
2015-12-18 22:41 ` Simon Glass
2015-12-19 15:23 ` Stefan Bruens
2015-12-19 20:29 ` Simon Glass
2015-12-19 21:23 ` Stefan Bruens [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12735461.N5aXaCtTTG@pebbles.site \
--to=stefan.bruens@rwth-aachen.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.