Skip to content

Commit c4bb7dc

Browse files
agarwalvaibhavgregkh
authored andcommitted
staging: greybus: audio: Resolve compilation error in topology parser
Fix compilation errors for GB Audio topology parser code with recent kernel versions. Signed-off-by: Vaibhav Agarwal <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/2542330352ae1d01469a616ea45edb461615e072.1594290158.git.vaibhav.sr@gmail.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ce7bd83 commit c4bb7dc

File tree

1 file changed

+57
-66
lines changed

1 file changed

+57
-66
lines changed

drivers/staging/greybus/audio_topology.c

Lines changed: 57 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* Copyright 2015-2016 Linaro Ltd.
66
*/
77

8+
#include <linux/greybus.h>
89
#include "audio_codec.h"
9-
#include "greybus_protocols.h"
1010

1111
#define GBAUDIO_INVALID_ID 0xFF
1212

@@ -165,15 +165,15 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
165165
struct gbaudio_ctl_pvt *data;
166166
struct gb_audio_ctl_elem_info *info;
167167
struct gbaudio_module_info *module;
168-
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
169-
struct gbaudio_codec_info *gbcodec = snd_soc_codec_get_drvdata(codec);
168+
struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
169+
struct gbaudio_codec_info *gbcodec = snd_soc_component_get_drvdata(comp);
170170

171-
dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
171+
dev_dbg(comp->dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
172172
data = (struct gbaudio_ctl_pvt *)kcontrol->private_value;
173173
info = (struct gb_audio_ctl_elem_info *)data->info;
174174

175175
if (!info) {
176-
dev_err(codec->dev, "NULL info for %s\n", uinfo->id.name);
176+
dev_err(comp->dev, "NULL info for %s\n", uinfo->id.name);
177177
return -EINVAL;
178178
}
179179

@@ -201,7 +201,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
201201
strlcpy(uinfo->value.enumerated.name, name, NAME_SIZE);
202202
break;
203203
default:
204-
dev_err(codec->dev, "Invalid type: %d for %s:kcontrol\n",
204+
dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n",
205205
info->type, kcontrol->id.name);
206206
break;
207207
}
@@ -216,11 +216,11 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol,
216216
struct gbaudio_ctl_pvt *data;
217217
struct gb_audio_ctl_elem_value gbvalue;
218218
struct gbaudio_module_info *module;
219-
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
220-
struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec);
219+
struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
220+
struct gbaudio_codec_info *gb = snd_soc_component_get_drvdata(comp);
221221
struct gb_bundle *bundle;
222222

223-
dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
223+
dev_dbg(comp->dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
224224
module = find_gb_module(gb, kcontrol->id.name);
225225
if (!module)
226226
return -EINVAL;
@@ -239,7 +239,7 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol,
239239
gb_pm_runtime_put_autosuspend(bundle);
240240

241241
if (ret) {
242-
dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret,
242+
dev_err_ratelimited(comp->dev, "%d:Error in %s for %s\n", ret,
243243
__func__, kcontrol->id.name);
244244
return ret;
245245
}
@@ -262,7 +262,7 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol,
262262
le32_to_cpu(gbvalue.value.enumerated_item[1]);
263263
break;
264264
default:
265-
dev_err(codec->dev, "Invalid type: %d for %s:kcontrol\n",
265+
dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n",
266266
info->type, kcontrol->id.name);
267267
ret = -EINVAL;
268268
break;
@@ -278,11 +278,11 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol,
278278
struct gbaudio_ctl_pvt *data;
279279
struct gb_audio_ctl_elem_value gbvalue;
280280
struct gbaudio_module_info *module;
281-
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
282-
struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec);
281+
struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
282+
struct gbaudio_codec_info *gb = snd_soc_component_get_drvdata(comp);
283283
struct gb_bundle *bundle;
284284

285-
dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
285+
dev_dbg(comp->dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
286286
module = find_gb_module(gb, kcontrol->id.name);
287287
if (!module)
288288
return -EINVAL;
@@ -309,7 +309,7 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol,
309309
cpu_to_le32(ucontrol->value.enumerated.item[1]);
310310
break;
311311
default:
312-
dev_err(codec->dev, "Invalid type: %d for %s:kcontrol\n",
312+
dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n",
313313
info->type, kcontrol->id.name);
314314
ret = -EINVAL;
315315
break;
@@ -328,7 +328,7 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol,
328328
gb_pm_runtime_put_autosuspend(bundle);
329329

330330
if (ret) {
331-
dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret,
331+
dev_err_ratelimited(comp->dev, "%d:Error in %s for %s\n", ret,
332332
__func__, kcontrol->id.name);
333333
}
334334

@@ -352,11 +352,7 @@ static int gbcodec_mixer_dapm_ctl_info(struct snd_kcontrol *kcontrol,
352352
int platform_max, platform_min;
353353
struct gbaudio_ctl_pvt *data;
354354
struct gb_audio_ctl_elem_info *info;
355-
struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
356-
struct snd_soc_dapm_widget *widget = wlist->widgets[0];
357-
struct snd_soc_codec *codec = widget->codec;
358355

359-
dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
360356
data = (struct gbaudio_ctl_pvt *)kcontrol->private_value;
361357
info = (struct gb_audio_ctl_elem_info *)data->info;
362358

@@ -387,11 +383,11 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol,
387383
struct gbaudio_module_info *module;
388384
struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
389385
struct snd_soc_dapm_widget *widget = wlist->widgets[0];
390-
struct snd_soc_codec *codec = widget->codec;
391-
struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec);
386+
struct device *codec_dev = widget->dapm->dev;
387+
struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev);
392388
struct gb_bundle *bundle;
393389

394-
dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
390+
dev_dbg(codec_dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
395391
module = find_gb_module(gb, kcontrol->id.name);
396392
if (!module)
397393
return -EINVAL;
@@ -415,7 +411,7 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol,
415411
gb_pm_runtime_put_autosuspend(bundle);
416412

417413
if (ret) {
418-
dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret,
414+
dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret,
419415
__func__, kcontrol->id.name);
420416
return ret;
421417
}
@@ -437,11 +433,11 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,
437433
struct gbaudio_module_info *module;
438434
struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
439435
struct snd_soc_dapm_widget *widget = wlist->widgets[0];
440-
struct snd_soc_codec *codec = widget->codec;
441-
struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec);
436+
struct device *codec_dev = widget->dapm->dev;
437+
struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev);
442438
struct gb_bundle *bundle;
443439

444-
dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
440+
dev_dbg(codec_dev, "Entered %s:%s\n", __func__, kcontrol->id.name);
445441
module = find_gb_module(gb, kcontrol->id.name);
446442
if (!module)
447443
return -EINVAL;
@@ -464,11 +460,8 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,
464460
if (gbvalue.value.integer_value[0] != val) {
465461
for (wi = 0; wi < wlist->num_widgets; wi++) {
466462
widget = wlist->widgets[wi];
467-
468-
widget->value = val;
469-
widget->dapm->update = NULL;
470-
snd_soc_dapm_mixer_update_power(widget, kcontrol,
471-
connect);
463+
snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
464+
connect, NULL);
472465
}
473466
gbvalue.value.integer_value[0] =
474467
cpu_to_le32(ucontrol->value.integer.value[0]);
@@ -484,7 +477,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,
484477
gb_pm_runtime_put_autosuspend(bundle);
485478

486479
if (ret) {
487-
dev_err_ratelimited(codec->dev,
480+
dev_err_ratelimited(codec_dev,
488481
"%d:Error in %s for %s\n", ret,
489482
__func__, kcontrol->id.name);
490483
return ret;
@@ -553,11 +546,11 @@ static int gbcodec_enum_ctl_get(struct snd_kcontrol *kcontrol,
553546
struct snd_ctl_elem_value *ucontrol)
554547
{
555548
int ret, ctl_id;
556-
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
549+
struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
550+
struct gbaudio_codec_info *gb = snd_soc_component_get_drvdata(comp);
557551
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
558552
struct gb_audio_ctl_elem_value gbvalue;
559553
struct gbaudio_module_info *module;
560-
struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec);
561554
struct gb_bundle *bundle;
562555

563556
module = find_gb_module(gb, kcontrol->id.name);
@@ -580,7 +573,7 @@ static int gbcodec_enum_ctl_get(struct snd_kcontrol *kcontrol,
580573
gb_pm_runtime_put_autosuspend(bundle);
581574

582575
if (ret) {
583-
dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret,
576+
dev_err_ratelimited(comp->dev, "%d:Error in %s for %s\n", ret,
584577
__func__, kcontrol->id.name);
585578
return ret;
586579
}
@@ -598,11 +591,11 @@ static int gbcodec_enum_ctl_put(struct snd_kcontrol *kcontrol,
598591
struct snd_ctl_elem_value *ucontrol)
599592
{
600593
int ret, ctl_id;
601-
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
594+
struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
595+
struct gbaudio_codec_info *gb = snd_soc_component_get_drvdata(comp);
602596
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
603597
struct gb_audio_ctl_elem_value gbvalue;
604598
struct gbaudio_module_info *module;
605-
struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec);
606599
struct gb_bundle *bundle;
607600

608601
module = find_gb_module(gb, kcontrol->id.name);
@@ -613,13 +606,13 @@ static int gbcodec_enum_ctl_put(struct snd_kcontrol *kcontrol,
613606
if (ctl_id < 0)
614607
return -EINVAL;
615608

616-
if (ucontrol->value.enumerated.item[0] > e->max - 1)
609+
if (ucontrol->value.enumerated.item[0] > e->items - 1)
617610
return -EINVAL;
618611
gbvalue.value.enumerated_item[0] =
619612
cpu_to_le32(ucontrol->value.enumerated.item[0]);
620613

621614
if (e->shift_l != e->shift_r) {
622-
if (ucontrol->value.enumerated.item[1] > e->max - 1)
615+
if (ucontrol->value.enumerated.item[1] > e->items - 1)
623616
return -EINVAL;
624617
gbvalue.value.enumerated_item[1] =
625618
cpu_to_le32(ucontrol->value.enumerated.item[1]);
@@ -637,8 +630,8 @@ static int gbcodec_enum_ctl_put(struct snd_kcontrol *kcontrol,
637630
gb_pm_runtime_put_autosuspend(bundle);
638631

639632
if (ret) {
640-
dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret,
641-
__func__, kcontrol->id.name);
633+
dev_err_ratelimited(comp->dev, "%d:Error in %s for %s\n",
634+
ret, __func__, kcontrol->id.name);
642635
}
643636

644637
return ret;
@@ -659,13 +652,13 @@ static int gbaudio_tplg_create_enum_kctl(struct gbaudio_module_info *gb,
659652
gb_enum = &ctl->info.value.enumerated;
660653

661654
/* since count=1, and reg is dummy */
662-
gbe->max = le32_to_cpu(gb_enum->items);
655+
gbe->items = le32_to_cpu(gb_enum->items);
663656
gbe->texts = gb_generate_enum_strings(gb, gb_enum);
664657

665658
/* debug enum info */
666-
dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->max,
659+
dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->items,
667660
le16_to_cpu(gb_enum->names_length));
668-
for (i = 0; i < gbe->max; i++)
661+
for (i = 0; i < gbe->items; i++)
669662
dev_dbg(gb->dev, "src[%d]: %s\n", i, gbe->texts[i]);
670663

671664
*kctl = (struct snd_kcontrol_new)
@@ -720,8 +713,8 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol,
720713
struct snd_soc_dapm_widget *widget = wlist->widgets[0];
721714
struct gbaudio_module_info *module;
722715
struct gb_audio_ctl_elem_value gbvalue;
723-
struct snd_soc_codec *codec = widget->codec;
724-
struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec);
716+
struct device *codec_dev = widget->dapm->dev;
717+
struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev);
725718
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
726719
struct gb_bundle *bundle;
727720

@@ -745,7 +738,7 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol,
745738
gb_pm_runtime_put_autosuspend(bundle);
746739

747740
if (ret) {
748-
dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret,
741+
dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret,
749742
__func__, kcontrol->id.name);
750743
return ret;
751744
}
@@ -768,12 +761,12 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
768761
struct snd_soc_dapm_widget *widget = wlist->widgets[0];
769762
struct gb_audio_ctl_elem_value gbvalue;
770763
struct gbaudio_module_info *module;
771-
struct snd_soc_codec *codec = widget->codec;
772-
struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec);
764+
struct device *codec_dev = widget->dapm->dev;
765+
struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev);
773766
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
774767
struct gb_bundle *bundle;
775768

