From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/9] USB core: Allocate tmpbuf using dma_alloc
Date: Thu, 21 Jun 2012 11:55:11 +0200 [thread overview]
Message-ID: <1340272517-8972-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1340272517-8972-1-git-send-email-s.hauer@pengutronix.de>
This needs to be dma save.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/core/usb.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 264ca2d..a5075d5 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -299,12 +299,14 @@ static int usb_new_device(struct usb_device *dev)
{
int addr, err;
int tmp;
- unsigned char tmpbuf[USB_BUFSIZ];
+ void *buf;
struct usb_device_descriptor *desc;
int port = -1;
struct usb_device *parent = dev->parent;
unsigned short portstatus;
+ buf = dma_alloc(USB_BUFSIZ);
+
/* We still haven't set the Address yet */
addr = dev->devnum;
dev->devnum = 0;
@@ -322,7 +324,7 @@ static int usb_new_device(struct usb_device *dev)
* the maxpacket size is 8 or 16 the device may be waiting to transmit
* some more, or keeps on retransmitting the 8 byte header. */
- desc = (struct usb_device_descriptor *)tmpbuf;
+ desc = buf;
dev->descriptor->bMaxPacketSize0 = 64; /* Start off at 64 bytes */
/* Default to 64 byte max packet size */
dev->maxpacketsize = PACKET_SIZE_64;
@@ -332,7 +334,7 @@ static int usb_new_device(struct usb_device *dev)
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64);
if (err < 0) {
USB_PRINTF("%s: usb_get_descriptor() failed with %d\n", __func__, err);
- return 1;
+ goto err_out;
}
dev->descriptor->bMaxPacketSize0 = desc->bMaxPacketSize0;
@@ -349,14 +351,15 @@ static int usb_new_device(struct usb_device *dev)
}
if (port < 0) {
printf("%s: cannot locate device's port.\n", __func__);
- return 1;
+ err = -ENODEV;
+ goto err_out;
}
/* reset the port for the second time */
err = hub_port_reset(dev->parent, port, &portstatus);
if (err < 0) {
printf("\n Couldn't reset port %i\n", port);
- return 1;
+ goto err_out;
}
}
@@ -383,7 +386,7 @@ static int usb_new_device(struct usb_device *dev)
if (err < 0) {
printf("\n USB device not accepting new address " \
"(error=%lX)\n", dev->status);
- return 1;
+ goto err_out;
}
wait_ms(10); /* Let the SET_ADDRESS settle */
@@ -399,7 +402,7 @@ static int usb_new_device(struct usb_device *dev)
else
printf("USB device descriptor short read " \
"(expected %i, got %i)\n", tmp, err);
- return 1;
+ goto err_out;
}
/* correct le values */
le16_to_cpus(&dev->descriptor->bcdUSB);
@@ -407,14 +410,14 @@ static int usb_new_device(struct usb_device *dev)
le16_to_cpus(&dev->descriptor->idProduct);
le16_to_cpus(&dev->descriptor->bcdDevice);
/* only support for one config for now */
- usb_get_configuration_no(dev, &tmpbuf[0], 0);
- usb_parse_config(dev, &tmpbuf[0], 0);
+ usb_get_configuration_no(dev, buf, 0);
+ usb_parse_config(dev, buf, 0);
usb_set_maxpacket(dev);
/* we set the default configuration here */
if (usb_set_configuration(dev, dev->config.bConfigurationValue)) {
printf("failed to set default configuration " \
"len %d, status %lX\n", dev->act_len, dev->status);
- return -1;
+ goto err_out;
}
USB_PRINTF("new device: Mfr=%d, Product=%d, SerialNumber=%d\n",
dev->descriptor->iManufacturer, dev->descriptor->iProduct,
@@ -441,7 +444,11 @@ static int usb_new_device(struct usb_device *dev)
register_device(&dev->dev);
list_add_tail(&dev->list, &usb_device_list);
- return 0;
+ err = 0;
+
+err_out:
+ dma_free(buf);
+ return err;
}
static struct usb_device *usb_alloc_new_device(void)
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-06-21 9:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-21 9:55 [PATCH] more dma fixes Sascha Hauer
2012-06-21 9:55 ` [PATCH 1/9] USB core: allocate setup_packet using dma_alloc Sascha Hauer
2012-06-21 9:55 ` [PATCH 2/9] USB core: device descriptor " Sascha Hauer
2012-06-21 9:55 ` Sascha Hauer [this message]
2012-06-21 9:55 ` [PATCH 4/9] USB ehci: Use dma coherent buffers for qh/qtd Sascha Hauer
2012-06-21 9:55 ` [PATCH 5/9] USB ehci: put fields of struct qTD directly into struct QH Sascha Hauer
2012-06-21 9:55 ` [PATCH 6/9] USB storage: use dma_alloc where appropriate Sascha Hauer
2012-06-21 9:55 ` [PATCH 7/9] block: use dma_alloc to allocate buffers Sascha Hauer
2012-06-21 9:55 ` [PATCH 8/9] partition: Use dma_alloc for allocating buffers Sascha Hauer
2012-06-21 9:55 ` [PATCH 9/9] USB ehci: rework cache handling Sascha Hauer
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=1340272517-8972-4-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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