csp_bridge: Extract csp_bridge_work
Refactor the inner loop to a new function csp_bridge_work().  This
allows us to
- call work function without loop
- Use work function without knowing arch specific csp_thread
The work function will return to the caller when it finish working on
a thing.
@@ -16,15 +16,12 @@ static void csp_bridge_set_interfaces(csp_iface_t * if_a, csp_iface_t * if_b) {
bif_b.iface = if_b;
}
-static CSP_DEFINE_TASK(csp_bridge) {
-
- /* Here there be bridging */
- while (1) {
+static void csp_bridge_work(void) {
/* Get next packet to route */
csp_qfifo_t input;
if (csp_qfifo_read(&input) != CSP_ERR_NONE) {
- continue;
+ return;
}
csp_packet_t * packet = input.packet;
@@ -55,6 +52,13 @@ static CSP_DEFINE_TASK(csp_bridge) {
}
}
+static CSP_DEFINE_TASK(csp_bridge) {
+
+ /* Here there be bridging */
+ while (1) {
+ csp_bridge_work();
+ }
+
return CSP_TASK_RETURN;
}
