Re: [PATCH v4 04/13] iio: dac: ad5686: fix powerdown control on dual-channel devices
From: Andy Shevchenko
Date: Wed Apr 29 2026 - 10:04:36 EST
On Wed, Apr 29, 2026 at 02:07:34PM +0100, Rodrigo Alencar via B4 Relay wrote:
> Fix powerdown control by using a proper bit shift for the powerdown mask
> values. During initialization, powerdown bits are initialized so that
> unused bits are set to 1 and the correct bit shift is used. Dual-channel
> devices use one-hot encoding in the address and that reflects on the
> position of the powerdown bits, which are not channel-index based
> for that case. Quad-channel devices also use one-hot encoding for the
> channel address but the result of log2(address) coincides with the channel
> index value. The issue was introduced when first adding support for
> dual-channel devices, which overlooked powerdown control differences.
...
> + /* Initialize masks to all ones provided the max shift (last channel) */
> + shift = ad5686_pd_mask_shift(&st->chip_info->channels[st->chip_info->num_channels - 1]);
> + st->pwr_down_mask = GENMASK(shift + 1, 0);
> + st->pwr_down_mode = GENMASK(shift + 1, 0);
Why do we care about upper bits being cleared? Can we simply use here
st->pwr_down_mask = GENMASK($MAX_CHAN * 2 + 1, 0);
// or even ~0, U32_MAX, et cetera
st->pwr_down_mask = ~0;
st->pwr_down_mode = ...same...
--
With Best Regards,
Andy Shevchenko