Re: [PATCH v5] iio: frequency: ad9832: Use FIELD_PREP macro to set bit fields
From: Marcelo Schmitt
Date: Thu Apr 03 2025 - 12:07:35 EST
On 04/02, Siddharth Menon wrote:
> On Sun, 30 Mar 2025 at 21:13, Marcelo Schmitt
> <marcelo.schmitt1@xxxxxxxxx> wrote:
> > The previous implementation would set ctrl_fp if val == 1 and unset it if val == 0.
> > This patch seems to be doing the reverse (setting ctrl_fp if val == 0, and
> > unsetting it if val != 0). Was the previous implementation potentially buggy?
>
> My apologies, I seem to have made a mistake here.
No worries. It's okay to change/update device drivers to make them better (e.g.
implement new features, fix bugs). If the proposed change was fixing something,
then it could be put into a separate patch with a Fixes tag. Though, I had
another look at the datasheet and my understanding is that the freq bit (bit 11)
should be set if the user writes 1 to out_altvoltageX_frequencysymbol (ABI
documented in drivers/staging/iio/Documentation/sysfs-bus-iio-dds).
By the way, I now think my suggestion of doing
st->ctrl_fp |= FIELD_PREP(AD9832_FREQ, !!val) was not a good idea since that
wouldn't follow the proposed ABI.
Anyway, it's okay to propose more changes/patches if you want. Just separate the
patches according to their logical change if you make more changes to the driver.
Regards,
Marcelo