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 USER SPACE:
In IFDHICCPresence(), there are:
......
ret = read(SmartCard[readerNum].fd, buffer, sizeof(buffer));
PRINTFD("read %d\n", ret);
if (ret != 4)
return IFD_COMMUNICATION_ERROR;
......
The return value of read is 10 on kernel 2.6.8, but 4 on kernel 2.6.11.
In KERNEL SPACE:
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
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle