@@ -489,7 +489,7 @@ static void remove_widget(struct snd_soc_component *comp,
489
489
* Dynamic Widgets either have 1..N enum kcontrols or mixers.
490
490
* The enum may either have an array of values or strings.
491
491
*/
492
- if (dobj -> widget .kcontrol_enum ) {
492
+ if (dobj -> widget .kcontrol_type == SND_SOC_TPLG_TYPE_ENUM ) {
493
493
/* enumerated widget mixer */
494
494
for (i = 0 ; i < w -> num_kcontrols ; i ++ ) {
495
495
struct snd_kcontrol * kcontrol = w -> kcontrols [i ];
@@ -506,16 +506,21 @@ static void remove_widget(struct snd_soc_component *comp,
506
506
}
507
507
kfree (w -> kcontrol_news );
508
508
} else {
509
- /* non enumerated widget mixer */
509
+ /* volume mixer or bytes controls */
510
510
for (i = 0 ; i < w -> num_kcontrols ; i ++ ) {
511
511
struct snd_kcontrol * kcontrol = w -> kcontrols [i ];
512
- struct soc_mixer_control * sm =
513
- (struct soc_mixer_control * ) kcontrol -> private_value ;
514
512
515
- kfree (w -> kcontrols [i ]-> tlv .p );
513
+ if (dobj -> widget .kcontrol_type
514
+ == SND_SOC_TPLG_TYPE_MIXER )
515
+ kfree (kcontrol -> tlv .p );
516
516
517
- snd_ctl_remove (card , w -> kcontrols [i ]);
518
- kfree (sm );
517
+ snd_ctl_remove (card , kcontrol );
518
+
519
+ /* Private value is used as struct soc_mixer_control
520
+ * for volume mixers or soc_bytes_ext for bytes
521
+ * controls.
522
+ */
523
+ kfree ((void * )kcontrol -> private_value );
519
524
}
520
525
kfree (w -> kcontrol_news );
521
526
}
@@ -1439,6 +1444,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
1439
1444
struct snd_soc_dapm_widget template , * widget ;
1440
1445
struct snd_soc_tplg_ctl_hdr * control_hdr ;
1441
1446
struct snd_soc_card * card = tplg -> comp -> card ;
1447
+ unsigned int kcontrol_type ;
1442
1448
int ret = 0 ;
1443
1449
1444
1450
if (strnlen (w -> name , SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) ==
@@ -1494,6 +1500,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
1494
1500
case SND_SOC_TPLG_CTL_VOLSW_XR_SX :
1495
1501
case SND_SOC_TPLG_CTL_RANGE :
1496
1502
case SND_SOC_TPLG_DAPM_CTL_VOLSW :
1503
+ kcontrol_type = SND_SOC_TPLG_TYPE_MIXER ; /* volume mixer */
1497
1504
template .num_kcontrols = w -> num_kcontrols ;
1498
1505
template .kcontrol_news =
1499
1506
soc_tplg_dapm_widget_dmixer_create (tplg ,
@@ -1508,7 +1515,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
1508
1515
case SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE :
1509
1516
case SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT :
1510
1517
case SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE :
1511
- template . dobj . widget . kcontrol_enum = 1 ;
1518
+ kcontrol_type = SND_SOC_TPLG_TYPE_ENUM ; /* enumerated mixer */
1512
1519
template .num_kcontrols = w -> num_kcontrols ;
1513
1520
template .kcontrol_news =
1514
1521
soc_tplg_dapm_widget_denum_create (tplg ,
@@ -1519,6 +1526,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
1519
1526
}
1520
1527
break ;
1521
1528
case SND_SOC_TPLG_CTL_BYTES :
1529
+ kcontrol_type = SND_SOC_TPLG_TYPE_BYTES ; /* bytes control */
1522
1530
template .num_kcontrols = w -> num_kcontrols ;
1523
1531
template .kcontrol_news =
1524
1532
soc_tplg_dapm_widget_dbytes_create (tplg ,
@@ -1555,6 +1563,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
1555
1563
}
1556
1564
1557
1565
widget -> dobj .type = SND_SOC_DOBJ_WIDGET ;
1566
+ widget -> dobj .widget .kcontrol_type = kcontrol_type ;
1558
1567
widget -> dobj .ops = tplg -> ops ;
1559
1568
widget -> dobj .index = tplg -> index ;
1560
1569
kfree (template .sname );
0 commit comments