All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: linux-can@vger.kernel.org
Cc: kernel@pengutronix.de,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	"Thomas Kopp" <thomas.kopp@microchip.com>,
	"Magnus Aagaard Sørensen" <mas@csselectronics.com>,
	"Marc Kleine-Budde" <mkl@pengutronix.de>
Subject: [can-next-rfc 03/14] can: mcp251xfd: mcp251xfd_regmap_crc_read(): ignore CRC error only if solely OSC register is read
Date: Sun, 25 Apr 2021 14:23:49 +0200	[thread overview]
Message-ID: <20210425122400.3276975-4-mkl@pengutronix.de> (raw)
In-Reply-To: <20210425122400.3276975-1-mkl@pengutronix.de>

MCP251XFD_REG_OSC is the first ever reg we read from. The chip may be
in deep sleep and the SPI transfer (i.e. the assertion of the CS) will
wake the chip up. This takes about 3ms. The CRC of this transfer is
wrong, or there isn't a chip at all, in this case the CRC will be
wrong, too. The driver ignores the CRC error and returns the read data
to the caller.

To avoid any confusion, this patch changes the
mcp251xfd_regmap_crc_read() function to only ignore the CRC error if
solely the OSC register is read. So when reading multiple registers at
once the CRC is returned.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c
index 297491516a26..e026247812aa 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c
@@ -369,7 +369,7 @@ mcp251xfd_regmap_crc_read(void *context,
 		 * to the caller. It will take care of both cases.
 		 *
 		 */
-		if (reg == MCP251XFD_REG_OSC) {
+		if (reg == MCP251XFD_REG_OSC && val_len == sizeof(__le32)) {
 			err = 0;
 			goto out;
 		}
-- 
2.30.2



  parent reply	other threads:[~2021-04-25 12:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-25 12:23 [RFC]: can-next 2021-04-25: mcp251xfd cleanups and PLL support Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 01/14] can: mcp251xfd: mcp251xfd_irq(): stop timestamping worker in case error in IRQ Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 02/14] can: mcp251xfd: mcp251xfd_tef_obj_read(): fix typo in error message Marc Kleine-Budde
2021-04-25 12:23 ` Marc Kleine-Budde [this message]
2021-04-25 12:23 ` [can-next-rfc 04/14] can: mcp251xfd: mcp251xfd_reg_invalid(): rename from mcp251xfd_osc_invalid() Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 05/14] can: mcp251xfd: mcp251xfd_chip_wait_for_osc_ready(): factor out into separate function Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 06/14] can: mcp251xfd: mcp251xfd_chip_wait_for_osc_ready(): improve chip detection and error handling Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 07/14] can: mcp251xfd: mcp251xfd_chip_wait_for_osc_ready(): prepare for PLL support Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 08/14] can: mcp251xfd: mcp251xfd_chip_softreset_check(): wait for OSC ready before accessing chip Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 09/14] can: mcp251xfd: mcp251xfd_chip_timestamp_init(): factor out into separate function Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 10/14] can: mcp251xfd: mcp251xfd_chip_wake(): renamed from mcp251xfd_chip_clock_enable() Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 11/14] can: mcp251xfd: __mcp251xfd_chip_set_mode(): prepare for PLL support: improve error handling and diagnostics Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 12/14] can: mcp251xfd: mcp251xfd_chip_clock_init(): prepare for PLL support, wait for OSC ready Marc Kleine-Budde
2021-04-25 12:23 ` [can-next-rfc 13/14] can: mcp251xfd: mcp251xfd_register(): prepare to activate PLL after softreset Marc Kleine-Budde
2021-04-25 12:24 ` [can-next-rfc 14/14] can: mcp251xfd: add support for internal PLL Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210425122400.3276975-4-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=mas@csselectronics.com \
    --cc=thomas.kopp@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.