xpp: echo_loader: whitespace cleanup

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.astersk.org/svn/dahdi/tools/trunk@10500 17933a7a-c749-41c5-a318-cba88f637d49
This commit is contained in:
Oron Peled 2012-03-15 20:42:56 +00:00 committed by Tzafrir Cohen
parent bccb264100
commit 273230b044

View File

@ -141,7 +141,7 @@ static int usb_buffer_flush(struct astribank_device *astribank, struct usb_buffe
if (ub->curr == 0)
return 0;
ret = xusb_send(astribank->xusb, ub->data, ub->curr, TIMEOUT);
if(ret < 0) {
if (ret < 0) {
AB_ERR(astribank, "xusb_send failed: %d\n", ret);
return ret;
}
@ -208,15 +208,18 @@ static int usb_buffer_send(struct astribank_device *astribank, struct usb_buffer
if (ret < 0)
return ret;
ret = xusb_recv(astribank->xusb, buf, PACKET_SIZE, TIMEOUT);
if(ret <= 0) {
if (ret <= 0) {
AB_ERR(astribank, "No USB packs to read: %s\n", strerror(-ret));
return -EINVAL;
}
DBG("%s: %d bytes recv\n", __func__, ret);
phead = (struct xpp_packet_header *)buf;
if(phead->header.op != SPI_RCV_XOP && phead->header.op != TST_RCV_XOP) {
AB_ERR(astribank, "Got unexpected reply OP=0x%02X\n", phead->header.op);
dump_packet(LOG_ERR, DBG_MASK, "hexline[ERR]", buf, ret);
if (phead->header.op != SPI_RCV_XOP &&
phead->header.op != TST_RCV_XOP) {
AB_ERR(astribank, "Got unexpected reply OP=0x%02X\n",
phead->header.op);
dump_packet(LOG_ERR, DBG_MASK, "hexline[ERR]",
buf, ret);
return -EINVAL;
}
dump_packet(LOG_DEBUG, DBG_MASK, "dump:echoline[R]", (char *)phead, phead->header.len);
@ -240,14 +243,16 @@ int spi_send(struct astribank_device *astribank, uint16_t addr, uint16_t data, i
char buf[PACKET_SIZE];
struct xpp_packet_header *phead = (struct xpp_packet_header *)buf;
int pack_len;
int spi_flags;
assert(astribank != NULL);
spi_flags = 0x30 | (recv_answer ? 0x40 : 0x00) | (ver ? 0x01 : 0x00);
pack_len = sizeof(phead->header) + sizeof(phead->alt.spi_pack);
phead->header.len = pack_len;
phead->header.op = SPI_SND_XOP;
phead->header.unit = 0x40; /* EC has always this unit num */
phead->alt.spi_pack.header = 0x05;
phead->alt.spi_pack.flags = 0x30 | (recv_answer ? 0x40: 0x00) | (ver ? 0x01: 0x00);
phead->alt.spi_pack.flags = spi_flags;
phead->alt.spi_pack.addr_l = (addr >> 0) & 0xFF;
phead->alt.spi_pack.addr_h = (addr >> 8) & 0xFF;
phead->alt.spi_pack.data_l = (data >> 0) & 0xFF;
@ -257,7 +262,7 @@ int spi_send(struct astribank_device *astribank, uint16_t addr, uint16_t data, i
ret = usb_buffer_send(astribank, &usb_buffer, buf, pack_len, TIMEOUT, recv_answer);
if(ret < 0) {
if (ret < 0) {
AB_ERR(astribank, "usb_buffer_send failed: %d\n", ret);
return ret;
}
@ -277,14 +282,15 @@ int test_send(struct astribank_device *astribank)
phead->header.len = 6;
phead->header.op = 0x35;
phead->header.unit = 0x00;
phead->alt.tst_pack.tid = 0x28; // EC TestId
phead->alt.tst_pack.tsid = 0x00; // EC SubId
phead->alt.tst_pack.tid = 0x28; /* EC TestId */
phead->alt.tst_pack.tsid = 0x00; /* EC SubId */
dump_packet(LOG_DEBUG, DBG_MASK, "dump:echoline[W]", (char *)phead, pack_len);
dump_packet(LOG_DEBUG, DBG_MASK, "dump:echoline[W]",
(char *)phead, pack_len);
ret = usb_buffer_send(astribank, &usb_buffer, buf, pack_len, TIMEOUT, 1);
if(ret < 0) {
ret = usb_buffer_send(astribank,
&usb_buffer, buf, pack_len, TIMEOUT, 1);
if (ret < 0) {
AB_ERR(astribank, "usb_buffer_send failed: %d\n", ret);
return ret;
}
@ -349,31 +355,32 @@ failed:
int load_file(char *filename, unsigned char **ppBuf, UINT32 *pLen)
{
unsigned char * pbyFileData = NULL;
FILE* pFile;
unsigned char *pbyFileData = NULL;
FILE *pFile;
DBG("Loading %s file...\n", filename);
pFile = fopen( filename, "rb" );
pFile = fopen(filename, "rb");
if (pFile == NULL) {
ERR("fopen\n");
return -ENODEV;
}
fseek( pFile, 0L, SEEK_END );
*pLen = ftell( pFile );
fseek( pFile, 0L, SEEK_SET );
fseek(pFile, 0L, SEEK_END);
*pLen = ftell(pFile);
fseek(pFile, 0L, SEEK_SET);
pbyFileData = (unsigned char *)malloc(*pLen);
if (pbyFileData == NULL) {
fclose( pFile );
ERR("malloc\n" );
fclose(pFile);
ERR("malloc\n");
return -ENODEV;
} else {
DBG("allocated mem for pbyFileData\n");
}
fread(pbyFileData, 1, *pLen, pFile);
fclose(pFile);
DBG("Successful loading %s file into memory (size = %d, DUMP: first = %02X %02X, last = %02X %02X)\n",
DBG("Successful loading %s file into memory "
"(size = %d, DUMP: first = %02X %02X, last = %02X %02X)\n",
filename, *pLen,
pbyFileData[0], pbyFileData[1],
pbyFileData[(*pLen)-2], pbyFileData[(*pLen)-1]);
@ -454,11 +461,14 @@ UINT32 Oct6100UserDriverWriteSmearApi(tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParam
{
unsigned int addr;
unsigned int data;
unsigned int len = f_pSmearParams->ulWriteLength;
const struct echo_mod *echo_mod = (struct echo_mod *)f_pSmearParams->pProcessContext;
struct astribank_device *astribank = echo_mod->astribank;
unsigned int len;
const struct echo_mod *echo_mod;
struct astribank_device *astribank;
unsigned int i;
len = f_pSmearParams->ulWriteLength;
echo_mod = (struct echo_mod *)f_pSmearParams->pProcessContext;
astribank = echo_mod->astribank;
for (i = 0; i < len; i++) {
int ret;
@ -499,10 +509,12 @@ UINT32 Oct6100UserDriverWriteBurstApi(tPOCT6100_WRITE_BURST_PARAMS f_pBurstParam
UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams)
{
const unsigned int addr = f_pReadParams->ulReadAddress;
const struct echo_mod *echo_mod = (struct echo_mod *)f_pReadParams->pProcessContext;
struct astribank_device *astribank = echo_mod->astribank;
const struct echo_mod *echo_mod;
struct astribank_device *astribank;
int ret;
echo_mod = (struct echo_mod *)f_pReadParams->pProcessContext;
astribank = echo_mod->astribank;
ret = echo_recv_data(astribank, addr);
if (ret < 0) {
ERR("echo_recv_data failed (%d)\n", ret);
@ -515,11 +527,14 @@ UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams)
UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
{
unsigned int addr;
unsigned int len = f_pBurstParams->ulReadLength;
const struct echo_mod *echo_mod = (struct echo_mod *)f_pBurstParams->pProcessContext;
struct astribank_device *astribank = echo_mod->astribank;
unsigned int len;
const struct echo_mod *echo_mod;
struct astribank_device *astribank;
unsigned int i;
len = f_pBurstParams->ulReadLength;
echo_mod = (struct echo_mod *)f_pBurstParams->pProcessContext;
astribank = echo_mod->astribank;
for (i = 0;i < len; i++) {
unsigned int ret;
@ -536,7 +551,6 @@ UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
inline int get_ver(struct astribank_device *astribank)
{
return spi_send(astribank, 0, 0, 1, 1);
}
@ -585,7 +599,8 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
memset(&InstanceSize, 0, sizeof(tOCT6100_GET_INSTANCE_SIZE));
memset(&OpenChip, 0, sizeof(tOCT6100_CHIP_OPEN));
if (!(echo_mod = malloc(sizeof(struct echo_mod)))) {
echo_mod = malloc(sizeof(struct echo_mod));
if (!echo_mod) {
AB_ERR(astribank, "cannot allocate memory for echo_mod\n");
return cOCT6100_ERR_FATAL;
}
@ -595,9 +610,10 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
/* Fill the OCT6100 Chip Open configuration structure with default values */
ulResult = Oct6100ChipOpenDef( &OpenChip );
ulResult = Oct6100ChipOpenDef(&OpenChip);
if (ulResult != cOCT6100_ERR_OK) {
AB_ERR(astribank, "Oct6100ChipOpenDef failed: result=%X\n", ulResult);
AB_ERR(astribank, "Oct6100ChipOpenDef failed: result=%X\n",
ulResult);
return ulResult;
}
@ -640,9 +656,9 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
/* Load the image file */
ulResult = load_file( filename,
&pbyImageData,
&ulImageByteSize );
&ulImageByteSize);
if ( ulResult != 0 ) {
if (ulResult != 0) {
AB_ERR(astribank, "Failed load_file %s (%08X)\n", filename, ulResult);
return ulResult;
}
@ -655,14 +671,17 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
OpenChip.pbyImageFile = pbyImageData;
OpenChip.ulImageSize = ulImageByteSize;
/* Inserting default values into tOCT6100_GET_INSTANCE_SIZE structure parameters. */
Oct6100GetInstanceSizeDef ( &InstanceSize );
/*
* Inserting default values into tOCT6100_GET_INSTANCE_SIZE
* structure parameters.
*/
Oct6100GetInstanceSizeDef(&InstanceSize);
/* Get the size of the OCT6100 instance structure. */
ulResult = Oct6100GetInstanceSize(&OpenChip, &InstanceSize );
if (ulResult != cOCT6100_ERR_OK)
{
AB_ERR(astribank, "Oct6100GetInstanceSize failed (%08X)\n", ulResult);
ulResult = Oct6100GetInstanceSize(&OpenChip, &InstanceSize);
if (ulResult != cOCT6100_ERR_OK) {
AB_ERR(astribank, "Oct6100GetInstanceSize failed (%08X)\n",
ulResult);
return ulResult;
}
@ -671,20 +690,22 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
echo_mod->astribank = astribank;
if (!pApiInstance) {
AB_ERR(astribank, "Out of memory (can't allocate %d bytes)!\n", InstanceSize.ulApiInstanceSize);
AB_ERR(astribank, "Out of memory (can't allocate %d bytes)!\n",
InstanceSize.ulApiInstanceSize);
return cOCT6100_ERR_FATAL;
}
/* Perform actual open of chip */
ulResult = Oct6100ChipOpen(pApiInstance, &OpenChip);
if (ulResult != cOCT6100_ERR_OK) {
AB_ERR(astribank, "Oct6100ChipOpen failed: result=%X\n", ulResult);
AB_ERR(astribank, "Oct6100ChipOpen failed: result=%X\n",
ulResult);
return ulResult;
}
DBG("%s: OCT6100 is open\n", __func__);
/* Free the image file data */
free( pbyImageData );
free(pbyImageData);
/**************************************************************************/
/**************************************************************************/
@ -692,10 +713,10 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
/**************************************************************************/
/**************************************************************************/
for( nChan = 0; nChan < ECHO_MAX_CHANS; nChan++ ) {
for (nChan = 0; nChan < ECHO_MAX_CHANS; nChan++) {
nSlot = nChan;
/* open a channel.*/
Oct6100ChannelOpenDef( &ChannelOpen );
Oct6100ChannelOpenDef(&ChannelOpen);
/* Assign the handle memory.*/
ChannelOpen.pulChannelHndl = &ulChanHndl;
@ -734,7 +755,7 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
cOCT6100_COMFORT_NOISE_FAST_LATCH
*/
ulResult = Oct6100ChannelOpen( pApiInstance,
&ChannelOpen );
&ChannelOpen);
if (ulResult != cOCT6100_ERR_OK) {
AB_ERR(astribank, "Found error on chan %d\n", nChan);
return ulResult;
@ -747,10 +768,10 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
/**************************************************************************/
/**************************************************************************/
for( nChan = 8; nChan < 32; nChan++ ) {
for (nChan = 8; nChan < 32; nChan++) {
nSlot = (nChan >> 3) * 32 + (nChan & 0x07);
/* open a channel.*/
Oct6100ChannelOpenDef( &ChannelOpen );
Oct6100ChannelOpenDef(&ChannelOpen);
/* Assign the handle memory.*/
ChannelOpen.pulChannelHndl = &ulChanHndl;
@ -783,7 +804,7 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
cOCT6100_COMFORT_NOISE_FAST_LATCH
*/
ulResult = Oct6100ChannelOpen( pApiInstance,
&ChannelOpen );
&ChannelOpen);
if (ulResult != cOCT6100_ERR_OK) {
AB_ERR(astribank, "Found error on chan %d\n", nChan);
return ulResult;