Skip to content

Commit 6e6208b

Browse files
Alexander Wachteralexanderwachter
authored andcommitted
drivers: CAN: Change u32_t error_flags to int error_numbers
The error_flags parameter of the can_tx_callback_t is a u32_t but gets negative CAN_TX error codes. This commit changes the error_flags to int error_numbers. Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
1 parent 629f369 commit 6e6208b

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

drivers/can/can_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(can_driver);
2424

2525
#define WORK_BUF_FULL 0xFFFF
2626

27-
void can_common_isr_callback_handler(u32_t err, void *cb_arg)
27+
void can_common_isr_callback_handler(int err, void *cb_arg)
2828
{
2929
struct can_send_wait *send_wait = (struct can_send_wait *) cb_arg;
3030

drivers/can/socket_can_generic.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ static inline void socket_can_iface_init(struct net_if *iface)
4444
LOG_DBG("Init CAN interface %p dev %p", iface, dev);
4545
}
4646

47-
static inline void tx_irq_callback(u32_t error_flags, void *arg)
47+
static inline void tx_irq_callback(int error_number, void *arg)
4848
{
4949
char *caller_str = (char *)arg;
50-
if (error_flags) {
50+
if (error_number) {
5151
LOG_DBG("TX error from %s! error-code: %d",
52-
caller_str, error_flags);
52+
caller_str, error_number);
5353
}
5454
}
5555

include/drivers/can.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ struct can_bus_err_cnt {
257257
* @param error_flags status of the performed send operation
258258
* @param arg argument that was passed when the message was sent
259259
*/
260-
typedef void (*can_tx_callback_t)(u32_t error_flags, void *arg);
260+
typedef void (*can_tx_callback_t)(int error_number, void *arg);
261261

262262
/**
263263
* @typedef can_rx_callback_t

samples/drivers/CAN/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ struct can_bus_err_cnt current_err_cnt;
3636

3737
CAN_DEFINE_MSGQ(counter_msgq, 2);
3838

39-
void tx_irq_callback(u32_t error_flags, void *arg)
39+
void tx_irq_callback(int error_number, void *arg)
4040
{
4141
char *sender = (char *)arg;
4242

43-
if (error_flags) {
43+
if (error_number) {
4444
printk("Callback! error-code: %d\nSender: %s\n",
45-
error_flags, sender);
45+
error_number, sender);
4646
}
4747
}
4848

subsys/net/l2/canbus/6locan.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ static void canbus_set_frame_addr_pkt(struct zcan_frame *frame,
425425
canbus_set_frame_addr(frame, dest_addr, &src_addr, mcast);
426426
}
427427

428-
static void canbus_fc_send_cb(u32_t err_flags, void *arg)
428+
static void canbus_fc_send_cb(int err_number, void *arg)
429429
{
430-
if (err_flags) {
431-
NET_ERR("Sending FC frame failed: %d", err_flags);
430+
if (err_number) {
431+
NET_ERR("Sending FC frame failed: %d", err_number);
432432
}
433433
}
434434

@@ -684,7 +684,7 @@ static enum net_verdict canbus_process_sf(struct net_pkt *pkt)
684684
return canbus_finish_pkt(pkt);
685685
}
686686

687-
static void canbus_tx_frame_isr(u32_t err_flags, void *arg)
687+
static void canbus_tx_frame_isr(int err_number, void *arg)
688688
{
689689
struct net_pkt *pkt = (struct net_pkt *)arg;
690690
struct canbus_isotp_tx_ctx *ctx = pkt->canbus_tx_ctx;
@@ -1528,14 +1528,14 @@ static inline int canbus_send_dad_request(struct device *net_can_dev,
15281528
return 0;
15291529
}
15301530

1531-
static void canbus_send_dad_resp_cb(u32_t err_flags, void *cb_arg)
1531+
static void canbus_send_dad_resp_cb(int err_number, void *cb_arg)
15321532
{
15331533
static u8_t fail_cnt;
15341534
struct k_work *work = (struct k_work *)cb_arg;
15351535

1536-
if (err_flags) {
1537-
NET_ERR("Failed to send dad response [%u]", err_flags);
1538-
if (err_flags != CAN_TX_BUS_OFF &&
1536+
if (err_number) {
1537+
NET_ERR("Failed to send dad response [%u]", err_number);
1538+
if (err_number != CAN_TX_BUS_OFF &&
15391539
fail_cnt < NET_CAN_DAD_SEND_RETRY) {
15401540
k_work_submit_to_queue(&net_canbus_workq, work);
15411541
}

tests/drivers/can/api/src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static inline void check_msg(struct zcan_frame *msg1, struct zcan_frame *msg2,
162162
zassert_equal(cmp_res, 0, "Received data differ");
163163
}
164164

165-
static void tx_timeout_isr(u32_t error_flags, void *arg)
165+
static void tx_timeout_isr(int error_number, void *arg)
166166
{
167167
int expected_err = (int)arg;
168168

@@ -173,7 +173,7 @@ static void tx_timeout_isr(u32_t error_flags, void *arg)
173173
expected_err, error_number);
174174
}
175175

176-
static void tx_std_isr(u32_t error_flags, void *arg)
176+
static void tx_std_isr(int error_number, void *arg)
177177
{
178178
struct zcan_frame *msg = (struct zcan_frame *)arg;
179179

@@ -182,7 +182,7 @@ static void tx_std_isr(u32_t error_flags, void *arg)
182182
zassert_equal(msg->std_id, TEST_CAN_STD_ID, "Arg does not match");
183183
}
184184

185-
static void tx_std_masked_isr(u32_t error_flags, void *arg)
185+
static void tx_std_masked_isr(int error_number, void *arg)
186186
{
187187
struct zcan_frame *msg = (struct zcan_frame *)arg;
188188

@@ -191,7 +191,7 @@ static void tx_std_masked_isr(u32_t error_flags, void *arg)
191191
zassert_equal(msg->std_id, TEST_CAN_STD_MASK_ID, "Arg does not match");
192192
}
193193

194-
static void tx_ext_isr(u32_t error_flags, void *arg)
194+
static void tx_ext_isr(int error_number, void *arg)
195195
{
196196
struct zcan_frame *msg = (struct zcan_frame *)arg;
197197

@@ -200,7 +200,7 @@ static void tx_ext_isr(u32_t error_flags, void *arg)
200200
zassert_equal(msg->ext_id, TEST_CAN_EXT_ID, "Arg does not match");
201201
}
202202

203-
static void tx_ext_masked_isr(u32_t error_flags, void *arg)
203+
static void tx_ext_masked_isr(int error_number, void *arg)
204204
{
205205
struct zcan_frame *msg = (struct zcan_frame *)arg;
206206

0 commit comments

Comments
 (0)