Skip to content

Commit e0466e6

Browse files
povikjannau
authored andcommitted
ASoC: macaudio: Tune DT parsing error messages
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
1 parent fa81d25 commit e0466e6

1 file changed

Lines changed: 31 additions & 17 deletions

File tree

sound/soc/apple/macaudio.c

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,14 @@ static int macaudio_parse_of_be_dai_link(struct macaudio_snd_data *ma,
206206
for_each_link_codecs(link, i, comp) {
207207
ret = macaudio_parse_of_component(codec, codec_base + i, comp);
208208
if (ret)
209-
return ret;
209+
return dev_err_probe(ma->card.dev, ret, "parsing CODEC DAI of link '%s' at %pOF\n",
210+
link->name, codec);
210211
}
211212

212213
ret = macaudio_parse_of_component(cpu, be_index, link->cpus);
213214
if (ret)
214-
return ret;
215+
return dev_err_probe(ma->card.dev, ret, "parsing CPU DAI of link '%s' at %pOF\n",
216+
link->name, codec);
215217

216218
link->name = link->cpus[0].dai_name;
217219

@@ -232,7 +234,7 @@ static int macaudio_parse_of(struct macaudio_snd_data *ma)
232234

233235
ret = snd_soc_of_parse_card_name(card, "model");
234236
if (ret) {
235-
dev_err(dev, "Error parsing card name: %d\n", ret);
237+
dev_err_probe(dev, ret, "parsing card name\n");
236238
return ret;
237239
}
238240

@@ -245,17 +247,17 @@ static int macaudio_parse_of(struct macaudio_snd_data *ma)
245247

246248
cpu = of_get_child_by_name(np, "cpu");
247249
if (!cpu) {
248-
dev_err(dev, "missing CPU DAI node at %pOF\n", np);
249-
ret = -EINVAL;
250+
ret = dev_err_probe(dev, -EINVAL,
251+
"missing CPU DAI node at %pOF\n", np);
250252
goto err_free;
251253
}
252254

253255
num_cpus = of_count_phandle_with_args(cpu, "sound-dai",
254256
"#sound-dai-cells");
255257

256258
if (num_cpus <= 0) {
257-
dev_err(card->dev, "missing sound-dai property at %pOF\n", cpu);
258-
ret = -EINVAL;
259+
ret = dev_err_probe(card->dev, -EINVAL,
260+
"missing sound-dai property at %pOF\n", cpu);
259261
goto err_free;
260262
}
261263
of_node_put(cpu);
@@ -296,10 +298,12 @@ static int macaudio_parse_of(struct macaudio_snd_data *ma)
296298

297299
ret = of_property_read_string(np, "link-name", &link_name);
298300
if (ret) {
299-
dev_err(card->dev, "missing link name\n");
301+
dev_err_probe(card->dev, ret, "missing link name\n");
300302
goto err_free;
301303
}
302304

305+
dev_dbg(ma->card.dev, "parsing link '%s'\n", link_name);
306+
303307
speakers = !strcmp(link_name, "Speaker")
304308
|| !strcmp(link_name, "Speakers");
305309
if (speakers)
@@ -309,31 +313,34 @@ static int macaudio_parse_of(struct macaudio_snd_data *ma)
309313
codec = of_get_child_by_name(np, "codec");
310314

311315
if (!codec || !cpu) {
312-
dev_err(dev, "missing DAI specifications for '%s'\n", link_name);
313-
ret = -EINVAL;
316+
ret = dev_err_probe(dev, -EINVAL,
317+
"missing DAI specifications for '%s'\n", link_name);
314318
goto err_free;
315319
}
316320

317321
num_bes = of_count_phandle_with_args(cpu, "sound-dai",
318322
"#sound-dai-cells");
319323
if (num_bes <= 0) {
320-
dev_err(card->dev, "missing sound-dai property at %pOF\n", cpu);
321-
ret = -EINVAL;
324+
ret = dev_err_probe(card->dev, -EINVAL,
325+
"missing sound-dai property at %pOF\n", cpu);
322326
goto err_free;
323327
}
324328

325329
num_codecs = of_count_phandle_with_args(codec, "sound-dai",
326330
"#sound-dai-cells");
327331
if (num_codecs <= 0) {
328-
dev_err(card->dev, "missing sound-dai property at %pOF\n", codec);
329-
ret = -EINVAL;
332+
ret = dev_err_probe(card->dev, -EINVAL,
333+
"missing sound-dai property at %pOF\n", codec);
330334
goto err_free;
331335
}
332336

337+
dev_dbg(ma->card.dev, "link '%s': %d CPUs %d CODECs\n",
338+
link_name, num_bes, num_codecs);
339+
333340
if (num_codecs % num_bes != 0) {
334-
dev_err(card->dev, "bad combination of CODEC (%d) and CPU (%d) number at %pOF\n",
341+
ret = dev_err_probe(card->dev, -EINVAL,
342+
"bad combination of CODEC (%d) and CPU (%d) number at %pOF\n",
335343
num_codecs, num_bes, np);
336-
ret = -EINVAL;
337344
goto err_free;
338345
}
339346

@@ -363,6 +370,13 @@ static int macaudio_parse_of(struct macaudio_snd_data *ma)
363370
right_mask = left_mask << 1;
364371

365372
for (be_index = 0; be_index < num_bes; be_index++) {
373+
/*
374+
* Set initial link name to be overwritten by a BE-specific
375+
* name later so that we can use at least use the provisional
376+
* name in error messages.
377+
*/
378+
link->name = link_name;
379+
366380
ret = macaudio_parse_of_be_dai_link(ma, link, be_index,
367381
ncodecs_per_cpu, cpu, codec);
368382
if (ret)
@@ -994,7 +1008,7 @@ static int macaudio_snd_platform_probe(struct platform_device *pdev)
9941008

9951009
ret = macaudio_parse_of(data);
9961010
if (ret)
997-
return dev_err_probe(&pdev->dev, ret, "failed OF parsing\n");
1011+
return ret;
9981012

9991013
for_each_card_prelinks(card, i, link) {
10001014
if (link->no_pcm) {

0 commit comments

Comments
 (0)