Re: [PATCH 1/3] spi: spi-gpio: Rewrite to use GPIO descriptors

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

 



On Tue, Feb 13, 2018 at 3:17 PM, Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:
> On Mon, Feb 12, 2018 at 2:45 PM, Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:

>>  #include <linux/gpio.h>
>> +#include <linux/gpio/machine.h>
>
> Do I understand correctly that gpio.h is left due to dependencies in
> other parts of the code (here and in the rest of changed drivers)?

Yes, unless I missed something. When I edited the files I
searched for gpio_* (well in EMACS just CTRL+s "gpio_"...)
and very often it turns out that the board files grab a few
GPIOs and so something.

Some of that can probably go away with the use of GPIO hogs,
some of it needs proper conversion to gpio descriptors (sigh)
So I guess I will get to it in the next 20 years or so, plenty
of clean-up work for everyone ;)

>> +       /* set initial clock line level */
>>         if (is_active)
>> +               gpiod_set_value_cansleep(spi_gpio->sck, spi->mode & SPI_CPOL);
>> +
>> +       /* Drive chip select line, if we have one */
>> +       if (spi_gpio->has_cs) {
>> +               struct gpio_desc *cs = spi_gpio->cs_gpios[spi->chip_select];
>>
>> +               /* SPI chip selects are normally active-low */
>> +               gpiod_set_value_cansleep(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
>
>   bool invert = !(spi->mode & SPI_CS_HIGH);
>
>   gpiod_set_value_cansleep(cs, !!is_active ^ invert);
>
> ?
>
> But I guess most used pattern is just explicit conditional
>
> if (spi->mode & SPI_CS_HIGH)
>         gpiod_set_value_cansleep(cs, is_active);
> else
>         gpiod_set_value_cansleep(cs, !is_active);

This looks neat and Mark seems to like this pattern so I will
go for this!

>> +       spi_gpio->cs_gpios = devm_kzalloc(&pdev->dev,
>> +                               pdata->num_chipselect * sizeof(*spi_gpio->cs_gpios),
>> +                               GFP_KERNEL);
>
> kcalloc

Okay!

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



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux