Skip to content

Commit 877a902

Browse files
Timo Schlüßlermarckleinebudde
authored andcommitted
can: mcp251x: add mcp251x_write_2regs() and make use of it
This patch introduces the function mcp251x_write_2regs() to write two registers with one SPI transfer and converts the disabling of pending interrupts in mcp251x_stop() to it. Signed-off-by: Timo Schlüßler <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 50ec881 commit 877a902

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/net/can/spi/mcp251x.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,18 @@ static void mcp251x_write_reg(struct spi_device *spi, u8 reg, u8 val)
320320
mcp251x_spi_trans(spi, 3);
321321
}
322322

323+
static void mcp251x_write_2regs(struct spi_device *spi, u8 reg, u8 v1, u8 v2)
324+
{
325+
struct mcp251x_priv *priv = spi_get_drvdata(spi);
326+
327+
priv->spi_tx_buf[0] = INSTRUCTION_WRITE;
328+
priv->spi_tx_buf[1] = reg;
329+
priv->spi_tx_buf[2] = v1;
330+
priv->spi_tx_buf[3] = v2;
331+
332+
mcp251x_spi_trans(spi, 4);
333+
}
334+
323335
static void mcp251x_write_bits(struct spi_device *spi, u8 reg,
324336
u8 mask, u8 val)
325337
{
@@ -645,8 +657,7 @@ static int mcp251x_stop(struct net_device *net)
645657
mutex_lock(&priv->mcp_lock);
646658

647659
/* Disable and clear pending interrupts */
648-
mcp251x_write_reg(spi, CANINTE, 0x00);
649-
mcp251x_write_reg(spi, CANINTF, 0x00);
660+
mcp251x_write_2regs(spi, CANINTE, 0x00, 0x00);
650661

651662
mcp251x_write_reg(spi, TXBCTRL(0), 0);
652663
mcp251x_clean(net);

0 commit comments

Comments
 (0)