patch-2.4.0-test10 linux/drivers/usb/storage/freecom.c
Next file: linux/drivers/usb/storage/scsiglue.c
Previous file: linux/drivers/usb/serial/whiteheat_fw.h
Back to the patch index
Back to the overall index
- Lines: 559
- Date:
Mon Oct 9 14:23:57 2000
- Orig file:
v2.4.0-test9/linux/drivers/usb/storage/freecom.c
- Orig date:
Sun Oct 8 10:50:30 2000
diff -u --recursive --new-file v2.4.0-test9/linux/drivers/usb/storage/freecom.c linux/drivers/usb/storage/freecom.c
@@ -1,6 +1,6 @@
/* Driver for Freecom USB/IDE adaptor
*
- * $Id: freecom.c,v 1.12 2000/09/22 01:16:17 mdharm Exp $
+ * $Id: freecom.c,v 1.13 2000/10/03 01:06:07 mdharm Exp $
*
* Freecom v0.1:
*
@@ -28,6 +28,7 @@
* (http://www.freecom.de/)
*/
+#include <linux/config.h>
#include "transport.h"
#include "protocol.h"
#include "usb.h"
@@ -35,7 +36,9 @@
#include "freecom.h"
#include "linux/hdreg.h"
+#ifdef CONFIG_USB_STORAGE_DEBUG
static void pdump (void *, int);
+#endif
struct freecom_udata {
__u8 buffer[64]; /* Common command block. */
@@ -104,7 +107,7 @@
* Transfer an entire SCSI command's worth of data payload over the bulk
* pipe.
*
- * Note that this uses us_transfer_partial to achieve it's goals -- this
+ * Note that this uses usb_stor_transfer_partial to achieve it's goals -- this
* function simply determines if we're going to use scatter-gather or not,
* and acts appropriately. For now, it also re-interprets the error codes.
*/
@@ -133,11 +136,12 @@
* remaining data */
if (transfer_amount - total_transferred >=
sg[i].length) {
- result = us_transfer_partial(us, sg[i].address,
- sg[i].length);
+ result = usb_stor_transfer_partial(us,
+ sg[i].address, sg[i].length);
total_transferred += sg[i].length;
} else
- result = us_transfer_partial(us, sg[i].address,
+ result = usb_stor_transfer_partial(us,
+ sg[i].address,
transfer_amount - total_transferred);
/* if we get an error, end the loop here */
@@ -147,7 +151,7 @@
}
else
/* no scatter-gather, just make the request */
- result = us_transfer_partial(us, srb->request_buffer,
+ result = usb_stor_transfer_partial(us, srb->request_buffer,
transfer_amount);
/* return the result in the data structure itself */
@@ -165,7 +169,7 @@
int opipe;
int result, partial;
- printk (KERN_DEBUG "IDE out 0x%02x <- 0x%02x\n", reg, value);
+ US_DEBUGP("IDE out 0x%02x <- 0x%02x\n", reg, value);
/* Get handles for both transports. */
opipe = usb_sndbulkpipe (us->pusb_dev, us->ep_out);
@@ -247,7 +251,7 @@
else
*value = le16_to_cpu (*(__u16 *) buffer);
- printk (KERN_DEBUG "IDE in 0x%02x -> 0x%02x\n", reg, *value);
+ US_DEBUGP("IDE in 0x%02x -> 0x%02x\n", reg, *value);
return USB_STOR_TRANSPORT_GOOD;
}
@@ -260,16 +264,13 @@
struct freecom_xfer_wrap *fxfr =
(struct freecom_xfer_wrap *) extra->buffer;
int result, partial;
- int offset;
- int this_read;
- __u8 *buffer = extra->buffer;
fxfr->Type = FCM_PACKET_INPUT | 0x00;
fxfr->Timeout = 0; /* Short timeout for debugging. */
fxfr->Count = cpu_to_le32 (count);
memset (fxfr->Pad, 0, sizeof (fxfr->Pad));
- printk (KERN_DEBUG "Read data Freecom! (c=%d)\n", count);
+ US_DEBUGP("Read data Freecom! (c=%d)\n", count);
/* Issue the transfer command. */
result = usb_stor_bulk_msg (us, fxfr, opipe,
@@ -280,78 +281,19 @@
/* -ENOENT -- we canceled this transfer */
if (result == -ENOENT) {
- US_DEBUGP("us_transfer_partial(): transfer aborted\n");
+ US_DEBUGP("freecom_readdata(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
return USB_STOR_TRANSPORT_ERROR;
}
- printk (KERN_DEBUG "Done issuing read request: %d %d\n",
- result, partial);
+ US_DEBUGP("Done issuing read request: %d %d\n", result, partial);
/* Now transfer all of our blocks. */
- printk (KERN_DEBUG "Start of read\n");
+ US_DEBUGP("Start of read\n");
us_transfer_freecom(srb, us, count);
-#if 0
- if (srb->use_sg) {
- US_DEBUGP ("Need to implement scatter-gather\n");
- return USB_STOR_TRANSPORT_ERROR;
- } else {
- offset = 0;
-
- while (offset < count) {
-#if 0
- this_read = count - offset;
- if (this_read > 64)
- this_read = 64;
-#else
- this_read = 64;
-#endif
-
- printk (KERN_DEBUG "Start of read\n");
- /* Use the given buffer directly, but only if there
- * is space for an entire packet. */
-
- if (offset + 64 <= srb->request_bufflen) {
- result = usb_stor_bulk_msg (
- us, srb->request_buffer+offset,
- ipipe, this_read, &partial);
- printk (KERN_DEBUG "Read111 = %d, %d\n",
- result, partial);
- pdump (srb->request_buffer+offset,
- partial);
- } else {
- result = usb_stor_bulk_msg (
- us, buffer,
- ipipe, this_read, &partial);
- printk (KERN_DEBUG "Read112 = %d, %d\n",
- result, partial);
- memcpy (srb->request_buffer+offset,
- buffer,
- srb->request_bufflen - offset);
- pdump (srb->request_buffer+offset,
- srb->request_bufflen - offset);
- }
-
- if (result != 0) {
- US_DEBUGP ("Freecom readblock r=%d, p=%d\n",
- result, partial);
-
- /* -ENOENT -- we canceled this transfer */
- if (result == -ENOENT) {
- US_DEBUGP("us_transfer_partial(): transfer aborted\n");
- return US_BULK_TRANSFER_ABORTED;
- }
+ US_DEBUGP("freecom_readdata done!\n");
- return USB_STOR_TRANSPORT_ERROR;
- }
-
- offset += this_read;
- }
- }
-#endif
-
- printk (KERN_DEBUG "freecom_readdata done!\n");
return USB_STOR_TRANSPORT_GOOD;
}
@@ -363,16 +305,13 @@
struct freecom_xfer_wrap *fxfr =
(struct freecom_xfer_wrap *) extra->buffer;
int result, partial;
- int offset;
- int this_write;
- __u8 *buffer = extra->buffer;
fxfr->Type = FCM_PACKET_OUTPUT | 0x00;
fxfr->Timeout = 0; /* Short timeout for debugging. */
fxfr->Count = cpu_to_le32 (count);
memset (fxfr->Pad, 0, sizeof (fxfr->Pad));
- printk (KERN_DEBUG "Write data Freecom! (c=%d)\n", count);
+ US_DEBUGP("Write data Freecom! (c=%d)\n", count);
/* Issue the transfer command. */
result = usb_stor_bulk_msg (us, fxfr, opipe,
@@ -383,78 +322,20 @@
/* -ENOENT -- we canceled this transfer */
if (result == -ENOENT) {
- US_DEBUGP("us_transfer_partial(): transfer aborted\n");
+ US_DEBUGP("freecom_writedata(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
return USB_STOR_TRANSPORT_ERROR;
}
- printk (KERN_DEBUG "Done issuing write request: %d %d\n",
+ US_DEBUGP("Done issuing write request: %d %d\n",
result, partial);
/* Now transfer all of our blocks. */
- printk (KERN_DEBUG "Start of write\n");
+ US_DEBUGP("Start of write\n");
us_transfer_freecom(srb, us, count);
-#if 0
- if (srb->use_sg) {
- US_DEBUGP ("Need to implement scatter-gather\n");
- return USB_STOR_TRANSPORT_ERROR;
- } else {
- offset = 0;
-
- while (offset < count) {
-#if 1
- this_write = count - offset;
- if (this_write > 64)
- this_write = 64;
-#else
- this_write = 64;
-#endif
-
- printk (KERN_DEBUG "Start of write\n");
- /* Use the given buffer directly, but only if there
- * is space for an entire packet. */
-
- if (offset + 64 <= srb->request_bufflen) {
- result = usb_stor_bulk_msg (
- us, srb->request_buffer+offset,
- opipe, this_write, &partial);
- printk (KERN_DEBUG "Write111 = %d, %d\n",
- result, partial);
- pdump (srb->request_buffer+offset,
- partial);
- } else {
- result = usb_stor_bulk_msg (
- us, buffer,
- opipe, this_write, &partial);
- printk (KERN_DEBUG "Write112 = %d, %d\n",
- result, partial);
- memcpy (buffer,
- srb->request_buffer+offset,
- srb->request_bufflen - offset);
- pdump (srb->request_buffer+offset,
- srb->request_bufflen - offset);
- }
-
- if (result != 0) {
- US_DEBUGP ("Freecom writeblock r=%d, p=%d\n",
- result, partial);
-
- /* -ENOENT -- we canceled this transfer */
- if (result == -ENOENT) {
- US_DEBUGP("us_transfer_partial(): transfer aborted\n");
- return US_BULK_TRANSFER_ABORTED;
- }
-
- return USB_STOR_TRANSPORT_ERROR;
- }
-
- offset += this_write;
- }
- }
-#endif
- printk (KERN_DEBUG "freecom_writedata done!\n");
+ US_DEBUGP("freecom_writedata done!\n");
return USB_STOR_TRANSPORT_GOOD;
}
@@ -477,7 +358,7 @@
fcb = (struct freecom_cb_wrap *) extra->buffer;
fst = (struct freecom_status *) extra->buffer;
- printk (KERN_DEBUG "Freecom TRANSPORT STARTED\n");
+ US_DEBUGP("Freecom TRANSPORT STARTED\n");
/* Get handles for both transports. */
opipe = usb_sndbulkpipe (us->pusb_dev, us->ep_out);
@@ -496,7 +377,7 @@
memcpy (fcb->Atapi, srb->cmnd, 12);
memset (fcb->Filler, 0, sizeof (fcb->Filler));
- pdump (srb->cmnd, 12);
+ US_DEBUG(pdump (srb->cmnd, 12));
/* Send it out. */
result = usb_stor_bulk_msg (us, fcb, opipe,
@@ -511,7 +392,7 @@
/* -ENOENT -- we canceled this transfer */
if (result == -ENOENT) {
- US_DEBUGP("us_transfer_partial(): transfer aborted\n");
+ US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
@@ -522,14 +403,14 @@
* doesn't hurt us to always do it now. */
result = usb_stor_bulk_msg (us, fst, ipipe,
FCM_PACKET_LENGTH, &partial);
- printk (KERN_DEBUG "foo Status result %d %d\n", result, partial);
+ US_DEBUGP("foo Status result %d %d\n", result, partial);
/* -ENOENT -- we canceled this transfer */
if (result == -ENOENT) {
- US_DEBUGP("us_transfer_partial(): transfer aborted\n");
+ US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
- pdump ((void *) fst, partial);
+ US_DEBUG(pdump ((void *) fst, partial));
/* while we haven't recieved the IRQ */
while (!(fst->Status & 0x2)) {
@@ -545,16 +426,17 @@
result = usb_stor_bulk_msg (us, fcb, opipe,
FCM_PACKET_LENGTH, &partial);
- /* The Freecom device will only fail if there is something wrong in
- * USB land. It returns the status in its own registers, which
- * come back in the bulk pipe. */
+ /* The Freecom device will only fail if there is something
+ * wrong in USB land. It returns the status in its own
+ * registers, which come back in the bulk pipe.
+ */
if (result != 0) {
US_DEBUGP ("freecom xport failure: r=%d, p=%d\n",
result, partial);
/* -ENOENT -- we canceled this transfer */
if (result == -ENOENT) {
- US_DEBUGP("us_transfer_partial(): transfer aborted\n");
+ US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
@@ -564,35 +446,35 @@
/* actually get the status info */
result = usb_stor_bulk_msg (us, fst, ipipe,
FCM_PACKET_LENGTH, &partial);
- printk (KERN_DEBUG "bar Status result %d %d\n", result, partial);
+ US_DEBUGP("bar Status result %d %d\n", result, partial);
/* -ENOENT -- we canceled this transfer */
if (result == -ENOENT) {
- US_DEBUGP("us_transfer_partial(): transfer aborted\n");
+ US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
- pdump ((void *) fst, partial);
+ US_DEBUG(pdump ((void *) fst, partial));
}
if (partial != 4 || result != 0) {
return USB_STOR_TRANSPORT_ERROR;
}
if ((fst->Status & 1) != 0) {
- printk (KERN_DEBUG "operation failed\n");
+ US_DEBUGP("operation failed\n");
return USB_STOR_TRANSPORT_FAILED;
}
/* The device might not have as much data available as we
* requested. If you ask for more than the device has, this reads
* and such will hang. */
- printk (KERN_DEBUG "Device indicates that it has %d bytes available\n",
+ US_DEBUGP("Device indicates that it has %d bytes available\n",
le16_to_cpu (fst->Count));
/* Find the length we desire to read. It is the lesser of the SCSI
* layer's requested length, and the length the device claims to
* have available. */
- length = us_transfer_length (srb);
- printk (KERN_DEBUG "SCSI requested %d\n", length);
+ length = usb_stor_transfer_length (srb);
+ US_DEBUGP("SCSI requested %d\n", length);
if (length > le16_to_cpu (fst->Count))
length = le16_to_cpu (fst->Count);
@@ -604,17 +486,17 @@
/* Make sure that the status indicates that the device
* wants data as well. */
if ((fst->Status & DRQ_STAT) == 0 || (fst->Reason & 3) != 2) {
- printk (KERN_DEBUG "SCSI wants data, drive doesn't have any\n");
+ US_DEBUGP("SCSI wants data, drive doesn't have any\n");
return USB_STOR_TRANSPORT_FAILED;
}
result = freecom_readdata (srb, us, ipipe, opipe, length);
if (result != USB_STOR_TRANSPORT_GOOD)
return result;
- printk (KERN_DEBUG "FCM: Waiting for status\n");
+ US_DEBUGP("FCM: Waiting for status\n");
result = usb_stor_bulk_msg (us, fst, ipipe,
FCM_PACKET_LENGTH, &partial);
- pdump ((void *) fst, partial);
+ US_DEBUG(pdump ((void *) fst, partial));
if (result == -ENOENT) {
US_DEBUGP ("freecom_transport: transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
@@ -622,14 +504,14 @@
if (partial != 4 || result != 0)
return USB_STOR_TRANSPORT_ERROR;
if ((fst->Status & ERR_STAT) != 0) {
- printk (KERN_DEBUG "operation failed\n");
+ US_DEBUGP("operation failed\n");
return USB_STOR_TRANSPORT_FAILED;
}
if ((fst->Reason & 3) != 3) {
- printk (KERN_DEBUG "Drive seems still hungry\n");
+ US_DEBUGP("Drive seems still hungry\n");
return USB_STOR_TRANSPORT_FAILED;
}
- printk (KERN_DEBUG "Transfer happy\n");
+ US_DEBUGP("Transfer happy\n");
break;
case SCSI_DATA_WRITE:
@@ -641,7 +523,7 @@
return result;
#if 1
- printk (KERN_DEBUG "FCM: Waiting for status\n");
+ US_DEBUGP("FCM: Waiting for status\n");
result = usb_stor_bulk_msg (us, fst, ipipe,
FCM_PACKET_LENGTH, &partial);
if (result == -ENOENT) {
@@ -651,15 +533,15 @@
if (partial != 4 || result != 0)
return USB_STOR_TRANSPORT_ERROR;
if ((fst->Status & ERR_STAT) != 0) {
- printk (KERN_DEBUG "operation failed\n");
+ US_DEBUGP("operation failed\n");
return USB_STOR_TRANSPORT_FAILED;
}
if ((fst->Reason & 3) != 3) {
- printk (KERN_DEBUG "Drive seems still hungry\n");
+ US_DEBUGP("Drive seems still hungry\n");
return USB_STOR_TRANSPORT_FAILED;
}
#endif
- printk (KERN_DEBUG "Transfer happy\n");
+ US_DEBUGP("Transfer happy\n");
break;
@@ -675,27 +557,12 @@
break;
}
-#if 0
- /* After the transfer, we can read our status register. */
- printk (KERN_DEBUG "Going to read status register\n");
- result = usb_stor_bulk_msg (us, &fst, ipipe,
- FCM_PACKET_LENGTH, &partial);
- printk (KERN_DEBUG "Result from read %d %d\n", result, partial);
- if (result != 0) {
- return USB_STOR_TRANSPORT_ERROR;
- }
- if ((fst.Reason & 1) != 0) {
- return USB_STOR_TRANSPORT_FAILED;
- }
-#endif
-
return USB_STOR_TRANSPORT_GOOD;
- printk (KERN_DEBUG "Freecom: transfer_length = %d\n",
- us_transfer_length (srb));
+ US_DEBUGP("Freecom: transfer_length = %d\n",
+ usb_stor_transfer_length (srb));
- printk (KERN_DEBUG "Freecom: direction = %d\n",
- srb->sc_data_direction);
+ US_DEBUGP("Freecom: direction = %d\n", srb->sc_data_direction);
return USB_STOR_TRANSPORT_ERROR;
}
@@ -713,13 +580,14 @@
us->extra = kmalloc (sizeof (struct freecom_udata),
GFP_KERNEL);
if (us->extra == NULL) {
- printk (KERN_WARNING USB_STORAGE "Out of memory\n");
+ US_DEBUGP("Out of memory\n");
return USB_STOR_TRANSPORT_ERROR;
}
}
- result = usb_stor_control_msg(us, usb_rcvctrlpipe(us->pusb_dev, 0),
- 0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20);
+ result = usb_control_msg(us->pusb_dev,
+ usb_rcvctrlpipe(us->pusb_dev, 0),
+ 0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20, 3*HZ);
buffer[32] = '\0';
US_DEBUGP("String returned from FC init is: %s\n", buffer);
@@ -736,7 +604,7 @@
if (result != USB_STOR_TRANSPORT_GOOD)
return result;
if (counter-- < 0) {
- printk (KERN_WARNING USB_STORAGE "Timeout in freecom");
+ US_DEBUGP("Timeout in freecom");
return USB_STOR_TRANSPORT_ERROR;
}
} while ((value & 0x80) != 0);
@@ -751,7 +619,7 @@
if (result != USB_STOR_TRANSPORT_GOOD)
return result;
if (counter-- < 0) {
- printk (KERN_WARNING USB_STORAGE "Timeout in freecom");
+ US_DEBUGP("Timeout in freecom");
return USB_STOR_TRANSPORT_ERROR;
}
} while ((value & 0x80) != 0);
@@ -765,12 +633,13 @@
int usb_stor_freecom_reset(struct us_data *us)
{
- printk (KERN_DEBUG "freecom reset called\n");
+ printk (KERN_CRIT "freecom reset called\n");
/* We don't really have this feature. */
- return USB_STOR_TRANSPORT_ERROR;
+ return FAILED;
}
+#ifdef CONFIG_USB_STORAGE_DEBUG
static void pdump (void *ibuffer, int length)
{
static char line[80];
@@ -791,7 +660,7 @@
line[offset++] = '.';
}
line[offset] = 0;
- printk (KERN_DEBUG "%s\n", line);
+ US_DEBUGP("%s\n", line);
offset = 0;
}
offset += sprintf (line+offset, "%08x:", i);
@@ -819,7 +688,8 @@
line[offset++] = '.';
}
line[offset] = 0;
- printk (KERN_DEBUG "%s\n", line);
+ US_DEBUGP("%s\n", line);
offset = 0;
}
+#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)