summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTzung-Bi Shih <tzungbi@google.com>2019-05-08 23:04:54 -0400
committerMark Brown <broonie@kernel.org>2019-05-13 07:43:29 -0400
commitbcd9382288af236321c83d27b0db196bf8814559 (patch)
tree1196a9f92a8086d84e7831c1ea0e67d39e9c0ea7
parent630be964b5d8d37d3dff9fc5c8af8a516aa94af0 (diff)
ASoC: max98357a: request GPIO when device get probed
devm_gpiod_get_optional() returns EBUSY after component rebound. Request GPIO in max98357a_platform_probe() to support component rebinding. Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/max98357a.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c
index d037a3e4d323..80080a6415b3 100644
--- a/sound/soc/codecs/max98357a.c
+++ b/sound/soc/codecs/max98357a.c
@@ -59,21 +59,7 @@ static const struct snd_soc_dapm_route max98357a_dapm_routes[] = {
59 {"Speaker", NULL, "HiFi Playback"}, 59 {"Speaker", NULL, "HiFi Playback"},
60}; 60};
61 61
62static int max98357a_component_probe(struct snd_soc_component *component)
63{
64 struct gpio_desc *sdmode;
65
66 sdmode = devm_gpiod_get_optional(component->dev, "sdmode", GPIOD_OUT_LOW);
67 if (IS_ERR(sdmode))
68 return PTR_ERR(sdmode);
69
70 snd_soc_component_set_drvdata(component, sdmode);
71
72 return 0;
73}
74
75static const struct snd_soc_component_driver max98357a_component_driver = { 62static const struct snd_soc_component_driver max98357a_component_driver = {
76 .probe = max98357a_component_probe,
77 .dapm_widgets = max98357a_dapm_widgets, 63 .dapm_widgets = max98357a_dapm_widgets,
78 .num_dapm_widgets = ARRAY_SIZE(max98357a_dapm_widgets), 64 .num_dapm_widgets = ARRAY_SIZE(max98357a_dapm_widgets),
79 .dapm_routes = max98357a_dapm_routes, 65 .dapm_routes = max98357a_dapm_routes,
@@ -112,16 +98,20 @@ static struct snd_soc_dai_driver max98357a_dai_driver = {
112 98
113static int max98357a_platform_probe(struct platform_device *pdev) 99static int max98357a_platform_probe(struct platform_device *pdev)
114{ 100{
101 struct gpio_desc *sdmode;
102
103 sdmode = devm_gpiod_get_optional(&pdev->dev,
104 "sdmode", GPIOD_OUT_LOW);
105 if (IS_ERR(sdmode))
106 return PTR_ERR(sdmode);
107
108 dev_set_drvdata(&pdev->dev, sdmode);
109
115 return devm_snd_soc_register_component(&pdev->dev, 110 return devm_snd_soc_register_component(&pdev->dev,
116 &max98357a_component_driver, 111 &max98357a_component_driver,
117 &max98357a_dai_driver, 1); 112 &max98357a_dai_driver, 1);
118} 113}
119 114
120static int max98357a_platform_remove(struct platform_device *pdev)
121{
122 return 0;
123}
124
125#ifdef CONFIG_OF 115#ifdef CONFIG_OF
126static const struct of_device_id max98357a_device_id[] = { 116static const struct of_device_id max98357a_device_id[] = {
127 { .compatible = "maxim,max98357a" }, 117 { .compatible = "maxim,max98357a" },
@@ -145,7 +135,6 @@ static struct platform_driver max98357a_platform_driver = {
145 .acpi_match_table = ACPI_PTR(max98357a_acpi_match), 135 .acpi_match_table = ACPI_PTR(max98357a_acpi_match),
146 }, 136 },
147 .probe = max98357a_platform_probe, 137 .probe = max98357a_platform_probe,
148 .remove = max98357a_platform_remove,
149}; 138};
150module_platform_driver(max98357a_platform_driver); 139module_platform_driver(max98357a_platform_driver);
151 140