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.

What is the matter with copy_to_user? or kernel space and user space?
What method can I use to debug with it?

Thanks in advanced.

Best regards,
TowerGee


-------------------------------------------------------
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&kid3432&bid#0486&dat1642
_______________________________________________
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