aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/keucr
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/keucr')
-rw-r--r--drivers/staging/keucr/common.h8
-rw-r--r--drivers/staging/keucr/init.c131
-rw-r--r--drivers/staging/keucr/init.h9
-rw-r--r--drivers/staging/keucr/scsiglue.c75
-rw-r--r--drivers/staging/keucr/smcommon.h2
-rw-r--r--drivers/staging/keucr/smil.h151
-rw-r--r--drivers/staging/keucr/smilecc.c60
-rw-r--r--drivers/staging/keucr/smilmain.c2014
-rw-r--r--drivers/staging/keucr/smilsub.c234
-rw-r--r--drivers/staging/keucr/smscsi.c84
-rw-r--r--drivers/staging/keucr/transport.c54
-rw-r--r--drivers/staging/keucr/transport.h7
-rw-r--r--drivers/staging/keucr/usb.c256
-rw-r--r--drivers/staging/keucr/usb.h163
14 files changed, 1018 insertions, 2230 deletions
diff --git a/drivers/staging/keucr/common.h b/drivers/staging/keucr/common.h
index cf347ccd6a6..f0b977616cd 100644
--- a/drivers/staging/keucr/common.h
+++ b/drivers/staging/keucr/common.h
@@ -1,14 +1,6 @@
#ifndef COMMON_INCD
#define COMMON_INCD
-typedef u8 BOOLEAN;
-typedef u8 BYTE;
-typedef u8 *PBYTE;
-typedef u16 WORD;
-typedef u16 *PWORD;
-typedef u32 DWORD;
-typedef u32 *PDWORD;
-
#define BYTE_MASK 0xff
#endif
diff --git a/drivers/staging/keucr/init.c b/drivers/staging/keucr/init.c
index 231611dc0f7..1e7449d6d12 100644
--- a/drivers/staging/keucr/init.c
+++ b/drivers/staging/keucr/init.c
@@ -9,6 +9,7 @@
#include "usb.h"
#include "scsiglue.h"
#include "transport.h"
+#include "smil.h"
#include "init.h"
/*
@@ -17,15 +18,15 @@
int ENE_InitMedia(struct us_data *us)
{
int result;
- BYTE MiscReg03 = 0;
+ u8 MiscReg03 = 0;
- printk(KERN_INFO "--- Init Media ---\n");
- result = ENE_Read_BYTE(us, REG_CARD_STATUS, &MiscReg03);
+ dev_info(&us->pusb_dev->dev, "--- Init Media ---\n");
+ result = ene_read_byte(us, REG_CARD_STATUS, &MiscReg03);
if (result != USB_STOR_XFER_GOOD) {
- printk(KERN_ERR "Read register fail !!\n");
+ dev_err(&us->pusb_dev->dev, "Failed to read register\n");
return USB_STOR_TRANSPORT_ERROR;
}
- printk(KERN_INFO "MiscReg03 = %x\n", MiscReg03);
+ dev_info(&us->pusb_dev->dev, "MiscReg03 = %x\n", MiscReg03);
if (MiscReg03 & 0x02) {
if (!us->SM_Status.Ready && !us->MS_Status.Ready) {
@@ -39,9 +40,9 @@ int ENE_InitMedia(struct us_data *us)
}
/*
- * ENE_Read_BYTE() :
+ * ene_read_byte() :
*/
-int ENE_Read_BYTE(struct us_data *us, WORD index, void *buf)
+int ene_read_byte(struct us_data *us, u16 index, void *buf)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
@@ -51,8 +52,8 @@ int ENE_Read_BYTE(struct us_data *us, WORD index, void *buf)
bcb->DataTransferLength = 0x01;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xED;
- bcb->CDB[2] = (BYTE)(index>>8);
- bcb->CDB[3] = (BYTE)index;
+ bcb->CDB[2] = (u8)(index>>8);
+ bcb->CDB[3] = (u8)index;
result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
return result;
@@ -65,13 +66,15 @@ int ENE_SMInit(struct us_data *us)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
- BYTE buf[0x200];
+ u8 buf[0x200];
- printk(KERN_INFO "transport --- ENE_SMInit\n");
+ dev_dbg(&us->pusb_dev->dev, "transport --- ENE_SMInit\n");
result = ENE_LoadBinCode(us, SM_INIT_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
- printk(KERN_INFO "Load SM Init Code Fail !!\n");
+ dev_info(&us->pusb_dev->dev,
+ "Failed to load SmartMedia init code\n: result= %x\n",
+ result);
return USB_STOR_TRANSPORT_ERROR;
}
@@ -84,26 +87,33 @@ int ENE_SMInit(struct us_data *us)
result = ENE_SendScsiCmd(us, FDIR_READ, &buf, 0);
if (result != USB_STOR_XFER_GOOD) {
- printk(KERN_ERR
- "Execution SM Init Code Fail !! result = %x\n", result);
+ dev_err(&us->pusb_dev->dev,
+ "Failed to load SmartMedia init code: result = %x\n",
+ result);
return USB_STOR_TRANSPORT_ERROR;
}
- us->SM_Status = *(PSM_STATUS)&buf[0];
+ us->SM_Status = *(struct keucr_sm_status *)&buf[0];
us->SM_DeviceID = buf[1];
us->SM_CardID = buf[2];
if (us->SM_Status.Insert && us->SM_Status.Ready) {
- printk(KERN_INFO "Insert = %x\n", us->SM_Status.Insert);
- printk(KERN_INFO "Ready = %x\n", us->SM_Status.Ready);
- printk(KERN_INFO "WtP = %x\n", us->SM_Status.WtP);
- printk(KERN_INFO "DeviceID = %x\n", us->SM_DeviceID);
- printk(KERN_INFO "CardID = %x\n", us->SM_CardID);
+ dev_info(&us->pusb_dev->dev, "Insert = %x\n",
+ us->SM_Status.Insert);
+ dev_info(&us->pusb_dev->dev, "Ready = %x\n",
+ us->SM_Status.Ready);
+ dev_info(&us->pusb_dev->dev, "WtP = %x\n",
+ us->SM_Status.WtP);
+ dev_info(&us->pusb_dev->dev, "DeviceID = %x\n",
+ us->SM_DeviceID);
+ dev_info(&us->pusb_dev->dev, "CardID = %x\n",
+ us->SM_CardID);
MediaChange = 1;
Check_D_MediaFmt(us);
} else {
- printk(KERN_ERR "SM Card Not Ready --- %x\n", buf[0]);
+ dev_err(&us->pusb_dev->dev,
+ "SmartMedia Card Not Ready --- %x\n", buf[0]);
return USB_STOR_TRANSPORT_ERROR;
}
@@ -113,14 +123,14 @@ int ENE_SMInit(struct us_data *us)
/*
* ENE_LoadBinCode()
*/
-int ENE_LoadBinCode(struct us_data *us, BYTE flag)
+int ENE_LoadBinCode(struct us_data *us, u8 flag)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
/* void *buf; */
- PBYTE buf;
+ u8 *buf;
- /* printk(KERN_INFO "transport --- ENE_LoadBinCode\n"); */
+ /* dev_info(&us->pusb_dev->dev, "transport --- ENE_LoadBinCode\n"); */
if (us->BIN_FLAG == flag)
return USB_STOR_TRANSPORT_GOOD;
@@ -130,11 +140,11 @@ int ENE_LoadBinCode(struct us_data *us, BYTE flag)
switch (flag) {
/* For SS */
case SM_INIT_PATTERN:
- printk(KERN_INFO "SM_INIT_PATTERN\n");
+ dev_dbg(&us->pusb_dev->dev, "SM_INIT_PATTERN\n");
memcpy(buf, SM_Init, 0x800);
break;
case SM_RW_PATTERN:
- printk(KERN_INFO "SM_RW_PATTERN\n");
+ dev_dbg(&us->pusb_dev->dev, "SM_RW_PATTERN\n");
memcpy(buf, SM_Rdwr, 0x800);
break;
}
@@ -155,7 +165,7 @@ int ENE_LoadBinCode(struct us_data *us, BYTE flag)
/*
* ENE_SendScsiCmd():
*/
-int ENE_SendScsiCmd(struct us_data *us, BYTE fDir, void *buf, int use_sg)
+int ENE_SendScsiCmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
@@ -165,12 +175,13 @@ int ENE_SendScsiCmd(struct us_data *us, BYTE fDir, void *buf, int use_sg)
cswlen = 0, partial = 0;
unsigned int residue;
- /* printk(KERN_INFO "transport --- ENE_SendScsiCmd\n"); */
+ /* dev_dbg(&us->pusb_dev->dev, "transport --- ENE_SendScsiCmd\n"); */
/* send cmd to out endpoint */
result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
bcb, US_BULK_CB_WRAP_LEN, NULL);
if (result != USB_STOR_XFER_GOOD) {
- printk(KERN_ERR "send cmd to out endpoint fail ---\n");
+ dev_err(&us->pusb_dev->dev,
+ "send cmd to out endpoint fail ---\n");
return USB_STOR_TRANSPORT_ERROR;
}
@@ -189,7 +200,7 @@ int ENE_SendScsiCmd(struct us_data *us, BYTE fDir, void *buf, int use_sg)
result = usb_stor_bulk_transfer_sg(us, pipe, buf,
transfer_length, 0, &partial);
if (result != USB_STOR_XFER_GOOD) {
- printk(KERN_ERR "data transfer fail ---\n");
+ dev_err(&us->pusb_dev->dev, "data transfer fail ---\n");
return USB_STOR_TRANSPORT_ERROR;
}
}
@@ -199,14 +210,16 @@ int ENE_SendScsiCmd(struct us_data *us, BYTE fDir, void *buf, int use_sg)
US_BULK_CS_WRAP_LEN, &cswlen);
if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
- printk(KERN_WARNING "Received 0-length CSW; retrying...\n");
+ dev_warn(&us->pusb_dev->dev,
+ "Received 0-length CSW; retrying...\n");
result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
bcs, US_BULK_CS_WRAP_LEN, &cswlen);
}
if (result == USB_STOR_XFER_STALLED) {
/* get the status again */
- printk(KERN_WARNING "Attempting to get CSW (2nd try)...\n");
+ dev_warn(&us->pusb_dev->dev,
+ "Attempting to get CSW (2nd try)...\n");
result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
bcs, US_BULK_CS_WRAP_LEN, NULL);
}
@@ -243,7 +256,7 @@ int ENE_Read_Data(struct us_data *us, void *buf, unsigned int length)
struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
int result;
- /* printk(KERN_INFO "transport --- ENE_Read_Data\n"); */
+ /* dev_dbg(&us->pusb_dev->dev, "transport --- ENE_Read_Data\n"); */
/* set up the command wrapper */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
@@ -318,55 +331,3 @@ int ENE_Write_Data(struct us_data *us, void *buf, unsigned int length)
return USB_STOR_TRANSPORT_GOOD;
}
-/*
- * usb_stor_print_cmd():
- */
-void usb_stor_print_cmd(struct scsi_cmnd *srb)
-{
- PBYTE Cdb = srb->cmnd;
- DWORD cmd = Cdb[0];
- DWORD bn = ((Cdb[2] << 24) & 0xff000000) |
- ((Cdb[3] << 16) & 0x00ff0000) |
- ((Cdb[4] << 8) & 0x0000ff00) |
- ((Cdb[5] << 0) & 0x000000ff);
- WORD blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
-
- switch (cmd) {
- case TEST_UNIT_READY:
- /* printk(KERN_INFO
- "scsi cmd %X --- SCSIOP_TEST_UNIT_READY\n", cmd); */
- break;
- case INQUIRY:
- printk(KERN_INFO "scsi cmd %X --- SCSIOP_INQUIRY\n", cmd);
- break;
- case MODE_SENSE:
- printk(KERN_INFO "scsi cmd %X --- SCSIOP_MODE_SENSE\n", cmd);
- break;
- case START_STOP:
- printk(KERN_INFO "scsi cmd %X --- SCSIOP_START_STOP\n", cmd);
- break;
- case READ_CAPACITY:
- printk(KERN_INFO "scsi cmd %X --- SCSIOP_READ_CAPACITY\n", cmd);
- break;
- case READ_10:
- /* printk(KERN_INFO
- "scsi cmd %X --- SCSIOP_READ,bn = %X, blen = %X\n"
- ,cmd, bn, blen); */
- break;
- case WRITE_10:
- /* printk(KERN_INFO
- "scsi cmd %X --- SCSIOP_WRITE,
- bn = %X, blen = %X\n" , cmd, bn, blen); */
- break;
- case ALLOW_MEDIUM_REMOVAL:
- printk(KERN_INFO
- "scsi cmd %X --- SCSIOP_ALLOW_MEDIUM_REMOVAL\n", cmd);
- break;
- default:
- printk(KERN_INFO "scsi cmd %X --- Other cmd\n", cmd);
- break;
- }
- bn = 0;
- blen = 0;
-}
-
diff --git a/drivers/staging/keucr/init.h b/drivers/staging/keucr/init.h
index c8b2cd60446..d1367e726ff 100644
--- a/drivers/staging/keucr/init.h
+++ b/drivers/staging/keucr/init.h
@@ -1,11 +1,6 @@
#include "common.h"
-extern DWORD MediaChange;
-extern int Check_D_MediaFmt(struct us_data *);
-
-
-
-static BYTE SM_Init[] = {
+static u8 SM_Init[] = {
0x7B, 0x09, 0x7C, 0xF0, 0x7D, 0x10, 0x7E, 0xE9,
0x7F, 0xCC, 0x12, 0x2F, 0x71, 0x90, 0xE9, 0xCC,
0xE0, 0xB4, 0x07, 0x12, 0x90, 0xFF, 0x09, 0xE0,
@@ -263,7 +258,7 @@ static BYTE SM_Init[] = {
0x58, 0x44, 0x2D, 0x49, 0x6E, 0x69, 0x74, 0x20,
0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x31 };
-static BYTE SM_Rdwr[] = {
+static u8 SM_Rdwr[] = {
0x7B, 0x0C, 0x7C, 0xF0, 0x7D, 0x10, 0x7E, 0xE9,
0x7F, 0xCC, 0x12, 0x2F, 0x71, 0x90, 0xE9, 0xC3,
0xE0, 0xB4, 0x73, 0x04, 0x74, 0x40, 0x80, 0x09,
diff --git a/drivers/staging/keucr/scsiglue.c b/drivers/staging/keucr/scsiglue.c
index 083b20e6253..7d8d444910c 100644
--- a/drivers/staging/keucr/scsiglue.c
+++ b/drivers/staging/keucr/scsiglue.c
@@ -73,7 +73,8 @@ static int slave_configure(struct scsi_device *sdev)
if (us->fflags & US_FL_CAPACITY_HEURISTICS)
sdev->guess_capacity = 1;
if (sdev->scsi_level > SCSI_2)
- sdev->sdev_target->scsi_level = sdev->scsi_level = SCSI_2;
+ sdev->sdev_target->scsi_level = sdev->scsi_level
+ = SCSI_2;
sdev->retry_hwerror = 1;
sdev->allow_restart = 1;
sdev->last_sector_bug = 1;
@@ -105,7 +106,7 @@ static int queuecommand_lck(struct scsi_cmnd *srb,
/* check for state-transition errors */
if (us->srb != NULL) {
/* pr_info("Error in %s: us->srb = %p\n"
- __FUNCTION__, us->srb); */
+ __func__, us->srb); */
return SCSI_MLQUEUE_HOST_BUSY;
}
@@ -144,7 +145,7 @@ static int command_abort(struct scsi_cmnd *srb)
scsi_lock(us_to_host(us));
if (us->srb != srb) {
scsi_unlock(us_to_host(us));
- printk("-- nothing to abort\n");
+ dev_info(&us->pusb_dev->dev, "-- nothing to abort\n");
return FAILED;
}
@@ -229,26 +230,18 @@ void usb_stor_report_bus_reset(struct us_data *us)
/* we use this macro to help us write into the buffer */
#undef SPRINTF
-#define SPRINTF(args...) \
- do { \
- if (pos < buffer+length) \
- pos += sprintf(pos, ## args); \
- } while (0)
+#define SPRINTF(args...) seq_printf(m, ##args)
-/*
- * proc_info()
- */
-static int proc_info(struct Scsi_Host *host, char *buffer, char **start,
- off_t offset, int length, int inout)
+static int write_info(struct Scsi_Host *host, char *buffer, int length)
+{
+ return length;
+}
+
+static int show_info(struct seq_file *m, struct Scsi_Host *host)
{
struct us_data *us = host_to_us(host);
- char *pos = buffer;
const char *string;
- /* pr_info("scsiglue --- proc_info\n"); */
- if (inout)
- return length;
-
/* print the controller name */
SPRINTF(" Host scsi%d: usb-storage\n", host->host_no);
@@ -278,29 +271,17 @@ static int proc_info(struct Scsi_Host *host, char *buffer, char **start,
SPRINTF(" Transport: %s\n", us->transport_name);
/* show the device flags */
- if (pos < buffer + length) {
- pos += sprintf(pos, " Quirks:");
+ SPRINTF(" Quirks:");
#define US_FLAG(name, value) \
do { \
if (us->fflags & value) \
- pos += sprintf(pos, " " #name); \
+ SPRINTF(" " #name); \
} while (0);
US_DO_ALL_FLAGS
#undef US_FLAG
-
- *(pos++) = '\n';
- }
-
- /* Calculate start of next buffer, and return value. */
- *start = buffer + offset;
-
- if ((pos - buffer) < offset)
- return 0;
- else if ((pos - buffer - offset) < length)
- return pos - buffer - offset;
- else
- return length;
+ seq_putc(m, '\n');
+ return 0;
}
/***********************************************************************
@@ -308,10 +289,7 @@ US_DO_ALL_FLAGS
***********************************************************************/
/* Output routine for the sysfs max_sectors file */
-/*
- * show_max_sectors()
- */
-static ssize_t show_max_sectors(struct device *dev,
+static ssize_t max_sectors_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);
@@ -321,10 +299,7 @@ static ssize_t show_max_sectors(struct device *dev,
}
/* Input routine for the sysfs max_sectors file */
-/*
- * store_max_sectors()
- */
-static ssize_t store_max_sectors(struct device *dev,
+static ssize_t max_sectors_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -338,9 +313,11 @@ static ssize_t store_max_sectors(struct device *dev,
}
return -EINVAL;
}
+static DEVICE_ATTR_RW(max_sectors);
-static DEVICE_ATTR(max_sectors, S_IRUGO | S_IWUSR, show_max_sectors, store_max_sectors);
-static struct device_attribute *sysfs_device_attr_list[] = {&dev_attr_max_sectors, NULL, };
+static struct device_attribute *sysfs_device_attr_list[] = {
+ &dev_attr_max_sectors, NULL,
+};
/* this defines our host template, with which we'll allocate hosts */
@@ -351,7 +328,8 @@ struct scsi_host_template usb_stor_host_template = {
/* basic userland interface stuff */
.name = "eucr-storage",
.proc_name = "eucr-storage",
- .proc_info = proc_info,
+ .write_info = write_info,
+ .show_info = show_info,
.info = host_info,
/* command interface -- queued only */
@@ -412,8 +390,9 @@ unsigned char usb_stor_sense_invalidCDB[18] = {
/*
* usb_stor_access_xfer_buf()
*/
-unsigned int usb_stor_access_xfer_buf(struct us_data *us, unsigned char *buffer,
- unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **sgptr,
+unsigned int usb_stor_access_xfer_buf(struct us_data *us,
+ unsigned char *buffer, unsigned int buflen,
+ struct scsi_cmnd *srb, struct scatterlist **sgptr,
unsigned int *offset, enum xfer_buf_dir dir)
{
unsigned int cnt;
@@ -443,7 +422,7 @@ unsigned int usb_stor_access_xfer_buf(struct us_data *us, unsigned char *buffer,
while (sglen > 0) {
unsigned int plen = min(sglen,
- (unsigned int)PAGE_SIZE - poff);
+ (unsigned int)PAGE_SIZE - poff);
unsigned char *ptr = kmap(page);
if (dir == TO_XFER_BUF)
diff --git a/drivers/staging/keucr/smcommon.h b/drivers/staging/keucr/smcommon.h
index 4d57203b64d..1d2752a1d5c 100644
--- a/drivers/staging/keucr/smcommon.h
+++ b/drivers/staging/keucr/smcommon.h
@@ -4,7 +4,7 @@
/***************************************************************************
-Define Difinetion
+Define Definition
***************************************************************************/
#define SMSUCCESS 0x0000 /* SUCCESS */
#define ERROR 0xFFFF /* ERROR */
diff --git a/drivers/staging/keucr/smil.h b/drivers/staging/keucr/smil.h
index 24a636a4aa1..f938759337e 100644
--- a/drivers/staging/keucr/smil.h
+++ b/drivers/staging/keucr/smil.h
@@ -45,7 +45,7 @@ Retry Counter Definition
Hardware ECC Definition
***************************************************************************/
#define HW_ECC_SUPPORTED 1 /* Hardware ECC Supported */
-/* No difinition for Software ECC */
+/* No definition for Software ECC */
/***************************************************************************
SmartMedia Command & Status Definition
@@ -168,56 +168,34 @@ SmartMedia Model & Attribute
/***************************************************************************
Struct Definition
***************************************************************************/
-struct SSFDCTYPE {
- BYTE Model;
- BYTE Attribute;
- BYTE MaxZones;
- BYTE MaxSectors;
- WORD MaxBlocks;
- WORD MaxLogBlocks;
+struct keucr_media_info {
+ u8 Model;
+ u8 Attribute;
+ u8 MaxZones;
+ u8 MaxSectors;
+ u16 MaxBlocks;
+ u16 MaxLogBlocks;
};
-typedef struct SSFDCTYPE_T {
- BYTE Model;
- BYTE Attribute;
- BYTE MaxZones;
- BYTE MaxSectors;
- WORD MaxBlocks;
- WORD MaxLogBlocks;
-} *SSFDCTYPE_T;
-
-struct ADDRESS {
- BYTE Zone; /* Zone Number */
- BYTE Sector; /* Sector(512byte) Number on Block */
- WORD PhyBlock; /* Physical Block Number on Zone */
- WORD LogBlock; /* Logical Block Number of Zone */
+struct keucr_media_address {
+ u8 Zone; /* Zone Number */
+ u8 Sector; /* Sector(512byte) Number on Block */
+ u16 PhyBlock; /* Physical Block Number on Zone */
+ u16 LogBlock; /* Logical Block Number of Zone */
};
-typedef struct ADDRESS_T {
- BYTE Zone; /* Zone Number */
- BYTE Sector; /* Sector(512byte) Number on Block */
- WORD PhyBlock; /* Physical Block Number on Zone */
- WORD LogBlock; /* Logical Block Number of Zone */
-} *ADDRESS_T;
-
-struct CIS_AREA {
- BYTE Sector; /* Sector(512byte) Number on Block */
- WORD PhyBlock; /* Physical Block Number on Zone 0 */
+struct keucr_media_area {
+ u8 Sector; /* Sector(512byte) Number on Block */
+ u16 PhyBlock; /* Physical Block Number on Zone 0 */
};
+extern u16 ReadBlock;
+extern u16 WriteBlock;
+extern u32 MediaChange;
-extern BYTE IsSSFDCCompliance;
-extern BYTE IsXDCompliance;
-
-extern DWORD ErrXDCode;
-extern DWORD ErrCode;
-extern WORD ReadBlock;
-extern WORD WriteBlock;
-extern DWORD MediaChange;
-
-extern struct SSFDCTYPE Ssfdc;
-extern struct ADDRESS Media;
-extern struct CIS_AREA CisArea;
+extern struct keucr_media_info Ssfdc;
+extern struct keucr_media_address Media;
+extern struct keucr_media_area CisArea;
/*
* SMILMain.c
@@ -226,24 +204,25 @@ extern struct CIS_AREA CisArea;
int Init_D_SmartMedia(void);
int Pwoff_D_SmartMedia(void);
int Check_D_SmartMedia(void);
-int Check_D_Parameter(struct us_data *, WORD *, BYTE *, BYTE *);
-int Media_D_ReadSector(struct us_data *, DWORD, WORD, BYTE *);
-int Media_D_WriteSector(struct us_data *, DWORD, WORD, BYTE *);
-int Media_D_CopySector(struct us_data *, DWORD, WORD, BYTE *);
-int Media_D_EraseBlock(struct us_data *, DWORD, WORD);
+int Check_D_MediaFmt(struct us_data *);
+int Check_D_Parameter(struct us_data *, u16 *, u8 *, u8 *);
+int Media_D_ReadSector(struct us_data *, u32, u16, u8 *);
+int Media_D_WriteSector(struct us_data *, u32, u16, u8 *);
+int Media_D_CopySector(struct us_data *, u32, u16, u8 *);
+int Media_D_EraseBlock(struct us_data *, u32, u16);
int Media_D_EraseAll(struct us_data *);
/******************************************/
-int Media_D_OneSectWriteStart(struct us_data *, DWORD, BYTE *);
-int Media_D_OneSectWriteNext(struct us_data *, BYTE *);
+int Media_D_OneSectWriteStart(struct us_data *, u32, u8 *);
+int Media_D_OneSectWriteNext(struct us_data *, u8 *);
int Media_D_OneSectWriteFlush(struct us_data *);
/******************************************/
extern int SM_FreeMem(void); /* ENE SM function */
-void SM_EnableLED(struct us_data *, BOOLEAN);
+void SM_EnableLED(struct us_data *, bool);
void Led_D_TernOn(void);
void Led_D_TernOff(void);
-int Media_D_EraseAllRedtData(DWORD Index, BOOLEAN CheckBlock);
+int Media_D_EraseAllRedtData(u32 Index, bool CheckBlock);
/*DWORD Media_D_GetMediaInfo(struct us_data * fdoExt,
PIOCTL_MEDIA_INFO_IN pParamIn, PIOCTL_MEDIA_INFO_OUT pParamOut); */
@@ -251,31 +230,31 @@ int Media_D_EraseAllRedtData(DWORD Index, BOOLEAN CheckBlock);
* SMILSub.c
*/
/******************************************/
-int Check_D_DataBlank(BYTE *);
-int Check_D_FailBlock(BYTE *);
-int Check_D_DataStatus(BYTE *);
-int Load_D_LogBlockAddr(BYTE *);
-void Clr_D_RedundantData(BYTE *);
-void Set_D_LogBlockAddr(BYTE *);
-void Set_D_FailBlock(BYTE *);
-void Set_D_DataStaus(BYTE *);
+int Check_D_DataBlank(u8 *);
+int Check_D_FailBlock(u8 *);
+int Check_D_DataStatus(u8 *);
+int Load_D_LogBlockAddr(u8 *);
+void Clr_D_RedundantData(u8 *);
+void Set_D_LogBlockAddr(u8 *);
+void Set_D_FailBlock(u8 *);
+void Set_D_DataStaus(u8 *);
/******************************************/
void Ssfdc_D_Reset(struct us_data *);
-int Ssfdc_D_ReadCisSect(struct us_data *, BYTE *, BYTE *);
+int Ssfdc_D_ReadCisSect(struct us_data *, u8 *, u8 *);
void Ssfdc_D_WriteRedtMode(void);
-void Ssfdc_D_ReadID(BYTE *, BYTE);
-int Ssfdc_D_ReadSect(struct us_data *, BYTE *, BYTE *);
-int Ssfdc_D_ReadBlock(struct us_data *, WORD, BYTE *, BYTE *);
-int Ssfdc_D_WriteSect(struct us_data *, BYTE *, BYTE *);
-int Ssfdc_D_WriteBlock(struct us_data *, WORD, BYTE *, BYTE *);
-int Ssfdc_D_CopyBlock(struct us_data *, WORD, BYTE *, BYTE *);
-int Ssfdc_D_WriteSectForCopy(struct us_data *, BYTE *, BYTE *);
+void Ssfdc_D_ReadID(u8 *, u8);
+int Ssfdc_D_ReadSect(struct us_data *, u8 *, u8 *);
+int Ssfdc_D_ReadBlock(struct us_data *, u16, u8 *, u8 *);
+int Ssfdc_D_WriteSect(struct us_data *, u8 *, u8 *);
+int Ssfdc_D_WriteBlock(struct us_data *, u16, u8 *, u8 *);
+int Ssfdc_D_CopyBlock(struct us_data *, u16, u8 *, u8 *);
+int Ssfdc_D_WriteSectForCopy(struct us_data *, u8 *, u8 *);
int Ssfdc_D_EraseBlock(struct us_data *);
-int Ssfdc_D_ReadRedtData(struct us_data *, BYTE *);
-int Ssfdc_D_WriteRedtData(struct us_data *, BYTE *);
+int Ssfdc_D_ReadRedtData(struct us_data *, u8 *);
+int Ssfdc_D_WriteRedtData(struct us_data *, u8 *);
int Ssfdc_D_CheckStatus(void);
-int Set_D_SsfdcModel(BYTE);
+int Set_D_SsfdcModel(u8);
void Cnt_D_Reset(void);
int Cnt_D_PowerOn(void);
void Cnt_D_PowerOff(void);
@@ -285,27 +264,25 @@ int Check_D_CntPower(void);
int Check_D_CardExist(void);
int Check_D_CardStsChg(void);
int Check_D_SsfdcWP(void);
-int SM_ReadBlock(struct us_data *, BYTE *, BYTE *);
+int SM_ReadBlock(struct us_data *, u8 *, u8 *);
-int Ssfdc_D_ReadSect_DMA(struct us_data *, BYTE *, BYTE *);
-int Ssfdc_D_ReadSect_PIO(struct us_data *, BYTE *, BYTE *);
-int Ssfdc_D_WriteSect_DMA(struct us_data *, BYTE *, BYTE *);
-int Ssfdc_D_WriteSect_PIO(struct us_data *, BYTE *, BYTE *);
+int Ssfdc_D_ReadSect_DMA(struct us_data *, u8 *, u8 *);
+int Ssfdc_D_ReadSect_PIO(struct us_data *, u8 *, u8 *);
+int Ssfdc_D_WriteSect_DMA(struct us_data *, u8 *, u8 *);
+int Ssfdc_D_WriteSect_PIO(struct us_data *, u8 *, u8 *);
/******************************************/
-int Check_D_ReadError(BYTE *);
-int Check_D_Correct(BYTE *, BYTE *);
-int Check_D_CISdata(BYTE *, BYTE *);
-void Set_D_RightECC(BYTE *);
+int Check_D_ReadError(u8 *);
+int Check_D_Correct(u8 *, u8 *);
+int Check_D_CISdata(u8 *, u8 *);
+void Set_D_RightECC(u8 *);
/*
* SMILECC.c
*/
-void calculate_ecc(BYTE *, BYTE *, BYTE *, BYTE *, BYTE *);
-BYTE correct_data(BYTE *, BYTE *, BYTE, BYTE, BYTE);
-int _Correct_D_SwECC(BYTE *, BYTE *, BYTE *);
-void _Calculate_D_SwECC(BYTE *, BYTE *);
-
-void SM_Init(void);
+void calculate_ecc(u8 *, u8 *, u8 *, u8 *, u8 *);
+u8 correct_data(u8 *, u8 *, u8, u8, u8);
+int _Correct_D_SwECC(u8 *, u8 *, u8 *);
+void _Calculate_D_SwECC(u8 *, u8 *);
#endif /* already included */
diff --git a/drivers/staging/keucr/smilecc.c b/drivers/staging/keucr/smilecc.c
index 3085f1d4a4e..ffe6030f5e4 100644
--- a/drivers/staging/keucr/smilecc.c
+++ b/drivers/staging/keucr/smilecc.c
@@ -13,7 +13,7 @@
/* #include "EMCRIOS.h" */
/* CP0-CP5 code table */
-static BYTE ecctable[256] = {
+static u8 ecctable[256] = {
0x00, 0x55, 0x56, 0x03, 0x59, 0x0C, 0x0F, 0x5A, 0x5A, 0x0F, 0x0C, 0x59, 0x03,
0x56, 0x55, 0x00, 0x65, 0x30, 0x33, 0x66, 0x3C, 0x69, 0x6A, 0x3F, 0x3F, 0x6A,
0x69, 0x3C, 0x66, 0x33, 0x30, 0x65, 0x66, 0x33, 0x30, 0x65, 0x3F, 0x6A, 0x69,
@@ -36,7 +36,7 @@ static BYTE ecctable[256] = {
0x5A, 0x5A, 0x0F, 0x0C, 0x59, 0x03, 0x56, 0x55, 0x00
};
-static void trans_result(BYTE, BYTE, BYTE *, BYTE *);
+static void trans_result(u8, u8, u8 *, u8 *);
#define BIT7 0x80
#define BIT6 0x40
@@ -57,11 +57,11 @@ static void trans_result(BYTE, BYTE, BYTE *, BYTE *);
* *ecc1; * LP15,LP14,LP13,...
* *ecc2; * LP07,LP06,LP05,...
*/
-static void trans_result(BYTE reg2, BYTE reg3, BYTE *ecc1, BYTE *ecc2)
+static void trans_result(u8 reg2, u8 reg3, u8 *ecc1, u8 *ecc2)
{
- BYTE a; /* Working for reg2,reg3 */
- BYTE b; /* Working for ecc1,ecc2 */
- BYTE i; /* For counting */
+ u8 a; /* Working for reg2,reg3 */
+ u8 b; /* Working for ecc1,ecc2 */
+ u8 i; /* For counting */
a = BIT7; b = BIT7; /* 80h=10000000b */
*ecc1 = *ecc2 = 0; /* Clear ecc1,ecc2 */
@@ -95,21 +95,21 @@ static void trans_result(BYTE reg2, BYTE reg3, BYTE *ecc1, BYTE *ecc2)
* *ecc2; * LP07,LP06,LP05,...
* *ecc3; * CP5,CP4,CP3,...,"1","1"
*/
-void calculate_ecc(BYTE *table, BYTE *data, BYTE *ecc1, BYTE *ecc2, BYTE *ecc3)
+void calculate_ecc(u8 *table, u8 *data, u8 *ecc1, u8 *ecc2, u8 *ecc3)
{
- DWORD i; /* For counting */
- BYTE a; /* Working for table */
- BYTE reg1; /* D-all,CP5,CP4,CP3,... */
- BYTE reg2; /* LP14,LP12,L10,... */
- BYTE reg3; /* LP15,LP13,L11,... */
+ u32 i; /* For counting */
+ u8 a; /* Working for table */
+ u8 reg1; /* D-all,CP5,CP4,CP3,... */
+ u8 reg2; /* LP14,LP12,L10,... */
+ u8 reg3; /* LP15,LP13,L11,... */
reg1 = reg2 = reg3 = 0; /* Clear parameter */
for (i = 0; i < 256; ++i) {
a = table[data[i]]; /* Get CP0-CP5 code from table */
reg1 ^= (a&MASK_CPS); /* XOR with a */
if ((a&BIT6) != 0) { /* If D_all(all bit XOR) = 1 */
- reg3 ^= (BYTE)i; /* XOR with counter */
- reg2 ^= ~((BYTE)i); /* XOR with inv. of counter */
+ reg3 ^= (u8)i; /* XOR with counter */
+ reg2 ^= ~((u8)i); /* XOR with inv. of counter */
}
}
@@ -127,22 +127,22 @@ void calculate_ecc(BYTE *table, BYTE *data, BYTE *ecc1, BYTE *ecc2, BYTE *ecc3)
* ecc2; * LP07,LP06,LP05,...
* ecc3; * CP5,CP4,CP3,...,"1","1"
*/
-BYTE correct_data(BYTE *data, BYTE *eccdata, BYTE ecc1, BYTE ecc2, BYTE ecc3)
+u8 correct_data(u8 *data, u8 *eccdata, u8 ecc1, u8 ecc2, u8 ecc3)
{
- DWORD l; /* Working to check d */
- DWORD d; /* Result of comparison */
- DWORD i; /* For counting */
- BYTE d1, d2, d3; /* Result of comparison */
- BYTE a; /* Working for add */
- BYTE add; /* Byte address of cor. DATA */
- BYTE b; /* Working for bit */
- BYTE bit; /* Bit address of cor. DATA */
+ u32 l; /* Working to check d */
+ u32 d; /* Result of comparison */
+ u32 i; /* For counting */
+ u8 d1, d2, d3; /* Result of comparison */
+ u8 a; /* Working for add */
+ u8 add; /* Byte address of cor. DATA */
+ u8 b; /* Working for bit */
+ u8 bit; /* Bit address of cor. DATA */
d1 = ecc1^eccdata[1]; d2 = ecc2^eccdata[0]; /* Compare LP's */
- d3 = ecc3^eccdata[2]; /* Comapre CP's */
- d = ((DWORD)d1<<16) /* Result of comparison */
- +((DWORD)d2<<8)
- +(DWORD)d3;
+ d3 = ecc3^eccdata[2]; /* Compare CP's */
+ d = ((u32)d1<<16) /* Result of comparison */
+ +((u32)d2<<8)
+ +(u32)d3;
if (d == 0)
return 0; /* If No error, return */
@@ -188,9 +188,9 @@ BYTE correct_data(BYTE *data, BYTE *eccdata, BYTE ecc1, BYTE ecc2, BYTE ecc3)
return 3; /* Uncorrectable error */
}
-int _Correct_D_SwECC(BYTE *buf, BYTE *redundant_ecc, BYTE *calculate_ecc)
+int _Correct_D_SwECC(u8 *buf, u8 *redundant_ecc, u8 *calculate_ecc)
{
- DWORD err;
+ u32 err;
err = correct_data(buf, redundant_ecc, *(calculate_ecc + 1),
*(calculate_ecc), *(calculate_ecc + 2));
@@ -203,7 +203,7 @@ int _Correct_D_SwECC(BYTE *buf, BYTE *redundant_ecc, BYTE *calculate_ecc)
return -1;
}
-void _Calculate_D_SwECC(BYTE *buf, BYTE *ecc)
+void _Calculate_D_SwECC(u8 *buf, u8 *ecc)
{
calculate_ecc(ecctable, buf, ecc+1, ecc+0, ecc+2);
}
diff --git a/drivers/staging/keucr/smilmain.c b/drivers/staging/keucr/smilmain.c
index cc49038e55d..42ec8a669ad 100644
--- a/drivers/staging/keucr/smilmain.c
+++ b/drivers/staging/keucr/smilmain.c
@@ -4,204 +4,110 @@
#include "smcommon.h"
#include "smil.h"
-int Check_D_LogCHS (WORD *,BYTE *,BYTE *);
-void Initialize_D_Media (void);
-void PowerOff_D_Media (void);
-int Check_D_MediaPower (void);
-int Check_D_MediaExist (void);
-int Check_D_MediaWP (void);
-int Check_D_MediaFmt (struct us_data *);
-int Check_D_MediaFmtForEraseAll (struct us_data *);
-int Conv_D_MediaAddr (struct us_data *, DWORD);
-int Inc_D_MediaAddr (struct us_data *);
-int Check_D_FirstSect (void);
-int Check_D_LastSect (void);
-int Media_D_ReadOneSect (struct us_data *, WORD, BYTE *);
-int Media_D_WriteOneSect (struct us_data *, WORD, BYTE *);
-int Media_D_CopyBlockHead (struct us_data *);
-int Media_D_CopyBlockTail (struct us_data *);
-int Media_D_EraseOneBlock (void);
-int Media_D_EraseAllBlock (void);
-
-int Copy_D_BlockAll (struct us_data *, DWORD);
-int Copy_D_BlockHead (struct us_data *);
-int Copy_D_BlockTail (struct us_data *);
-int Reassign_D_BlockHead (struct us_data *);
-
-int Assign_D_WriteBlock (void);
-int Release_D_ReadBlock (struct us_data *);
-int Release_D_WriteBlock (struct us_data *);
-int Release_D_CopySector (struct us_data *);
-
-int Copy_D_PhyOneSect (struct us_data *);
-int Read_D_PhyOneSect (struct us_data *, WORD, BYTE *);
-int Write_D_PhyOneSect (struct us_data *, WORD, BYTE *);
-int Erase_D_PhyOneBlock (struct us_data *);
-
-int Set_D_PhyFmtValue (struct us_data *);
-int Search_D_CIS (struct us_data *);
-int Make_D_LogTable (struct us_data *);
-void Check_D_BlockIsFull (void);
-
-int MarkFail_D_PhyOneBlock (struct us_data *);
-
-DWORD ErrXDCode;
-DWORD ErrCode;
-//BYTE SectBuf[SECTSIZE];
-static BYTE WorkBuf[SECTSIZE];
-static BYTE Redundant[REDTSIZE];
-static BYTE WorkRedund[REDTSIZE];
-//WORD Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
-static WORD *Log2Phy[MAX_ZONENUM]; // 128 x 1000, Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
-static BYTE Assign[MAX_ZONENUM][MAX_BLOCKNUM/8];
-static WORD AssignStart[MAX_ZONENUM];
-WORD ReadBlock;
-WORD WriteBlock;
-DWORD MediaChange;
-static DWORD SectCopyMode;
-
-//BIT Control Macro
-static BYTE BitData[] = { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 } ;
-#define Set_D_Bit(a,b) (a[(BYTE)((b)/8)]|= BitData[(b)%8])
-#define Clr_D_Bit(a,b) (a[(BYTE)((b)/8)]&=~BitData[(b)%8])
-#define Chk_D_Bit(a,b) (a[(BYTE)((b)/8)] & BitData[(b)%8])
-
-//extern PBYTE SMHostAddr;
-BYTE IsSSFDCCompliance;
-BYTE IsXDCompliance;
-
-
-//
-////Power Control & Media Exist Check Function
-////----- Init_D_SmartMedia() --------------------------------------------
-//int Init_D_SmartMedia(void)
-//{
-// int i;
-//
-// EMCR_Print("Init_D_SmartMedia start\n");
-// for (i=0; i<MAX_ZONENUM; i++)
-// {
-// if (Log2Phy[i]!=NULL)
-// {
-// EMCR_Print("ExFreePool Zone = %x, Addr = %x\n", i, Log2Phy[i]);
-// ExFreePool(Log2Phy[i]);
-// Log2Phy[i] = NULL;
-// }
-// }
-//
-// Initialize_D_Media();
-// return(NO_ERROR);
-//}
-
-//----- SM_FreeMem() -------------------------------------------------
+static int Conv_D_MediaAddr(struct us_data *, u32);
+static int Inc_D_MediaAddr(struct us_data *);
+static int Media_D_ReadOneSect(struct us_data *, u16, u8 *);
+
+static int Copy_D_BlockAll(struct us_data *, u32);
+
+static int Assign_D_WriteBlock(void);
+static int Release_D_ReadBlock(struct us_data *);
+static int Release_D_WriteBlock(struct us_data *);
+static int Release_D_CopySector(struct us_data *);
+
+static int Copy_D_PhyOneSect(struct us_data *);
+static int Read_D_PhyOneSect(struct us_data *, u16, u8 *);
+static int Erase_D_PhyOneBlock(struct us_data *);
+
+static int Set_D_PhyFmtValue(struct us_data *);
+static int Search_D_CIS(struct us_data *);
+static int Make_D_LogTable(struct us_data *);
+
+static int MarkFail_D_PhyOneBlock(struct us_data *);
+
+static u32 ErrCode;
+static u8 WorkBuf[SECTSIZE];
+static u8 Redundant[REDTSIZE];
+static u8 WorkRedund[REDTSIZE];
+/* 128 x 1000, Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK]; */
+static u16 *Log2Phy[MAX_ZONENUM];
+static u8 Assign[MAX_ZONENUM][MAX_BLOCKNUM / 8];
+static u16 AssignStart[MAX_ZONENUM];
+u16 ReadBlock;
+u16 WriteBlock;
+u32 MediaChange;
+static u32 SectCopyMode;
+
+/* BIT Control Macro */
+static u8 BitData[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
+#define Set_D_Bit(a, b) (a[(u8)((b) / 8)] |= BitData[(b) % 8])
+#define Clr_D_Bit(a, b) (a[(u8)((b) / 8)] &= ~BitData[(b) % 8])
+#define Chk_D_Bit(a, b) (a[(u8)((b) / 8)] & BitData[(b) % 8])
+
+/* ----- SM_FreeMem() ------------------------------------------------- */
int SM_FreeMem(void)
{
int i;
pr_info("SM_FreeMem start\n");
- for (i=0; i<MAX_ZONENUM; i++)
- {
- if (Log2Phy[i]!=NULL)
- {
+ for (i = 0; i < MAX_ZONENUM; i++) {
+ if (Log2Phy[i] != NULL) {
pr_info("Free Zone = %x, Addr = %p\n", i, Log2Phy[i]);
kfree(Log2Phy[i]);
Log2Phy[i] = NULL;
}
}
- return(NO_ERROR);
+ return NO_ERROR;
}
-////----- Pwoff_D_SmartMedia() -------------------------------------------
-//int Pwoff_D_SmartMedia(void)
-//{
-// PowerOff_D_Media();
-// return(NO_ERROR);
-//}
-//
-////----- Check_D_SmartMedia() -------------------------------------------
-//int Check_D_SmartMedia(void)
-//{
-// if (Check_D_MediaExist())
-// return(ErrCode);
-//
-// return(NO_ERROR);
-//}
-//
-////----- Check_D_Parameter() --------------------------------------------
-//int Check_D_Parameter(PFDO_DEVICE_EXTENSION fdoExt,WORD *pcyl,BYTE *phead,BYTE *psect)
-//{
-// if (Check_D_MediaPower())
-// return(ErrCode);
-//
-// if (Check_D_MediaFmt(fdoExt))
-// return(ErrCode);
-//
-// if (Check_D_LogCHS(pcyl,phead,psect))
-// return(ErrCode);
-//
-// return(NO_ERROR);
-//}
-
-//SmartMedia Read/Write/Erase Function
-//----- Media_D_ReadSector() -------------------------------------------
-int Media_D_ReadSector(struct us_data *us, DWORD start,WORD count,BYTE *buf)
+/* SmartMedia Read/Write/Erase Function */
+/* ----- Media_D_ReadSector() ------------------------------------------- */
+int Media_D_ReadSector(struct us_data *us, u32 start, u16 count, u8 *buf)
{
- WORD len, bn;
+ u16 len, bn;
- //if (Check_D_MediaPower()) ; ¦b 6250 don't care
- // return(ErrCode);
- //if (Check_D_MediaFmt(fdoExt)) ;
- // return(ErrCode);
if (Conv_D_MediaAddr(us, start))
- return(ErrCode);
+ return ErrCode;
- while(1)
- {
+ while (1) {
len = Ssfdc.MaxSectors - Media.Sector;
if (count > len)
bn = len;
else
bn = count;
- //if (Media_D_ReadOneSect(fdoExt, SectBuf))
- //if (Media_D_ReadOneSect(fdoExt, count, buf))
- if (Media_D_ReadOneSect(us, bn, buf))
- {
+
+ if (Media_D_ReadOneSect(us, bn, buf)) {
ErrCode = ERR_EccReadErr;
- return(ErrCode);
+ return ErrCode;
}
Media.Sector += bn;
count -= bn;
- if (count<=0)
+ if (count <= 0)
break;
buf += bn * SECTSIZE;
if (Inc_D_MediaAddr(us))
- return(ErrCode);
+ return ErrCode;
}
- return(NO_ERROR);
+ return NO_ERROR;
}
-// here
-//----- Media_D_CopySector() ------------------------------------------
-int Media_D_CopySector(struct us_data *us, DWORD start,WORD count,BYTE *buf)
+/* here */
+/* ----- Media_D_CopySector() ------------------------------------------ */
+int Media_D_CopySector(struct us_data *us, u32 start, u16 count, u8 *buf)
{
- //DWORD mode;
- //int i;
- WORD len, bn;
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
+ u16 len, bn;
/* pr_info("Media_D_CopySector !!!\n"); */
if (Conv_D_MediaAddr(us, start))
- return(ErrCode);
+ return ErrCode;
- while(1)
- {
+ while (1) {
if (Assign_D_WriteBlock())
- return(ERROR);
+ return ERROR;
len = Ssfdc.MaxSectors - Media.Sector;
if (count > len)
@@ -209,607 +115,137 @@ int Media_D_CopySector(struct us_data *us, DWORD start,WORD count,BYTE *buf)
else
bn = count;
- //if (Ssfdc_D_CopyBlock(fdoExt,count,buf,Redundant))
- if (Ssfdc_D_CopyBlock(us,bn,buf,Redundant))
- {
+ if (Ssfdc_D_CopyBlock(us, bn, buf, Redundant)) {
ErrCode = ERR_WriteFault;
- return(ErrCode);
+ return ErrCode;
}
Media.Sector = 0x1F;
- //if (Release_D_ReadBlock(fdoExt))
- if (Release_D_CopySector(us))
- {
- if (ErrCode==ERR_HwError)
- {
+ if (Release_D_CopySector(us)) {
+ if (ErrCode == ERR_HwError) {
ErrCode = ERR_WriteFault;
- return(ErrCode);
+ return ErrCode;
}
}
count -= bn;
- if (count<=0)
+ if (count <= 0)
break;
buf += bn * SECTSIZE;
if (Inc_D_MediaAddr(us))
- return(ErrCode);
-
- }
- return(NO_ERROR);
-}
-
-//----- Release_D_CopySector() ------------------------------------------
-int Release_D_CopySector(struct us_data *us)
-{
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
-
- Log2Phy[Media.Zone][Media.LogBlock]=WriteBlock;
- Media.PhyBlock=ReadBlock;
+ return ErrCode;
- if (Media.PhyBlock==NO_ASSIGN)
- {
- Media.PhyBlock=WriteBlock;
- return(SMSUCCESS);
}
-
- Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
- Media.PhyBlock=WriteBlock;
-
- return(SMSUCCESS);
-}
-/*
-//----- Media_D_WriteSector() ------------------------------------------
-int Media_D_WriteSector(PFDO_DEVICE_EXTENSION fdoExt, DWORD start,WORD count,BYTE *buf)
-{
- int i;
- WORD len, bn;
- SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- ADDRESS_T bb = (ADDRESS_T) &Media;
-
- //if (Check_D_MediaPower())
- // return(ErrCode);
- //
- //if (Check_D_MediaFmt(fdoExt))
- // return(ErrCode);
- //
- //if (Check_D_MediaWP())
- // return(ErrCode);
-
- if (Conv_D_MediaAddr(fdoExt, start))
- return(ErrCode);
-
- //ENE_Print("Media_D_WriteSector --- Sector = %x\n", Media.Sector);
- if (Check_D_FirstSect())
- {
- if (Media_D_CopyBlockHead(fdoExt))
- {
- ErrCode = ERR_WriteFault;
- return(ErrCode);
- }
- }
-
- while(1)
- {
- if (!Check_D_FirstSect())
- {
- if (Assign_D_WriteBlock())
- return(ErrCode);
- }
-
- len = Ssfdc.MaxSectors - Media.Sector;
- if (count > len)
- bn = len;
- else
- bn = count;
- //for(i=0;i<SECTSIZE;i++)
- // SectBuf[i]=*buf++;
-
- //if (Media_D_WriteOneSect(fdoExt, SectBuf))
- if (Media_D_WriteOneSect(fdoExt, bn, buf))
- {
- ErrCode = ERR_WriteFault;
- return(ErrCode);
- }
-
- Media.Sector += bn - 1;
-
- if (!Check_D_LastSect())
- {
- if (Release_D_ReadBlock(fdoExt))
-
- { if (ErrCode==ERR_HwError)
- {
- ErrCode = ERR_WriteFault;
- return(ErrCode);
- }
- }
- }
-
- count -= bn;
-
- if (count<=0)
- break;
-
- buf += bn * SECTSIZE;
-
- //if (--count<=0)
- // break;
-
- if (Inc_D_MediaAddr(fdoExt))
- return(ErrCode);
- }
-
- if (!Check_D_LastSect())
- return(NO_ERROR);
-
- if (Inc_D_MediaAddr(fdoExt))
- return(ErrCode);
-
- if (Media_D_CopyBlockTail(fdoExt))
- {
- ErrCode = ERR_WriteFault;
- return(ErrCode);
- }
-
- return(NO_ERROR);
-}
-//
-////----- Media_D_EraseBlock() -------------------------------------------
-//int Media_D_EraseBlock(PFDO_DEVICE_EXTENSION fdoExt, DWORD start,WORD count)
-//{
-// if (Check_D_MediaPower())
-// return(ErrCode);
-//
-// if (Check_D_MediaFmt(fdoExt))
-// return(ErrCode);
-//
-// if (Check_D_MediaWP())
-// return(ErrCode);
-//
-// if (Conv_D_MediaAddr(start))
-// return(ErrCode);
-//
-// while(Check_D_FirstSect()) {
-// if (Inc_D_MediaAddr(fdoExt))
-// return(ErrCode);
-//
-// if (--count<=0)
-// return(NO_ERROR);
-// }
-//
-// while(1) {
-// if (!Check_D_LastSect())
-// if (Media_D_EraseOneBlock())
-// if (ErrCode==ERR_HwError)
-// {
-// ErrCode = ERR_WriteFault;
-// return(ErrCode);
-// }
-//
-// if (Inc_D_MediaAddr(fdoExt))
-// return(ErrCode);
-//
-// if (--count<=0)
-// return(NO_ERROR);
-// }
-//}
-//
-////----- Media_D_EraseAll() ---------------------------------------------
-//int Media_D_EraseAll(PFDO_DEVICE_EXTENSION fdoExt)
-//{
-// if (Check_D_MediaPower())
-// return(ErrCode);
-//
-// if (Check_D_MediaFmtForEraseAll(fdoExt))
-// return(ErrCode);
-//
-// if (Check_D_MediaWP())
-// return(ErrCode);
-//
-// if (Media_D_EraseAllBlock())
-// return(ErrCode);
-//
-// return(NO_ERROR);
-//}
-
-//SmartMedia Write Function for One Sector Write Mode
-//----- Media_D_OneSectWriteStart() ------------------------------------
-int Media_D_OneSectWriteStart(PFDO_DEVICE_EXTENSION fdoExt,DWORD start,BYTE *buf)
-{
-// int i;
-// SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
-// ADDRESS_T bb = (ADDRESS_T) &Media;
-//
-// //if (Check_D_MediaPower())
-// // return(ErrCode);
-// //if (Check_D_MediaFmt(fdoExt))
-// // return(ErrCode);
-// //if (Check_D_MediaWP())
-// // return(ErrCode);
-// if (Conv_D_MediaAddr(fdoExt, start))
-// return(ErrCode);
-//
-// if (Check_D_FirstSect())
-// if (Media_D_CopyBlockHead(fdoExt))
-// {
-// ErrCode = ERR_WriteFault;
-// return(ErrCode);
-// }
-//
-// if (!Check_D_FirstSect())
-// if (Assign_D_WriteBlock())
-// return(ErrCode);
-//
-// //for(i=0;i<SECTSIZE;i++)
-// // SectBuf[i]=*buf++;
-//
-// //if (Media_D_WriteOneSect(fdoExt, SectBuf))
-// if (Media_D_WriteOneSect(fdoExt, buf))
-// {
-// ErrCode = ERR_WriteFault;
-// return(ErrCode);
-// }
-//
-// if (!Check_D_LastSect())
-// {
-// if (Release_D_ReadBlock(fdoExt))
-// if (ErrCode==ERR_HwError)
-// {
-// ErrCode = ERR_WriteFault;
-// return(ErrCode);
-// }
-// }
-
- return(NO_ERROR);
-}
-
-//----- Media_D_OneSectWriteNext() -------------------------------------
-int Media_D_OneSectWriteNext(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf)
-{
-// int i;
-// SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
-// ADDRESS_T bb = (ADDRESS_T) &Media;
-//
-// if (Inc_D_MediaAddr(fdoExt))
-// return(ErrCode);
-//
-// if (!Check_D_FirstSect())
-// if (Assign_D_WriteBlock())
-// return(ErrCode);
-//
-// //for(i=0;i<SECTSIZE;i++)
-// // SectBuf[i]=*buf++;
-//
-// //if (Media_D_WriteOneSect(fdoExt, SectBuf))
-// if (Media_D_WriteOneSect(fdoExt, buf))
-// {
-// ErrCode = ERR_WriteFault;
-// return(ErrCode);
-// }
-//
-// if (!Check_D_LastSect())
-// {
-// if (Release_D_ReadBlock(fdoExt))
-// if (ErrCode==ERR_HwError)
-// {
-// ErrCode = ERR_WriteFault;
-// return(ErrCode);
-// }
-// }
-
- return(NO_ERROR);
+ return NO_ERROR;
}
-//----- Media_D_OneSectWriteFlush() ------------------------------------
-int Media_D_OneSectWriteFlush(PFDO_DEVICE_EXTENSION fdoExt)
-{
- if (!Check_D_LastSect())
- return(NO_ERROR);
-
- if (Inc_D_MediaAddr(fdoExt))
- return(ErrCode);
-
- if (Media_D_CopyBlockTail(fdoExt))
- {
- ErrCode = ERR_WriteFault;
- return(ErrCode);
- }
-
- return(NO_ERROR);
-}
-//
-////LED Tern On/Off Subroutine
-////----- SM_EnableLED() -----------------------------------------------
-//void SM_EnableLED(PFDO_DEVICE_EXTENSION fdoExt, BOOLEAN enable)
-//{
-// if (fdoExt->Drive_IsSWLED)
-// {
-// if (enable)
-// Led_D_TernOn();
-// else
-// Led_D_TernOff();
-// }
-//}
-//
-////----- Led_D_TernOn() -------------------------------------------------
-//void Led_D_TernOn(void)
-//{
-// if (Check_D_CardStsChg())
-// MediaChange=ERROR;
-//
-// Cnt_D_LedOn();
-//}
-//
-////----- Led_D_TernOff() ------------------------------------------------
-//void Led_D_TernOff(void)
-//{
-// if (Check_D_CardStsChg())
-// MediaChange=ERROR;
-//
-// Cnt_D_LedOff();
-//}
-//
-////SmartMedia Logical Format Subroutine
-////----- Check_D_LogCHS() -----------------------------------------------
-//int Check_D_LogCHS(WORD *c,BYTE *h,BYTE *s)
-//{
-// switch(Ssfdc.Model) {
-// case SSFDC1MB: *c=125; *h= 4; *s= 4; break;
-// case SSFDC2MB: *c=125; *h= 4; *s= 8; break;
-// case SSFDC4MB: *c=250; *h= 4; *s= 8; break;
-// case SSFDC8MB: *c=250; *h= 4; *s=16; break;
-// case SSFDC16MB: *c=500; *h= 4; *s=16; break;
-// case SSFDC32MB: *c=500; *h= 8; *s=16; break;
-// case SSFDC64MB: *c=500; *h= 8; *s=32; break;
-// case SSFDC128MB: *c=500; *h=16; *s=32; break;
-// default: *c= 0; *h= 0; *s= 0; ErrCode = ERR_NoSmartMedia; return(ERROR);
-// }
-//
-// return(SMSUCCESS);
-//}
-//
-////Power Control & Media Exist Check Subroutine
-////----- Initialize_D_Media() -------------------------------------------
-//void Initialize_D_Media(void)
-//{
-// ErrCode = NO_ERROR;
-// MediaChange = ERROR;
-// SectCopyMode = COMPLETED;
-// Cnt_D_Reset();
-//}
-//
-////----- PowerOff_D_Media() ---------------------------------------------
-//void PowerOff_D_Media(void)
-//{
-// Cnt_D_PowerOff();
-//}
-//
-////----- Check_D_MediaPower() -------------------------------------------
-//int Check_D_MediaPower(void)
-//{
-// //usleep(56*1024);
-// if (Check_D_CardStsChg())
-// MediaChange = ERROR;
-// //usleep(56*1024);
-// if ((!Check_D_CntPower())&&(!MediaChange)) // ¦³ power & Media ¨S³Q change, «h return success
-// return(SMSUCCESS);
-// //usleep(56*1024);
-//
-// if (Check_D_CardExist()) // Check if card is not exist, return err
-// {
-// ErrCode = ERR_NoSmartMedia;
-// MediaChange = ERROR;
-// return(ERROR);
-// }
-// //usleep(56*1024);
-// if (Cnt_D_PowerOn())
-// {
-// ErrCode = ERR_NoSmartMedia;
-// MediaChange = ERROR;
-// return(ERROR);
-// }
-// //usleep(56*1024);
-// Ssfdc_D_Reset(fdoExt);
-// //usleep(56*1024);
-// return(SMSUCCESS);
-//}
-//
-////-----Check_D_MediaExist() --------------------------------------------
-//int Check_D_MediaExist(void)
-//{
-// if (Check_D_CardStsChg())
-// MediaChange = ERROR;
-//
-// if (!Check_D_CardExist())
-// {
-// if (!MediaChange)
-// return(SMSUCCESS);
-//
-// ErrCode = ERR_ChangedMedia;
-// return(ERROR);
-// }
-//
-// ErrCode = ERR_NoSmartMedia;
-//
-// return(ERROR);
-//}
-//
-////----- Check_D_MediaWP() ----------------------------------------------
-//int Check_D_MediaWP(void)
-//{
-// if (Ssfdc.Attribute &MWP)
-// {
-// ErrCode = ERR_WrtProtect;
-// return(ERROR);
-// }
-//
-// return(SMSUCCESS);
-//}
-*/
-//SmartMedia Physical Format Test Subroutine
-//----- Check_D_MediaFmt() ---------------------------------------------
+/* SmartMedia Physical Format Test Subroutine */
+/* ----- Check_D_MediaFmt() --------------------------------------------- */
int Check_D_MediaFmt(struct us_data *us)
{
pr_info("Check_D_MediaFmt\n");
- //ULONG i,j, result=FALSE, zone,block;
- //usleep(56*1024);
if (!MediaChange)
- return(SMSUCCESS);
+ return SMSUCCESS;
MediaChange = ERROR;
SectCopyMode = COMPLETED;
- //usleep(56*1024);
- if (Set_D_PhyFmtValue(us))
- {
+ if (Set_D_PhyFmtValue(us)) {
ErrCode = ERR_UnknownMedia;
- return(ERROR);
+ return ERROR;
}
-
- //usleep(56*1024);
- if (Search_D_CIS(us))
- {
+
+ if (Search_D_CIS(us)) {
ErrCode = ERR_IllegalFmt;
- return(ERROR);
+ return ERROR;
+ }
+
+ MediaChange = SMSUCCESS;
+ return SMSUCCESS;
+}
+
+/* ----- Release_D_CopySector() ------------------------------------------ */
+static int Release_D_CopySector(struct us_data *us)
+{
+ Log2Phy[Media.Zone][Media.LogBlock] = WriteBlock;
+ Media.PhyBlock = ReadBlock;
+
+ if (Media.PhyBlock == NO_ASSIGN) {
+ Media.PhyBlock = WriteBlock;
+ return SMSUCCESS;
}
+ Clr_D_Bit(Assign[Media.Zone], Media.PhyBlock);
+ Media.PhyBlock = WriteBlock;
- MediaChange = SMSUCCESS;
- return(SMSUCCESS);
+ return SMSUCCESS;
}
-/*
-////----- Check_D_BlockIsFull() ----------------------------------
-//void Check_D_BlockIsFull()
-//{
-// ULONG i, block;
-//
-// if (IsXDCompliance || IsSSFDCCompliance)
-// {
-// // If the blocks are full then return write-protect.
-// block = Ssfdc.MaxBlocks/8;
-// for (Media.Zone=0; Media.Zone<Ssfdc.MaxZones; Media.Zone++)
-// {
-// if (Log2Phy[Media.Zone]==NULL)
-// {
-// if (Make_D_LogTable())
-// {
-// ErrCode = ERR_IllegalFmt;
-// return;
-// }
-// }
-//
-// for (i=0; i<block; i++)
-// {
-// if (Assign[Media.Zone][i] != 0xFF)
-// return;
-// }
-// }
-// Ssfdc.Attribute |= WP;
-// }
-//}
-//
-//
-////----- Check_D_MediaFmtForEraseAll() ----------------------------------
-//int Check_D_MediaFmtForEraseAll(PFDO_DEVICE_EXTENSION fdoExt)
-//{
-// MediaChange = ERROR;
-// SectCopyMode = COMPLETED;
-//
-// if (Set_D_PhyFmtValue(fdoExt))
-// {
-// ErrCode = ERR_UnknownMedia;
-// return(ERROR);
-// }
-//
-// if (Search_D_CIS(fdoExt))
-// {
-// ErrCode = ERR_IllegalFmt;
-// return(ERROR);
-// }
-//
-// return(SMSUCCESS);
-//}
-*/
-//SmartMedia Physical Address Control Subroutine
-//----- Conv_D_MediaAddr() ---------------------------------------------
-int Conv_D_MediaAddr(struct us_data *us, DWORD addr)
+
+/* SmartMedia Physical Address Control Subroutine */
+/* ----- Conv_D_MediaAddr() --------------------------------------------- */
+static int Conv_D_MediaAddr(struct us_data *us, u32 addr)
{
- DWORD temp;
- //ULONG zz;
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
-
- temp = addr/Ssfdc.MaxSectors;
- Media.Zone = (BYTE) (temp/Ssfdc.MaxLogBlocks);
-
- if (Log2Phy[Media.Zone]==NULL)
- {
- if (Make_D_LogTable(us))
- {
+ u32 temp;
+
+ temp = addr / Ssfdc.MaxSectors;
+ Media.Zone = (u8) (temp / Ssfdc.MaxLogBlocks);
+
+ if (Log2Phy[Media.Zone] == NULL) {
+ if (Make_D_LogTable(us)) {
ErrCode = ERR_IllegalFmt;
- return(ERROR);
+ return ERROR;
}
}
- Media.Sector = (BYTE) (addr%Ssfdc.MaxSectors);
- Media.LogBlock = (WORD) (temp%Ssfdc.MaxLogBlocks);
+ Media.Sector = (u8) (addr % Ssfdc.MaxSectors);
+ Media.LogBlock = (u16) (temp % Ssfdc.MaxLogBlocks);
- if (Media.Zone<Ssfdc.MaxZones)
- {
+ if (Media.Zone < Ssfdc.MaxZones) {
Clr_D_RedundantData(Redundant);
Set_D_LogBlockAddr(Redundant);
Media.PhyBlock = Log2Phy[Media.Zone][Media.LogBlock];
- return(SMSUCCESS);
+ return SMSUCCESS;
}
ErrCode = ERR_OutOfLBA;
- return(ERROR);
+ return ERROR;
}
-//----- Inc_D_MediaAddr() ----------------------------------------------
-int Inc_D_MediaAddr(struct us_data *us)
+/* ----- Inc_D_MediaAddr() ---------------------------------------------- */
+static int Inc_D_MediaAddr(struct us_data *us)
{
- WORD LogBlock = Media.LogBlock;
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
+ u16 LogBlock = Media.LogBlock;
- if (++Media.Sector<Ssfdc.MaxSectors)
- return(SMSUCCESS);
+ if (++Media.Sector < Ssfdc.MaxSectors)
+ return SMSUCCESS;
- if (Log2Phy[Media.Zone]==NULL)
- {
- if (Make_D_LogTable(us))
- {
+ if (Log2Phy[Media.Zone] == NULL) {
+ if (Make_D_LogTable(us)) {
ErrCode = ERR_IllegalFmt;
- return(ERROR);
+ return ERROR;
}
}
- Media.Sector=0;
+ Media.Sector = 0;
Media.LogBlock = LogBlock;
- if (++Media.LogBlock<Ssfdc.MaxLogBlocks)
- {
+ if (++Media.LogBlock < Ssfdc.MaxLogBlocks) {
Clr_D_RedundantData(Redundant);
Set_D_LogBlockAddr(Redundant);
- Media.PhyBlock=Log2Phy[Media.Zone][Media.LogBlock];
- return(SMSUCCESS);
+ Media.PhyBlock = Log2Phy[Media.Zone][Media.LogBlock];
+ return SMSUCCESS;
}
- Media.LogBlock=0;
+ Media.LogBlock = 0;
- if (++Media.Zone<Ssfdc.MaxZones)
- {
- if (Log2Phy[Media.Zone]==NULL)
- {
- if (Make_D_LogTable(us))
- {
+ if (++Media.Zone < Ssfdc.MaxZones) {
+ if (Log2Phy[Media.Zone] == NULL) {
+ if (Make_D_LogTable(us)) {
ErrCode = ERR_IllegalFmt;
- return(ERROR);
+ return ERROR;
}
}
@@ -817,1034 +253,508 @@ int Inc_D_MediaAddr(struct us_data *us)
Clr_D_RedundantData(Redundant);
Set_D_LogBlockAddr(Redundant);
- Media.PhyBlock=Log2Phy[Media.Zone][Media.LogBlock];
- return(SMSUCCESS);
+ Media.PhyBlock = Log2Phy[Media.Zone][Media.LogBlock];
+ return SMSUCCESS;
}
- Media.Zone=0;
+ Media.Zone = 0;
ErrCode = ERR_OutOfLBA;
- return(ERROR);
-}
-/*
-//----- Check_D_FirstSect() --------------------------------------------
-int Check_D_FirstSect(void)
-{
- SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- ADDRESS_T bb = (ADDRESS_T) &Media;
-
- if (!Media.Sector)
- return(SMSUCCESS);
-
- return(ERROR);
+ return ERROR;
}
-//----- Check_D_LastSect() ---------------------------------------------
-int Check_D_LastSect(void)
+/* SmartMedia Read/Write Subroutine with Retry */
+/* ----- Media_D_ReadOneSect() ------------------------------------------ */
+static int Media_D_ReadOneSect(struct us_data *us, u16 count, u8 *buf)
{
- SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- ADDRESS_T bb = (ADDRESS_T) &Media;
-
- if (Media.Sector<(Ssfdc.MaxSectors-1))
- return(ERROR);
-
- return(SMSUCCESS);
-}
-*/
-//SmartMedia Read/Write Subroutine with Retry
-//----- Media_D_ReadOneSect() ------------------------------------------
-int Media_D_ReadOneSect(struct us_data *us, WORD count, BYTE *buf)
-{
- DWORD err, retry;
+ u32 err, retry;
if (!Read_D_PhyOneSect(us, count, buf))
- return(SMSUCCESS);
- if (ErrCode==ERR_HwError)
- return(ERROR);
- if (ErrCode==ERR_DataStatus)
- return(ERROR);
+ return SMSUCCESS;
+ if (ErrCode == ERR_HwError)
+ return ERROR;
+ if (ErrCode == ERR_DataStatus)
+ return ERROR;
#ifdef RDERR_REASSIGN
- if (Ssfdc.Attribute &MWP)
- {
- if (ErrCode==ERR_CorReadErr)
- return(SMSUCCESS);
- return(ERROR);
+ if (Ssfdc.Attribute & MWP) {
+ if (ErrCode == ERR_CorReadErr)
+ return SMSUCCESS;
+ return ERROR;
}
- err=ErrCode;
- for(retry=0; retry<2; retry++)
- {
- if (Copy_D_BlockAll(us, (err==ERR_EccReadErr)?REQ_FAIL:REQ_ERASE))
- {
- if (ErrCode==ERR_HwError)
- return(ERROR);
+ err = ErrCode;
+ for (retry = 0; retry < 2; retry++) {
+ if (Copy_D_BlockAll(us,
+ (err == ERR_EccReadErr) ? REQ_FAIL : REQ_ERASE)) {
+ if (ErrCode == ERR_HwError)
+ return ERROR;
continue;
}
ErrCode = err;
- if (ErrCode==ERR_CorReadErr)
- return(SMSUCCESS);
- return(ERROR);
+ if (ErrCode == ERR_CorReadErr)
+ return SMSUCCESS;
+ return ERROR;
}
MediaChange = ERROR;
#else
- if (ErrCode==ERR_CorReadErr) return(SMSUCCESS);
+ if (ErrCode == ERR_CorReadErr)
+ return SMSUCCESS;
#endif
- return(ERROR);
-}
-/*
-//----- Media_D_WriteOneSect() -----------------------------------------
-int Media_D_WriteOneSect(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf)
-{
- DWORD retry;
- SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- ADDRESS_T bb = (ADDRESS_T) &Media;
-
- if (!Write_D_PhyOneSect(fdoExt, count, buf))
- return(SMSUCCESS);
- if (ErrCode==ERR_HwError)
- return(ERROR);
-
- for(retry=1; retry<2; retry++)
- {
- if (Reassign_D_BlockHead(fdoExt))
- {
- if (ErrCode==ERR_HwError)
- return(ERROR);
- continue;
- }
-
- if (!Write_D_PhyOneSect(fdoExt, count, buf))
- return(SMSUCCESS);
- if (ErrCode==ERR_HwError)
- return(ERROR);
- }
-
- if (Release_D_WriteBlock(fdoExt))
- return(ERROR);
-
- ErrCode = ERR_WriteFault;
- MediaChange = ERROR;
- return(ERROR);
+ return ERROR;
}
-//SmartMedia Data Copy Subroutine with Retry
-//----- Media_D_CopyBlockHead() ----------------------------------------
-int Media_D_CopyBlockHead(PFDO_DEVICE_EXTENSION fdoExt)
+/* SmartMedia Physical Sector Data Copy Subroutine */
+/* ----- Copy_D_BlockAll() ---------------------------------------------- */
+static int Copy_D_BlockAll(struct us_data *us, u32 mode)
{
- DWORD retry;
-
- for(retry=0; retry<2; retry++)
- {
- if (!Copy_D_BlockHead(fdoExt))
- return(SMSUCCESS);
- if (ErrCode==ERR_HwError)
- return(ERROR);
- }
-
- MediaChange = ERROR;
- return(ERROR);
-}
+ u8 sect;
-//----- Media_D_CopyBlockTail() ----------------------------------------
-int Media_D_CopyBlockTail(PFDO_DEVICE_EXTENSION fdoExt)
-{
- DWORD retry;
-
- if (!Copy_D_BlockTail(fdoExt))
- return(SMSUCCESS);
- if (ErrCode==ERR_HwError)
- return(ERROR);
-
- for(retry=1; retry<2; retry++)
- {
- if (Reassign_D_BlockHead(fdoExt))
- {
- if (ErrCode==ERR_HwError)
- return(ERROR);
- continue;
- }
-
- if (!Copy_D_BlockTail(fdoExt))
- return(SMSUCCESS);
- if (ErrCode==ERR_HwError)
- return(ERROR);
- }
-
- if (Release_D_WriteBlock(fdoExt))
- return(ERROR);
-
- ErrCode = ERR_WriteFault;
- MediaChange = ERROR;
- return(ERROR);
-}
-//
-////----- Media_D_EraseOneBlock() ----------------------------------------
-//int Media_D_EraseOneBlock(void)
-//{
-// WORD LogBlock = Media.LogBlock;
-// WORD PhyBlock = Media.PhyBlock;
-// SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
-// ADDRESS_T bb = (ADDRESS_T) &Media;
-//
-// if (Media.PhyBlock==NO_ASSIGN)
-// return(SMSUCCESS);
-//
-// if (Log2Phy[Media.Zone]==NULL)
-// {
-// if (Make_D_LogTable())
-// {
-// ErrCode = ERR_IllegalFmt;
-// return(ERROR);
-// }
-// }
-// Media.LogBlock = LogBlock;
-// Media.PhyBlock = PhyBlock;
-//
-// Log2Phy[Media.Zone][Media.LogBlock]=NO_ASSIGN;
-//
-// if (Erase_D_PhyOneBlock(fdoExt))
-// {
-// if (ErrCode==ERR_HwError)
-// return(ERROR);
-// if (MarkFail_D_PhyOneBlock())
-// return(ERROR);
-//
-// ErrCode = ERR_WriteFault;
-// return(ERROR);
-// }
-//
-// Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
-// Media.PhyBlock=NO_ASSIGN;
-// return(SMSUCCESS);
-//}
-//
-////SmartMedia Erase Subroutine
-////----- Media_D_EraseAllBlock() ----------------------------------------
-//int Media_D_EraseAllBlock(void)
-//{
-// WORD cis=0;
-//
-// SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
-// ADDRESS_T bb = (ADDRESS_T) &Media;
-//
-// MediaChange = ERROR;
-// Media.Sector = 0;
-//
-// for(Media.Zone=0; Media.Zone<Ssfdc.MaxZones; Media.Zone++)
-// for(Media.PhyBlock=0; Media.PhyBlock<Ssfdc.MaxBlocks; Media.PhyBlock++) {
-// if (Ssfdc_D_ReadRedtData(Redundant))
-// {
-// Ssfdc_D_Reset(fdoExt);
-// return(ERROR);
-// }
-//
-// Ssfdc_D_Reset(fdoExt);
-// if (!Check_D_FailBlock(Redundant))
-// {
-// if (cis)
-// {
-// if (Ssfdc_D_EraseBlock(fdoExt))
-// {
-// ErrCode = ERR_HwError;
-// return(ERROR);
-// }
-//
-// if (Ssfdc_D_CheckStatus())
-// {
-// if (MarkFail_D_PhyOneBlock())
-// return(ERROR);
-// }
-//
-// continue;
-// }
-//
-// if (Media.PhyBlock!=CisArea.PhyBlock)
-// {
-// ErrCode = ERR_IllegalFmt;
-// return(ERROR);
-// }
-//
-// cis++;
-// }
-//
-// }
-// return(SMSUCCESS);
-//}
-*/
-//SmartMedia Physical Sector Data Copy Subroutine
-//----- Copy_D_BlockAll() ----------------------------------------------
-int Copy_D_BlockAll(struct us_data *us, DWORD mode)
-{
- BYTE sect;
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
-
- sect=Media.Sector;
+ sect = Media.Sector;
if (Assign_D_WriteBlock())
- return(ERROR);
- if (mode==REQ_FAIL)
- SectCopyMode=REQ_FAIL;
-
- for(Media.Sector=0; Media.Sector<Ssfdc.MaxSectors; Media.Sector++)
- {
- if (Copy_D_PhyOneSect(us))
- {
- if (ErrCode==ERR_HwError)
- return(ERROR);
+ return ERROR;
+ if (mode == REQ_FAIL)
+ SectCopyMode = REQ_FAIL;
+
+ for (Media.Sector = 0; Media.Sector < Ssfdc.MaxSectors;
+ Media.Sector++) {
+ if (Copy_D_PhyOneSect(us)) {
+ if (ErrCode == ERR_HwError)
+ return ERROR;
if (Release_D_WriteBlock(us))
- return(ERROR);
+ return ERROR;
ErrCode = ERR_WriteFault;
- Media.PhyBlock=ReadBlock;
- Media.Sector=sect;
+ Media.PhyBlock = ReadBlock;
+ Media.Sector = sect;
- return(ERROR);
+ return ERROR;
}
}
if (Release_D_ReadBlock(us))
- return(ERROR);
+ return ERROR;
- Media.PhyBlock=WriteBlock;
- Media.Sector=sect;
- return(SMSUCCESS);
-}
-/*
-//----- Copy_D_BlockHead() ---------------------------------------------
-int Copy_D_BlockHead(PFDO_DEVICE_EXTENSION fdoExt)
-{
- BYTE sect;
- SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- ADDRESS_T bb = (ADDRESS_T) &Media;
-
- sect=Media.Sector;
- if (Assign_D_WriteBlock())
- return(ERROR);
-
- for(Media.Sector=0; Media.Sector<sect; Media.Sector++)
- {
- if (Copy_D_PhyOneSect(fdoExt))
- {
- if (ErrCode==ERR_HwError)
- return(ERROR);
- if (Release_D_WriteBlock(fdoExt))
- return(ERROR);
-
- ErrCode = ERR_WriteFault;
- Media.PhyBlock=ReadBlock;
- Media.Sector=sect;
-
- return(ERROR);
- }
- }
-
- Media.PhyBlock=WriteBlock;
- Media.Sector=sect;
- return(SMSUCCESS);
+ Media.PhyBlock = WriteBlock;
+ Media.Sector = sect;
+ return SMSUCCESS;
}
-//----- Copy_D_BlockTail() ---------------------------------------------
-int Copy_D_BlockTail(PFDO_DEVICE_EXTENSION fdoExt)
+/* SmartMedia Physical Block Assign/Release Subroutine */
+/* ----- Assign_D_WriteBlock() ------------------------------------------ */
+static int Assign_D_WriteBlock(void)
{
- BYTE sect;
- SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- ADDRESS_T bb = (ADDRESS_T) &Media;
-
- for(sect=Media.Sector; Media.Sector<Ssfdc.MaxSectors; Media.Sector++)
- {
- if (Copy_D_PhyOneSect(fdoExt))
- {
- if (ErrCode==ERR_HwError)
- return(ERROR);
-
- Media.PhyBlock=WriteBlock;
- Media.Sector=sect;
-
- return(ERROR);
- }
- }
-
- if (Release_D_ReadBlock(fdoExt))
- return(ERROR);
-
- Media.PhyBlock=WriteBlock;
- Media.Sector=sect;
- return(SMSUCCESS);
-}
+ ReadBlock = Media.PhyBlock;
-//----- Reassign_D_BlockHead() -----------------------------------------
-int Reassign_D_BlockHead(PFDO_DEVICE_EXTENSION fdoExt)
-{
- DWORD mode;
- WORD block;
- BYTE sect;
- SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- ADDRESS_T bb = (ADDRESS_T) &Media;
-
- mode=SectCopyMode;
- block=ReadBlock;
- sect=Media.Sector;
-
- if (Assign_D_WriteBlock())
- return(ERROR);
-
- SectCopyMode=REQ_FAIL;
-
- for(Media.Sector=0; Media.Sector<sect; Media.Sector++)
- {
- if (Copy_D_PhyOneSect(fdoExt))
- {
- if (ErrCode==ERR_HwError)
- return(ERROR);
- if (Release_D_WriteBlock(fdoExt))
- return(ERROR);
-
- ErrCode = ERR_WriteFault;
- SectCopyMode=mode;
- WriteBlock=ReadBlock;
- ReadBlock=block;
- Media.Sector=sect;
- Media.PhyBlock=WriteBlock;
-
- return(ERROR);
- }
- }
-
- if (Release_D_ReadBlock(fdoExt))
- return(ERROR);
-
- SectCopyMode=mode;
- ReadBlock=block;
- Media.Sector=sect;
- Media.PhyBlock=WriteBlock;
- return(SMSUCCESS);
-}
-*/
-//SmartMedia Physical Block Assign/Release Subroutine
-//----- Assign_D_WriteBlock() ------------------------------------------
-int Assign_D_WriteBlock(void)
-{
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
- ReadBlock=Media.PhyBlock;
-
- for(WriteBlock=AssignStart[Media.Zone]; WriteBlock<Ssfdc.MaxBlocks; WriteBlock++)
- {
- if (!Chk_D_Bit(Assign[Media.Zone],WriteBlock))
- {
- Set_D_Bit(Assign[Media.Zone],WriteBlock);
- AssignStart[Media.Zone]=WriteBlock+1;
- Media.PhyBlock=WriteBlock;
- SectCopyMode=REQ_ERASE;
- //ErrXDCode = NO_ERROR;
- return(SMSUCCESS);
+ for (WriteBlock = AssignStart[Media.Zone];
+ WriteBlock < Ssfdc.MaxBlocks; WriteBlock++) {
+ if (!Chk_D_Bit(Assign[Media.Zone], WriteBlock)) {
+ Set_D_Bit(Assign[Media.Zone], WriteBlock);
+ AssignStart[Media.Zone] = WriteBlock + 1;
+ Media.PhyBlock = WriteBlock;
+ SectCopyMode = REQ_ERASE;
+ return SMSUCCESS;
}
}
- for(WriteBlock=0; WriteBlock<AssignStart[Media.Zone]; WriteBlock++)
- {
- if (!Chk_D_Bit(Assign[Media.Zone],WriteBlock))
- {
- Set_D_Bit(Assign[Media.Zone],WriteBlock);
- AssignStart[Media.Zone]=WriteBlock+1;
- Media.PhyBlock=WriteBlock;
- SectCopyMode=REQ_ERASE;
- //ErrXDCode = NO_ERROR;
- return(SMSUCCESS);
+ for (WriteBlock = 0;
+ WriteBlock < AssignStart[Media.Zone]; WriteBlock++) {
+ if (!Chk_D_Bit(Assign[Media.Zone], WriteBlock)) {
+ Set_D_Bit(Assign[Media.Zone], WriteBlock);
+ AssignStart[Media.Zone] = WriteBlock + 1;
+ Media.PhyBlock = WriteBlock;
+ SectCopyMode = REQ_ERASE;
+ return SMSUCCESS;
}
}
- WriteBlock=NO_ASSIGN;
+ WriteBlock = NO_ASSIGN;
ErrCode = ERR_WriteFault;
- // For xD test
- //Ssfdc.Attribute |= WP;
- //ErrXDCode = ERR_WrtProtect;
- return(ERROR);
+
+ return ERROR;
}
-//----- Release_D_ReadBlock() ------------------------------------------
-int Release_D_ReadBlock(struct us_data *us)
+/* ----- Release_D_ReadBlock() ------------------------------------------ */
+static int Release_D_ReadBlock(struct us_data *us)
{
- DWORD mode;
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
+ u32 mode;
- mode=SectCopyMode;
- SectCopyMode=COMPLETED;
+ mode = SectCopyMode;
+ SectCopyMode = COMPLETED;
- if (mode==COMPLETED)
- return(SMSUCCESS);
+ if (mode == COMPLETED)
+ return SMSUCCESS;
- Log2Phy[Media.Zone][Media.LogBlock]=WriteBlock;
- Media.PhyBlock=ReadBlock;
+ Log2Phy[Media.Zone][Media.LogBlock] = WriteBlock;
+ Media.PhyBlock = ReadBlock;
- if (Media.PhyBlock==NO_ASSIGN)
- {
- Media.PhyBlock=WriteBlock;
- return(SMSUCCESS);
+ if (Media.PhyBlock == NO_ASSIGN) {
+ Media.PhyBlock = WriteBlock;
+ return SMSUCCESS;
}
- if (mode==REQ_ERASE)
- {
- if (Erase_D_PhyOneBlock(us))
- {
- if (ErrCode==ERR_HwError) return(ERROR);
- if (MarkFail_D_PhyOneBlock(us)) return(ERROR);
- }
- else
- Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
- }
- else if (MarkFail_D_PhyOneBlock(us))
- return(ERROR);
+ if (mode == REQ_ERASE) {
+ if (Erase_D_PhyOneBlock(us)) {
+ if (ErrCode == ERR_HwError)
+ return ERROR;
+ if (MarkFail_D_PhyOneBlock(us))
+ return ERROR;
+ } else
+ Clr_D_Bit(Assign[Media.Zone], Media.PhyBlock);
+ } else if (MarkFail_D_PhyOneBlock(us))
+ return ERROR;
- Media.PhyBlock=WriteBlock;
- return(SMSUCCESS);
+ Media.PhyBlock = WriteBlock;
+ return SMSUCCESS;
}
-//----- Release_D_WriteBlock() -----------------------------------------
-int Release_D_WriteBlock(struct us_data *us)
+/* ----- Release_D_WriteBlock() ----------------------------------------- */
+static int Release_D_WriteBlock(struct us_data *us)
{
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
- SectCopyMode=COMPLETED;
- Media.PhyBlock=WriteBlock;
+ SectCopyMode = COMPLETED;
+ Media.PhyBlock = WriteBlock;
if (MarkFail_D_PhyOneBlock(us))
- return(ERROR);
+ return ERROR;
- Media.PhyBlock=ReadBlock;
- return(SMSUCCESS);
+ Media.PhyBlock = ReadBlock;
+ return SMSUCCESS;
}
-//SmartMedia Physical Sector Data Copy Subroutine
-//----- Copy_D_PhyOneSect() --------------------------------------------
-int Copy_D_PhyOneSect(struct us_data *us)
+/* SmartMedia Physical Sector Data Copy Subroutine */
+/* ----- Copy_D_PhyOneSect() -------------------------------------------- */
+static int Copy_D_PhyOneSect(struct us_data *us)
{
int i;
- DWORD err, retry;
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
-
- /* pr_info("Copy_D_PhyOneSect --- Secotr = %x\n", Media.Sector); */
- if (ReadBlock!=NO_ASSIGN)
- {
- Media.PhyBlock=ReadBlock;
- for(retry=0; retry<2; retry++)
- {
- if (retry!=0)
- {
+ u32 err, retry;
+
+ /* pr_info("Copy_D_PhyOneSect --- Sector = %x\n", Media.Sector); */
+ if (ReadBlock != NO_ASSIGN) {
+ Media.PhyBlock = ReadBlock;
+ for (retry = 0; retry < 2; retry++) {
+ if (retry != 0) {
Ssfdc_D_Reset(us);
- if (Ssfdc_D_ReadCisSect(us,WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
+ if (Ssfdc_D_ReadCisSect(us, WorkBuf,
+ WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange = ERROR;
+ return ERROR;
+ }
- if (Check_D_CISdata(WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
+ if (Check_D_CISdata(WorkBuf, WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange = ERROR;
+ return ERROR;
+ }
}
- if (Ssfdc_D_ReadSect(us,WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
- if (Check_D_DataStatus(WorkRedund))
- { err=ERROR; break; }
- if (!Check_D_ReadError(WorkRedund))
- { err=SMSUCCESS; break; }
- if (!Check_D_Correct(WorkBuf,WorkRedund))
- { err=SMSUCCESS; break; }
-
- err=ERROR;
- SectCopyMode=REQ_FAIL;
+ if (Ssfdc_D_ReadSect(us, WorkBuf, WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange = ERROR;
+ return ERROR;
+ }
+ if (Check_D_DataStatus(WorkRedund)) {
+ err = ERROR;
+ break;
+ }
+ if (!Check_D_ReadError(WorkRedund)) {
+ err = SMSUCCESS;
+ break;
+ }
+ if (!Check_D_Correct(WorkBuf, WorkRedund)) {
+ err = SMSUCCESS;
+ break;
+ }
+
+ err = ERROR;
+ SectCopyMode = REQ_FAIL;
}
- }
- else
- {
- err=SMSUCCESS;
- for(i=0; i<SECTSIZE; i++)
- WorkBuf[i]=DUMMY_DATA;
+ } else {
+ err = SMSUCCESS;
+ for (i = 0; i < SECTSIZE; i++)
+ WorkBuf[i] = DUMMY_DATA;
Clr_D_RedundantData(WorkRedund);
}
Set_D_LogBlockAddr(WorkRedund);
- if (err==ERROR)
- {
+ if (err == ERROR) {
Set_D_RightECC(WorkRedund);
Set_D_DataStaus(WorkRedund);
}
- Media.PhyBlock=WriteBlock;
+ Media.PhyBlock = WriteBlock;
- if (Ssfdc_D_WriteSectForCopy(us, WorkBuf, WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
- if (Ssfdc_D_CheckStatus())
- { ErrCode = ERR_WriteFault; return(ERROR); }
+ if (Ssfdc_D_WriteSectForCopy(us, WorkBuf, WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange = ERROR;
+ return ERROR;
+ }
+ if (Ssfdc_D_CheckStatus()) {
+ ErrCode = ERR_WriteFault;
+ return ERROR;
+ }
- Media.PhyBlock=ReadBlock;
- return(SMSUCCESS);
+ Media.PhyBlock = ReadBlock;
+ return SMSUCCESS;
}
-//SmartMedia Physical Sector Read/Write/Erase Subroutine
-//----- Read_D_PhyOneSect() --------------------------------------------
-int Read_D_PhyOneSect(struct us_data *us, WORD count, BYTE *buf)
+/* SmartMedia Physical Sector Read/Write/Erase Subroutine */
+/* ----- Read_D_PhyOneSect() -------------------------------------------- */
+static int Read_D_PhyOneSect(struct us_data *us, u16 count, u8 *buf)
{
int i;
- DWORD retry;
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
-
- if (Media.PhyBlock==NO_ASSIGN)
- {
- for(i=0; i<SECTSIZE; i++)
- *buf++=DUMMY_DATA;
- return(SMSUCCESS);
+ u32 retry;
+
+ if (Media.PhyBlock == NO_ASSIGN) {
+ for (i = 0; i < SECTSIZE; i++)
+ *buf++ = DUMMY_DATA;
+ return SMSUCCESS;
}
- for(retry=0; retry<2; retry++)
- {
- if (retry!=0)
- {
+ for (retry = 0; retry < 2; retry++) {
+ if (retry != 0) {
Ssfdc_D_Reset(us);
- if (Ssfdc_D_ReadCisSect(us,WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
- if (Check_D_CISdata(WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
+ if (Ssfdc_D_ReadCisSect(us, WorkBuf, WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange = ERROR;
+ return ERROR;
+ }
+ if (Check_D_CISdata(WorkBuf, WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange = ERROR;
+ return ERROR;
+ }
}
- //if (Ssfdc_D_ReadSect(fdoExt,buf,Redundant))
- if (Ssfdc_D_ReadBlock(us,count,buf,Redundant))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
- if (Check_D_DataStatus(Redundant))
- { ErrCode = ERR_DataStatus; return(ERROR); }
+ if (Ssfdc_D_ReadBlock(us, count, buf, Redundant)) {
+ ErrCode = ERR_HwError;
+ MediaChange = ERROR;
+ return ERROR;
+ }
+ if (Check_D_DataStatus(Redundant)) {
+ ErrCode = ERR_DataStatus;
+ return ERROR;
+ }
if (!Check_D_ReadError(Redundant))
- return(SMSUCCESS);
+ return SMSUCCESS;
- if (!Check_D_Correct(buf,Redundant))
- { ErrCode = ERR_CorReadErr; return(ERROR); }
+ if (!Check_D_Correct(buf, Redundant)) {
+ ErrCode = ERR_CorReadErr;
+ return ERROR;
+ }
}
ErrCode = ERR_EccReadErr;
- return(ERROR);
+ return ERROR;
}
-/*
-//----- Write_D_PhyOneSect() -------------------------------------------
-int Write_D_PhyOneSect(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf)
-{
- SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- ADDRESS_T bb = (ADDRESS_T) &Media;
-
- //if (Ssfdc_D_WriteSect(fdoExt,buf,Redundant))
- if (Ssfdc_D_WriteBlock(fdoExt,count,buf,Redundant))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
- if (Ssfdc_D_CheckStatus())
- { ErrCode = ERR_WriteFault; return(ERROR); }
- return(SMSUCCESS);
-}
-*/
-//----- Erase_D_PhyOneBlock() ------------------------------------------
-int Erase_D_PhyOneBlock(struct us_data *us)
+/* ----- Erase_D_PhyOneBlock() ------------------------------------------ */
+static int Erase_D_PhyOneBlock(struct us_data *us)
{
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
-
- if (Ssfdc_D_EraseBlock(us))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return(ERROR); }
- if (Ssfdc_D_CheckStatus())
- { ErrCode = ERR_WriteFault; return(ERROR); }
+ if (Ssfdc_D_EraseBlock(us)) {
+ ErrCode = ERR_HwError;
+ MediaChange = ERROR;
+ return ERROR;
+ }
+ if (Ssfdc_D_CheckStatus()) {
+ ErrCode = ERR_WriteFault;
+ return ERROR;
+ }
- return(SMSUCCESS);
+ return SMSUCCESS;
}
-//SmartMedia Physical Format Check Local Subroutine
-//----- Set_D_PhyFmtValue() --------------------------------------------
-int Set_D_PhyFmtValue(struct us_data *us)
+/* SmartMedia Physical Format Check Local Subroutine */
+/* ----- Set_D_PhyFmtValue() -------------------------------------------- */
+static int Set_D_PhyFmtValue(struct us_data *us)
{
-// PPDO_DEVICE_EXTENSION pdoExt;
-// BYTE idcode[4];
-// DWORD UserDefData_1, UserDefData_2, Data, mask;
-//
-// //if (!fdoExt->ChildDeviceObject) return(ERROR);
-// //pdoExt = fdoExt->ChildDeviceObject->DeviceExtension;
-//
-// Ssfdc_D_ReadID(idcode, READ_ID_1);
-//
- //if (Set_D_SsfdcModel(idcode[1]))
- if (Set_D_SsfdcModel(us->SM_DeviceID))
- return(ERROR);
-
-// //Use Multi-function pin to differentiate SM and xD.
-// UserDefData_1 = ReadPCIReg(fdoExt->BusID, fdoExt->DevID, fdoExt->FuncID, PCI_REG_USER_DEF) & 0x80;
-// if (UserDefData_1)
-// {
-// if ( READ_PORT_BYTE(SM_REG_INT_STATUS) & 0x80 ) fdoExt->DiskType = DISKTYPE_XD;
-// if ( READ_PORT_BYTE(SM_REG_INT_STATUS) & 0x40 ) fdoExt->DiskType = DISKTYPE_SM;
-//
-// if ( IsXDCompliance && (fdoExt->DiskType == DISKTYPE_XD) )
-// {
-// Ssfdc_D_ReadID(idcode, READ_ID_3);
-// if (idcode[2] != 0xB5)
-// return(ERROR);
-// }
-// }
-//
-// //Use GPIO to differentiate SM and xD.
-// UserDefData_2 = ReadPCIReg(fdoExt->BusID, fdoExt->DevID, fdoExt->FuncID, PCI_REG_USER_DEF) >> 8;
-// if ( UserDefData_2 )
-// {
-// Data = ReadPCIReg(fdoExt->BusID, fdoExt->DevID, 0, 0xAC);
-//
-// mask = 1 << (UserDefData_2-1);
-// // 1 : xD , 0 : SM
-// if ( Data & mask)
-// fdoExt->DiskType = DISKTYPE_XD;
-// else
-// fdoExt->DiskType = DISKTYPE_SM;
-//
-// if ( IsXDCompliance && (fdoExt->DiskType == DISKTYPE_XD) )
-// {
-// Ssfdc_D_ReadID(idcode, READ_ID_3);
-// if (idcode[2] != 0xB5)
-// return(ERROR);
-// }
-// }
-//
-// if ( !(UserDefData_1 | UserDefData_2) )
-// {
-// // Use UserDefine Register to differentiate SM and xD.
-// Ssfdc_D_ReadID(idcode, READ_ID_3);
-//
-// if (idcode[2] == 0xB5)
-// fdoExt->DiskType = DISKTYPE_XD;
-// else
-// {
-// if (!IsXDCompliance)
-// fdoExt->DiskType = DISKTYPE_SM;
-// else
-// return(ERROR);
-// }
-//
-// if (fdoExt->UserDef_DiskType == 0x04) fdoExt->DiskType = DISKTYPE_XD;
-// if (fdoExt->UserDef_DiskType == 0x08) fdoExt->DiskType = DISKTYPE_SM;
-// }
-//
-// if (!fdoExt->UserDef_DisableWP)
-// {
-// if (fdoExt->DiskType == DISKTYPE_SM)
-// {
-// if (Check_D_SsfdcWP())
-// Ssfdc.Attribute|=WP;
-// }
-// }
-
- return(SMSUCCESS);
+ if (Set_D_SsfdcModel(us->SM_DeviceID))
+ return ERROR;
+
+ return SMSUCCESS;
}
-//----- Search_D_CIS() -------------------------------------------------
-int Search_D_CIS(struct us_data *us)
+/* ----- Search_D_CIS() ------------------------------------------------- */
+static int Search_D_CIS(struct us_data *us)
{
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
+ Media.Zone = 0;
+ Media.Sector = 0;
- Media.Zone=0; Media.Sector=0;
-
- for (Media.PhyBlock=0; Media.PhyBlock<(Ssfdc.MaxBlocks-Ssfdc.MaxLogBlocks-1); Media.PhyBlock++)
- {
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- {
+ for (Media.PhyBlock = 0;
+ Media.PhyBlock < (Ssfdc.MaxBlocks - Ssfdc.MaxLogBlocks - 1);
+ Media.PhyBlock++) {
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
Ssfdc_D_Reset(us);
- return(ERROR);
+ return ERROR;
}
if (!Check_D_FailBlock(Redundant))
break;
}
- if (Media.PhyBlock==(Ssfdc.MaxBlocks-Ssfdc.MaxLogBlocks-1))
- {
+ if (Media.PhyBlock == (Ssfdc.MaxBlocks - Ssfdc.MaxLogBlocks - 1)) {
Ssfdc_D_Reset(us);
- return(ERROR);
+ return ERROR;
}
- while (Media.Sector<CIS_SEARCH_SECT)
- {
- if (Media.Sector)
- {
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- {
+ while (Media.Sector < CIS_SEARCH_SECT) {
+ if (Media.Sector) {
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
Ssfdc_D_Reset(us);
- return(ERROR);
+ return ERROR;
}
}
- if (!Check_D_DataStatus(Redundant))
- {
- if (Ssfdc_D_ReadSect(us,WorkBuf,Redundant))
- {
+ if (!Check_D_DataStatus(Redundant)) {
+ if (Ssfdc_D_ReadSect(us, WorkBuf, Redundant)) {
Ssfdc_D_Reset(us);
- return(ERROR);
+ return ERROR;
}
- if (Check_D_CISdata(WorkBuf,Redundant))
- {
+ if (Check_D_CISdata(WorkBuf, Redundant)) {
Ssfdc_D_Reset(us);
- return(ERROR);
+ return ERROR;
}
- CisArea.PhyBlock=Media.PhyBlock;
- CisArea.Sector=Media.Sector;
+ CisArea.PhyBlock = Media.PhyBlock;
+ CisArea.Sector = Media.Sector;
Ssfdc_D_Reset(us);
- return(SMSUCCESS);
+ return SMSUCCESS;
}
Media.Sector++;
}
Ssfdc_D_Reset(us);
- return(ERROR);
+ return ERROR;
}
-//----- Make_D_LogTable() ----------------------------------------------
-int Make_D_LogTable(struct us_data *us)
+/* ----- Make_D_LogTable() ---------------------------------------------- */
+static int Make_D_LogTable(struct us_data *us)
{
- WORD phyblock,logblock;
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
+ u16 phyblock, logblock;
- if (Log2Phy[Media.Zone]==NULL)
- {
- Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK*sizeof(WORD), GFP_KERNEL);
+ if (Log2Phy[Media.Zone] == NULL) {
+ Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK * sizeof(u16),
+ GFP_KERNEL);
/* pr_info("ExAllocatePool Zone = %x, Addr = %x\n",
Media.Zone, Log2Phy[Media.Zone]); */
- if (Log2Phy[Media.Zone]==NULL)
- return(ERROR);
+ if (Log2Phy[Media.Zone] == NULL)
+ return ERROR;
}
- Media.Sector=0;
-
- //for(Media.Zone=0; Media.Zone<MAX_ZONENUM; Media.Zone++)
- //for(Media.Zone=0; Media.Zone<Ssfdc.MaxZones; Media.Zone++)
- {
- /* pr_info("Make_D_LogTable --- MediaZone = 0x%x\n",
- Media.Zone); */
- for(Media.LogBlock=0; Media.LogBlock<Ssfdc.MaxLogBlocks; Media.LogBlock++)
- Log2Phy[Media.Zone][Media.LogBlock]=NO_ASSIGN;
-
- for(Media.PhyBlock=0; Media.PhyBlock<(MAX_BLOCKNUM/8); Media.PhyBlock++)
- Assign[Media.Zone][Media.PhyBlock]=0x00;
-
- for(Media.PhyBlock=0; Media.PhyBlock<Ssfdc.MaxBlocks; Media.PhyBlock++)
- {
- if ((!Media.Zone) && (Media.PhyBlock<=CisArea.PhyBlock))
- {
- Set_D_Bit(Assign[Media.Zone],Media.PhyBlock);
- continue;
- }
+ Media.Sector = 0;
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- { Ssfdc_D_Reset(us); return(ERROR); }
+ /* pr_info("Make_D_LogTable --- MediaZone = 0x%x\n",
+ Media.Zone); */
+ for (Media.LogBlock = 0; Media.LogBlock < Ssfdc.MaxLogBlocks;
+ Media.LogBlock++)
+ Log2Phy[Media.Zone][Media.LogBlock] = NO_ASSIGN;
+
+ for (Media.PhyBlock = 0; Media.PhyBlock < (MAX_BLOCKNUM / 8);
+ Media.PhyBlock++)
+ Assign[Media.Zone][Media.PhyBlock] = 0x00;
+
+ for (Media.PhyBlock = 0; Media.PhyBlock < Ssfdc.MaxBlocks;
+ Media.PhyBlock++) {
+ if ((!Media.Zone) && (Media.PhyBlock <= CisArea.PhyBlock)) {
+ Set_D_Bit(Assign[Media.Zone], Media.PhyBlock);
+ continue;
+ }
- if (!Check_D_DataBlank(Redundant))
- continue;
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
+ Ssfdc_D_Reset(us);
+ return ERROR;
+ }
- Set_D_Bit(Assign[Media.Zone],Media.PhyBlock);
+ if (!Check_D_DataBlank(Redundant))
+ continue;
- if (Check_D_FailBlock(Redundant))
- continue;
+ Set_D_Bit(Assign[Media.Zone], Media.PhyBlock);
- //if (Check_D_DataStatus(Redundant))
- // continue;
+ if (Check_D_FailBlock(Redundant))
+ continue;
- if (Load_D_LogBlockAddr(Redundant))
- continue;
+ if (Load_D_LogBlockAddr(Redundant))
+ continue;
- if (Media.LogBlock>=Ssfdc.MaxLogBlocks)
- continue;
+ if (Media.LogBlock >= Ssfdc.MaxLogBlocks)
+ continue;
- if (Log2Phy[Media.Zone][Media.LogBlock]==NO_ASSIGN)
- {
- Log2Phy[Media.Zone][Media.LogBlock]=Media.PhyBlock;
- continue;
+ if (Log2Phy[Media.Zone][Media.LogBlock] == NO_ASSIGN) {
+ Log2Phy[Media.Zone][Media.LogBlock] = Media.PhyBlock;
+ continue;
+ }
+
+ phyblock = Media.PhyBlock;
+ logblock = Media.LogBlock;
+ Media.Sector = (u8)(Ssfdc.MaxSectors - 1);
+
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
+ Ssfdc_D_Reset(us);
+ return ERROR;
+ }
+
+ if (!Load_D_LogBlockAddr(Redundant) &&
+ (Media.LogBlock == logblock)) {
+ Media.PhyBlock = Log2Phy[Media.Zone][logblock];
+
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
+ Ssfdc_D_Reset(us);
+ return ERROR;
}
- phyblock = Media.PhyBlock;
- logblock = Media.LogBlock;
- Media.Sector = (BYTE)(Ssfdc.MaxSectors-1);
-
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- { Ssfdc_D_Reset(us); return(ERROR); }
-
- if (!Load_D_LogBlockAddr(Redundant))
- {
- if (Media.LogBlock==logblock)
- {
- Media.PhyBlock=Log2Phy[Media.Zone][logblock];
-
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- { Ssfdc_D_Reset(us); return(ERROR); }
-
- Media.PhyBlock=phyblock;
-
- if (!Load_D_LogBlockAddr(Redundant))
- {
- if (Media.LogBlock!=logblock)
- {
- Media.PhyBlock=Log2Phy[Media.Zone][logblock];
- Log2Phy[Media.Zone][logblock]=phyblock;
- }
- }
- else
- {
- Media.PhyBlock=Log2Phy[Media.Zone][logblock];
- Log2Phy[Media.Zone][logblock]=phyblock;
- }
+ Media.PhyBlock = phyblock;
+
+ if (!Load_D_LogBlockAddr(Redundant)) {
+ if (Media.LogBlock != logblock) {
+ Media.PhyBlock =
+ Log2Phy[Media.Zone][logblock];
+ Log2Phy[Media.Zone][logblock] =
+ phyblock;
}
+ } else {
+ Media.PhyBlock = Log2Phy[Media.Zone][logblock];
+ Log2Phy[Media.Zone][logblock] = phyblock;
}
+ }
+
+ Media.Sector = 0;
+ Media.PhyBlock = phyblock;
+
+ AssignStart[Media.Zone] = 0;
- Media.Sector=0;
-
-// here Not yet
-//#ifdef L2P_ERR_ERASE
-// if (!(Ssfdc.Attribute &MWP))
-// {
-// Ssfdc_D_Reset(fdoExt);
-// if (Ssfdc_D_EraseBlock(fdoExt))
-// return(ERROR);
-//
-// if (Ssfdc_D_CheckStatus())
-// {
-// if (MarkFail_D_PhyOneBlock())
-// return(ERROR);
-// }
-// else
-// Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
-// }
-//#else
-// Ssfdc.Attribute|=MWP;
-//#endif
- Media.PhyBlock=phyblock;
-
- } // End for (Media.PhyBlock<Ssfdc.MaxBlocks)
-
- AssignStart[Media.Zone]=0;
-
- } // End for (Media.Zone<MAX_ZONENUM)
+ } /* End for (Media.Zone<MAX_ZONENUM) */
Ssfdc_D_Reset(us);
- return(SMSUCCESS);
+ return SMSUCCESS;
}
-//----- MarkFail_D_PhyOneBlock() ---------------------------------------
-int MarkFail_D_PhyOneBlock(struct us_data *us)
+/* ----- MarkFail_D_PhyOneBlock() --------------------------------------- */
+static int MarkFail_D_PhyOneBlock(struct us_data *us)
{
- BYTE sect;
- //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
- //ADDRESS_T bb = (ADDRESS_T) &Media;
+ u8 sect;
- sect=Media.Sector;
+ sect = Media.Sector;
Set_D_FailBlock(WorkRedund);
- //Ssfdc_D_WriteRedtMode();
- for(Media.Sector=0; Media.Sector<Ssfdc.MaxSectors; Media.Sector++)
- {
- if (Ssfdc_D_WriteRedtData(us, WorkRedund))
- {
+ for (Media.Sector = 0; Media.Sector < Ssfdc.MaxSectors;
+ Media.Sector++) {
+ if (Ssfdc_D_WriteRedtData(us, WorkRedund)) {
Ssfdc_D_Reset(us);
Media.Sector = sect;
ErrCode = ERR_HwError;
MediaChange = ERROR;
- return(ERROR);
- } // NO Status Check
+ return ERROR;
+ } /* NO Status Check */
}
Ssfdc_D_Reset(us);
- Media.Sector=sect;
- return(SMSUCCESS);
+ Media.Sector = sect;
+ return SMSUCCESS;
}
-/*
-//
-////----- SM_Init() ----------------------------------------------------
-//void SM_Init(void)
-//{
-// _Hw_D_ClrIntCardChg();
-// _Hw_D_SetIntMask();
-// // For DMA Interrupt
-// _Hw_D_ClrDMAIntCardChg();
-// _Hw_D_SetDMAIntMask();
-//}
-//
-////----- Media_D_EraseAllRedtData() -----------------------------------
-//int Media_D_EraseAllRedtData(DWORD Index, BOOLEAN CheckBlock)
-//{
-// BYTE i;
-//
-// if (Check_D_MediaPower())
-// return(ErrCode);
-//
-// if (Check_D_MediaWP())
-// return(ErrCode);
-//
-// for (i=0; i<REDTSIZE; i++)
-// WorkRedund[i] = 0xFF;
-//
-// Media.Zone = (BYTE)Index;
-// for (Media.PhyBlock=0; Media.PhyBlock<Ssfdc.MaxBlocks; Media.PhyBlock++)
-// {
-// if ((!Media.Zone) && (Media.PhyBlock<=CisArea.PhyBlock))
-// continue;
-//
-// if (Ssfdc_D_EraseBlock(fdoExt))
-// {
-// ErrCode = ERR_HwError;
-// return(ERROR);
-// }
-//
-// for(Media.Sector=0; Media.Sector<Ssfdc.MaxSectors; Media.Sector++)
-// {
-// Ssfdc_D_WriteRedtMode();
-//
-// if (Ssfdc_D_WriteRedtData(WorkRedund))
-// {
-// Ssfdc_D_Reset(fdoExt);
-// ErrCode = ERR_HwError;
-// MediaChange = ERROR;
-// return(ERROR);
-// } // NO Status Check
-// }
-//
-// Ssfdc_D_Reset(fdoExt);
-// }
-//
-// Ssfdc_D_Reset(fdoExt);
-//
-// return(SMSUCCESS);
-//}
-//
-////----- Media_D_GetMediaInfo() ---------------------------------------
-//DWORD Media_D_GetMediaInfo(PFDO_DEVICE_EXTENSION fdoExt, PIOCTL_MEDIA_INFO_IN pParamIn, PIOCTL_MEDIA_INFO_OUT pParamOut)
-//{
-// pParamOut->ErrCode = STATUS_CMD_FAIL;
-//
-// Init_D_SmartMedia();
-//
-// if (Check_D_MediaPower())
-// return (ErrCode==ERR_NoSmartMedia) ? STATUS_CMD_NO_MEDIA : STATUS_CMD_FAIL;
-//
-// if (Set_D_PhyFmtValue(fdoExt))
-// return STATUS_CMD_FAIL;
-//
-// //usleep(56*1024);
-// if (Search_D_CIS(fdoExt))
-// return STATUS_CMD_FAIL;
-//
-// if (Check_D_MediaWP())
-// return STATUS_CMD_MEDIA_WP;
-//
-// pParamOut->PageSize = Ssfdc.MaxSectors;
-// pParamOut->BlockSize = Ssfdc.MaxBlocks;
-// pParamOut->ZoneSize = Ssfdc.MaxZones;
-//
-// return STATUS_CMD_SUCCESS;
-//}*/
diff --git a/drivers/staging/keucr/smilsub.c b/drivers/staging/keucr/smilsub.c
index d4dd5ed516c..e981f14f3bf 100644
--- a/drivers/staging/keucr/smilsub.c
+++ b/drivers/staging/keucr/smilsub.c
@@ -6,45 +6,16 @@
#include "smcommon.h"
#include "smil.h"
-void _Set_D_SsfdcRdCmd(BYTE);
-void _Set_D_SsfdcRdAddr(BYTE);
-void _Set_D_SsfdcRdChip(void);
-void _Set_D_SsfdcRdStandby(void);
-void _Start_D_SsfdcRdHwECC(void);
-void _Stop_D_SsfdcRdHwECC(void);
-void _Load_D_SsfdcRdHwECC(BYTE);
-void _Set_D_SsfdcWrCmd(BYTE);
-void _Set_D_SsfdcWrAddr(BYTE);
-void _Set_D_SsfdcWrBlock(void);
-void _Set_D_SsfdcWrStandby(void);
-void _Start_D_SsfdcWrHwECC(void);
-void _Load_D_SsfdcWrHwECC(BYTE);
-int _Check_D_SsfdcBusy(WORD);
-int _Check_D_SsfdcStatus(void);
-void _Reset_D_SsfdcErr(void);
-void _Read_D_SsfdcBuf(BYTE *);
-void _Write_D_SsfdcBuf(BYTE *);
-void _Read_D_SsfdcByte(BYTE *);
-void _ReadRedt_D_SsfdcBuf(BYTE *);
-void _WriteRedt_D_SsfdcBuf(BYTE *);
-BYTE _Check_D_DevCode(BYTE);
-
-void _Set_D_ECCdata(BYTE, BYTE *);
-void _Calc_D_ECCdata(BYTE *);
-
-
-struct SSFDCTYPE Ssfdc;
-struct ADDRESS Media;
-struct CIS_AREA CisArea;
-
-static BYTE EccBuf[6];
-extern PBYTE SMHostAddr;
-extern DWORD ErrXDCode;
-
-extern WORD ReadBlock;
-extern WORD WriteBlock;
+static u8 _Check_D_DevCode(u8);
+static u32 ErrXDCode;
+static u8 IsSSFDCCompliance;
+static u8 IsXDCompliance;
+struct keucr_media_info Ssfdc;
+struct keucr_media_address Media;
+struct keucr_media_area CisArea;
+static u8 EccBuf[6];
#define EVEN 0 /* Even Page for 256byte/page */
#define ODD 1 /* Odd Page for 256byte/page */
@@ -53,7 +24,7 @@ extern WORD WriteBlock;
/* SmartMedia Redundant buffer data Control Subroutine
*----- Check_D_DataBlank() --------------------------------------------
*/
-int Check_D_DataBlank(BYTE *redundant)
+int Check_D_DataBlank(u8 *redundant)
{
char i;
@@ -65,7 +36,7 @@ int Check_D_DataBlank(BYTE *redundant)
}
/* ----- Check_D_FailBlock() -------------------------------------------- */
-int Check_D_FailBlock(BYTE *redundant)
+int Check_D_FailBlock(u8 *redundant)
{
redundant += REDT_BLOCK;
@@ -80,7 +51,7 @@ int Check_D_FailBlock(BYTE *redundant)
}
/* ----- Check_D_DataStatus() ------------------------------------------- */
-int Check_D_DataStatus(BYTE *redundant)
+int Check_D_DataStatus(u8 *redundant)
{
redundant += REDT_DATA;
@@ -99,12 +70,14 @@ int Check_D_DataStatus(BYTE *redundant)
}
/* ----- Load_D_LogBlockAddr() ------------------------------------------ */
-int Load_D_LogBlockAddr(BYTE *redundant)
+int Load_D_LogBlockAddr(u8 *redundant)
{
- WORD addr1, addr2;
+ u16 addr1, addr2;
- addr1 = (WORD)*(redundant + REDT_ADDR1H)*0x0100 + (WORD)*(redundant + REDT_ADDR1L);
- addr2 = (WORD)*(redundant + REDT_ADDR2H)*0x0100 + (WORD)*(redundant + REDT_ADDR2L);
+ addr1 = (u16)*(redundant + REDT_ADDR1H)*0x0100 +
+ (u16)*(redundant + REDT_ADDR1L);
+ addr2 = (u16)*(redundant + REDT_ADDR2H)*0x0100 +
+ (u16)*(redundant + REDT_ADDR2L);
if (addr1 == addr2)
if ((addr1 & 0xF000) == 0x1000) {
@@ -112,7 +85,7 @@ int Load_D_LogBlockAddr(BYTE *redundant)
return SMSUCCESS;
}
- if (hweight16((WORD)(addr1^addr2)) != 0x01)
+ if (hweight16((u16)(addr1^addr2)) != 0x01)
return ERROR;
if ((addr1 & 0xF000) == 0x1000)
@@ -131,7 +104,7 @@ int Load_D_LogBlockAddr(BYTE *redundant)
}
/* ----- Clr_D_RedundantData() ------------------------------------------ */
-void Clr_D_RedundantData(BYTE *redundant)
+void Clr_D_RedundantData(u8 *redundant)
{
char i;
@@ -140,9 +113,9 @@ void Clr_D_RedundantData(BYTE *redundant)
}
/* ----- Set_D_LogBlockAddr() ------------------------------------------- */
-void Set_D_LogBlockAddr(BYTE *redundant)
+void Set_D_LogBlockAddr(u8 *redundant)
{
- WORD addr;
+ u16 addr;
*(redundant + REDT_BLOCK) = 0xFF;
*(redundant + REDT_DATA) = 0xFF;
@@ -151,20 +124,22 @@ void Set_D_LogBlockAddr(BYTE *redundant)
if ((hweight16(addr) % 2))
addr++;
- *(redundant + REDT_ADDR1H) = *(redundant + REDT_ADDR2H) = (BYTE)(addr / 0x0100);
- *(redundant + REDT_ADDR1L) = *(redundant + REDT_ADDR2L) = (BYTE)addr;
+ *(redundant + REDT_ADDR1H) = *(redundant + REDT_ADDR2H) =
+ (u8)(addr / 0x0100);
+ *(redundant + REDT_ADDR1L) = *(redundant + REDT_ADDR2L) = (u8)addr;
}
/*----- Set_D_FailBlock() ---------------------------------------------- */
-void Set_D_FailBlock(BYTE *redundant)
+void Set_D_FailBlock(u8 *redundant)
{
char i;
+
for (i = 0; i < REDTSIZE; i++)
- *redundant++ = (BYTE)((i == REDT_BLOCK) ? 0xF0 : 0xFF);
+ *redundant++ = (u8)((i == REDT_BLOCK) ? 0xF0 : 0xFF);
}
/* ----- Set_D_DataStaus() ---------------------------------------------- */
-void Set_D_DataStaus(BYTE *redundant)
+void Set_D_DataStaus(u8 *redundant)
{
redundant += REDT_DATA;
*redundant = 0x00;
@@ -180,10 +155,10 @@ void Ssfdc_D_Reset(struct us_data *us)
}
/* ----- Ssfdc_D_ReadCisSect() ------------------------------------------ */
-int Ssfdc_D_ReadCisSect(struct us_data *us, BYTE *buf, BYTE *redundant)
+int Ssfdc_D_ReadCisSect(struct us_data *us, u8 *buf, u8 *redundant)
{
- BYTE zone, sector;
- WORD block;
+ u8 zone, sector;
+ u16 block;
zone = Media.Zone; block = Media.PhyBlock; sector = Media.Sector;
Media.Zone = 0;
@@ -191,7 +166,9 @@ int Ssfdc_D_ReadCisSect(struct us_data *us, BYTE *buf, BYTE *redundant)
Media.Sector = CisArea.Sector;
if (Ssfdc_D_ReadSect(us, buf, redundant)) {
- Media.Zone = zone; Media.PhyBlock = block; Media.Sector = sector;
+ Media.Zone = zone;
+ Media.PhyBlock = block;
+ Media.Sector = sector;
return ERROR;
}
@@ -201,20 +178,21 @@ int Ssfdc_D_ReadCisSect(struct us_data *us, BYTE *buf, BYTE *redundant)
/* 6250 CMD 1 */
/* ----- Ssfdc_D_ReadSect() --------------------------------------------- */
-int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf, BYTE *redundant)
+int Ssfdc_D_ReadSect(struct us_data *us, u8 *buf, u8 *redundant)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
- WORD addr;
+ u16 addr;
result = ENE_LoadBinCode(us, SM_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
- printk("Load SM RW Code Fail !!\n");
+ dev_err(&us->pusb_dev->dev,
+ "Failed to load SmartMedia read/write code\n");
return USB_STOR_TRANSPORT_ERROR;
}
- addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
- addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector;
+ addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
+ addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
/* Read sect data */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
@@ -223,8 +201,8 @@ int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf, BYTE *redundant)
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x02;
- bcb->CDB[4] = (BYTE)addr;
- bcb->CDB[3] = (BYTE)(addr / 0x0100);
+ bcb->CDB[4] = (u8)addr;
+ bcb->CDB[3] = (u8)(addr / 0x0100);
bcb->CDB[2] = Media.Zone / 2;
result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
@@ -238,8 +216,8 @@ int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf, BYTE *redundant)
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x03;
- bcb->CDB[4] = (BYTE)addr;
- bcb->CDB[3] = (BYTE)(addr / 0x0100);
+ bcb->CDB[4] = (u8)addr;
+ bcb->CDB[3] = (u8)(addr / 0x0100);
bcb->CDB[2] = Media.Zone / 2;
bcb->CDB[8] = 0;
bcb->CDB[9] = 1;
@@ -252,20 +230,22 @@ int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf, BYTE *redundant)
}
/* ----- Ssfdc_D_ReadBlock() --------------------------------------------- */
-int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant)
+int Ssfdc_D_ReadBlock(struct us_data *us, u16 count, u8 *buf,
+ u8 *redundant)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
- WORD addr;
+ u16 addr;
result = ENE_LoadBinCode(us, SM_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
- printk("Load SM RW Code Fail !!\n");
+ dev_err(&us->pusb_dev->dev,
+ "Failed to load SmartMedia read/write code\n");
return USB_STOR_TRANSPORT_ERROR;
}
- addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
- addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector;
+ addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
+ addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
/* Read sect data */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
@@ -274,8 +254,8 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x02;
- bcb->CDB[4] = (BYTE)addr;
- bcb->CDB[3] = (BYTE)(addr / 0x0100);
+ bcb->CDB[4] = (u8)addr;
+ bcb->CDB[3] = (u8)(addr / 0x0100);
bcb->CDB[2] = Media.Zone / 2;
result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
@@ -289,8 +269,8 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x03;
- bcb->CDB[4] = (BYTE)addr;
- bcb->CDB[3] = (BYTE)(addr / 0x0100);
+ bcb->CDB[4] = (u8)addr;
+ bcb->CDB[3] = (u8)(addr / 0x0100);
bcb->CDB[2] = Media.Zone / 2;
bcb->CDB[8] = 0;
bcb->CDB[9] = 1;
@@ -304,22 +284,24 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant
/* ----- Ssfdc_D_CopyBlock() -------------------------------------------- */
-int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant)
+int Ssfdc_D_CopyBlock(struct us_data *us, u16 count, u8 *buf,
+ u8 *redundant)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
- WORD ReadAddr, WriteAddr;
+ u16 ReadAddr, WriteAddr;
result = ENE_LoadBinCode(us, SM_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
- printk("Load SM RW Code Fail !!\n");
+ dev_err(&us->pusb_dev->dev,
+ "Failed to load SmartMedia read/write code\n");
return USB_STOR_TRANSPORT_ERROR;
}
- ReadAddr = (WORD)Media.Zone*Ssfdc.MaxBlocks + ReadBlock;
- ReadAddr = ReadAddr*(WORD)Ssfdc.MaxSectors;
- WriteAddr = (WORD)Media.Zone*Ssfdc.MaxBlocks + WriteBlock;
- WriteAddr = WriteAddr*(WORD)Ssfdc.MaxSectors;
+ ReadAddr = (u16)Media.Zone*Ssfdc.MaxBlocks + ReadBlock;
+ ReadAddr = ReadAddr*(u16)Ssfdc.MaxSectors;
+ WriteAddr = (u16)Media.Zone*Ssfdc.MaxBlocks + WriteBlock;
+ WriteAddr = WriteAddr*(u16)Ssfdc.MaxSectors;
/* Write sect data */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
@@ -328,16 +310,16 @@ int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant
bcb->Flags = 0x00;
bcb->CDB[0] = 0xF0;
bcb->CDB[1] = 0x08;
- bcb->CDB[7] = (BYTE)WriteAddr;
- bcb->CDB[6] = (BYTE)(WriteAddr / 0x0100);
+ bcb->CDB[7] = (u8)WriteAddr;
+ bcb->CDB[6] = (u8)(WriteAddr / 0x0100);
bcb->CDB[5] = Media.Zone / 2;
bcb->CDB[8] = *(redundant + REDT_ADDR1H);
bcb->CDB[9] = *(redundant + REDT_ADDR1L);
bcb->CDB[10] = Media.Sector;
if (ReadBlock != NO_ASSIGN) {
- bcb->CDB[4] = (BYTE)ReadAddr;
- bcb->CDB[3] = (BYTE)(ReadAddr / 0x0100);
+ bcb->CDB[4] = (u8)ReadAddr;
+ bcb->CDB[3] = (u8)(ReadAddr / 0x0100);
bcb->CDB[2] = Media.Zone / 2;
} else
bcb->CDB[11] = 1;
@@ -350,21 +332,22 @@ int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant
}
/* ----- Ssfdc_D_WriteSectForCopy() ------------------------------------- */
-int Ssfdc_D_WriteSectForCopy(struct us_data *us, BYTE *buf, BYTE *redundant)
+int Ssfdc_D_WriteSectForCopy(struct us_data *us, u8 *buf, u8 *redundant)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
- WORD addr;
+ u16 addr;
result = ENE_LoadBinCode(us, SM_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
- printk("Load SM RW Code Fail !!\n");
+ dev_err(&us->pusb_dev->dev,
+ "Failed to load SmartMedia read/write code\n");
return USB_STOR_TRANSPORT_ERROR;
}
- addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
- addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector;
+ addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
+ addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
/* Write sect data */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
@@ -373,8 +356,8 @@ int Ssfdc_D_WriteSectForCopy(struct us_data *us, BYTE *buf, BYTE *redundant)
bcb->Flags = 0x00;
bcb->CDB[0] = 0xF0;
bcb->CDB[1] = 0x04;
- bcb->CDB[7] = (BYTE)addr;
- bcb->CDB[6] = (BYTE)(addr / 0x0100);
+ bcb->CDB[7] = (u8)addr;
+ bcb->CDB[6] = (u8)(addr / 0x0100);
bcb->CDB[5] = Media.Zone / 2;
bcb->CDB[8] = *(redundant + REDT_ADDR1H);
bcb->CDB[9] = *(redundant + REDT_ADDR1L);
@@ -392,16 +375,17 @@ int Ssfdc_D_EraseBlock(struct us_data *us)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
- WORD addr;
+ u16 addr;
result = ENE_LoadBinCode(us, SM_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
- printk("Load SM RW Code Fail !!\n");
+ dev_err(&us->pusb_dev->dev,
+ "Failed to load SmartMedia read/write code\n");
return USB_STOR_TRANSPORT_ERROR;
}
- addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
- addr = addr*(WORD)Ssfdc.MaxSectors;
+ addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
+ addr = addr*(u16)Ssfdc.MaxSectors;
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
@@ -409,8 +393,8 @@ int Ssfdc_D_EraseBlock(struct us_data *us)
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF2;
bcb->CDB[1] = 0x06;
- bcb->CDB[7] = (BYTE)addr;
- bcb->CDB[6] = (BYTE)(addr / 0x0100);
+ bcb->CDB[7] = (u8)addr;
+ bcb->CDB[6] = (u8)(addr / 0x0100);
bcb->CDB[5] = Media.Zone / 2;
result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0);
@@ -422,21 +406,22 @@ int Ssfdc_D_EraseBlock(struct us_data *us)
/* 6250 CMD 2 */
/*----- Ssfdc_D_ReadRedtData() ----------------------------------------- */
-int Ssfdc_D_ReadRedtData(struct us_data *us, BYTE *redundant)
+int Ssfdc_D_ReadRedtData(struct us_data *us, u8 *redundant)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
- WORD addr;
- BYTE *buf;
+ u16 addr;
+ u8 *buf;
result = ENE_LoadBinCode(us, SM_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
- printk("Load SM RW Code Fail !!\n");
+ dev_err(&us->pusb_dev->dev,
+ "Failed to load SmartMedia read/write code\n");
return USB_STOR_TRANSPORT_ERROR;
}
- addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
- addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector;
+ addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
+ addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
@@ -444,8 +429,8 @@ int Ssfdc_D_ReadRedtData(struct us_data *us, BYTE *redundant)
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x03;
- bcb->CDB[4] = (BYTE)addr;
- bcb->CDB[3] = (BYTE)(addr / 0x0100);
+ bcb->CDB[4] = (u8)addr;
+ bcb->CDB[3] = (u8)(addr / 0x0100);
bcb->CDB[2] = Media.Zone / 2;
bcb->CDB[8] = 0;
bcb->CDB[9] = 1;
@@ -462,20 +447,21 @@ int Ssfdc_D_ReadRedtData(struct us_data *us, BYTE *redundant)
/* 6250 CMD 4 */
/* ----- Ssfdc_D_WriteRedtData() ---------------------------------------- */
-int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant)
+int Ssfdc_D_WriteRedtData(struct us_data *us, u8 *redundant)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
- WORD addr;
+ u16 addr;
result = ENE_LoadBinCode(us, SM_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
- printk("Load SM RW Code Fail !!\n");
+ dev_err(&us->pusb_dev->dev,
+ "Failed to load SmartMedia read/write code\n");
return USB_STOR_TRANSPORT_ERROR;
}
- addr = (WORD)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
- addr = addr*(WORD)Ssfdc.MaxSectors + Media.Sector;
+ addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
+ addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
@@ -483,8 +469,8 @@ int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant)
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF2;
bcb->CDB[1] = 0x05;
- bcb->CDB[7] = (BYTE)addr;
- bcb->CDB[6] = (BYTE)(addr / 0x0100);
+ bcb->CDB[7] = (u8)addr;
+ bcb->CDB[6] = (u8)(addr / 0x0100);
bcb->CDB[5] = Media.Zone / 2;
bcb->CDB[8] = *(redundant + REDT_ADDR1H);
bcb->CDB[9] = *(redundant + REDT_ADDR1L);
@@ -507,7 +493,7 @@ int Ssfdc_D_CheckStatus(void)
/* SmartMedia ID Code Check & Mode Set Subroutine
* ----- Set_D_SsfdcModel() ---------------------------------------------
*/
-int Set_D_SsfdcModel(BYTE dcode)
+int Set_D_SsfdcModel(u8 dcode)
{
switch (_Check_D_DevCode(dcode)) {
case SSFDC1MB:
@@ -611,11 +597,11 @@ int Set_D_SsfdcModel(BYTE dcode)
return ERROR;
}
- return SMSUCCESS;
+ return SMSUCCESS;
}
/* ----- _Check_D_DevCode() --------------------------------------------- */
-BYTE _Check_D_DevCode(BYTE dcode)
+static u8 _Check_D_DevCode(u8 dcode)
{
switch (dcode) {
case 0x6E:
@@ -645,21 +631,21 @@ BYTE _Check_D_DevCode(BYTE dcode)
/* SmartMedia ECC Control Subroutine
* ----- Check_D_ReadError() ----------------------------------------------
*/
-int Check_D_ReadError(BYTE *redundant)
+int Check_D_ReadError(u8 *redundant)
{
return SMSUCCESS;
}
/* ----- Check_D_Correct() ---------------------------------------------- */
-int Check_D_Correct(BYTE *buf, BYTE *redundant)
+int Check_D_Correct(u8 *buf, u8 *redundant)
{
return SMSUCCESS;
}
/* ----- Check_D_CISdata() ---------------------------------------------- */
-int Check_D_CISdata(BYTE *buf, BYTE *redundant)
+int Check_D_CISdata(u8 *buf, u8 *redundant)
{
- BYTE cis[] = {0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02,
+ u8 cis[] = {0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02,
0xDF, 0x01, 0x20};
int cis_len = sizeof(cis);
@@ -684,10 +670,10 @@ int Check_D_CISdata(BYTE *buf, BYTE *redundant)
}
/* ----- Set_D_RightECC() ---------------------------------------------- */
-void Set_D_RightECC(BYTE *redundant)
+void Set_D_RightECC(u8 *redundant)
{
- /* Driver ECC Check */
- return;
+ /* Driver ECC Check */
+ return;
}
diff --git a/drivers/staging/keucr/smscsi.c b/drivers/staging/keucr/smscsi.c
index 58b55557118..20858f6777c 100644
--- a/drivers/staging/keucr/smscsi.c
+++ b/drivers/staging/keucr/smscsi.c
@@ -11,16 +11,12 @@
#include "transport.h"
#include "smil.h"
-int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb);
-int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb);
-int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb);
-int SM_SCSI_Start_Stop(struct us_data *us, struct scsi_cmnd *srb);
-int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb);
-int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb);
-int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb);
-
-extern PBYTE SMHostAddr;
-extern DWORD ErrXDCode;
+static int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb);
+static int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb);
+static int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb);
+static int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb);
+static int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb);
+static int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb);
/* ----- SM_SCSIIrp() -------------------------------------------------- */
int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
@@ -56,8 +52,8 @@ int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
return result;
}
-/* ----- SM_SCSI_Test_Unit_Ready() -------------------------------------------------- */
-int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
+/* ----- SM_SCSI_Test_Unit_Ready() ------------------------------------- */
+static int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
{
if (us->SM_Status.Insert && us->SM_Status.Ready)
return USB_STOR_TRANSPORT_GOOD;
@@ -69,21 +65,27 @@ int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
return USB_STOR_TRANSPORT_GOOD;
}
-/* ----- SM_SCSI_Inquiry() -------------------------------------------------- */
-int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
+/* ----- SM_SCSI_Inquiry() --------------------------------------------- */
+static int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
{
- BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
+ u8 data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00,
+ 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20,
+ 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65,
+ 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
-/* ----- SM_SCSI_Mode_Sense() -------------------------------------------------- */
-int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
+/* ----- SM_SCSI_Mode_Sense() ------------------------------------------ */
+static int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
{
- BYTE mediaNoWP[12] = {0x0b, 0x00, 0x00, 0x08, 0x00, 0x00, 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
- BYTE mediaWP[12] = {0x0b, 0x00, 0x80, 0x08, 0x00, 0x00, 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
+ u8 mediaNoWP[12] = {0x0b, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
+ u8 mediaWP[12] = {0x0b, 0x00, 0x80, 0x08, 0x00, 0x00,
+ 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
if (us->SM_Status.WtP)
usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
@@ -94,23 +96,23 @@ int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
return USB_STOR_TRANSPORT_GOOD;
}
-/* ----- SM_SCSI_Read_Capacity() -------------------------------------------------- */
-int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
+/* ----- SM_SCSI_Read_Capacity() --------------------------------------- */
+static int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
{
unsigned int offset = 0;
struct scatterlist *sg = NULL;
- DWORD bl_num;
- WORD bl_len;
- BYTE buf[8];
+ u32 bl_num;
+ u16 bl_len;
+ u8 buf[8];
- printk("SM_SCSI_Read_Capacity\n");
+ dev_dbg(&us->pusb_dev->dev, "SM_SCSI_Read_Capacity\n");
bl_len = 0x200;
bl_num = Ssfdc.MaxLogBlocks * Ssfdc.MaxSectors * Ssfdc.MaxZones - 1;
us->bl_num = bl_num;
- printk("bl_len = %x\n", bl_len);
- printk("bl_num = %x\n", bl_num);
+ dev_dbg(&us->pusb_dev->dev, "bl_len = %x\n", bl_len);
+ dev_dbg(&us->pusb_dev->dev, "bl_num = %x\n", bl_num);
buf[0] = (bl_num >> 24) & 0xff;
buf[1] = (bl_num >> 16) & 0xff;
@@ -127,14 +129,16 @@ int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
}
/* ----- SM_SCSI_Read() -------------------------------------------------- */
-int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
+static int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
{
int result = 0;
- PBYTE Cdb = srb->cmnd;
- DWORD bn = ((Cdb[2] << 24) & 0xff000000) | ((Cdb[3] << 16) & 0x00ff0000) |
- ((Cdb[4] << 8) & 0x0000ff00) | ((Cdb[5] << 0) & 0x000000ff);
- WORD blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
- DWORD blenByte = blen * 0x200;
+ u8 *Cdb = srb->cmnd;
+ u32 bn = ((Cdb[2] << 24) & 0xff000000) |
+ ((Cdb[3] << 16) & 0x00ff0000) |
+ ((Cdb[4] << 8) & 0x0000ff00) |
+ ((Cdb[5] << 0) & 0x000000ff);
+ u16 blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
+ u32 blenByte = blen * 0x200;
void *buf;
@@ -157,14 +161,16 @@ int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
}
/* ----- SM_SCSI_Write() -------------------------------------------------- */
-int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
+static int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
{
int result = 0;
- PBYTE Cdb = srb->cmnd;
- DWORD bn = ((Cdb[2] << 24) & 0xff000000) | ((Cdb[3] << 16) & 0x00ff0000) |
- ((Cdb[4] << 8) & 0x0000ff00) | ((Cdb[5] << 0) & 0x000000ff);
- WORD blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
- DWORD blenByte = blen * 0x200;
+ u8 *Cdb = srb->cmnd;
+ u32 bn = ((Cdb[2] << 24) & 0xff000000) |
+ ((Cdb[3] << 16) & 0x00ff0000) |
+ ((Cdb[4] << 8) & 0x0000ff00) |
+ ((Cdb[5] << 0) & 0x000000ff);
+ u16 blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
+ u32 blenByte = blen * 0x200;
void *buf;
diff --git a/drivers/staging/keucr/transport.c b/drivers/staging/keucr/transport.c
index 1a8837df076..5e59525271f 100644
--- a/drivers/staging/keucr/transport.c
+++ b/drivers/staging/keucr/transport.c
@@ -79,6 +79,47 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
}
/*
+ * usb_stor_print_cmd():
+ */
+static void usb_stor_print_cmd(struct us_data *us, struct scsi_cmnd *srb)
+{
+ u8 *Cdb = srb->cmnd;
+ u32 cmd = Cdb[0];
+
+ switch (cmd) {
+ case TEST_UNIT_READY:
+ break;
+ case INQUIRY:
+ dev_dbg(&us->pusb_dev->dev,
+ "scsi cmd %X --- SCSIOP_INQUIRY\n", cmd);
+ break;
+ case MODE_SENSE:
+ dev_dbg(&us->pusb_dev->dev,
+ "scsi cmd %X --- SCSIOP_MODE_SENSE\n", cmd);
+ break;
+ case START_STOP:
+ dev_dbg(&us->pusb_dev->dev,
+ "scsi cmd %X --- SCSIOP_START_STOP\n", cmd);
+ break;
+ case READ_CAPACITY:
+ dev_dbg(&us->pusb_dev->dev,
+ "scsi cmd %X --- SCSIOP_READ_CAPACITY\n", cmd);
+ break;
+ case READ_10:
+ break;
+ case WRITE_10:
+ break;
+ case ALLOW_MEDIUM_REMOVAL:
+ dev_dbg(&us->pusb_dev->dev,
+ "scsi cmd %X --- SCSIOP_ALLOW_MEDIUM_REMOVAL\n", cmd);
+ break;
+ default:
+ dev_dbg(&us->pusb_dev->dev, "scsi cmd %X --- Other cmd\n", cmd);
+ break;
+ }
+}
+
+/*
* usb_stor_control_msg()
*/
int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
@@ -303,7 +344,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
int result;
/* pr_info("transport --- usb_stor_invoke_transport\n"); */
- usb_stor_print_cmd(srb);
+ usb_stor_print_cmd(us, srb);
/* send the command to the transport layer */
scsi_set_resid(srb, 0);
result = us->transport(srb, us); /* usb_stor_Bulk_transport; */
@@ -429,7 +470,7 @@ void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
int result = 0;
/* pr_info("transport --- ENE_stor_invoke_transport\n"); */
- usb_stor_print_cmd(srb);
+ usb_stor_print_cmd(us, srb);
/* send the command to the transport layer */
scsi_set_resid(srb, 0);
if (!(us->SM_Status.Ready))
@@ -504,8 +545,8 @@ Handle_Errors:
*/
void BuildSenseBuffer(struct scsi_cmnd *srb, int SrbStatus)
{
- BYTE *buf = srb->sense_buffer;
- BYTE asc;
+ u8 *buf = srb->sense_buffer;
+ u8 asc;
pr_info("transport --- BuildSenseBuffer\n");
switch (SrbStatus) {
@@ -628,6 +669,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
/* R/W data */
if (transfer_length) {
unsigned int pipe;
+
if (srb->sc_data_direction == DMA_FROM_DEVICE)
pipe = us->recv_bulk_pipe;
else
@@ -708,8 +750,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
} else {
residue = min(residue, transfer_length);
- scsi_set_resid(srb, max(scsi_get_resid(srb),
- (int) residue));
+ scsi_set_resid(srb, max_t(int, scsi_get_resid(srb),
+ residue));
}
}
diff --git a/drivers/staging/keucr/transport.h b/drivers/staging/keucr/transport.h
index 2a11a98375d..abd8e5a3dd6 100644
--- a/drivers/staging/keucr/transport.h
+++ b/drivers/staging/keucr/transport.h
@@ -29,7 +29,6 @@
extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
extern int usb_stor_Bulk_max_lun(struct us_data *);
extern int usb_stor_Bulk_reset(struct us_data *);
-extern void usb_stor_print_cmd(struct scsi_cmnd *);
extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
extern void usb_stor_stop_transport(struct us_data *);
extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
@@ -59,9 +58,9 @@ extern void usb_stor_set_xfer_buf(struct us_data*, unsigned char *buffer,
extern void ENE_stor_invoke_transport(struct scsi_cmnd *, struct us_data *);
extern int ENE_InitMedia(struct us_data *);
extern int ENE_SMInit(struct us_data *);
-extern int ENE_SendScsiCmd(struct us_data*, BYTE, void*, int);
-extern int ENE_LoadBinCode(struct us_data*, BYTE);
-extern int ENE_Read_BYTE(struct us_data*, WORD index, void *buf);
+extern int ENE_SendScsiCmd(struct us_data*, u8, void*, int);
+extern int ENE_LoadBinCode(struct us_data*, u8);
+extern int ene_read_byte(struct us_data*, u16 index, void *buf);
extern int ENE_Read_Data(struct us_data*, void *buf, unsigned int length);
extern int ENE_Write_Data(struct us_data*, void *buf, unsigned int length);
extern void BuildSenseBuffer(struct scsi_cmnd *, int);
diff --git a/drivers/staging/keucr/usb.c b/drivers/staging/keucr/usb.c
index 55a0b82c639..12ebde7315c 100644
--- a/drivers/staging/keucr/usb.c
+++ b/drivers/staging/keucr/usb.c
@@ -2,7 +2,6 @@
#include <linux/errno.h>
#include <linux/freezer.h>
#include <linux/module.h>
-#include <linux/init.h>
#include <linux/slab.h>
#include <linux/kthread.h>
#include <linux/mutex.h>
@@ -24,13 +23,13 @@ MODULE_LICENSE("GPL");
static unsigned int delay_use = 1;
-static struct usb_device_id eucr_usb_ids [] = {
+static struct usb_device_id eucr_usb_ids[] = {
{ USB_DEVICE(0x058f, 0x6366) },
{ USB_DEVICE(0x0cf2, 0x6230) },
{ USB_DEVICE(0x0cf2, 0x6250) },
{ } /* Terminating entry */
};
-MODULE_DEVICE_TABLE (usb, eucr_usb_ids);
+MODULE_DEVICE_TABLE(usb, eucr_usb_ids);
#ifdef CONFIG_PM
@@ -42,65 +41,55 @@ static int eucr_suspend(struct usb_interface *iface, pm_message_t message)
/* Wait until no command is running */
mutex_lock(&us->dev_mutex);
- //US_DEBUGP("%s\n", __func__);
if (us->suspend_resume_hook)
(us->suspend_resume_hook)(us, US_SUSPEND);
- /* When runtime PM is working, we'll set a flag to indicate
- * whether we should autoresume when a SCSI request arrives. */
- // us->Power_IsResum = true;
- //us->SD_Status.Ready = 0;
-
mutex_unlock(&us->dev_mutex);
return 0;
}
-//EXPORT_SYMBOL_GPL(eucr_suspend);
static int eucr_resume(struct usb_interface *iface)
{
- BYTE tmp = 0;
+ u8 tmp = 0;
struct us_data *us = usb_get_intfdata(iface);
pr_info("--- eucr_resume---\n");
mutex_lock(&us->dev_mutex);
- //US_DEBUGP("%s\n", __func__);
if (us->suspend_resume_hook)
(us->suspend_resume_hook)(us, US_RESUME);
mutex_unlock(&us->dev_mutex);
-
- us->Power_IsResum = true;
- //
- //us->SD_Status.Ready = 0; //??
- us->SM_Status = *(PSM_STATUS)&tmp;
-
+ us->Power_IsResum = true;
+
+ us->SM_Status = *(struct keucr_sm_status *)&tmp;
+
return 0;
}
-//EXPORT_SYMBOL_GPL(eucr_resume);
+
static int eucr_reset_resume(struct usb_interface *iface)
{
- BYTE tmp = 0;
+ u8 tmp = 0;
struct us_data *us = usb_get_intfdata(iface);
pr_info("--- eucr_reset_resume---\n");
- //US_DEBUGP("%s\n", __func__);
/* Report the reset to the SCSI core */
usb_stor_report_bus_reset(us);
- /* FIXME: Notify the subdrivers that they need to reinitialize
- * the device */
- //ENE_InitMedia(us);
- us->Power_IsResum = true;
- //
- //us->SD_Status.Ready = 0; //??
- us->SM_Status = *(PSM_STATUS)&tmp;
+ /*
+ * FIXME: Notify the subdrivers that they need to reinitialize
+ * the device
+ */
+
+ us->Power_IsResum = true;
+
+ us->SM_Status = *(struct keucr_sm_status *)&tmp;
+
return 0;
}
-//EXPORT_SYMBOL_GPL(usb_stor_reset_resume);
#else
@@ -110,7 +99,6 @@ static int eucr_reset_resume(struct usb_interface *iface)
#endif
-//----- eucr_pre_reset() ---------------------
static int eucr_pre_reset(struct usb_interface *iface)
{
struct us_data *us = usb_get_intfdata(iface);
@@ -122,7 +110,6 @@ static int eucr_pre_reset(struct usb_interface *iface)
return 0;
}
-//----- eucr_post_reset() ---------------------
static int eucr_post_reset(struct usb_interface *iface)
{
struct us_data *us = usb_get_intfdata(iface);
@@ -136,20 +123,18 @@ static int eucr_post_reset(struct usb_interface *iface)
return 0;
}
-//----- fill_inquiry_response() ---------------------
-void fill_inquiry_response(struct us_data *us, unsigned char *data, unsigned int data_len)
+void fill_inquiry_response(struct us_data *us, unsigned char *data,
+ unsigned int data_len)
{
pr_info("usb --- fill_inquiry_response\n");
- if (data_len<36) // You lose.
+ if (data_len < 36) /* You lose. */
return;
- if (data[0]&0x20)
- {
- memset(data+8,0,28);
- }
- else
- {
- u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice);
+ if (data[0]&0x20) {
+ memset(data+8, 0, 28);
+ } else {
+ u16 bcdDevice =
+ le16_to_cpu(us->pusb_dev->descriptor.bcdDevice);
memcpy(data+8, us->unusual_dev->vendorName,
strlen(us->unusual_dev->vendorName) > 8 ? 8 :
strlen(us->unusual_dev->vendorName));
@@ -164,18 +149,16 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data, unsigned int
usb_stor_set_xfer_buf(us, data, data_len, us->srb, TO_XFER_BUF);
}
-//----- usb_stor_control_thread() ---------------------
-static int usb_stor_control_thread(void * __us)
+static int usb_stor_control_thread(void *__us)
{
struct us_data *us = (struct us_data *)__us;
struct Scsi_Host *host = us_to_host(us);
pr_info("usb --- usb_stor_control_thread\n");
- for(;;)
- {
+ for (;;) {
if (wait_for_completion_interruptible(&us->cmnd_ready))
break;
-
+
/* lock the device pointers */
mutex_lock(&(us->dev_mutex));
@@ -189,44 +172,35 @@ static int usb_stor_control_thread(void * __us)
scsi_lock(host);
/* When we are called with no command pending, we're done */
- if (us->srb == NULL)
- {
+ if (us->srb == NULL) {
scsi_unlock(host);
mutex_unlock(&us->dev_mutex);
- //US_DEBUGP("-- exiting\n");
break;
}
/* has the command timed out *already* ? */
- if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
- {
+ if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
us->srb->result = DID_ABORT << 16;
goto SkipForAbort;
}
scsi_unlock(host);
- if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL)
- {
+ if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) {
us->srb->result = DID_ERROR << 16;
- }
- else if (us->srb->device->id && !(us->fflags & US_FL_SCM_MULT_TARG))
- {
+ } else if (us->srb->device->id
+ && !(us->fflags & US_FL_SCM_MULT_TARG)) {
us->srb->result = DID_BAD_TARGET << 16;
- }
- else if (us->srb->device->lun > us->max_lun)
- {
+ } else if (us->srb->device->lun > us->max_lun) {
us->srb->result = DID_BAD_TARGET << 16;
- }
- else if ((us->srb->cmnd[0] == INQUIRY) && (us->fflags & US_FL_FIX_INQUIRY))
- {
- unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02, 0x1F, 0x00, 0x00, 0x00};
+ } else if ((us->srb->cmnd[0] == INQUIRY)
+ && (us->fflags & US_FL_FIX_INQUIRY)) {
+ unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02,
+ 0x1F, 0x00, 0x00, 0x00};
fill_inquiry_response(us, data_ptr, 36);
us->srb->result = SAM_STAT_GOOD;
- }
- else
- {
+ } else {
us->proto_handler(us->srb, us);
}
@@ -234,18 +208,14 @@ static int usb_stor_control_thread(void * __us)
scsi_lock(host);
/* indicate that the command is done */
- if (us->srb->result != DID_ABORT << 16)
- {
+ if (us->srb->result != DID_ABORT << 16) {
us->srb->scsi_done(us->srb);
- }
- else
- {
+ } else {
SkipForAbort:
pr_info("scsi command aborted\n");
}
- if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
- {
+ if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
complete(&(us->notify));
/* Allow USB transfers to resume */
@@ -262,8 +232,7 @@ SkipForAbort:
} /* for (;;) */
/* Wait until we are told to stop */
- for (;;)
- {
+ for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
if (kthread_should_stop())
break;
@@ -271,9 +240,8 @@ SkipForAbort:
}
__set_current_state(TASK_RUNNING);
return 0;
-}
+}
-//----- associate_dev() ---------------------
static int associate_dev(struct us_data *us, struct usb_interface *intf)
{
pr_info("usb --- associate_dev\n");
@@ -287,34 +255,32 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)
usb_set_intfdata(intf, us);
/* Allocate the device-related DMA-mapped buffers */
- us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL, &us->cr_dma);
- if (!us->cr)
- {
+ us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL,
+ &us->cr_dma);
+ if (!us->cr) {
pr_info("usb_ctrlrequest allocation failed\n");
return -ENOMEM;
}
- us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL, &us->iobuf_dma);
- if (!us->iobuf)
- {
+ us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL,
+ &us->iobuf_dma);
+ if (!us->iobuf) {
pr_info("I/O buffer allocation failed\n");
return -ENOMEM;
}
us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL);
if (!us->sensebuf)
- {
- pr_info("Sense buffer allocation failed\n");
return -ENOMEM;
- }
+
return 0;
}
-//----- get_device_info() ---------------------
static int get_device_info(struct us_data *us, const struct usb_device_id *id)
{
struct usb_device *dev = us->pusb_dev;
- struct usb_interface_descriptor *idesc = &us->pusb_intf->cur_altsetting->desc;
+ struct usb_interface_descriptor *idesc =
+ &us->pusb_intf->cur_altsetting->desc;
pr_info("usb --- get_device_info\n");
@@ -323,8 +289,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
us->fflags = id->driver_info;
us->Power_IsResum = false;
- if (us->fflags & US_FL_IGNORE_DEVICE)
- {
+ if (us->fflags & US_FL_IGNORE_DEVICE) {
pr_info("device ignored\n");
return -ENODEV;
}
@@ -335,7 +300,6 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
return 0;
}
-//----- get_transport() ---------------------
static int get_transport(struct us_data *us)
{
pr_info("usb --- get_transport\n");
@@ -349,7 +313,6 @@ static int get_transport(struct us_data *us)
default:
return -EIO;
}
- /* pr_info("Transport: %s\n", us->transport_name); */
/* fix for single-lun devices */
if (us->fflags & US_FL_SINGLE_LUN)
@@ -357,7 +320,6 @@ static int get_transport(struct us_data *us)
return 0;
}
-//----- get_protocol() ---------------------
static int get_protocol(struct us_data *us)
{
pr_info("usb --- get_protocol\n");
@@ -368,7 +330,8 @@ static int get_protocol(struct us_data *us)
switch (us->subclass) {
case USB_SC_SCSI:
us->protocol_name = "Transparent SCSI";
- if( (us->pusb_dev->descriptor.idVendor == 0x0CF2) && (us->pusb_dev->descriptor.idProduct == 0x6250) )
+ if ((us->pusb_dev->descriptor.idVendor == 0x0CF2)
+ && (us->pusb_dev->descriptor.idProduct == 0x6250))
us->proto_handler = ENE_stor_invoke_transport;
else
us->proto_handler = usb_stor_invoke_transport;
@@ -377,11 +340,9 @@ static int get_protocol(struct us_data *us)
default:
return -EIO;
}
- /* pr_info("Protocol: %s\n", us->protocol_name); */
return 0;
}
-//----- get_pipes() ---------------------
static int get_pipes(struct us_data *us)
{
struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting;
@@ -393,32 +354,24 @@ static int get_pipes(struct us_data *us)
pr_info("usb --- get_pipes\n");
- for (i = 0; i < altsetting->desc.bNumEndpoints; i++)
- {
+ for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
ep = &altsetting->endpoint[i].desc;
- if (usb_endpoint_xfer_bulk(ep))
- {
- if (usb_endpoint_dir_in(ep))
- {
+ if (usb_endpoint_xfer_bulk(ep)) {
+ if (usb_endpoint_dir_in(ep)) {
if (!ep_in)
ep_in = ep;
- }
- else
- {
+ } else {
if (!ep_out)
ep_out = ep;
}
- }
- else if (usb_endpoint_is_int_in(ep))
- {
+ } else if (usb_endpoint_is_int_in(ep)) {
if (!ep_int)
ep_int = ep;
}
}
- if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int))
- {
+ if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) {
pr_info("Endpoint sanity check failed! Rejecting dev.\n");
return -EIO;
}
@@ -426,33 +379,32 @@ static int get_pipes(struct us_data *us)
/* Calculate and store the pipe values */
us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0);
us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0);
- us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
- us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
- if (ep_int)
- {
- us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+ us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev,
+ ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+ us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev,
+ ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+ if (ep_int) {
+ us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev,
+ ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
us->ep_bInterval = ep_int->bInterval;
}
return 0;
}
-//----- usb_stor_acquire_resources() ---------------------
static int usb_stor_acquire_resources(struct us_data *us)
{
struct task_struct *th;
pr_info("usb --- usb_stor_acquire_resources\n");
us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
- if (!us->current_urb)
- {
+ if (!us->current_urb) {
pr_info("URB allocation failed\n");
return -ENOMEM;
}
/* Start up our control thread */
th = kthread_run(usb_stor_control_thread, us, "eucr-storage");
- if (IS_ERR(th))
- {
+ if (IS_ERR(th)) {
pr_info("Unable to start control thread\n");
return PTR_ERR(th);
}
@@ -461,7 +413,6 @@ static int usb_stor_acquire_resources(struct us_data *us)
return 0;
}
-//----- usb_stor_release_resources() ---------------------
static void usb_stor_release_resources(struct us_data *us)
{
pr_info("usb --- usb_stor_release_resources\n");
@@ -473,8 +424,7 @@ static void usb_stor_release_resources(struct us_data *us)
kthread_stop(us->ctl_thread);
/* Call the destructor routine, if it exists */
- if (us->extra_destructor)
- {
+ if (us->extra_destructor) {
pr_info("-- calling extra_destructor()\n");
us->extra_destructor(us->extra);
}
@@ -484,7 +434,6 @@ static void usb_stor_release_resources(struct us_data *us)
usb_free_urb(us->current_urb);
}
-//----- dissociate_dev() ---------------------
static void dissociate_dev(struct us_data *us)
{
pr_info("usb --- dissociate_dev\n");
@@ -492,16 +441,14 @@ static void dissociate_dev(struct us_data *us)
kfree(us->sensebuf);
/* Free the device-related DMA-mapped buffers */
- if (us->cr)
- usb_free_coherent(us->pusb_dev, sizeof(*us->cr), us->cr, us->cr_dma);
- if (us->iobuf)
- usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma);
+ usb_free_coherent(us->pusb_dev, sizeof(*us->cr), us->cr, us->cr_dma);
+ usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf,
+ us->iobuf_dma);
/* Remove our private data from the interface */
usb_set_intfdata(us->pusb_intf, NULL);
}
-//----- quiesce_and_remove_host() ---------------------
static void quiesce_and_remove_host(struct us_data *us)
{
struct Scsi_Host *host = us_to_host(us);
@@ -512,19 +459,22 @@ static void quiesce_and_remove_host(struct us_data *us)
if (us->pusb_dev->state == USB_STATE_NOTATTACHED)
set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
- /* Prevent SCSI-scanning (if it hasn't started yet)
+ /*
+ * Prevent SCSI-scanning (if it hasn't started yet)
* and wait for the SCSI-scanning thread to stop.
*/
set_bit(US_FLIDX_DONT_SCAN, &us->dflags);
wake_up(&us->delay_wait);
wait_for_completion(&us->scanning_done);
- /* Removing the host will perform an orderly shutdown: caches
+ /*
+ * Removing the host will perform an orderly shutdown: caches
* synchronized, disks spun down, etc.
*/
scsi_remove_host(host);
- /* Prevent any new commands from being accepted and cut short
+ /*
+ * Prevent any new commands from being accepted and cut short
* reset delays.
*/
scsi_lock(host);
@@ -533,7 +483,6 @@ static void quiesce_and_remove_host(struct us_data *us)
wake_up(&us->delay_wait);
}
-//----- release_everything() ---------------------
static void release_everything(struct us_data *us)
{
pr_info("usb --- release_everything\n");
@@ -543,8 +492,7 @@ static void release_everything(struct us_data *us)
scsi_host_put(us_to_host(us));
}
-//----- usb_stor_scan_thread() ---------------------
-static int usb_stor_scan_thread(void * __us)
+static int usb_stor_scan_thread(void *__us)
{
struct us_data *us = (struct us_data *)__us;
@@ -560,11 +508,10 @@ static int usb_stor_scan_thread(void * __us)
}
/* If the device is still connected, perform the scanning */
- if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags))
- {
+ if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) {
/* For bulk-only devices, determine the max LUN value */
- if (us->protocol == USB_PR_BULK && !(us->fflags & US_FL_SINGLE_LUN))
- {
+ if (us->protocol == USB_PR_BULK
+ && !(us->fflags & US_FL_SINGLE_LUN)) {
mutex_lock(&us->dev_mutex);
us->max_lun = usb_stor_Bulk_max_lun(us);
mutex_unlock(&us->dev_mutex);
@@ -575,20 +522,19 @@ static int usb_stor_scan_thread(void * __us)
complete_and_exit(&us->scanning_done, 0);
}
-//----- eucr_probe() ---------------------
-static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id)
+static int eucr_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
{
struct Scsi_Host *host;
struct us_data *us;
int result;
- BYTE MiscReg03 = 0;
+ u8 MiscReg03 = 0;
struct task_struct *th;
pr_info("usb --- eucr_probe\n");
- host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
- if (!host)
- {
+ host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
+ if (!host) {
pr_info("Unable to allocate the scsi host\n");
return -ENOMEM;
}
@@ -630,8 +576,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
goto BadDevice;
result = scsi_add_host(host, &intf->dev);
- if (result)
- {
+ if (result) {
pr_info("Unable to add the scsi host\n");
goto BadDevice;
}
@@ -648,7 +593,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
wake_up_process(th);
/* probe card type */
- result = ENE_Read_BYTE(us, REG_CARD_STATUS, &MiscReg03);
+ result = ene_read_byte(us, REG_CARD_STATUS, &MiscReg03);
if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR;
quiesce_and_remove_host(us);
@@ -658,9 +603,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
if (!(MiscReg03 & 0x02)) {
result = -ENODEV;
quiesce_and_remove_host(us);
- pr_info("keucr: The driver only supports SM/MS card.\
- To use SD card, \
- please build driver/usb/storage/ums-eneub6250.ko\n");
+ pr_info("keucr: The driver only supports SM/MS card. To use SD card, please build driver/usb/storage/ums-eneub6250.ko\n");
goto BadDevice;
}
@@ -673,7 +616,6 @@ BadDevice:
return result;
}
-//----- eucr_disconnect() ---------------------
static void eucr_disconnect(struct usb_interface *intf)
{
struct us_data *us = usb_get_intfdata(intf);
@@ -683,17 +625,13 @@ static void eucr_disconnect(struct usb_interface *intf)
release_everything(us);
}
-/***********************************************************************
- * Initialization and registration
- ***********************************************************************/
-
-//----- usb_storage_driver() ---------------------
+/* Initialization and registration */
static struct usb_driver usb_storage_driver = {
.name = "eucr",
.probe = eucr_probe,
- .suspend = eucr_suspend,
+ .suspend = eucr_suspend,
.resume = eucr_resume,
- .reset_resume = eucr_reset_resume,
+ .reset_resume = eucr_reset_resume,
.disconnect = eucr_disconnect,
.pre_reset = eucr_pre_reset,
.post_reset = eucr_post_reset,
diff --git a/drivers/staging/keucr/usb.h b/drivers/staging/keucr/usb.h
index a5f7a16c11c..e894f840c70 100644
--- a/drivers/staging/keucr/usb.h
+++ b/drivers/staging/keucr/usb.h
@@ -1,4 +1,4 @@
-// Driver for USB Mass Storage compliant devices
+/* Driver for USB Mass Storage compliant devices */
#ifndef _USB_H_
#define _USB_H_
@@ -19,26 +19,26 @@ struct scsi_cmnd;
*/
struct us_unusual_dev {
- const char* vendorName;
- const char* productName;
+ const char *vendorName;
+ const char *productName;
__u8 useProtocol;
__u8 useTransport;
int (*initFunction)(struct us_data *);
};
-//EnE HW Register
+/* EnE HW Register */
#define REG_CARD_STATUS 0xFF83
#define REG_HW_TRAP1 0xFF89
-// SRB Status. Refers /usr/include/wine/wine/wnaspi32.h & SCSI sense key
-#define SS_SUCCESS 0x00 // No Sense
+/* SRB Status. Refers /usr/include/wine/wine/wnaspi32.h & SCSI sense key */
+#define SS_SUCCESS 0x00 /* No Sense */
#define SS_NOT_READY 0x02
#define SS_MEDIUM_ERR 0x03
#define SS_HW_ERR 0x04
#define SS_ILLEGAL_REQUEST 0x05
#define SS_UNIT_ATTENTION 0x06
-//ENE Load FW Pattern
+/* ENE Load FW Pattern */
#define SD_INIT1_PATTERN 1
#define SD_INIT2_PATTERN 2
#define SD_RW_PATTERN 3
@@ -51,39 +51,40 @@ struct us_unusual_dev {
#define FDIR_WRITE 0
#define FDIR_READ 1
-typedef struct _SD_STATUS {
- BYTE Insert:1;
- BYTE Ready:1;
- BYTE MediaChange:1;
- BYTE IsMMC:1;
- BYTE HiCapacity:1;
- BYTE HiSpeed:1;
- BYTE WtP:1;
- BYTE Reserved:1;
-} SD_STATUS, *PSD_STATUS;
-
-typedef struct _MS_STATUS {
- BYTE Insert:1;
- BYTE Ready:1;
- BYTE MediaChange:1;
- BYTE IsMSPro:1;
- BYTE IsMSPHG:1;
- BYTE Reserved1:1;
- BYTE WtP:1;
- BYTE Reserved2:1;
-} MS_STATUS, *PMS_STATUS;
-
-typedef struct _SM_STATUS {
- BYTE Insert:1;
- BYTE Ready:1;
- BYTE MediaChange:1;
- BYTE Reserved:3;
- BYTE WtP:1;
- BYTE IsMS:1;
-} SM_STATUS, *PSM_STATUS;
-
-// SD Block Length
-#define SD_BLOCK_LEN 9 // 2^9 = 512 Bytes, The HW maximum read/write data length
+struct keucr_sd_status {
+ u8 Insert:1;
+ u8 Ready:1;
+ u8 MediaChange:1;
+ u8 IsMMC:1;
+ u8 HiCapacity:1;
+ u8 HiSpeed:1;
+ u8 WtP:1;
+ u8 Reserved:1;
+};
+
+struct keucr_ms_status {
+ u8 Insert:1;
+ u8 Ready:1;
+ u8 MediaChange:1;
+ u8 IsMSPro:1;
+ u8 IsMSPHG:1;
+ u8 Reserved1:1;
+ u8 WtP:1;
+ u8 Reserved2:1;
+};
+
+struct keucr_sm_status {
+ u8 Insert:1;
+ u8 Ready:1;
+ u8 MediaChange:1;
+ u8 Reserved:3;
+ u8 WtP:1;
+ u8 IsMS:1;
+};
+
+/* SD Block Length */
+#define SD_BLOCK_LEN 9 /* 2^9 = 512 Bytes,
+ The HW maximum read/write data length */
/* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
#define US_FLIDX_URB_ACTIVE 0 /* current_urb is in use */
@@ -107,9 +108,9 @@ typedef struct _SM_STATUS {
#define US_IOBUF_SIZE 64 /* Size of the DMA-mapped I/O buffer */
#define US_SENSE_SIZE 18 /* Size of the autosense data buffer */
-typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*);
-typedef int (*trans_reset)(struct us_data*);
-typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*);
+typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data *);
+typedef int (*trans_reset)(struct us_data *);
+typedef void (*proto_cmnd)(struct scsi_cmnd *, struct us_data *);
typedef void (*extra_data_destructor)(void *); /* extra data destructor */
typedef void (*pm_hook)(struct us_data *, int); /* power management hook */
@@ -176,52 +177,54 @@ struct us_data {
#ifdef CONFIG_PM
pm_hook suspend_resume_hook;
#endif
- // for 6250 code
- SD_STATUS SD_Status;
- MS_STATUS MS_Status;
- SM_STATUS SM_Status;
-
- //----- SD Control Data ----------------
- //SD_REGISTER SD_Regs;
- WORD SD_Block_Mult;
- BYTE SD_READ_BL_LEN;
- WORD SD_C_SIZE;
- BYTE SD_C_SIZE_MULT;
-
- // SD/MMC New spec.
- BYTE SD_SPEC_VER;
- BYTE SD_CSD_VER;
- BYTE SD20_HIGH_CAPACITY;
- DWORD HC_C_SIZE;
- BYTE MMC_SPEC_VER;
- BYTE MMC_BusWidth;
- BYTE MMC_HIGH_CAPACITY;
-
- //----- MS Control Data ----------------
- BOOLEAN MS_SWWP;
- DWORD MSP_TotalBlock;
+ /* for 6250 code */
+ struct keucr_sd_status SD_Status;
+ struct keucr_ms_status MS_Status;
+ struct keucr_sm_status SM_Status;
+
+ /* ----- SD Control Data ---------------- */
+ /* SD_REGISTER SD_Regs; */
+ u16 SD_Block_Mult;
+ u8 SD_READ_BL_LEN;
+ u16 SD_C_SIZE;
+ u8 SD_C_SIZE_MULT;
+
+ /* SD/MMC New spec. */
+ u8 SD_SPEC_VER;
+ u8 SD_CSD_VER;
+ u8 SD20_HIGH_CAPACITY;
+ u32 HC_C_SIZE;
+ u8 MMC_SPEC_VER;
+ u8 MMC_BusWidth;
+ u8 MMC_HIGH_CAPACITY;
+
+ /* ----- MS Control Data ---------------- */
+ bool MS_SWWP;
+ u32 MSP_TotalBlock;
/* MS_LibControl MS_Lib; */
- BOOLEAN MS_IsRWPage;
- WORD MS_Model;
+ bool MS_IsRWPage;
+ u16 MS_Model;
- //----- SM Control Data ----------------
- BYTE SM_DeviceID;
- BYTE SM_CardID;
+ /* ----- SM Control Data ---------------- */
+ u8 SM_DeviceID;
+ u8 SM_CardID;
- PBYTE testbuf;
- BYTE BIN_FLAG;
- DWORD bl_num;
+ u8 *testbuf;
+ u8 BIN_FLAG;
+ u32 bl_num;
int SrbStatus;
-
- //------Power Managerment ---------------
- BOOLEAN Power_IsResum;
+
+ /* ------Power Managerment --------------- */
+ bool Power_IsResum;
};
/* Convert between us_data and the corresponding Scsi_Host */
-static inline struct Scsi_Host *us_to_host(struct us_data *us) {
+static inline struct Scsi_Host *us_to_host(struct us_data *us)
+{
return container_of((void *) us, struct Scsi_Host, hostdata);
}
-static inline struct us_data *host_to_us(struct Scsi_Host *host) {
+static inline struct us_data *host_to_us(struct Scsi_Host *host)
+{
return (struct us_data *) host->hostdata;
}