Thread (18 messages) 18 messages, 7 authors, 2018-06-13

[PATCH v4 5/6] spi: at91-usart: add driver for at91-usart as spi

From: nicolas.ferre@microchip.com (Nicolas Ferre)
Date: 2018-05-29 14:36:42
Also in: linux-devicetree, linux-serial, linux-spi, lkml

On 29/05/2018 at 16:28, Radu Pirea wrote:

On 05/28/2018 11:21 AM, Andy Shevchenko wrote:
quoted
On Fri, May 25, 2018 at 8:19 PM, Radu Pirea [off-list ref] wrote:
quoted
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.
[..]
quoted
quoted
+static int at91_usart_gpio_setup(struct platform_device *pdev)
+{
quoted
+       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
quoted
quoted
+       int                     i;
quoted
+       int                     ret = 0;
+       int                     nb = 0;
What happened to indentation?

Redundnant assignment for both.
quoted
+       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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help