]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
phy: tusb1210: make better use of gpiod API
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 12 Jun 2015 06:55:30 +0000 (08:55 +0200)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 6 Jul 2015 08:10:22 +0000 (10:10 +0200)
Since 39b2bbe3d715 (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: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
drivers/phy/phy-tusb1210.c

index 07efdd318bdc9215d4de464aa3a19f7cc22ec612..93dd45f2f26e2dfe3904c625af9820fee494c37d 100644 (file)
@@ -61,32 +61,26 @@ static struct phy_ops phy_ops = {
 
 static int tusb1210_probe(struct ulpi *ulpi)
 {
-       struct gpio_desc *gpio;
        struct tusb1210 *tusb;
        u8 val, reg;
-       int ret;
 
        tusb = devm_kzalloc(&ulpi->dev, sizeof(*tusb), GFP_KERNEL);
        if (!tusb)
                return -ENOMEM;
 
-       gpio = devm_gpiod_get(&ulpi->dev, "reset");
-       if (!IS_ERR(gpio)) {
-               ret = gpiod_direction_output(gpio, 0);
-               if (ret)
-                       return ret;
-               gpiod_set_value_cansleep(gpio, 1);
-               tusb->gpio_reset = gpio;
-       }
+       tusb->gpio_reset = devm_gpiod_get_optional(&ulpi->dev, "reset",
+                                                  GPIOD_OUT_LOW);
+       if (IS_ERR(tusb->gpio_reset))
+               return PTR_ERR(tusb->gpio_reset);
 
-       gpio = devm_gpiod_get(&ulpi->dev, "cs");
-       if (!IS_ERR(gpio)) {
-               ret = gpiod_direction_output(gpio, 0);
-               if (ret)
-                       return ret;
-               gpiod_set_value_cansleep(gpio, 1);
-               tusb->gpio_cs = gpio;
-       }
+       gpiod_set_value_cansleep(tusb->gpio_reset, 1);
+
+       tusb->gpio_cs = devm_gpiod_get_optional(&ulpi->dev, "cs",
+                                               GPIOD_OUT_LOW);
+       if (IS_ERR(tusb->gpio_cs))
+               return PTR_ERR(tusb->gpio_cs);
+
+       gpiod_set_value_cansleep(tusb->gpio_cs, 1);
 
        /*
         * VENDOR_SPECIFIC2 register in TUSB1210 can be used for configuring eye