Commit 20c3d7f7 authored by Cho, Yu-Chen's avatar Cho, Yu-Chen Committed by Greg Kroah-Hartman

Staging: Remove ENE UB6250 MS card codes from keucr

Remove ENE UB6250 MS card codes from keucr.
Signed-off-by: default avatarCho, Yu-Chen <acho@novell.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 33842ced
config USB_ENESTORAGE
tristate "USB ENE SM/MS card reader support"
tristate "USB ENE SM card reader support"
depends on USB && SCSI && m
---help---
Say Y here if you wish to control a ENE SM/MS Card reader.
To use SD card, please build driver/usb/storage/ums-eneub6250.ko
Say Y here if you wish to control a ENE SM Card reader.
To use SD/MS card, please build driver/usb/storage/ums-eneub6250.ko
This option depends on 'SCSI' support being enabled, but you
probably also need 'SCSI device support: SCSI disk support'
......
......@@ -7,8 +7,6 @@ keucr-y := \
scsiglue.o \
transport.o \
init.o \
msscsi.o \
ms.o \
smscsi.o \
smilmain.o \
smilsub.o \
......
......@@ -31,9 +31,7 @@ int ENE_InitMedia(struct us_data *us)
if (!us->SM_Status.Ready && !us->MS_Status.Ready) {
result = ENE_SMInit(us);
if (result != USB_STOR_XFER_GOOD) {
result = ENE_MSInit(us);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
return USB_STOR_TRANSPORT_ERROR;
}
}
......@@ -61,60 +59,6 @@ int ENE_Read_BYTE(struct us_data *us, WORD index, void *buf)
return result;
}
/*
* ENE_MSInit():
*/
int ENE_MSInit(struct us_data *us)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
BYTE buf[0x200];
WORD MSP_BlockSize, MSP_UserAreaBlocks;
printk(KERN_INFO "transport --- ENE_MSInit\n");
result = ENE_LoadBinCode(us, MS_INIT_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
printk(KERN_ERR "Load MS Init Code Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = 0x200;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x01;
result = ENE_SendScsiCmd(us, FDIR_READ, &buf, 0);
if (result != USB_STOR_XFER_GOOD) {
printk(KERN_ERR "Execution MS Init Code Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
us->MS_Status = *(PMS_STATUS)&buf[0];
if (us->MS_Status.Insert && us->MS_Status.Ready) {
printk(KERN_INFO "Insert = %x\n", us->MS_Status.Insert);
printk(KERN_INFO "Ready = %x\n", us->MS_Status.Ready);
printk(KERN_INFO "IsMSPro = %x\n", us->MS_Status.IsMSPro);
printk(KERN_INFO "IsMSPHG = %x\n", us->MS_Status.IsMSPHG);
printk(KERN_INFO "WtP = %x\n", us->MS_Status.WtP);
if (us->MS_Status.IsMSPro) {
MSP_BlockSize = (buf[6] << 8) | buf[7];
MSP_UserAreaBlocks = (buf[10] << 8) | buf[11];
us->MSP_TotalBlock = MSP_BlockSize * MSP_UserAreaBlocks;
} else {
MS_CardInit(us);
}
printk(KERN_INFO "MS Init Code OK !!\n");
} else {
printk(KERN_INFO "MS Card Not Ready --- %x\n", buf[0]);
return USB_STOR_TRANSPORT_ERROR;
}
return USB_STOR_TRANSPORT_GOOD;
}
/*
*ENE_SMInit()
*/
......@@ -185,19 +129,6 @@ int ENE_LoadBinCode(struct us_data *us, BYTE flag)
if (buf == NULL)
return USB_STOR_TRANSPORT_ERROR;
switch (flag) {
/* For MS */
case MS_INIT_PATTERN:
printk(KERN_INFO "MS_INIT_PATTERN\n");
memcpy(buf, MS_Init, 0x800);
break;
case MSP_RW_PATTERN:
printk(KERN_INFO "MSP_RW_PATTERN\n");
memcpy(buf, MSP_Rdwr, 0x800);
break;
case MS_RW_PATTERN:
printk(KERN_INFO "MS_RW_PATTERN\n");
memcpy(buf, MS_Rdwr, 0x800);
break;
/* For SS */
case SM_INIT_PATTERN:
printk(KERN_INFO "SM_INIT_PATTERN\n");
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_device.h>
#include "usb.h"
#include "scsiglue.h"
#include "transport.h"
/*
* MS_SCSI_Test_Unit_Ready()
*/
int MS_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
{
/* pr_info("MS_SCSI_Test_Unit_Ready\n"); */
if (us->MS_Status.Insert && us->MS_Status.Ready)
return USB_STOR_TRANSPORT_GOOD;
else {
ENE_MSInit(us);
return USB_STOR_TRANSPORT_GOOD;
}
return USB_STOR_TRANSPORT_GOOD;
}
/*
* MS_SCSI_Inquiry()
*/
int MS_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
{
/* pr_info("MS_SCSI_Inquiry\n"); */
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};
usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
/*
* MS_SCSI_Mode_Sense()
*/
int MS_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};
if (us->MS_Status.WtP)
usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
else
usb_stor_set_xfer_buf(us, mediaNoWP, 12, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
/*
* MS_SCSI_Read_Capacity()
*/
int MS_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];
pr_info("MS_SCSI_Read_Capacity\n");
bl_len = 0x200;
if (us->MS_Status.IsMSPro)
bl_num = us->MSP_TotalBlock - 1;
else
bl_num = us->MS_Lib.NumberOfLogBlock *
us->MS_Lib.blockSize * 2 - 1;
us->bl_num = bl_num;
pr_info("bl_len = %x\n", bl_len);
pr_info("bl_num = %x\n", bl_num);
/* srb->request_bufflen = 8; */
buf[0] = (bl_num >> 24) & 0xff;
buf[1] = (bl_num >> 16) & 0xff;
buf[2] = (bl_num >> 8) & 0xff;
buf[3] = (bl_num >> 0) & 0xff;
buf[4] = (bl_len >> 24) & 0xff;
buf[5] = (bl_len >> 16) & 0xff;
buf[6] = (bl_len >> 8) & 0xff;
buf[7] = (bl_len >> 0) & 0xff;
usb_stor_access_xfer_buf(us, buf, 8, srb, &sg, &offset, TO_XFER_BUF);
/* usb_stor_set_xfer_buf(us, buf, srb->request_bufflen,
srb, TO_XFER_BUF); */
return USB_STOR_TRANSPORT_GOOD;
}
/*
* MS_SCSI_Read()
*/
int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
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;
/* pr_info("SCSIOP_READ --- bn = %X, blen = %X, srb->use_sg = %X\n",
bn, blen, srb->use_sg); */
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
if (us->MS_Status.IsMSPro) {
result = ENE_LoadBinCode(us, MSP_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
pr_info("Load MSP RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
/* set up the command wrapper */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x02;
bcb->CDB[5] = (BYTE)(bn);
bcb->CDB[4] = (BYTE)(bn>>8);
bcb->CDB[3] = (BYTE)(bn>>16);
bcb->CDB[2] = (BYTE)(bn>>24);
result = ENE_SendScsiCmd(us, FDIR_READ, scsi_sglist(srb), 1);
} else {
void *buf;
int offset = 0;
WORD phyblk, logblk;
BYTE PageNum;
WORD len;
DWORD blkno;
buf = kmalloc(blenByte, GFP_KERNEL);
if (buf == NULL)
return USB_STOR_TRANSPORT_ERROR;
result = ENE_LoadBinCode(us, MS_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
pr_info("Load MS RW pattern Fail !!\n");
result = USB_STOR_TRANSPORT_ERROR;
goto exit;
}
logblk = (WORD)(bn / us->MS_Lib.PagesPerBlock);
PageNum = (BYTE)(bn % us->MS_Lib.PagesPerBlock);
while (1) {
if (blen > (us->MS_Lib.PagesPerBlock-PageNum))
len = us->MS_Lib.PagesPerBlock-PageNum;
else
len = blen;
phyblk = MS_LibConv2Physical(us, logblk);
blkno = phyblk * 0x20 + PageNum;
/* set up the command wrapper */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = 0x200 * len;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[1] = 0x02;
bcb->CDB[5] = (BYTE)(blkno);
bcb->CDB[4] = (BYTE)(blkno>>8);
bcb->CDB[3] = (BYTE)(blkno>>16);
bcb->CDB[2] = (BYTE)(blkno>>24);
result = ENE_SendScsiCmd(us, FDIR_READ, buf+offset, 0);
if (result != USB_STOR_XFER_GOOD) {
pr_info("MS_SCSI_Read --- result = %x\n",
result);
result = USB_STOR_TRANSPORT_ERROR;
goto exit;
}
blen -= len;
if (blen <= 0)
break;
logblk++;
PageNum = 0;
offset += MS_BYTES_PER_PAGE*len;
}
usb_stor_set_xfer_buf(us, buf, blenByte, srb, TO_XFER_BUF);
exit:
kfree(buf);
}
return result;
}
/*
* MS_SCSI_Write()
*/
int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
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;
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
if (us->MS_Status.IsMSPro) {
result = ENE_LoadBinCode(us, MSP_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
pr_info("Load MSP RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
/* set up the command wrapper */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x00;
bcb->CDB[0] = 0xF0;
bcb->CDB[1] = 0x04;
bcb->CDB[5] = (BYTE)(bn);
bcb->CDB[4] = (BYTE)(bn>>8);
bcb->CDB[3] = (BYTE)(bn>>16);
bcb->CDB[2] = (BYTE)(bn>>24);
result = ENE_SendScsiCmd(us, FDIR_WRITE, scsi_sglist(srb), 1);
} else {
void *buf;
int offset = 0;
WORD PhyBlockAddr;
BYTE PageNum;
DWORD result;
WORD len, oldphy, newphy;
buf = kmalloc(blenByte, GFP_KERNEL);
if (buf == NULL)
return USB_STOR_TRANSPORT_ERROR;
usb_stor_set_xfer_buf(us, buf, blenByte, srb, FROM_XFER_BUF);
result = ENE_LoadBinCode(us, MS_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
pr_info("Load MS RW pattern Fail !!\n");
result = USB_STOR_TRANSPORT_ERROR;
goto exit;
}
PhyBlockAddr = (WORD)(bn / us->MS_Lib.PagesPerBlock);
PageNum = (BYTE)(bn % us->MS_Lib.PagesPerBlock);
while (1) {
if (blen > (us->MS_Lib.PagesPerBlock-PageNum))
len = us->MS_Lib.PagesPerBlock-PageNum;
else
len = blen;
oldphy = MS_LibConv2Physical(us, PhyBlockAddr);
newphy = MS_LibSearchBlockFromLogical(us, PhyBlockAddr);
result = MS_ReaderCopyBlock(us, oldphy, newphy,
PhyBlockAddr, PageNum,
buf+offset, len);
if (result != USB_STOR_XFER_GOOD) {
pr_info("MS_SCSI_Write --- result = %x\n",
result);
result = USB_STOR_TRANSPORT_ERROR;
goto exit;
}
us->MS_Lib.Phy2LogMap[oldphy] = MS_LB_NOT_USED_ERASED;
MS_LibForceSetLogicalPair(us, PhyBlockAddr, newphy);
blen -= len;
if (blen <= 0)
break;
PhyBlockAddr++;
PageNum = 0;
offset += MS_BYTES_PER_PAGE*len;
}
exit:
kfree(buf);
}
return result;
}
/*
* MS_SCSIIrp()
*/
int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
{
int result;
us->SrbStatus = SS_SUCCESS;
switch (srb->cmnd[0]) {
case TEST_UNIT_READY:
result = MS_SCSI_Test_Unit_Ready(us, srb);
break; /* 0x00 */
case INQUIRY:
result = MS_SCSI_Inquiry(us, srb);
break; /* 0x12 */
case MODE_SENSE:
result = MS_SCSI_Mode_Sense(us, srb);
break; /* 0x1A */
case READ_CAPACITY:
result = MS_SCSI_Read_Capacity(us, srb);
break; /* 0x25 */
case READ_10:
result = MS_SCSI_Read(us, srb);
break; /* 0x28 */
case WRITE_10:
result = MS_SCSI_Write(us, srb);
break; /* 0x2A */
default:
us->SrbStatus = SS_ILLEGAL_REQUEST;
result = USB_STOR_TRANSPORT_FAILED;
break;
}
return result;
}
......@@ -432,7 +432,7 @@ void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
usb_stor_print_cmd(srb);
/* send the command to the transport layer */
scsi_set_resid(srb, 0);
if (!(us->MS_Status.Ready || us->SM_Status.Ready))
if (!(us->SM_Status.Ready))
result = ENE_InitMedia(us);
if (us->Power_IsResum == true) {
......@@ -440,8 +440,6 @@ void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
us->Power_IsResum = false;
}
if (us->MS_Status.Ready)
result = MS_SCSIIrp(us, srb);
if (us->SM_Status.Ready)
result = SM_SCSIIrp(us, srb);
......
......@@ -95,7 +95,6 @@ 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_MSInit(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);
......@@ -107,51 +106,6 @@ extern void BuildSenseBuffer(struct scsi_cmnd *, int);
/*
* ENE scsi function
*/
extern int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
extern int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
/*
* ENE MS function
*/
extern int MS_CardInit(struct us_data *us);
extern void MS_LibFreeAllocatedArea(struct us_data *us);
extern void MS_LibFreeWriteBuf(struct us_data *us);
extern int MS_LibFreeLogicalMap(struct us_data *us);
extern int MS_LibForceSetLogicalPair(struct us_data *us, WORD logblk,
WORD phyblk);
extern int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr,
BYTE PageNum, DWORD *PageBuf,
MS_LibTypeExtdat *ExtraDat);
extern int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy,
WORD newphy, WORD PhyBlockAddr,
BYTE PageNum, PBYTE buf, WORD len);
extern int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr);
extern int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock,
BYTE *PageData);
extern int MS_LibAllocLogicalMap(struct us_data *us);
extern int MS_LibSetBootBlockMark(struct us_data *us, WORD phyblk);
extern int MS_LibSetLogicalBlockMark(struct us_data *us, WORD phyblk,
WORD mark);
extern int MS_LibSetInitialErrorBlock(struct us_data *us, WORD phyblk);
extern int MS_LibScanLogicalBlockNumber(struct us_data *us, WORD phyblk);
extern int MS_LibAllocWriteBuf(struct us_data *us);
void MS_LibClearWriteBuf(struct us_data *us);
void MS_LibPhy2LogRange(WORD PhyBlock, WORD *LogStart,
WORD *LogEnde);
extern int MS_LibReadExtra(struct us_data *us, DWORD PhyBlock,
BYTE PageNum, MS_LibTypeExtdat *ExtraDat);
extern int MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock,
BYTE PageNum, BYTE blen, void *buf);
extern int MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk);
extern int MS_LibErasePhyBlock(struct us_data *us, WORD phyblk);
extern int MS_LibErrorPhyBlock(struct us_data *us, WORD phyblk);
extern int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr,
BYTE PageNum, BYTE OverwriteFlag);
extern int MS_LibSetLogicalPair(struct us_data *us,
WORD logblk, WORD phyblk);
extern int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock);
extern int MS_CountFreeBlock(struct us_data *us, WORD PhyBlock);
extern int MS_LibSearchBlockFromLogical(struct us_data *us, WORD logblk);
extern int MS_LibSearchBlockFromPhysical(struct us_data *us, WORD phyblk);
#endif
......@@ -75,7 +75,6 @@ static int eucr_resume(struct usb_interface *iface)
us->Power_IsResum = true;
//
//us->SD_Status.Ready = 0; //??
us->MS_Status = *(PMS_STATUS)&tmp;
us->SM_Status = *(PSM_STATUS)&tmp;
return 0;
......@@ -98,7 +97,6 @@ static int eucr_reset_resume(struct usb_interface *iface)
us->Power_IsResum = true;
//
//us->SD_Status.Ready = 0; //??
us->MS_Status = *(PMS_STATUS)&tmp;
us->SM_Status = *(PSM_STATUS)&tmp;
return 0;
}
......
......@@ -10,7 +10,6 @@
#include <linux/mutex.h>
#include <scsi/scsi_host.h>
#include "common.h"
#include "ms.h"
struct us_data;
struct scsi_cmnd;
......@@ -201,7 +200,7 @@ struct us_data {
//----- MS Control Data ----------------
BOOLEAN MS_SWWP;
DWORD MSP_TotalBlock;
MS_LibControl MS_Lib;
/* MS_LibControl MS_Lib; */
BOOLEAN MS_IsRWPage;
WORD MS_Model;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment