Commit 8e71c680 authored by Uwe Kleine-König's avatar Uwe Kleine-König

phy: tusb1210: make better use of gpiod API

Since 39b2bbe3 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Furthermore there is devm_gpiod_get_optional which is designed to get
optional gpios.

Simplify driver accordingly.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 3bfe7680
...@@ -61,32 +61,26 @@ static struct phy_ops phy_ops = { ...@@ -61,32 +61,26 @@ static struct phy_ops phy_ops = {
static int tusb1210_probe(struct ulpi *ulpi) static int tusb1210_probe(struct ulpi *ulpi)
{ {
struct gpio_desc *gpio;
struct tusb1210 *tusb; struct tusb1210 *tusb;
u8 val, reg; u8 val, reg;
int ret;
tusb = devm_kzalloc(&ulpi->dev, sizeof(*tusb), GFP_KERNEL); tusb = devm_kzalloc(&ulpi->dev, sizeof(*tusb), GFP_KERNEL);
if (!tusb) if (!tusb)
return -ENOMEM; return -ENOMEM;
gpio = devm_gpiod_get(&ulpi->dev, "reset"); tusb->gpio_reset = devm_gpiod_get_optional(&ulpi->dev, "reset",
if (!IS_ERR(gpio)) { GPIOD_OUT_LOW);
ret = gpiod_direction_output(gpio, 0); if (IS_ERR(tusb->gpio_reset))
if (ret) return PTR_ERR(tusb->gpio_reset);
return ret;
gpiod_set_value_cansleep(gpio, 1);
tusb->gpio_reset = gpio;
}
gpio = devm_gpiod_get(&ulpi->dev, "cs"); gpiod_set_value_cansleep(tusb->gpio_reset, 1);
if (!IS_ERR(gpio)) {
ret = gpiod_direction_output(gpio, 0); tusb->gpio_cs = devm_gpiod_get_optional(&ulpi->dev, "cs",
if (ret) GPIOD_OUT_LOW);
return ret; if (IS_ERR(tusb->gpio_cs))
gpiod_set_value_cansleep(gpio, 1); return PTR_ERR(tusb->gpio_cs);
tusb->gpio_cs = gpio;
} gpiod_set_value_cansleep(tusb->gpio_cs, 1);
/* /*
* VENDOR_SPECIFIC2 register in TUSB1210 can be used for configuring eye * VENDOR_SPECIFIC2 register in TUSB1210 can be used for configuring eye
......
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