Bluetooth: hci_bcm: improve use of gpios API

devm_gpiod_get currently has an optional parameter to set initial
direction and value for the requested gpio. Make use of this to simplify
the driver and make it not fail to build when this parameter is made
mandatory (which is scheduled for 4.3-rc1).

Moreover use the _optional variant of devm_gpiod_get to simplify error
handling (which also gets more strict for free).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
Uwe Kleine-König 2015-08-12 09:20:56 +02:00 коммит произвёл Marcel Holtmann
Родитель ea9eb698b2
Коммит 62aaefa7d0
1 изменённых файлов: 9 добавлений и 15 удалений

Просмотреть файл

@ -408,7 +408,6 @@ static int bcm_acpi_probe(struct bcm_device *dev)
{ {
struct platform_device *pdev = dev->pdev; struct platform_device *pdev = dev->pdev;
const struct acpi_device_id *id; const struct acpi_device_id *id;
struct gpio_desc *gpio;
struct acpi_device *adev; struct acpi_device *adev;
LIST_HEAD(resources); LIST_HEAD(resources);
int ret; int ret;
@ -426,21 +425,16 @@ static int bcm_acpi_probe(struct bcm_device *dev)
dev->clk = devm_clk_get(&pdev->dev, NULL); dev->clk = devm_clk_get(&pdev->dev, NULL);
gpio = devm_gpiod_get(&pdev->dev, "device-wakeup"); dev->device_wakeup = devm_gpiod_get_optional(&pdev->dev,
if (!IS_ERR(gpio)) { "device-wakeup",
ret = gpiod_direction_output(gpio, 0); GPIOD_OUT_LOW);
if (ret) if (IS_ERR(dev->device_wakeup))
return ret; return PTR_ERR(dev->device_wakeup);
dev->device_wakeup = gpio;
}
gpio = devm_gpiod_get(&pdev->dev, "shutdown"); dev->shutdown = devm_gpiod_get_optional(&pdev->dev, "shutdown",
if (!IS_ERR(gpio)) { GPIOD_OUT_LOW);
ret = gpiod_direction_output(gpio, 0); if (IS_ERR(dev->shutdown))
if (ret) return PTR_ERR(dev->shutdown);
return ret;
dev->shutdown = gpio;
}
/* Make sure at-least one of the GPIO is defined and that /* Make sure at-least one of the GPIO is defined and that
* a name is specified for this instance * a name is specified for this instance