LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Nicolas Ferre <nicolas.ferre@microchip.com>
To: Radu Pirea <radu.pirea@microchip.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Mark Brown <broonie@kernel.org>, <alexandre.belloni@bootlin.com>,
	Lee Jones <lee.jones@linaro.org>,
	Richard Genoud <richard.genoud@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-spi <linux-spi@vger.kernel.org>,
	linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	"open list:SERIAL DRIVERS" <linux-serial@vger.kernel.org>,
	Ludovic Desroches <ludovic.desroches@microchip.com>
Subject: Re: [PATCH v4 5/6] spi: at91-usart: add driver for at91-usart as spi
Date: Tue, 29 May 2018 16:34:37 +0200	[thread overview]
Message-ID: <0c529082-722c-14d8-7a04-dfeb63d5de92@microchip.com> (raw)
In-Reply-To: <110bb353-b131-348c-8e26-9863b074142d@microchip.com>

On 29/05/2018 at 16:28, Radu Pirea wrote:
> 
> 
> On 05/28/2018 11:21 AM, Andy Shevchenko wrote:
>> On Fri, May 25, 2018 at 8:19 PM, Radu Pirea <radu.pirea@microchip.com> wrote:
>>> This is the driver for at91-usart in spi mode. The USART IP can be configured
>>> to work in many modes and one of them is SPI.

[..]

>>> +static int at91_usart_gpio_setup(struct platform_device *pdev)
>>> +{
>>
>>> +       struct device_node      *np = pdev->dev.parent->of_node;
>>
>> Your driver is not OF specific as far as I can see. Drop all these
>> device_node stuff and change API calls respectively.
> 
> Ok. What do you suggest to use instead of OF API to get the count of
> cs-gpios and to read their values one by one?

As Alexandre said, we can make this driver OF specific.

What could be interesting is to use the gpio descriptors API and not the 
older one. This would allow us to have far more control over the gpio 
that we use in our drivers (Ludovic is converting our drivers to only 
use gpiod structures).

Regards,
   Nicolas

> 
>>
>>> +       int                     i;
>>
>>> +       int                     ret = 0;
>>> +       int                     nb = 0;
>>
>> What happened to indentation?
>>
>> Redundnant assignment for both.
>>
>>> +       if (!np)
>>> +               return -EINVAL;
>>> +
>>> +       nb = of_gpio_named_count(np, "cs-gpios");
>>> +       for (i = 0; i < nb; i++) {
>>> +               int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
>>> +
>>> +               if (cs_gpio < 0)
>>> +                       return cs_gpio;
>>> +
>>> +               if (gpio_is_valid(cs_gpio)) {
>>> +                       ret = devm_gpio_request_one(&pdev->dev, cs_gpio,
>>> +                                                   GPIOF_DIR_OUT,
>>> +                                                   dev_name(&pdev->dev));
>>> +                       if (ret)
>>> +                               return ret;
>>> +               }
>>> +       }
>>> +
>>> +       return 0;
>>> +}
[..]

-- 
Nicolas Ferre

  reply	other threads:[~2018-05-29 14:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 17:19 [PATCH v4 0/6] Driver for at91 usart in spi mode Radu Pirea
2018-05-25 17:19 ` [PATCH v4 1/6] MAINTAINERS: add at91 usart mfd driver Radu Pirea
2018-05-25 17:19 ` [PATCH v4 2/6] dt-bindings: add binding for atmel-usart in SPI mode Radu Pirea
2018-05-31  1:00   ` Rob Herring
2018-06-13  6:11   ` Lee Jones
2018-05-25 17:19 ` [PATCH v4 3/6] mfd: at91-usart: added mfd driver for usart Radu Pirea
2018-05-28  8:00   ` Andy Shevchenko
2018-05-29  9:32     ` Alexandre Belloni
2018-05-31  1:02   ` Rob Herring
2018-05-25 17:19 ` [PATCH v4 4/6] MAINTAINERS: add at91 usart spi driver Radu Pirea
2018-05-25 17:19 ` [PATCH v4 5/6] spi: at91-usart: add driver for at91-usart as spi Radu Pirea
2018-05-28  8:21   ` Andy Shevchenko
2018-05-29 14:28     ` Radu Pirea
2018-05-29 14:34       ` Nicolas Ferre [this message]
2018-05-29 14:36         ` Nicolas Ferre
2018-05-25 17:19 ` [PATCH v4 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd Radu Pirea
2018-05-28 10:08   ` Richard Genoud
2018-05-29  9:15     ` Radu Pirea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c529082-722c-14d8-7a04-dfeb63d5de92@microchip.com \
    --to=nicolas.ferre@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=mark.rutland@arm.com \
    --cc=radu.pirea@microchip.com \
    --cc=richard.genoud@gmail.com \
    --cc=robh+dt@kernel.org \
    --subject='Re: [PATCH v4 5/6] spi: at91-usart: add driver for at91-usart as spi' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).