CC2420: Eliminated duplicated code in cc2420_read
This commit is contained in:
parent
e3eb924f13
commit
e977da8fe2
@ -775,26 +775,12 @@ cc2420_read(void *buf, unsigned short bufsize)
|
|||||||
|
|
||||||
if(len > CC2420_MAX_PACKET_LEN) {
|
if(len > CC2420_MAX_PACKET_LEN) {
|
||||||
/* Oops, we must be out of sync. */
|
/* Oops, we must be out of sync. */
|
||||||
flushrx();
|
|
||||||
RIMESTATS_ADD(badsynch);
|
RIMESTATS_ADD(badsynch);
|
||||||
RELEASE_LOCK();
|
} else if(len <= FOOTER_LEN) {
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(len <= FOOTER_LEN) {
|
|
||||||
flushrx();
|
|
||||||
RIMESTATS_ADD(tooshort);
|
RIMESTATS_ADD(tooshort);
|
||||||
RELEASE_LOCK();
|
} else if(len - FOOTER_LEN > bufsize) {
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(len - FOOTER_LEN > bufsize) {
|
|
||||||
flushrx();
|
|
||||||
RIMESTATS_ADD(toolong);
|
RIMESTATS_ADD(toolong);
|
||||||
RELEASE_LOCK();
|
} else {
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
getrxdata(buf, len - FOOTER_LEN);
|
getrxdata(buf, len - FOOTER_LEN);
|
||||||
getrxdata(footer, FOOTER_LEN);
|
getrxdata(footer, FOOTER_LEN);
|
||||||
|
|
||||||
@ -824,12 +810,12 @@ cc2420_read(void *buf, unsigned short bufsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
RELEASE_LOCK();
|
RELEASE_LOCK();
|
||||||
|
return len - FOOTER_LEN;
|
||||||
if(len < FOOTER_LEN) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return len - FOOTER_LEN;
|
flushrx();
|
||||||
|
RELEASE_LOCK();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user