stm32mp157/usb/usb_detect/usb_detect.c

35 lines
1.1 KiB
C

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/can/dev.h>
static struct usb_device_id usb_detect_id_table[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(0xffff, 0xffff, 0xff, 0xff, 0x02), .driver_info = 1 }, // ctrl
{ USB_DEVICE_AND_INTERFACE_INFO(0xffff, 0xffff, 0xff, 0xff, 0x0a), .driver_info = 2 }, // data
{ }
};
static int usb_detect_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
printk("%s %s %d\r\n", __FILE__, __FUNCTION__, __LINE__);
printk("USB device detected: vendor=0x%04X, product=0x%04X, info=%ld\r\n",
id->idVendor, id->idProduct, id->driver_info);
return 0;
}
static void usb_detect_disconnect(struct usb_interface *intf)
{
printk("%s %s %d\r\n", __FILE__, __FUNCTION__, __LINE__);
printk("USB device disconnected\r\n");
}
static struct usb_driver usb_detect_driver = {
.name = "usb_detect_driver",
.probe = usb_detect_probe,
.disconnect = usb_detect_disconnect,
.id_table = usb_detect_id_table,
};
module_usb_driver(usb_detect_driver);
MODULE_LICENSE("GPL");