ASoC: codecs: ak4104: move to GPIO consumer API

Get the reset GPIO through the GPIO consumer API. This allows specifying the
DT property as "reset-gpios" without breaking existing DT users.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Daniel Mack 2018-12-06 13:24:57 +01:00 committed by Mark Brown
parent db097f95b4
commit d8f2c8592b
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 7 additions and 15 deletions

View File

@ -13,7 +13,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_gpio.h> #include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <sound/asoundef.h> #include <sound/asoundef.h>
#include <sound/core.h> #include <sound/core.h>
@ -268,8 +268,8 @@ static const struct regmap_config ak4104_regmap = {
static int ak4104_spi_probe(struct spi_device *spi) static int ak4104_spi_probe(struct spi_device *spi)
{ {
struct device_node *np = spi->dev.of_node;
struct ak4104_private *ak4104; struct ak4104_private *ak4104;
struct gpio_desc *reset_gpiod;
unsigned int val; unsigned int val;
int ret; int ret;
@ -297,19 +297,11 @@ static int ak4104_spi_probe(struct spi_device *spi)
return ret; return ret;
} }
if (np) { reset_gpiod = devm_gpiod_get_optional(&spi->dev, "reset",
enum of_gpio_flags flags; GPIOD_OUT_HIGH);
int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags); if (IS_ERR(reset_gpiod) &&
PTR_ERR(reset_gpiod) == -EPROBE_DEFER)
if (gpio_is_valid(gpio)) { return -EPROBE_DEFER;
ret = devm_gpio_request_one(&spi->dev, gpio,
flags & OF_GPIO_ACTIVE_LOW ?
GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH,
"ak4104 reset");
if (ret < 0)
return ret;
}
}
/* read the 'reserved' register - according to the datasheet, it /* read the 'reserved' register - according to the datasheet, it
* should contain 0x5b. Not a good way to verify the presence of * should contain 0x5b. Not a good way to verify the presence of