Hi all.
I'm developing a USB driver atm. Every time I load/unload the module I cannot seem to be able to execute the probe/disconnect functions. I want to this, so that I know I can carry on developing the driver. My DEVICE and VENDOR ID's are correct (obtained from lsusb).
Here's my source code.
Code:
#include<linux/module.h>
#include<linux/init.h>
#include<linux/usb.h>
#include<linux/fs.h> /*file operations*/
#include<linux/device.h> /*usb_driver*/
#include<linux/types.h>
/*Product vendor and device id, obtained from lsusb.*/
#define VENDOR_ID 0x1770 /*KORYO USB*/
#define DEVICE_ID 0xff00 /*Controller*/
//USB device operations
static int dev_probe(struct usb_interface *interface, const struct usb_device_id *id);
static void dev_disconnect(struct usb_interface *interface);
static struct usb_device_id device_table[] = {
{
USB_DEVICE(VENDOR_ID,
DEVICE_ID)
},
{
}
};
MODULE_DEVICE_TABLE(usb, device_table);
static struct usb_driver dev_drv = {
.name = "dev",
.probe = dev_probe,
.disconnect = dev_disconnect,
.id_table = device_table,
};
static int dev_probe(struct usb_interface *interface, const struct usb_device_id *id)
{
printk("IN PROBING");
if (id->idVendor == VENDOR_ID
&& id->idProduct == DEVICE_ID ) {
printk("DEVICE MATCH");
}
return 0;
}
static void dev_disconnect(struct usb_interface *interface)
{
printk(KERN_INFO"dev DISCONNECTED");
}
static int dev_init(void)
{
int retval=usb_register(&dev_drv);
if (retval < 0) {
err("Unable to register USB device. Error code %d ", retVal);
return retval;
}
return 0;
}
static void dev_exit(void)
{
printk(KERN_INFO"MODULE UNLOADED");
usb_deregister(&dev_drv);
}
module_init(dev_init);
module_exit(dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("me");
MODULE_DESCRIPTION("");
MODULE_VERSION("v0.1");
I'm running Opensuse 11.4. I'm using dmesg and /var/log/messages for checking out the print outs.
I don't get it, I compile the module, insert it, and when I connect my device, even though the ID's are correct the probe and disconnect functions
don't get executed.
Thanks.