Re: [PATCH v2 1/2] ASoC: tegra210_adx: simplify byte map get/put logic
From: Mark Brown
Date: Wed Apr 08 2026 - 13:47:48 EST
On Wed, Apr 08, 2026 at 10:38:17PM +0530, Piyush Patle wrote:
> +static int tegra210_adx_write_map_ram(struct tegra210_adx *adx)
> {
> + const unsigned int bits_per_mask = BITS_PER_TYPE(*adx->map) * BITS_PER_BYTE;
Why are we multiplying by BITS_PER_BYTE here? We've got a number of
bits already from BITS_PER_TYPE().
> + for (i = 0; i < adx->soc_data->ram_depth; i++) {
> + u32 word = 0;
> + int b;
> +
> + for (b = 0; b < TEGRA_ADX_SLOTS_PER_WORD; b++) {
> + unsigned int slot = i * TEGRA_ADX_SLOTS_PER_WORD + b;
> + u16 val = adx->map[slot];
> +
> + if (val >= 256)
> + continue;
> +
> + word |= (u32)val << (b * BITS_PER_BYTE);
> + byte_mask[slot / bits_per_mask] |= 1U << (slot % bits_per_mask);
How big can bits_per_mask get?
> @@ -118,9 +144,7 @@ static int tegra210_adx_runtime_resume(struct device *dev)
> regcache_cache_only(adx->regmap, false);
> regcache_sync(adx->regmap);
>
> - tegra210_adx_write_map_ram(adx);
> -
> - return 0;
> + return tegra210_adx_write_map_ram(adx);
We need to unwind at least the regcache_cache_only() above if resume
fails.
Attachment:
signature.asc
Description: PGP signature