Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <schluessler@krause.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Timo Schlüßler and committed by
Marc Kleine-Budde
877a9021 50ec8812

+13 -2
+13 -2
drivers/net/can/spi/mcp251x.c
··· 320 320 mcp251x_spi_trans(spi, 3); 321 321 } 322 322 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 + 323 335 static void mcp251x_write_bits(struct spi_device *spi, u8 reg, 324 336 u8 mask, u8 val) 325 337 { ··· 657 645 mutex_lock(&priv->mcp_lock); 658 646 659 647 /* Disable and clear pending interrupts */ 660 - mcp251x_write_reg(spi, CANINTE, 0x00); 661 - mcp251x_write_reg(spi, CANINTF, 0x00); 648 + mcp251x_write_2regs(spi, CANINTE, 0x00, 0x00); 662 649 663 650 mcp251x_write_reg(spi, TXBCTRL(0), 0); 664 651 mcp251x_clean(net);