ASoC: soc-ops: use snd_soc_component_regmap_val_bytes()

component has component->val_bytes which is set via
snd_soc_component_setup_regmap(). But it can be calculated via
component->regmap. No need to keep it as component->val_bytes.

Use snd_soc_component_regmap_val_bytes().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/875x71zyw5.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2026-03-12 00:15:21 +00:00 committed by Mark Brown
parent 72660d1ac9
commit 7a478db698
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -514,9 +514,10 @@ int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct soc_bytes *params = (void *)kcontrol->private_value;
int val_bytes = snd_soc_component_regmap_val_bytes(component);
uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
uinfo->count = params->num_regs * component->val_bytes;
uinfo->count = params->num_regs * val_bytes;
return 0;
}
@ -527,18 +528,19 @@ int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct soc_bytes *params = (void *)kcontrol->private_value;
int val_bytes = snd_soc_component_regmap_val_bytes(component);
int ret;
if (component->regmap)
ret = regmap_raw_read(component->regmap, params->base,
ucontrol->value.bytes.data,
params->num_regs * component->val_bytes);
params->num_regs * val_bytes);
else
ret = -EINVAL;
/* Hide any masked bytes to ensure consistent data reporting */
if (ret == 0 && params->mask) {
switch (component->val_bytes) {
switch (val_bytes) {
case 1:
ucontrol->value.bytes.data[0] &= ~params->mask;
break;
@ -564,13 +566,14 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct soc_bytes *params = (void *)kcontrol->private_value;
int val_bytes = snd_soc_component_regmap_val_bytes(component);
unsigned int val, mask;
int ret, len;
if (!component->regmap || !params->num_regs)
return -EINVAL;
len = params->num_regs * component->val_bytes;
len = params->num_regs * val_bytes;
void *data __free(kfree) = kmemdup(ucontrol->value.bytes.data, len,
GFP_KERNEL | GFP_DMA);
@ -589,7 +592,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
val &= params->mask;
switch (component->val_bytes) {
switch (val_bytes) {
case 1:
((u8 *)data)[0] &= ~params->mask;
((u8 *)data)[0] |= val;
@ -712,9 +715,10 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct soc_mreg_control *mc =
(struct soc_mreg_control *)kcontrol->private_value;
int val_bytes = snd_soc_component_regmap_val_bytes(component);
unsigned int regbase = mc->regbase;
unsigned int regcount = mc->regcount;
unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
unsigned int regwshift = val_bytes * BITS_PER_BYTE;
unsigned int regwmask = GENMASK(regwshift - 1, 0);
unsigned long mask = GENMASK(mc->nbits - 1, 0);
long val = 0;
@ -756,9 +760,10 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct soc_mreg_control *mc =
(struct soc_mreg_control *)kcontrol->private_value;
int val_bytes = snd_soc_component_regmap_val_bytes(component);
unsigned int regbase = mc->regbase;
unsigned int regcount = mc->regcount;
unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
unsigned int regwshift = val_bytes * BITS_PER_BYTE;
unsigned int regwmask = GENMASK(regwshift - 1, 0);
unsigned long mask = GENMASK(mc->nbits - 1, 0);
long val = ucontrol->value.integer.value[0];