Re: [PATCH] ASoC: Add support for multi register mux

From: Mark Brown
Date: Wed Mar 26 2014 - 21:30:26 EST


On Tue, Mar 25, 2014 at 05:02:35PM -0700, Arun Shamanna Lakshmi wrote:

> + }
> + if (!match) {
> + dev_err(codec->dev, "ASoC: Failed to find matched enum value\n");
> + return -EINVAL;
> + } else
> + ucontrol->value.enumerated.item[0] = i;

Coding style nit: if one side of the if has braces both should. Most of
this code could also use more blank lines.

> + for (reg_idx = 0; reg_idx < e->num_regs; reg_idx++) {
> + val = e->values[item * e->num_regs + reg_idx];
> + ret = snd_soc_update_bits_locked(codec, e->reg[reg_idx],
> + e->mask[reg_idx], val);
> + if (ret)
> + return ret;
> + }

So, this is a bit interesting. It will update one register at a time
which means that we are likely to transiently set an invalid value
sometimes which might not make the hardware happy or may cause us to
write a valid value with undesirable consequences. I'd expect to see
some handling of this, some combination of providing a safe value that
the hardware could be reset to prior to change and doing a bulk write to
all the registers simultaneously if we can (I know sometimes hardware
has special handling for atomic updates of multi-register values in a
single block transfer).

Attachment: signature.asc
Description: Digital signature