]> err.no Git - linux-2.6/blobdiff - drivers/usb/storage/isd200.c
Merge commit 'v2.6.26-rc9' into x86/cpu
[linux-2.6] / drivers / usb / storage / isd200.c
index 178e8c2a8a2feb41f03fd7d16117347647f6247b..3addcd8f827bd3d17463dbc67395c072cfae4d81 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/hdreg.h>
-#include <linux/ide.h>
 #include <linux/scatterlist.h>
 
 #include <scsi/scsi.h>
 #define REG_STATUS             0x80
 #define REG_COMMAND            0x80
 
+/* ATA registers offset definitions */
+#define ATA_REG_ERROR_OFFSET           1
+#define ATA_REG_LCYL_OFFSET            4
+#define ATA_REG_HCYL_OFFSET            5
+#define ATA_REG_STATUS_OFFSET          7
+
 /* ATA error definitions not in <linux/hdreg.h> */
 #define ATA_ERROR_MEDIA_CHANGE         0x20
 
@@ -287,6 +292,7 @@ struct isd200_info {
 
        /* maximum number of LUNs supported */
        unsigned char MaxLUNs;
+       unsigned char cmnd[BLK_MAX_CDB];
        struct scsi_cmnd srb;
        struct scatterlist sg;
 };
@@ -360,7 +366,7 @@ static void isd200_build_sense(struct us_data *us, struct scsi_cmnd *srb)
 {
        struct isd200_info *info = (struct isd200_info *)us->extra;
        struct sense_data *buf = (struct sense_data *) &srb->sense_buffer[0];
-       unsigned char error = info->ATARegs[IDE_ERROR_OFFSET];
+       unsigned char error = info->ATARegs[ATA_REG_ERROR_OFFSET];
 
        if(error & ATA_ERROR_MEDIA_CHANGE) {
                buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID;
@@ -415,14 +421,14 @@ static void isd200_set_srb(struct isd200_info *info,
                sg_init_one(&info->sg, buff, bufflen);
 
        srb->sc_data_direction = dir;
-       srb->request_buffer = buff ? &info->sg : NULL;
-       srb->request_bufflen = bufflen;
-       srb->use_sg = buff ? 1 : 0;
+       srb->sdb.table.sgl = buff ? &info->sg : NULL;
+       srb->sdb.length = bufflen;
+       srb->sdb.table.nents = buff ? 1 : 0;
 }
 
 static void isd200_srb_set_bufflen(struct scsi_cmnd *srb, unsigned bufflen)
 {
-       srb->request_bufflen = bufflen;
+       srb->sdb.length = bufflen;
 }
 
 
@@ -445,6 +451,7 @@ static int isd200_action( struct us_data *us, int action,
 
        memset(&ata, 0, sizeof(ata));
        memset(&srb_dev, 0, sizeof(srb_dev));
+       srb->cmnd = info->cmnd;
        srb->device = &srb_dev;
        ++srb->serial_number;
 
@@ -549,8 +556,8 @@ static int isd200_read_regs( struct us_data *us )
                retStatus = ISD200_ERROR;
        } else {
                memcpy(info->ATARegs, info->RegsBuf, sizeof(info->ATARegs));
-               US_DEBUGP("   Got ATA Register[IDE_ERROR_OFFSET] = 0x%x\n", 
-                         info->ATARegs[IDE_ERROR_OFFSET]);
+               US_DEBUGP("   Got ATA Register[ATA_REG_ERROR_OFFSET] = 0x%x\n",
+                         info->ATARegs[ATA_REG_ERROR_OFFSET]);
        }
 
        return retStatus;
@@ -892,7 +899,7 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
                        break;
 
                if (!detect) {
-                       if (regs[IDE_STATUS_OFFSET] & BUSY_STAT ) {
+                       if (regs[ATA_REG_STATUS_OFFSET] & BUSY_STAT) {
                                US_DEBUGP("   %s status is still BSY, try again...\n",mstr);
                        } else {
                                US_DEBUGP("   %s status !BSY, continue with next operation\n",mstr);
@@ -902,12 +909,12 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
                /* check for BUSY_STAT and */
                /* WRERR_STAT (workaround ATA Zip drive) and */ 
                /* ERR_STAT (workaround for Archos CD-ROM) */
-               else if (regs[IDE_STATUS_OFFSET] & 
+               else if (regs[ATA_REG_STATUS_OFFSET] &
                         (BUSY_STAT | WRERR_STAT | ERR_STAT )) {
                        US_DEBUGP("   Status indicates it is not ready, try again...\n");
                }
                /* check for DRDY, ATA devices set DRDY after SRST */
-               else if (regs[IDE_STATUS_OFFSET] & READY_STAT) {
+               else if (regs[ATA_REG_STATUS_OFFSET] & READY_STAT) {
                        US_DEBUGP("   Identified ATA device\n");
                        info->DeviceFlags |= DF_ATA_DEVICE;
                        info->DeviceHead = master_slave;
@@ -916,8 +923,8 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
                /* check Cylinder High/Low to
                   determine if it is an ATAPI device
                */
-               else if ((regs[IDE_HCYL_OFFSET] == 0xEB) &&
-                        (regs[IDE_LCYL_OFFSET] == 0x14)) {
+               else if (regs[ATA_REG_HCYL_OFFSET] == 0xEB &&
+                        regs[ATA_REG_LCYL_OFFSET] == 0x14) {
                        /* It seems that the RICOH 
                           MP6200A CD/RW drive will 
                           report itself okay as a
@@ -1001,12 +1008,6 @@ static int isd200_manual_enum(struct us_data *us)
        return(retStatus);
 }
 
-/*
- *     We are the last non IDE user of the legacy IDE ident structures
- *     and we thus want to keep a private copy of this function so the
- *     driver can be used without the obsolete drivers/ide layer
- */
-
 static void isd200_fix_driveid (struct hd_driveid *id)
 {
 #ifndef __LITTLE_ENDIAN
@@ -1231,6 +1232,7 @@ static int isd200_get_inquiry_data( struct us_data *us )
            
                        /* Free driver structure */         
                        us->extra_destructor(info);
+                       kfree(info);
                        us->extra = NULL;
                        us->extra_destructor = NULL;
                }
@@ -1470,6 +1472,7 @@ static void isd200_free_info_ptrs(void *info_)
        if (info) {
                kfree(info->id);
                kfree(info->RegsBuf);
+               kfree(info->srb.sense_buffer);
        }
 }
 
@@ -1495,7 +1498,9 @@ static int isd200_init_info(struct us_data *us)
                                kzalloc(sizeof(struct hd_driveid), GFP_KERNEL);
                info->RegsBuf = (unsigned char *)
                                kmalloc(sizeof(info->ATARegs), GFP_KERNEL);
-               if (!info->id || !info->RegsBuf) {
+               info->srb.sense_buffer =
+                               kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
+               if (!info->id || !info->RegsBuf || !info->srb.sense_buffer) {
                        isd200_free_info_ptrs(info);
                        kfree(info);
                        retStatus = ISD200_ERROR;