usb_canbus: Minor code reformatting of drain_hw_queue()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2023-04-14 14:48:40 -04:00
parent f10c60eea7
commit 3377f29bc5
1 changed files with 10 additions and 10 deletions

View File

@ -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;
}
}