aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2015-06-12 02:55:30 -0400
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2015-07-06 04:10:22 -0400
commit8e71c68074ff37348d586c87b0ee530e7440b094 (patch)
tree352b5fdb9ba64ea4cbf011c7d9418c410caf7b1d
parent3bfe76806f705a24b82bc43c84c8506f3a44f77b (diff)
phy: tusb1210: make better use of gpiod API
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>
-rw-r--r--drivers/phy/phy-tusb1210.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/drivers/phy/phy-tusb1210.c b/drivers/phy/phy-tusb1210.c
index 07efdd318bdc..93dd45f2f26e 100644
--- a/drivers/phy/phy-tusb1210.c
+++ b/drivers/phy/phy-tusb1210.c
@@ -61,32 +61,26 @@ static struct phy_ops phy_ops = {
61 61
62static int tusb1210_probe(struct ulpi *ulpi) 62static int tusb1210_probe(struct ulpi *ulpi)
63{ 63{
64 struct gpio_desc *gpio;
65 struct tusb1210 *tusb; 64 struct tusb1210 *tusb;
66 u8 val, reg; 65 u8 val, reg;
67 int ret;
68 66
69 tusb = devm_kzalloc(&ulpi->dev, sizeof(*tusb), GFP_KERNEL); 67 tusb = devm_kzalloc(&ulpi->dev, sizeof(*tusb), GFP_KERNEL);
70 if (!tusb) 68 if (!tusb)
71 return -ENOMEM; 69 return -ENOMEM;
72 70
73 gpio = devm_gpiod_get(&ulpi->dev, "reset"); 71 tusb->gpio_reset = devm_gpiod_get_optional(&ulpi->dev, "reset",
74 if (!IS_ERR(gpio)) { 72 GPIOD_OUT_LOW);
75 ret = gpiod_direction_output(gpio, 0); 73 if (IS_ERR(tusb->gpio_reset))
76 if (ret) 74 return PTR_ERR(tusb->gpio_reset);
77 return ret;
78 gpiod_set_value_cansleep(gpio, 1);
79 tusb->gpio_reset = gpio;
80 }
81 75
82 gpio = devm_gpiod_get(&ulpi->dev, "cs"); 76 gpiod_set_value_cansleep(tusb->gpio_reset, 1);
83 if (!IS_ERR(gpio)) { 77
84 ret = gpiod_direction_output(gpio, 0); 78 tusb->gpio_cs = devm_gpiod_get_optional(&ulpi->dev, "cs",
85 if (ret) 79 GPIOD_OUT_LOW);
86 return ret; 80 if (IS_ERR(tusb->gpio_cs))
87 gpiod_set_value_cansleep(gpio, 1); 81 return PTR_ERR(tusb->gpio_cs);
88 tusb->gpio_cs = gpio; 82
89 } 83 gpiod_set_value_cansleep(tusb->gpio_cs, 1);
90 84
91 /* 85 /*
92 * VENDOR_SPECIFIC2 register in TUSB1210 can be used for configuring eye 86 * VENDOR_SPECIFIC2 register in TUSB1210 can be used for configuring eye