Re: [RFC 2/6] usb/dummy_hcd: add sg support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

On 08-12-2011 21:30, Sebastian Andrzej Siewior wrote:

This patch adds sg support to dummy_hcd. It seems that uas is not able
to work with a hcd which does not support sg only based transfers.

Signed-off-by: Sebastian Andrzej Siewior<bigeasy@xxxxxxxxxxxxx>
---
  drivers/usb/gadget/dummy_hcd.c |   78 ++++++++++++++++++++++++++++++++++++----
  1 files changed, 71 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index bfba4aa..5ba8e18 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
[...]
@@ -1084,9 +1085,10 @@ static int dummy_urb_enqueue (
  	unsigned long	flags;
  	int		rc;

-	if (!urb->transfer_buffer&&  urb->transfer_buffer_length)
-		return -EINVAL;
-
+	if (!urb->transfer_buffer&&  urb->transfer_buffer_length) {
+			if (!urb->num_sgs)
+				return -EINVAL;
+	}

Why not collapse all this into single *if*? Also, the last *if* seems overindented, and {} around it are not necessary.

  	urbp = kmalloc (sizeof *urbp, mem_flags);
  	if (!urbp)
  		return -ENOMEM;
@@ -1140,21 +1142,82 @@ static int dummy_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
[...]
  static int dummy_perform_transfer(struct urb *urb, struct dummy_request *req,
  		u32 len)
  {
  	void *ubuf, *rbuf;
  	int to_host;
+	struct sg_mapping_iter miter;
+	u32 flags = SG_MITER_ATOMIC;
+	u32 trans = 0;
+	u32 this_sg;

  	to_host = usb_pipein(urb->pipe);
  	rbuf = req->req.buf + req->req.actual;
-	ubuf = urb->transfer_buffer += urb->actual_length;
+
+	if (!urb->num_sgs) {
+		ubuf = urb->transfer_buffer += urb->actual_length;
+		if (to_host)
+			memcpy(ubuf, rbuf, len);
+		else
+			memcpy(rbuf, ubuf, len);
+		return len;
+	}

  	if (to_host)
-		memcpy(ubuf, rbuf, len);
+		flags |= SG_MITER_TO_SG;
  	else
-		memcpy(rbuf, ubuf, len);
-	return len;
+		flags |= SG_MITER_FROM_SG;
+
+	sg_miter_start(&miter, urb->sg, urb->num_sgs,
+			flags);

   No need to break the line above.

WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux