Skip to content

Commit

Permalink
wip: can: use send_defer
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed May 15, 2024
1 parent 8ce701d commit 0ca10af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
interrupt-parent = <&gpio1>;
interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
flow-ctrl-gpios = <&gpio1 14 GPIO_ACTIVE_LOW>;
spi-max-frequency = <10000000>;
spi-max-frequency = <16000000>;
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion recipes-kernel/kernel-modules/x8h7/x8h7_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static void x8h7_can_tx_work_handler(struct work_struct *ws)

priv->tx_len = priv->tx_frame.field.len;

x8h7_pkt_send_sync(priv->periph,
x8h7_pkt_send_defer(priv->periph,
X8H7_CAN_OC_SEND,
X8H7_CAN_HEADER_SIZE + priv->tx_frame.field.len, /* Send 4-Byte ID, 1-Byte Length and the required number of data bytes. */
priv->tx_frame.buf);
Expand Down
10 changes: 7 additions & 3 deletions recipes-kernel/kernel-modules/x8h7/x8h7_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "x8h7.h"

#define DRIVER_NAME "x8h7"
#define X8H7_BUF_SIZE (64*1024)
#define X8H7_BUF_SIZE (512)
#define FIXED_PACKET_LEN 512

//#define DEBUG
Expand Down Expand Up @@ -200,7 +200,7 @@ int x8h7_pkt_enq(uint8_t peripheral, uint8_t opcode, uint16_t size, void *data)
return 0;
}

return -ENOMEM;
return -EAGAIN;
}

static int x8h7_pkt_send(void);
Expand Down Expand Up @@ -240,7 +240,11 @@ int x8h7_pkt_send_defer(uint8_t peripheral, uint8_t opcode, uint16_t size, void
mutex_lock(&spidev->lock);
ret = x8h7_pkt_enq(peripheral, opcode, size, data);
if (ret < 0) {
printk("x8h7_pkt_enq failed with %d", ret);
printk("trying packet send since enq failed %d", ret);
ret = x8h7_pkt_send();
if (ret < 0) {
printk("x8h7_pkt_enq failed with %d", ret);
}
mutex_unlock(&spidev->lock);
return ret;
}
Expand Down

0 comments on commit 0ca10af

Please sign in to comment.