18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Driver for USB Mass Storage devices 48c2ecf20Sopenharmony_ci * Usual Tables File for usb-storage and libusual 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu) 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/kernel.h> 108c2ecf20Sopenharmony_ci#include <linux/module.h> 118c2ecf20Sopenharmony_ci#include <linux/usb.h> 128c2ecf20Sopenharmony_ci#include <linux/usb_usual.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* 168c2ecf20Sopenharmony_ci * The table of devices 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ 198c2ecf20Sopenharmony_ci vendorName, productName, useProtocol, useTransport, \ 208c2ecf20Sopenharmony_ci initFunction, flags) \ 218c2ecf20Sopenharmony_ci{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ 228c2ecf20Sopenharmony_ci .driver_info = (flags) } 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define COMPLIANT_DEV UNUSUAL_DEV 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define USUAL_DEV(useProto, useTrans) \ 278c2ecf20Sopenharmony_ci{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) } 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* Define the device is matched with Vendor ID and interface descriptors */ 308c2ecf20Sopenharmony_ci#define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \ 318c2ecf20Sopenharmony_ci vendorName, productName, useProtocol, useTransport, \ 328c2ecf20Sopenharmony_ci initFunction, flags) \ 338c2ecf20Sopenharmony_ci{ \ 348c2ecf20Sopenharmony_ci .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \ 358c2ecf20Sopenharmony_ci | USB_DEVICE_ID_MATCH_VENDOR, \ 368c2ecf20Sopenharmony_ci .idVendor = (id_vendor), \ 378c2ecf20Sopenharmony_ci .bInterfaceClass = (cl), \ 388c2ecf20Sopenharmony_ci .bInterfaceSubClass = (sc), \ 398c2ecf20Sopenharmony_ci .bInterfaceProtocol = (pr), \ 408c2ecf20Sopenharmony_ci .driver_info = (flags) \ 418c2ecf20Sopenharmony_ci} 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ciconst struct usb_device_id usb_storage_usb_ids[] = { 448c2ecf20Sopenharmony_ci# include "unusual_devs.h" 458c2ecf20Sopenharmony_ci { } /* Terminating entry */ 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(usb, usb_storage_usb_ids); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#undef UNUSUAL_DEV 508c2ecf20Sopenharmony_ci#undef COMPLIANT_DEV 518c2ecf20Sopenharmony_ci#undef USUAL_DEV 528c2ecf20Sopenharmony_ci#undef UNUSUAL_VENDOR_INTF 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* 558c2ecf20Sopenharmony_ci * The table of devices to ignore 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_cistruct ignore_entry { 588c2ecf20Sopenharmony_ci u16 vid, pid, bcdmin, bcdmax; 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ 628c2ecf20Sopenharmony_ci vendorName, productName, useProtocol, useTransport, \ 638c2ecf20Sopenharmony_ci initFunction, flags) \ 648c2ecf20Sopenharmony_ci{ \ 658c2ecf20Sopenharmony_ci .vid = id_vendor, \ 668c2ecf20Sopenharmony_ci .pid = id_product, \ 678c2ecf20Sopenharmony_ci .bcdmin = bcdDeviceMin, \ 688c2ecf20Sopenharmony_ci .bcdmax = bcdDeviceMax, \ 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_cistatic const struct ignore_entry ignore_ids[] = { 728c2ecf20Sopenharmony_ci# include "unusual_alauda.h" 738c2ecf20Sopenharmony_ci# include "unusual_cypress.h" 748c2ecf20Sopenharmony_ci# include "unusual_datafab.h" 758c2ecf20Sopenharmony_ci# include "unusual_ene_ub6250.h" 768c2ecf20Sopenharmony_ci# include "unusual_freecom.h" 778c2ecf20Sopenharmony_ci# include "unusual_isd200.h" 788c2ecf20Sopenharmony_ci# include "unusual_jumpshot.h" 798c2ecf20Sopenharmony_ci# include "unusual_karma.h" 808c2ecf20Sopenharmony_ci# include "unusual_onetouch.h" 818c2ecf20Sopenharmony_ci# include "unusual_realtek.h" 828c2ecf20Sopenharmony_ci# include "unusual_sddr09.h" 838c2ecf20Sopenharmony_ci# include "unusual_sddr55.h" 848c2ecf20Sopenharmony_ci# include "unusual_usbat.h" 858c2ecf20Sopenharmony_ci { } /* Terminating entry */ 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#undef UNUSUAL_DEV 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* Return an error if a device is in the ignore_ids list */ 918c2ecf20Sopenharmony_ciint usb_usual_ignore_device(struct usb_interface *intf) 928c2ecf20Sopenharmony_ci{ 938c2ecf20Sopenharmony_ci struct usb_device *udev; 948c2ecf20Sopenharmony_ci unsigned vid, pid, bcd; 958c2ecf20Sopenharmony_ci const struct ignore_entry *p; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci udev = interface_to_usbdev(intf); 988c2ecf20Sopenharmony_ci vid = le16_to_cpu(udev->descriptor.idVendor); 998c2ecf20Sopenharmony_ci pid = le16_to_cpu(udev->descriptor.idProduct); 1008c2ecf20Sopenharmony_ci bcd = le16_to_cpu(udev->descriptor.bcdDevice); 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci for (p = ignore_ids; p->vid; ++p) { 1038c2ecf20Sopenharmony_ci if (p->vid == vid && p->pid == pid && 1048c2ecf20Sopenharmony_ci p->bcdmin <= bcd && p->bcdmax >= bcd) 1058c2ecf20Sopenharmony_ci return -ENXIO; 1068c2ecf20Sopenharmony_ci } 1078c2ecf20Sopenharmony_ci return 0; 1088c2ecf20Sopenharmony_ci} 109