USB Question about devices being reconnected to the host

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm learning about USB drivers and I would like to know about disconnecting and reconnecting usb devices.

I can see my probe function being called and also the disconnect function. But if I reconnect the device there is no call from the kernel to notify my driver about the device being reconnected.

I can also see that the module for my driver was not unloaded, so I dont understand the life cycle of a USB device.

If the module is not unloaded at disconnection and re-loaded for a new device being connected, how can the driver know the device is there after a disconnection?

Thanks
Lucas

This is my dmesg for the driver at the end of this email:

[   34.706041] usb 1-1.1.2: new high-speed USB device number 5 using dwc_otg
[ 34.837647] usb 1-1.1.2: New USB device found, idVendor=04b4, idProduct=00f1, bcdDevice= 0.00 [ 34.837666] usb 1-1.1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   34.837679] usb 1-1.1.2: Product: FX3
[   34.837693] usb 1-1.1.2: Manufacturer: Cypress
[   34.902480] usbdev_probe
[   34.902681] usbcore: registered new interface driver My USB Device
[   45.416310] usb 1-1.1.2: USB disconnect, device number 5
[   45.416655] usbdev_disconnect
[   61.326035] usb 1-1.1.2: new high-speed USB device number 6 using dwc_otg
[ 61.457674] usb 1-1.1.2: New USB device found, idVendor=04b4, idProduct=00f1, bcdDevice= 0.00 [ 61.457692] usb 1-1.1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   61.457706] usb 1-1.1.2: Product: FX3
[   61.457720] usb 1-1.1.2: Manufacturer: Cypress

Driver:

#define DEBUG
#include <linux/of.h>
#include <linux/usb.h>
#include <linux/module.h>

static int usbdev_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
	pr_info("%s", __func__);

	return 0;
}

static void usbdev_disconnect(struct usb_interface *intf)
{
	pr_info("%s", __func__);
}

static int usbdev_suspend(struct usb_interface *intf, pm_message_t message)
{
	pr_err("%s", __func__);
	return 0;
}

static int usbdev_resume(struct usb_interface *intf)
{
	pr_info("%s", __func__);
	return 0;
}

static int usbdev_reset_resume(struct usb_interface *intf)
{
	pr_info("%s", __func__);
	return 0;
}

static int usbdev_pre_reset(struct usb_interface *intf)
{
	pr_info("%s", __func__);
	return 0;
}

static int usbdev_post_reset(struct usb_interface *intf)
{
	pr_info("%s", __func__);
	return 0;
}

static const struct usb_device_id usbdev_id_table[] = {
	{ USB_DEVICE(0x04b4, 0x00f1) },
	{}
};
MODULE_DEVICE_TABLE(usb, usbdev_id_table);

static struct usb_driver usbdev_driver = {
	.name			= "My USB Device",
	.probe			= usbdev_probe,
	.disconnect		= usbdev_disconnect,
	.id_table		= usbdev_id_table,
	.suspend	 	= usbdev_suspend,
	.resume			= usbdev_resume,
	.reset_resume 	= usbdev_reset_resume,
	.pre_reset		= usbdev_pre_reset,
	.post_reset 	= usbdev_post_reset,
};

module_usb_driver(usbdev_driver);

MODULE_AUTHOR("Lucas Tanure <tanure@xxxxxxxxx>");
MODULE_DESCRIPTION("Driver for My USB device");
MODULE_LICENSE("GPL v2");



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux