How to overload function in a kernel module
Hi there,
I'm trying to write a USB kernel driver. When I look at a simple code of a skeleton module, I see there's a function called "qusb_read". No matter what its name, because there's a structure to specify the relation: static struct file_operations qusb_fops = { .owner = THIS_MODULE, .read = qusb_read, .write = qusb_write, .open = qusb_open, .release = qusb_release, }; It's similar to write function. In this "read" func, they use "usb_bulk_msg" that transfers bulk transfer. How can I implement with usb_control_msg that works with contron transfer? Could these functions co-exist? I mean overload functions? Thanks in advance. Jakov |
Hi -
Read this: http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html The answer to your specific question (about "fops" and how it works) is in section 4.1.1. C++ handles polymorphic functions with a "vtable". You can think of fops as being similar to a vtable: it allows you to to provide a "polymorphic" set of standard operations (open, read, write, close, etc) specific to a particular device. 'Hope that helps .. PSM |
Quote:
Best regards, Jakov |
All times are GMT -5. The time now is 02:40 PM. |