aboutsummaryrefslogtreecommitdiffstats
path: root/src/generic/canserial.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2023-04-15 12:21:46 -0400
committerKevin O'Connor <kevin@koconnor.net>2023-04-24 11:31:06 -0400
commit28f11244c3a91c18f0f4f3c3a02b5f20b0ff5547 (patch)
tree38820808b6873e85c664b4c4aed047c23449a060 /src/generic/canserial.c
parent3377f29bc54938ab2820ff6b5212ce525e12b511 (diff)
downloadkutter-28f11244c3a91c18f0f4f3c3a02b5f20b0ff5547.tar.gz
kutter-28f11244c3a91c18f0f4f3c3a02b5f20b0ff5547.tar.xz
kutter-28f11244c3a91c18f0f4f3c3a02b5f20b0ff5547.zip
usb_canbus: No need to check if canserial can accept a packet
The canserial code already advertizes a receive window, so the host should never flood the canserial code. Remove the extra scheduling checks to simplify the usb_canbus code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/generic/canserial.c')
-rw-r--r--src/generic/canserial.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/generic/canserial.c b/src/generic/canserial.c
index 0607e489..d56235f5 100644
--- a/src/generic/canserial.c
+++ b/src/generic/canserial.c
@@ -224,7 +224,7 @@ canserial_notify_rx(void)
DECL_CONSTANT("RECEIVE_WINDOW", ARRAY_SIZE(CanData.receive_buf));
// Handle incoming data (called from IRQ handler)
-int
+void
canserial_process_data(struct canbus_msg *msg)
{
uint32_t id = msg->id;
@@ -233,7 +233,7 @@ canserial_process_data(struct canbus_msg *msg)
int rpos = CanData.receive_pos;
uint32_t len = CANMSG_DATA_LEN(msg);
if (len > sizeof(CanData.receive_buf) - rpos)
- return -1;
+ return;
memcpy(&CanData.receive_buf[rpos], msg->data, len);
CanData.receive_pos = rpos + len;
canserial_notify_rx();
@@ -243,13 +243,12 @@ canserial_process_data(struct canbus_msg *msg)
uint32_t pushp = CanData.admin_push_pos;
if (pushp >= CanData.admin_pull_pos + ARRAY_SIZE(CanData.admin_queue))
// No space - drop message
- return -1;
+ return;
uint32_t pos = pushp % ARRAY_SIZE(CanData.admin_queue);
memcpy(&CanData.admin_queue[pos], msg, sizeof(*msg));
CanData.admin_push_pos = pushp + 1;
canserial_notify_rx();
}
- return 0;
}
// Remove from the receive buffer the given number of bytes