776-
if (ucontrol->value.enumerated.item[0] > e->max - 1)
769+
if (ucontrol->value.enumerated.item[0] > e->items - 1)
777770
return -EINVAL;
778771

779772
module = find_gb_module(gb, kcontrol->id.name);
@@ -797,7 +790,7 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
797790
gb_pm_runtime_put_autosuspend(bundle);
798791

799792
if (ret) {
800-
dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret,
793+
dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret,
801794
__func__, kcontrol->id.name);
802795
return ret;
803796
}
@@ -814,7 +807,7 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
814807
}
815808

816809
if (e->shift_l != e->shift_r) {
817-
if (ucontrol->value.enumerated.item[1] > e->max - 1)
810+
if (ucontrol->value.enumerated.item[1] > e->items - 1)
818811
return -EINVAL;
819812
val |= ucontrol->value.enumerated.item[1] << e->shift_r;
820813
mask |= e->mask << e->shift_r;
@@ -837,16 +830,14 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
837830
gb_pm_runtime_put_autosuspend(bundle);
838831

839832
if (ret) {
840-
dev_err_ratelimited(codec->dev,
833+
dev_err_ratelimited(codec_dev,
841834
"%d:Error in %s for %s\n", ret,
842835
__func__, kcontrol->id.name);
843836
}
844837
for (wi = 0; wi < wlist->num_widgets; wi++) {
845838
widget = wlist->widgets[wi];
846-
847-
widget->value = val;
848-
widget->dapm->update = NULL;
849-
snd_soc_dapm_mux_update_power(widget, kcontrol, mux, e);
839+
snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
840+
val, e, NULL);
850841
}
851842
}
852843

@@ -868,13 +859,13 @@ static int gbaudio_tplg_create_enum_ctl(struct gbaudio_module_info *gb,
868859
gb_enum = &ctl->info.value.enumerated;
869860

870861
/* since count=1, and reg is dummy */
871-
gbe->max = le32_to_cpu(gb_enum->items);
862+
gbe->items = le32_to_cpu(gb_enum->items);
872863
gbe->texts = gb_generate_enum_strings(gb, gb_enum);
873864

874865
/* debug enum info */
875-
dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->max,
866+
dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->items,
876867
le16_to_cpu(gb_enum->names_length));
877-
for (i = 0; i < gbe->max; i++)
868+
for (i = 0; i < gbe->items; i++)
878869
dev_dbg(gb->dev, "src[%d]: %s\n", i, gbe->texts[i]);
879870

880871
*kctl = (struct snd_kcontrol_new)
@@ -935,12 +926,12 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w,
935926
{
936927
int wid;
937928
int ret;
938-
struct snd_soc_codec *codec = w->codec;
939-
struct gbaudio_codec_info *gbcodec = snd_soc_codec_get_drvdata(codec);
929+
struct device *codec_dev = w->dapm->dev;
930+
struct gbaudio_codec_info *gbcodec = dev_get_drvdata(codec_dev);
940931
struct gbaudio_module_info *module;
941932
struct gb_bundle *bundle;
942933

943-
dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
934+
dev_dbg(codec_dev, "%s %s %d\n", __func__, w->name, event);
944935

945936
/* Find relevant module */
946937
module = find_gb_module(gbcodec, w->name);
@@ -950,7 +941,7 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w,
950941
/* map name to widget id */
951942
wid = gbaudio_map_widgetname(module, w->name);
952943
if (wid < 0) {
953-
dev_err(codec->dev, "Invalid widget name:%s\n", w->name);
944+
dev_err(codec_dev, "Invalid widget name:%s\n", w->name);
954945
return -EINVAL;
955946
}
956947

@@ -973,7 +964,7 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w,
973964
break;
974965
}
975966
if (ret)
976-
dev_err_ratelimited(codec->dev,
967+
dev_err_ratelimited(codec_dev,
977968
"%d: widget, event:%d failed:%d\n", wid,
978969
event, ret);
979970

0 commit comments

Comments
 (0)