Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * Driver for USB Mass Storage devices
0004  * Usual Tables File for usb-storage and libusual
0005  *
0006  * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu)
0007  */
0008 
0009 #include <linux/kernel.h>
0010 #include <linux/module.h>
0011 #include <linux/usb.h>
0012 #include <linux/usb_usual.h>
0013 
0014 
0015 /*
0016  * The table of devices
0017  */
0018 #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
0019             vendorName, productName, useProtocol, useTransport, \
0020             initFunction, flags) \
0021 { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
0022   .driver_info = (flags) }
0023 
0024 #define COMPLIANT_DEV   UNUSUAL_DEV
0025 
0026 #define USUAL_DEV(useProto, useTrans) \
0027 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) }
0028 
0029 /* Define the device is matched with Vendor ID and interface descriptors */
0030 #define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \
0031             vendorName, productName, useProtocol, useTransport, \
0032             initFunction, flags) \
0033 { \
0034     .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
0035                 | USB_DEVICE_ID_MATCH_VENDOR, \
0036     .idVendor    = (id_vendor), \
0037     .bInterfaceClass = (cl), \
0038     .bInterfaceSubClass = (sc), \
0039     .bInterfaceProtocol = (pr), \
0040     .driver_info = (flags) \
0041 }
0042 
0043 const struct usb_device_id usb_storage_usb_ids[] = {
0044 #   include "unusual_devs.h"
0045     { }     /* Terminating entry */
0046 };
0047 MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
0048 
0049 #undef UNUSUAL_DEV
0050 #undef COMPLIANT_DEV
0051 #undef USUAL_DEV
0052 #undef UNUSUAL_VENDOR_INTF
0053 
0054 /*
0055  * The table of devices to ignore
0056  */
0057 struct ignore_entry {
0058     u16 vid, pid, bcdmin, bcdmax;
0059 };
0060 
0061 #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
0062             vendorName, productName, useProtocol, useTransport, \
0063             initFunction, flags) \
0064 {                   \
0065     .vid    = id_vendor,        \
0066     .pid    = id_product,       \
0067     .bcdmin = bcdDeviceMin,     \
0068     .bcdmax = bcdDeviceMax,     \
0069 }
0070 
0071 static const struct ignore_entry ignore_ids[] = {
0072 #   include "unusual_alauda.h"
0073 #   include "unusual_cypress.h"
0074 #   include "unusual_datafab.h"
0075 #   include "unusual_ene_ub6250.h"
0076 #   include "unusual_freecom.h"
0077 #   include "unusual_isd200.h"
0078 #   include "unusual_jumpshot.h"
0079 #   include "unusual_karma.h"
0080 #   include "unusual_onetouch.h"
0081 #   include "unusual_realtek.h"
0082 #   include "unusual_sddr09.h"
0083 #   include "unusual_sddr55.h"
0084 #   include "unusual_usbat.h"
0085     { }     /* Terminating entry */
0086 };
0087 
0088 #undef UNUSUAL_DEV
0089 
0090 /* Return an error if a device is in the ignore_ids list */
0091 int usb_usual_ignore_device(struct usb_interface *intf)
0092 {
0093     struct usb_device *udev;
0094     unsigned vid, pid, bcd;
0095     const struct ignore_entry *p;
0096 
0097     udev = interface_to_usbdev(intf);
0098     vid = le16_to_cpu(udev->descriptor.idVendor);
0099     pid = le16_to_cpu(udev->descriptor.idProduct);
0100     bcd = le16_to_cpu(udev->descriptor.bcdDevice);
0101 
0102     for (p = ignore_ids; p->vid; ++p) {
0103         if (p->vid == vid && p->pid == pid &&
0104                 p->bcdmin <= bcd && p->bcdmax >= bcd)
0105             return -ENXIO;
0106     }
0107     return 0;
0108 }