CC2420: Eliminated duplicated code in cc2420_read

This commit is contained in:
kkrentz 2013-06-05 07:50:21 -07:00
parent e3eb924f13
commit e977da8fe2

View file

@ -775,26 +775,12 @@ cc2420_read(void *buf, unsigned short bufsize)
if(len > CC2420_MAX_PACKET_LEN) {
/* Oops, we must be out of sync. */
flushrx();
RIMESTATS_ADD(badsynch);
RELEASE_LOCK();
return 0;
}
if(len <= FOOTER_LEN) {
flushrx();
} else if(len <= FOOTER_LEN) {
RIMESTATS_ADD(tooshort);
RELEASE_LOCK();
return 0;
}
if(len - FOOTER_LEN > bufsize) {
flushrx();
} else if(len - FOOTER_LEN > bufsize) {
RIMESTATS_ADD(toolong);
RELEASE_LOCK();
return 0;
}
} else {
getrxdata(buf, len - FOOTER_LEN);
getrxdata(footer, FOOTER_LEN);
@ -824,12 +810,12 @@ cc2420_read(void *buf, unsigned short bufsize)
}
RELEASE_LOCK();
if(len < FOOTER_LEN) {
return 0;
return len - FOOTER_LEN;
}
return len - FOOTER_LEN;
flushrx();
RELEASE_LOCK();
return 0;
}
/*---------------------------------------------------------------------------*/
void