Re: [PATCH v2 14/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for gain-ranges

Mark Brown
2026-04-30T01:33:00Z

[-- Attachment #1: Type: text/plain, Size: 1041 bytes --]

On Wed, Apr 29, 2026 at 09:43:50AM +0200, Herve Codina wrote:

> +static int *simple_amp_alloc_tlv_ranges(const struct simple_amp_ranges *ranges)
> +{
> + unsigned int index;
> + unsigned int *tlv;

> + return tlv;
> +}

The function returns a pointer to int but everything else is pointer to
unsigned int.

> +static int simple_amp_check_new_range(const struct simple_amp_range *new_range,
> + const struct simple_amp_range *tab_ranges,
> + unsigned int nb_ranges)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < nb_ranges; i++) {
> + /* Check for range overlaps */
> + if (new_range->min.gain_db >= tab_ranges[i].min.gain_db &&
> + new_range->min.gain_db <= tab_ranges[i].max.gain_db)
> + return -EINVAL;
> +
> + if (new_range->max.gain_db >= tab_ranges[i].min.gain_db &&
> + new_range->max.gain_db <= tab_ranges[i].max.gain_db)
> + return -EINVAL;
> + }
> + return 0;
> +}

This checks if the new range is inside an existing range but won't
notice if the existing range is entirely inside the new one.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]