Re: [PATCH 2/2] USB: gadget: f_fs: even zero-length packets require a buffer

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

 



On Fri, 28 Jan 2011 10:23:58 +0100, Marek Szyprowski <m.szyprowski@xxxxxxxxxxx> wrote:
Some UDC drivers fails to queue a request if req->buf == NULL even for
ZLP requests. This patch add support for dummy request buffer in case of
ZLP request.

Signed-off-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>

Acked-by: Michal Nazarewicz <mina86@xxxxxxxxxx>

but see comment below:

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
@@ -356,6 +356,7 @@ static void ffs_ep0_complete(struct usb_ep *ep, struct usb_request *req)
 	complete_all(&ffs->ep0req_completion);
 }
+static char ffs_tmp_buf[1];
static int __ffs_ep0_queue_wait(struct ffs_data *ffs, char *data, size_t len)
 {
 	struct usb_request *req = ffs->ep0req;
@@ -368,6 +369,10 @@ static int __ffs_ep0_queue_wait(struct ffs_data *ffs, char *data, size_t len)
 	req->buf      = data;
 	req->length   = len;
+	/* UDC layer require to provide a buffer even for ZLP */
+	if (req->buf == NULL)
+		req->buf = ffs_tmp_buf;
+
 	INIT_COMPLETION(ffs->ep0req_completion);
	ret = usb_ep_queue(ffs->gadget->ep0, req, GFP_ATOMIC);

I'd put the static buffer inside the function as to not pollute global
namespace, ie:

+	/* UDC layer require to provide a buffer even for ZLP */
+	if (req->buf == NULL) {
+		static char dummy[1];
+		req->buf = dummy;
+	}
+

--
Best regards,                                       _     _
.o. | Liege of Serenly Enlightened Majesty of     o' \,=./ `o
..o | Computer Science,  Michal "mina86" Nazarewicz  (o o)
ooo +-<email/jid: mnazarewicz@xxxxxxxxxx>--------ooO--(_)--Ooo--
--
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