LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices



Reply
 
Search this Thread
Old 04-29-2011, 08:32 PM   #1
phil128
LQ Newbie
 
Registered: May 2009
Posts: 15

Rep: Reputation: 0
Device probing and disconnecting not working.


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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
USB drive not working properly, read only device? (USB key storage device) Arodef Linux - Hardware 14 01-01-2010 08:32 AM
ripd stops working after disconnecting VPN Crazy-EyE Linux - Networking 0 06-19-2009 10:20 AM
USB device (DDR pad) keeps disconnecting shadowsnipes Linux - Hardware 9 01-03-2009 06:21 PM
modem working (slmodem-2.9.10) - disconnecting patternscribe Linux - Laptop and Netbook 1 12-21-2004 09:03 PM


All times are GMT -5. The time now is 07:31 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration