diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2015-07-06 05:09:48 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-07-29 10:59:18 -0400 |
commit | 2df033ca39b56605725384bac1579cdd30e052a6 (patch) | |
tree | 25a9035e4cbf6c2fc7867b7217396fdefc14b6e1 | |
parent | 83b7b67c780500a1d5d87c44ee8963166154adfa (diff) |
usb: dwc3: pci: 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.
Use this additional parameter and the _optional variant to simplify the
driver and improve error handling. Also expand the comment to explain
why it's not sensible to switch to devm_gpiod_get and why the gpiod_put
is also necessary.
Furthermore this is one caller less that stops us making the flags
argument to gpiod_get*() mandatory.
Tested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/dwc3/dwc3-pci.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 27e4fc896e9d..f62617999f3c 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -83,17 +83,23 @@ static int dwc3_pci_quirks(struct pci_dev *pdev) | |||
83 | acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev), | 83 | acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev), |
84 | acpi_dwc3_byt_gpios); | 84 | acpi_dwc3_byt_gpios); |
85 | 85 | ||
86 | /* These GPIOs will turn on the USB2 PHY */ | 86 | /* |
87 | gpio = gpiod_get(&pdev->dev, "cs"); | 87 | * These GPIOs will turn on the USB2 PHY. Note that we have to |
88 | if (!IS_ERR(gpio)) { | 88 | * put the gpio descriptors again here because the phy driver |
89 | gpiod_direction_output(gpio, 0); | 89 | * might want to grab them, too. |
90 | gpiod_set_value_cansleep(gpio, 1); | 90 | */ |
91 | gpiod_put(gpio); | 91 | gpio = gpiod_get_optional(&pdev->dev, "cs", GPIOD_OUT_LOW); |
92 | } | 92 | if (IS_ERR(gpio)) |
93 | return PTR_ERR(gpio); | ||
94 | |||
95 | gpiod_set_value_cansleep(gpio, 1); | ||
96 | gpiod_put(gpio); | ||
97 | |||
98 | gpio = gpiod_get_optional(&pdev->dev, "reset", GPIOD_OUT_LOW); | ||
99 | if (IS_ERR(gpio)) | ||
100 | return PTR_ERR(gpio); | ||
93 | 101 | ||
94 | gpio = gpiod_get(&pdev->dev, "reset"); | 102 | if (gpio) { |
95 | if (!IS_ERR(gpio)) { | ||
96 | gpiod_direction_output(gpio, 0); | ||
97 | gpiod_set_value_cansleep(gpio, 1); | 103 | gpiod_set_value_cansleep(gpio, 1); |
98 | gpiod_put(gpio); | 104 | gpiod_put(gpio); |
99 | usleep_range(10000, 11000); | 105 | usleep_range(10000, 11000); |