|
6 | 6 | //
|
7 | 7 | // Author: Herve Codina <[email protected]>
|
8 | 8 |
|
| 9 | +#include <linux/cleanup.h> |
9 | 10 | #include <linux/iio/consumer.h>
|
10 | 11 | #include <linux/minmax.h>
|
11 | 12 | #include <linux/mod_devicetable.h>
|
@@ -131,51 +132,36 @@ static int audio_iio_aux_add_dapms(struct snd_soc_component *component,
|
131 | 132 | struct audio_iio_aux_chan *chan)
|
132 | 133 | {
|
133 | 134 | struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
|
134 |
| - char *output_name; |
135 |
| - char *input_name; |
136 |
| - char *pga_name; |
137 | 135 | int ret;
|
138 | 136 |
|
139 |
| - input_name = kasprintf(GFP_KERNEL, "%s IN", chan->name); |
| 137 | + /* Allocated names are not needed afterwards (duplicated in ASoC internals) */ |
| 138 | + char *input_name __free(kfree) = kasprintf(GFP_KERNEL, "%s IN", chan->name); |
140 | 139 | if (!input_name)
|
141 | 140 | return -ENOMEM;
|
142 | 141 |
|
143 |
| - output_name = kasprintf(GFP_KERNEL, "%s OUT", chan->name); |
144 |
| - if (!output_name) { |
145 |
| - ret = -ENOMEM; |
146 |
| - goto out_free_input_name; |
147 |
| - } |
| 142 | + char *output_name __free(kfree) = kasprintf(GFP_KERNEL, "%s OUT", chan->name); |
| 143 | + if (!output_name) |
| 144 | + return -ENOMEM; |
148 | 145 |
|
149 |
| - pga_name = kasprintf(GFP_KERNEL, "%s PGA", chan->name); |
150 |
| - if (!pga_name) { |
151 |
| - ret = -ENOMEM; |
152 |
| - goto out_free_output_name; |
153 |
| - } |
| 146 | + char *pga_name __free(kfree) = kasprintf(GFP_KERNEL, "%s PGA", chan->name); |
| 147 | + if (!pga_name) |
| 148 | + return -ENOMEM; |
154 | 149 |
|
155 | 150 | widgets[0] = SND_SOC_DAPM_INPUT(input_name);
|
156 | 151 | widgets[1] = SND_SOC_DAPM_OUTPUT(output_name);
|
157 | 152 | widgets[2] = SND_SOC_DAPM_PGA(pga_name, SND_SOC_NOPM, 0, 0, NULL, 0);
|
158 | 153 | ret = snd_soc_dapm_new_controls(dapm, widgets, 3);
|
159 | 154 | if (ret)
|
160 |
| - goto out_free_pga_name; |
| 155 | + return ret; |
161 | 156 |
|
162 | 157 | routes[0].sink = pga_name;
|
163 | 158 | routes[0].control = NULL;
|
164 | 159 | routes[0].source = input_name;
|
165 | 160 | routes[1].sink = output_name;
|
166 | 161 | routes[1].control = NULL;
|
167 | 162 | routes[1].source = pga_name;
|
168 |
| - ret = snd_soc_dapm_add_routes(dapm, routes, 2); |
169 | 163 |
|
170 |
| - /* Allocated names are no more needed (duplicated in ASoC internals) */ |
171 |
| - |
172 |
| -out_free_pga_name: |
173 |
| - kfree(pga_name); |
174 |
| -out_free_output_name: |
175 |
| - kfree(output_name); |
176 |
| -out_free_input_name: |
177 |
| - kfree(input_name); |
178 |
| - return ret; |
| 164 | + return snd_soc_dapm_add_routes(dapm, routes, 2); |
179 | 165 | }
|
180 | 166 |
|
181 | 167 | static int audio_iio_aux_component_probe(struct snd_soc_component *component)
|
|
0 commit comments