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