Skip to content

Commit 3340ec4

Browse files
mairacanalbroonie
authored andcommitted
spi: at91-usart: replacing legacy gpio interface for gpiod
Removing dependency of linux/of_gpio.h and replacing it for linux/gpio/consumer.h Signed-off-by: Maíra Canal <[email protected]> Link: https://lore.kernel.org/r/YW8I5Emdc3t0cqhz@fedora Signed-off-by: Mark Brown <[email protected]>
1 parent 08411e3 commit 3340ec4

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

drivers/spi/spi-at91-usart.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <linux/kernel.h>
1515
#include <linux/module.h>
1616
#include <linux/of_platform.h>
17-
#include <linux/of_gpio.h>
17+
#include <linux/gpio/consumer.h>
1818
#include <linux/pinctrl/consumer.h>
1919
#include <linux/platform_device.h>
2020
#include <linux/pm_runtime.h>
@@ -482,29 +482,12 @@ static void at91_usart_spi_init(struct at91_usart_spi *aus)
482482

483483
static int at91_usart_gpio_setup(struct platform_device *pdev)
484484
{
485-
struct device_node *np = pdev->dev.parent->of_node;
486-
int i;
487-
int ret;
488-
int nb;
489-
490-
if (!np)
491-
return -EINVAL;
492-
493-
nb = of_gpio_named_count(np, "cs-gpios");
494-
for (i = 0; i < nb; i++) {
495-
int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
485+
struct gpio_descs *cs_gpios;
496486

497-
if (cs_gpio < 0)
498-
return cs_gpio;
487+
cs_gpios = devm_gpiod_get_array_optional(&pdev->dev, "cs", GPIOD_OUT_LOW);
499488

500-
if (gpio_is_valid(cs_gpio)) {
501-
ret = devm_gpio_request_one(&pdev->dev, cs_gpio,
502-
GPIOF_DIR_OUT,
503-
dev_name(&pdev->dev));
504-
if (ret)
505-
return ret;
506-
}
507-
}
489+
if (IS_ERR(cs_gpios))
490+
return PTR_ERR(cs_gpios);
508491

509492
return 0;
510493
}

0 commit comments

Comments
 (0)