Skip to content

Commit db72589

Browse files
can: m_can: m_can_fifo_{read,write}: don't read or write from/to FIFO if length is 0
In order to optimize FIFO access, especially on m_can cores attached to slow busses like SPI, in patch | e393817 ("can: m_can: Disable IRQs on FIFO bus errors") bulk read/write support has been added to the m_can_fifo_{read,write} functions. That change leads to the tcan driver to call regmap_bulk_{read,write}() with a length of 0 (for CAN frames with 0 data length). regmap treats this as an error: | tcan4x5x spi1.0 tcan4x5x0: FIFO write returned -22 This patch fixes the problem by not calling the cdev->ops->{read,write)_fifo() in case of a 0 length read/write. Fixes: e393817 ("can: m_can: Disable IRQs on FIFO bus errors") Link: https://lore.kernel.org/all/[email protected] Cc: [email protected] Cc: Matt Kline <[email protected]> Cc: Chandrasekar Ramakrishnan <[email protected]> Reported-by: Michael Anochin <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 17a3042 commit db72589

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/net/can/m_can/m_can.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ m_can_fifo_read(struct m_can_classdev *cdev,
336336
u32 addr_offset = cdev->mcfg[MRAM_RXF0].off + fgi * RXF0_ELEMENT_SIZE +
337337
offset;
338338

339+
if (val_count == 0)
340+
return 0;
341+
339342
return cdev->ops->read_fifo(cdev, addr_offset, val, val_count);
340343
}
341344

@@ -346,6 +349,9 @@ m_can_fifo_write(struct m_can_classdev *cdev,
346349
u32 addr_offset = cdev->mcfg[MRAM_TXB].off + fpi * TXB_ELEMENT_SIZE +
347350
offset;
348351

352+
if (val_count == 0)
353+
return 0;
354+
349355
return cdev->ops->write_fifo(cdev, addr_offset, val, val_count);
350356
}
351357

0 commit comments

Comments
 (0)