Discussion:
usblp : Seiko/Epson Printer M129C - poll/select always POLLIN
Richard Clark
2007-12-20 02:00:26 UTC
Permalink
I am using an Epson BA-T500 controller board that identifies itself the
same as the Seiko/Epson Printer M129C that was recently added to the
kernel.

In the past I had used my own driver created off of usb-skeleton.c, and
I did not bother with the bi-directional side.

Now that it's in the usblp.c driver, along with it's quirks, I am
starting to make use of the inbound bulk endpoint for printer status.

My problem is that even if there is no data present, the URB request
completes and usblp->rcomplete is flagged. This is causing my
poll/select call to always trigger even when there is no data.

Question - 1
Is this action normal for class based usb printers ? ie, the URB request
will complete and return even if there is no data.

Question - 2
I have solved my problem by changing the usblp_buld_read callback to
check for data before flaging usblp->rcomplete, and if not, resubmitting
the URB. Is there any problem with doing as I have below ?

static void usblp_bulk_read(struct urb *urb)
{
struct usblp *usblp = urb->context;

if (unlikely(!usblp || !usblp->dev || !usblp->used))
return;

if (unlikely(!usblp->present))
goto unplug;
if (unlikely(urb->status))
warn("usblp%d: nonzero read/write bulk status received:
%d",
usblp->minor, urb->status);
if (urb->actual_length)
usblp->rcomplete = 1;
else {
if (usb_submit_urb(usblp->readurb, GFP_ATOMIC) < 0)
err("usblp%d: Error resubmitting read urb",
usblp->minor);
}
unplug:
wake_up_interruptible(&usblp->wait);
}

Thanks for any info.

--
Richard C


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Greg KH
2007-12-23 07:56:30 UTC
Permalink
Post by Richard Clark
I am using an Epson BA-T500 controller board that identifies itself the
same as the Seiko/Epson Printer M129C that was recently added to the
kernel.
In the past I had used my own driver created off of usb-skeleton.c, and
I did not bother with the bi-directional side.
Now that it's in the usblp.c driver, along with it's quirks, I am
starting to make use of the inbound bulk endpoint for printer status.
My problem is that even if there is no data present, the URB request
completes and usblp->rcomplete is flagged. This is causing my
poll/select call to always trigger even when there is no data.
Question - 1
Is this action normal for class based usb printers ? ie, the URB request
will complete and return even if there is no data.
What does the usb printer spec say about this?
Post by Richard Clark
Question - 2
I have solved my problem by changing the usblp_buld_read callback to
check for data before flaging usblp->rcomplete, and if not, resubmitting
the URB. Is there any problem with doing as I have below ?
static void usblp_bulk_read(struct urb *urb)
{
struct usblp *usblp = urb->context;
if (unlikely(!usblp || !usblp->dev || !usblp->used))
return;
if (unlikely(!usblp->present))
goto unplug;
if (unlikely(urb->status))
%d",
usblp->minor, urb->status);
if (urb->actual_length)
usblp->rcomplete = 1;
else {
if (usb_submit_urb(usblp->readurb, GFP_ATOMIC) < 0)
err("usblp%d: Error resubmitting read urb",
usblp->minor);
}
wake_up_interruptible(&usblp->wait);
}
Can you send this in diff format so we can see exactly what was changed?

thanks,

greg k-h

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Richard Clark
2007-12-23 22:31:47 UTC
Permalink
Post by Greg KH
Post by Richard Clark
Question - 1
Is this action normal for class based usb printers ? ie, the URB request
will complete and return even if there is no data.
What does the usb printer spec say about this?
I have looked through the USB Device Class Def for Printing Devices, and
through the USB 1.1 spec but I can't find anything that answers it.
Post by Greg KH
From reading the Linux Device Drivers manual, things like
usb_bulk_message having a timeout parm makes me think that in general,
if there is not data, the bulk endpoint will not return without data.

This printer already deviates from the device class spec in other
regards.
Post by Greg KH
Post by Richard Clark
Question - 2
I have solved my problem by changing the usblp_buld_read callback to
check for data before flaging usblp->rcomplete, and if not, resubmitting
the URB. Is there any problem with doing as I have below ?
Can you send this in diff format so we can see exactly what was changed?
Yes, sorry, my bad.

--- drivers/usb/class/usblp.c.orig 2007-07-08 16:32:17.000000000 -0700
+++ drivers/usb/class/usblp.c 2007-12-19 17:30:41.000000000 -0800
@@ -277,27 +277,32 @@

static void usblp_bulk_read(struct urb *urb)
{
struct usblp *usblp = urb->context;

if (unlikely(!usblp || !usblp->dev || !usblp->used))
return;

if (unlikely(!usblp->present))
goto unplug;
if (unlikely(urb->status))
warn("usblp%d: nonzero read/write bulk status received:
%d",
usblp->minor, urb->status);
- usblp->rcomplete = 1;
+ if (urb->actual_length)
+ usblp->rcomplete = 1;
+ else {
+ if (usb_submit_urb(usblp->readurb, GFP_ATOMIC) < 0)
+ err("usblp%d: Error resubmitting read urb",
usblp->minor);
+ }
unplug:
wake_up_interruptible(&usblp->wait);
}



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Loading...