int i;
pr_info("SM_FreeMem start\n");
- for (i=0; i<MAX_ZONENUM; i++)
- {
- if (Log2Phy[i]!=NULL)
- {
+ for (i=0; i<MAX_ZONENUM; i++) {
+ if (Log2Phy[i]!=NULL) {
pr_info("Free Zone = %x, Addr = %p\n", i, Log2Phy[i]);
kfree(Log2Phy[i]);
Log2Phy[i] = NULL;
if (Conv_D_MediaAddr(us, start))
return ErrCode;
- while(1)
- {
+ while(1) {
len = Ssfdc.MaxSectors - Media.Sector;
if (count > len)
bn = len;
bn = count;
//if (Media_D_ReadOneSect(fdoExt, SectBuf))
//if (Media_D_ReadOneSect(fdoExt, count, buf))
- if (Media_D_ReadOneSect(us, bn, buf))
- {
+ if (Media_D_ReadOneSect(us, bn, buf)) {
ErrCode = ERR_EccReadErr;
return ErrCode;
}
if (Conv_D_MediaAddr(us, start))
return ErrCode;
- while(1)
- {
+ while(1) {
if (Assign_D_WriteBlock())
return ERROR;
bn = count;
//if (Ssfdc_D_CopyBlock(fdoExt,count,buf,Redundant))
- if (Ssfdc_D_CopyBlock(us,bn,buf,Redundant))
- {
+ if (Ssfdc_D_CopyBlock(us,bn,buf,Redundant)) {
ErrCode = ERR_WriteFault;
return ErrCode;
}
Media.Sector = 0x1F;
//if (Release_D_ReadBlock(fdoExt))
- if (Release_D_CopySector(us))
- {
- if (ErrCode==ERR_HwError)
- {
+ if (Release_D_CopySector(us)) {
+ if (ErrCode==ERR_HwError) {
ErrCode = ERR_WriteFault;
return ErrCode;
}
Log2Phy[Media.Zone][Media.LogBlock]=WriteBlock;
Media.PhyBlock=ReadBlock;
- if (Media.PhyBlock==NO_ASSIGN)
- {
+ if (Media.PhyBlock==NO_ASSIGN) {
Media.PhyBlock=WriteBlock;
return SMSUCCESS;
}
SectCopyMode = COMPLETED;
//usleep(56*1024);
- if (Set_D_PhyFmtValue(us))
- {
+ if (Set_D_PhyFmtValue(us)) {
ErrCode = ERR_UnknownMedia;
return ERROR;
}
//usleep(56*1024);
- if (Search_D_CIS(us))
- {
+ if (Search_D_CIS(us)) {
ErrCode = ERR_IllegalFmt;
return ERROR;
}
temp = addr/Ssfdc.MaxSectors;
Media.Zone = (BYTE) (temp/Ssfdc.MaxLogBlocks);
- if (Log2Phy[Media.Zone]==NULL)
- {
- if (Make_D_LogTable(us))
- {
+ if (Log2Phy[Media.Zone]==NULL) {
+ if (Make_D_LogTable(us)) {
ErrCode = ERR_IllegalFmt;
return ERROR;
}
Media.Sector = (BYTE) (addr%Ssfdc.MaxSectors);
Media.LogBlock = (WORD) (temp%Ssfdc.MaxLogBlocks);
- if (Media.Zone<Ssfdc.MaxZones)
- {
+ if (Media.Zone<Ssfdc.MaxZones) {
Clr_D_RedundantData(Redundant);
Set_D_LogBlockAddr(Redundant);
Media.PhyBlock = Log2Phy[Media.Zone][Media.LogBlock];
if (++Media.Sector<Ssfdc.MaxSectors)
return SMSUCCESS;
- if (Log2Phy[Media.Zone]==NULL)
- {
- if (Make_D_LogTable(us))
- {
+ if (Log2Phy[Media.Zone]==NULL) {
+ if (Make_D_LogTable(us)) {
ErrCode = ERR_IllegalFmt;
return ERROR;
}
Media.Sector=0;
Media.LogBlock = LogBlock;
- if (++Media.LogBlock<Ssfdc.MaxLogBlocks)
- {
+ if (++Media.LogBlock<Ssfdc.MaxLogBlocks) {
Clr_D_RedundantData(Redundant);
Set_D_LogBlockAddr(Redundant);
Media.PhyBlock=Log2Phy[Media.Zone][Media.LogBlock];
Media.LogBlock=0;
- if (++Media.Zone<Ssfdc.MaxZones)
- {
- if (Log2Phy[Media.Zone]==NULL)
- {
- if (Make_D_LogTable(us))
- {
+ if (++Media.Zone<Ssfdc.MaxZones) {
+ if (Log2Phy[Media.Zone]==NULL) {
+ if (Make_D_LogTable(us)) {
ErrCode = ERR_IllegalFmt;
return ERROR;
}
return ERROR;
#ifdef RDERR_REASSIGN
- if (Ssfdc.Attribute &MWP)
- {
+ if (Ssfdc.Attribute &MWP) {
if (ErrCode==ERR_CorReadErr)
return SMSUCCESS;
return ERROR;
}
err=ErrCode;
- for(retry=0; retry<2; retry++)
- {
- if (Copy_D_BlockAll(us, (err==ERR_EccReadErr)?REQ_FAIL:REQ_ERASE))
- {
+ for(retry=0; retry<2; retry++) {
+ if (Copy_D_BlockAll(us, (err==ERR_EccReadErr)?REQ_FAIL:REQ_ERASE)) {
if (ErrCode==ERR_HwError)
return ERROR;
continue;
if (mode==REQ_FAIL)
SectCopyMode=REQ_FAIL;
- for(Media.Sector=0; Media.Sector<Ssfdc.MaxSectors; Media.Sector++)
- {
- if (Copy_D_PhyOneSect(us))
- {
+ for(Media.Sector=0; Media.Sector<Ssfdc.MaxSectors; Media.Sector++) {
+ if (Copy_D_PhyOneSect(us)) {
if (ErrCode==ERR_HwError)
return ERROR;
if (Release_D_WriteBlock(us))
//ADDRESS_T bb = (ADDRESS_T) &Media;
ReadBlock=Media.PhyBlock;
- for(WriteBlock=AssignStart[Media.Zone]; WriteBlock<Ssfdc.MaxBlocks; WriteBlock++)
- {
- if (!Chk_D_Bit(Assign[Media.Zone],WriteBlock))
- {
+ for(WriteBlock=AssignStart[Media.Zone]; WriteBlock<Ssfdc.MaxBlocks; WriteBlock++) {
+ if (!Chk_D_Bit(Assign[Media.Zone],WriteBlock)) {
Set_D_Bit(Assign[Media.Zone],WriteBlock);
AssignStart[Media.Zone]=WriteBlock+1;
Media.PhyBlock=WriteBlock;
}
}
- for(WriteBlock=0; WriteBlock<AssignStart[Media.Zone]; WriteBlock++)
- {
- if (!Chk_D_Bit(Assign[Media.Zone],WriteBlock))
- {
+ for(WriteBlock=0; WriteBlock<AssignStart[Media.Zone]; WriteBlock++) {
+ if (!Chk_D_Bit(Assign[Media.Zone],WriteBlock)) {
Set_D_Bit(Assign[Media.Zone],WriteBlock);
AssignStart[Media.Zone]=WriteBlock+1;
Media.PhyBlock=WriteBlock;
Log2Phy[Media.Zone][Media.LogBlock]=WriteBlock;
Media.PhyBlock=ReadBlock;
- if (Media.PhyBlock==NO_ASSIGN)
- {
+ if (Media.PhyBlock==NO_ASSIGN) {
Media.PhyBlock=WriteBlock;
return SMSUCCESS;
}
- if (mode==REQ_ERASE)
- {
- if (Erase_D_PhyOneBlock(us))
- {
+ if (mode==REQ_ERASE) {
+ if (Erase_D_PhyOneBlock(us)) {
if (ErrCode==ERR_HwError) return ERROR;
if (MarkFail_D_PhyOneBlock(us)) return ERROR;
}
//ADDRESS_T bb = (ADDRESS_T) &Media;
/* pr_info("Copy_D_PhyOneSect --- Secotr = %x\n", Media.Sector); */
- if (ReadBlock!=NO_ASSIGN)
- {
+ if (ReadBlock!=NO_ASSIGN) {
Media.PhyBlock=ReadBlock;
- for(retry=0; retry<2; retry++)
- {
- if (retry!=0)
- {
+ for(retry=0; retry<2; retry++) {
+ if (retry!=0) {
Ssfdc_D_Reset(us);
- if (Ssfdc_D_ReadCisSect(us,WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return ERROR; }
+ if (Ssfdc_D_ReadCisSect(us,WorkBuf,WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange=ERROR;
+ return ERROR;
+ }
- if (Check_D_CISdata(WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return ERROR; }
+ if (Check_D_CISdata(WorkBuf,WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange=ERROR;
+ return ERROR;
+ }
}
- if (Ssfdc_D_ReadSect(us,WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return ERROR; }
- if (Check_D_DataStatus(WorkRedund))
- { err=ERROR; break; }
- if (!Check_D_ReadError(WorkRedund))
- { err=SMSUCCESS; break; }
- if (!Check_D_Correct(WorkBuf,WorkRedund))
- { err=SMSUCCESS; break; }
+ if (Ssfdc_D_ReadSect(us,WorkBuf,WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange=ERROR;
+ return ERROR;
+ }
+ if (Check_D_DataStatus(WorkRedund)) {
+ err=ERROR;
+ break;
+ }
+ if (!Check_D_ReadError(WorkRedund)) {
+ err=SMSUCCESS;
+ break;
+ }
+ if (!Check_D_Correct(WorkBuf,WorkRedund)) {
+ err=SMSUCCESS;
+ break;
+ }
err=ERROR;
SectCopyMode=REQ_FAIL;
}
}
- else
- {
+ else {
err=SMSUCCESS;
for(i=0; i<SECTSIZE; i++)
WorkBuf[i]=DUMMY_DATA;
}
Set_D_LogBlockAddr(WorkRedund);
- if (err==ERROR)
- {
+ if (err==ERROR) {
Set_D_RightECC(WorkRedund);
Set_D_DataStaus(WorkRedund);
}
Media.PhyBlock=WriteBlock;
- if (Ssfdc_D_WriteSectForCopy(us, WorkBuf, WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return ERROR; }
- if (Ssfdc_D_CheckStatus())
- { ErrCode = ERR_WriteFault; return ERROR; }
+ if (Ssfdc_D_WriteSectForCopy(us, WorkBuf, WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange=ERROR;
+ return ERROR;
+ }
+ if (Ssfdc_D_CheckStatus()) {
+ ErrCode = ERR_WriteFault;
+ return ERROR;
+ }
Media.PhyBlock=ReadBlock;
return SMSUCCESS;
//SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
//ADDRESS_T bb = (ADDRESS_T) &Media;
- if (Media.PhyBlock==NO_ASSIGN)
- {
+ if (Media.PhyBlock==NO_ASSIGN) {
for(i=0; i<SECTSIZE; i++)
*buf++=DUMMY_DATA;
return SMSUCCESS;
}
- for(retry=0; retry<2; retry++)
- {
- if (retry!=0)
- {
+ for(retry=0; retry<2; retry++) {
+ if (retry!=0) {
Ssfdc_D_Reset(us);
- if (Ssfdc_D_ReadCisSect(us,WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return ERROR; }
- if (Check_D_CISdata(WorkBuf,WorkRedund))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return ERROR; }
+ if (Ssfdc_D_ReadCisSect(us,WorkBuf,WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange=ERROR;
+ return ERROR;
+ }
+ if (Check_D_CISdata(WorkBuf,WorkRedund)) {
+ ErrCode = ERR_HwError;
+ MediaChange=ERROR;
+ return ERROR;
+ }
}
//if (Ssfdc_D_ReadSect(fdoExt,buf,Redundant))
- if (Ssfdc_D_ReadBlock(us,count,buf,Redundant))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return ERROR; }
- if (Check_D_DataStatus(Redundant))
- { ErrCode = ERR_DataStatus; return ERROR; }
+ if (Ssfdc_D_ReadBlock(us,count,buf,Redundant)) {
+ ErrCode = ERR_HwError;
+ MediaChange=ERROR;
+ return ERROR;
+ }
+ if (Check_D_DataStatus(Redundant)) {
+ ErrCode = ERR_DataStatus;
+ return ERROR;
+ }
if (!Check_D_ReadError(Redundant))
return SMSUCCESS;
- if (!Check_D_Correct(buf,Redundant))
- { ErrCode = ERR_CorReadErr; return ERROR; }
+ if (!Check_D_Correct(buf,Redundant)) {
+ ErrCode = ERR_CorReadErr;
+ return ERROR;
+ }
}
ErrCode = ERR_EccReadErr;
//SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
//ADDRESS_T bb = (ADDRESS_T) &Media;
- if (Ssfdc_D_EraseBlock(us))
- { ErrCode = ERR_HwError; MediaChange=ERROR; return ERROR; }
- if (Ssfdc_D_CheckStatus())
- { ErrCode = ERR_WriteFault; return ERROR; }
+ if (Ssfdc_D_EraseBlock(us)) {
+ ErrCode = ERR_HwError;
+ MediaChange=ERROR;
+ return ERROR;
+ }
+ if (Ssfdc_D_CheckStatus()) {
+ ErrCode = ERR_WriteFault;
+ return ERROR;
+ }
return SMSUCCESS;
}
Media.Zone=0; Media.Sector=0;
- for (Media.PhyBlock=0; Media.PhyBlock<(Ssfdc.MaxBlocks-Ssfdc.MaxLogBlocks-1); Media.PhyBlock++)
- {
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- {
+ for (Media.PhyBlock=0; Media.PhyBlock<(Ssfdc.MaxBlocks-Ssfdc.MaxLogBlocks-1); Media.PhyBlock++) {
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
Ssfdc_D_Reset(us);
return ERROR;
}
break;
}
- if (Media.PhyBlock==(Ssfdc.MaxBlocks-Ssfdc.MaxLogBlocks-1))
- {
+ if (Media.PhyBlock==(Ssfdc.MaxBlocks-Ssfdc.MaxLogBlocks-1)) {
Ssfdc_D_Reset(us);
return ERROR;
}
- while (Media.Sector<CIS_SEARCH_SECT)
- {
- if (Media.Sector)
- {
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- {
+ while (Media.Sector<CIS_SEARCH_SECT) {
+ if (Media.Sector) {
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
Ssfdc_D_Reset(us);
return ERROR;
}
}
- if (!Check_D_DataStatus(Redundant))
- {
- if (Ssfdc_D_ReadSect(us,WorkBuf,Redundant))
- {
+ if (!Check_D_DataStatus(Redundant)) {
+ if (Ssfdc_D_ReadSect(us,WorkBuf,Redundant)) {
Ssfdc_D_Reset(us);
return ERROR;
}
- if (Check_D_CISdata(WorkBuf,Redundant))
- {
+ if (Check_D_CISdata(WorkBuf,Redundant)) {
Ssfdc_D_Reset(us);
return ERROR;
}
//SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
//ADDRESS_T bb = (ADDRESS_T) &Media;
- if (Log2Phy[Media.Zone]==NULL)
- {
+ if (Log2Phy[Media.Zone]==NULL) {
Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK*sizeof(WORD), GFP_KERNEL);
/* pr_info("ExAllocatePool Zone = %x, Addr = %x\n",
Media.Zone, Log2Phy[Media.Zone]); */
for(Media.PhyBlock=0; Media.PhyBlock<(MAX_BLOCKNUM/8); Media.PhyBlock++)
Assign[Media.Zone][Media.PhyBlock]=0x00;
- for(Media.PhyBlock=0; Media.PhyBlock<Ssfdc.MaxBlocks; Media.PhyBlock++)
- {
- if ((!Media.Zone) && (Media.PhyBlock<=CisArea.PhyBlock))
- {
+ for(Media.PhyBlock=0; Media.PhyBlock<Ssfdc.MaxBlocks; Media.PhyBlock++) {
+ if ((!Media.Zone) && (Media.PhyBlock<=CisArea.PhyBlock)) {
Set_D_Bit(Assign[Media.Zone],Media.PhyBlock);
continue;
}
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- { Ssfdc_D_Reset(us); return ERROR; }
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
+ Ssfdc_D_Reset(us);
+ return ERROR;
+ }
if (!Check_D_DataBlank(Redundant))
continue;
if (Media.LogBlock>=Ssfdc.MaxLogBlocks)
continue;
- if (Log2Phy[Media.Zone][Media.LogBlock]==NO_ASSIGN)
- {
+ if (Log2Phy[Media.Zone][Media.LogBlock]==NO_ASSIGN) {
Log2Phy[Media.Zone][Media.LogBlock]=Media.PhyBlock;
continue;
}
logblock = Media.LogBlock;
Media.Sector = (BYTE)(Ssfdc.MaxSectors-1);
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- { Ssfdc_D_Reset(us); return ERROR; }
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
+ Ssfdc_D_Reset(us);
+ return ERROR;
+ }
- if (!Load_D_LogBlockAddr(Redundant))
- {
- if (Media.LogBlock==logblock)
- {
+ if (!Load_D_LogBlockAddr(Redundant)) {
+ if (Media.LogBlock==logblock) {
Media.PhyBlock=Log2Phy[Media.Zone][logblock];
- if (Ssfdc_D_ReadRedtData(us, Redundant))
- { Ssfdc_D_Reset(us); return ERROR; }
+ if (Ssfdc_D_ReadRedtData(us, Redundant)) {
+ Ssfdc_D_Reset(us);
+ return ERROR;
+ }
Media.PhyBlock=phyblock;
- if (!Load_D_LogBlockAddr(Redundant))
- {
- if (Media.LogBlock!=logblock)
- {
+ if (!Load_D_LogBlockAddr(Redundant)) {
+ if (Media.LogBlock!=logblock) {
Media.PhyBlock=Log2Phy[Media.Zone][logblock];
Log2Phy[Media.Zone][logblock]=phyblock;
}
}
- else
- {
+ else {
Media.PhyBlock=Log2Phy[Media.Zone][logblock];
Log2Phy[Media.Zone][logblock]=phyblock;
}
Set_D_FailBlock(WorkRedund);
//Ssfdc_D_WriteRedtMode();
- for(Media.Sector=0; Media.Sector<Ssfdc.MaxSectors; Media.Sector++)
- {
- if (Ssfdc_D_WriteRedtData(us, WorkRedund))
- {
+ for(Media.Sector=0; Media.Sector<Ssfdc.MaxSectors; Media.Sector++) {
+ if (Ssfdc_D_WriteRedtData(us, WorkRedund)) {
Ssfdc_D_Reset(us);
Media.Sector = sect;
ErrCode = ERR_HwError;