aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r--drivers/usb/storage/Kconfig39
-rw-r--r--drivers/usb/storage/Makefile1
-rw-r--r--drivers/usb/storage/cypress_atacb.c200
-rw-r--r--drivers/usb/storage/cypress_atacb.h25
-rw-r--r--drivers/usb/storage/libusual.c14
-rw-r--r--drivers/usb/storage/scsiglue.c26
-rw-r--r--drivers/usb/storage/transport.c23
-rw-r--r--drivers/usb/storage/unusual_devs.h8
-rw-r--r--drivers/usb/storage/usb.c26
9 files changed, 309 insertions, 53 deletions
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index 7e53333be01..0f6d234d699 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -32,8 +32,8 @@ config USB_STORAGE_DEBUG
32 verbose debugging messages. 32 verbose debugging messages.
33 33
34config USB_STORAGE_DATAFAB 34config USB_STORAGE_DATAFAB
35 bool "Datafab Compact Flash Reader support (EXPERIMENTAL)" 35 bool "Datafab Compact Flash Reader support"
36 depends on USB_STORAGE && EXPERIMENTAL 36 depends on USB_STORAGE
37 help 37 help
38 Support for certain Datafab CompactFlash readers. 38 Support for certain Datafab CompactFlash readers.
39 Datafab has a web page at <http://www.datafabusa.com/>. 39 Datafab has a web page at <http://www.datafabusa.com/>.
@@ -69,8 +69,8 @@ config USB_STORAGE_DPCM
69 There is a web page at <http://www.ziocorp.com/products/>. 69 There is a web page at <http://www.ziocorp.com/products/>.
70 70
71config USB_STORAGE_USBAT 71config USB_STORAGE_USBAT
72 bool "USBAT/USBAT02-based storage support (EXPERIMENTAL)" 72 bool "USBAT/USBAT02-based storage support"
73 depends on USB_STORAGE && EXPERIMENTAL 73 depends on USB_STORAGE
74 help 74 help
75 Say Y here to include additional code to support storage devices 75 Say Y here to include additional code to support storage devices
76 based on the SCM/Shuttle USBAT/USBAT02 processors. 76 based on the SCM/Shuttle USBAT/USBAT02 processors.
@@ -90,30 +90,30 @@ config USB_STORAGE_USBAT
90 - Sandisk ImageMate SDDR-05b 90 - Sandisk ImageMate SDDR-05b
91 91
92config USB_STORAGE_SDDR09 92config USB_STORAGE_SDDR09
93 bool "SanDisk SDDR-09 (and other SmartMedia) support (EXPERIMENTAL)" 93 bool "SanDisk SDDR-09 (and other SmartMedia) support"
94 depends on USB_STORAGE && EXPERIMENTAL 94 depends on USB_STORAGE
95 help 95 help
96 Say Y here to include additional code to support the Sandisk SDDR-09 96 Say Y here to include additional code to support the Sandisk SDDR-09
97 SmartMedia reader in the USB Mass Storage driver. 97 SmartMedia reader in the USB Mass Storage driver.
98 Also works for the Microtech Zio! SmartMedia reader. 98 Also works for the Microtech Zio! SmartMedia reader.
99 99
100config USB_STORAGE_SDDR55 100config USB_STORAGE_SDDR55
101 bool "SanDisk SDDR-55 SmartMedia support (EXPERIMENTAL)" 101 bool "SanDisk SDDR-55 SmartMedia support"
102 depends on USB_STORAGE && EXPERIMENTAL 102 depends on USB_STORAGE
103 help 103 help
104 Say Y here to include additional code to support the Sandisk SDDR-55 104 Say Y here to include additional code to support the Sandisk SDDR-55
105 SmartMedia reader in the USB Mass Storage driver. 105 SmartMedia reader in the USB Mass Storage driver.
106 106
107config USB_STORAGE_JUMPSHOT 107config USB_STORAGE_JUMPSHOT
108 bool "Lexar Jumpshot Compact Flash Reader (EXPERIMENTAL)" 108 bool "Lexar Jumpshot Compact Flash Reader"
109 depends on USB_STORAGE && EXPERIMENTAL 109 depends on USB_STORAGE
110 help 110 help
111 Say Y here to include additional code to support the Lexar Jumpshot 111 Say Y here to include additional code to support the Lexar Jumpshot
112 USB CompactFlash reader. 112 USB CompactFlash reader.
113 113
114config USB_STORAGE_ALAUDA 114config USB_STORAGE_ALAUDA
115 bool "Olympus MAUSB-10/Fuji DPC-R1 support (EXPERIMENTAL)" 115 bool "Olympus MAUSB-10/Fuji DPC-R1 support"
116 depends on USB_STORAGE && EXPERIMENTAL 116 depends on USB_STORAGE
117 help 117 help
118 Say Y here to include additional code to support the Olympus MAUSB-10 118 Say Y here to include additional code to support the Olympus MAUSB-10
119 and Fujifilm DPC-R1 USB Card reader/writer devices. 119 and Fujifilm DPC-R1 USB Card reader/writer devices.
@@ -122,8 +122,8 @@ config USB_STORAGE_ALAUDA
122 XD and SmartMedia cards. 122 XD and SmartMedia cards.
123 123
124config USB_STORAGE_ONETOUCH 124config USB_STORAGE_ONETOUCH
125 bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" 125 bool "Support OneTouch Button on Maxtor Hard Drives"
126 depends on USB_STORAGE && INPUT_EVDEV && EXPERIMENTAL && !PM 126 depends on USB_STORAGE && INPUT_EVDEV
127 help 127 help
128 Say Y here to include additional code to support the Maxtor OneTouch 128 Say Y here to include additional code to support the Maxtor OneTouch
129 USB hard drive's onetouch button. 129 USB hard drive's onetouch button.
@@ -145,6 +145,17 @@ config USB_STORAGE_KARMA
145 on the resulting scsi device node returns the Karma to normal 145 on the resulting scsi device node returns the Karma to normal
146 operation. 146 operation.
147 147
148config USB_STORAGE_CYPRESS_ATACB
149 bool "SAT emulation on Cypress USB/ATA Bridge with ATACB"
150 depends on USB_STORAGE
151 ---help---
152 Say Y here if you want to use SAT (ata pass through) on devices based
153 on the Cypress USB/ATA bridge supporting ATACB. This will allow you
154 to use tools to tune and monitor your drive (like hdparm or smartctl).
155
156 If you say no here your device will still work with the standard usb
157 mass storage class.
158
148config USB_LIBUSUAL 159config USB_LIBUSUAL
149 bool "The shared table of common (or usual) storage devices" 160 bool "The shared table of common (or usual) storage devices"
150 depends on USB 161 depends on USB
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index 023969b4385..4c596c766c5 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -21,6 +21,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o 21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o
22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o 22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
23usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o 23usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o
24usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o
24 25
25usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ 26usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
26 initializers.o $(usb-storage-obj-y) 27 initializers.o $(usb-storage-obj-y)
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
new file mode 100644
index 00000000000..d88824b3511
--- /dev/null
+++ b/drivers/usb/storage/cypress_atacb.c
@@ -0,0 +1,200 @@
1/*
2 * Support for emulating SAT (ata pass through) on devices based
3 * on the Cypress USB/ATA bridge supporting ATACB.
4 *
5 * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <scsi/scsi.h>
23#include <scsi/scsi_cmnd.h>
24#include <scsi/scsi_eh.h>
25#include <linux/ata.h>
26
27#include "usb.h"
28#include "protocol.h"
29#include "scsiglue.h"
30#include "debug.h"
31
32/*
33 * ATACB is a protocol used on cypress usb<->ata bridge to
34 * send raw ATA command over mass storage
35 * There is a ATACB2 protocol that support LBA48 on newer chip.
36 * More info that be found on cy7c68310_8.pdf and cy7c68300c_8.pdf
37 * datasheet from cypress.com.
38 */
39void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
40{
41 unsigned char save_cmnd[MAX_COMMAND_SIZE];
42
43 if (likely(srb->cmnd[0] != ATA_16 && srb->cmnd[0] != ATA_12)) {
44 usb_stor_transparent_scsi_command(srb, us);
45 return;
46 }
47
48 memcpy(save_cmnd, srb->cmnd, sizeof(save_cmnd));
49 memset(srb->cmnd, 0, sizeof(srb->cmnd));
50
51 /* check if we support the command */
52 if (save_cmnd[1] >> 5) /* MULTIPLE_COUNT */
53 goto invalid_fld;
54 /* check protocol */
55 switch((save_cmnd[1] >> 1) & 0xf) {
56 case 3: /*no DATA */
57 case 4: /* PIO in */
58 case 5: /* PIO out */
59 break;
60 default:
61 goto invalid_fld;
62 }
63
64 /* first build the ATACB command */
65 srb->cmd_len = 16;
66
67 srb->cmnd[0] = 0x24; /* bVSCBSignature : vendor-specific command
68 this value can change, but most(all ?) manufacturers
69 keep the cypress default : 0x24 */
70 srb->cmnd[1] = 0x24; /* bVSCBSubCommand : 0x24 for ATACB */
71
72 srb->cmnd[3] = 0xff - 1; /* features, sector count, lba low, lba med
73 lba high, device, command are valid */
74 srb->cmnd[4] = 1; /* TransferBlockCount : 512 */
75
76 if (save_cmnd[0] == ATA_16) {
77 srb->cmnd[ 6] = save_cmnd[ 4]; /* features */
78 srb->cmnd[ 7] = save_cmnd[ 6]; /* sector count */
79 srb->cmnd[ 8] = save_cmnd[ 8]; /* lba low */
80 srb->cmnd[ 9] = save_cmnd[10]; /* lba med */
81 srb->cmnd[10] = save_cmnd[12]; /* lba high */
82 srb->cmnd[11] = save_cmnd[13]; /* device */
83 srb->cmnd[12] = save_cmnd[14]; /* command */
84
85 if (save_cmnd[1] & 0x01) {/* extended bit set for LBA48 */
86 /* this could be supported by atacb2 */
87 if (save_cmnd[3] || save_cmnd[5] || save_cmnd[7] || save_cmnd[9]
88 || save_cmnd[11])
89 goto invalid_fld;
90 }
91 }
92 else { /* ATA12 */
93 srb->cmnd[ 6] = save_cmnd[3]; /* features */
94 srb->cmnd[ 7] = save_cmnd[4]; /* sector count */
95 srb->cmnd[ 8] = save_cmnd[5]; /* lba low */
96 srb->cmnd[ 9] = save_cmnd[6]; /* lba med */
97 srb->cmnd[10] = save_cmnd[7]; /* lba high */
98 srb->cmnd[11] = save_cmnd[8]; /* device */
99 srb->cmnd[12] = save_cmnd[9]; /* command */
100
101 }
102 /* Filter SET_FEATURES - XFER MODE command */
103 if ((srb->cmnd[12] == ATA_CMD_SET_FEATURES)
104 && (srb->cmnd[6] == SETFEATURES_XFER))
105 goto invalid_fld;
106
107 if (srb->cmnd[12] == ATA_CMD_ID_ATA || srb->cmnd[12] == ATA_CMD_ID_ATAPI)
108 srb->cmnd[2] |= (1<<7); /* set IdentifyPacketDevice for these cmds */
109
110
111 usb_stor_transparent_scsi_command(srb, us);
112
113 /* if the device doesn't support ATACB
114 */
115 if (srb->result == SAM_STAT_CHECK_CONDITION &&
116 memcmp(srb->sense_buffer, usb_stor_sense_invalidCDB,
117 sizeof(usb_stor_sense_invalidCDB)) == 0) {
118 US_DEBUGP("cypress atacb not supported ???\n");
119 goto end;
120 }
121
122 /* if ck_cond flags is set, and there wasn't critical error,
123 * build the special sense
124 */
125 if ((srb->result != (DID_ERROR << 16) &&
126 srb->result != (DID_ABORT << 16)) &&
127 save_cmnd[2] & 0x20) {
128 struct scsi_eh_save ses;
129 unsigned char regs[8];
130 unsigned char *sb = srb->sense_buffer;
131 unsigned char *desc = sb + 8;
132 int tmp_result;
133
134 /* build the command for
135 * reading the ATA registers */
136 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, 0);
137 srb->sdb.length = sizeof(regs);
138 sg_init_one(&ses.sense_sgl, regs, srb->sdb.length);
139 srb->sdb.table.sgl = &ses.sense_sgl;
140 srb->sc_data_direction = DMA_FROM_DEVICE;
141 srb->sdb.table.nents = 1;
142 /* we use the same command as before, but we set
143 * the read taskfile bit, for not executing atacb command,
144 * but reading register selected in srb->cmnd[4]
145 */
146 srb->cmnd[2] = 1;
147
148 usb_stor_transparent_scsi_command(srb, us);
149 tmp_result = srb->result;
150 scsi_eh_restore_cmnd(srb, &ses);
151 /* we fail to get registers, report invalid command */
152 if (tmp_result != SAM_STAT_GOOD)
153 goto invalid_fld;
154
155 /* build the sense */
156 memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
157
158 /* set sk, asc for a good command */
159 sb[1] = RECOVERED_ERROR;
160 sb[2] = 0; /* ATA PASS THROUGH INFORMATION AVAILABLE */
161 sb[3] = 0x1D;
162
163 /* XXX we should generate sk, asc, ascq from status and error
164 * regs
165 * (see 11.1 Error translation ­ ATA device error to SCSI error map)
166 * and ata_to_sense_error from libata.
167 */
168
169 /* Sense data is current and format is descriptor. */
170 sb[0] = 0x72;
171 desc[0] = 0x09; /* ATA_RETURN_DESCRIPTOR */
172
173 /* set length of additional sense data */
174 sb[7] = 14;
175 desc[1] = 12;
176
177 /* Copy registers into sense buffer. */
178 desc[ 2] = 0x00;
179 desc[ 3] = regs[1]; /* features */
180 desc[ 5] = regs[2]; /* sector count */
181 desc[ 7] = regs[3]; /* lba low */
182 desc[ 9] = regs[4]; /* lba med */
183 desc[11] = regs[5]; /* lba high */
184 desc[12] = regs[6]; /* device */
185 desc[13] = regs[7]; /* command */
186
187 srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
188 }
189 goto end;
190invalid_fld:
191 srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
192
193 memcpy(srb->sense_buffer,
194 usb_stor_sense_invalidCDB,
195 sizeof(usb_stor_sense_invalidCDB));
196end:
197 memcpy(srb->cmnd, save_cmnd, sizeof(save_cmnd));
198 if (srb->cmnd[0] == ATA_12)
199 srb->cmd_len = 12;
200}
diff --git a/drivers/usb/storage/cypress_atacb.h b/drivers/usb/storage/cypress_atacb.h
new file mode 100644
index 00000000000..fbada898d56
--- /dev/null
+++ b/drivers/usb/storage/cypress_atacb.h
@@ -0,0 +1,25 @@
1/*
2 * Support for emulating SAT (ata pass through) on devices based
3 * on the Cypress USB/ATA bridge supporting ATACB.
4 *
5 * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#ifndef _CYPRESS_ATACB_H_
23#define _CYPRESS_ATACB_H_
24extern void cypress_atacb_passthrough(struct scsi_cmnd*, struct us_data*);
25#endif
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c
index 55b952084f0..a28d49122e7 100644
--- a/drivers/usb/storage/libusual.c
+++ b/drivers/usb/storage/libusual.c
@@ -9,6 +9,7 @@
9#include <linux/usb_usual.h> 9#include <linux/usb_usual.h>
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <linux/kthread.h> 11#include <linux/kthread.h>
12#include <linux/mutex.h>
12 13
13/* 14/*
14 */ 15 */
@@ -30,7 +31,7 @@ static atomic_t usu_bias = ATOMIC_INIT(USB_US_DEFAULT_BIAS);
30#define BIAS_NAME_SIZE (sizeof("usb-storage")) 31#define BIAS_NAME_SIZE (sizeof("usb-storage"))
31static const char *bias_names[3] = { "none", "usb-storage", "ub" }; 32static const char *bias_names[3] = { "none", "usb-storage", "ub" };
32 33
33static struct semaphore usu_init_notify; 34static DEFINE_MUTEX(usu_probe_mutex);
34static DECLARE_COMPLETION(usu_end_notify); 35static DECLARE_COMPLETION(usu_end_notify);
35static atomic_t total_threads = ATOMIC_INIT(0); 36static atomic_t total_threads = ATOMIC_INIT(0);
36 37
@@ -178,10 +179,7 @@ static int usu_probe_thread(void *arg)
178 int rc; 179 int rc;
179 unsigned long flags; 180 unsigned long flags;
180 181
181 /* A completion does not work here because it's counted. */ 182 mutex_lock(&usu_probe_mutex);
182 down(&usu_init_notify);
183 up(&usu_init_notify);
184
185 rc = request_module(bias_names[type]); 183 rc = request_module(bias_names[type]);
186 spin_lock_irqsave(&usu_lock, flags); 184 spin_lock_irqsave(&usu_lock, flags);
187 if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) { 185 if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) {
@@ -194,6 +192,7 @@ static int usu_probe_thread(void *arg)
194 } 192 }
195 st->fls &= ~USU_MOD_FL_THREAD; 193 st->fls &= ~USU_MOD_FL_THREAD;
196 spin_unlock_irqrestore(&usu_lock, flags); 194 spin_unlock_irqrestore(&usu_lock, flags);
195 mutex_unlock(&usu_probe_mutex);
197 196
198 complete_and_exit(&usu_end_notify, 0); 197 complete_and_exit(&usu_end_notify, 0);
199} 198}
@@ -204,10 +203,9 @@ static int __init usb_usual_init(void)
204{ 203{
205 int rc; 204 int rc;
206 205
207 sema_init(&usu_init_notify, 0); 206 mutex_lock(&usu_probe_mutex);
208
209 rc = usb_register(&usu_driver); 207 rc = usb_register(&usu_driver);
210 up(&usu_init_notify); 208 mutex_unlock(&usu_probe_mutex);
211 return rc; 209 return rc;
212} 210}
213 211
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 8c1e2954f3b..3fcde9f0fa5 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -73,6 +73,7 @@ static const char* host_info(struct Scsi_Host *host)
73static int slave_alloc (struct scsi_device *sdev) 73static int slave_alloc (struct scsi_device *sdev)
74{ 74{
75 struct us_data *us = host_to_us(sdev->host); 75 struct us_data *us = host_to_us(sdev->host);
76 struct usb_host_endpoint *bulk_in_ep;
76 77
77 /* 78 /*
78 * Set the INQUIRY transfer length to 36. We don't use any of 79 * Set the INQUIRY transfer length to 36. We don't use any of
@@ -84,12 +85,13 @@ static int slave_alloc (struct scsi_device *sdev)
84 /* Scatter-gather buffers (all but the last) must have a length 85 /* Scatter-gather buffers (all but the last) must have a length
85 * divisible by the bulk maxpacket size. Otherwise a data packet 86 * divisible by the bulk maxpacket size. Otherwise a data packet
86 * would end up being short, causing a premature end to the data 87 * would end up being short, causing a premature end to the data
87 * transfer. Since high-speed bulk pipes have a maxpacket size 88 * transfer. We'll use the maxpacket value of the bulk-IN pipe
88 * of 512, we'll use that as the scsi device queue's DMA alignment 89 * to set the SCSI device queue's DMA alignment mask.
89 * mask. Guaranteeing proper alignment of the first buffer will 90 */
90 * have the desired effect because, except at the beginning and 91 bulk_in_ep = us->pusb_dev->ep_in[usb_pipeendpoint(us->recv_bulk_pipe)];
91 * the end, scatter-gather buffers follow page boundaries. */ 92 blk_queue_update_dma_alignment(sdev->request_queue,
92 blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); 93 le16_to_cpu(bulk_in_ep->desc.wMaxPacketSize) - 1);
94 /* wMaxPacketSize must be a power of 2 */
93 95
94 /* 96 /*
95 * The UFI spec treates the Peripheral Qualifier bits in an 97 * The UFI spec treates the Peripheral Qualifier bits in an
@@ -132,7 +134,7 @@ static int slave_configure(struct scsi_device *sdev)
132 /* Disk-type devices use MODE SENSE(6) if the protocol 134 /* Disk-type devices use MODE SENSE(6) if the protocol
133 * (SubClass) is Transparent SCSI, otherwise they use 135 * (SubClass) is Transparent SCSI, otherwise they use
134 * MODE SENSE(10). */ 136 * MODE SENSE(10). */
135 if (us->subclass != US_SC_SCSI) 137 if (us->subclass != US_SC_SCSI && us->subclass != US_SC_CYP_ATACB)
136 sdev->use_10_for_ms = 1; 138 sdev->use_10_for_ms = 1;
137 139
138 /* Many disks only accept MODE SENSE transfer lengths of 140 /* Many disks only accept MODE SENSE transfer lengths of
@@ -226,12 +228,12 @@ static int queuecommand(struct scsi_cmnd *srb,
226{ 228{
227 struct us_data *us = host_to_us(srb->device->host); 229 struct us_data *us = host_to_us(srb->device->host);
228 230
229 US_DEBUGP("%s called\n", __FUNCTION__); 231 US_DEBUGP("%s called\n", __func__);
230 232
231 /* check for state-transition errors */ 233 /* check for state-transition errors */
232 if (us->srb != NULL) { 234 if (us->srb != NULL) {
233 printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n", 235 printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n",
234 __FUNCTION__, us->srb); 236 __func__, us->srb);
235 return SCSI_MLQUEUE_HOST_BUSY; 237 return SCSI_MLQUEUE_HOST_BUSY;
236 } 238 }
237 239
@@ -260,7 +262,7 @@ static int command_abort(struct scsi_cmnd *srb)
260{ 262{
261 struct us_data *us = host_to_us(srb->device->host); 263 struct us_data *us = host_to_us(srb->device->host);
262 264
263 US_DEBUGP("%s called\n", __FUNCTION__); 265 US_DEBUGP("%s called\n", __func__);
264 266
265 /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING 267 /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING
266 * bits are protected by the host lock. */ 268 * bits are protected by the host lock. */
@@ -297,7 +299,7 @@ static int device_reset(struct scsi_cmnd *srb)
297 struct us_data *us = host_to_us(srb->device->host); 299 struct us_data *us = host_to_us(srb->device->host);
298 int result; 300 int result;
299 301
300 US_DEBUGP("%s called\n", __FUNCTION__); 302 US_DEBUGP("%s called\n", __func__);
301 303
302 /* lock the device pointers and do the reset */ 304 /* lock the device pointers and do the reset */
303 mutex_lock(&(us->dev_mutex)); 305 mutex_lock(&(us->dev_mutex));
@@ -313,7 +315,7 @@ static int bus_reset(struct scsi_cmnd *srb)
313 struct us_data *us = host_to_us(srb->device->host); 315 struct us_data *us = host_to_us(srb->device->host);
314 int result; 316 int result;
315 317
316 US_DEBUGP("%s called\n", __FUNCTION__); 318 US_DEBUGP("%s called\n", __func__);
317 result = usb_stor_port_reset(us); 319 result = usb_stor_port_reset(us);
318 return result < 0 ? FAILED : SUCCESS; 320 return result < 0 ? FAILED : SUCCESS;
319} 321}
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index bdd4334bed5..6610d2dd1e7 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -110,7 +110,7 @@
110 */ 110 */
111static void usb_stor_blocking_completion(struct urb *urb) 111static void usb_stor_blocking_completion(struct urb *urb)
112{ 112{
113 struct completion *urb_done_ptr = (struct completion *)urb->context; 113 struct completion *urb_done_ptr = urb->context;
114 114
115 complete(urb_done_ptr); 115 complete(urb_done_ptr);
116} 116}
@@ -198,7 +198,7 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
198 int status; 198 int status;
199 199
200 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", 200 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n",
201 __FUNCTION__, request, requesttype, 201 __func__, request, requesttype,
202 value, index, size); 202 value, index, size);
203 203
204 /* fill in the devrequest structure */ 204 /* fill in the devrequest structure */
@@ -250,7 +250,7 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
250 usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe), 250 usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe),
251 usb_pipeout(pipe), 0); 251 usb_pipeout(pipe), 0);
252 252
253 US_DEBUGP("%s: result = %d\n", __FUNCTION__, result); 253 US_DEBUGP("%s: result = %d\n", __func__, result);
254 return result; 254 return result;
255} 255}
256 256
@@ -332,7 +332,7 @@ int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
332 int result; 332 int result;
333 333
334 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", 334 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n",
335 __FUNCTION__, request, requesttype, 335 __func__, request, requesttype,
336 value, index, size); 336 value, index, size);
337 337
338 /* fill in the devrequest structure */ 338 /* fill in the devrequest structure */
@@ -366,7 +366,7 @@ static int usb_stor_intr_transfer(struct us_data *us, void *buf,
366 unsigned int pipe = us->recv_intr_pipe; 366 unsigned int pipe = us->recv_intr_pipe;
367 unsigned int maxp; 367 unsigned int maxp;
368 368
369 US_DEBUGP("%s: xfer %u bytes\n", __FUNCTION__, length); 369 US_DEBUGP("%s: xfer %u bytes\n", __func__, length);
370 370
371 /* calculate the max packet size */ 371 /* calculate the max packet size */
372 maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe)); 372 maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe));
@@ -393,7 +393,7 @@ int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
393{ 393{
394 int result; 394 int result;
395 395
396 US_DEBUGP("%s: xfer %u bytes\n", __FUNCTION__, length); 396 US_DEBUGP("%s: xfer %u bytes\n", __func__, length);
397 397
398 /* fill and submit the URB */ 398 /* fill and submit the URB */
399 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length, 399 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length,
@@ -424,7 +424,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
424 return USB_STOR_XFER_ERROR; 424 return USB_STOR_XFER_ERROR;
425 425
426 /* initialize the scatter-gather request block */ 426 /* initialize the scatter-gather request block */
427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__, 427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __func__,
428 length, num_sg); 428 length, num_sg);
429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, 429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
430 sg, num_sg, length, GFP_NOIO); 430 sg, num_sg, length, GFP_NOIO);
@@ -603,7 +603,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
603 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE); 603 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE);
604 604
605 /* FIXME: we must do the protocol translation here */ 605 /* FIXME: we must do the protocol translation here */
606 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI) 606 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI ||
607 us->subclass == US_SC_CYP_ATACB)
607 srb->cmd_len = 6; 608 srb->cmd_len = 6;
608 else 609 else
609 srb->cmd_len = 12; 610 srb->cmd_len = 12;
@@ -700,7 +701,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
700/* Stop the current URB transfer */ 701/* Stop the current URB transfer */
701void usb_stor_stop_transport(struct us_data *us) 702void usb_stor_stop_transport(struct us_data *us)
702{ 703{
703 US_DEBUGP("%s called\n", __FUNCTION__); 704 US_DEBUGP("%s called\n", __func__);
704 705
705 /* If the state machine is blocked waiting for an URB, 706 /* If the state machine is blocked waiting for an URB,
706 * let's wake it up. The test_and_clear_bit() call 707 * let's wake it up. The test_and_clear_bit() call
@@ -1134,7 +1135,7 @@ static int usb_stor_reset_common(struct us_data *us,
1134 1135
1135int usb_stor_CB_reset(struct us_data *us) 1136int usb_stor_CB_reset(struct us_data *us)
1136{ 1137{
1137 US_DEBUGP("%s called\n", __FUNCTION__); 1138 US_DEBUGP("%s called\n", __func__);
1138 1139
1139 memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE); 1140 memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE);
1140 us->iobuf[0] = SEND_DIAGNOSTIC; 1141 us->iobuf[0] = SEND_DIAGNOSTIC;
@@ -1149,7 +1150,7 @@ int usb_stor_CB_reset(struct us_data *us)
1149 */ 1150 */
1150int usb_stor_Bulk_reset(struct us_data *us) 1151int usb_stor_Bulk_reset(struct us_data *us)
1151{ 1152{
1152 US_DEBUGP("%s called\n", __FUNCTION__); 1153 US_DEBUGP("%s called\n", __func__);
1153 1154
1154 return usb_stor_reset_common(us, US_BULK_RESET_REQUEST, 1155 return usb_stor_reset_common(us, US_BULK_RESET_REQUEST,
1155 USB_TYPE_CLASS | USB_RECIP_INTERFACE, 1156 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 91252075e6e..732bf52a775 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1719,6 +1719,14 @@ UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001,
1719 US_SC_DEVICE, US_PR_DEVICE, NULL, 1719 US_SC_DEVICE, US_PR_DEVICE, NULL,
1720 US_FL_CAPACITY_HEURISTICS), 1720 US_FL_CAPACITY_HEURISTICS),
1721 1721
1722#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
1723UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
1724 "Cypress",
1725 "Cypress AT2LP",
1726 US_SC_CYP_ATACB, US_PR_BULK, NULL,
1727 0),
1728#endif
1729
1722/* Control/Bulk transport for all SubClass values */ 1730/* Control/Bulk transport for all SubClass values */
1723USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), 1731USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
1724USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), 1732USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR),
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index ac6114eea0c..a856effad3b 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -101,6 +101,9 @@
101#ifdef CONFIG_USB_STORAGE_KARMA 101#ifdef CONFIG_USB_STORAGE_KARMA
102#include "karma.h" 102#include "karma.h"
103#endif 103#endif
104#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
105#include "cypress_atacb.h"
106#endif
104 107
105/* Some informational data */ 108/* Some informational data */
106MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); 109MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
@@ -187,7 +190,7 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message)
187 /* Wait until no command is running */ 190 /* Wait until no command is running */
188 mutex_lock(&us->dev_mutex); 191 mutex_lock(&us->dev_mutex);
189 192
190 US_DEBUGP("%s\n", __FUNCTION__); 193 US_DEBUGP("%s\n", __func__);
191 if (us->suspend_resume_hook) 194 if (us->suspend_resume_hook)
192 (us->suspend_resume_hook)(us, US_SUSPEND); 195 (us->suspend_resume_hook)(us, US_SUSPEND);
193 196
@@ -204,7 +207,7 @@ static int storage_resume(struct usb_interface *iface)
204 207
205 mutex_lock(&us->dev_mutex); 208 mutex_lock(&us->dev_mutex);
206 209
207 US_DEBUGP("%s\n", __FUNCTION__); 210 US_DEBUGP("%s\n", __func__);
208 if (us->suspend_resume_hook) 211 if (us->suspend_resume_hook)
209 (us->suspend_resume_hook)(us, US_RESUME); 212 (us->suspend_resume_hook)(us, US_RESUME);
210 213
@@ -216,7 +219,7 @@ static int storage_reset_resume(struct usb_interface *iface)
216{ 219{
217 struct us_data *us = usb_get_intfdata(iface); 220 struct us_data *us = usb_get_intfdata(iface);
218 221
219 US_DEBUGP("%s\n", __FUNCTION__); 222 US_DEBUGP("%s\n", __func__);
220 223
221 /* Report the reset to the SCSI core */ 224 /* Report the reset to the SCSI core */
222 usb_stor_report_bus_reset(us); 225 usb_stor_report_bus_reset(us);
@@ -237,7 +240,7 @@ static int storage_pre_reset(struct usb_interface *iface)
237{ 240{
238 struct us_data *us = usb_get_intfdata(iface); 241 struct us_data *us = usb_get_intfdata(iface);
239 242
240 US_DEBUGP("%s\n", __FUNCTION__); 243 US_DEBUGP("%s\n", __func__);
241 244
242 /* Make sure no command runs during the reset */ 245 /* Make sure no command runs during the reset */
243 mutex_lock(&us->dev_mutex); 246 mutex_lock(&us->dev_mutex);
@@ -248,7 +251,7 @@ static int storage_post_reset(struct usb_interface *iface)
248{ 251{
249 struct us_data *us = usb_get_intfdata(iface); 252 struct us_data *us = usb_get_intfdata(iface);
250 253
251 US_DEBUGP("%s\n", __FUNCTION__); 254 US_DEBUGP("%s\n", __func__);
252 255
253 /* Report the reset to the SCSI core */ 256 /* Report the reset to the SCSI core */
254 usb_stor_report_bus_reset(us); 257 usb_stor_report_bus_reset(us);
@@ -434,7 +437,7 @@ SkipForAbort:
434/* Associate our private data with the USB device */ 437/* Associate our private data with the USB device */
435static int associate_dev(struct us_data *us, struct usb_interface *intf) 438static int associate_dev(struct us_data *us, struct usb_interface *intf)
436{ 439{
437 US_DEBUGP("-- %s\n", __FUNCTION__); 440 US_DEBUGP("-- %s\n", __func__);
438 441
439 /* Fill in the device-related fields */ 442 /* Fill in the device-related fields */
440 us->pusb_dev = interface_to_usbdev(intf); 443 us->pusb_dev = interface_to_usbdev(intf);
@@ -708,6 +711,13 @@ static int get_protocol(struct us_data *us)
708 break; 711 break;
709#endif 712#endif
710 713
714#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
715 case US_SC_CYP_ATACB:
716 us->protocol_name = "Transparent SCSI with Cypress ATACB";
717 us->proto_handler = cypress_atacb_passthrough;
718 break;
719#endif
720
711 default: 721 default:
712 return -EIO; 722 return -EIO;
713 } 723 }
@@ -806,7 +816,7 @@ static int usb_stor_acquire_resources(struct us_data *us)
806/* Release all our dynamic resources */ 816/* Release all our dynamic resources */
807static void usb_stor_release_resources(struct us_data *us) 817static void usb_stor_release_resources(struct us_data *us)
808{ 818{
809 US_DEBUGP("-- %s\n", __FUNCTION__); 819 US_DEBUGP("-- %s\n", __func__);
810 820
811 /* Tell the control thread to exit. The SCSI host must 821 /* Tell the control thread to exit. The SCSI host must
812 * already have been removed so it won't try to queue 822 * already have been removed so it won't try to queue
@@ -832,7 +842,7 @@ static void usb_stor_release_resources(struct us_data *us)
832/* Dissociate from the USB device */ 842/* Dissociate from the USB device */
833static void dissociate_dev(struct us_data *us) 843static void dissociate_dev(struct us_data *us)
834{ 844{
835 US_DEBUGP("-- %s\n", __FUNCTION__); 845 US_DEBUGP("-- %s\n", __func__);
836 846
837 kfree(us->sensebuf); 847 kfree(us->sensebuf);
838 848