Skip to content

Commit 10cd28a

Browse files
henrikbrixandersenfabiobaltieri
authored andcommitted
drivers: can: loopback: assume can_send() always provides callback
Given the recent change to the CAN controller can_send() API wrapper, assume that a callback is always provided at the driver level. Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent 4165186 commit 10cd28a

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

drivers/can/can_loopback.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ struct can_loopback_frame {
2222
struct can_frame frame;
2323
can_tx_callback_t cb;
2424
void *cb_arg;
25-
struct k_sem *tx_compl;
2625
};
2726

2827
struct can_loopback_filter {
@@ -82,12 +81,7 @@ static void tx_thread(void *arg1, void *arg2, void *arg3)
8281
}
8382

8483
k_mutex_unlock(&data->mtx);
85-
86-
if (!frame.cb) {
87-
k_sem_give(frame.tx_compl);
88-
} else {
89-
frame.cb(dev, 0, frame.cb_arg);
90-
}
84+
frame.cb(dev, 0, frame.cb_arg);
9185
}
9286
}
9387

@@ -99,9 +93,10 @@ static int can_loopback_send(const struct device *dev,
9993
struct can_loopback_data *data = dev->data;
10094
struct can_loopback_frame loopback_frame;
10195
uint8_t max_dlc = CAN_MAX_DLC;
102-
struct k_sem tx_sem;
10396
int ret;
10497

98+
__ASSERT_NO_MSG(callback != NULL);
99+
105100
LOG_DBG("Sending %d bytes on %s. Id: 0x%x, ID type: %s %s",
106101
frame->dlc, dev->name, frame->id,
107102
frame->id_type == CAN_STANDARD_IDENTIFIER ?
@@ -130,18 +125,9 @@ static int can_loopback_send(const struct device *dev,
130125
loopback_frame.frame = *frame;
131126
loopback_frame.cb = callback;
132127
loopback_frame.cb_arg = user_data;
133-
loopback_frame.tx_compl = &tx_sem;
134-
135-
if (!callback) {
136-
k_sem_init(&tx_sem, 0, 1);
137-
}
138128

139129
ret = k_msgq_put(&data->tx_msgq, &loopback_frame, timeout);
140130

141-
if (!callback) {
142-
k_sem_take(&tx_sem, K_FOREVER);
143-
}
144-
145131
return ret ? -EAGAIN : 0;
146132
}
147133

0 commit comments

Comments
 (0)