Skip to contentSkip to conversation

USB: g_printer: fix handling zero-length packet

PATCH In review sangsu 2 participants 2 messages Sep 20, 2008 USB

lore
Share & tools
lore

sangsu

author
#0 lore raw

PATCH 1/1 USB: g_printer: fix handling zero-length packet

g_printer doesn't have to check whether the data size is a multiple of MaxPacketSize, because device controller driver already make that check.

---
drivers/usb/gadget/printer.c | 3++-

1 files changed, 2 insertion(+), 1 deletions(-)
drivers/usb/gadget/printer.c +0 -0
@@ -1264,8 +1264,7 @@
	/* respond with data transfer before status phase? */
	if (value >= 0) {
		req->length = value;
-		req->zero = value < wLength
-				&& (value % gadget->ep0->maxpacket) == 0;
+		req->zero = value < wLength;
		value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
		if (value < 0) {
			DBG(dev, "ep_queue --> %d\n", value);
#1 lore raw
Quoted 12 lines · sangsu

g_printer doesn't have to check whether the data size is a multiple of MaxPacketSize, because device controller driver already make that check.

---
drivers/usb/gadget/printer.c | 3++-

1 files changed, 2 insertion(+), 1 deletions(-)

drivers/usb/gadget/printer.c line 1270

Quoted 9 lines
drivers/usb/gadget/printer.c +1 -2
@@ -1264,8 +1264,7 @@
 	/* respond with data transfer before status phase? */
 	if (value >= 0) {
 		req->length = value;
-		req->zero = value < wLength
-				&& (value % gadget->ep0->maxpacket) == 0;
+		req->zero = value < wLength;
 		value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
 		if (value < 0) {
 			DBG(dev, "ep_queue --> %d\n", value);

When posting changes like this you should add Greg KH to the CC: list; otherwise he won't realize this patch needs to be merged.

You should also CC: the author of the original code -- but in this case you can't because Craig Nadler didn't include his email address in the source file.

For what it's worth, this patch looks okay to me.

Alan Stern