Commit db49ca38 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Paolo Abeni

net: davicom: dm9000: switch to using gpiod API

This patch switches the driver away from legacy gpio/of_gpio API to
gpiod API, and removes use of of_get_named_gpio_flags() which I want to
make private to gpiolib.
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220906204922.3789922-1-dmitry.torokhov@gmail.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent c9ae520a
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/of_gpio.h>
#include <asm/delay.h> #include <asm/delay.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -1421,8 +1420,7 @@ dm9000_probe(struct platform_device *pdev) ...@@ -1421,8 +1420,7 @@ dm9000_probe(struct platform_device *pdev)
int iosize; int iosize;
int i; int i;
u32 id_val; u32 id_val;
int reset_gpios; struct gpio_desc *reset_gpio;
enum of_gpio_flags flags;
struct regulator *power; struct regulator *power;
bool inv_mac_addr = false; bool inv_mac_addr = false;
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
...@@ -1442,20 +1440,24 @@ dm9000_probe(struct platform_device *pdev) ...@@ -1442,20 +1440,24 @@ dm9000_probe(struct platform_device *pdev)
dev_dbg(dev, "regulator enabled\n"); dev_dbg(dev, "regulator enabled\n");
} }
reset_gpios = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0, reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
&flags); ret = PTR_ERR_OR_ZERO(reset_gpio);
if (gpio_is_valid(reset_gpios)) {
ret = devm_gpio_request_one(dev, reset_gpios, flags,
"dm9000_reset");
if (ret) { if (ret) {
dev_err(dev, "failed to request reset gpio %d: %d\n", dev_err(dev, "failed to request reset gpio: %d\n", ret);
reset_gpios, ret); goto out_regulator_disable;
}
if (reset_gpio) {
ret = gpiod_set_consumer_name(reset_gpio, "dm9000_reset");
if (ret) {
dev_err(dev, "failed to set reset gpio name: %d\n",
ret);
goto out_regulator_disable; goto out_regulator_disable;
} }
/* According to manual PWRST# Low Period Min 1ms */ /* According to manual PWRST# Low Period Min 1ms */
msleep(2); msleep(2);
gpio_set_value(reset_gpios, 1); gpiod_set_value_cansleep(reset_gpio, 0);
/* Needs 3ms to read eeprom when PWRST is deasserted */ /* Needs 3ms to read eeprom when PWRST is deasserted */
msleep(4); msleep(4);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment