14
14
#include <linux/init.h>
15
15
#include <linux/kernel.h>
16
16
#include <linux/device.h>
17
- #include <linux/gpio.h>
17
+ #include <linux/gpio/consumer .h>
18
18
#include <linux/slab.h>
19
19
#include <linux/module.h>
20
20
#include <sound/core.h>
21
21
#include <sound/pcm.h>
22
22
#include <sound/initval.h>
23
23
#include <sound/soc.h>
24
24
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
+ };
26
31
27
32
static int pcm3008_dac_ev (struct snd_soc_dapm_widget * w ,
28
33
struct snd_kcontrol * kcontrol ,
29
34
int event )
30
35
{
31
36
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 ;
33
38
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 ));
36
41
37
42
return 0 ;
38
43
}
@@ -42,10 +47,10 @@ static int pcm3008_adc_ev(struct snd_soc_dapm_widget *w,
42
47
int event )
43
48
{
44
49
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 ;
46
51
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 ));
49
54
50
55
return 0 ;
51
56
}
@@ -106,11 +111,13 @@ static const struct snd_soc_component_driver soc_component_dev_pcm3008 = {
106
111
107
112
static int pcm3008_codec_probe (struct platform_device * pdev )
108
113
{
109
- struct pcm3008_setup_data * setup = pdev -> dev . platform_data ;
110
- int ret ;
114
+ struct device * dev = & pdev -> dev ;
115
+ struct pcm3008 * pcm ;
111
116
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 );
114
121
115
122
/* DEM1 DEM0 DE-EMPHASIS_MODE
116
123
* Low Low De-emphasis 44.1 kHz ON
@@ -120,30 +127,26 @@ static int pcm3008_codec_probe(struct platform_device *pdev)
120
127
*/
121
128
122
129
/* 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 );
127
133
128
134
/* 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 );
133
138
134
139
/* 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 );
139
143
140
144
/* 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 );
145
148
146
- return devm_snd_soc_register_component (& pdev -> dev ,
149
+ return devm_snd_soc_register_component (dev ,
147
150
& soc_component_dev_pcm3008 , & pcm3008_dai , 1 );
148
151
}
149
152
0 commit comments