I am trying to write a basic device driver in Linux to perform IO on USB mass storage devices. I am using 2.6.34 kernel for the same. I used usb-skeleton.c that comes with the kernel to understand the correct working of USB core's APIs. I compiled it, inserted it generated /dev/skel0 device for my USB flash drive.
http://lxr.free-electrons.com/source/drivers/usb/usb-skeleton.c?v=2.6.34
I wrote 1 packet of 1024 bytes on the device but to my surprise, the write failed with Input/Output error.
# insmod usb-skeleton.ko
# ls /dev/skel0
/dev/skel0
# dd if=/dev/urandom of=/dev/skel0 bs=1024 count=1
dd closing output file `/dev/ask0': Input/Output error
When I wrote data, skeleton driver's write function and even the write callback is getting called but still the IO failed.
As usb-skeleton.c comes with Linux kernel, I am sure that it would be rigorously tested and flawless. I must be doing something wrong and being a novice in device driver programming, am unable to realize the mistake. I would appreciate any help in this matter.
Thank you.