Skip to content

Commit

Permalink
staging:keucr: Remove typedefs
Browse files Browse the repository at this point in the history
As suggested by Pablo, this patch uses a coccinelle script to remove the
typedefs:
typedef u8 BOOLEAN;  <-- use "bool" instead.
typedef u8 BYTE;     <-- use "u8"
typedef u8 *PBYTE;   <-- use "u8 *"
typedef u16 WORD;    <-- use "u16"
typedef u16 *PWORD;  <-- use "u16 *"
typedef u32 DWORD;   <-- use "u32"
typedef u32 *PDWORD; <-- use "u32 *"
in common.h.

The coccinelle script is:
/* coccinelle script to remove typedefs. */
@remove_typedef@
@@
-typedef bool BOOLEAN;
-typedef u8 BYTE;
-typedef u8 *PBYTE;
-typedef u16 WORD;
-typedef u16 *PWORD;
-typedef u32 DWORD;
-typedef u32 *PDWORD;

@fix_usage@
typedef BOOLEAN;
@@
-BOOLEAN
+bool

@fix_usage1@
typedef BYTE;
@@
-BYTE
+u8

@fix_usage2@
typedef PBYTE;
@@
-PBYTE
+u8 *

@fix_usage3@
typedef WORD;
@@
-WORD
+u16

@fix_usage4@
typedef PWORD;
@@
-PWORD
+u16 *

@fix_usage5@
typedef DWORD;
identifier f;
@@
-DWORD
+u32

@fix_usage6@
typedef PDWORD;
@@
-PDWORD
+u32 *

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
  • Loading branch information
Himangi Saraogi authored and Peter P Waskiewicz Jr committed Mar 17, 2014
1 parent 68b3500 commit 432f857
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 297 deletions.
8 changes: 0 additions & 8 deletions drivers/staging/keucr/common.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
#ifndef COMMON_INCD
#define COMMON_INCD

typedef u8 BOOLEAN;
typedef u8 BYTE;
typedef u8 *PBYTE;
typedef u16 WORD;
typedef u16 *PWORD;
typedef u32 DWORD;
typedef u32 *PDWORD;

#define BYTE_MASK 0xff

