Skip to content

Commit

Permalink
ASoC: twl6040: Simplify custom get_volsw callback
Browse files Browse the repository at this point in the history
The custom get_volsw does not need to call any core get_volsw calls,
since we are returning the shadow values for the gains.
Return -EINVAL in the unlikely event, if the function has been called
for unhandled control. This way we can remove one check in the code.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Peter Ujfalusi authored and Mark Brown committed Oct 5, 2011
1 parent 0f9887d commit e49b683
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions sound/soc/codecs/twl6040.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,20 +796,14 @@ static int twl6040_get_volsw(struct snd_kcontrol *kcontrol,
out = &twl6040_priv->handsfree;
break;
default:
break;
}

if (out) {
ucontrol->value.integer.value[0] = out->left_vol;
ucontrol->value.integer.value[1] = out->right_vol;
return 0;
dev_warn(codec->dev, "%s: Unexpected register: 0x%02x\n",
__func__, mc->reg);
return -EINVAL;
}

/* call the appropriate handler depending on the rreg */
if (mc->rreg)
return snd_soc_get_volsw_2r(kcontrol, ucontrol);
else
return snd_soc_get_volsw(kcontrol, ucontrol);
ucontrol->value.integer.value[0] = out->left_vol;
ucontrol->value.integer.value[1] = out->right_vol;
return 0;
}

/*
Expand Down

0 comments on commit e49b683

Please sign in to comment.