From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/4] USB: Staticize usb_storage.c
Date: Tue, 14 Feb 2012 00:37:24 -0500 [thread overview]
Message-ID: <201202140037.25015.vapier@gentoo.org> (raw)
In-Reply-To: <1329195499-20414-5-git-send-email-marek.vasut@gmail.com>
On Monday 13 February 2012 23:58:19 Marek Vasut wrote:
> Also, make usb_stor_buf local.
probably should get split out into its own patch
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
>
> int usb_stor_scan(int mode)
> ...
> unsigned char i;
> struct usb_device *dev;
>
> - /* GJ */
> - memset(usb_stor_buf, 0, sizeof(usb_stor_buf));
> -
> if (mode == 1)
> printf(" scanning bus for storage devices... ");
> ...
> -int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
> +static int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
> block_dev_desc_t *dev_desc)
> {
> unsigned char perq, modi;
> unsigned long cap[2];
> unsigned long *capacity, *blksz;
> ccb *pccb = &usb_ccb;
> + unsigned char usb_stor_buf[512];
> +
> + /* GJ */
> + memset(usb_stor_buf, 0, sizeof(usb_stor_buf));
before, the code would do:
usb_stor_scan() {
memset(usb_stor_buf)
for (...) {
usb_stor_get_info() {
... use usb_stor_buf ...
}
}
}
now the new code calls memset multiple times. in a cursory reading of the
code, i'd say just drop the memset altogether. the get_info func will return
if the usb_inquiry call failed and the buffer contents don't matter. if
usb_query worked, then the buffer should contain valid data and the memset was
pointless.
looking a bit more, i think 512 is too big. it makes sense when it's a global
dumping ground that random parts of the code would use. but this buffer is
only used with usb_inquiry (which in reality is the SCSI INQUIRY command), and
that should require just 36 bytes.
so my suggestion would be:
- drop usb_stor_buf changes from this patch and make a dedicated one
- drop the useless GJ comment
- drop the useless memset
- shrink the buffer to 36 bytes
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120214/08b18e72/attachment.pgp>
prev parent reply other threads:[~2012-02-14 5:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-14 4:58 [U-Boot] [PATCH 0/4] USB cleanup Marek Vasut
2012-02-14 4:58 ` [U-Boot] [PATCH 1/4] USB: Staticize internal functions Marek Vasut
2012-02-14 5:21 ` Mike Frysinger
2012-02-14 4:58 ` [U-Boot] [PATCH 2/4] USB: Separate out USB hub driver Marek Vasut
2012-02-14 5:25 ` Mike Frysinger
2012-02-14 5:59 ` Marek Vasut
2012-02-14 4:58 ` [U-Boot] [PATCH 3/4] USB: Make struct devrequest setup_packet local Marek Vasut
2012-02-14 5:25 ` Mike Frysinger
2012-02-14 4:58 ` [U-Boot] [PATCH 4/4] USB: Staticize usb_storage.c Marek Vasut
2012-02-14 5:37 ` Mike Frysinger [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=201202140037.25015.vapier@gentoo.org \
--to=vapier@gentoo.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox