aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/usb.c
diff options
context:
space:
mode:
authorPete Zaitcev <zaitcev@redhat.com>2005-10-22 23:15:09 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 16:48:31 -0500
commita00828e9ac62caed7b830d631914d7748817ccd1 (patch)
tree2fed4c66762fa4f54945413b4027ff5837ad0633 /drivers/usb/storage/usb.c
parent1c50c317e2e7f15427149cbc216a63366468710e (diff)
[PATCH] USB: drivers/usb/storage/libusual
This patch adds a shim driver libusual, which routes devices between usb-storage and ub according to the common table, based on unusual_devs.h. The help and example syntax is in Kconfig. Signed-off-by: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/storage/usb.c')
-rw-r--r--drivers/usb/storage/usb.c119
1 files changed, 39 insertions, 80 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 3847ebed2aa4..c8375aa62723 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -112,49 +112,33 @@ static atomic_t total_threads = ATOMIC_INIT(0);
112static DECLARE_COMPLETION(threads_gone); 112static DECLARE_COMPLETION(threads_gone);
113 113
114 114
115/* The entries in this table, except for final ones here 115/*
116 * (USB_MASS_STORAGE_CLASS and the empty entry), correspond, 116 * The entries in this table correspond, line for line,
117 * line for line with the entries of us_unsuaul_dev_list[]. 117 * with the entries of us_unusual_dev_list[].
118 */ 118 */
119#ifndef CONFIG_USB_LIBUSUAL
119 120
120#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ 121#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
121 vendorName, productName,useProtocol, useTransport, \ 122 vendorName, productName,useProtocol, useTransport, \
122 initFunction, flags) \ 123 initFunction, flags) \
123{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax) } 124{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \
125 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
126
127#define USUAL_DEV(useProto, useTrans, useType) \
128{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
129 .driver_info = (USB_US_TYPE_STOR<<24) }
124 130
125static struct usb_device_id storage_usb_ids [] = { 131static struct usb_device_id storage_usb_ids [] = {
126 132
127# include "unusual_devs.h" 133# include "unusual_devs.h"
128#undef UNUSUAL_DEV 134#undef UNUSUAL_DEV
129 /* Control/Bulk transport for all SubClass values */ 135#undef USUAL_DEV
130 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_RBC, US_PR_CB) },
131 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8020, US_PR_CB) },
132 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_QIC, US_PR_CB) },
133 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_CB) },
134 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_CB) },
135 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_CB) },
136
137 /* Control/Bulk/Interrupt transport for all SubClass values */
138 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_RBC, US_PR_CBI) },
139 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8020, US_PR_CBI) },
140 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_QIC, US_PR_CBI) },
141 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_CBI) },
142 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_CBI) },
143 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_CBI) },
144
145 /* Bulk-only transport for all SubClass values */
146 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_RBC, US_PR_BULK) },
147 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8020, US_PR_BULK) },
148 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_QIC, US_PR_BULK) },
149 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_BULK) },
150 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_BULK) },
151 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) },
152
153 /* Terminating entry */ 136 /* Terminating entry */
154 { } 137 { }
155}; 138};
156 139
157MODULE_DEVICE_TABLE (usb, storage_usb_ids); 140MODULE_DEVICE_TABLE (usb, storage_usb_ids);
141#endif /* CONFIG_USB_LIBUSUAL */
158 142
159/* This is the list of devices we recognize, along with their flag data */ 143/* This is the list of devices we recognize, along with their flag data */
160 144
@@ -167,7 +151,6 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
167 * are free to use as many characters as you like. 151 * are free to use as many characters as you like.
168 */ 152 */
169 153
170#undef UNUSUAL_DEV
171#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \ 154#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
172 vendor_name, product_name, use_protocol, use_transport, \ 155 vendor_name, product_name, use_protocol, use_transport, \
173 init_function, Flags) \ 156 init_function, Flags) \
@@ -177,53 +160,18 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
177 .useProtocol = use_protocol, \ 160 .useProtocol = use_protocol, \
178 .useTransport = use_transport, \ 161 .useTransport = use_transport, \
179 .initFunction = init_function, \ 162 .initFunction = init_function, \
180 .flags = Flags, \ 163}
164
165#define USUAL_DEV(use_protocol, use_transport, use_type) \
166{ \
167 .useProtocol = use_protocol, \
168 .useTransport = use_transport, \
181} 169}
182 170
183static struct us_unusual_dev us_unusual_dev_list[] = { 171static struct us_unusual_dev us_unusual_dev_list[] = {
184# include "unusual_devs.h" 172# include "unusual_devs.h"
185# undef UNUSUAL_DEV 173# undef UNUSUAL_DEV
186 /* Control/Bulk transport for all SubClass values */ 174# undef USUAL_DEV
187 { .useProtocol = US_SC_RBC,
188 .useTransport = US_PR_CB},
189 { .useProtocol = US_SC_8020,
190 .useTransport = US_PR_CB},
191 { .useProtocol = US_SC_QIC,
192 .useTransport = US_PR_CB},
193 { .useProtocol = US_SC_UFI,
194 .useTransport = US_PR_CB},
195 { .useProtocol = US_SC_8070,
196 .useTransport = US_PR_CB},
197 { .useProtocol = US_SC_SCSI,
198 .useTransport = US_PR_CB},
199
200 /* Control/Bulk/Interrupt transport for all SubClass values */
201 { .useProtocol = US_SC_RBC,
202 .useTransport = US_PR_CBI},
203 { .useProtocol = US_SC_8020,
204 .useTransport = US_PR_CBI},
205 { .useProtocol = US_SC_QIC,
206 .useTransport = US_PR_CBI},
207 { .useProtocol = US_SC_UFI,
208 .useTransport = US_PR_CBI},
209 { .useProtocol = US_SC_8070,
210 .useTransport = US_PR_CBI},
211 { .useProtocol = US_SC_SCSI,
212 .useTransport = US_PR_CBI},
213
214 /* Bulk-only transport for all SubClass values */
215 { .useProtocol = US_SC_RBC,
216 .useTransport = US_PR_BULK},
217 { .useProtocol = US_SC_8020,
218 .useTransport = US_PR_BULK},
219 { .useProtocol = US_SC_QIC,
220 .useTransport = US_PR_BULK},
221 { .useProtocol = US_SC_UFI,
222 .useTransport = US_PR_BULK},
223 { .useProtocol = US_SC_8070,
224 .useTransport = US_PR_BULK},
225 { .useProtocol = US_SC_SCSI,
226 .useTransport = US_PR_BULK},
227 175
228 /* Terminating entry */ 176 /* Terminating entry */
229 { NULL } 177 { NULL }
@@ -484,14 +432,20 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)
484 return 0; 432 return 0;
485} 433}
486 434
435/* Find an unusual_dev descriptor (always succeeds in the current code) */
436static struct us_unusual_dev *find_unusual(const struct usb_device_id *id)
437{
438 const int id_index = id - storage_usb_ids;
439 return &us_unusual_dev_list[id_index];
440}
441
487/* Get the unusual_devs entries and the string descriptors */ 442/* Get the unusual_devs entries and the string descriptors */
488static void get_device_info(struct us_data *us, int id_index) 443static void get_device_info(struct us_data *us, const struct usb_device_id *id)
489{ 444{
490 struct usb_device *dev = us->pusb_dev; 445 struct usb_device *dev = us->pusb_dev;
491 struct usb_interface_descriptor *idesc = 446 struct usb_interface_descriptor *idesc =
492 &us->pusb_intf->cur_altsetting->desc; 447 &us->pusb_intf->cur_altsetting->desc;
493 struct us_unusual_dev *unusual_dev = &us_unusual_dev_list[id_index]; 448 struct us_unusual_dev *unusual_dev = find_unusual(id);
494 struct usb_device_id *id = &storage_usb_ids[id_index];
495 449
496 /* Store the entries */ 450 /* Store the entries */
497 us->unusual_dev = unusual_dev; 451 us->unusual_dev = unusual_dev;
@@ -501,7 +455,7 @@ static void get_device_info(struct us_data *us, int id_index)
501 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ? 455 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ?
502 idesc->bInterfaceProtocol : 456 idesc->bInterfaceProtocol :
503 unusual_dev->useTransport; 457 unusual_dev->useTransport;
504 us->flags = unusual_dev->flags; 458 us->flags = USB_US_ORIG_FLAGS(id->driver_info);
505 459
506 /* 460 /*
507 * This flag is only needed when we're in high-speed, so let's 461 * This flag is only needed when we're in high-speed, so let's
@@ -529,7 +483,7 @@ static void get_device_info(struct us_data *us, int id_index)
529 if (unusual_dev->useTransport != US_PR_DEVICE && 483 if (unusual_dev->useTransport != US_PR_DEVICE &&
530 us->protocol == idesc->bInterfaceProtocol) 484 us->protocol == idesc->bInterfaceProtocol)
531 msg += 2; 485 msg += 2;
532 if (msg >= 0 && !(unusual_dev->flags & US_FL_NEED_OVERRIDE)) 486 if (msg >= 0 && !(us->flags & US_FL_NEED_OVERRIDE))
533 printk(KERN_NOTICE USB_STORAGE "This device " 487 printk(KERN_NOTICE USB_STORAGE "This device "
534 "(%04x,%04x,%04x S %02x P %02x)" 488 "(%04x,%04x,%04x S %02x P %02x)"
535 " has %s in unusual_devs.h\n" 489 " has %s in unusual_devs.h\n"
@@ -921,10 +875,12 @@ static int storage_probe(struct usb_interface *intf,
921{ 875{
922 struct Scsi_Host *host; 876 struct Scsi_Host *host;
923 struct us_data *us; 877 struct us_data *us;
924 const int id_index = id - storage_usb_ids;
925 int result; 878 int result;
926 struct task_struct *th; 879 struct task_struct *th;
927 880
881 if (usb_usual_check_type(id, USB_US_TYPE_STOR))
882 return -ENXIO;
883
928 US_DEBUGP("USB Mass Storage device detected\n"); 884 US_DEBUGP("USB Mass Storage device detected\n");
929 885
930 /* 886 /*
@@ -957,7 +913,7 @@ static int storage_probe(struct usb_interface *intf,
957 * of the match from the usb_device_id table, so we can find the 913 * of the match from the usb_device_id table, so we can find the
958 * corresponding entry in the private table. 914 * corresponding entry in the private table.
959 */ 915 */
960 get_device_info(us, id_index); 916 get_device_info(us, id);
961 917
962#ifdef CONFIG_USB_STORAGE_SDDR09 918#ifdef CONFIG_USB_STORAGE_SDDR09
963 if (us->protocol == US_PR_EUSB_SDDR09 || 919 if (us->protocol == US_PR_EUSB_SDDR09 ||
@@ -1062,9 +1018,10 @@ static int __init usb_stor_init(void)
1062 1018
1063 /* register the driver, return usb_register return code if error */ 1019 /* register the driver, return usb_register return code if error */
1064 retval = usb_register(&usb_storage_driver); 1020 retval = usb_register(&usb_storage_driver);
1065 if (retval == 0) 1021 if (retval == 0) {
1066 printk(KERN_INFO "USB Mass Storage support registered.\n"); 1022 printk(KERN_INFO "USB Mass Storage support registered.\n");
1067 1023 usb_usual_set_present(USB_US_TYPE_STOR);
1024 }
1068 return retval; 1025 return retval;
1069} 1026}
1070 1027
@@ -1088,6 +1045,8 @@ static void __exit usb_stor_exit(void)
1088 wait_for_completion(&threads_gone); 1045 wait_for_completion(&threads_gone);
1089 atomic_dec(&total_threads); 1046 atomic_dec(&total_threads);
1090 } 1047 }
1048
1049 usb_usual_clear_present(USB_US_TYPE_STOR);
1091} 1050}
1092 1051
1093module_init(usb_stor_init); 1052module_init(usb_stor_init);