Skip to content

Commit ef5aa8b

Browse files
linuswbroonie
authored andcommitted
ASoC: pcm3008: Convert to GPIO descriptors
This converts the PCM3008 driver to look up the GPIO lines using descriptors. Apparently there are no in-tree users of the platform data struct, so users need to adopt. New users can associate the GPIO lines with the platform device "pcm3008-codec". Signed-off-by: Linus Walleij <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 98dba9d commit ef5aa8b

File tree

2 files changed

+32
-48
lines changed

2 files changed

+32
-48
lines changed

sound/soc/codecs/pcm3008.c

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,30 @@
1414
#include <linux/init.h>
1515
#include <linux/kernel.h>
1616
#include <linux/device.h>
17-
#include <linux/gpio.h>
17+
#include <linux/gpio/consumer.h>
1818
#include <linux/slab.h>
1919
#include <linux/module.h>
2020
#include <sound/core.h>
2121
#include <sound/pcm.h>
2222
#include <sound/initval.h>
2323
#include <sound/soc.h>
2424

25-
#include "pcm3008.h"
25+
struct pcm3008 {
26+
struct gpio_desc *dem0_pin;
27+
struct gpio_desc *dem1_pin;
28+
struct gpio_desc *pdad_pin;
29+
struct gpio_desc *pdda_pin;
30+
};
2631

2732
static int pcm3008_dac_ev(struct snd_soc_dapm_widget *w,
2833
struct snd_kcontrol *kcontrol,
2934
int event)
3035
{
3136
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
32-
struct pcm3008_setup_data *setup = component->dev->platform_data;
37+
struct pcm3008 *pcm = component->dev->platform_data;
3338

34-
gpio_set_value_cansleep(setup->pdda_pin,
35-
SND_SOC_DAPM_EVENT_ON(event));
39+
gpiod_set_value_cansleep(pcm->pdda_pin,
40+
SND_SOC_DAPM_EVENT_ON(event));
3641

3742
return 0;
3843
}
@@ -42,10 +47,10 @@ static int pcm3008_adc_ev(struct snd_soc_dapm_widget *w,
4247
int event)
4348
{
4449
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
45-
struct pcm3008_setup_data *setup = component->dev->platform_data;
50+
struct pcm3008 *pcm = component->dev->platform_data;
4651

47-
gpio_set_value_cansleep(setup->pdad_pin,
48-
SND_SOC_DAPM_EVENT_ON(event));
52+
gpiod_set_value_cansleep(pcm->pdad_pin,
53+
SND_SOC_DAPM_EVENT_ON(event));
4954

5055
return 0;
5156
}
@@ -106,11 +111,13 @@ static const struct snd_soc_component_driver soc_component_dev_pcm3008 = {
106111

107112
static int pcm3008_codec_probe(struct platform_device *pdev)
108113
{
109-
struct pcm3008_setup_data *setup = pdev->dev.platform_data;
110-
int ret;
114+
struct device *dev = &pdev->dev;
115+
struct pcm3008 *pcm;
111116

112-
if (!setup)
113-
return -EINVAL;
117+
pcm = devm_kzalloc(dev, sizeof(*pcm), GFP_KERNEL);
118+
if (!pcm)
119+
return -ENOMEM;
120+
platform_set_drvdata(pdev, pcm);
114121

115122
/* DEM1 DEM0 DE-EMPHASIS_MODE
116123
* Low Low De-emphasis 44.1 kHz ON
@@ -120,30 +127,26 @@ static int pcm3008_codec_probe(struct platform_device *pdev)
120127
*/
121128

122129
/* Configure DEM0 GPIO (turning OFF DAC De-emphasis). */
123-
ret = devm_gpio_request_one(&pdev->dev, setup->dem0_pin,
124-
GPIOF_OUT_INIT_HIGH, "codec_dem0");
125-
if (ret != 0)
126-
return ret;
130+
pcm->dem0_pin = devm_gpiod_get(dev, "dem0", GPIOD_OUT_HIGH);
131+
if (IS_ERR(pcm->dem0_pin))
132+
return PTR_ERR(pcm->dem0_pin);
127133

128134
/* Configure DEM1 GPIO (turning OFF DAC De-emphasis). */
129-
ret = devm_gpio_request_one(&pdev->dev, setup->dem1_pin,
130-
GPIOF_OUT_INIT_LOW, "codec_dem1");
131-
if (ret != 0)
132-
return ret;
135+
pcm->dem1_pin = devm_gpiod_get(dev, "dem1", GPIOD_OUT_LOW);
136+
if (IS_ERR(pcm->dem1_pin))
137+
return PTR_ERR(pcm->dem1_pin);
133138

134139
/* Configure PDAD GPIO. */
135-
ret = devm_gpio_request_one(&pdev->dev, setup->pdad_pin,
136-
GPIOF_OUT_INIT_LOW, "codec_pdad");
137-
if (ret != 0)
138-
return ret;
140+
pcm->pdad_pin = devm_gpiod_get(dev, "pdad", GPIOD_OUT_LOW);
141+
if (IS_ERR(pcm->pdad_pin))
142+
return PTR_ERR(pcm->pdad_pin);
139143

140144
/* Configure PDDA GPIO. */
141-
ret = devm_gpio_request_one(&pdev->dev, setup->pdda_pin,
142-
GPIOF_OUT_INIT_LOW, "codec_pdda");
143-
if (ret != 0)
144-
return ret;
145+
pcm->pdda_pin = devm_gpiod_get(dev, "pdda", GPIOD_OUT_LOW);
146+
if (IS_ERR(pcm->pdda_pin))
147+
return PTR_ERR(pcm->pdda_pin);
145148

146-
return devm_snd_soc_register_component(&pdev->dev,
149+
return devm_snd_soc_register_component(dev,
147150
&soc_component_dev_pcm3008, &pcm3008_dai, 1);
148151
}
149152

sound/soc/codecs/pcm3008.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)