usb.c (2e0fe709687470637a0709b930ccc9e993d2dad5) usb.c (e6e244b6cb1f70e7109381626293cd40a8334ed3)
1/* Driver for USB Mass Storage compliant devices
2 *
3 * Current development and maintenance by:
4 * (c) 1999-2003 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
5 *
6 * Developed with the assistance of:
7 * (c) 2000 David L. Brown, Jr. (usb-storage@davidb.org)
1/* Driver for USB Mass Storage compliant devices
2 *
3 * Current development and maintenance by:
4 * (c) 1999-2003 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
5 *
6 * Developed with the assistance of:
7 * (c) 2000 David L. Brown, Jr. (usb-storage@davidb.org)
8 * (c) 2003 Alan Stern (stern@rowland.harvard.edu)
8 * (c) 2003-2009 Alan Stern (stern@rowland.harvard.edu)
9 *
10 * Initial work by:
11 * (c) 1999 Michael Gee (michael@linuxspecific.com)
12 *
13 * usb_device_id support by Adam J. Richter (adam@yggdrasil.com):
14 * (c) 2000 Yggdrasil Computing, Inc.
15 *
16 * This driver is based on the 'USB Mass Storage Class' document. This

--- 96 unchanged lines hidden (view full) ---

113
114static char quirks[128];
115module_param_string(quirks, quirks, sizeof(quirks), S_IRUGO | S_IWUSR);
116MODULE_PARM_DESC(quirks, "supplemental list of device IDs and their quirks");
117
118
119/*
120 * The entries in this table correspond, line for line,
9 *
10 * Initial work by:
11 * (c) 1999 Michael Gee (michael@linuxspecific.com)
12 *
13 * usb_device_id support by Adam J. Richter (adam@yggdrasil.com):
14 * (c) 2000 Yggdrasil Computing, Inc.
15 *
16 * This driver is based on the 'USB Mass Storage Class' document. This

--- 96 unchanged lines hidden (view full) ---

113
114static char quirks[128];
115module_param_string(quirks, quirks, sizeof(quirks), S_IRUGO | S_IWUSR);
116MODULE_PARM_DESC(quirks, "supplemental list of device IDs and their quirks");
117
118
119/*
120 * The entries in this table correspond, line for line,
121 * with the entries of us_unusual_dev_list[].
121 * with the entries in usb_storage_usb_ids[], defined in usual-tables.c.
122 */
122 */
123#ifndef CONFIG_USB_LIBUSUAL
124
123
125#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
126 vendorName, productName,useProtocol, useTransport, \
127 initFunction, flags) \
128{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \
129 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
130
131#define COMPLIANT_DEV UNUSUAL_DEV
132
133#define USUAL_DEV(useProto, useTrans, useType) \
134{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
135 .driver_info = (USB_US_TYPE_STOR<<24) }
136
137static struct usb_device_id storage_usb_ids [] = {
138
139# include "unusual_devs.h"
140#undef UNUSUAL_DEV
141#undef COMPLIANT_DEV
142#undef USUAL_DEV
143 /* Terminating entry */
144 { }
145};
146
147MODULE_DEVICE_TABLE (usb, storage_usb_ids);
148#endif /* CONFIG_USB_LIBUSUAL */
149
150/* This is the list of devices we recognize, along with their flag data */
151
152/* The vendor name should be kept at eight characters or less, and
153 * the product name should be kept at 16 characters or less. If a device
154 * has the US_FL_FIX_INQUIRY flag, then the vendor and product names
155 * normally generated by a device thorugh the INQUIRY response will be
156 * taken from this list, and this is the reason for the above size
157 * restriction. However, if the flag is not present, then you
158 * are free to use as many characters as you like.
159 */

--- 14 unchanged lines hidden (view full) ---

174#define USUAL_DEV(use_protocol, use_transport, use_type) \
175{ \
176 .useProtocol = use_protocol, \
177 .useTransport = use_transport, \
178}
179
180static struct us_unusual_dev us_unusual_dev_list[] = {
181# include "unusual_devs.h"
124/* The vendor name should be kept at eight characters or less, and
125 * the product name should be kept at 16 characters or less. If a device
126 * has the US_FL_FIX_INQUIRY flag, then the vendor and product names
127 * normally generated by a device thorugh the INQUIRY response will be
128 * taken from this list, and this is the reason for the above size
129 * restriction. However, if the flag is not present, then you
130 * are free to use as many characters as you like.
131 */

--- 14 unchanged lines hidden (view full) ---

146#define USUAL_DEV(use_protocol, use_transport, use_type) \
147{ \
148 .useProtocol = use_protocol, \
149 .useTransport = use_transport, \
150}
151
152static struct us_unusual_dev us_unusual_dev_list[] = {
153# include "unusual_devs.h"
182# undef UNUSUAL_DEV
183# undef COMPLIANT_DEV
184# undef USUAL_DEV
185
186 /* Terminating entry */
187 { NULL }
154 { } /* Terminating entry */
188};
189
155};
156
157#undef UNUSUAL_DEV
158#undef COMPLIANT_DEV
159#undef USUAL_DEV
190
160
161
191#ifdef CONFIG_PM /* Minimal support for suspend and resume */
192
162#ifdef CONFIG_PM /* Minimal support for suspend and resume */
163
193static int storage_suspend(struct usb_interface *iface, pm_message_t message)
164int usb_stor_suspend(struct usb_interface *iface, pm_message_t message)
194{
195 struct us_data *us = usb_get_intfdata(iface);
196
197 /* Wait until no command is running */
198 mutex_lock(&us->dev_mutex);
199
200 US_DEBUGP("%s\n", __func__);
201 if (us->suspend_resume_hook)
202 (us->suspend_resume_hook)(us, US_SUSPEND);
203
204 /* When runtime PM is working, we'll set a flag to indicate
205 * whether we should autoresume when a SCSI request arrives. */
206
207 mutex_unlock(&us->dev_mutex);
208 return 0;
209}
165{
166 struct us_data *us = usb_get_intfdata(iface);
167
168 /* Wait until no command is running */
169 mutex_lock(&us->dev_mutex);
170
171 US_DEBUGP("%s\n", __func__);
172 if (us->suspend_resume_hook)
173 (us->suspend_resume_hook)(us, US_SUSPEND);
174
175 /* When runtime PM is working, we'll set a flag to indicate
176 * whether we should autoresume when a SCSI request arrives. */
177
178 mutex_unlock(&us->dev_mutex);
179 return 0;
180}
181EXPORT_SYMBOL_GPL(usb_stor_suspend);
210
182
211static int storage_resume(struct usb_interface *iface)
183int usb_stor_resume(struct usb_interface *iface)
212{
213 struct us_data *us = usb_get_intfdata(iface);
214
215 mutex_lock(&us->dev_mutex);
216
217 US_DEBUGP("%s\n", __func__);
218 if (us->suspend_resume_hook)
219 (us->suspend_resume_hook)(us, US_RESUME);
220
221 mutex_unlock(&us->dev_mutex);
222 return 0;
223}
184{
185 struct us_data *us = usb_get_intfdata(iface);
186
187 mutex_lock(&us->dev_mutex);
188
189 US_DEBUGP("%s\n", __func__);
190 if (us->suspend_resume_hook)
191 (us->suspend_resume_hook)(us, US_RESUME);
192
193 mutex_unlock(&us->dev_mutex);
194 return 0;
195}
196EXPORT_SYMBOL_GPL(usb_stor_resume);
224
197
225static int storage_reset_resume(struct usb_interface *iface)
198int usb_stor_reset_resume(struct usb_interface *iface)
226{
227 struct us_data *us = usb_get_intfdata(iface);
228
229 US_DEBUGP("%s\n", __func__);
230
231 /* Report the reset to the SCSI core */
232 usb_stor_report_bus_reset(us);
233
234 /* FIXME: Notify the subdrivers that they need to reinitialize
235 * the device */
236 return 0;
237}
199{
200 struct us_data *us = usb_get_intfdata(iface);
201
202 US_DEBUGP("%s\n", __func__);
203
204 /* Report the reset to the SCSI core */
205 usb_stor_report_bus_reset(us);
206
207 /* FIXME: Notify the subdrivers that they need to reinitialize
208 * the device */
209 return 0;
210}
211EXPORT_SYMBOL_GPL(usb_stor_reset_resume);
238
239#endif /* CONFIG_PM */
240
241/*
242 * The next two routines get called just before and just after
243 * a USB port reset, whether from this driver or a different one.
244 */
245
212
213#endif /* CONFIG_PM */
214
215/*
216 * The next two routines get called just before and just after
217 * a USB port reset, whether from this driver or a different one.
218 */
219
246static int storage_pre_reset(struct usb_interface *iface)
220int usb_stor_pre_reset(struct usb_interface *iface)
247{
248 struct us_data *us = usb_get_intfdata(iface);
249
250 US_DEBUGP("%s\n", __func__);
251
252 /* Make sure no command runs during the reset */
253 mutex_lock(&us->dev_mutex);
254 return 0;
255}
221{
222 struct us_data *us = usb_get_intfdata(iface);
223
224 US_DEBUGP("%s\n", __func__);
225
226 /* Make sure no command runs during the reset */
227 mutex_lock(&us->dev_mutex);
228 return 0;
229}
230EXPORT_SYMBOL_GPL(usb_stor_pre_reset);
256
231
257static int storage_post_reset(struct usb_interface *iface)
232int usb_stor_post_reset(struct usb_interface *iface)
258{
259 struct us_data *us = usb_get_intfdata(iface);
260
261 US_DEBUGP("%s\n", __func__);
262
263 /* Report the reset to the SCSI core */
264 usb_stor_report_bus_reset(us);
265
266 /* FIXME: Notify the subdrivers that they need to reinitialize
267 * the device */
268
269 mutex_unlock(&us->dev_mutex);
270 return 0;
271}
233{
234 struct us_data *us = usb_get_intfdata(iface);
235
236 US_DEBUGP("%s\n", __func__);
237
238 /* Report the reset to the SCSI core */
239 usb_stor_report_bus_reset(us);
240
241 /* FIXME: Notify the subdrivers that they need to reinitialize
242 * the device */
243
244 mutex_unlock(&us->dev_mutex);
245 return 0;
246}
247EXPORT_SYMBOL_GPL(usb_stor_post_reset);
272
273/*
274 * fill_inquiry_response takes an unsigned char array (which must
275 * be at least 36 characters) and populates the vendor name,
276 * product name, and revision fields. Then the array is copied
277 * into the SCSI command's response buffer (oddly enough
278 * called request_buffer). data_len contains the length of the
279 * data array, which again must be at least 36.

--- 26 unchanged lines hidden (view full) ---

306 data[32] = 0x30 + ((bcdDevice>>12) & 0x0F);
307 data[33] = 0x30 + ((bcdDevice>>8) & 0x0F);
308 data[34] = 0x30 + ((bcdDevice>>4) & 0x0F);
309 data[35] = 0x30 + ((bcdDevice) & 0x0F);
310 }
311
312 usb_stor_set_xfer_buf(data, data_len, us->srb);
313}
248
249/*
250 * fill_inquiry_response takes an unsigned char array (which must
251 * be at least 36 characters) and populates the vendor name,
252 * product name, and revision fields. Then the array is copied
253 * into the SCSI command's response buffer (oddly enough
254 * called request_buffer). data_len contains the length of the
255 * data array, which again must be at least 36.

--- 26 unchanged lines hidden (view full) ---

282 data[32] = 0x30 + ((bcdDevice>>12) & 0x0F);
283 data[33] = 0x30 + ((bcdDevice>>8) & 0x0F);
284 data[34] = 0x30 + ((bcdDevice>>4) & 0x0F);
285 data[35] = 0x30 + ((bcdDevice) & 0x0F);
286 }
287
288 usb_stor_set_xfer_buf(data, data_len, us->srb);
289}
290EXPORT_SYMBOL_GPL(fill_inquiry_response);
314
315static int usb_stor_control_thread(void * __us)
316{
317 struct us_data *us = (struct us_data *)__us;
318 struct Scsi_Host *host = us_to_host(us);
319
320 for(;;) {
321 US_DEBUGP("*** thread sleeping.\n");

--- 224 unchanged lines hidden (view full) ---

546 }
547 }
548 us->fflags = (us->fflags & ~mask) | f;
549 dev_info(&us->pusb_intf->dev, "Quirks match for "
550 "vid %04x pid %04x: %x\n",
551 vid, pid, f);
552}
553
291
292static int usb_stor_control_thread(void * __us)
293{
294 struct us_data *us = (struct us_data *)__us;
295 struct Scsi_Host *host = us_to_host(us);
296
297 for(;;) {
298 US_DEBUGP("*** thread sleeping.\n");

--- 224 unchanged lines hidden (view full) ---

523 }
524 }
525 us->fflags = (us->fflags & ~mask) | f;
526 dev_info(&us->pusb_intf->dev, "Quirks match for "
527 "vid %04x pid %04x: %x\n",
528 vid, pid, f);
529}
530
554/* Find an unusual_dev descriptor (always succeeds in the current code) */
555static struct us_unusual_dev *find_unusual(const struct usb_device_id *id)
556{
557 const int id_index = id - storage_usb_ids;
558 return &us_unusual_dev_list[id_index];
559}
560
561/* Get the unusual_devs entries and the string descriptors */
531/* Get the unusual_devs entries and the string descriptors */
562static int get_device_info(struct us_data *us, const struct usb_device_id *id)
532static int get_device_info(struct us_data *us, const struct usb_device_id *id,
533 struct us_unusual_dev *unusual_dev)
563{
564 struct usb_device *dev = us->pusb_dev;
565 struct usb_interface_descriptor *idesc =
566 &us->pusb_intf->cur_altsetting->desc;
534{
535 struct usb_device *dev = us->pusb_dev;
536 struct usb_interface_descriptor *idesc =
537 &us->pusb_intf->cur_altsetting->desc;
567 struct us_unusual_dev *unusual_dev = find_unusual(id);
568
569 /* Store the entries */
570 us->unusual_dev = unusual_dev;
571 us->subclass = (unusual_dev->useProtocol == US_SC_DEVICE) ?
572 idesc->bInterfaceSubClass :
573 unusual_dev->useProtocol;
574 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ?
575 idesc->bInterfaceProtocol :

--- 48 unchanged lines hidden (view full) ---

624 msgs[msg],
625 utsname()->release);
626 }
627
628 return 0;
629}
630
631/* Get the transport settings */
538
539 /* Store the entries */
540 us->unusual_dev = unusual_dev;
541 us->subclass = (unusual_dev->useProtocol == US_SC_DEVICE) ?
542 idesc->bInterfaceSubClass :
543 unusual_dev->useProtocol;
544 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ?
545 idesc->bInterfaceProtocol :

