Search Linux Wireless

Re: [PATCH 3/4] wilc1000: Check for errors at end of DMA write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Mosberger-Tang <davidm@xxxxxxxxxx> 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@xxxxxxxxxx>
> ---
>  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



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux