lkml.org 
[lkml]   [2015]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] spi: omap2-mcspi: Add support for GPIO chipselects
On 04/27/2015 10:21 PM, Michael Welling wrote:
> On Mon, Apr 27, 2015 at 08:55:50PM +0100, Mark Brown wrote:
>> On Sun, Apr 26, 2015 at 10:44:30PM -0500, Michael Welling wrote:
>>
>>> + if (gpio_is_valid(spi->cs_gpio)) {
>>> + gpio_set_value(spi->cs_gpio, (cs_active) ?
>>> + !!(spi->mode & SPI_CS_HIGH) :
>>> + !(spi->mode & SPI_CS_HIGH));
>>> + }
>>
>> Two problems here. One is that the above logic statement is just not
>> readable (the repitition of hecks, the ternery operator, the
>> indentation...) and the other is that the core chipselect support
>> already handles GPIO chipselects so you should really be converting the
>> driver to use that. At the very least the code needs to be legible
>> though.
>
> Before I send another patch how does this look?
>
> if (gpio_is_valid(spi->cs_gpio)) {
> if (cs_active)
> gpio_set_value(spi->cs_gpio, spi->mode & SPI_CS_HIGH);
> else
> gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
> }
>
> If I were to attempt to convert the driver to use the core chipselect support,
> how would I go about doing it?
>
> Is there another driver that I can use for reference?

We've recently done that for spi-img-spfi.c.

--
Ezequiel


\
 
 \ /
  Last update: 2015-04-28 16:41    [W:0.079 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site