Skip to content

Commit 5b20486

Browse files
committed
usb_canbus: Rename UsbCan.queue to UsbCan.canhw_queue
Rename the internal variable names. This is in preparation for support of a USB message queue. Signed-off-by: Kevin O'Connor <[email protected]>
1 parent 472fd32 commit 5b20486

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/generic/usb_canbus.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ static struct usbcan_data {
116116
uint32_t assigned_id;
117117

118118
// Data from physical canbus interface
119-
uint32_t pull_pos, push_pos;
120-
struct canbus_msg queue[32];
119+
uint32_t canhw_pull_pos, canhw_push_pos;
120+
struct canbus_msg canhw_queue[32];
121121
} UsbCan;
122122

123123
enum {
@@ -139,16 +139,16 @@ void
139139
canbus_process_data(struct canbus_msg *msg)
140140
{
141141
// Add to admin command queue
142-
uint32_t pushp = UsbCan.push_pos;
143-
if (pushp - UsbCan.pull_pos >= ARRAY_SIZE(UsbCan.queue))
142+
uint32_t pushp = UsbCan.canhw_push_pos;
143+
if (pushp - UsbCan.canhw_pull_pos >= ARRAY_SIZE(UsbCan.canhw_queue))
144144
// No space - drop message
145145
return;
146146
if (UsbCan.assigned_id && (msg->id & ~1) == UsbCan.assigned_id)
147147
// Id reserved for local
148148
return;
149-
uint32_t pos = pushp % ARRAY_SIZE(UsbCan.queue);
150-
memcpy(&UsbCan.queue[pos], msg, sizeof(*msg));
151-
UsbCan.push_pos = pushp + 1;
149+
uint32_t pos = pushp % ARRAY_SIZE(UsbCan.canhw_queue);
150+
memcpy(&UsbCan.canhw_queue[pos], msg, sizeof(*msg));
151+
UsbCan.canhw_push_pos = pushp + 1;
152152
usb_notify_bulk_out();
153153
}
154154

@@ -167,24 +167,24 @@ send_frame(struct canbus_msg *msg)
167167

168168
// Send any pending hw frames to host
169169
static void
170-
drain_hw_queue(void)
170+
drain_canhw_queue(void)
171171
{
172-
uint32_t pull_pos = UsbCan.pull_pos;
172+
uint32_t pull_pos = UsbCan.canhw_pull_pos;
173173
for (;;) {
174-
uint32_t push_pos = readl(&UsbCan.push_pos);
174+
uint32_t push_pos = readl(&UsbCan.canhw_push_pos);
175175
if (push_pos == pull_pos) {
176176
// No more data to send
177177
UsbCan.usb_send_busy = 0;
178178
return;
179179
}
180-
uint32_t pos = pull_pos % ARRAY_SIZE(UsbCan.queue);
181-
int ret = send_frame(&UsbCan.queue[pos]);
180+
uint32_t pos = pull_pos % ARRAY_SIZE(UsbCan.canhw_queue);
181+
int ret = send_frame(&UsbCan.canhw_queue[pos]);
182182
if (ret < 0) {
183183
// USB is busy - retry later
184184
UsbCan.usb_send_busy = 1;
185185
return;
186186
}
187-
UsbCan.pull_pos = pull_pos = pull_pos + 1;
187+
UsbCan.canhw_pull_pos = pull_pos = pull_pos + 1;
188188
}
189189
}
190190

@@ -195,7 +195,7 @@ usbcan_task(void)
195195
return;
196196

197197
// Send any pending hw frames to host
198-
drain_hw_queue();
198+
drain_canhw_queue();
199199

200200
for (;;) {
201201
// See if previous host frame needs to be transmitted

0 commit comments

Comments
 (0)