--- 48 unchanged lines hidden (view full) ---

594 msgs[msg],
595 utsname()->release);
596 }
597
598 return 0;
599}
600
601/* Get the transport settings */
632static int get_transport(struct us_data *us)
602static void get_transport(struct us_data *us)
633{
634 switch (us->protocol) {
635 case US_PR_CB:
636 us->transport_name = "Control/Bulk";
637 us->transport = usb_stor_CB_transport;
638 us->transport_reset = usb_stor_CB_reset;
639 us->max_lun = 7;
640 break;

--- 86 unchanged lines hidden (view full) ---

727#ifdef CONFIG_USB_STORAGE_KARMA
728 case US_PR_KARMA:
729 us->transport_name = "Rio Karma/Bulk";
730 us->transport = rio_karma_transport;
731 us->transport_reset = usb_stor_Bulk_reset;
732 break;
733#endif
734
603{
604 switch (us->protocol) {
605 case US_PR_CB:
606 us->transport_name = "Control/Bulk";
607 us->transport = usb_stor_CB_transport;
608 us->transport_reset = usb_stor_CB_reset;
609 us->max_lun = 7;
610 break;

--- 86 unchanged lines hidden (view full) ---

697#ifdef CONFIG_USB_STORAGE_KARMA
698 case US_PR_KARMA:
699 us->transport_name = "Rio Karma/Bulk";
700 us->transport = rio_karma_transport;
701 us->transport_reset = usb_stor_Bulk_reset;
702 break;
703#endif
704
735 default:
736 return -EIO;
737 }
705 }
738 US_DEBUGP("Transport: %s\n", us->transport_name);
739
740 /* fix for single-lun devices */
741 if (us->fflags & US_FL_SINGLE_LUN)
742 us->max_lun = 0;
743 return 0;
744}
745
746/* Get the protocol settings */
706}
707
708/* Get the protocol settings */
747static int get_protocol(struct us_data *us)
709static void get_protocol(struct us_data *us)
748{
749 switch (us->subclass) {
750 case US_SC_RBC:
751 us->protocol_name = "Reduced Block Commands (RBC)";
752 us->proto_handler = usb_stor_transparent_scsi_command;
753 break;
754
755 case US_SC_8020:

--- 33 unchanged lines hidden (view full) ---

789
790#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
791 case US_SC_CYP_ATACB:
792 us->protocol_name = "Transparent SCSI with Cypress ATACB";
793 us->proto_handler = cypress_atacb_passthrough;
794 break;
795#endif
796
710{
711 switch (us->subclass) {
712 case US_SC_RBC:
713 us->protocol_name = "Reduced Block Commands (RBC)";
714 us->proto_handler = usb_stor_transparent_scsi_command;
715 break;
716
717 case US_SC_8020:

--- 33 unchanged lines hidden (view full) ---

751
752#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
753 case US_SC_CYP_ATACB:
754 us->protocol_name = "Transparent SCSI with Cypress ATACB";
755 us->proto_handler = cypress_atacb_passthrough;
756 break;
757#endif
758
797 default:
798 return -EIO;
799 }
759 }
800 US_DEBUGP("Protocol: %s\n", us->protocol_name);
801 return 0;
802}
803
804/* Get the pipe settings */
805static int get_pipes(struct us_data *us)
806{
807 struct usb_host_interface *altsetting =
808 us->pusb_intf->cur_altsetting;
809 int i;

--- 197 unchanged lines hidden (view full) ---

1007
1008 /* Should we unbind if no devices were detected? */
1009 }
1010
1011 complete_and_exit(&us->scanning_done, 0);
1012}
1013
1014
760}
761
762/* Get the pipe settings */
763static int get_pipes(struct us_data *us)
764{
765 struct usb_host_interface *altsetting =
766 us->pusb_intf->cur_altsetting;
767 int i;

--- 197 unchanged lines hidden (view full) ---

965
966 /* Should we unbind if no devices were detected? */
967 }
968
969 complete_and_exit(&us->scanning_done, 0);
970}
971
972
1015/* Probe to see if we can drive a newly-connected USB device */
1016static int storage_probe(struct usb_interface *intf,
1017 const struct usb_device_id *id)
973/* First part of general USB mass-storage probing */
974int usb_stor_probe1(struct us_data **pus,
975 struct usb_interface *intf,
976 const struct usb_device_id *id,
977 struct us_unusual_dev *unusual_dev)
1018{
1019 struct Scsi_Host *host;
1020 struct us_data *us;
1021 int result;
978{
979 struct Scsi_Host *host;
980 struct us_data *us;
981 int result;
1022 struct task_struct *th;
1023
982
1024 if (usb_usual_check_type(id, USB_US_TYPE_STOR))
1025 return -ENXIO;
1026
1027 US_DEBUGP("USB Mass Storage device detected\n");
1028
1029 /*
1030 * Ask the SCSI layer to allocate a host structure, with extra
1031 * space at the end for our private us_data structure.
1032 */
1033 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
1034 if (!host) {
1035 printk(KERN_WARNING USB_STORAGE
1036 "Unable to allocate the scsi host\n");
1037 return -ENOMEM;
1038 }
1039
1040 /*
1041 * Allow 16-byte CDBs and thus > 2TB
1042 */
1043 host->max_cmd_len = 16;
983 US_DEBUGP("USB Mass Storage device detected\n");
984
985 /*
986 * Ask the SCSI layer to allocate a host structure, with extra
987 * space at the end for our private us_data structure.
988 */
989 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
990 if (!host) {
991 printk(KERN_WARNING USB_STORAGE
992 "Unable to allocate the scsi host\n");
993 return -ENOMEM;
994 }
995
996 /*
997 * Allow 16-byte CDBs and thus > 2TB
998 */
999 host->max_cmd_len = 16;
1044 us = host_to_us(host);
1000 *pus = us = host_to_us(host);
1045 memset(us, 0, sizeof(struct us_data));
1046 mutex_init(&(us->dev_mutex));
1047 init_completion(&us->cmnd_ready);
1048 init_completion(&(us->notify));
1049 init_waitqueue_head(&us->delay_wait);
1050 init_completion(&us->scanning_done);
1051
1052 /* Associate the us_data structure with the USB device */
1053 result = associate_dev(us, intf);
1054 if (result)
1055 goto BadDevice;
1056
1001 memset(us, 0, sizeof(struct us_data));
1002 mutex_init(&(us->dev_mutex));
1003 init_completion(&us->cmnd_ready);
1004 init_completion(&(us->notify));
1005 init_waitqueue_head(&us->delay_wait);
1006 init_completion(&us->scanning_done);
1007
1008 /* Associate the us_data structure with the USB device */
1009 result = associate_dev(us, intf);
1010 if (result)
1011 goto BadDevice;
1012
1057 /*
1058 * Get the unusual_devs entries and the descriptors
1059 *
1060 * id_index is calculated in the declaration to be the index number
1061 * of the match from the usb_device_id table, so we can find the
1062 * corresponding entry in the private table.
1063 */
1064 result = get_device_info(us, id);
1013 /* Get the unusual_devs entries and the descriptors */
1014 result = get_device_info(us, id, unusual_dev);
1065 if (result)
1066 goto BadDevice;
1067
1015 if (result)
1016 goto BadDevice;
1017
1068 /* Get the transport, protocol, and pipe settings */
1069 result = get_transport(us);
1070 if (result)
1018 /* Get standard transport and protocol settings */
1019 get_transport(us);
1020 get_protocol(us);
1021
1022 /* Give the caller a chance to fill in specialized transport
1023 * or protocol settings.
1024 */
1025 return 0;
1026
1027BadDevice:
1028 US_DEBUGP("storage_probe() failed\n");
1029 release_everything(us);
1030 return result;
1031}
1032EXPORT_SYMBOL_GPL(usb_stor_probe1);
1033
1034/* Second part of general USB mass-storage probing */
1035int usb_stor_probe2(struct us_data *us)
1036{
1037 struct task_struct *th;
1038 int result;
1039
1040 /* Make sure the transport and protocol have both been set */
1041 if (!us->transport || !us->proto_handler) {
1042 result = -ENXIO;
1071 goto BadDevice;
1043 goto BadDevice;
1072 result = get_protocol(us);
1073 if (result)
1074 goto BadDevice;
1044 }
1045 US_DEBUGP("Transport: %s\n", us->transport_name);
1046 US_DEBUGP("Protocol: %s\n", us->protocol_name);
1047
1048 /* fix for single-lun devices */
1049 if (us->fflags & US_FL_SINGLE_LUN)
1050 us->max_lun = 0;
1051
1052 /* Find the endpoints and calculate pipe values */
1075 result = get_pipes(us);
1076 if (result)
1077 goto BadDevice;
1078
1079 /* Acquire all the other resources and add the host */
1080 result = usb_stor_acquire_resources(us);
1081 if (result)
1082 goto BadDevice;
1053 result = get_pipes(us);
1054 if (result)
1055 goto BadDevice;
1056
1057 /* Acquire all the other resources and add the host */
1058 result = usb_stor_acquire_resources(us);
1059 if (result)
1060 goto BadDevice;
1083 result = scsi_add_host(host, &intf->dev);
1061 result = scsi_add_host(us_to_host(us), &us->pusb_intf->dev);
1084 if (result) {
1085 printk(KERN_WARNING USB_STORAGE
1086 "Unable to add the scsi host\n");
1087 goto BadDevice;
1088 }
1089
1090 /* Start up the thread for delayed SCSI-device scanning */
1091 th = kthread_create(usb_stor_scan_thread, us, "usb-stor-scan");

--- 11 unchanged lines hidden (view full) ---

1103 return 0;
1104
1105 /* We come here if there are any problems */
1106BadDevice:
1107 US_DEBUGP("storage_probe() failed\n");
1108 release_everything(us);
1109 return result;
1110}
1062 if (result) {
1063 printk(KERN_WARNING USB_STORAGE
1064 "Unable to add the scsi host\n");
1065 goto BadDevice;
1066 }
1067
1068 /* Start up the thread for delayed SCSI-device scanning */
1069 th = kthread_create(usb_stor_scan_thread, us, "usb-stor-scan");

--- 11 unchanged lines hidden (view full) ---

1081 return 0;
1082
1083 /* We come here if there are any problems */
1084BadDevice:
1085 US_DEBUGP("storage_probe() failed\n");
1086 release_everything(us);
1087 return result;
1088}
1089EXPORT_SYMBOL_GPL(usb_stor_probe2);
1111
1090
1112/* Handle a disconnect event from the USB core */
1113static void storage_disconnect(struct usb_interface *intf)
1091/* Handle a USB mass-storage disconnect */
1092void usb_stor_disconnect(struct usb_interface *intf)
1114{
1115 struct us_data *us = usb_get_intfdata(intf);
1116
1117 US_DEBUGP("storage_disconnect() called\n");
1118 quiesce_and_remove_host(us);
1119 release_everything(us);
1120}
1093{
1094 struct us_data *us = usb_get_intfdata(intf);
1095
1096 US_DEBUGP("storage_disconnect() called\n");
1097 quiesce_and_remove_host(us);
1098 release_everything(us);
1099}
1100EXPORT_SYMBOL_GPL(usb_stor_disconnect);
1121
1101
1102/* The main probe routine for standard devices */
1103static int storage_probe(struct usb_interface *intf,
1104 const struct usb_device_id *id)
1105{
1106 struct us_data *us;
1107 int result;
1108
1109 /*
1110 * If libusual is configured, let it decide whether a standard
1111 * device should be handled by usb-storage or by ub.
1112 * If the device isn't standard (is handled by a subdriver
1113 * module) then don't accept it.
1114 */
1115 if (usb_usual_check_type(id, USB_US_TYPE_STOR) ||
1116 usb_usual_ignore_device(intf))
1117 return -ENXIO;
1118
1119 /*
1120 * Call the general probe procedures.
1121 *
1122 * The unusual_dev_list array is parallel to the usb_storage_usb_ids
1123 * table, so we use the index of the id entry to find the
1124 * corresponding unusual_devs entry.
1125 */
1126 result = usb_stor_probe1(&us, intf, id,
1127 (id - usb_storage_usb_ids) + us_unusual_dev_list);
1128 if (result)
1129 return result;
1130
1131 /* No special transport or protocol settings in the main module */
1132
1133 result = usb_stor_probe2(us);
1134 return result;
1135}
1136
1122/***********************************************************************
1123 * Initialization and registration
1124 ***********************************************************************/
1125
1126static struct usb_driver usb_storage_driver = {
1127 .name = "usb-storage",
1128 .probe = storage_probe,
1137/***********************************************************************
1138 * Initialization and registration
1139 ***********************************************************************/
1140
1141static struct usb_driver usb_storage_driver = {
1142 .name = "usb-storage",
1143 .probe = storage_probe,
1129 .disconnect = storage_disconnect,
1130#ifdef CONFIG_PM
1131 .suspend = storage_suspend,
1132 .resume = storage_resume,
1133 .reset_resume = storage_reset_resume,
1134#endif
1135 .pre_reset = storage_pre_reset,
1136 .post_reset = storage_post_reset,
1137 .id_table = storage_usb_ids,
1144 .disconnect = usb_stor_disconnect,
1145 .suspend = usb_stor_suspend,
1146 .resume = usb_stor_resume,
1147 .reset_resume = usb_stor_reset_resume,
1148 .pre_reset = usb_stor_pre_reset,
1149 .post_reset = usb_stor_post_reset,
1150 .id_table = usb_storage_usb_ids,
1138 .soft_unbind = 1,
1139};
1140
1141static int __init usb_stor_init(void)
1142{
1143 int retval;
1144
1145 printk(KERN_INFO "Initializing USB Mass Storage driver...\n");

--- 26 unchanged lines hidden ---
1151 .soft_unbind = 1,
1152};
1153
1154static int __init usb_stor_init(void)
1155{
1156 int retval;
1157
1158 printk(KERN_INFO "Initializing USB Mass Storage driver...\n");

--- 26 unchanged lines hidden ---