Skip to contentSkip to conversation

can: mcp251xfd: use regmap_bulk_write for compatibility

PATCH In review Su Yanjun 2 participants 4 messages Jan 22, 2021

Subsystems (4)
lore
Share & tools
lore

Su Yanjun

author
#0 lore raw

PATCH 1/1 can: mcp251xfd: use regmap_bulk_write for compatibility

Recently i use mcp2518fd on 4.x kernel which multiple write is not backported, regmap_raw_write will cause old kernel crash because the tx buffer in driver is smaller then 2K. Use regmap_bulk_write instead for compatibility.

---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +3 -2
index 3dde52669343..ab8aad0a7594 100644
@@ -932,6 +932,7 @@ static int mcp251xfd_chip_ecc_init(struct mcp251xfd_priv *priv)
 	void *ram;
 	u32 val = 0;
 	int err;
+	int val_bytes = regmap_get_val_bytes(priv->map_reg);
 
 	ecc->ecc_stat = 0;
 
@@ -947,8 +948,8 @@ static int mcp251xfd_chip_ecc_init(struct mcp251xfd_priv *priv)
 	if (!ram)
 		return -ENOMEM;
 
-	err = regmap_raw_write(priv->map_reg, MCP251XFD_RAM_START, ram,
-			       MCP251XFD_RAM_SIZE);
+	err = regmap_bulk_write(priv->map_reg, MCP251XFD_RAM_START, ram,
+			       MCP251XFD_RAM_SIZE / val_bytes);
 	kfree(ram);
 
 	return err;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 4 lines · Su Yanjun

Recently i use mcp2518fd on 4.x kernel which multiple write is not backported, regmap_raw_write will cause old kernel crash because the tx buffer in driver is smaller then 2K. Use regmap_bulk_write instead for compatibility.

Hmmm, this patch will never be backported to any 4.x kernel, as the driver is not available on these kernels. You have to carry patches for these kernels anyway, so I think I'll not take that patch. Sorry. Drop me a note if you are interested in updating your kernel to a recent v5.11 kernel.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
author
#2 lore raw
Quoted 9 lines · Marc Kleine-Budde
Quoted 4 lines · Su Yanjun

Recently i use mcp2518fd on 4.x kernel which multiple write is not backported, regmap_raw_write will cause old kernel crash because the tx buffer in driver is smaller then 2K. Use regmap_bulk_write instead for compatibility.

Hmmm, this patch will never be backported to any 4.x kernel, as the driver is not available on these kernels. You have to carry patches for these kernels anyway, so I think I'll not take that patch. Sorry. Drop me a note if you are interested in updating your kernel to a recent v5.11 kernel.

I got it. I have already port it to 4.x kernel. I just want anyone working on old kernels to use the driver more easier.

Thanks.

Quoted 4 lines

regards,
Marc

#3 lore raw
Quoted 7 lines · Su
Quoted 5 lines · Marc Kleine-Budde
Quoted 4 lines · Su Yanjun

Recently i use mcp2518fd on 4.x kernel which multiple write is not backported, regmap_raw_write will cause old kernel crash because the tx buffer in driver is smaller then 2K. Use regmap_bulk_write instead for compatibility.

Quoted 7 lines
Quoted 4 lines

Hmmm, this patch will never be backported to any 4.x kernel, as the driver is not available on these kernels. You have to carry patches for these kernels anyway, so I think I'll not take that patch. Sorry. Drop me a note if you are interested in updating your kernel to a recent v5.11 kernel.

I got it. I have already port it to 4.x kernel. I just want anyone working on old kernels to use the driver more easier.

Ok, you can post a link yo your repo with the patches for the interested reader.

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |