mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-07 11:28:32 +00:00
can: m_can: Count TXE FIFO getidx in the driver
The getindex simply increases by one for every iteration. There is no need to get the current getidx every time from a register. Instead we can just count and wrap if necessary. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-5-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
fac52bf786
commit
d4535b90a7
1 changed files with 2 additions and 3 deletions
|
@ -1030,15 +1030,13 @@ static int m_can_echo_tx_event(struct net_device *dev)
|
||||||
|
|
||||||
/* Get Tx Event fifo element count */
|
/* Get Tx Event fifo element count */
|
||||||
txe_count = FIELD_GET(TXEFS_EFFL_MASK, m_can_txefs);
|
txe_count = FIELD_GET(TXEFS_EFFL_MASK, m_can_txefs);
|
||||||
|
fgi = FIELD_GET(TXEFS_EFGI_MASK, m_can_txefs);
|
||||||
|
|
||||||
/* Get and process all sent elements */
|
/* Get and process all sent elements */
|
||||||
for (i = 0; i < txe_count; i++) {
|
for (i = 0; i < txe_count; i++) {
|
||||||
u32 txe, timestamp = 0;
|
u32 txe, timestamp = 0;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* retrieve get index */
|
|
||||||
fgi = FIELD_GET(TXEFS_EFGI_MASK, m_can_read(cdev, M_CAN_TXEFS));
|
|
||||||
|
|
||||||
/* get message marker, timestamp */
|
/* get message marker, timestamp */
|
||||||
err = m_can_txe_fifo_read(cdev, fgi, 4, &txe);
|
err = m_can_txe_fifo_read(cdev, fgi, 4, &txe);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -1052,6 +1050,7 @@ static int m_can_echo_tx_event(struct net_device *dev)
|
||||||
/* ack txe element */
|
/* ack txe element */
|
||||||
m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK,
|
m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK,
|
||||||
fgi));
|
fgi));
|
||||||
|
fgi = (++fgi >= cdev->mcfg[MRAM_TXE].num ? 0 : fgi);
|
||||||
|
|
||||||
/* update stats */
|
/* update stats */
|
||||||
m_can_tx_update_stats(cdev, msg_mark, timestamp);
|
m_can_tx_update_stats(cdev, msg_mark, timestamp);
|
||||||
|
|
Loading…
Reference in a new issue