RE: Subject: [PATCH] AD7879: Fix spi word size

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

 



On Wednesday, May 19, 2010 3:01 AM, Michael Hennerich wrote:
> Similar patch as reported by Oskar Schirmer <os@xxxxxxxxx> for the
> AD7877.
> 
> With no word size given in the users platform data, a generic spi host
> controller driver will assume a default word size of eight bit.
> Ensure spi->bits_per_word is set for 16-bit transfers.
> 
> Signed-off-by: Michael Hennerich <Michael.hennerich@xxxxxxxxxx>
> ---
>  drivers/input/touchscreen/ad7879.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/ad7879.c
> b/drivers/input/touchscreen/ad7879.c
> index 794d070..ff490c0 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -715,6 +715,16 @@ static int __devinit ad7879_probe(struct spi_device
> *spi)
>  		return -EINVAL;
>  	}
>  
> +	if (spi->bits_per_word != 16) {

The master never sets this field so this test isn't needed.  The platform
specific spi_board_info "could" set the field but I don't think any currently
do.

If the bits_per_word field is not set when spi_setup is called, it is set to
the default value (8) before calling the spi master drivers setup routine.
You just need to set the value since that is what the protocol requires.  The
spi_setup call is still needed since part of the probe for this driver does
generate a spi transaction, you need to make sure the master driver will support
the protocol before that happens.

> +		spi->bits_per_word = 16;
> +		error = spi_setup(spi);
> +		if (error) {
> +			dev_dbg(&spi->dev,
> +				"spi master doesn't support 16 bits/word\n");
> +			return error;
> +		}
> +	}   
> +
>  	ts = kzalloc(sizeof(struct ad7879), GFP_KERNEL);
>  	if (!ts)
>  		return -ENOMEM;

Regards,
Hartley--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux