Re: [PATCH 1/2] ALSA: tea6330t: add mixer state restore helper

From: Takashi Iwai

Date: Tue Apr 07 2026 - 07:56:10 EST


On Tue, 07 Apr 2026 03:22:07 +0200,
Cássio Gabriel wrote:
> diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c
> index e8c50a036bea..3e413929d3ea 100644
> --- a/sound/i2c/tea6330t.c
> +++ b/sound/i2c/tea6330t.c
> @@ -358,3 +358,36 @@ int snd_tea6330t_update_mixer(struct snd_card *card,
>
> EXPORT_SYMBOL(snd_tea6330t_detect);
> EXPORT_SYMBOL(snd_tea6330t_update_mixer);

Oh we need a cleanup to put EXPORT_SYMBOL() after each function.
(It should be a different patch, though.)

> +
> +int snd_tea6330t_restore_mixer(struct snd_i2c_bus *bus)
> +{
> + struct snd_i2c_device *device;
> + struct tea6330t *tea;
> + unsigned char bytes[7];
> + unsigned int idx;
> + int err;
> +
> + if (!bus)
> + return -EINVAL;
> +
> + list_for_each_entry(device, &bus->devices, list) {
> + if (device->addr != TEA6330T_ADDR)
> + continue;
> +
> + tea = device->private_data;
> + if (!tea)
> + return -EINVAL;
> +
> + snd_i2c_lock(bus);
> + bytes[0] = TEA6330T_SADDR_VOLUME_LEFT;
> + for (idx = 0; idx < 6; idx++)
> + bytes[idx + 1] = tea->regs[idx];
> + err = snd_i2c_sendbytes(device, bytes, 7);
> + snd_i2c_unlock(bus);
> +
> + return err < 0 ? err : 0;
> + }

I think snd_i2c_lock() should cover the whole loop for the race at
linked list traversal.


thanks,

Takashi