net: ks8851: 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: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220906204922.3789922-2-dmitry.torokhov@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
db49ca3857
commit
7b77bb5c81
@ -403,7 +403,7 @@ struct ks8851_net {
|
|||||||
struct eeprom_93cx6 eeprom;
|
struct eeprom_93cx6 eeprom;
|
||||||
struct regulator *vdd_reg;
|
struct regulator *vdd_reg;
|
||||||
struct regulator *vdd_io;
|
struct regulator *vdd_io;
|
||||||
int gpio;
|
struct gpio_desc *gpio;
|
||||||
struct mii_bus *mii_bus;
|
struct mii_bus *mii_bus;
|
||||||
|
|
||||||
void (*lock)(struct ks8851_net *ks,
|
void (*lock)(struct ks8851_net *ks,
|
||||||
|
@ -17,10 +17,9 @@
|
|||||||
#include <linux/cache.h>
|
#include <linux/cache.h>
|
||||||
#include <linux/crc32.h>
|
#include <linux/crc32.h>
|
||||||
#include <linux/mii.h>
|
#include <linux/mii.h>
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/regulator/consumer.h>
|
#include <linux/regulator/consumer.h>
|
||||||
|
|
||||||
#include <linux/gpio.h>
|
|
||||||
#include <linux/of_gpio.h>
|
|
||||||
#include <linux/of_mdio.h>
|
#include <linux/of_mdio.h>
|
||||||
#include <linux/of_net.h>
|
#include <linux/of_net.h>
|
||||||
|
|
||||||
@ -1117,24 +1116,23 @@ int ks8851_probe_common(struct net_device *netdev, struct device *dev,
|
|||||||
{
|
{
|
||||||
struct ks8851_net *ks = netdev_priv(netdev);
|
struct ks8851_net *ks = netdev_priv(netdev);
|
||||||
unsigned cider;
|
unsigned cider;
|
||||||
int gpio;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ks->netdev = netdev;
|
ks->netdev = netdev;
|
||||||
ks->tx_space = 6144;
|
ks->tx_space = 6144;
|
||||||
|
|
||||||
gpio = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0, NULL);
|
ks->gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
|
||||||
if (gpio == -EPROBE_DEFER)
|
ret = PTR_ERR_OR_ZERO(ks->gpio);
|
||||||
return gpio;
|
if (ret) {
|
||||||
|
if (ret != -EPROBE_DEFER)
|
||||||
|
dev_err(dev, "reset gpio request failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ks->gpio = gpio;
|
ret = gpiod_set_consumer_name(ks->gpio, "ks8851_rst_n");
|
||||||
if (gpio_is_valid(gpio)) {
|
if (ret) {
|
||||||
ret = devm_gpio_request_one(dev, gpio,
|
dev_err(dev, "failed to set reset gpio name: %d\n", ret);
|
||||||
GPIOF_OUT_INIT_LOW, "ks8851_rst_n");
|
return ret;
|
||||||
if (ret) {
|
|
||||||
dev_err(dev, "reset gpio request failed\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ks->vdd_io = devm_regulator_get(dev, "vdd-io");
|
ks->vdd_io = devm_regulator_get(dev, "vdd-io");
|
||||||
@ -1161,9 +1159,9 @@ int ks8851_probe_common(struct net_device *netdev, struct device *dev,
|
|||||||
goto err_reg;
|
goto err_reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gpio_is_valid(gpio)) {
|
if (ks->gpio) {
|
||||||
usleep_range(10000, 11000);
|
usleep_range(10000, 11000);
|
||||||
gpio_set_value(gpio, 1);
|
gpiod_set_value_cansleep(ks->gpio, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_init(&ks->statelock);
|
spin_lock_init(&ks->statelock);
|
||||||
@ -1239,8 +1237,8 @@ int ks8851_probe_common(struct net_device *netdev, struct device *dev,
|
|||||||
err_id:
|
err_id:
|
||||||
ks8851_unregister_mdiobus(ks);
|
ks8851_unregister_mdiobus(ks);
|
||||||
err_mdio:
|
err_mdio:
|
||||||
if (gpio_is_valid(gpio))
|
if (ks->gpio)
|
||||||
gpio_set_value(gpio, 0);
|
gpiod_set_value_cansleep(ks->gpio, 1);
|
||||||
regulator_disable(ks->vdd_reg);
|
regulator_disable(ks->vdd_reg);
|
||||||
err_reg:
|
err_reg:
|
||||||
regulator_disable(ks->vdd_io);
|
regulator_disable(ks->vdd_io);
|
||||||
@ -1259,8 +1257,8 @@ void ks8851_remove_common(struct device *dev)
|
|||||||
dev_info(dev, "remove\n");
|
dev_info(dev, "remove\n");
|
||||||
|
|
||||||
unregister_netdev(priv->netdev);
|
unregister_netdev(priv->netdev);
|
||||||
if (gpio_is_valid(priv->gpio))
|
if (priv->gpio)
|
||||||
gpio_set_value(priv->gpio, 0);
|
gpiod_set_value_cansleep(priv->gpio, 1);
|
||||||
regulator_disable(priv->vdd_reg);
|
regulator_disable(priv->vdd_reg);
|
||||||
regulator_disable(priv->vdd_io);
|
regulator_disable(priv->vdd_io);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user