.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * AK4104 ALSA SoC (ASoC) driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify it |
---|
7 | | - * under the terms of the GNU General Public License as published by the |
---|
8 | | - * Free Software Foundation; either version 2 of the License, or (at your |
---|
9 | | - * option) any later version. |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/module.h> |
---|
13 | 9 | #include <linux/slab.h> |
---|
14 | 10 | #include <linux/spi/spi.h> |
---|
15 | 11 | #include <linux/of_device.h> |
---|
16 | | -#include <linux/of_gpio.h> |
---|
| 12 | +#include <linux/gpio/consumer.h> |
---|
17 | 13 | #include <linux/regulator/consumer.h> |
---|
18 | 14 | #include <sound/asoundef.h> |
---|
19 | 15 | #include <sound/core.h> |
---|
.. | .. |
---|
268 | 264 | |
---|
269 | 265 | static int ak4104_spi_probe(struct spi_device *spi) |
---|
270 | 266 | { |
---|
271 | | - struct device_node *np = spi->dev.of_node; |
---|
272 | 267 | struct ak4104_private *ak4104; |
---|
| 268 | + struct gpio_desc *reset_gpiod; |
---|
273 | 269 | unsigned int val; |
---|
274 | 270 | int ret; |
---|
275 | 271 | |
---|
.. | .. |
---|
297 | 293 | return ret; |
---|
298 | 294 | } |
---|
299 | 295 | |
---|
300 | | - if (np) { |
---|
301 | | - enum of_gpio_flags flags; |
---|
302 | | - int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags); |
---|
303 | | - |
---|
304 | | - if (gpio_is_valid(gpio)) { |
---|
305 | | - ret = devm_gpio_request_one(&spi->dev, gpio, |
---|
306 | | - flags & OF_GPIO_ACTIVE_LOW ? |
---|
307 | | - GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH, |
---|
308 | | - "ak4104 reset"); |
---|
309 | | - if (ret < 0) |
---|
310 | | - return ret; |
---|
311 | | - } |
---|
312 | | - } |
---|
| 296 | + reset_gpiod = devm_gpiod_get_optional(&spi->dev, "reset", |
---|
| 297 | + GPIOD_OUT_HIGH); |
---|
| 298 | + if (PTR_ERR(reset_gpiod) == -EPROBE_DEFER) |
---|
| 299 | + return -EPROBE_DEFER; |
---|
313 | 300 | |
---|
314 | 301 | /* read the 'reserved' register - according to the datasheet, it |
---|
315 | 302 | * should contain 0x5b. Not a good way to verify the presence of |
---|