aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2023-04-14 14:48:40 -0400
committerKevin O'Connor <kevin@koconnor.net>2023-04-24 11:31:06 -0400
commit3377f29bc54938ab2820ff6b5212ce525e12b511 (patch)
tree6a4b42a5152ad0abcce0c22dee8e9a05c1dda0fc /src
parentf10c60eea767e04f3eda524e66b410127a5af34a (diff)
downloadkutter-3377f29bc54938ab2820ff6b5212ce525e12b511.tar.gz
kutter-3377f29bc54938ab2820ff6b5212ce525e12b511.tar.xz
kutter-3377f29bc54938ab2820ff6b5212ce525e12b511.zip
usb_canbus: Minor code reformatting of drain_hw_queue()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/generic/usb_canbus.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/generic/usb_canbus.c b/src/generic/usb_canbus.c
index b1023627..602acc70 100644
--- a/src/generic/usb_canbus.c
+++ b/src/generic/usb_canbus.c
@@ -169,18 +169,18 @@ send_frame(struct canbus_msg *msg)
static int
drain_hw_queue(void)
{
+ uint32_t pull_pos = UsbCan.pull_pos;
for (;;) {
uint32_t push_pos = readl(&UsbCan.push_pos);
- uint32_t pull_pos = UsbCan.pull_pos;
- if (push_pos != pull_pos) {
- uint32_t pos = pull_pos % ARRAY_SIZE(UsbCan.queue);
- int ret = send_frame(&UsbCan.queue[pos]);
- if (ret < 0)
- return -1;
- UsbCan.pull_pos = pull_pos + 1;
- continue;
- }
- return 0;
+ if (push_pos == pull_pos)
+ // No more data to send
+ return 0;
+ uint32_t pos = pull_pos % ARRAY_SIZE(UsbCan.queue);
+ int ret = send_frame(&UsbCan.queue[pos]);
+ if (ret < 0)
+ // USB is busy - retry later
+ return -1;
+ UsbCan.pull_pos = pull_pos = pull_pos + 1;
}
}