lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ca3b3f5247624a35b8203472a53df79a@svr-chch-ex1.atlnz.lc>
Date:   Tue, 23 May 2017 20:43:13 +0000
From:   Chris Packham <Chris.Packham@...iedtelesis.co.nz>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
CC:     Mark Brown <broonie@...nel.org>,
        linux-spi <linux-spi@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] spi: use gpio_desc instead of numeric gpio

Hi Andy,

On 24/05/17 06:28, Andy Shevchenko wrote:
> On Tue, May 23, 2017 at 7:03 AM, Chris Packham
> <chris.packham@...iedtelesis.co.nz> wrote:
>> By using a gpio_desc and gpiod_set_value() instead of a numeric gpio and
>> gpio_set_value() the gpio flags are taken into account. This is useful
>> when using a gpio chip-select to supplement a controllers native
>> chip-select.
>
> I think would be better to move everything in SPI core to GPIO descriptors.

I did consider it but it's a big change and I don't have access a lot of 
gear to test on (maybe 2 or 3 SoCs with a SPI host controller and the 
same SPI-NOR chips).

I can give it a try. Perhaps converting the spi core structures over and 
leaving the slaves using numeric gpios. Then later converting the slaves.

>
>>
>> Signed-off-by: Chris Packham <chris.packham@...iedtelesis.co.nz>
>> ---
>>
>> Notes:
>>      My specific use-case is I have a board that uses the spi-orion driver but
>>      only has one CS pin available. In order to access two spi slave devices the
>>      board has a 1-of-2 decoder/demultiplexer which is driven via a gpio.
>>
>>      The problem is that for one of the 2 slave devices the gpio level required
>>      is opposite to the chip-select so I can't simply specify "spi-cs-high".
>>      With this change I can flag the gpio as active low and the gpio subsystem
>>      takes care of the additional inversion required.
>>
>>   drivers/spi/spi.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
>> index 6f87fec409b5..b39c0f9956dd 100644
>> --- a/drivers/spi/spi.c
>> +++ b/drivers/spi/spi.c
>> @@ -725,7 +725,10 @@ static void spi_set_cs(struct spi_device *spi, bool enable)
>>                  enable = !enable;
>>
>>          if (gpio_is_valid(spi->cs_gpio)) {
>> -               gpio_set_value(spi->cs_gpio, !enable);
>> +               struct gpio_desc *gpio = gpio_to_desc(spi->cs_gpio);
>> +
>> +               if (gpio)
>> +                       gpiod_set_value(gpio, !enable);
>>                  /* Some SPI masters need both GPIO CS & slave_select */
>>                  if ((spi->master->flags & SPI_MASTER_GPIO_SS) &&
>>                      spi->master->set_cs)
>> --
>> 2.13.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-spi" in
>> the body of a message to majordomo@...r.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