aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r--drivers/usb/storage/datafab.c3
-rw-r--r--drivers/usb/storage/isd200.c10
-rw-r--r--drivers/usb/storage/jumpshot.c3
-rw-r--r--drivers/usb/storage/scsiglue.c9
-rw-r--r--drivers/usb/storage/sddr55.c3
-rw-r--r--drivers/usb/storage/shuttle_usbat.c3
-rw-r--r--drivers/usb/storage/unusual_devs.h32
-rw-r--r--drivers/usb/storage/usb.c25
-rw-r--r--drivers/usb/storage/usb.h5
9 files changed, 60 insertions, 33 deletions
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
index 54e3e6c7ecd8..01d8971ad7db 100644
--- a/drivers/usb/storage/datafab.c
+++ b/drivers/usb/storage/datafab.c
@@ -512,13 +512,12 @@ int datafab_transport(struct scsi_cmnd * srb, struct us_data *us)
512 }; 512 };
513 513
514 if (!us->extra) { 514 if (!us->extra) {
515 us->extra = kmalloc(sizeof(struct datafab_info), GFP_NOIO); 515 us->extra = kzalloc(sizeof(struct datafab_info), GFP_NOIO);
516 if (!us->extra) { 516 if (!us->extra) {
517 US_DEBUGP("datafab_transport: Gah! " 517 US_DEBUGP("datafab_transport: Gah! "
518 "Can't allocate storage for Datafab info struct!\n"); 518 "Can't allocate storage for Datafab info struct!\n");
519 return USB_STOR_TRANSPORT_ERROR; 519 return USB_STOR_TRANSPORT_ERROR;
520 } 520 }
521 memset(us->extra, 0, sizeof(struct datafab_info));
522 us->extra_destructor = datafab_info_destructor; 521 us->extra_destructor = datafab_info_destructor;
523 ((struct datafab_info *)us->extra)->lun = -1; 522 ((struct datafab_info *)us->extra)->lun = -1;
524 } 523 }
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index ecb328aa9ea1..6831dca93c1b 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1361,21 +1361,19 @@ static int isd200_init_info(struct us_data *us)
1361 struct isd200_info *info; 1361 struct isd200_info *info;
1362 1362
1363 info = (struct isd200_info *) 1363 info = (struct isd200_info *)
1364 kmalloc(sizeof(struct isd200_info), GFP_KERNEL); 1364 kzalloc(sizeof(struct isd200_info), GFP_KERNEL);
1365 if (!info) 1365 if (!info)
1366 retStatus = ISD200_ERROR; 1366 retStatus = ISD200_ERROR;
1367 else { 1367 else {
1368 memset(info, 0, sizeof(struct isd200_info));
1369 info->id = (struct hd_driveid *) 1368 info->id = (struct hd_driveid *)
1370 kmalloc(sizeof(struct hd_driveid), GFP_KERNEL); 1369 kzalloc(sizeof(struct hd_driveid), GFP_KERNEL);
1371 info->RegsBuf = (unsigned char *) 1370 info->RegsBuf = (unsigned char *)
1372 kmalloc(sizeof(info->ATARegs), GFP_KERNEL); 1371 kmalloc(sizeof(info->ATARegs), GFP_KERNEL);
1373 if (!info->id || !info->RegsBuf) { 1372 if (!info->id || !info->RegsBuf) {
1374 isd200_free_info_ptrs(info); 1373 isd200_free_info_ptrs(info);
1375 kfree(info); 1374 kfree(info);
1376 retStatus = ISD200_ERROR; 1375 retStatus = ISD200_ERROR;
1377 } else 1376 }
1378 memset(info->id, 0, sizeof(struct hd_driveid));
1379 } 1377 }
1380 1378
1381 if (retStatus == ISD200_GOOD) { 1379 if (retStatus == ISD200_GOOD) {
@@ -1384,7 +1382,7 @@ static int isd200_init_info(struct us_data *us)
1384 } else 1382 } else
1385 US_DEBUGP("ERROR - kmalloc failure\n"); 1383 US_DEBUGP("ERROR - kmalloc failure\n");
1386 1384
1387 return(retStatus); 1385 return retStatus;
1388} 1386}
1389 1387
1390/************************************************************************** 1388/**************************************************************************
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
index aff9d51c327c..5031aa98f6a9 100644
--- a/drivers/usb/storage/jumpshot.c
+++ b/drivers/usb/storage/jumpshot.c
@@ -441,12 +441,11 @@ int jumpshot_transport(struct scsi_cmnd * srb, struct us_data *us)
441 }; 441 };
442 442
443 if (!us->extra) { 443 if (!us->extra) {
444 us->extra = kmalloc(sizeof(struct jumpshot_info), GFP_NOIO); 444 us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO);
445 if (!us->extra) { 445 if (!us->extra) {
446 US_DEBUGP("jumpshot_transport: Gah! Can't allocate storage for jumpshot info struct!\n"); 446 US_DEBUGP("jumpshot_transport: Gah! Can't allocate storage for jumpshot info struct!\n");
447 return USB_STOR_TRANSPORT_ERROR; 447 return USB_STOR_TRANSPORT_ERROR;
448 } 448 }
449 memset(us->extra, 0, sizeof(struct jumpshot_info));
450 us->extra_destructor = jumpshot_info_destructor; 449 us->extra_destructor = jumpshot_info_destructor;
451 } 450 }
452 451
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 4ef5527028c5..5f11e19eaae3 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -47,6 +47,7 @@
47 47
48#include <linux/slab.h> 48#include <linux/slab.h>
49#include <linux/module.h> 49#include <linux/module.h>
50#include <linux/mutex.h>
50 51
51#include <scsi/scsi.h> 52#include <scsi/scsi.h>
52#include <scsi/scsi_cmnd.h> 53#include <scsi/scsi_cmnd.h>
@@ -271,9 +272,9 @@ static int device_reset(struct scsi_cmnd *srb)
271 US_DEBUGP("%s called\n", __FUNCTION__); 272 US_DEBUGP("%s called\n", __FUNCTION__);
272 273
273 /* lock the device pointers and do the reset */ 274 /* lock the device pointers and do the reset */
274 down(&(us->dev_semaphore)); 275 mutex_lock(&(us->dev_mutex));
275 result = us->transport_reset(us); 276 result = us->transport_reset(us);
276 up(&(us->dev_semaphore)); 277 mutex_unlock(&us->dev_mutex);
277 278
278 return result < 0 ? FAILED : SUCCESS; 279 return result < 0 ? FAILED : SUCCESS;
279} 280}
@@ -286,9 +287,9 @@ static int bus_reset(struct scsi_cmnd *srb)
286 287
287 US_DEBUGP("%s called\n", __FUNCTION__); 288 US_DEBUGP("%s called\n", __FUNCTION__);
288 289
289 down(&(us->dev_semaphore)); 290 mutex_lock(&(us->dev_mutex));
290 result = usb_stor_port_reset(us); 291 result = usb_stor_port_reset(us);
291 up(&(us->dev_semaphore)); 292 mutex_unlock(&us->dev_mutex);
292 293
293 return result < 0 ? FAILED : SUCCESS; 294 return result < 0 ? FAILED : SUCCESS;
294} 295}
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
index 8451779f4269..0b1b5b59ca7b 100644
--- a/drivers/usb/storage/sddr55.c
+++ b/drivers/usb/storage/sddr55.c
@@ -751,11 +751,10 @@ int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
751 struct sddr55_card_info *info; 751 struct sddr55_card_info *info;
752 752
753 if (!us->extra) { 753 if (!us->extra) {
754 us->extra = kmalloc( 754 us->extra = kzalloc(
755 sizeof(struct sddr55_card_info), GFP_NOIO); 755 sizeof(struct sddr55_card_info), GFP_NOIO);
756 if (!us->extra) 756 if (!us->extra)
757 return USB_STOR_TRANSPORT_ERROR; 757 return USB_STOR_TRANSPORT_ERROR;
758 memset(us->extra, 0, sizeof(struct sddr55_card_info));
759 us->extra_destructor = sddr55_card_info_destructor; 758 us->extra_destructor = sddr55_card_info_destructor;
760 } 759 }
761 760
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index fea176d7e79a..f2bc5c9e23d5 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -1318,12 +1318,11 @@ int init_usbat(struct us_data *us)
1318 unsigned char subcountL = USBAT_ATA_LBA_ME; 1318 unsigned char subcountL = USBAT_ATA_LBA_ME;
1319 unsigned char *status = us->iobuf; 1319 unsigned char *status = us->iobuf;
1320 1320
1321 us->extra = kmalloc(sizeof(struct usbat_info), GFP_NOIO); 1321 us->extra = kzalloc(sizeof(struct usbat_info), GFP_NOIO);
1322 if (!us->extra) { 1322 if (!us->extra) {
1323 US_DEBUGP("init_usbat: Gah! Can't allocate storage for usbat info struct!\n"); 1323 US_DEBUGP("init_usbat: Gah! Can't allocate storage for usbat info struct!\n");
1324 return 1; 1324 return 1;
1325 } 1325 }
1326 memset(us->extra, 0, sizeof(struct usbat_info));
1327 info = (struct usbat_info *) (us->extra); 1326 info = (struct usbat_info *) (us->extra);
1328 1327
1329 /* Enable peripheral control signals */ 1328 /* Enable peripheral control signals */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 31ca92056c27..c4a9dcff5f2b 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -62,6 +62,13 @@ UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100,
62 US_SC_DEVICE, US_PR_DEVICE, NULL, 62 US_SC_DEVICE, US_PR_DEVICE, NULL,
63 US_FL_SINGLE_LUN ), 63 US_FL_SINGLE_LUN ),
64 64
65/* Reported by Rodolfo Quesada <rquesada@roqz.net> */
66UNUSUAL_DEV( 0x03ee, 0x6906, 0x0003, 0x0003,
67 "VIA Technologies Inc.",
68 "Mitsumi multi cardreader",
69 US_SC_DEVICE, US_PR_DEVICE, NULL,
70 US_FL_IGNORE_RESIDUE ),
71
65UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200, 72UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200,
66 "HP", 73 "HP",
67 "CD-Writer+", 74 "CD-Writer+",
@@ -120,6 +127,12 @@ UNUSUAL_DEV( 0x0419, 0xaaf6, 0x0100, 0x0100,
120 US_SC_DEVICE, US_PR_DEVICE, NULL, 127 US_SC_DEVICE, US_PR_DEVICE, NULL,
121 US_FL_IGNORE_RESIDUE ), 128 US_FL_IGNORE_RESIDUE ),
122 129
130/* Reported by Pete Zaitcev <zaitcev@redhat.com>, bz#176584 */
131UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100,
132 "GENERIC", "MP3 PLAYER", /* MyMusix PD-205 on the outside. */
133 US_SC_DEVICE, US_PR_DEVICE, NULL,
134 US_FL_IGNORE_RESIDUE ),
135
123/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 136/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
124UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 137UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
125 "SMSC", 138 "SMSC",
@@ -760,12 +773,19 @@ UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001,
760 US_SC_DEVICE, US_PR_DEVICE, NULL, 773 US_SC_DEVICE, US_PR_DEVICE, NULL,
761 US_FL_FIX_CAPACITY ), 774 US_FL_FIX_CAPACITY ),
762 775
763UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200, 776/* Submitted by Roman Hodek <roman@hodek.net> */
777UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200,
764 "Sandisk", 778 "Sandisk",
765 "ImageMate SDDR-05a", 779 "ImageMate SDDR-05a",
766 US_SC_SCSI, US_PR_CB, NULL, 780 US_SC_SCSI, US_PR_CB, NULL,
767 US_FL_SINGLE_LUN ), 781 US_FL_SINGLE_LUN ),
768 782
783UNUSUAL_DEV( 0x0781, 0x0002, 0x0009, 0x0009,
784 "SanDisk Corporation",
785 "ImageMate CompactFlash USB",
786 US_SC_DEVICE, US_PR_DEVICE, NULL,
787 US_FL_FIX_CAPACITY ),
788
769#ifdef CONFIG_USB_STORAGE_USBAT 789#ifdef CONFIG_USB_STORAGE_USBAT
770UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005, 790UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005,
771 "Sandisk", 791 "Sandisk",
@@ -1073,6 +1093,16 @@ UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
1073 0), 1093 0),
1074#endif 1094#endif
1075 1095
1096/*
1097 * Pete Zaitcev <zaitcev@yahoo.com>, bz#164688.
1098 * The device blatantly ignores LUN and returns 1 in GetMaxLUN.
1099 */
1100UNUSUAL_DEV( 0x0c45, 0x1060, 0x0100, 0x0100,
1101 "Unknown",
1102 "Unknown",
1103 US_SC_DEVICE, US_PR_DEVICE, NULL,
1104 US_FL_SINGLE_LUN ),
1105
1076/* Submitted by Joris Struyve <joris@struyve.be> */ 1106/* Submitted by Joris Struyve <joris@struyve.be> */
1077UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff, 1107UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
1078 "Medion", 1108 "Medion",
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index dbcf23980ff1..dd108634348e 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -55,6 +55,7 @@
55#include <linux/init.h> 55#include <linux/init.h>
56#include <linux/slab.h> 56#include <linux/slab.h>
57#include <linux/kthread.h> 57#include <linux/kthread.h>
58#include <linux/mutex.h>
58 59
59#include <scsi/scsi.h> 60#include <scsi/scsi.h>
60#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
@@ -188,7 +189,7 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message)
188 struct us_data *us = usb_get_intfdata(iface); 189 struct us_data *us = usb_get_intfdata(iface);
189 190
190 /* Wait until no command is running */ 191 /* Wait until no command is running */
191 down(&us->dev_semaphore); 192 mutex_lock(&us->dev_mutex);
192 193
193 US_DEBUGP("%s\n", __FUNCTION__); 194 US_DEBUGP("%s\n", __FUNCTION__);
194 if (us->suspend_resume_hook) 195 if (us->suspend_resume_hook)
@@ -198,7 +199,7 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message)
198 /* When runtime PM is working, we'll set a flag to indicate 199 /* When runtime PM is working, we'll set a flag to indicate
199 * whether we should autoresume when a SCSI request arrives. */ 200 * whether we should autoresume when a SCSI request arrives. */
200 201
201 up(&us->dev_semaphore); 202 mutex_unlock(&us->dev_mutex);
202 return 0; 203 return 0;
203} 204}
204 205
@@ -206,14 +207,14 @@ static int storage_resume(struct usb_interface *iface)
206{ 207{
207 struct us_data *us = usb_get_intfdata(iface); 208 struct us_data *us = usb_get_intfdata(iface);
208 209
209 down(&us->dev_semaphore); 210 mutex_lock(&us->dev_mutex);
210 211
211 US_DEBUGP("%s\n", __FUNCTION__); 212 US_DEBUGP("%s\n", __FUNCTION__);
212 if (us->suspend_resume_hook) 213 if (us->suspend_resume_hook)
213 (us->suspend_resume_hook)(us, US_RESUME); 214 (us->suspend_resume_hook)(us, US_RESUME);
214 iface->dev.power.power_state.event = PM_EVENT_ON; 215 iface->dev.power.power_state.event = PM_EVENT_ON;
215 216
216 up(&us->dev_semaphore); 217 mutex_unlock(&us->dev_mutex);
217 return 0; 218 return 0;
218} 219}
219 220
@@ -276,12 +277,12 @@ static int usb_stor_control_thread(void * __us)
276 US_DEBUGP("*** thread awakened.\n"); 277 US_DEBUGP("*** thread awakened.\n");
277 278
278 /* lock the device pointers */ 279 /* lock the device pointers */
279 down(&(us->dev_semaphore)); 280 mutex_lock(&(us->dev_mutex));
280 281
281 /* if the device has disconnected, we are free to exit */ 282 /* if the device has disconnected, we are free to exit */
282 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 283 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
283 US_DEBUGP("-- exiting\n"); 284 US_DEBUGP("-- exiting\n");
284 up(&(us->dev_semaphore)); 285 mutex_unlock(&us->dev_mutex);
285 break; 286 break;
286 } 287 }
287 288
@@ -370,7 +371,7 @@ SkipForAbort:
370 scsi_unlock(host); 371 scsi_unlock(host);
371 372
372 /* unlock the device pointers */ 373 /* unlock the device pointers */
373 up(&(us->dev_semaphore)); 374 mutex_unlock(&us->dev_mutex);
374 } /* for (;;) */ 375 } /* for (;;) */
375 376
376 scsi_host_put(host); 377 scsi_host_put(host);
@@ -815,8 +816,8 @@ static void quiesce_and_remove_host(struct us_data *us)
815 * The thread will exit when it sees the DISCONNECTING flag. */ 816 * The thread will exit when it sees the DISCONNECTING flag. */
816 817
817 /* Wait for the current command to finish, then remove the host */ 818 /* Wait for the current command to finish, then remove the host */
818 down(&us->dev_semaphore); 819 mutex_lock(&us->dev_mutex);
819 up(&us->dev_semaphore); 820 mutex_unlock(&us->dev_mutex);
820 821
821 /* queuecommand won't accept any new commands and the control 822 /* queuecommand won't accept any new commands and the control
822 * thread won't execute a previously-queued command. If there 823 * thread won't execute a previously-queued command. If there
@@ -870,9 +871,9 @@ retry:
870 /* For bulk-only devices, determine the max LUN value */ 871 /* For bulk-only devices, determine the max LUN value */
871 if (us->protocol == US_PR_BULK && 872 if (us->protocol == US_PR_BULK &&
872 !(us->flags & US_FL_SINGLE_LUN)) { 873 !(us->flags & US_FL_SINGLE_LUN)) {
873 down(&us->dev_semaphore); 874 mutex_lock(&us->dev_mutex);
874 us->max_lun = usb_stor_Bulk_max_lun(us); 875 us->max_lun = usb_stor_Bulk_max_lun(us);
875 up(&us->dev_semaphore); 876 mutex_unlock(&us->dev_mutex);
876 } 877 }
877 scsi_scan_host(us_to_host(us)); 878 scsi_scan_host(us_to_host(us));
878 printk(KERN_DEBUG "usb-storage: device scan complete\n"); 879 printk(KERN_DEBUG "usb-storage: device scan complete\n");
@@ -912,7 +913,7 @@ static int storage_probe(struct usb_interface *intf,
912 913
913 us = host_to_us(host); 914 us = host_to_us(host);
914 memset(us, 0, sizeof(struct us_data)); 915 memset(us, 0, sizeof(struct us_data));
915 init_MUTEX(&(us->dev_semaphore)); 916 mutex_init(&(us->dev_mutex));
916 init_MUTEX_LOCKED(&(us->sema)); 917 init_MUTEX_LOCKED(&(us->sema));
917 init_completion(&(us->notify)); 918 init_completion(&(us->notify));
918 init_waitqueue_head(&us->delay_wait); 919 init_waitqueue_head(&us->delay_wait);
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 7259fd1f6b0d..009fb0953a56 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -49,6 +49,7 @@
49#include <linux/blkdev.h> 49#include <linux/blkdev.h>
50#include <linux/smp_lock.h> 50#include <linux/smp_lock.h>
51#include <linux/completion.h> 51#include <linux/completion.h>
52#include <linux/mutex.h>
52#include <scsi/scsi_host.h> 53#include <scsi/scsi_host.h>
53 54
54struct us_data; 55struct us_data;
@@ -103,9 +104,9 @@ typedef void (*pm_hook)(struct us_data *, int); /* power management hook */
103struct us_data { 104struct us_data {
104 /* The device we're working with 105 /* The device we're working with
105 * It's important to note: 106 * It's important to note:
106 * (o) you must hold dev_semaphore to change pusb_dev 107 * (o) you must hold dev_mutex to change pusb_dev
107 */ 108 */
108 struct semaphore dev_semaphore; /* protect pusb_dev */ 109 struct mutex dev_mutex; /* protect pusb_dev */
109 struct usb_device *pusb_dev; /* this usb_device */ 110 struct usb_device *pusb_dev; /* this usb_device */
110 struct usb_interface *pusb_intf; /* this interface */ 111 struct usb_interface *pusb_intf; /* this interface */
111 struct us_unusual_dev *unusual_dev; /* device-filter entry */ 112 struct us_unusual_dev *unusual_dev; /* device-filter entry */