Re: [PATCH] USB: g_mass_storage: superfluous and missing packets fixed

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

 



On Tue, 26 Jan 2010, Michal Nazarewicz wrote:
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index a37640e..84f6491 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -614,7 +614,13 @@ static int fsg_setup(struct usb_function *f,
 			return -EDOM;
 		VDBG(fsg, "get max LUN\n");
 		*(u8 *) req->buf = fsg->common->nluns - 1;
-		return 1;
+
+		/* Respond with data/status */
+		req->length = 1;
+		req->zero = 1 < w_length;

On Tue, 26 Jan 2010 16:24:07 +0100, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
I'm not familiar with the context here.  It sure looks like the routine
originally named class_setup_req() was renamed to fsg_setup(), and the
additional code originally present in fsg_setup() was dropped.  That
could easily be a bug... I don't know if it really is.

Yes, that's the case.  As I was converting FSG into a composite function
I removed standard USB requests handling and moved class requests handling
from class_setup_req() to fsg_setup().  Doing so, I've somehow overlooked
the code for posting a reply (it didn't show up in tests until we got
a proper hardware USB analyser).

Regardless, setting req->length to 1 is probably wrong if w_length is
0.  And setting req->zero at all is unnecessary.

That's the thing done in original fsg_setup() (in file storage gadget):

	if (rc >= 0 && rc != DELAYED_STATUS) {
		rc = min(rc, w_length);
		fsg->ep0req->length = rc;
		fsg->ep0req->zero = rc < w_length;
		fsg->ep0req_name = (ctrl->bRequestType & USB_DIR_IN ?
				"ep0-in" : "ep0-out");
		rc = ep0_queue(fsg);
	}

as well as in composite:

	if (value >= 0) {
		req->length = value;
		req->zero = value < w_length;
		value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
		if (value < 0) {
			DBG(cdev, "ep_queue --> %d\n", value);
			req->status = 0;
			composite_setup_complete(gadget->ep0, req);
		}
	}

so I assumed it's the correct thing to do.

+		fsg->common->ep0req_name =
+			ctrl->bRequestType & USB_DIR_IN ? "ep0-in" : "ep0-out";
+		return ep0_queue(fsg->common);

--
Best regards,                                           _     _
 .o. | Liege of Serenely Enlightened Majesty of       o' \,=./ `o
 ..o | Computer Science,  Michał "mina86" Nazarewicz     (o o)
 ooo +---[mina86@xxxxxxxxxx]---[mina86@jabber.org]---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