EmbLogic's Blog

usb driver.probe function not call properly ? please provide me appropriate solution?

#include<linux/init.h>
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/usb.h>
#include<linux/fs.h>              //for struct file_operations
#include<linux/slab.h>           //for kmalloc
#include<linux/kref.h>          //for struct kref
#include<linux/mutex.h>        //for struct mutex
#include<linux/device.h>      //for structure device
#include<linux/completion.h>  //for struct completion
#include<linux/interrupt.h>
#include<linux/writeback.h>
MODULE_LICENSE(“GPL”);
MODULE_AUTHOR(“lkm”);

static int gdm7213_probe(struct usb_interface *interface, const struct usb_device_id *id);
void gdm7213_disconnect (struct usb_interface *intf);

static struct usb_device_id gdm7213_table [] = {
{ USB_DEVICE(0x03f0,0×5307) },            //my flash drive vendor id ,product id.u can check it with ur device.
{ }
};

MODULE_DEVICE_TABLE(usb, gdm7213_table);

static struct usb_driver gdm7213_driver = {
.name                 = “lkm”,
.probe                = gdm7213_probe,
.disconnect           = gdm7213_disconnect,
//    .suspend              = gdm7213_suspend,
//    .resume               = gdm7213_resume,
//  .pre_reset            = gdm7213_pre_reset,
//    .post_reset           = gdm7213_post_reset,
.id_table             = gdm7213_table,
};

static int gdm7213_probe(struct usb_interface *interface, const struct usb_device_id *id)
{
printk(KERN_INFO “GDM7213 gdm7213_probe()\n”);
return 0;
}
void gdm7213_disconnect (struct usb_interface *intf)
{
printk(KERN_INFO “GDM7213 gdm7213_disconnect()\n”);

}

static int __init gdm7213_init_module(void)
{
int result;
printk(KERN_INFO “GDM7213 init_module()\n”);

result = usb_register(&gdm7213_driver);
if (result)
err(“usb_register failed. Error number %d”, result);
else
printk(KERN_INFO “usb registerd\n”);
return result;
}

static void __exit gdm7213_cleanup_module(void)
{
printk(KERN_INFO “GDM7213 cleanup_module()\n”);
usb_deregister(&gdm7213_driver);
}

module_init(gdm7213_init_module);
module_exit(gdm7213_cleanup_module);

One Response to usb driver.probe function not call properly ? please provide me appropriate solution?

  1. kpeswani says:

    Ur code is correct…
    the only thing u need to check is whether ur device’s vid & pid are same as given, if u r not sure abt then give
    {.driver_info=42}
    Also in probe u need to register ur device by usb_register_dev(interface,class) for the device to be shown in /proc filesystem

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>