Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: storage: Define a new macro for USB storage match rules

1. Define a new macro for USB storage match rules:
matching with Vendor ID and interface descriptors.

Signed-off-by: fangxiaozhi <huananhu@huawei.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

fangxiaozhi and committed by
Greg Kroah-Hartman
07c7be3d 0ba3b2cc

+27
+12
drivers/usb/storage/usb.c
··· 120 120 .useTransport = use_transport, \ 121 121 } 122 122 123 + #define UNUSUAL_VENDOR_INTF(idVendor, cl, sc, pr, \ 124 + vendor_name, product_name, use_protocol, use_transport, \ 125 + init_function, Flags) \ 126 + { \ 127 + .vendorName = vendor_name, \ 128 + .productName = product_name, \ 129 + .useProtocol = use_protocol, \ 130 + .useTransport = use_transport, \ 131 + .initFunction = init_function, \ 132 + } 133 + 123 134 static struct us_unusual_dev us_unusual_dev_list[] = { 124 135 # include "unusual_devs.h" 125 136 { } /* Terminating entry */ ··· 142 131 #undef UNUSUAL_DEV 143 132 #undef COMPLIANT_DEV 144 133 #undef USUAL_DEV 134 + #undef UNUSUAL_VENDOR_INTF 145 135 146 136 #ifdef CONFIG_LOCKDEP 147 137
+15
drivers/usb/storage/usual-tables.c
··· 41 41 #define USUAL_DEV(useProto, useTrans) \ 42 42 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) } 43 43 44 + /* Define the device is matched with Vendor ID and interface descriptors */ 45 + #define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \ 46 + vendorName, productName, useProtocol, useTransport, \ 47 + initFunction, flags) \ 48 + { \ 49 + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \ 50 + | USB_DEVICE_ID_MATCH_VENDOR, \ 51 + .idVendor = (id_vendor), \ 52 + .bInterfaceClass = (cl), \ 53 + .bInterfaceSubClass = (sc), \ 54 + .bInterfaceProtocol = (pr), \ 55 + .driver_info = (flags) \ 56 + } 57 + 44 58 struct usb_device_id usb_storage_usb_ids[] = { 45 59 # include "unusual_devs.h" 46 60 { } /* Terminating entry */ ··· 64 50 #undef UNUSUAL_DEV 65 51 #undef COMPLIANT_DEV 66 52 #undef USUAL_DEV 53 + #undef UNUSUAL_VENDOR_INTF 67 54 68 55 /* 69 56 * The table of devices to ignore