Skip to content

Commit 3ee0d39

Browse files
andy-shevbroonie
authored andcommitted
ASoC: soc-ac97: Convert to agnostic GPIO API
The of_gpio.h is going to be removed. In preparation of that convert the driver to the agnostic API. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 0438499 commit 3ee0d39

File tree

1 file changed

+22
-46
lines changed

1 file changed

+22
-46
lines changed

sound/soc/soc-ac97.c

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
#include <linux/ctype.h>
1515
#include <linux/delay.h>
1616
#include <linux/export.h>
17-
#include <linux/gpio.h>
17+
#include <linux/gpio/consumer.h>
1818
#include <linux/gpio/driver.h>
1919
#include <linux/init.h>
20-
#include <linux/of_gpio.h>
2120
#include <linux/of.h>
2221
#include <linux/pinctrl/consumer.h>
2322
#include <linux/slab.h>
@@ -29,9 +28,9 @@ struct snd_ac97_reset_cfg {
2928
struct pinctrl_state *pstate_reset;
3029
struct pinctrl_state *pstate_warm_reset;
3130
struct pinctrl_state *pstate_run;
32-
int gpio_sdata;
33-
int gpio_sync;
34-
int gpio_reset;
31+
struct gpio_desc *reset_gpio;
32+
struct gpio_desc *sdata_gpio;
33+
struct gpio_desc *sync_gpio;
3534
};
3635

3736
static struct snd_ac97_bus soc_ac97_bus = {
@@ -268,11 +267,11 @@ static void snd_soc_ac97_warm_reset(struct snd_ac97 *ac97)
268267

269268
pinctrl_select_state(pctl, snd_ac97_rst_cfg.pstate_warm_reset);
270269

271-
gpio_direction_output(snd_ac97_rst_cfg.gpio_sync, 1);
270+
gpiod_direction_output_raw(snd_ac97_rst_cfg.sync_gpio, 1);
272271

273272
udelay(10);
274273

275-
gpio_direction_output(snd_ac97_rst_cfg.gpio_sync, 0);
274+
gpiod_direction_output_raw(snd_ac97_rst_cfg.sync_gpio, 0);
276275

277276
pinctrl_select_state(pctl, snd_ac97_rst_cfg.pstate_run);
278277
msleep(2);
@@ -284,13 +283,13 @@ static void snd_soc_ac97_reset(struct snd_ac97 *ac97)
284283

285284
pinctrl_select_state(pctl, snd_ac97_rst_cfg.pstate_reset);
286285

287-
gpio_direction_output(snd_ac97_rst_cfg.gpio_sync, 0);
288-
gpio_direction_output(snd_ac97_rst_cfg.gpio_sdata, 0);
289-
gpio_direction_output(snd_ac97_rst_cfg.gpio_reset, 0);
286+
gpiod_direction_output_raw(snd_ac97_rst_cfg.sync_gpio, 0);
287+
gpiod_direction_output_raw(snd_ac97_rst_cfg.sdata_gpio, 0);
288+
gpiod_direction_output_raw(snd_ac97_rst_cfg.reset_gpio, 0);
290289

291290
udelay(10);
292291

293-
gpio_direction_output(snd_ac97_rst_cfg.gpio_reset, 1);
292+
gpiod_direction_output_raw(snd_ac97_rst_cfg.reset_gpio, 1);
294293

295294
pinctrl_select_state(pctl, snd_ac97_rst_cfg.pstate_run);
296295
msleep(2);
@@ -301,8 +300,6 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev,
301300
{
302301
struct pinctrl *p;
303302
struct pinctrl_state *state;
304-
int gpio;
305-
int ret;
306303

307304
p = devm_pinctrl_get(dev);
308305
if (IS_ERR(p)) {
@@ -332,41 +329,20 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev,
332329
}
333330
cfg->pstate_run = state;
334331

335-
gpio = of_get_named_gpio(dev->of_node, "ac97-gpios", 0);
336-
if (gpio < 0) {
337-
dev_err(dev, "Can't find ac97-sync gpio\n");
338-
return gpio;
339-
}
340-
ret = devm_gpio_request(dev, gpio, "AC97 link sync");
341-
if (ret) {
342-
dev_err(dev, "Failed requesting ac97-sync gpio\n");
343-
return ret;
344-
}
345-
cfg->gpio_sync = gpio;
332+
cfg->sync_gpio = devm_gpiod_get_index(dev, "ac97", 0, GPIOD_ASIS);
333+
if (IS_ERR(cfg->sync_gpio))
334+
return dev_err_probe(dev, PTR_ERR(cfg->sync_gpio), "Can't find ac97-sync gpio\n");
335+
gpiod_set_consumer_name(cfg->sync_gpio, "AC97 link sync");
346336

347-
gpio = of_get_named_gpio(dev->of_node, "ac97-gpios", 1);
348-
if (gpio < 0) {
349-
dev_err(dev, "Can't find ac97-sdata gpio %d\n", gpio);
350-
return gpio;
351-
}
352-
ret = devm_gpio_request(dev, gpio, "AC97 link sdata");
353-
if (ret) {
354-
dev_err(dev, "Failed requesting ac97-sdata gpio\n");
355-
return ret;
356-
}
357-
cfg->gpio_sdata = gpio;
337+
cfg->sdata_gpio = devm_gpiod_get_index(dev, "ac97", 1, GPIOD_ASIS);
338+
if (IS_ERR(cfg->sdata_gpio))
339+
return dev_err_probe(dev, PTR_ERR(cfg->sync_gpio), "Can't find ac97-sdata gpio\n");
340+
gpiod_set_consumer_name(cfg->sdata_gpio, "AC97 link sdata");
358341

359-
gpio = of_get_named_gpio(dev->of_node, "ac97-gpios", 2);
360-
if (gpio < 0) {
361-
dev_err(dev, "Can't find ac97-reset gpio\n");
362-
return gpio;
363-
}
364-
ret = devm_gpio_request(dev, gpio, "AC97 link reset");
365-
if (ret) {
366-
dev_err(dev, "Failed requesting ac97-reset gpio\n");
367-
return ret;
368-
}
369-
cfg->gpio_reset = gpio;
342+
cfg->reset_gpio = devm_gpiod_get_index(dev, "ac97", 2, GPIOD_ASIS);
343+
if (IS_ERR(cfg->reset_gpio))
344+
return dev_err_probe(dev, PTR_ERR(cfg->sync_gpio), "Can't find ac97-reset gpio\n");
345+
gpiod_set_consumer_name(cfg->reset_gpio, "AC97 link reset");
370346

371347
return 0;
372348
}

0 commit comments

Comments
 (0)