1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Driver for USB Mass Storage devices 4 * Usual Tables File for usb-storage and libusual 5 * 6 * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu) 7 */ 8 9 #include <linux/kernel.h> 10 #include <linux/module.h> 11 #include <linux/usb.h> 12 #include <linux/usb_usual.h> 13 14 15 /* 16 * The table of devices 17 */ 18 #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ 19 vendorName, productName, useProtocol, useTransport, \ 20 initFunction, flags) \ 21 { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ 22 .driver_info = (kernel_ulong_t)(flags) } 23 24 #define COMPLIANT_DEV UNUSUAL_DEV 25 26 #define USUAL_DEV(useProto, useTrans) \ 27 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) } 28 29 const struct usb_device_id usb_storage_usb_ids[] = { 30 # include "unusual_devs.h" 31 { } /* Terminating entry */ 32 }; 33 MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids); 34 35 #undef UNUSUAL_DEV 36 #undef COMPLIANT_DEV 37 #undef USUAL_DEV 38 39 /* 40 * The table of devices to ignore 41 */ 42 struct ignore_entry { 43 u16 vid, pid, bcdmin, bcdmax; 44 }; 45 46 #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ 47 vendorName, productName, useProtocol, useTransport, \ 48 initFunction, flags) \ 49 { \ 50 .vid = id_vendor, \ 51 .pid = id_product, \ 52 .bcdmin = bcdDeviceMin, \ 53 .bcdmax = bcdDeviceMax, \ 54 } 55 56 static const struct ignore_entry ignore_ids[] = { 57 # include "unusual_alauda.h" 58 # include "unusual_cypress.h" 59 # include "unusual_datafab.h" 60 # include "unusual_ene_ub6250.h" 61 # include "unusual_freecom.h" 62 # include "unusual_isd200.h" 63 # include "unusual_jumpshot.h" 64 # include "unusual_karma.h" 65 # include "unusual_onetouch.h" 66 # include "unusual_realtek.h" 67 # include "unusual_sddr09.h" 68 # include "unusual_sddr55.h" 69 # include "unusual_usbat.h" 70 { } /* Terminating entry */ 71 }; 72 73 #undef UNUSUAL_DEV 74 75 /* Return an error if a device is in the ignore_ids list */ 76 int usb_usual_ignore_device(struct usb_interface *intf) 77 { 78 struct usb_device *udev; 79 unsigned vid, pid, bcd; 80 const struct ignore_entry *p; 81 82 udev = interface_to_usbdev(intf); 83 vid = le16_to_cpu(udev->descriptor.idVendor); 84 pid = le16_to_cpu(udev->descriptor.idProduct); 85 bcd = le16_to_cpu(udev->descriptor.bcdDevice); 86 87 for (p = ignore_ids; p->vid; ++p) { 88 if (p->vid == vid && p->pid == pid && 89 p->bcdmin <= bcd && p->bcdmax >= bcd) 90 return -ENXIO; 91 } 92 return 0; 93 } 94