On Thu, 9 Feb 2006, mail mail wrote:

> Hi,
> 
> I wrote a USB smart card device driver for kernel 2.6. I can run it
> with no error on kernel 2.6.11, but fail on kernel 2.6.8 and 2.6.14.
> Now I can locate that the problem exist in copy_to_user() system call.
> My environment is Debian Sarge 2.6.8-2-386.
> 
> In skel_read(), there are:
> ......
>         /* do a blocking bulk read to get data from the device */
>         retval = usb_bulk_msg(dev->udev,
>                               usb_rcvbulkpipe(dev->udev,
> dev->bulk_in_endpointAddr),
>                               dev->bulk_in_buffer,
>                               min(dev->bulk_in_size, count),
>                               //dev->bulk_in_size,
>                               &count, HZ*10);
> 
>         info("retval of skel_read %d", retval);
> 
>         /* if the read was successful, copy the data to userspace */
>         if (!retval) {
>                 if (copy_to_user(buffer, dev->bulk_in_buffer, count)) {
>                         info("fault");
>                         retval = -EFAULT;
>                 }
>                 else
>                 {
>                         retval = count;
>                         info("good");
>                         info("retval of copy_to_user is %d", retval);
>                 }
>         }
> ......
> 
> The output of the above code is :
> Feb  9 15:03:36 localhost kernel: /root/bnewDT3500/kernel/DT3500.c:
> retval of skel_read 0
> Feb  9 15:03:36 localhost kernel: /root/bnewDT3500/kernel/DT3500.c: good
> Feb  9 15:03:36 localhost kernel: /root/bnewDT3500/kernel/DT3500.c:
> retval of copy_to_user is 10
> 
> In the right case, the return value of copy_to_user should be 4 on my
> PC, and 4 is also the value on kernel 2.6.11 which can run the driver
> successfully.

Without getting too involved in this, I'd like to point out that your 
driver fragment doesn't print out the value returned by copy_to_user.  It 
prints out the value of count, which is the actual transfer length from 
usb_bulk_msg.  The fact that you see the "retval of copy_to_user" message 
at all means that copy_to_user actually returned 0.

Alan Stern



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to