usb_canbus: Minor code reformatting of drain_hw_queue()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
f10c60eea7
commit
3377f29bc5
|
@ -169,18 +169,18 @@ send_frame(struct canbus_msg *msg)
|
||||||
static int
|
static int
|
||||||
drain_hw_queue(void)
|
drain_hw_queue(void)
|
||||||
{
|
{
|
||||||
|
uint32_t pull_pos = UsbCan.pull_pos;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
uint32_t push_pos = readl(&UsbCan.push_pos);
|
uint32_t push_pos = readl(&UsbCan.push_pos);
|
||||||
uint32_t pull_pos = UsbCan.pull_pos;
|
if (push_pos == pull_pos)
|
||||||
if (push_pos != pull_pos) {
|
// No more data to send
|
||||||
uint32_t pos = pull_pos % ARRAY_SIZE(UsbCan.queue);
|
return 0;
|
||||||
int ret = send_frame(&UsbCan.queue[pos]);
|
uint32_t pos = pull_pos % ARRAY_SIZE(UsbCan.queue);
|
||||||
if (ret < 0)
|
int ret = send_frame(&UsbCan.queue[pos]);
|
||||||
return -1;
|
if (ret < 0)
|
||||||
UsbCan.pull_pos = pull_pos + 1;
|
// USB is busy - retry later
|
||||||
continue;
|
return -1;
|
||||||
}
|
UsbCan.pull_pos = pull_pos = pull_pos + 1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue