linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@codeaurora.org>
To: David Mosberger-Tang <davidm@egauge.net>
Cc: linux-wireless@vger.kernel.org,
	Ajay Singh <ajay.kathat@microchip.com>,
	Claudiu Beznea <claudiu.beznea@microchip.com>
Subject: Re: [PATCH 3/4] wilc1000: Check for errors at end of DMA write
Date: Thu, 25 Feb 2021 10:27:52 +0200	[thread overview]
Message-ID: <87eeh4eelz.fsf@tynnyri.adurom.net> (raw)
In-Reply-To: <20210224055135.1509200-3-davidm@egauge.net> (David Mosberger-Tang's message of "Wed, 24 Feb 2021 05:51:57 +0000 (UTC)")

David Mosberger-Tang <davidm@egauge.net> writes:

> After a DMA write to the WILC chip, check for and report any errors.
>
> This is based on code from the wilc driver in the linux-at91
> repository.
>
> Signed-off-by: David Mosberger-Tang <davidm@egauge.net>
> ---
>  drivers/net/wireless/microchip/wilc1000/spi.c | 50 ++++++++++++++++++-
>  1 file changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c
> index fca34d1999ec..b0e096a03a28 100644
> --- a/drivers/net/wireless/microchip/wilc1000/spi.c
> +++ b/drivers/net/wireless/microchip/wilc1000/spi.c
> @@ -750,6 +750,51 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data)
>  	return 0;
>  }
>  
> +static int spi_data_rsp(struct wilc *wilc, u8 cmd)
> +{
> +	struct spi_device *spi = to_spi_device(wilc->dev);
> +	int result, i;
> +	u8 rsp[4];
> +
> +	/*
> +	 * The response to data packets is two bytes long.  For
> +	 * efficiency's sake, wilc_spi_write() wisely ignores the
> +	 * responses for all packets but the final one.  The downside
> +	 * of that optimization is that when the final data packet is
> +	 * short, we may receive (part of) the response to the
> +	 * second-to-last packet before the one for the final packet.
> +	 * To handle this, we always read 4 bytes and then search for
> +	 * the last byte that contains the "Response Start" code (0xc
> +	 * in the top 4 bits).  We then know that this byte is the
> +	 * first response byte of the final data packet.
> +	 */
> +	result = wilc_spi_rx(wilc, rsp, sizeof(rsp));
> +	if (result) {
> +		dev_err(&spi->dev, "Failed bus error...\n");
> +		return result;
> +	}
> +
> +	for (i = sizeof(rsp) - 2; i >= 0; --i)
> +		if ((rsp[i] & 0xf0) == 0xc0)
> +			break;

No magic numbers. Please create proper defines for these.

> +	if (i < 0) {
> +		dev_err(&spi->dev,
> +			"Data packet response missing (%02x %02x %02x %02x)\n",
> +			rsp[0], rsp[1], rsp[2], rsp[3]);
> +		return -1;
> +	}
> +
> +	/* rsp[i] is the last response start byte */
> +
> +	if (rsp[i] != 0xc3 || rsp[i + 1] != 0x00) {

Same here.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

  reply	other threads:[~2021-02-25  8:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24  5:51 [PATCH 1/4] wilc1000: Make SPI transfers work at 48MHz David Mosberger-Tang
2021-02-24  5:51 ` [PATCH 2/4] wilc1000: Introduce symbolic names for SPI protocol register David Mosberger-Tang
2021-02-24  5:51 ` [PATCH 3/4] wilc1000: Check for errors at end of DMA write David Mosberger-Tang
2021-02-25  8:27   ` Kalle Valo [this message]
2021-02-25 18:10     ` David Mosberger-Tang
2021-02-24  5:52 ` [PATCH 4/4] wilc1000: Add support for enabling CRC David Mosberger-Tang
2021-02-24 10:01   ` Ajay.Kathat
2021-02-24 16:25     ` David Mosberger-Tang
2021-02-25  4:50       ` Ajay.Kathat
2021-02-24 13:35   ` Ajay.Kathat
2021-02-24 15:47     ` David Mosberger-Tang
2021-02-25  4:58       ` Ajay.Kathat
2021-02-25  8:25         ` Kalle Valo
2021-02-24 21:19   ` Julian Calaby
2021-02-24 23:36     ` David Mosberger-Tang
2021-02-25  5:56       ` Ajay.Kathat
2021-02-25  8:22         ` Kalle Valo
2021-02-25 11:03           ` Ajay.Kathat
2021-02-26  7:09             ` Kalle Valo
2021-02-27 17:29 ` [PATCH v2 1/4] wilc1000: Make SPI transfers work at 48MHz David Mosberger-Tang
2021-04-17 17:48   ` Kalle Valo
2021-02-27 17:29 ` [PATCH v2 2/4] wilc1000: Introduce symbolic names for SPI protocol register David Mosberger-Tang
2021-02-27 17:29 ` [PATCH v2 3/4] wilc1000: Check for errors at end of DMA write David Mosberger-Tang
2021-02-27 17:31 ` [PATCH v2 4/4] wilc1000: Add support for enabling CRC David Mosberger-Tang

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=87eeh4eelz.fsf@tynnyri.adurom.net \
    --to=kvalo@codeaurora.org \
    --cc=ajay.kathat@microchip.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=davidm@egauge.net \
    --cc=linux-wireless@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).