ASoC: soc-component: merge snd_soc_component_read() and snd_soc_component_read32()
We had read/write function for Codec, Platform, etc,
but these has been merged into snd_soc_component_read/write().
Internally, it is using regmap or driver function.
In read case, each styles are like below
regmap
ret = regmap_read(..., reg, &val);
driver function
val = xxx->read(..., reg);
Because of this kind of different style, to keep same read style,
when we merged each read function into snd_soc_component_read(),
we created snd_soc_component_read32(), like below.
commit 738b49efe6
("ASoC: add snd_soc_component_read32")
(1) val = snd_soc_component_read32(component, reg);
(2) ret = snd_soc_component_read(component, reg, &val);
Many drivers are using snd_soc_component_read32(), and
some drivers are using snd_soc_component_read() today.
In generally, we don't check read function successes,
because, we will have many other issues at initial timing
if read function didn't work.
Now we can use soc_component_err() when error case.
This means, it is easy to notice if error occurred.
This patch aggressively merge snd_soc_component_read() and _read32(),
and makes snd_soc_component_read/write() as generally style.
This patch do
1) merge snd_soc_component_read() and snd_soc_component_read32()
2) it uses soc_component_err() when error case (easy to notice)
3) keeps read32 for now by #define
4) update snd_soc_component_read() for all drivers
Because _read() user drivers are not too many, this patch changes
all user drivers.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:

committed by
Mark Brown

parent
3bd057c821
commit
cf6e26c71b
@@ -407,41 +407,30 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
|
||||
* snd_soc_component_read() - Read register value
|
||||
* @component: Component to read from
|
||||
* @reg: Register to read
|
||||
* @val: Pointer to where the read value is stored
|
||||
*
|
||||
* Return: 0 on success, a negative error code otherwise.
|
||||
* Return: read value
|
||||
*/
|
||||
int snd_soc_component_read(struct snd_soc_component *component,
|
||||
unsigned int reg, unsigned int *val)
|
||||
unsigned int snd_soc_component_read(struct snd_soc_component *component,
|
||||
unsigned int reg)
|
||||
{
|
||||
int ret;
|
||||
unsigned int val = 0;
|
||||
|
||||
if (component->regmap)
|
||||
ret = regmap_read(component->regmap, reg, val);
|
||||
ret = regmap_read(component->regmap, reg, &val);
|
||||
else if (component->driver->read) {
|
||||
*val = component->driver->read(component, reg);
|
||||
ret = 0;
|
||||
val = component->driver->read(component, reg);
|
||||
}
|
||||
else
|
||||
ret = -EIO;
|
||||
|
||||
return soc_component_ret(component, ret);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_component_read);
|
||||
|
||||
unsigned int snd_soc_component_read32(struct snd_soc_component *component,
|
||||
unsigned int reg)
|
||||
{
|
||||
unsigned int val;
|
||||
int ret;
|
||||
|
||||
ret = snd_soc_component_read(component, reg, &val);
|
||||
if (ret < 0)
|
||||
return soc_component_ret(component, -1);
|
||||
soc_component_ret(component, ret);
|
||||
|
||||
return val;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_component_read32);
|
||||
EXPORT_SYMBOL_GPL(snd_soc_component_read);
|
||||
|
||||
/**
|
||||
* snd_soc_component_write() - Write register value
|
||||
@@ -470,19 +459,17 @@ static int snd_soc_component_update_bits_legacy(
|
||||
unsigned int mask, unsigned int val, bool *change)
|
||||
{
|
||||
unsigned int old, new;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&component->io_mutex);
|
||||
|
||||
ret = snd_soc_component_read(component, reg, &old);
|
||||
if (ret < 0)
|
||||
goto out_unlock;
|
||||
old = snd_soc_component_read(component, reg);
|
||||
|
||||
new = (old & ~mask) | (val & mask);
|
||||
*change = old != new;
|
||||
if (*change)
|
||||
ret = snd_soc_component_write(component, reg, new);
|
||||
out_unlock:
|
||||
|
||||
mutex_unlock(&component->io_mutex);
|
||||
|
||||
return soc_component_ret(component, ret);
|
||||
@@ -584,11 +571,8 @@ int snd_soc_component_test_bits(struct snd_soc_component *component,
|
||||
unsigned int reg, unsigned int mask, unsigned int value)
|
||||
{
|
||||
unsigned int old, new;
|
||||
int ret;
|
||||
|
||||
ret = snd_soc_component_read(component, reg, &old);
|
||||
if (ret < 0)
|
||||
return soc_component_ret(component, ret);
|
||||
old = snd_soc_component_read(component, reg);
|
||||
new = (old & ~mask) | value;
|
||||
return old != new;
|
||||
}
|
||||
|
Reference in New Issue
Block a user