staging/keucr: fix keucr coding style
cover staging/keucr: fix keucr coding style
Fix some .c .h files coding style.
Cho, Yu-Chen (7):
staging/keucr: fix keucr ms coding style
staging/keucr: fix keucr msscsi coding style
staging/keucr: fix keucr scsiglue coding style
staging/keucr: fix keucr smilecc.c coding style
staging/keucr: fix keucr smil.h coding style
staging/keucr: fix keucr transport coding style
staging/keucr : fix transport other code style
drivers/staging/keucr/ms.c | 693 +++++++++++++++++++++---------------- drivers/staging/keucr/ms.h | 338 ++++++++++--------- drivers/staging/keucr/msscsi.c | 219 +++++++------ drivers/staging/keucr/scsiglue.c | 157 +++++---- drivers/staging/keucr/smil.h | 291 ++++++++-------- drivers/staging/keucr/smilecc.c | 293 ++++++++-------- drivers/staging/keucr/transport.c | 389 +++++++++++---------- drivers/staging/keucr/transport.h | 81 +++-- 8 files changed, 1337 insertions(+), 1124 deletions(-)
PATCH 1/7 staging/keucr: fix keucr ms coding style
fix keucr ms.c and ms.h coding style
--- drivers/staging/keucr/ms.c | 693 ++++++++++++++++++++++++------------------- drivers/staging/keucr/ms.h | 338 ++++++++++++---------- 2 files changed, 566 insertions(+), 465 deletions(-)
drivers/staging/keucr/ms.c +387 -306
@@ -6,13 +6,17 @@#include "transport.h" #include "ms.h" -//----- MS_ReaderCopyBlock() ------------------------------------------ -int MS_ReaderCopyBlock (struct us_data *us,WORD oldphy,WORD newphy,WORD PhyBlockAddr,BYTE PageNum,PBYTE buf,WORD len) +/* +* MS_ReaderCopyBlock() +*/ +int MS_ReaderCopyBlock (struct us_data *us,WORD oldphy,WORD newphy, +WORD PhyBlockAddr,BYTE PageNum,PBYTE buf,WORD len) {struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;int result; -//printk("MS_ReaderCopyBlock --- PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum); +/* printk(KERN_INFO "MS_ReaderCopyBlock --- PhyBlockAddr = %x, +PageNum = %x\n", PhyBlockAddr, PageNum); */ result =ENE_LoadBinCode (us,MS_RW_PATTERN );if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ;
@@ -40,21 +44,25 @@ int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy, WORD newphy, WORD PhyBloreturn USB_STOR_TRANSPORT_GOOD ; } -//----- MS_ReaderReadPage() ------------------------------------------ -int MS_ReaderReadPage (struct us_data *us,DWORD PhyBlockAddr,BYTE PageNum,PDWORD PageBuf,MS_LibTypeExtdat *ExtraDat) +/* +* MS_ReaderReadPage() +*/ +int MS_ReaderReadPage (struct us_data *us,DWORD PhyBlockAddr, +BYTE PageNum,PDWORD PageBuf,MS_LibTypeExtdat *ExtraDat) {struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;int result;BYTE ExtBuf[4 ];DWORD bn = PhyBlockAddr *0x20 + PageNum; -//printk("MS --- MS_ReaderReadPage, PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum); +/* printk(KERN_INFO "MS --- MS_ReaderReadPage, +PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum); */ result =ENE_LoadBinCode (us,MS_RW_PATTERN );if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ; -// Read Page Data +/* Read Page Data */ memset (bcb,0 ,sizeof (struct bulk_cb_wrap )); bcb->Signature =cpu_to_le32 (US_BULK_CB_SIGN ); bcb->DataTransferLength =0x200 ;
@@ -65,12 +73,12 @@ int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, PDWO bcb->CDB[4 ] = (BYTE )(bn>>8 ); bcb->CDB[3 ] = (BYTE )(bn>>16 ); bcb->CDB[2 ] = (BYTE )(bn>>24 ); - + result =ENE_SendScsiCmd (us,FDIR_READ , PageBuf,0 );if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ; -// Read Extra Data +/* Read Extra Data */ memset (bcb,0 ,sizeof (struct bulk_cb_wrap )); bcb->Signature =cpu_to_le32 (US_BULK_CB_SIGN ); bcb->DataTransferLength =0x4 ;
@@ -88,9 +96,9 @@ int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, PDWOreturn USB_STOR_TRANSPORT_ERROR ; ExtraDat->reserved =0 ; - ExtraDat->intr =0x80 ;// Not yet, �����], �� fireware support - ExtraDat->status0 =0x10 ;// Not yet, �����], �� fireware support - ExtraDat->status1 =0x00 ;// Not yet, �����], �� fireware support + ExtraDat->intr =0x80 ;/* Not yet,fireware support */ + ExtraDat->status0 =0x10 ;/* Not yet,fireware support */ + ExtraDat->status1 =0x00 ;/* Not yet,fireware support */ ExtraDat->ovrflg = ExtBuf[0 ]; ExtraDat->mngflg = ExtBuf[1 ]; ExtraDat->logadr =MemStickLogAddr (ExtBuf[2 ], ExtBuf[3 ]);
@@ -98,14 +106,17 @@ int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, PDWOreturn USB_STOR_TRANSPORT_GOOD ; } -//----- MS_ReaderEraseBlock() ---------------------------------------- +/* +* MS_ReaderEraseBlock() +*/ int MS_ReaderEraseBlock (struct us_data *us,DWORD PhyBlockAddr) {struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;int result;DWORD bn = PhyBlockAddr; -//printk("MS --- MS_ReaderEraseBlock, PhyBlockAddr = %x\n", PhyBlockAddr); +/* printk(KERN_INFO "MS --- MS_ReaderEraseBlock, +PhyBlockAddr = %x\n", PhyBlockAddr); */ result =ENE_LoadBinCode (us,MS_RW_PATTERN );if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ;
@@ -119,7 +130,7 @@ int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr) bcb->CDB[4 ] = (BYTE )(bn); bcb->CDB[3 ] = (BYTE )(bn>>8 ); bcb->CDB[2 ] = (BYTE )(bn>>16 ); - + result =ENE_SendScsiCmd (us,FDIR_READ ,NULL ,0 );if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ;
@@ -127,23 +138,25 @@ int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr)return USB_STOR_TRANSPORT_GOOD ; } -//----- MS_CardInit() ------------------------------------------------ +/* +* MS_CardInit() +*/ int MS_CardInit (struct us_data *us) { -DWORD result=0 ; +DWORD result =0 ;WORD TmpBlock;PBYTE PageBuffer0 =NULL , PageBuffer1 =NULL ;MS_LibTypeExtdat extdat;WORD btBlk1st, btBlk2nd;DWORD btBlk1stErred; -printk ("MS_CardInit start\n" ); +printk (KERN_INFO "MS_CardInit start\n" );MS_LibFreeAllocatedArea (us); -if (((PageBuffer0 =kmalloc (MS_BYTES_PER_PAGE ,GFP_KERNEL )) ==NULL ) || - ((PageBuffer1 =kmalloc (MS_BYTES_PER_PAGE ,GFP_KERNEL )) ==NULL )) - { + PageBuffer0 =kmalloc (MS_BYTES_PER_PAGE ,GFP_KERNEL ); + PageBuffer1 =kmalloc (MS_BYTES_PER_PAGE ,GFP_KERNEL ); +if ((PageBuffer0 ==NULL ) || (PageBuffer1 ==NULL )) { result =MS_NO_MEMORY_ERROR ; goto exit; }
@@ -151,16 +164,16 @@ int MS_CardInit(struct us_data *us) btBlk1st = btBlk2nd =MS_LB_NOT_USED ; btBlk1stErred =0 ; -for (TmpBlock=0 ; TmpBlock <MS_MAX_INITIAL_ERROR_BLOCKS +2 ; TmpBlock++) - { -switch (MS_ReaderReadPage (us, TmpBlock,0 , (DWORD *)PageBuffer0, &extdat)) - { -case MS_STATUS_SUCCESS : +for (TmpBlock =0 ; TmpBlock <MS_MAX_INITIAL_ERROR_BLOCKS +2 ; + TmpBlock++) { +switch (MS_ReaderReadPage (us, TmpBlock,0 , + (DWORD *)PageBuffer0, &extdat)) { +case MS_STATUS_SUCCESS :break ; -case MS_STATUS_INT_ERROR : +case MS_STATUS_INT_ERROR :break ; -case MS_STATUS_ERROR : -default : +case MS_STATUS_ERROR : +default :continue ; }
@@ -173,38 +186,37 @@ int MS_CardInit(struct us_data *us) (((MemStickBootBlockPage0 *)PageBuffer0)->header.bNumberOfDataEntry != MS_BOOT_BLOCK_DATA_ENTRIES)) continue; -if (btBlk1st !=MS_LB_NOT_USED ) - { +if (btBlk1st !=MS_LB_NOT_USED ) { btBlk2nd = TmpBlock;break ; } btBlk1st = TmpBlock;memcpy (PageBuffer1, PageBuffer0,MS_BYTES_PER_PAGE ); -if (extdat.status1 & (MS_REG_ST1_DTER |MS_REG_ST1_EXER |MS_REG_ST1_FGER )) +if (extdat.status1 & + (MS_REG_ST1_DTER |MS_REG_ST1_EXER |MS_REG_ST1_FGER )) btBlk1stErred =1 ; } -if (btBlk1st ==MS_LB_NOT_USED ) - { +if (btBlk1st ==MS_LB_NOT_USED ) { result =MS_STATUS_ERROR ; goto exit; } -// write protect +/* write protect */ if ((extdat.status0 &MS_REG_ST0_WP ) ==MS_REG_ST0_WP_ON )MS_LibCtrlSet (us,MS_LIB_CTRL_WRPROTECT ); result =MS_STATUS_ERROR ; -// 1st Boot Block +/* 1st Boot Block */ if (btBlk1stErred ==0 ) - result =MS_LibProcessBootBlock (us, btBlk1st, PageBuffer1);// 1st -// 2nd Boot Block + result =MS_LibProcessBootBlock (us, btBlk1st, PageBuffer1); +/* 1st */ +/* 2nd Boot Block */ if (result && (btBlk2nd !=MS_LB_NOT_USED )) result =MS_LibProcessBootBlock (us, btBlk2nd, PageBuffer0); -if (result) - { +if (result) { result =MS_STATUS_ERROR ; goto exit; }
@@ -214,8 +226,7 @@ int MS_CardInit(struct us_data *us) us->MS_Lib.Phy2LogMap[btBlk1st] =MS_LB_BOOT_BLOCK ; -if (btBlk2nd !=MS_LB_NOT_USED ) - { +if (btBlk2nd !=MS_LB_NOT_USED ) {for (TmpBlock = btBlk1st +1 ; TmpBlock < btBlk2nd; TmpBlock++) us->MS_Lib.Phy2LogMap[TmpBlock] =MS_LB_INITIAL_ERROR ; us->MS_Lib.Phy2LogMap[btBlk2nd] =MS_LB_BOOT_BLOCK ;
@@ -225,18 +236,17 @@ int MS_CardInit(struct us_data *us)if (result) goto exit; -for (TmpBlock=MS_PHYSICAL_BLOCKS_PER_SEGMENT ; TmpBlock<us->MS_Lib.NumberOfPhyBlock; TmpBlock+=MS_PHYSICAL_BLOCKS_PER_SEGMENT ) - { -if (MS_CountFreeBlock (us, TmpBlock) ==0 ) - { +for (TmpBlock =MS_PHYSICAL_BLOCKS_PER_SEGMENT ; + TmpBlock < us->MS_Lib.NumberOfPhyBlock; + TmpBlock +=MS_PHYSICAL_BLOCKS_PER_SEGMENT ) { +if (MS_CountFreeBlock (us, TmpBlock) ==0 ) {MS_LibCtrlSet (us,MS_LIB_CTRL_WRPROTECT );break ; } } -// write -if (MS_LibAllocWriteBuf (us)) - { +/* write */ +if (MS_LibAllocWriteBuf (us)) { result =MS_NO_MEMORY_ERROR ; goto exit; }
@@ -245,46 +255,48 @@ int MS_CardInit(struct us_data *us) exit:kfree (PageBuffer1); -kfree (PageBuffer0); +kfree (PageBuffer0); -printk ("MS_CardInit end\n" ); +printk (KERN_INFO "MS_CardInit end\n" );return result; } -//----- MS_LibCheckDisableBlock() ------------------------------------ +/* +* MS_LibCheckDisableBlock() +*/ int MS_LibCheckDisableBlock (struct us_data *us,WORD PhyBlock) { -PWORD PageBuf=NULL ; -DWORD result=MS_STATUS_SUCCESS ; -DWORD blk, index=0 ; +PWORD PageBuf =NULL ; +DWORD result =MS_STATUS_SUCCESS ; +DWORD blk, index =0 ;MS_LibTypeExtdat extdat; -if (((PageBuf =kmalloc (MS_BYTES_PER_PAGE ,GFP_KERNEL )) ==NULL )) - { + PageBuf =kmalloc (MS_BYTES_PER_PAGE ,GFP_KERNEL ); +if (PageBuf ==NULL ) { result =MS_NO_MEMORY_ERROR ; goto exit; }MS_ReaderReadPage (us, PhyBlock,1 , (DWORD *)PageBuf, &extdat); -do - { +do { blk =be16_to_cpu (PageBuf[index]);if (blk ==MS_LB_NOT_USED )break ; -if (blk == us->MS_Lib.Log2PhyMap[0 ]) - { +if (blk == us->MS_Lib.Log2PhyMap[0 ]) { result =MS_ERROR_FLASH_READ ;break ; } index++; - }while (1 ); + }while (1 ); exit:kfree (PageBuf);return result; } -//----- MS_LibFreeAllocatedArea() ------------------------------------ +/* +* MS_LibFreeAllocatedArea() +*/ void MS_LibFreeAllocatedArea (struct us_data *us) {MS_LibFreeWriteBuf (us);
@@ -302,26 +314,31 @@ void MS_LibFreeAllocatedArea(struct us_data *us) us->MS_Lib.NumberOfLogBlock =0 ; } -//----- MS_LibFreeWriteBuf() ----------------------------------------- +/* +* MS_LibFreeWriteBuf() +*/ void MS_LibFreeWriteBuf (struct us_data *us) { - us->MS_Lib.wrtblk = (WORD )-1 ;//set to -1 -MS_LibClearPageMap (us);// memset((fdoExt)->MS_Lib.pagemap, 0, sizeof((fdoExt)->MS_Lib.pagemap)) + us->MS_Lib.wrtblk = (WORD )-1 ;/* set to -1 */ -if (us->MS_Lib.blkpag) - { -kfree ((BYTE *)(us->MS_Lib.blkpag));// Arnold test ... +/* memset((fdoExt)->MS_Lib.pagemap, 0, +sizeof((fdoExt)->MS_Lib.pagemap)) */ +MS_LibClearPageMap (us); + +if (us->MS_Lib.blkpag) { +kfree ((BYTE *)(us->MS_Lib.blkpag));/* Arnold test ... */ us->MS_Lib.blkpag =NULL ; } -if (us->MS_Lib.blkext) - { -kfree ((BYTE *)(us->MS_Lib.blkext));// Arnold test ... +if (us->MS_Lib.blkext) { +kfree ((BYTE *)(us->MS_Lib.blkext));/* Arnold test ... */ us->MS_Lib.blkext =NULL ; } } -//----- MS_LibFreeLogicalMap() --------------------------------------- +/* +* MS_LibFreeLogicalMap() +*/ int MS_LibFreeLogicalMap (struct us_data *us) {kfree (us->MS_Lib.Phy2LogMap);
@@ -330,10 +347,12 @@ int MS_LibFreeLogicalMap(struct us_data *us)kfree (us->MS_Lib.Log2PhyMap); us->MS_Lib.Log2PhyMap =NULL ; -return 0 ; +return 0 ; } -//----- MS_LibProcessBootBlock() ------------------------------------- +/* +* MS_LibProcessBootBlock() +*/ int MS_LibProcessBootBlock (struct us_data *us,WORD PhyBlock,BYTE *PageData) {MemStickBootBlockSysEnt *SysEntry;
@@ -343,144 +362,165 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)BYTE *PageBuffer;MS_LibTypeExtdat ExtraData; -if ((PageBuffer =kmalloc (MS_BYTES_PER_PAGE ,GFP_KERNEL ))==NULL ) + + PageBuffer =kmalloc (MS_BYTES_PER_PAGE ,GFP_KERNEL ); +if (PageBuffer ==NULL )return (DWORD )-1 ; result = (DWORD )-1 ; - SysInfo= &(((MemStickBootBlockPage0 *)PageData)->sysinf); + SysInfo = &(((MemStickBootBlockPage0 *)PageData)->sysinf); -if ((SysInfo->bMsClass !=MS_SYSINF_MSCLASS_TYPE_1 ) || - (be16_to_cpu (SysInfo->wPageSize) !=MS_SYSINF_PAGE_SIZE ) || +if ((SysInfo->bMsClass !=MS_SYSINF_MSCLASS_TYPE_1 ) || + (be16_to_cpu (SysInfo->wPageSize) !=MS_SYSINF_PAGE_SIZE ) || ((SysInfo->bSecuritySupport &MS_SYSINF_SECURITY ) ==MS_SYSINF_SECURITY_SUPPORT ) || - (SysInfo->bReserved1 !=MS_SYSINF_RESERVED1 ) || - (SysInfo->bReserved2 !=MS_SYSINF_RESERVED2 ) || - (SysInfo->bFormatType!=MS_SYSINF_FORMAT_FAT ) || + (SysInfo->bReserved1 !=MS_SYSINF_RESERVED1 ) || + (SysInfo->bReserved2 !=MS_SYSINF_RESERVED2 ) || + (SysInfo->bFormatType !=MS_SYSINF_FORMAT_FAT ) || (SysInfo->bUsage !=MS_SYSINF_USAGE_GENERAL )) goto exit; -switch (us->MS_Lib.cardType = SysInfo->bCardType) - { -case MS_SYSINF_CARDTYPE_RDONLY : -MS_LibCtrlSet (us,MS_LIB_CTRL_RDONLY ); -break ; -case MS_SYSINF_CARDTYPE_RDWR : -MS_LibCtrlReset (us,MS_LIB_CTRL_RDONLY ); -break ; -case MS_SYSINF_CARDTYPE_HYBRID : -default : - goto exit; +switch (us->MS_Lib.cardType = SysInfo->bCardType) { +case MS_SYSINF_CARDTYPE_RDONLY : +MS_LibCtrlSet (us,MS_LIB_CTRL_RDONLY ); +break ; +case MS_SYSINF_CARDTYPE_RDWR : +MS_LibCtrlReset (us,MS_LIB_CTRL_RDONLY ); +break ; +case MS_SYSINF_CARDTYPE_HYBRID : +default : + goto exit; } us->MS_Lib.blockSize =be16_to_cpu (SysInfo->wBlockSize); us->MS_Lib.NumberOfPhyBlock =be16_to_cpu (SysInfo->wBlockNumber); - us->MS_Lib.NumberOfLogBlock =be16_to_cpu (SysInfo->wTotalBlockNumber) -2 ; - us->MS_Lib.PagesPerBlock = us->MS_Lib.blockSize *SIZE_OF_KIRO /MS_BYTES_PER_PAGE ; - us->MS_Lib.NumberOfSegment = us->MS_Lib.NumberOfPhyBlock /MS_PHYSICAL_BLOCKS_PER_SEGMENT ; + us->MS_Lib.NumberOfLogBlock =be16_to_cpu (SysInfo->wTotalBlockNumber) + -2 ; + us->MS_Lib.PagesPerBlock = us->MS_Lib.blockSize *SIZE_OF_KIRO / +MS_BYTES_PER_PAGE ; + us->MS_Lib.NumberOfSegment = us->MS_Lib.NumberOfPhyBlock / +MS_PHYSICAL_BLOCKS_PER_SEGMENT ; us->MS_Model =be16_to_cpu (SysInfo->wMemorySize); -if (MS_LibAllocLogicalMap (us))//Allocate to all number of logicalblock and physicalblock +/*Allocate to all number of logicalblock and physicalblock */ +if (MS_LibAllocLogicalMap (us)) goto exit; -MS_LibSetBootBlockMark (us, PhyBlock);//Mark the book block +/* Mark the book block */ +MS_LibSetBootBlockMark (us, PhyBlock); SysEntry = &(((MemStickBootBlockPage0 *)PageData)->sysent); -for (i=0 ; i<MS_NUMBER_OF_SYSTEM_ENTRY ; i++) - { +for (i =0 ; i <MS_NUMBER_OF_SYSTEM_ENTRY ; i++) {DWORD EntryOffset, EntrySize; -if ((EntryOffset =be32_to_cpu (SysEntry->entry[i].dwStart)) ==0xffffff ) + EntryOffset =be32_to_cpu (SysEntry->entry[i].dwStart); + +if (EntryOffset ==0xffffff )continue ; + EntrySize =be32_to_cpu (SysEntry->entry[i].dwSize); -if ((EntrySize =be32_to_cpu (SysEntry->entry[i].dwSize)) ==0 ) +if (EntrySize ==0 )continue ; -if (EntryOffset +MS_BYTES_PER_PAGE + EntrySize > us->MS_Lib.blockSize * (DWORD )SIZE_OF_KIRO ) +if (EntryOffset +MS_BYTES_PER_PAGE + EntrySize > + us->MS_Lib.blockSize * (DWORD )SIZE_OF_KIRO )continue ; -if (i ==0 ) - { +if (i ==0 ) {BYTE PrevPageNumber =0 ;WORD phyblk; -if (SysEntry->entry[i].bType !=MS_SYSENT_TYPE_INVALID_BLOCK ) +if (SysEntry->entry[i].bType != +MS_SYSENT_TYPE_INVALID_BLOCK ) goto exit; -while (EntrySize >0 ) - { -if ((PageNumber = (BYTE )(EntryOffset /MS_BYTES_PER_PAGE +1 )) != PrevPageNumber) - { -switch (MS_ReaderReadPage (us, PhyBlock, PageNumber, (DWORD *)PageBuffer, &ExtraData)) - { -case MS_STATUS_SUCCESS : -break ; -case MS_STATUS_WRITE_PROTECT : -case MS_ERROR_FLASH_READ : -case MS_STATUS_ERROR : -default : - goto exit; +while (EntrySize >0 ) { + + PageNumber = (BYTE )(EntryOffset / +MS_BYTES_PER_PAGE +1 ); +if (PageNumber != PrevPageNumber) { +switch (MS_ReaderReadPage (us, PhyBlock, + PageNumber, (DWORD *)PageBuffer, + &ExtraData)) { +case MS_STATUS_SUCCESS : +break ; +case MS_STATUS_WRITE_PROTECT : +case MS_ERROR_FLASH_READ : +case MS_STATUS_ERROR : +default : + goto exit; } PrevPageNumber = PageNumber; } -if ((phyblk =be16_to_cpu (*(WORD *)(PageBuffer + (EntryOffset %MS_BYTES_PER_PAGE )))) <0x0fff ) + phyblk =be16_to_cpu (*(WORD *)(PageBuffer + + (EntryOffset %MS_BYTES_PER_PAGE ))); +if (phyblk <0x0fff )MS_LibSetInitialErrorBlock (us, phyblk); EntryOffset +=2 ; EntrySize -=2 ; } - } -else if (i ==1 ) - {// CIS/IDI + }else if (i ==1 ) {/* CIS/IDI */ MemStickBootBlockIDI *idi;if (SysEntry->entry[i].bType !=MS_SYSENT_TYPE_CIS_IDI ) goto exit; -switch (MS_ReaderReadPage (us, PhyBlock, (BYTE )(EntryOffset /MS_BYTES_PER_PAGE +1 ), (DWORD *)PageBuffer, &ExtraData)) - { -case MS_STATUS_SUCCESS : -break ; -case MS_STATUS_WRITE_PROTECT : -case MS_ERROR_FLASH_READ : -case MS_STATUS_ERROR : -default : - goto exit; +switch (MS_ReaderReadPage (us, PhyBlock, + (BYTE )(EntryOffset /MS_BYTES_PER_PAGE +1 ), + (DWORD *)PageBuffer, &ExtraData)) { +case MS_STATUS_SUCCESS : +break ; +case MS_STATUS_WRITE_PROTECT : +case MS_ERROR_FLASH_READ : +case MS_STATUS_ERROR : +default : + goto exit; } - idi = &((MemStickBootBlockCIS_IDI *)(PageBuffer + (EntryOffset %MS_BYTES_PER_PAGE )))->idi.idi; -if (le16_to_cpu (idi->wIDIgeneralConfiguration) !=MS_IDI_GENERAL_CONF ) + idi = &((MemStickBootBlockCIS_IDI *)(PageBuffer + + (EntryOffset %MS_BYTES_PER_PAGE )))->idi.idi; +if (le16_to_cpu (idi->wIDIgeneralConfiguration) != +MS_IDI_GENERAL_CONF ) goto exit; - us->MS_Lib.BytesPerSector =le16_to_cpu (idi->wIDIbytesPerSector); + us->MS_Lib.BytesPerSector = +le16_to_cpu (idi->wIDIbytesPerSector);if (us->MS_Lib.BytesPerSector !=MS_BYTES_PER_PAGE ) goto exit; } - }// End for .. + }/* End for .. */ result =0 ; exit: -if (result)MS_LibFreeLogicalMap (us); +if (result) +MS_LibFreeLogicalMap (us); +kfree (PageBuffer); result =0 ;return result; } -//----- MS_LibAllocLogicalMap() -------------------------------------- +/* +* MS_LibAllocLogicalMap() +*/ int MS_LibAllocLogicalMap (struct us_data *us) {DWORD i; - us->MS_Lib.Phy2LogMap =kmalloc (us->MS_Lib.NumberOfPhyBlock *sizeof (WORD ),GFP_KERNEL ); - us->MS_Lib.Log2PhyMap =kmalloc (us->MS_Lib.NumberOfLogBlock *sizeof (WORD ),GFP_KERNEL ); + us->MS_Lib.Phy2LogMap =kmalloc (us->MS_Lib.NumberOfPhyBlock * +sizeof (WORD ),GFP_KERNEL ); + us->MS_Lib.Log2PhyMap =kmalloc (us->MS_Lib.NumberOfLogBlock * +sizeof (WORD ),GFP_KERNEL ); -if ((us->MS_Lib.Phy2LogMap ==NULL ) || (us->MS_Lib.Log2PhyMap ==NULL )) - { +if ((us->MS_Lib.Phy2LogMap ==NULL ) || + (us->MS_Lib.Log2PhyMap ==NULL )) {MS_LibFreeLogicalMap (us);return (DWORD )-1 ; }
@@ -489,128 +529,142 @@ int MS_LibAllocLogicalMap(struct us_data *us) us->MS_Lib.Phy2LogMap[i] =MS_LB_NOT_USED ;for (i =0 ; i < us->MS_Lib.NumberOfLogBlock; i++) - us->MS_Lib.Log2PhyMap[i] =MS_LB_NOT_USED ; + us->MS_Lib.Log2PhyMap[i] =MS_LB_NOT_USED ;return 0 ; } -//----- MS_LibSetBootBlockMark() ------------------------------------- +/* +* MS_LibSetBootBlockMark() +*/ int MS_LibSetBootBlockMark (struct us_data *us,WORD phyblk) { -return MS_LibSetLogicalBlockMark (us, phyblk,MS_LB_BOOT_BLOCK ); +return MS_LibSetLogicalBlockMark (us, phyblk,MS_LB_BOOT_BLOCK ); } -//----- MS_LibSetLogicalBlockMark() ---------------------------------- +/* +* MS_LibSetLogicalBlockMark() +*/ int MS_LibSetLogicalBlockMark (struct us_data *us,WORD phyblk,WORD mark) { -if (phyblk >= us->MS_Lib.NumberOfPhyBlock) -return (DWORD )-1 ; +if (phyblk >= us->MS_Lib.NumberOfPhyBlock) +return (DWORD )-1 ; - us->MS_Lib.Phy2LogMap[phyblk] = mark; + us->MS_Lib.Phy2LogMap[phyblk] = mark; -return 0 ; +return 0 ; } -//----- MS_LibSetInitialErrorBlock() --------------------------------- +/* +* MS_LibSetInitialErrorBlock() +*/ int MS_LibSetInitialErrorBlock (struct us_data *us,WORD phyblk) { -return MS_LibSetLogicalBlockMark (us, phyblk,MS_LB_INITIAL_ERROR ); +return MS_LibSetLogicalBlockMark (us, phyblk,MS_LB_INITIAL_ERROR ); } -//----- MS_LibScanLogicalBlockNumber() ------------------------------- +/* +* MS_LibScanLogicalBlockNumber() +*/ int MS_LibScanLogicalBlockNumber (struct us_data *us,WORD btBlk1st) {WORD PhyBlock, newblk, i;WORD LogStart, LogEnde;MS_LibTypeExtdat extdat;BYTE buf[0x200 ]; -DWORD count=0 , index=0 ; +DWORD count =0 , index =0 ; -for (PhyBlock =0 ; PhyBlock < us->MS_Lib.NumberOfPhyBlock;) - { +for (PhyBlock =0 ; PhyBlock < us->MS_Lib.NumberOfPhyBlock;) {MS_LibPhy2LogRange (PhyBlock, &LogStart, &LogEnde); -for (i=0 ; i<MS_PHYSICAL_BLOCKS_PER_SEGMENT ; i++, PhyBlock++) - { -switch (MS_LibConv2Logical (us, PhyBlock)) - { -case MS_STATUS_ERROR : -continue ; -default : -break ; +for (i =0 ; i <MS_PHYSICAL_BLOCKS_PER_SEGMENT ; + i++, PhyBlock++) { +switch (MS_LibConv2Logical (us, PhyBlock)) { +case MS_STATUS_ERROR : +continue ; +default : +break ; } -if (count == PhyBlock) - { -MS_LibReadExtraBlock (us, PhyBlock,0 ,0x80 , &buf); +if (count == PhyBlock) { +MS_LibReadExtraBlock (us, PhyBlock, +0 ,0x80 , &buf); count +=0x80 ; } index = (PhyBlock %0x80 ) *4 ; extdat.ovrflg = buf[index]; extdat.mngflg = buf[index+1 ]; - extdat.logadr =MemStickLogAddr (buf[index+2 ], buf[index+3 ]); + extdat.logadr =MemStickLogAddr (buf[index+2 ], + buf[index+3 ]); -if ((extdat.ovrflg &MS_REG_OVR_BKST ) !=MS_REG_OVR_BKST_OK ) - { +if ((extdat.ovrflg &MS_REG_OVR_BKST ) != +MS_REG_OVR_BKST_OK ) {MS_LibSetAcquiredErrorBlock (us, PhyBlock);continue ; } -if ((extdat.mngflg &MS_REG_MNG_ATFLG ) ==MS_REG_MNG_ATFLG_ATTBL ) - { +if ((extdat.mngflg &MS_REG_MNG_ATFLG ) == +MS_REG_MNG_ATFLG_ATTBL ) {MS_LibErasePhyBlock (us, PhyBlock);continue ; } -if (extdat.logadr !=MS_LB_NOT_USED ) - { -if ((extdat.logadr < LogStart) || (LogEnde <= extdat.logadr)) - { +if (extdat.logadr !=MS_LB_NOT_USED ) { +if ((extdat.logadr < LogStart) || + (LogEnde <= extdat.logadr)) {MS_LibErasePhyBlock (us, PhyBlock);continue ; } -if ((newblk =MS_LibConv2Physical (us, extdat.logadr)) !=MS_LB_NOT_USED ) - { -if (extdat.logadr==0 ) - { -MS_LibSetLogicalPair (us, extdat.logadr, PhyBlock); -if (MS_LibCheckDisableBlock (us, btBlk1st) ) - { -MS_LibSetLogicalPair (us, extdat.logadr, newblk); + newblk =MS_LibConv2Physical (us, extdat.logadr); + +if (newblk !=MS_LB_NOT_USED ) { +if (extdat.logadr ==0 ) { +MS_LibSetLogicalPair (us, + extdat.logadr, + PhyBlock); +if (MS_LibCheckDisableBlock (us, + btBlk1st)) { +MS_LibSetLogicalPair (us, + extdat.logadr, newblk);continue ; } }MS_LibReadExtra (us, newblk,0 , &extdat); -if ((extdat.ovrflg &MS_REG_OVR_UDST ) ==MS_REG_OVR_UDST_UPDATING ) - { -MS_LibErasePhyBlock (us, PhyBlock); +if ((extdat.ovrflg &MS_REG_OVR_UDST ) == +MS_REG_OVR_UDST_UPDATING ) { +MS_LibErasePhyBlock (us, + PhyBlock);continue ; - } -else + }else {MS_LibErasePhyBlock (us, newblk); + } } -MS_LibSetLogicalPair (us, extdat.logadr, PhyBlock); +MS_LibSetLogicalPair (us, extdat.logadr, + PhyBlock); } } - }//End for ... + }/* End for ... */ return MS_STATUS_SUCCESS ; } -//----- MS_LibAllocWriteBuf() ---------------------------------------- +/* +* MS_LibAllocWriteBuf() +*/ int MS_LibAllocWriteBuf (struct us_data *us) { us->MS_Lib.wrtblk = (WORD )-1 ; - us->MS_Lib.blkpag =kmalloc (us->MS_Lib.PagesPerBlock * us->MS_Lib.BytesPerSector,GFP_KERNEL ); - us->MS_Lib.blkext =kmalloc (us->MS_Lib.PagesPerBlock *sizeof (MS_LibTypeExtdat),GFP_KERNEL ); + us->MS_Lib.blkpag =kmalloc (us->MS_Lib.PagesPerBlock * + us->MS_Lib.BytesPerSector,GFP_KERNEL ); + us->MS_Lib.blkext =kmalloc (us->MS_Lib.PagesPerBlock * +sizeof (MS_LibTypeExtdat),GFP_KERNEL ); -if ((us->MS_Lib.blkpag ==NULL ) || (us->MS_Lib.blkext ==NULL )) - { +if ((us->MS_Lib.blkpag ==NULL ) || (us->MS_Lib.blkext ==NULL )) {MS_LibFreeWriteBuf (us);return (DWORD )-1 ; }
@@ -620,7 +674,9 @@ int MS_LibAllocWriteBuf(struct us_data *us)return 0 ; } -//----- MS_LibClearWriteBuf() ---------------------------------------- +/* +* MS_LibClearWriteBuf() +*/ void MS_LibClearWriteBuf (struct us_data *us) {int i;
@@ -629,12 +685,11 @@ void MS_LibClearWriteBuf(struct us_data *us)MS_LibClearPageMap (us);if (us->MS_Lib.blkpag) -memset (us->MS_Lib.blkpag,0xff , us->MS_Lib.PagesPerBlock * us->MS_Lib.BytesPerSector); +memset (us->MS_Lib.blkpag,0xff , + us->MS_Lib.PagesPerBlock * us->MS_Lib.BytesPerSector); -if (us->MS_Lib.blkext) - { -for (i =0 ; i < us->MS_Lib.PagesPerBlock; i++) - { +if (us->MS_Lib.blkext) { +for (i =0 ; i < us->MS_Lib.PagesPerBlock; i++) { us->MS_Lib.blkext[i].status1 =MS_REG_ST1_DEFAULT ; us->MS_Lib.blkext[i].ovrflg =MS_REG_OVR_DEFAULT ; us->MS_Lib.blkext[i].mngflg =MS_REG_MNG_DEFAULT ;
@@ -643,32 +698,36 @@ void MS_LibClearWriteBuf(struct us_data *us) } } -//----- MS_LibPhy2LogRange() ----------------------------------------- +/* +* MS_LibPhy2LogRange() +*/ void MS_LibPhy2LogRange (WORD PhyBlock,WORD *LogStart,WORD *LogEnde) { PhyBlock /=MS_PHYSICAL_BLOCKS_PER_SEGMENT ; -if (PhyBlock) - { - *LogStart =MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT + (PhyBlock -1 ) *MS_LOGICAL_BLOCKS_PER_SEGMENT ;//496 - *LogEnde = *LogStart +MS_LOGICAL_BLOCKS_PER_SEGMENT ;//496 - } -else - { +if (PhyBlock) { + *LogStart =MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT + + (PhyBlock -1 ) *MS_LOGICAL_BLOCKS_PER_SEGMENT ;/*496*/ + *LogEnde = *LogStart +MS_LOGICAL_BLOCKS_PER_SEGMENT ;/*496*/ + }else { *LogStart =0 ; - *LogEnde =MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT ;//494 + *LogEnde =MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT ;/*494*/ } } -//----- MS_LibReadExtraBlock() -------------------------------------------- -int MS_LibReadExtraBlock (struct us_data *us,DWORD PhyBlock,BYTE PageNum,BYTE blen,void *buf) +/* +* MS_LibReadExtraBlock() +*/ +int MS_LibReadExtraBlock (struct us_data *us,DWORD PhyBlock, +BYTE PageNum,BYTE blen,void *buf) {struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;int result; -//printk("MS_LibReadExtraBlock --- PhyBlock = %x, PageNum = %x, blen = %x\n", PhyBlock, PageNum, blen); +/* printk("MS_LibReadExtraBlock --- PhyBlock = %x, +PageNum = %x, blen = %x\n", PhyBlock, PageNum, blen); */ -// Read Extra Data +/* Read Extra Data */ memset (bcb,0 ,sizeof (struct bulk_cb_wrap )); bcb->Signature =cpu_to_le32 (US_BULK_CB_SIGN ); bcb->DataTransferLength =0x4 * blen;
@@ -688,14 +747,18 @@ int MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock, BYTE PageNum, BYTEreturn USB_STOR_TRANSPORT_GOOD ; } -//----- MS_LibReadExtra() -------------------------------------------- -int MS_LibReadExtra (struct us_data *us,DWORD PhyBlock,BYTE PageNum,MS_LibTypeExtdat *ExtraDat) +/* +* MS_LibReadExtra() +*/ +int MS_LibReadExtra (struct us_data *us,DWORD PhyBlock, +BYTE PageNum,MS_LibTypeExtdat *ExtraDat) {struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;int result;BYTE ExtBuf[4 ]; -//printk("MS_LibReadExtra --- PhyBlock = %x, PageNum = %x\n", PhyBlock, PageNum); +/* printk("MS_LibReadExtra --- PhyBlock = %x, PageNum = %x\n" +, PhyBlock, PageNum); */ memset (bcb,0 ,sizeof (struct bulk_cb_wrap )); bcb->Signature =cpu_to_le32 (US_BULK_CB_SIGN ); bcb->DataTransferLength =0x4 ;
@@ -707,23 +770,25 @@ int MS_LibReadExtra(struct us_data *us, DWORD PhyBlock, BYTE PageNum, MS_LibType bcb->CDB[3 ] = (BYTE )(PhyBlock>>8 ); bcb->CDB[2 ] = (BYTE )(PhyBlock>>16 ); bcb->CDB[6 ] =0x01 ; - + result =ENE_SendScsiCmd (us,FDIR_READ , &ExtBuf,0 );if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ; ExtraDat->reserved =0 ; - ExtraDat->intr =0x80 ;// Not yet, waiting for fireware support - ExtraDat->status0 =0x10 ;// Not yet, waiting for fireware support - ExtraDat->status1 =0x00 ;// Not yet, waiting for fireware support + ExtraDat->intr =0x80 ;/* Not yet, waiting for fireware support */ + ExtraDat->status0 =0x10 ;/* Not yet, waiting for fireware support */ + ExtraDat->status1 =0x00 ;/* Not yet, waiting for fireware support */ ExtraDat->ovrflg = ExtBuf[0 ]; ExtraDat->mngflg = ExtBuf[1 ]; ExtraDat->logadr =MemStickLogAddr (ExtBuf[2 ], ExtBuf[3 ]); - +return USB_STOR_TRANSPORT_GOOD ; } -//----- MS_LibSetAcquiredErrorBlock() -------------------------------- +/* +* MS_LibSetAcquiredErrorBlock() +*/ int MS_LibSetAcquiredErrorBlock (struct us_data *us,WORD phyblk) {WORD log;
@@ -731,7 +796,9 @@ int MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk)if (phyblk >= us->MS_Lib.NumberOfPhyBlock)return (DWORD )-1 ; -if ((log = us->MS_Lib.Phy2LogMap[phyblk]) < us->MS_Lib.NumberOfLogBlock) + log = us->MS_Lib.Phy2LogMap[phyblk]; + +if (log < us->MS_Lib.NumberOfLogBlock) us->MS_Lib.Log2PhyMap[log] =MS_LB_NOT_USED ;if (us->MS_Lib.Phy2LogMap[phyblk] !=MS_LB_INITIAL_ERROR )
@@ -740,7 +807,9 @@ int MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk)return 0 ; } -//----- MS_LibErasePhyBlock() ---------------------------------------- +/* +* MS_LibErasePhyBlock() +*/ int MS_LibErasePhyBlock (struct us_data *us,WORD phyblk) {WORD log;
@@ -748,27 +817,27 @@ int MS_LibErasePhyBlock(struct us_data *us, WORD phyblk)if (phyblk >= us->MS_Lib.NumberOfPhyBlock)return MS_STATUS_ERROR ; -if ((log = us->MS_Lib.Phy2LogMap[phyblk]) < us->MS_Lib.NumberOfLogBlock) + log = us->MS_Lib.Phy2LogMap[phyblk]; + +if (log < us->MS_Lib.NumberOfLogBlock) us->MS_Lib.Log2PhyMap[log] =MS_LB_NOT_USED ; us->MS_Lib.Phy2LogMap[phyblk] =MS_LB_NOT_USED ; -if (MS_LibIsWritable (us)) - { -switch (MS_ReaderEraseBlock (us, phyblk)) - { -case MS_STATUS_SUCCESS : - us->MS_Lib.Phy2LogMap[phyblk] =MS_LB_NOT_USED_ERASED ; -return MS_STATUS_SUCCESS ; -case MS_ERROR_FLASH_ERASE : -case MS_STATUS_INT_ERROR : -MS_LibErrorPhyBlock (us, phyblk); -return MS_ERROR_FLASH_ERASE ; -case MS_STATUS_ERROR : -default : -MS_LibCtrlSet (us,MS_LIB_CTRL_RDONLY ); -MS_LibSetAcquiredErrorBlock (us, phyblk); -return MS_STATUS_ERROR ; +if (MS_LibIsWritable (us)) { +switch (MS_ReaderEraseBlock (us, phyblk)) { +case MS_STATUS_SUCCESS : + us->MS_Lib.Phy2LogMap[phyblk] =MS_LB_NOT_USED_ERASED ; +return MS_STATUS_SUCCESS ; +case MS_ERROR_FLASH_ERASE : +case MS_STATUS_INT_ERROR : +MS_LibErrorPhyBlock (us, phyblk); +return MS_ERROR_FLASH_ERASE ; +case MS_STATUS_ERROR : +default : +MS_LibCtrlSet (us,MS_LIB_CTRL_RDONLY ); +MS_LibSetAcquiredErrorBlock (us, phyblk); +return MS_STATUS_ERROR ; } }
@@ -777,29 +846,35 @@ int MS_LibErasePhyBlock(struct us_data *us, WORD phyblk)return MS_STATUS_SUCCESS ; } -//----- MS_LibErrorPhyBlock() ---------------------------------------- +/* +* MS_LibErrorPhyBlock() +*/ int MS_LibErrorPhyBlock (struct us_data *us,WORD phyblk) { -if (phyblk >= us->MS_Lib.NumberOfPhyBlock) -return MS_STATUS_ERROR ; +if (phyblk >= us->MS_Lib.NumberOfPhyBlock) +return MS_STATUS_ERROR ; -MS_LibSetAcquiredErrorBlock (us, phyblk); +MS_LibSetAcquiredErrorBlock (us, phyblk); -if (MS_LibIsWritable (us)) -return MS_LibOverwriteExtra (us, phyblk,0 , +if (MS_LibIsWritable (us)) +return MS_LibOverwriteExtra (us, phyblk,0 , (BYTE )(~MS_REG_OVR_BKST &BYTE_MASK )); -return MS_STATUS_SUCCESS ; +return MS_STATUS_SUCCESS ; } -//----- MS_LibOverwriteExtra() --------------------------------------- -int MS_LibOverwriteExtra (struct us_data *us,DWORD PhyBlockAddr,BYTE PageNum,BYTE OverwriteFlag) +/* +* MS_LibOverwriteExtra() +*/ +int MS_LibOverwriteExtra (struct us_data *us,DWORD PhyBlockAddr, +BYTE PageNum,BYTE OverwriteFlag) {struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;int result; -//printk("MS --- MS_LibOverwriteExtra, PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum); +/* printk("MS --- MS_LibOverwriteExtra, \ +PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum); */ result =ENE_LoadBinCode (us,MS_RW_PATTERN );if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ;
@@ -818,7 +893,7 @@ int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, B bcb->CDB[7 ] =0xFF ; bcb->CDB[8 ] =0xFF ; bcb->CDB[9 ] =0xFF ; - + result =ENE_SendScsiCmd (us,FDIR_READ ,NULL ,0 );if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ;
@@ -826,13 +901,16 @@ int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, Breturn USB_STOR_TRANSPORT_GOOD ; } -//----- MS_LibForceSetLogicalPair() ---------------------------------- +/* +* MS_LibForceSetLogicalPair() +*/ int MS_LibForceSetLogicalPair (struct us_data *us,WORD logblk,WORD phyblk) {if (logblk ==MS_LB_NOT_USED )return 0 ; -if ((logblk >= us->MS_Lib.NumberOfLogBlock) || (phyblk >= us->MS_Lib.NumberOfPhyBlock)) +if ((logblk >= us->MS_Lib.NumberOfLogBlock) || + (phyblk >= us->MS_Lib.NumberOfPhyBlock))return (DWORD )-1 ; us->MS_Lib.Phy2LogMap[phyblk] = logblk;
@@ -841,10 +919,13 @@ int MS_LibForceSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk)return 0 ; } -//----- MS_LibSetLogicalPair() --------------------------------------- +/* +* MS_LibSetLogicalPair() +*/ int MS_LibSetLogicalPair (struct us_data *us,WORD logblk,WORD phyblk) { -if ((logblk >= us->MS_Lib.NumberOfLogBlock) || (phyblk >= us->MS_Lib.NumberOfPhyBlock)) +if ((logblk >= us->MS_Lib.NumberOfLogBlock) || + (phyblk >= us->MS_Lib.NumberOfPhyBlock))return (DWORD )-1 ; us->MS_Lib.Phy2LogMap[phyblk] = logblk;
@@ -853,28 +934,30 @@ int MS_LibSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk)return 0 ; } -//----- MS_CountFreeBlock() ------------------------------------------ +/* +* MS_CountFreeBlock() +*/ int MS_CountFreeBlock (struct us_data *us,WORD PhyBlock) {DWORD Ende, Count; Ende = PhyBlock +MS_PHYSICAL_BLOCKS_PER_SEGMENT ; -for (Count =0 ; PhyBlock < Ende; PhyBlock++) - { -switch (us->MS_Lib.Phy2LogMap[PhyBlock]) - { -case MS_LB_NOT_USED : -case MS_LB_NOT_USED_ERASED : - Count++; -default : -break ; +for (Count =0 ; PhyBlock < Ende; PhyBlock++) { +switch (us->MS_Lib.Phy2LogMap[PhyBlock]) { +case MS_LB_NOT_USED : +case MS_LB_NOT_USED_ERASED : + Count++; +default : +break ; } }return Count; } -//----- MS_LibSearchBlockFromPhysical() ------------------------------ +/* +* MS_LibSearchBlockFromPhysical() +*/ int MS_LibSearchBlockFromPhysical (struct us_data *us,WORD phyblk) {WORD Newblk;
@@ -884,70 +967,68 @@ int MS_LibSearchBlockFromPhysical(struct us_data *us, WORD phyblk)if (phyblk >= us->MS_Lib.NumberOfPhyBlock)return MS_LB_ERROR ; -for (blk = phyblk +1 ; blk != phyblk; blk++) - { +for (blk = phyblk +1 ; blk != phyblk; blk++) {if ((blk &MS_PHYSICAL_BLOCKS_PER_SEGMENT_MASK ) ==0 ) blk -=MS_PHYSICAL_BLOCKS_PER_SEGMENT ; Newblk = us->MS_Lib.Phy2LogMap[blk];if (us->MS_Lib.Phy2LogMap[blk] ==MS_LB_NOT_USED_ERASED )return blk; -else if (us->MS_Lib.Phy2LogMap[blk] ==MS_LB_NOT_USED ) - { -switch (MS_LibReadExtra (us, blk,0 , &extdat)) - { -case MS_STATUS_SUCCESS : -case MS_STATUS_SUCCESS_WITH_ECC : -break ; -case MS_NOCARD_ERROR : -return MS_NOCARD_ERROR ; -case MS_STATUS_INT_ERROR : -return MS_LB_ERROR ; -case MS_ERROR_FLASH_READ : -default : -MS_LibSetAcquiredErrorBlock (us, blk);// MS_LibErrorPhyBlock(fdoExt, blk); -continue ; - }// End switch +else if (us->MS_Lib.Phy2LogMap[blk] ==MS_LB_NOT_USED ) { +switch (MS_LibReadExtra (us, blk,0 , &extdat)) { +case MS_STATUS_SUCCESS : +case MS_STATUS_SUCCESS_WITH_ECC : +break ; +case MS_NOCARD_ERROR : +return MS_NOCARD_ERROR ; +case MS_STATUS_INT_ERROR : +return MS_LB_ERROR ; +case MS_ERROR_FLASH_READ : +default : +MS_LibSetAcquiredErrorBlock (us, blk); +/* MS_LibErrorPhyBlock(fdoExt, blk); */ +continue ; + }/* End switch */ -if ((extdat.ovrflg &MS_REG_OVR_BKST ) !=MS_REG_OVR_BKST_OK ) - { +if ((extdat.ovrflg &MS_REG_OVR_BKST ) != +MS_REG_OVR_BKST_OK ) {MS_LibSetAcquiredErrorBlock (us, blk);continue ; } -switch (MS_LibErasePhyBlock (us, blk)) - { -case MS_STATUS_SUCCESS : -return blk; -case MS_STATUS_ERROR : -return MS_LB_ERROR ; -case MS_ERROR_FLASH_ERASE : -default : -MS_LibErrorPhyBlock (us, blk); -break ; +switch (MS_LibErasePhyBlock (us, blk)) { +case MS_STATUS_SUCCESS : +return blk; +case MS_STATUS_ERROR : +return MS_LB_ERROR ; +case MS_ERROR_FLASH_ERASE : +default : +MS_LibErrorPhyBlock (us, blk); +break ; } } - }// End for + }/* End for */ return MS_LB_ERROR ; } -//----- MS_LibSearchBlockFromLogical() ------------------------------- +/* +* MS_LibSearchBlockFromLogical() +*/ int MS_LibSearchBlockFromLogical (struct us_data *us,WORD logblk) {WORD phyblk; -if ((phyblk=MS_LibConv2Physical (us, logblk)) >=MS_LB_ERROR ) - { + phyblk =MS_LibConv2Physical (us, logblk); +if (phyblk >=MS_LB_ERROR ) {if (logblk >= us->MS_Lib.NumberOfLogBlock)return MS_LB_ERROR ; - phyblk = (logblk +MS_NUMBER_OF_BOOT_BLOCK ) /MS_LOGICAL_BLOCKS_PER_SEGMENT ; + phyblk = (logblk +MS_NUMBER_OF_BOOT_BLOCK ) / +MS_LOGICAL_BLOCKS_PER_SEGMENT ; phyblk *=MS_PHYSICAL_BLOCKS_PER_SEGMENT ; phyblk +=MS_PHYSICAL_BLOCKS_PER_SEGMENT -1 ; }return MS_LibSearchBlockFromPhysical (us, phyblk); } - -
drivers/staging/keucr/ms.h +179 -159
462 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 2/7 staging/keucr: fix keucr msscsi coding style
In reply to Cho, Yu-ChenFix keucr msscsi.c coding style.
Remove externs ,and move MS_SCSIIrp to end,
because there are not necessary to add extern for MS_SCSIIrp function.
--- drivers/staging/keucr/msscsi.c | 219 +++++++++++++++++++++------------------- 1 files changed, 117 insertions(+), 102 deletions(-)
drivers/staging/keucr/msscsi.c +117 -102
@@ -12,68 +12,48 @@#include "scsiglue.h" #include "transport.h" -int MS_SCSI_Test_Unit_Ready (struct us_data *us,struct scsi_cmnd *srb); -int MS_SCSI_Inquiry (struct us_data *us,struct scsi_cmnd *srb); -int MS_SCSI_Mode_Sense (struct us_data *us,struct scsi_cmnd *srb); -int MS_SCSI_Start_Stop (struct us_data *us,struct scsi_cmnd *srb); -int MS_SCSI_Read_Capacity (struct us_data *us,struct scsi_cmnd *srb); -int MS_SCSI_Read (struct us_data *us,struct scsi_cmnd *srb); -int MS_SCSI_Write (struct us_data *us,struct scsi_cmnd *srb); - -//----- 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; -} - -//----- MS_SCSI_Test_Unit_Ready() -------------------------------------------------- +/* +* 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 - { +else {ENE_MSInit (us);return USB_STOR_TRANSPORT_GOOD ; } - +return USB_STOR_TRANSPORT_GOOD ; } -//----- MS_SCSI_Inquiry() -------------------------------------------------- +/* +* 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 }; +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() -------------------------------------------------- +/* +* 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 }; +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 );
@@ -84,7 +64,9 @@ int MS_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)return USB_STOR_TRANSPORT_GOOD ; } -//----- MS_SCSI_Read_Capacity() -------------------------------------------------- +/* +* MS_SCSI_Read_Capacity() +*/ int MS_SCSI_Read_Capacity (struct us_data *us,struct scsi_cmnd *srb) {unsigned int offset =0 ;
@@ -96,58 +78,62 @@ int MS_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)pr_info ("MS_SCSI_Read_Capacity\n" ); bl_len =0x200 ; -if ( us->MS_Status.IsMSPro ) +if (us->MS_Status.IsMSPro) bl_num = us->MSP_TotalBlock -1 ;else - bl_num = us->MS_Lib.NumberOfLogBlock * us->MS_Lib.blockSize *2 -1 ; + 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 ; - +/* 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); +/* usb_stor_set_xfer_buf(us, buf, srb->request_bufflen, +srb, TO_XFER_BUF); */ return USB_STOR_TRANSPORT_GOOD ; } -//----- MS_SCSI_Read() -------------------------------------------------- +/* +* 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 ; +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 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) - { +if (us->MS_Status.IsMSPro) { result =ENE_LoadBinCode (us,MSP_RW_PATTERN ); -if (result !=USB_STOR_XFER_GOOD ) - { +if (result !=USB_STOR_XFER_GOOD ) {pr_info ("Load MSP RW pattern Fail !!\n" );return USB_STOR_TRANSPORT_ERROR ; } -// set up the command wrapper +/* 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;
@@ -160,11 +146,9 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb) bcb->CDB[2 ] = (BYTE )(bn>>24 ); result =ENE_SendScsiCmd (us,FDIR_READ ,scsi_sglist (srb),1 ); - } -else - { + }else {void *buf; -int offset=0 ; +int offset =0 ;WORD phyblk, logblk;BYTE PageNum;WORD len;
@@ -175,8 +159,7 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)return USB_STOR_TRANSPORT_ERROR ; result =ENE_LoadBinCode (us,MS_RW_PATTERN ); -if (result !=USB_STOR_XFER_GOOD ) - { +if (result !=USB_STOR_XFER_GOOD ) {pr_info ("Load MS RW pattern Fail !!\n" ); result =USB_STOR_TRANSPORT_ERROR ; goto exit;
@@ -185,9 +168,8 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb) logblk = (WORD )(bn / us->MS_Lib.PagesPerBlock); PageNum = (BYTE )(bn % us->MS_Lib.PagesPerBlock); -while (1 ) - { -if (blen > (us->MS_Lib.PagesPerBlock-PageNum) ) +while (1 ) { +if (blen > (us->MS_Lib.PagesPerBlock-PageNum)) len = us->MS_Lib.PagesPerBlock-PageNum;else len = blen;
@@ -195,7 +177,7 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb) phyblk =MS_LibConv2Physical (us, logblk); blkno = phyblk *0x20 + PageNum; -// set up the command wrapper +/* 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;
@@ -208,8 +190,7 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb) bcb->CDB[2 ] = (BYTE )(blkno>>24 ); result =ENE_SendScsiCmd (us,FDIR_READ , buf+offset,0 ); -if (result !=USB_STOR_XFER_GOOD ) - { +if (result !=USB_STOR_XFER_GOOD ) {pr_info ("MS_SCSI_Read --- result = %x\n" , result); result =USB_STOR_TRANSPORT_ERROR ;
@@ -217,7 +198,7 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb) } blen -= len; -if (blen<=0 ) +if (blen <=0 )break ; logblk++; PageNum =0 ;
@@ -230,30 +211,32 @@ exit:return result; } -//----- MS_SCSI_Write() -------------------------------------------------- +/* +* 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 ; +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 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) - { +if (us->MS_Status.IsMSPro) { result =ENE_LoadBinCode (us,MSP_RW_PATTERN ); -if (result !=USB_STOR_XFER_GOOD ) - { +if (result !=USB_STOR_XFER_GOOD ) {pr_info ("Load MSP RW pattern Fail !!\n" );return USB_STOR_TRANSPORT_ERROR ; } -// set up the command wrapper +/* 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;
@@ -266,11 +249,9 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb) bcb->CDB[2 ] = (BYTE )(bn>>24 ); result =ENE_SendScsiCmd (us,FDIR_WRITE ,scsi_sglist (srb),1 ); - } -else - { + }else {void *buf; -int offset=0 ; +int offset =0 ;WORD PhyBlockAddr;BYTE PageNum;DWORD result;
@@ -282,8 +263,7 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)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 ) - { +if (result !=USB_STOR_XFER_GOOD ) {pr_info ("Load MS RW pattern Fail !!\n" ); result =USB_STOR_TRANSPORT_ERROR ; goto exit;
@@ -292,9 +272,8 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb) PhyBlockAddr = (WORD )(bn / us->MS_Lib.PagesPerBlock); PageNum = (BYTE )(bn % us->MS_Lib.PagesPerBlock); -while (1 ) - { -if (blen > (us->MS_Lib.PagesPerBlock-PageNum) ) +while (1 ) { +if (blen > (us->MS_Lib.PagesPerBlock-PageNum)) len = us->MS_Lib.PagesPerBlock-PageNum;else len = blen;
@@ -302,9 +281,10 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb) 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 ) - { + 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 ;
@@ -315,7 +295,7 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)MS_LibForceSetLogicalPair (us, PhyBlockAddr, newphy); blen -= len; -if (blen<=0 ) +if (blen <=0 )break ; PhyBlockAddr++; PageNum =0 ;
@@ -327,3 +307,38 @@ exit: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; +} +
Signature · 1 line
1.7.1
PATCH 3/7 staging/keucr: fix keucr scsiglue coding style
In reply to Cho, Yu-Chenfix keucr scsiglue.c coding style
--- drivers/staging/keucr/scsiglue.c | 157 ++++++++++++++++++++++--------------- 1 files changed, 93 insertions(+), 64 deletions(-)
drivers/staging/keucr/scsiglue.c +93 -64
@@ -15,14 +15,18 @@#include "transport.h" /* Host functions */ -//----- host_info() --------------------- -static const char *host_info (struct Scsi_Host *host) +/* +* host_info() +*/ +static const char *host_info (struct Scsi_Host *host) {/* pr_info("scsiglue --- host_info\n"); */ return "SCSI emulation for USB Mass Storage devices" ; } -//----- slave_alloc() --------------------- +/* +* slave_alloc() +*/ static int slave_alloc (struct scsi_device *sdev) {struct us_data *us =host_to_us (sdev->host);
@@ -38,14 +42,15 @@ static int slave_alloc(struct scsi_device *sdev)return 0 ; } -//----- slave_configure() --------------------- +/* +* slave_configure() +*/ static int slave_configure (struct scsi_device *sdev) {struct us_data *us =host_to_us (sdev->host);/* pr_info("scsiglue --- slave_configure\n"); */ -if (us->fflags & (US_FL_MAX_SECTORS_64 |US_FL_MAX_SECTORS_MIN )) - { +if (us->fflags & (US_FL_MAX_SECTORS_64 |US_FL_MAX_SECTORS_MIN )) {unsigned int max_sectors =64 ;if (us->fflags &US_FL_MAX_SECTORS_MIN )
@@ -55,9 +60,9 @@ static int slave_configure(struct scsi_device *sdev) max_sectors); } -if (sdev->type ==TYPE_DISK ) - { -if (us->subclass !=USB_SC_SCSI && us->subclass !=USB_SC_CYP_ATACB ) +if (sdev->type ==TYPE_DISK ) { +if (us->subclass !=USB_SC_SCSI && + us->subclass !=USB_SC_CYP_ATACB ) sdev->use_10_for_ms =1 ; sdev->use_192_bytes_for_3f =1 ;if (us->fflags &US_FL_NO_WP_DETECT )
@@ -72,13 +77,12 @@ static int slave_configure(struct scsi_device *sdev) sdev->retry_hwerror =1 ; sdev->allow_restart =1 ; sdev->last_sector_bug =1 ; - } -else - { + }else { sdev->use_10_for_ms =1 ; } -if ((us->protocol ==USB_PR_CB || us->protocol ==USB_PR_CBI ) && sdev->scsi_level ==SCSI_UNKNOWN ) +if ((us->protocol ==USB_PR_CB || us->protocol ==USB_PR_CBI ) && + sdev->scsi_level ==SCSI_UNKNOWN ) us->max_lun =0 ;if (us->fflags &US_FL_NOT_LOCKABLE )
@@ -88,24 +92,25 @@ static int slave_configure(struct scsi_device *sdev) }/* This is always called with scsi_lock(host) held */ -//----- queuecommand() --------------------- -static int queuecommand_lck (struct scsi_cmnd *srb,void (*done)(struct scsi_cmnd *)) +/* +* queuecommand() +*/ +static int queuecommand_lck (struct scsi_cmnd *srb, +void (*done)(struct scsi_cmnd *)) {struct us_data *us =host_to_us (srb->device->host);/* pr_info("scsiglue --- queuecommand\n"); */ /* check for state-transition errors */ -if (us->srb !=NULL ) - { +if (us->srb !=NULL ) {/* pr_info("Error in %s: us->srb = %p\n" __FUNCTION__, us->srb); */ return SCSI_MLQUEUE_HOST_BUSY ; }/* fail the command if we are disconnecting */ -if (test_bit (US_FLIDX_DISCONNECTING , &us->dflags)) - { +if (test_bit (US_FLIDX_DISCONNECTING , &us->dflags)) {pr_info ("Fail command during disconnect\n" ); srb->result =DID_NO_CONNECT <<16 ;done (srb);
@@ -127,7 +132,9 @@ static DEF_SCSI_QCMD(queuecommand)***********************************************************************/ /* Command timeout and abort */ -//----- command_abort() --------------------- +/* +* command_abort() +*/ static int command_abort (struct scsi_cmnd *srb) {struct us_data *us =host_to_us (srb->device->host);
@@ -135,16 +142,14 @@ static int command_abort(struct scsi_cmnd *srb)/* pr_info("scsiglue --- command_abort\n"); */ scsi_lock (us_to_host (us)); -if (us->srb != srb) - { +if (us->srb != srb) {scsi_unlock (us_to_host (us));printk ("-- nothing to abort\n" );return FAILED ; }set_bit (US_FLIDX_TIMED_OUT , &us->dflags); -if (!test_bit (US_FLIDX_RESETTING , &us->dflags)) - { +if (!test_bit (US_FLIDX_RESETTING , &us->dflags)) {set_bit (US_FLIDX_ABORTING , &us->dflags);usb_stor_stop_transport (us); }
@@ -155,8 +160,12 @@ static int command_abort(struct scsi_cmnd *srb)return SUCCESS ; } -/* This invokes the transport reset mechanism to reset the state of the device */ -//----- device_reset() --------------------- +/* This invokes the transport reset mechanism to reset the state of the +* device. +*/ +/* +* device_reset() +*/ static int device_reset (struct scsi_cmnd *srb) {struct us_data *us =host_to_us (srb->device->host);
@@ -172,7 +181,9 @@ static int device_reset(struct scsi_cmnd *srb)return result <0 ?FAILED :SUCCESS ; } -//----- bus_reset() --------------------- +/* +* bus_reset() +*/ static int bus_reset (struct scsi_cmnd *srb) {struct us_data *us =host_to_us (srb->device->host);
@@ -183,7 +194,9 @@ static int bus_reset(struct scsi_cmnd *srb)return result <0 ?FAILED :SUCCESS ; } -//----- usb_stor_report_device_reset() --------------------- +/* +* usb_stor_report_device_reset() +*/ void usb_stor_report_device_reset (struct us_data *us) {int i;
@@ -191,14 +204,15 @@ void usb_stor_report_device_reset(struct us_data *us)/* pr_info("scsiglue --- usb_stor_report_device_reset\n"); */ scsi_report_device_reset (host,0 ,0 ); -if (us->fflags &US_FL_SCM_MULT_TARG ) - { +if (us->fflags &US_FL_SCM_MULT_TARG ) {for (i =1 ; i < host->max_id; ++i)scsi_report_device_reset (host,0 , i); } } -//----- usb_stor_report_bus_reset() --------------------- +/* +* usb_stor_report_bus_reset() +*/ void usb_stor_report_bus_reset (struct us_data *us) {struct Scsi_Host *host =us_to_host (us);
@@ -218,8 +232,11 @@ void usb_stor_report_bus_reset(struct us_data *us) #define SPRINTF(args...) \ do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0) -//----- proc_info() --------------------- -static int proc_info (struct Scsi_Host *host,char *buffer,char **start,off_t offset,int length,int inout) +/* +* proc_info() +*/ +static int proc_info (struct Scsi_Host *host,char *buffer,char **start, +off_t offset,int length,int inout) {struct us_data *us =host_to_us (host);char *pos = buffer;
@@ -258,8 +275,7 @@ static int proc_info (struct Scsi_Host *host, char *buffer, char **start, off_tSPRINTF (" Transport: %s\n" , us->transport_name);/* show the device flags */ -if (pos < buffer + length) - { +if (pos < buffer + length) { pos +=sprintf (pos," Quirks:" );#define US_FLAG (name, value) \
@@ -274,11 +290,11 @@ US_DO_ALL_FLAGS *start = buffer + offset;if ((pos - buffer) < offset) -return (0 ); +return 0 ;else if ((pos - buffer - offset) < length) -return (pos - buffer - offset); +return pos - buffer - offset;else -return (length); +return length; }/***********************************************************************
@@ -286,8 +302,11 @@ US_DO_ALL_FLAGS***********************************************************************/ /* Output routine for the sysfs max_sectors file */ -//----- show_max_sectors() --------------------- -static ssize_t show_max_sectors (struct device *dev,struct device_attribute *attr,char *buf) +/* +* show_max_sectors() +*/ +static ssize_t show_max_sectors (struct device *dev, +struct device_attribute *attr,char *buf) {struct scsi_device *sdev =to_scsi_device (dev);
@@ -296,19 +315,22 @@ static ssize_t show_max_sectors(struct device *dev, struct device_attribute *att }/* Input routine for the sysfs max_sectors file */ -//----- store_max_sectors() --------------------- -static ssize_t store_max_sectors (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) +/* +* store_max_sectors() +*/ +static ssize_t store_max_sectors (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct scsi_device *sdev =to_scsi_device (dev);unsigned short ms;/* pr_info("scsiglue --- ssize_t store_max_sectors\n"); */ -if (sscanf (buf,"%hu" , &ms) >0 && ms <=SCSI_DEFAULT_MAX_SECTORS ) - { +if (sscanf (buf,"%hu" , &ms) >0 && ms <=SCSI_DEFAULT_MAX_SECTORS ) {blk_queue_max_hw_sectors (sdev->request_queue, ms);return strlen (buf); } -return -EINVAL ; +return -EINVAL ; } static DEVICE_ATTR(max_sectors, S_IRUGO | S_IWUSR, show_max_sectors, store_max_sectors);
@@ -316,7 +338,9 @@ static struct device_attribute *sysfs_device_attr_list[] = {&dev_attr_max_sector/* this defines our host template, with which we'll allocate hosts */ -//----- usb_stor_host_template() --------------------- +/* +* usb_stor_host_template() +*/ struct scsi_host_template usb_stor_host_template = {/* basic userland interface stuff */ .name ="eucr-storage" ,
@@ -379,7 +403,9 @@ unsigned char usb_stor_sense_invalidCDB[18] = {* Scatter-gather transfer buffer access routines ***********************************************************************/ -//----- usb_stor_access_xfer_buf() --------------------- +/* +* 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 *offset,enum xfer_buf_dir dir)
@@ -393,28 +419,25 @@ unsigned int usb_stor_access_xfer_buf(struct us_data *us, unsigned char *buffer, sg =scsi_sglist (srb); cnt =0 ; -while (cnt < buflen && sg) - { -struct page *page =sg_page (sg) + ((sg->offset + *offset) >>PAGE_SHIFT ); +while (cnt < buflen && sg) { +struct page *page =sg_page (sg) + + ((sg->offset + *offset) >>PAGE_SHIFT );unsigned int poff = (sg->offset + *offset) & (PAGE_SIZE -1 );unsigned int sglen = sg->length - *offset; -if (sglen > buflen - cnt) - { +if (sglen > buflen - cnt) {/* Transfer ends within this s-g entry */ sglen = buflen - cnt; *offset += sglen; - } -else - { + }else {/* Transfer continues to next s-g entry */ *offset =0 ; sg =sg_next (sg); } -while (sglen >0 ) - { -unsigned int plen =min (sglen, (unsigned int )PAGE_SIZE - poff); +while (sglen >0 ) { +unsigned int plen =min (sglen, + (unsigned int )PAGE_SIZE - poff);unsigned char *ptr =kmap (page);if (dir ==TO_XFER_BUF )
@@ -436,18 +459,24 @@ unsigned int usb_stor_access_xfer_buf(struct us_data *us, unsigned char *buffer,return cnt; } -/* Store the contents of buffer into srb's transfer buffer and set the SCSI residue. */ -//----- usb_stor_set_xfer_buf() --------------------- -void usb_stor_set_xfer_buf (struct us_data *us,unsigned char *buffer,unsigned int buflen,struct scsi_cmnd *srb, -unsigned int dir) +/* +* Store the contents of buffer into srb's transfer +* buffer and set the SCSI residue. +*/ +/* +* usb_stor_set_xfer_buf() +*/ +void usb_stor_set_xfer_buf (struct us_data *us,unsigned char *buffer, +unsigned int buflen,struct scsi_cmnd *srb,unsigned int dir) {unsigned int offset =0 ;struct scatterlist *sg =NULL ;/* pr_info("transport --- usb_stor_set_xfer_buf\n"); */ -// TO_XFER_BUF = 0, FROM_XFER_BUF = 1 +/* TO_XFER_BUF = 0, FROM_XFER_BUF = 1 */ buflen =min (buflen,scsi_bufflen (srb)); - buflen =usb_stor_access_xfer_buf (us, buffer, buflen, srb, &sg, &offset, dir); + buflen =usb_stor_access_xfer_buf (us, buffer, buflen, srb, + &sg, &offset, dir);if (buflen <scsi_bufflen (srb))scsi_set_resid (srb,scsi_bufflen (srb) - buflen); }
Signature · 1 line
1.7.1
PATCH 4/7 staging/keucr: fix keucr smilecc.c coding style
In reply to Cho, Yu-Chenfix keucr smilecc.c coding style
--- drivers/staging/keucr/smilecc.c | 293 ++++++++++++++++++++------------------- 1 files changed, 149 insertions(+), 144 deletions(-)
drivers/staging/keucr/smilecc.c +149 -144
@@ -1,39 +1,42 @@#include "usb.h" #include "scsiglue.h" #include "transport.h" -//#include "stdlib.h" -//#include "EUCR6SK.h" +/* #include "stdlib.h" */ +/* #include "EUCR6SK.h" */ #include "smcommon.h" #include "smil.h" -//#include <stdio.h> -//#include <stdlib.h> -//#include <string.h> -//#include <dos.h> -// -//#include "EMCRIOS.h" +/* #include <stdio.h> */ +/* #include <stdlib.h> */ +/* #include <string.h> */ +/* #include <dos.h> */ +/* #include "EMCRIOS.h" */ -// CP0-CP5 code table +/* CP0-CP5 code table */ static BYTE 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 ,0x3C ,0x3C ,0x69 ,0x6A ,0x3F ,0x65 ,0x30 ,0x33 ,0x66 , -0x03 ,0x56 ,0x55 ,0x00 ,0x5A ,0x0F ,0x0C ,0x59 ,0x59 ,0x0C ,0x0F ,0x5A ,0x00 ,0x55 ,0x56 ,0x03 , -0x69 ,0x3C ,0x3F ,0x6A ,0x30 ,0x65 ,0x66 ,0x33 ,0x33 ,0x66 ,0x65 ,0x30 ,0x6A ,0x3F ,0x3C ,0x69 , -0x0C ,0x59 ,0x5A ,0x0F ,0x55 ,0x00 ,0x03 ,0x56 ,0x56 ,0x03 ,0x00 ,0x55 ,0x0F ,0x5A ,0x59 ,0x0C , -0x0F ,0x5A ,0x59 ,0x0C ,0x56 ,0x03 ,0x00 ,0x55 ,0x55 ,0x00 ,0x03 ,0x56 ,0x0C ,0x59 ,0x5A ,0x0F , -0x6A ,0x3F ,0x3C ,0x69 ,0x33 ,0x66 ,0x65 ,0x30 ,0x30 ,0x65 ,0x66 ,0x33 ,0x69 ,0x3C ,0x3F ,0x6A , -0x6A ,0x3F ,0x3C ,0x69 ,0x33 ,0x66 ,0x65 ,0x30 ,0x30 ,0x65 ,0x66 ,0x33 ,0x69 ,0x3C ,0x3F ,0x6A , -0x0F ,0x5A ,0x59 ,0x0C ,0x56 ,0x03 ,0x00 ,0x55 ,0x55 ,0x00 ,0x03 ,0x56 ,0x0C ,0x59 ,0x5A ,0x0F , -0x0C ,0x59 ,0x5A ,0x0F ,0x55 ,0x00 ,0x03 ,0x56 ,0x56 ,0x03 ,0x00 ,0x55 ,0x0F ,0x5A ,0x59 ,0x0C , -0x69 ,0x3C ,0x3F ,0x6A ,0x30 ,0x65 ,0x66 ,0x33 ,0x33 ,0x66 ,0x65 ,0x30 ,0x6A ,0x3F ,0x3C ,0x69 , -0x03 ,0x56 ,0x55 ,0x00 ,0x5A ,0x0F ,0x0C ,0x59 ,0x59 ,0x0C ,0x0F ,0x5A ,0x00 ,0x55 ,0x56 ,0x03 , -0x66 ,0x33 ,0x30 ,0x65 ,0x3F ,0x6A ,0x69 ,0x3C ,0x3C ,0x69 ,0x6A ,0x3F ,0x65 ,0x30 ,0x33 ,0x66 , -0x65 ,0x30 ,0x33 ,0x66 ,0x3C ,0x69 ,0x6A ,0x3F ,0x3F ,0x6A ,0x69 ,0x3C ,0x66 ,0x33 ,0x30 ,0x65 , -0x00 ,0x55 ,0x56 ,0x03 ,0x59 ,0x0C ,0x0F ,0x5A ,0x5A ,0x0F ,0x0C ,0x59 ,0x03 ,0x56 ,0x55 ,0x00 +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 , +0x3C ,0x3C ,0x69 ,0x6A ,0x3F ,0x65 ,0x30 ,0x33 ,0x66 ,0x03 ,0x56 ,0x55 ,0x00 , +0x5A ,0x0F ,0x0C ,0x59 ,0x59 ,0x0C ,0x0F ,0x5A ,0x00 ,0x55 ,0x56 ,0x03 ,0x69 , +0x3C ,0x3F ,0x6A ,0x30 ,0x65 ,0x66 ,0x33 ,0x33 ,0x66 ,0x65 ,0x30 ,0x6A ,0x3F , +0x3C ,0x69 ,0x0C ,0x59 ,0x5A ,0x0F ,0x55 ,0x00 ,0x03 ,0x56 ,0x56 ,0x03 ,0x00 , +0x55 ,0x0F ,0x5A ,0x59 ,0x0C ,0x0F ,0x5A ,0x59 ,0x0C ,0x56 ,0x03 ,0x00 ,0x55 , +0x55 ,0x00 ,0x03 ,0x56 ,0x0C ,0x59 ,0x5A ,0x0F ,0x6A ,0x3F ,0x3C ,0x69 ,0x33 , +0x66 ,0x65 ,0x30 ,0x30 ,0x65 ,0x66 ,0x33 ,0x69 ,0x3C ,0x3F ,0x6A ,0x6A ,0x3F , +0x3C ,0x69 ,0x33 ,0x66 ,0x65 ,0x30 ,0x30 ,0x65 ,0x66 ,0x33 ,0x69 ,0x3C ,0x3F , +0x6A ,0x0F ,0x5A ,0x59 ,0x0C ,0x56 ,0x03 ,0x00 ,0x55 ,0x55 ,0x00 ,0x03 ,0x56 , +0x0C ,0x59 ,0x5A ,0x0F ,0x0C ,0x59 ,0x5A ,0x0F ,0x55 ,0x00 ,0x03 ,0x56 ,0x56 , +0x03 ,0x00 ,0x55 ,0x0F ,0x5A ,0x59 ,0x0C ,0x69 ,0x3C ,0x3F ,0x6A ,0x30 ,0x65 , +0x66 ,0x33 ,0x33 ,0x66 ,0x65 ,0x30 ,0x6A ,0x3F ,0x3C ,0x69 ,0x03 ,0x56 ,0x55 , +0x00 ,0x5A ,0x0F ,0x0C ,0x59 ,0x59 ,0x0C ,0x0F ,0x5A ,0x00 ,0x55 ,0x56 ,0x03 , +0x66 ,0x33 ,0x30 ,0x65 ,0x3F ,0x6A ,0x69 ,0x3C ,0x3C ,0x69 ,0x6A ,0x3F ,0x65 , +0x30 ,0x33 ,0x66 ,0x65 ,0x30 ,0x33 ,0x66 ,0x3C ,0x69 ,0x6A ,0x3F ,0x3F ,0x6A , +0x69 ,0x3C ,0x66 ,0x33 ,0x30 ,0x65 ,0x00 ,0x55 ,0x56 ,0x03 ,0x59 ,0x0C ,0x0F , +0x5A ,0x5A ,0x0F ,0x0C ,0x59 ,0x03 ,0x56 ,0x55 ,0x00 }; -static void trans_result (BYTE ,BYTE ,BYTE *,BYTE *); +static void trans_result (BYTE ,BYTE ,BYTE *,BYTE *);#define BIT7 0x80#define BIT6 0x40
@@ -49,138 +52,140 @@ static void trans_result (BYTE, BYTE, BYTE *, BYTE *);#define CORRECTABLE 0x00555554L/* -* reg2; // LP14,LP12,LP10,... -* reg3; // LP15,LP13,LP11,... -* *ecc1; // LP15,LP14,LP13,... -* *ecc2; // LP07,LP06,LP05,... +* reg2; * LP14,LP12,LP10,... +* reg3; * LP15,LP13,LP11,... +* *ecc1; * LP15,LP14,LP13,... +* *ecc2; * LP07,LP06,LP05,... */ static void trans_result (BYTE reg2,BYTE reg3,BYTE *ecc1,BYTE *ecc2) { -BYTE a;// Working for reg2,reg3 -BYTE b;// Working for ecc1,ecc2 -BYTE i;// For counting - - a=BIT7 ; b=BIT7 ;// 80h=10000000b - *ecc1=*ecc2=0 ;// Clear ecc1,ecc2 -for (i=0 ; i<4 ; ++i) { -if ((reg3&a)!=0 ) - *ecc1|=b;// LP15,13,11,9 -> ecc1 - b=b>>1 ;// Right shift -if ((reg2&a)!=0 ) - *ecc1|=b;// LP14,12,10,8 -> ecc1 - b=b>>1 ;// Right shift - a=a>>1 ;// Right shift - } - - b=BIT7 ;// 80h=10000000b -for (i=0 ; i<4 ; ++i) { -if ((reg3&a)!=0 ) - *ecc2|=b;// LP7,5,3,1 -> ecc2 - b=b>>1 ;// Right shift -if ((reg2&a)!=0 ) - *ecc2|=b;// LP6,4,2,0 -> ecc2 - b=b>>1 ;// Right shift - a=a>>1 ;// Right shift - } +BYTE a;/* Working for reg2,reg3 */ +BYTE b;/* Working for ecc1,ecc2 */ +BYTE i;/* For counting */ + + a =BIT7 ; b =BIT7 ;/* 80h=10000000b */ + *ecc1 = *ecc2 =0 ;/* Clear ecc1,ecc2 */ +for (i =0 ; i <4 ; ++i) { +if ((reg3&a) !=0 ) + *ecc1 |= b;/* LP15,13,11,9 -> ecc1 */ + b = b>>1 ;/* Right shift */ +if ((reg2&a) !=0 ) + *ecc1 |= b;/* LP14,12,10,8 -> ecc1 */ + b = b>>1 ;/* Right shift */ + a = a>>1 ;/* Right shift */ + } + + b =BIT7 ;/* 80h=10000000b */ +for (i =0 ; i <4 ; ++i) { +if ((reg3&a) !=0 ) + *ecc2 |= b;/* LP7,5,3,1 -> ecc2 */ + b = b>>1 ;/* Right shift */ +if ((reg2&a) !=0 ) + *ecc2 |= b;/* LP6,4,2,0 -> ecc2 */ + b = b>>1 ;/* Right shift */ + a = a>>1 ;/* Right shift */ + } } -//static void calculate_ecc(table,data,ecc1,ecc2,ecc3) +/*static void calculate_ecc(table,data,ecc1,ecc2,ecc3) */ /* -* *table; // CP0-CP5 code table -* *data; // DATA -* *ecc1; // LP15,LP14,LP13,... -* *ecc2; // LP07,LP06,LP05,... -* *ecc3; // CP5,CP4,CP3,...,"1","1" +* *table; * CP0-CP5 code table +* *data; * DATA +* *ecc1; * LP15,LP14,LP13,... +* *ecc2; * LP07,LP06,LP05,... +* *ecc3; * CP5,CP4,CP3,...,"1","1" */ void calculate_ecc (BYTE *table,BYTE *data,BYTE *ecc1,BYTE *ecc2,BYTE *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,... - - 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 - } - } - -// Trans LP14,12,10,... & LP15,13,11,... -> LP15,14,13,... & LP7,6,5,.. -trans_result (reg2,reg3,ecc1,ecc2); - *ecc1=~(*ecc1); *ecc2=~(*ecc2);// Inv. ecc2 & ecc3 - *ecc3=((~reg1)<<2 )|BIT1BIT0 ;// Make TEL format +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,... */ + + 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 */ + } + } + +/* Trans LP14,12,10,... & LP15,13,11,... -> +LP15,14,13,... & LP7,6,5,.. */ +trans_result (reg2, reg3, ecc1, ecc2); + *ecc1 = ~(*ecc1); *ecc2 = ~(*ecc2);/* Inv. ecc2 & ecc3 */ + *ecc3 = ((~reg1)<<2 )|BIT1BIT0 ;/* Make TEL format */ }/* -* *data; // DATA -* *eccdata; // ECC DATA -* ecc1; // LP15,LP14,LP13,... -* ecc2; // LP07,LP06,LP05,... -* ecc3; // CP5,CP4,CP3,...,"1","1" +* *data; * DATA +* *eccdata; * ECC DATA +* ecc1; * LP15,LP14,LP13,... +* ecc2; * LP07,LP06,LP05,... +* ecc3; * CP5,CP4,CP3,...,"1","1" */ BYTE correct_data (BYTE *data,BYTE *eccdata,BYTE ecc1,BYTE ecc2,BYTE 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 - - 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; - -if (d==0 )return (0 );// If No error, return - -if (((d^(d>>1 ))&CORRECTABLE )==CORRECTABLE ) - {// If correctable - l=BIT23 ; - add=0 ;// Clear parameter - a=BIT7 ; - -for (i=0 ; i<8 ; ++i) {// Checking 8 bit -if ((d&l)!=0 ) add|=a;// Make byte address from LP's - l>>=2 ; a>>=1 ;// Right Shift - } - - bit=0 ;// Clear parameter - b=BIT2 ; -for (i=0 ; i<3 ; ++i) {// Checking 3 bit -if ((d&l)!=0 ) bit|=b;// Make bit address from CP's - l>>=2 ; b>>=1 ;// Right shift - } - - b=BIT0 ; - data[add]^=(b<<bit);// Put corrected data -return (1 ); - } - - i=0 ;// Clear count - d&=0x00ffffffL ;// Masking - -while (d) {// If d=0 finish counting -if (d&BIT0 ) ++i;// Count number of 1 bit - d>>=1 ;// Right shift - } - -if (i==1 ) - {// If ECC error - eccdata[1 ]=ecc1; eccdata[0 ]=ecc2;// Put right ECC code - eccdata[2 ]=ecc3; -return (2 ); - } -return (3 );// Uncorrectable error +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 */ + + 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; + +if (d ==0 ) +return 0 ;/* If No error, return */ + +if (((d^(d>>1 ))&CORRECTABLE ) ==CORRECTABLE ) {/* If correctable */ + l =BIT23 ; + add =0 ;/* Clear parameter */ + a =BIT7 ; + +for (i =0 ; i <8 ; ++i) {/* Checking 8 bit */ +if ((d&l) !=0 ) + add |= a;/* Make byte address from LP's */ + l >>=2 ; a >>=1 ;/* Right Shift */ + } + + bit =0 ;/* Clear parameter */ + b =BIT2 ; +for (i =0 ; i <3 ; ++i) {/* Checking 3 bit */ +if ((d&l) !=0 ) + bit |= b;/* Make bit address from CP's */ + l >>=2 ; b >>=1 ;/* Right shift */ + } + + b =BIT0 ; + data[add] ^= (b<<bit);/* Put corrected data */ +return 1 ; + } + + i =0 ;/* Clear count */ + d &=0x00ffffffL ;/* Masking */ + +while (d) {/* If d=0 finish counting */ +if (d&BIT0 ) + ++i;/* Count number of 1 bit */ + d >>=1 ;/* Right shift */ + } + +if (i ==1 ) {/* If ECC error */ + eccdata[1 ] = ecc1; eccdata[0 ] = ecc2;/* Put right ECC code */ + eccdata[2 ] = ecc3; +return 2 ; + } +return 3 ;/* Uncorrectable error */ }int _Correct_D_SwECC (BYTE *buf,BYTE *redundant_ecc,BYTE *calculate_ecc)
@@ -200,7 +205,7 @@ int _Correct_D_SwECC(BYTE *buf, BYTE *redundant_ecc, BYTE *calculate_ecc)void _Calculate_D_SwECC (BYTE *buf,BYTE *ecc) { -calculate_ecc (ecctable,buf,ecc+1 ,ecc+0 ,ecc+2 ); +calculate_ecc (ecctable, buf, ecc+1 , ecc+0 , ecc+2 ); }
Signature · 1 line
1.7.1
PATCH 5/7 staging/keucr: fix keucr smil.h coding style
In reply to Cho, Yu-Chenfix keucr smil.h coding style
--- drivers/staging/keucr/smil.h | 291 ++++++++++++++++++++++-------------------- 1 files changed, 150 insertions(+), 141 deletions(-)
drivers/staging/keucr/smil.h +150 -141
@@ -44,21 +44,22 @@ Retry Counter Definition/*************************************************************************** Hardware ECC Definition ***************************************************************************/ -#define HW_ECC_SUPPORTED 1/* Hardware ECC Supported */ /* No difinition for Software ECC */ +#define HW_ECC_SUPPORTED 1/* Hardware ECC Supported */ +/* No difinition for Software ECC */ /*************************************************************************** SmartMedia Command & Status Definition ***************************************************************************/ /* SmartMedia Command */ #define WRDATA 0x80 -//#define READ 0x00 +/* #define READ 0x00 */ #define READ_REDT 0x50 -//#define WRITE 0x10 +/* #define WRITE 0x10 */ #define RDSTATUS 0x70 -#define READ1 0x00 //NO -#define READ2 0x01 //NO -#define READ3 0x50 //NO +#define READ1 0x00/* NO */ +#define READ2 0x01/* NO */ +#define READ3 0x50/* NO */ #define RST_CHIP 0xFF#define ERASE1 0x60#define ERASE2 0xD0
@@ -67,19 +68,19 @@ SmartMedia Command & Status Definition#define READ_ID_3 0x9A/* 712 SmartMedia Command */ -#define SM_CMD_RESET 0x00 // 0xFF -#define SM_CMD_READ_ID_1 0x10 // 0x90 -#define SM_CMD_READ_ID_2 0x20 // 0x91 -#define SM_CMD_READ_STAT 0x30 // 0x70 -#define SM_CMD_RDMULTPL_STAT 0x40 // 0x71 -#define SM_CMD_READ_1 0x50 // 0x00 -#define SM_CMD_READ_2 0x60 // 0x01 -#define SM_CMD_READ_3 0x70 // 0x50 -#define SM_CMD_PAGPRGM_TRUE 0x80 // {0x80, 0x10} -#define SM_CMD_PAGPRGM_DUMY 0x90 // {0x80, 0x11} -#define SM_CMD_PAGPRGM_MBLK 0xA0 // {0x80, 0x15} -#define SM_CMD_BLKERASE 0xB0 // {0x60, 0xD0} -#define SM_CMD_BLKERASE_MULTPL 0xC0 // {0x60-0x60, 0xD0} +#define SM_CMD_RESET 0x00/* 0xFF */ +#define SM_CMD_READ_ID_1 0x10/* 0x90 */ +#define SM_CMD_READ_ID_2 0x20/* 0x91 */ +#define SM_CMD_READ_STAT 0x30/* 0x70 */ +#define SM_CMD_RDMULTPL_STAT 0x40/* 0x71 */ +#define SM_CMD_READ_1 0x50/* 0x00 */ +#define SM_CMD_READ_2 0x60/* 0x01 */ +#define SM_CMD_READ_3 0x70/* 0x50 */ +#define SM_CMD_PAGPRGM_TRUE 0x80/* {0x80, 0x10} */ +#define SM_CMD_PAGPRGM_DUMY 0x90/* {0x80, 0x11} */ +#define SM_CMD_PAGPRGM_MBLK 0xA0/* {0x80, 0x15} */ +#define SM_CMD_BLKERASE 0xB0/* {0x60, 0xD0} */ +#define SM_CMD_BLKERASE_MULTPL 0xC0/* {0x60-0x60, 0xD0} */ #define SM_CRADDTCT_DEBNCETIMER_EN 0x02#define SM_CMD_START_BIT 0x01
@@ -87,27 +88,31 @@ SmartMedia Command & Status Definition#define SM_WaitCmdDone { while (!SM_CmdDone); }#define SM_WaitDmaDone { while (!SM_DmaDone); } -// SmartMedia Status -#define WR_FAIL 0x01 // 0:Pass, 1:Fail -#define SUSPENDED 0x20 // 0:Not Suspended, 1:Suspended -#define READY 0x40 // 0:Busy, 1:Ready -#define WR_PRTCT 0x80 // 0:Protect, 1:Not Protect - -// SmartMedia Busy Time (1bit:0.1ms) -#define BUSY_PROG 200 // tPROG : 20ms ----- Program Time old : 200 -#define BUSY_ERASE 4000 // tBERASE : 400ms ----- Block Erase Time old : 4000 -//for 712 Test -//#define BUSY_READ 1 // tR : 100us ----- Data transfer Time old : 1 -//#define BUSY_READ 10 // tR : 100us ----- Data transfer Time old : 1 -#define BUSY_READ 200 // tR : 20ms ----- Data transfer Time old : 1 -//#define BUSY_RESET 60 // tRST : 6ms ----- Device Resetting Time old : 60 -#define BUSY_RESET 600 // tRST : 60ms ----- Device Resetting Time old : 60 - -// Hardware Timer (1bit:0.1ms) -#define TIME_PON 3000 // 300ms ------ Power On Wait Time -#define TIME_CDCHK 200 // 20ms ------ Card Check Interval Timer -#define TIME_WPCHK 50 // 5ms ------ WP Check Interval Timer -#define TIME_5VCHK 10 // 1ms ------ 5V Check Interval Timer +/* SmartMedia Status */ +#define WR_FAIL 0x01/* 0:Pass, 1:Fail */ +#define SUSPENDED 0x20/* 0:Not Suspended, 1:Suspended */ +#define READY 0x40/* 0:Busy, 1:Ready */ +#define WR_PRTCT 0x80/* 0:Protect, 1:Not Protect */ + +/* SmartMedia Busy Time (1bit:0.1ms) */ +#define BUSY_PROG 200/* tPROG : 20ms ----- Program Time old : 200 */ +#define BUSY_ERASE 4000/* tBERASE : 400ms ----- Block Erase Time old : 4000 */ + +/*for 712 Test */ +/* #define BUSY_READ 1 *//* tR : 100us ----- Data transfer Time old : 1 */ +/* #define BUSY_READ 10 *//* tR : 100us ----- Data transfer Time old : 1 */ + +#define BUSY_READ 200/* tR : 20ms ----- Data transfer Time old : 1 */ + +/* #define BUSY_RESET 60 *//* tRST : 6ms ----- Device Resetting Time old : 60 */ + +#define BUSY_RESET 600/* tRST : 60ms ----- Device Resetting Time old : 60 */ + +/* Hardware Timer (1bit:0.1ms) */ +#define TIME_PON 3000/* 300ms ------ Power On Wait Time */ +#define TIME_CDCHK 200/* 20ms ------ Card Check Interval Timer */ +#define TIME_WPCHK 50/* 5ms ------ WP Check Interval Timer */ +#define TIME_5VCHK 10/* 1ms ------ 5V Check Interval Timer */ /*************************************************************************** Redundant Data
@@ -129,32 +134,32 @@ Redundant DataSmartMedia Model & Attribute ***************************************************************************/ /* SmartMedia Attribute */ -#define NOWP 0x00 // 0... .... No Write Protect -#define WP 0x80 // 1... .... Write Protected -#define MASK 0x00 // .00. .... NAND MASK ROM Model -#define FLASH 0x20 // .01. .... NAND Flash ROM Model -#define AD3CYC 0x00 // ...0 .... Address 3-cycle -#define AD4CYC 0x10 // ...1 .... Address 4-cycle -#define BS16 0x00 // .... 00.. 16page/block -#define BS32 0x04 // .... 01.. 32page/block -#define PS256 0x00 // .... ..00 256byte/page -#define PS512 0x01 // .... ..01 512byte/page -#define MWP 0x80 // WriteProtect mask -#define MFLASH 0x60 // Flash Rom mask -#define MADC 0x10 // Address Cycle -#define MBS 0x0C // BlockSize mask -#define MPS 0x03 // PageSize mask +#define NOWP 0x00/* 0... .... No Write Protect */ +#define WP 0x80/* 1... .... Write Protected */ +#define MASK 0x00/* .00. .... NAND MASK ROM Model */ +#define FLASH 0x20/* .01. .... NAND Flash ROM Model */ +#define AD3CYC 0x00/* ...0 .... Address 3-cycle */ +#define AD4CYC 0x10/* ...1 .... Address 4-cycle */ +#define BS16 0x00/* .... 00.. 16page/block */ +#define BS32 0x04/* .... 01.. 32page/block */ +#define PS256 0x00/* .... ..00 256byte/page */ +#define PS512 0x01/* .... ..01 512byte/page */ +#define MWP 0x80/* WriteProtect mask */ +#define MFLASH 0x60/* Flash Rom mask */ +#define MADC 0x10/* Address Cycle */ +#define MBS 0x0C/* BlockSize mask */ +#define MPS 0x03/* PageSize mask */ /* SmartMedia Model */ -#define NOSSFDC 0x00 // NO SmartMedia -#define SSFDC1MB 0x01 // 1MB SmartMedia -#define SSFDC2MB 0x02 // 2MB SmartMedia -#define SSFDC4MB 0x03 // 4MB SmartMedia -#define SSFDC8MB 0x04 // 8MB SmartMedia -#define SSFDC16MB 0x05 // 16MB SmartMedia -#define SSFDC32MB 0x06 // 32MB SmartMedia -#define SSFDC64MB 0x07 // 64MB SmartMedia -#define SSFDC128MB 0x08 //128MB SmartMedia +#define NOSSFDC 0x00/* NO SmartMedia */ +#define SSFDC1MB 0x01/* 1MB SmartMedia */ +#define SSFDC2MB 0x02/* 2MB SmartMedia */ +#define SSFDC4MB 0x03/* 4MB SmartMedia */ +#define SSFDC8MB 0x04/* 8MB SmartMedia */ +#define SSFDC16MB 0x05/* 16MB SmartMedia */ +#define SSFDC32MB 0x06/* 32MB SmartMedia */ +#define SSFDC64MB 0x07/* 64MB SmartMedia */ +#define SSFDC128MB 0x08/*128MB SmartMedia */ #define SSFDC256MB 0x09#define SSFDC512MB 0x0A#define SSFDC1GB 0x0B
@@ -163,8 +168,7 @@ SmartMedia Model & Attribute/*************************************************************************** Struct Definition ***************************************************************************/ -struct SSFDCTYPE -{ +struct SSFDCTYPE {BYTE Model;BYTE Attribute;BYTE MaxZones;
@@ -183,8 +187,7 @@ typedef struct SSFDCTYPE_TWORD MaxLogBlocks; } *SSFDCTYPE_T ; -struct ADDRESS -{ +struct ADDRESS {BYTE Zone;/* Zone Number */ BYTE Sector;/* Sector(512byte) Number on Block */ WORD PhyBlock;/* Physical Block Number on Zone */
@@ -199,8 +202,7 @@ typedef struct ADDRESS_TWORD LogBlock;/* Logical Block Number of Zone */ } *ADDRESS_T ; -struct CIS_AREA -{ +struct CIS_AREA {BYTE Sector;/* Sector(512byte) Number on Block */ WORD PhyBlock;/* Physical Block Number on Zone 0 */ };
@@ -219,86 +221,93 @@ extern struct SSFDCTYPE Ssfdc;extern struct ADDRESS Media;extern struct CIS_AREA CisArea; -//----- SMILMain.c --------------------------------------------------- +/* +* SMILMain.c +*/ /******************************************/ -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 Media_D_EraseAll (struct us_data *); +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 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_OneSectWriteFlush (struct us_data *); +int Media_D_OneSectWriteStart (struct us_data *,DWORD ,BYTE *); +int Media_D_OneSectWriteNext (struct us_data *,BYTE *); +int Media_D_OneSectWriteFlush (struct us_data *);/******************************************/ extern int SM_FreeMem (void );/* ENE SM function */ -void SM_EnableLED (struct us_data *,BOOLEAN ); -void Led_D_TernOn (void ); -void Led_D_TernOff (void ); +void SM_EnableLED (struct us_data *,BOOLEAN ); +void Led_D_TernOn (void ); +void Led_D_TernOff (void ); -int Media_D_EraseAllRedtData (DWORD Index,BOOLEAN CheckBlock); -//DWORD Media_D_GetMediaInfo (struct us_data * fdoExt, PIOCTL_MEDIA_INFO_IN pParamIn, PIOCTL_MEDIA_INFO_OUT pParamOut); +int Media_D_EraseAllRedtData (DWORD Index,BOOLEAN CheckBlock); +/*DWORD Media_D_GetMediaInfo(struct us_data * fdoExt, +PIOCTL_MEDIA_INFO_IN pParamIn, PIOCTL_MEDIA_INFO_OUT pParamOut); */ -//----- SMILSub.c ---------------------------------------------------- +/* +* 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 (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 *);/******************************************/ -void Ssfdc_D_Reset (struct us_data *); -int Ssfdc_D_ReadCisSect (struct us_data *,BYTE *,BYTE *); -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 *); -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_CheckStatus (void ); -int Set_D_SsfdcModel (BYTE ); -void Cnt_D_Reset (void ); -int Cnt_D_PowerOn (void ); -void Cnt_D_PowerOff (void ); -void Cnt_D_LedOn (void ); -void Cnt_D_LedOff (void ); -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 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 *); +void Ssfdc_D_Reset (struct us_data *); +int Ssfdc_D_ReadCisSect (struct us_data *,BYTE *,BYTE *); +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 *); +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_CheckStatus (void ); +int Set_D_SsfdcModel (BYTE ); +void Cnt_D_Reset (void ); +int Cnt_D_PowerOn (void ); +void Cnt_D_PowerOff (void ); +void Cnt_D_LedOn (void ); +void Cnt_D_LedOff (void ); +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 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 Check_D_ReadError (BYTE *); -int Check_D_Correct (BYTE *,BYTE *); -int Check_D_CISdata (BYTE *,BYTE *); -void Set_D_RightECC (BYTE *); - -//----- 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 ); - -#endif // already included +int Check_D_ReadError (BYTE *); +int Check_D_Correct (BYTE *,BYTE *); +int Check_D_CISdata (BYTE *,BYTE *); +void Set_D_RightECC (BYTE *); + +/* +* 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 ); + +#endif /* already included */
Signature · 1 line
1.7.1
PATCH 6/7 staging/keucr: fix keucr transport coding style
In reply to Cho, Yu-Chenfix keucr transport.c transport.h coding style
--- drivers/staging/keucr/transport.c | 385 ++++++++++++++++++++----------------- drivers/staging/keucr/transport.h | 81 +++++--- 2 files changed, 258 insertions(+), 208 deletions(-)
drivers/staging/keucr/transport.c +208 -177
@@ -15,7 +15,9 @@/*********************************************************************** * Data transfer routines ***********************************************************************/ -//----- usb_stor_blocking_completion() --------------------- +/* +* usb_stor_blocking_completion() +*/ static void usb_stor_blocking_completion (struct urb *urb) {struct completion *urb_done_ptr = urb->context;
@@ -24,7 +26,9 @@ static void usb_stor_blocking_completion(struct urb *urb)complete (urb_done_ptr); } -//----- usb_stor_msg_common() --------------------- +/* +* usb_stor_msg_common() +*/ static int usb_stor_msg_common (struct us_data *us,int timeout) {struct completion urb_done;
@@ -54,20 +58,18 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)set_bit (US_FLIDX_URB_ACTIVE , &us->dflags); -if (test_bit (US_FLIDX_ABORTING , &us->dflags)) - { -if (test_and_clear_bit (US_FLIDX_URB_ACTIVE , &us->dflags)) - { +if (test_bit (US_FLIDX_ABORTING , &us->dflags)) { +if (test_and_clear_bit (US_FLIDX_URB_ACTIVE , &us->dflags)) {/* pr_info("-- cancelling URB\n"); */ usb_unlink_urb (us->current_urb); } } - timeleft =wait_for_completion_interruptible_timeout (&urb_done, timeout ? :MAX_SCHEDULE_TIMEOUT ); + timeleft =wait_for_completion_interruptible_timeout (&urb_done, + timeout ? :MAX_SCHEDULE_TIMEOUT );clear_bit (US_FLIDX_URB_ACTIVE , &us->dflags); -if (timeleft <=0 ) - { +if (timeleft <=0 ) {/* pr_info("%s -- cancelling URB\n", timeleft == 0 ? "Timeout" : "Signal"); */ usb_kill_urb (us->current_urb);
@@ -76,7 +78,9 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)return us->current_urb->status; } -//----- usb_stor_control_msg() --------------------- +/* +* usb_stor_control_msg() +*/ int usb_stor_control_msg (struct us_data *us,unsigned int pipe,u8 request,u8 requesttype,u16 value,u16 index,void *data,u16 size,int timeout)
@@ -94,7 +98,7 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,/* fill and submit the URB */ usb_fill_control_urb (us->current_urb, us->pusb_dev, pipe, - (unsigned char *) us->cr, data, size, + (unsigned char *) us->cr, data, size, usb_stor_blocking_completion,NULL ); status =usb_stor_msg_common (us, timeout);
@@ -104,14 +108,16 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,return status; } -//----- usb_stor_clear_halt() --------------------- +/* +* usb_stor_clear_halt() +*/ int usb_stor_clear_halt (struct us_data *us,unsigned int pipe) {int result;int endp =usb_pipeendpoint (pipe);/* pr_info("transport --- usb_stor_clear_halt\n"); */ -if (usb_pipein (pipe)) +if (usb_pipein (pipe)) endp |=USB_DIR_IN ; result = usb_stor_control_msg(us, us->send_ctrl_pipe,
@@ -121,13 +127,16 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)/* reset the endpoint toggle */ if (result >=0 ) -//usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0); -usb_reset_endpoint (us->pusb_dev, endp); +/* usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe), +usb_pipeout(pipe), 0); */ +usb_reset_endpoint (us->pusb_dev, endp);return result; } -//----- interpret_urb_result() --------------------- +/* +* interpret_urb_result() +*/ static int interpret_urb_result (struct us_data *us,unsigned int pipe,unsigned int length,int result,unsigned int partial) {
@@ -135,16 +144,14 @@ static int interpret_urb_result(struct us_data *us, unsigned int pipe,switch (result) {/* no error code; did we send all the data? */ case 0 : -if (partial != length) - { +if (partial != length) {/* pr_info("-- short transfer\n"); */ return USB_STOR_XFER_SHORT ; }/* pr_info("-- transfer complete\n"); */ return USB_STOR_XFER_GOOD ;case -EPIPE : -if (usb_pipecontrol (pipe)) - { +if (usb_pipecontrol (pipe)) {/* pr_info("-- stall on control pipe\n"); */ return USB_STOR_XFER_STALLED ; }
@@ -170,7 +177,9 @@ static int interpret_urb_result(struct us_data *us, unsigned int pipe, } } -//----- usb_stor_bulk_transfer_buf() --------------------- +/* +* usb_stor_bulk_transfer_buf() +*/ int usb_stor_bulk_transfer_buf (struct us_data *us,unsigned int pipe,void *buf,unsigned int length,unsigned int *act_len) {
@@ -179,17 +188,21 @@ int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,/* pr_info("transport --- usb_stor_bulk_transfer_buf\n"); */ /* fill and submit the URB */ -usb_fill_bulk_urb (us->current_urb, us->pusb_dev, pipe, buf, length, usb_stor_blocking_completion,NULL ); +usb_fill_bulk_urb (us->current_urb, us->pusb_dev, pipe, buf, + length, usb_stor_blocking_completion,NULL ); result =usb_stor_msg_common (us,0 );/* store the actual length of the data transferred */ if (act_len) *act_len = us->current_urb->actual_length; -return interpret_urb_result (us, pipe, length, result, us->current_urb->actual_length); +return interpret_urb_result (us, pipe, length, result, + us->current_urb->actual_length); } -//----- usb_stor_bulk_transfer_sglist() --------------------- +/* +* usb_stor_bulk_transfer_sglist() +*/ static int usb_stor_bulk_transfer_sglist (struct us_data *us,unsigned int pipe,struct scatterlist *sg,int num_sg,unsigned int length,unsigned int *act_len)
@@ -201,22 +214,21 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,return USB_STOR_XFER_ERROR ;/* initialize the scatter-gather request block */ - result =usb_sg_init (&us->current_sg, us->pusb_dev, pipe,0 , sg, num_sg, length,GFP_NOIO ); -if (result) - { + result =usb_sg_init (&us->current_sg, us->pusb_dev, pipe,0 , + sg, num_sg, length,GFP_NOIO ); +if (result) {/* pr_info("usb_sg_init returned %d\n", result); */ return USB_STOR_XFER_ERROR ; } -/* since the block has been initialized successfully, it's now okay to cancel it */ +/* since the block has been initialized successfully, +it's now okay to cancel it */ set_bit (US_FLIDX_SG_ACTIVE , &us->dflags);/* did an abort/disconnect occur during the submission? */ -if (test_bit (US_FLIDX_ABORTING , &us->dflags)) - { +if (test_bit (US_FLIDX_ABORTING , &us->dflags)) {/* cancel the request, if it hasn't been cancelled already */ -if (test_and_clear_bit (US_FLIDX_SG_ACTIVE , &us->dflags)) - { +if (test_and_clear_bit (US_FLIDX_SG_ACTIVE , &us->dflags)) {/* pr_info("-- cancelling sg request\n"); */ usb_sg_cancel (&us->current_sg); }
@@ -230,11 +242,15 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,if (act_len) *act_len = us->current_sg.bytes; -return interpret_urb_result (us, pipe, length, result, us->current_sg.bytes); +return interpret_urb_result (us, pipe, length, + result, us->current_sg.bytes); } -//----- usb_stor_bulk_srb() --------------------- -int usb_stor_bulk_srb (struct us_data * us,unsigned int pipe,struct scsi_cmnd * srb) +/* +* usb_stor_bulk_srb() +*/ +int usb_stor_bulk_srb (struct us_data *us,unsigned int pipe, +struct scsi_cmnd *srb) {unsigned int partial; int result = usb_stor_bulk_transfer_sglist(us, pipe, scsi_sglist(srb),
@@ -245,8 +261,10 @@ int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe, struct scsi_cmnd* sreturn result; } -//----- usb_stor_bulk_transfer_sg() --------------------- -int usb_stor_bulk_transfer_sg (struct us_data * us,unsigned int pipe, +/* +* usb_stor_bulk_transfer_sg() +*/ +int usb_stor_bulk_transfer_sg (struct us_data *us,unsigned int pipe,void *buf,unsigned int length_left,int use_sg,int *residual) {int result;
@@ -254,18 +272,16 @@ int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,/* pr_info("transport --- usb_stor_bulk_transfer_sg\n"); */ /* are we scatter-gathering? */ -if (use_sg) - { +if (use_sg) {/* use the usb core scatter-gather primitives */ result =usb_stor_bulk_transfer_sglist (us, pipe, (struct scatterlist *) buf, use_sg, length_left, &partial); length_left -= partial; - } -else - { + }else {/* no scatter-gather, just make the request */ - result =usb_stor_bulk_transfer_buf (us, pipe, buf, length_left, &partial); + result =usb_stor_bulk_transfer_buf (us, pipe, buf, + length_left, &partial); length_left -= partial; }
@@ -278,7 +294,9 @@ int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,/*********************************************************************** * Transport routines ***********************************************************************/ -//----- usb_stor_invoke_transport() --------------------- +/* +* usb_stor_invoke_transport() +*/ void usb_stor_invoke_transport (struct scsi_cmnd *srb,struct us_data *us) {int need_auto_sense;
@@ -288,27 +306,25 @@ void usb_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 ); - result = us->transport (srb, us);//usb_stor_Bulk_transport; - -/* if the command gets aborted by the higher layers, we need to short-circuit all other processing */ -if (test_bit (US_FLIDX_TIMED_OUT , &us->dflags)) - { + result = us->transport (srb, us);/* usb_stor_Bulk_transport; */ + +/* if the command gets aborted by the higher layers, +we need to short-circuit all other processing */ +if (test_bit (US_FLIDX_TIMED_OUT , &us->dflags)) {/* pr_info("-- command was aborted\n"); */ srb->result =DID_ABORT <<16 ; goto Handle_Errors; }/* if there is a transport error, reset and don't auto-sense */ -if (result ==USB_STOR_TRANSPORT_ERROR ) - { +if (result ==USB_STOR_TRANSPORT_ERROR ) {/* pr_info("-- transport indicates error, resetting\n"); */ srb->result =DID_ERROR <<16 ; goto Handle_Errors; }/* if the transport provided its own sense data, don't auto-sense */ -if (result ==USB_STOR_TRANSPORT_NO_SENSE ) - { +if (result ==USB_STOR_TRANSPORT_NO_SENSE ) { srb->result =SAM_STAT_CHECK_CONDITION ;return ; }
@@ -318,21 +334,19 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)/* Determine if we need to auto-sense */ need_auto_sense =0 ; -if ((us->protocol ==USB_PR_CB || us->protocol ==USB_PR_DPCM_USB ) && srb->sc_data_direction !=DMA_FROM_DEVICE ) - { +if ((us->protocol ==USB_PR_CB || us->protocol ==USB_PR_DPCM_USB ) && + srb->sc_data_direction !=DMA_FROM_DEVICE ) {/* pr_info("-- CB transport device requiring auto-sense\n"); */ need_auto_sense =1 ; } -if (result ==USB_STOR_TRANSPORT_FAILED ) - { +if (result ==USB_STOR_TRANSPORT_FAILED ) {/* pr_info("-- transport indicates command failure\n"); */ need_auto_sense =1 ; }/* Now, if we need to do the auto-sense, let's do it */ -if (need_auto_sense) - { +if (need_auto_sense) {int temp_result;struct scsi_eh_save ses;
@@ -341,11 +355,13 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)scsi_eh_prep_cmnd (srb, &ses,NULL ,0 ,US_SENSE_SIZE );/* we must do the protocol translation here */ -if (us->subclass ==USB_SC_RBC || us->subclass ==USB_SC_SCSI || us->subclass ==USB_SC_CYP_ATACB ) +if (us->subclass ==USB_SC_RBC || + us->subclass ==USB_SC_SCSI || + us->subclass ==USB_SC_CYP_ATACB ) { srb->cmd_len =6 ; -else + }else { srb->cmd_len =12 ; - + }/* issue the auto-sense command */ scsi_set_resid (srb,0 ); temp_result = us->transport (us->srb, us);
@@ -353,14 +369,12 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)/* let's clean up right away */ scsi_eh_restore_cmnd (srb, &ses); -if (test_bit (US_FLIDX_TIMED_OUT , &us->dflags)) - { +if (test_bit (US_FLIDX_TIMED_OUT , &us->dflags)) {/* pr_info("-- auto-sense aborted\n"); */ srb->result =DID_ABORT <<16 ; goto Handle_Errors; } -if (temp_result !=USB_STOR_TRANSPORT_GOOD ) - { +if (temp_result !=USB_STOR_TRANSPORT_GOOD ) {/* pr_info("-- auto-sense failure\n"); */ srb->result =DID_ERROR <<16 ;if (!(us->fflags &US_FL_SCM_MULT_TARG ))
@@ -374,16 +388,17 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)if (result ==USB_STOR_TRANSPORT_GOOD && (srb->sense_buffer[2 ] &0xaf ) ==0 && srb->sense_buffer[12 ] ==0 && - srb->sense_buffer[13 ] ==0 ) - { + srb->sense_buffer[13 ] ==0 ) { srb->result =SAM_STAT_GOOD ; srb->sense_buffer[0 ] =0x0 ; } }/* Did we transfer less than the minimum amount required? */ -if (srb->result ==SAM_STAT_GOOD &&scsi_bufflen (srb) -scsi_get_resid (srb) < srb->underflow) - srb->result = (DID_ERROR <<16 );//v02 | (SUGGEST_RETRY << 24); +if (srb->result ==SAM_STAT_GOOD &&scsi_bufflen (srb) - +scsi_get_resid (srb) < srb->underflow) + srb->result = (DID_ERROR <<16 ); +/* v02 | (SUGGEST_RETRY << 24); */ return ;
@@ -397,8 +412,7 @@ Handle_Errors: result =usb_stor_port_reset (us);mutex_lock (&us->dev_mutex); -if (result <0 ) - { +if (result <0 ) {scsi_lock (us_to_host (us));usb_stor_report_device_reset (us);scsi_unlock (us_to_host (us));
@@ -407,10 +421,12 @@ Handle_Errors:clear_bit (US_FLIDX_RESETTING , &us->dflags); } -//----- ENE_stor_invoke_transport() --------------------- +/* +* ENE_stor_invoke_transport() +*/ void ENE_stor_invoke_transport (struct scsi_cmnd *srb,struct us_data *us) { -int result=0 ; +int result =0 ;/* pr_info("transport --- ENE_stor_invoke_transport\n"); */ usb_stor_print_cmd (srb);
@@ -418,50 +434,51 @@ void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)scsi_set_resid (srb,0 );if (!(us->MS_Status.Ready || us->SM_Status.Ready)) result =ENE_InitMedia (us); - +if (us->Power_IsResum == true) { result =ENE_InitMedia (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); - -/* if the command gets aborted by the higher layers, we need to short-circuit all other processing */ -if (test_bit (US_FLIDX_TIMED_OUT , &us->dflags)) - { + us->Power_IsResum = false; + } + +if (us->MS_Status.Ready) + result =MS_SCSIIrp (us, srb); +if (us->SM_Status.Ready) + result =SM_SCSIIrp (us, srb); + +/* if the command gets aborted by the higher layers, +we need to short-circuit all other processing */ +if (test_bit (US_FLIDX_TIMED_OUT , &us->dflags)) {/* pr_info("-- command was aborted\n"); */ srb->result =DID_ABORT <<16 ; goto Handle_Errors; }/* if there is a transport error, reset and don't auto-sense */ -if (result ==USB_STOR_TRANSPORT_ERROR ) - { +if (result ==USB_STOR_TRANSPORT_ERROR ) {/* pr_info("-- transport indicates error, resetting\n"); */ srb->result =DID_ERROR <<16 ; goto Handle_Errors; }/* if the transport provided its own sense data, don't auto-sense */ -if (result ==USB_STOR_TRANSPORT_NO_SENSE ) - { +if (result ==USB_STOR_TRANSPORT_NO_SENSE ) { srb->result =SAM_STAT_CHECK_CONDITION ;return ; } srb->result =SAM_STAT_GOOD ; -if (result ==USB_STOR_TRANSPORT_FAILED ) - { +if (result ==USB_STOR_TRANSPORT_FAILED ) {/* pr_info("-- transport indicates command failure\n"); */ -//need_auto_sense = 1; +/* need_auto_sense = 1; */ BuildSenseBuffer (srb, us->SrbStatus); srb->result =SAM_STAT_CHECK_CONDITION ; }/* Did we transfer less than the minimum amount required? */ -if (srb->result ==SAM_STAT_GOOD &&scsi_bufflen (srb) -scsi_get_resid (srb) < srb->underflow) - srb->result = (DID_ERROR <<16 );//v02 | (SUGGEST_RETRY << 24); +if (srb->result ==SAM_STAT_GOOD &&scsi_bufflen (srb) - +scsi_get_resid (srb) < srb->underflow) + srb->result = (DID_ERROR <<16 ); +/* v02 | (SUGGEST_RETRY << 24); */ return ;
@@ -475,8 +492,7 @@ Handle_Errors: result =usb_stor_port_reset (us);mutex_lock (&us->dev_mutex); -if (result <0 ) - { +if (result <0 ) {scsi_lock (us_to_host (us));usb_stor_report_device_reset (us);scsi_unlock (us_to_host (us));
@@ -485,47 +501,58 @@ Handle_Errors:clear_bit (US_FLIDX_RESETTING , &us->dflags); } -//----- BuildSenseBuffer() ------------------------------------------- +/* +* BuildSenseBuffer() +*/ void BuildSenseBuffer (struct scsi_cmnd *srb,int SrbStatus) { -BYTE *buf = srb->sense_buffer; -BYTE asc; +BYTE *buf = srb->sense_buffer; +BYTE asc;pr_info ("transport --- BuildSenseBuffer\n" ); -switch (SrbStatus) - { -case SS_NOT_READY : asc =0x3a ;break ;// sense key = 0x02 -case SS_MEDIUM_ERR : asc =0x0c ;break ;// sense key = 0x03 -case SS_ILLEGAL_REQUEST : asc =0x20 ;break ;// sense key = 0x05 -default : asc =0x00 ;break ;// ?? - } - -memset (buf,0 ,18 ); - buf[0x00 ] =0xf0 ; - buf[0x02 ] = SrbStatus; - buf[0x07 ] =0x0b ; - buf[0x0c ] = asc; +switch (SrbStatus) { +case SS_NOT_READY : + asc =0x3a ; +break ;/* sense key = 0x02 */ +case SS_MEDIUM_ERR : + asc =0x0c ; +break ;/* sense key = 0x03 */ +case SS_ILLEGAL_REQUEST : + asc =0x20 ; +break ;/* sense key = 0x05 */ +default : + asc =0x00 ; +break ;/* ?? */ + } + +memset (buf,0 ,18 ); + buf[0x00 ] =0xf0 ; + buf[0x02 ] = SrbStatus; + buf[0x07 ] =0x0b ; + buf[0x0c ] = asc; } -//----- usb_stor_stop_transport() --------------------- +/* +* usb_stor_stop_transport() +*/ void usb_stor_stop_transport (struct us_data *us) {/* pr_info("transport --- usb_stor_stop_transport\n"); */ -if (test_and_clear_bit (US_FLIDX_URB_ACTIVE , &us->dflags)) - { +if (test_and_clear_bit (US_FLIDX_URB_ACTIVE , &us->dflags)) {/* pr_info("-- cancelling URB\n"); */ usb_unlink_urb (us->current_urb); } -if (test_and_clear_bit (US_FLIDX_SG_ACTIVE , &us->dflags)) - { +if (test_and_clear_bit (US_FLIDX_SG_ACTIVE , &us->dflags)) {/* pr_info("-- cancelling sg request\n"); */ usb_sg_cancel (&us->current_sg); } } -//----- usb_stor_Bulk_max_lun() --------------------- +/* +* usb_stor_Bulk_max_lun() +*/ int usb_stor_Bulk_max_lun (struct us_data *us) {int result;
@@ -549,7 +576,9 @@ int usb_stor_Bulk_max_lun(struct us_data *us)return 0 ; } -//----- usb_stor_Bulk_transport() --------------------- +/* +* usb_stor_Bulk_transport() +*/ int usb_stor_Bulk_transport (struct scsi_cmnd *srb,struct us_data *us) {struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
@@ -563,8 +592,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)/* pr_info("transport --- usb_stor_Bulk_transport\n"); */ /* Take care of BULK32 devices; set extra byte to 0 */ -if (unlikely (us->fflags &US_FL_BULK32 )) - { +if (unlikely (us->fflags &US_FL_BULK32 )) { cbwlen =32 ; us->iobuf[31 ] =0 ; }
@@ -583,14 +611,15 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)memset (bcb->CDB,0 ,sizeof (bcb->CDB));memcpy (bcb->CDB, srb->cmnd, bcb->Length); -// send command +/* send command */ /* send it to out endpoint */ /* pr_info("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n", le32_to_cpu(bcb->Signature), bcb->Tag, le32_to_cpu(bcb->DataTransferLength), bcb->Flags, (bcb->Lun >> 4), (bcb->Lun & 0x0F), bcb->Length); */ - result =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, bcb, cbwlen,NULL ); + result =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, + bcb, cbwlen,NULL );/* pr_info("Bulk command transfer result=%d\n", result); */ if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ;
@@ -598,10 +627,10 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)if (unlikely (us->fflags &US_FL_GO_SLOW ))udelay (125 ); -// R/W data -if (transfer_length) - { -unsigned int pipe = srb->sc_data_direction ==DMA_FROM_DEVICE ? us->recv_bulk_pipe : us->send_bulk_pipe; +/* R/W data */ +if (transfer_length) { +unsigned int pipe = srb->sc_data_direction == +DMA_FROM_DEVICE ? us->recv_bulk_pipe : us->send_bulk_pipe; result =usb_stor_bulk_srb (us, pipe, srb);/* pr_info("Bulk data transfer result 0x%x\n", result); */ if (result ==USB_STOR_XFER_ERROR )
@@ -613,20 +642,21 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)/* get CSW for device status */ /* pr_info("Attempting to get CSW...\n"); */ - result =usb_stor_bulk_transfer_buf (us, us->recv_bulk_pipe, bcs,US_BULK_CS_WRAP_LEN , &cswlen); + result =usb_stor_bulk_transfer_buf (us, us->recv_bulk_pipe, bcs, +US_BULK_CS_WRAP_LEN , &cswlen); -if (result ==USB_STOR_XFER_SHORT && cswlen ==0 ) - { +if (result ==USB_STOR_XFER_SHORT && cswlen ==0 ) {/* pr_info("Received 0-length CSW; retrying...\n"); */ - result =usb_stor_bulk_transfer_buf (us, us->recv_bulk_pipe, bcs,US_BULK_CS_WRAP_LEN , &cswlen); + result =usb_stor_bulk_transfer_buf (us, us->recv_bulk_pipe, bcs, +US_BULK_CS_WRAP_LEN , &cswlen); }/* did the attempt to read the CSW fail? */ -if (result ==USB_STOR_XFER_STALLED ) - { +if (result ==USB_STOR_XFER_STALLED ) {/* get the status again */ /* pr_info("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 ); + result =usb_stor_bulk_transfer_buf (us, us->recv_bulk_pipe, bcs, +US_BULK_CS_WRAP_LEN ,NULL ); }/* if we still have a failure at this point, we're in trouble */
@@ -639,21 +669,19 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)/* pr_info("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", le32_to_cpu(bcs->Signature), bcs->Tag, residue, bcs->Status); */ -if (!(bcs->Tag == us->tag || (us->fflags &US_FL_BULK_IGNORE_TAG )) || bcs->Status >US_BULK_STAT_PHASE ) - { +if (!(bcs->Tag == us->tag || + (us->fflags &US_FL_BULK_IGNORE_TAG )) || + bcs->Status >US_BULK_STAT_PHASE ) {/* pr_info("Bulk logical error\n"); */ return USB_STOR_TRANSPORT_ERROR ; } -if (!us->bcs_signature) - { +if (!us->bcs_signature) { us->bcs_signature = bcs->Signature; -//if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN)) +/* if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN)) */ /* pr_info("Learnt BCS signature 0x%08X\n", le32_to_cpu(us->bcs_signature)); */ - } -else if (bcs->Signature != us->bcs_signature) - { + }else if (bcs->Signature != us->bcs_signature) {/* pr_info("Signature mismatch: got %08X, expecting %08X\n", le32_to_cpu(bcs->Signature), le32_to_cpu(us->bcs_signature)); */
@@ -662,8 +690,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)/* try to compute the actual residue, based on how much data * was really transferred and what the device tells us */ -if (residue && !(us->fflags &US_FL_IGNORE_RESIDUE )) - { +if (residue && !(us->fflags &US_FL_IGNORE_RESIDUE )) {/* Heuristically detect devices that generate bogus residues * by seeing what happens with INQUIRY and READ CAPACITY
@@ -674,34 +701,31 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) ((srb->cmnd[0 ] ==INQUIRY && transfer_length ==36 ) || (srb->cmnd[0 ] ==READ_CAPACITY && - transfer_length == 8))) - { + transfer_length == 8))) { us->fflags |= US_FL_IGNORE_RESIDUE; - } -else - { + }else { residue =min (residue, transfer_length); -scsi_set_resid (srb,max (scsi_get_resid (srb), (int ) residue)); +scsi_set_resid (srb,max (scsi_get_resid (srb), + (int ) residue)); } }/* based on the status code, we report good or bad */ -switch (bcs->Status) - { -case US_BULK_STAT_OK : -if (fake_sense) - { -memcpy (srb->sense_buffer, usb_stor_sense_invalidCDB,sizeof (usb_stor_sense_invalidCDB)); -return USB_STOR_TRANSPORT_NO_SENSE ; - } -return USB_STOR_TRANSPORT_GOOD ; - -case US_BULK_STAT_FAIL : -return USB_STOR_TRANSPORT_FAILED ; - -case US_BULK_STAT_PHASE : -return USB_STOR_TRANSPORT_ERROR ; +switch (bcs->Status) { +case US_BULK_STAT_OK : +if (fake_sense) { +memcpy (srb->sense_buffer, usb_stor_sense_invalidCDB, +sizeof (usb_stor_sense_invalidCDB)); +return USB_STOR_TRANSPORT_NO_SENSE ; + } +return USB_STOR_TRANSPORT_GOOD ; + +case US_BULK_STAT_FAIL : +return USB_STOR_TRANSPORT_FAILED ; + +case US_BULK_STAT_PHASE : +return USB_STOR_TRANSPORT_ERROR ; }return USB_STOR_TRANSPORT_ERROR ; }
@@ -709,7 +733,9 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)/*********************************************************************** * Reset routines ***********************************************************************/ -//----- usb_stor_reset_common() --------------------- +/* +* usb_stor_reset_common() +*/ static int usb_stor_reset_common (struct us_data *us,u8 request,u8 requesttype,u16 value,u16 index,void *data,u16 size)
@@ -718,22 +744,23 @@ static int usb_stor_reset_common(struct us_data *us,int result2;/* pr_info("transport --- usb_stor_reset_common\n"); */ -if (test_bit (US_FLIDX_DISCONNECTING , &us->dflags)) - { +if (test_bit (US_FLIDX_DISCONNECTING , &us->dflags)) {/* pr_info("No reset during disconnect\n"); */ return -EIO ; } - result =usb_stor_control_msg (us, us->send_ctrl_pipe, request, requesttype, value, index, data, size,5 *HZ ); -if (result <0 ) - { + result =usb_stor_control_msg (us, us->send_ctrl_pipe, + request, requesttype, value, index, data, size,5 *HZ ); + +if (result <0 ) {/* pr_info("Soft reset failed: %d\n", result); */ return result; } -wait_event_interruptible_timeout (us->delay_wait,test_bit (US_FLIDX_DISCONNECTING , &us->dflags),HZ *6 ); -if (test_bit (US_FLIDX_DISCONNECTING , &us->dflags)) - { +wait_event_interruptible_timeout (us->delay_wait, +test_bit (US_FLIDX_DISCONNECTING , &us->dflags),HZ *6 ); + +if (test_bit (US_FLIDX_DISCONNECTING , &us->dflags)) {/* pr_info("Reset interrupted by disconnect\n"); */ return -EIO ; }
@@ -747,14 +774,16 @@ static int usb_stor_reset_common(struct us_data *us,/* return a result code based on the result of the clear-halts */ if (result >=0 ) result = result2; -//if (result < 0) +/* if (result < 0) */ /* pr_info("Soft reset failed\n"); */ -//else +/* else */ /* pr_info("Soft reset done\n"); */ return result; } -//----- usb_stor_Bulk_reset() --------------------- +/* +* usb_stor_Bulk_reset() +*/ int usb_stor_Bulk_reset (struct us_data *us) {/* pr_info("transport --- usb_stor_Bulk_reset\n"); */
@@ -763,7 +792,9 @@ int usb_stor_Bulk_reset(struct us_data *us) 0, us->ifnum, NULL, 0); } -//----- usb_stor_port_reset() --------------------- +/* +* usb_stor_port_reset() +*/ int usb_stor_port_reset (struct us_data *us) {int result;
drivers/staging/keucr/transport.h +50 -31
135 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 7/7 staging/keucr : fix transport other code style
In reply to Cho, Yu-Chenfix keucr transport.c other coding style but not from checkpatch.pl. replace ternary conditional "?:" with if/else
--- drivers/staging/keucr/transport.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/staging/keucr/transport.c +6 -2
@@ -629,8 +629,12 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)/* R/W data */ if (transfer_length) { -unsigned int pipe = srb->sc_data_direction == -DMA_FROM_DEVICE ? us->recv_bulk_pipe : us->send_bulk_pipe; +unsigned int pipe; +if (srb->sc_data_direction ==DMA_FROM_DEVICE ) + pipe = us->recv_bulk_pipe; +else + pipe = us->send_bulk_pipe; + result =usb_stor_bulk_srb (us, pipe, srb);/* pr_info("Bulk data transfer result 0x%x\n", result); */ if (result ==USB_STOR_XFER_ERROR )
Signature · 1 line
1.7.1