#endif
Expand Down
16 changes: 8 additions & 8 deletions drivers/staging/keucr/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
int ENE_InitMedia(struct us_data *us)
{
int result;
BYTE MiscReg03 = 0;
u8 MiscReg03 = 0;

dev_info(&us->pusb_dev->dev, "--- Init Media ---\n");
result = ene_read_byte(us, REG_CARD_STATUS, &MiscReg03);
Expand All @@ -41,7 +41,7 @@ int ENE_InitMedia(struct us_data *us)
/*
* ene_read_byte() :
*/
int ene_read_byte(struct us_data *us, WORD index, void *buf)
int ene_read_byte(struct us_data *us, u16 index, void *buf)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
Expand All @@ -51,8 +51,8 @@ int ene_read_byte(struct us_data *us, WORD index, void *buf)
bcb->DataTransferLength = 0x01;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xED;
bcb->CDB[2] = (BYTE)(index>>8);
bcb->CDB[3] = (BYTE)index;
bcb->CDB[2] = (u8)(index>>8);
bcb->CDB[3] = (u8)index;

result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
return result;
Expand All @@ -65,7 +65,7 @@ int ENE_SMInit(struct us_data *us)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
BYTE buf[0x200];
u8 buf[0x200];

dev_dbg(&us->pusb_dev->dev, "transport --- ENE_SMInit\n");

Expand Down Expand Up @@ -122,12 +122,12 @@ int ENE_SMInit(struct us_data *us)
/*
* ENE_LoadBinCode()
*/
int ENE_LoadBinCode(struct us_data *us, BYTE flag)
int ENE_LoadBinCode(struct us_data *us, u8 flag)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
/* void *buf; */
PBYTE buf;
u8 *buf;

/* dev_info(&us->pusb_dev->dev, "transport --- ENE_LoadBinCode\n"); */
if (us->BIN_FLAG == flag)
Expand Down Expand Up @@ -164,7 +164,7 @@ int ENE_LoadBinCode(struct us_data *us, BYTE flag)
/*
* ENE_SendScsiCmd():
*/
int ENE_SendScsiCmd(struct us_data *us, BYTE fDir, void *buf, int use_sg)
int ENE_SendScsiCmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/keucr/init.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "common.h"

extern DWORD MediaChange;
extern u32 MediaChange;
extern int Check_D_MediaFmt(struct us_data *);



static BYTE SM_Init[] = {
static u8 SM_Init[] = {
0x7B, 0x09, 0x7C, 0xF0, 0x7D, 0x10, 0x7E, 0xE9,
0x7F, 0xCC, 0x12, 0x2F, 0x71, 0x90, 0xE9, 0xCC,
0xE0, 0xB4, 0x07, 0x12, 0x90, 0xFF, 0x09, 0xE0,
Expand Down Expand Up @@ -263,7 +263,7 @@ static BYTE SM_Init[] = {
0x58, 0x44, 0x2D, 0x49, 0x6E, 0x69, 0x74, 0x20,
0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x31 };

static BYTE SM_Rdwr[] = {
static u8 SM_Rdwr[] = {
0x7B, 0x0C, 0x7C, 0xF0, 0x7D, 0x10, 0x7E, 0xE9,
0x7F, 0xCC, 0x12, 0x2F, 0x71, 0x90, 0xE9, 0xC3,
0xE0, 0xB4, 0x73, 0x04, 0x74, 0x40, 0x80, 0x09,
Expand Down
112 changes: 56 additions & 56 deletions drivers/staging/keucr/smil.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,29 +169,29 @@ SmartMedia Model & Attribute
Struct Definition
***************************************************************************/
struct keucr_media_info {
BYTE Model;
BYTE Attribute;
BYTE MaxZones;
BYTE MaxSectors;
WORD MaxBlocks;
WORD MaxLogBlocks;
u8 Model;
u8 Attribute;
u8 MaxZones;
u8 MaxSectors;
u16 MaxBlocks;
u16 MaxLogBlocks;
};

struct keucr_media_address {
BYTE Zone; /* Zone Number */
BYTE Sector; /* Sector(512byte) Number on Block */
WORD PhyBlock; /* Physical Block Number on Zone */
WORD LogBlock; /* Logical Block Number of Zone */
u8 Zone; /* Zone Number */
u8 Sector; /* Sector(512byte) Number on Block */
u16 PhyBlock; /* Physical Block Number on Zone */
u16 LogBlock; /* Logical Block Number of Zone */
};

struct keucr_media_area {
BYTE Sector; /* Sector(512byte) Number on Block */
WORD PhyBlock; /* Physical Block Number on Zone 0 */
u8 Sector; /* Sector(512byte) Number on Block */
u16 PhyBlock; /* Physical Block Number on Zone 0 */
};

extern WORD ReadBlock;
extern WORD WriteBlock;
extern DWORD MediaChange;
extern u16 ReadBlock;
extern u16 WriteBlock;
extern u32 MediaChange;

extern struct keucr_media_info Ssfdc;
extern struct keucr_media_address Media;
Expand All @@ -204,56 +204,56 @@ extern struct keucr_media_area CisArea;
int Init_D_SmartMedia(void);
int Pwoff_D_SmartMedia(void);
int Check_D_SmartMedia(void);
int Check_D_Parameter(struct us_data *, WORD *, BYTE *, BYTE *);
int Media_D_ReadSector(struct us_data *, DWORD, WORD, BYTE *);
int Media_D_WriteSector(struct us_data *, DWORD, WORD, BYTE *);
int Media_D_CopySector(struct us_data *, DWORD, WORD, BYTE *);
int Media_D_EraseBlock(struct us_data *, DWORD, WORD);
int Check_D_Parameter(struct us_data *, u16 *, u8 *, u8 *);
int Media_D_ReadSector(struct us_data *, u32, u16, u8 *);
int Media_D_WriteSector(struct us_data *, u32, u16, u8 *);
int Media_D_CopySector(struct us_data *, u32, u16, u8 *);
int Media_D_EraseBlock(struct us_data *, u32, u16);
int Media_D_EraseAll(struct us_data *);
/******************************************/
int Media_D_OneSectWriteStart(struct us_data *, DWORD, BYTE *);
int Media_D_OneSectWriteNext(struct us_data *, BYTE *);
int Media_D_OneSectWriteStart(struct us_data *, u32, u8 *);
int Media_D_OneSectWriteNext(struct us_data *, u8 *);
int Media_D_OneSectWriteFlush(struct us_data *);

/******************************************/
extern int SM_FreeMem(void); /* ENE SM function */
void SM_EnableLED(struct us_data *, BOOLEAN);
void SM_EnableLED(struct us_data *, bool);
void Led_D_TernOn(void);
void Led_D_TernOff(void);

int Media_D_EraseAllRedtData(DWORD Index, BOOLEAN CheckBlock);
int Media_D_EraseAllRedtData(u32 Index, bool CheckBlock);
/*DWORD Media_D_GetMediaInfo(struct us_data * fdoExt,
PIOCTL_MEDIA_INFO_IN pParamIn, PIOCTL_MEDIA_INFO_OUT pParamOut); */

/*
* SMILSub.c
*/
/******************************************/
int Check_D_DataBlank(BYTE *);
int Check_D_FailBlock(BYTE *);
int Check_D_DataStatus(BYTE *);
int Load_D_LogBlockAddr(BYTE *);
void Clr_D_RedundantData(BYTE *);
void Set_D_LogBlockAddr(BYTE *);
void Set_D_FailBlock(BYTE *);
void Set_D_DataStaus(BYTE *);
int Check_D_DataBlank(u8 *);
int Check_D_FailBlock(u8 *);
int Check_D_DataStatus(u8 *);
int Load_D_LogBlockAddr(u8 *);
void Clr_D_RedundantData(u8 *);
void Set_D_LogBlockAddr(u8 *);
void Set_D_FailBlock(u8 *);
void Set_D_DataStaus(u8 *);

/******************************************/
void Ssfdc_D_Reset(struct us_data *);
int Ssfdc_D_ReadCisSect(struct us_data *, BYTE *, BYTE *);
int Ssfdc_D_ReadCisSect(struct us_data *, u8 *, u8 *);
void Ssfdc_D_WriteRedtMode(void);
void Ssfdc_D_ReadID(BYTE *, BYTE);
int Ssfdc_D_ReadSect(struct us_data *, BYTE *, BYTE *);
int Ssfdc_D_ReadBlock(struct us_data *, WORD, BYTE *, BYTE *);
int Ssfdc_D_WriteSect(struct us_data *, BYTE *, BYTE *);
int Ssfdc_D_WriteBlock(struct us_data *, WORD, BYTE *, BYTE *);
int Ssfdc_D_CopyBlock(struct us_data *, WORD, BYTE *, BYTE *);
int Ssfdc_D_WriteSectForCopy(struct us_data *, BYTE *, BYTE *);
void Ssfdc_D_ReadID(u8 *, u8);
int Ssfdc_D_ReadSect(struct us_data *, u8 *, u8 *);
int Ssfdc_D_ReadBlock(struct us_data *, u16, u8 *, u8 *);
int Ssfdc_D_WriteSect(struct us_data *, u8 *, u8 *);
int Ssfdc_D_WriteBlock(struct us_data *, u16, u8 *, u8 *);
int Ssfdc_D_CopyBlock(struct us_data *, u16, u8 *, u8 *);
int Ssfdc_D_WriteSectForCopy(struct us_data *, u8 *, u8 *);
int Ssfdc_D_EraseBlock(struct us_data *);
int Ssfdc_D_ReadRedtData(struct us_data *, BYTE *);
int Ssfdc_D_WriteRedtData(struct us_data *, BYTE *);
int Ssfdc_D_ReadRedtData(struct us_data *, u8 *);
int Ssfdc_D_WriteRedtData(struct us_data *, u8 *);
int Ssfdc_D_CheckStatus(void);
int Set_D_SsfdcModel(BYTE);
int Set_D_SsfdcModel(u8);
void Cnt_D_Reset(void);
int Cnt_D_PowerOn(void);
void Cnt_D_PowerOff(void);
Expand All @@ -263,26 +263,26 @@ int Check_D_CntPower(void);
int Check_D_CardExist(void);
int Check_D_CardStsChg(void);
int Check_D_SsfdcWP(void);
int SM_ReadBlock(struct us_data *, BYTE *, BYTE *);
int SM_ReadBlock(struct us_data *, u8 *, u8 *);

int Ssfdc_D_ReadSect_DMA(struct us_data *, BYTE *, BYTE *);
int Ssfdc_D_ReadSect_PIO(struct us_data *, BYTE *, BYTE *);
int Ssfdc_D_WriteSect_DMA(struct us_data *, BYTE *, BYTE *);
int Ssfdc_D_WriteSect_PIO(struct us_data *, BYTE *, BYTE *);
int Ssfdc_D_ReadSect_DMA(struct us_data *, u8 *, u8 *);
int Ssfdc_D_ReadSect_PIO(struct us_data *, u8 *, u8 *);
int Ssfdc_D_WriteSect_DMA(struct us_data *, u8 *, u8 *);
int Ssfdc_D_WriteSect_PIO(struct us_data *, u8 *, u8 *);

/******************************************/
int Check_D_ReadError(BYTE *);
int Check_D_Correct(BYTE *, BYTE *);
int Check_D_CISdata(BYTE *, BYTE *);
void Set_D_RightECC(BYTE *);
int Check_D_ReadError(u8 *);
int Check_D_Correct(u8 *, u8 *);
int Check_D_CISdata(u8 *, u8 *);
void Set_D_RightECC(u8 *);

/*
* SMILECC.c
*/
void calculate_ecc(BYTE *, BYTE *, BYTE *, BYTE *, BYTE *);
BYTE correct_data(BYTE *, BYTE *, BYTE, BYTE, BYTE);
int _Correct_D_SwECC(BYTE *, BYTE *, BYTE *);
void _Calculate_D_SwECC(BYTE *, BYTE *);
void calculate_ecc(u8 *, u8 *, u8 *, u8 *, u8 *);
u8 correct_data(u8 *, u8 *, u8, u8, u8);
int _Correct_D_SwECC(u8 *, u8 *, u8 *);
void _Calculate_D_SwECC(u8 *, u8 *);

void SM_Init(void);

Expand Down
58 changes: 29 additions & 29 deletions drivers/staging/keucr/smilecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/* #include "EMCRIOS.h" */

/* CP0-CP5 code table */
static BYTE ecctable[256] = {
static u8 ecctable[256] = {
0x00, 0x55, 0x56, 0x03, 0x59, 0x0C, 0x0F, 0x5A, 0x5A, 0x0F, 0x0C, 0x59, 0x03,
0x56, 0x55, 0x00, 0x65, 0x30, 0x33, 0x66, 0x3C, 0x69, 0x6A, 0x3F, 0x3F, 0x6A,
0x69, 0x3C, 0x66, 0x33, 0x30, 0x65, 0x66, 0x33, 0x30, 0x65, 0x3F, 0x6A, 0x69,
Expand All @@ -36,7 +36,7 @@ static BYTE ecctable[256] = {
0x5A, 0x5A, 0x0F, 0x0C, 0x59, 0x03, 0x56, 0x55, 0x00
};

static void trans_result(BYTE, BYTE, BYTE *, BYTE *);
static void trans_result(u8, u8, u8 *, u8 *);

#define BIT7 0x80
#define BIT6 0x40
Expand All @@ -57,11 +57,11 @@ static void trans_result(BYTE, BYTE, BYTE *, BYTE *);
* *ecc1; * LP15,LP14,LP13,...
* *ecc2; * LP07,LP06,LP05,...
*/
static void trans_result(BYTE reg2, BYTE reg3, BYTE *ecc1, BYTE *ecc2)
static void trans_result(u8 reg2, u8 reg3, u8 *ecc1, u8 *ecc2)
{
BYTE a; /* Working for reg2,reg3 */
BYTE b; /* Working for ecc1,ecc2 */
BYTE i; /* For counting */
u8 a; /* Working for reg2,reg3 */
u8 b; /* Working for ecc1,ecc2 */
u8 i; /* For counting */

a = BIT7; b = BIT7; /* 80h=10000000b */
*ecc1 = *ecc2 = 0; /* Clear ecc1,ecc2 */
Expand Down Expand Up @@ -95,21 +95,21 @@ static void trans_result(BYTE reg2, BYTE reg3, BYTE *ecc1, BYTE *ecc2)
* *ecc2; * LP07,LP06,LP05,...
* *ecc3; * CP5,CP4,CP3,...,"1","1"
*/
void calculate_ecc(BYTE *table, BYTE *data, BYTE *ecc1, BYTE *ecc2, BYTE *ecc3)
void calculate_ecc(u8 *table, u8 *data, u8 *ecc1, u8 *ecc2, u8 *ecc3)
{
DWORD i; /* For counting */
BYTE a; /* Working for table */
BYTE reg1; /* D-all,CP5,CP4,CP3,... */
BYTE reg2; /* LP14,LP12,L10,... */
BYTE reg3; /* LP15,LP13,L11,... */
u32 i; /* For counting */
u8 a; /* Working for table */
u8 reg1; /* D-all,CP5,CP4,CP3,... */
u8 reg2; /* LP14,LP12,L10,... */
u8 reg3; /* LP15,LP13,L11,... */

reg1 = reg2 = reg3 = 0; /* Clear parameter */
for (i = 0; i < 256; ++i) {
a = table[data[i]]; /* Get CP0-CP5 code from table */
reg1 ^= (a&MASK_CPS); /* XOR with a */
if ((a&BIT6) != 0) { /* If D_all(all bit XOR) = 1 */
reg3 ^= (BYTE)i; /* XOR with counter */
reg2 ^= ~((BYTE)i); /* XOR with inv. of counter */
reg3 ^= (u8)i; /* XOR with counter */
reg2 ^= ~((u8)i); /* XOR with inv. of counter */
}
}

Expand All @@ -127,22 +127,22 @@ void calculate_ecc(BYTE *table, BYTE *data, BYTE *ecc1, BYTE *ecc2, BYTE *ecc3)
* ecc2; * LP07,LP06,LP05,...
* ecc3; * CP5,CP4,CP3,...,"1","1"
*/
BYTE correct_data(BYTE *data, BYTE *eccdata, BYTE ecc1, BYTE ecc2, BYTE ecc3)
u8 correct_data(u8 *data, u8 *eccdata, u8 ecc1, u8 ecc2, u8 ecc3)
{
DWORD l; /* Working to check d */
DWORD d; /* Result of comparison */
DWORD i; /* For counting */
BYTE d1, d2, d3; /* Result of comparison */
BYTE a; /* Working for add */
BYTE add; /* Byte address of cor. DATA */
BYTE b; /* Working for bit */
BYTE bit; /* Bit address of cor. DATA */
u32 l; /* Working to check d */
u32 d; /* Result of comparison */
u32 i; /* For counting */
u8 d1, d2, d3; /* Result of comparison */
u8 a; /* Working for add */
u8 add; /* Byte address of cor. DATA */
u8 b; /* Working for bit */
u8 bit; /* Bit address of cor. DATA */

d1 = ecc1^eccdata[1]; d2 = ecc2^eccdata[0]; /* Compare LP's */
d3 = ecc3^eccdata[2]; /* Compare CP's */
d = ((DWORD)d1<<16) /* Result of comparison */
+((DWORD)d2<<8)
+(DWORD)d3;
d = ((u32)d1<<16) /* Result of comparison */
+((u32)d2<<8)
+(u32)d3;

if (d == 0)
return 0; /* If No error, return */
Expand Down Expand Up @@ -188,9 +188,9 @@ BYTE correct_data(BYTE *data, BYTE *eccdata, BYTE ecc1, BYTE ecc2, BYTE ecc3)
return 3; /* Uncorrectable error */
}

int _Correct_D_SwECC(BYTE *buf, BYTE *redundant_ecc, BYTE *calculate_ecc)
int _Correct_D_SwECC(u8 *buf, u8 *redundant_ecc, u8 *calculate_ecc)
{
DWORD err;
u32 err;

err = correct_data(buf, redundant_ecc, *(calculate_ecc + 1),
*(calculate_ecc), *(calculate_ecc + 2));
Expand All @@ -203,7 +203,7 @@ int _Correct_D_SwECC(BYTE *buf, BYTE *redundant_ecc, BYTE *calculate_ecc)
return -1;
}

void _Calculate_D_SwECC(BYTE *buf, BYTE *ecc)
void _Calculate_D_SwECC(u8 *buf, u8 *ecc)
{
calculate_ecc(ecctable, buf, ecc+1, ecc+0, ecc+2);
}
Expand Down
Loading

0 comments on commit 432f857

Please sign in to comment.