From: Jonathan Cameron <jic23@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Zicheng Qu <quzicheng@huawei.com>,
lars@metafoo.de, Michael.Hennerich@analog.com,
gregkh@linuxfoundation.org, daniel.baluta@intel.com,
shubhrajyoti@ti.com, linux-iio@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
tanghui20@huawei.com, zhangqiao22@huawei.com,
judy.chenhui@huawei.com
Subject: Re: [PATCH v2 1/2] staging: iio: ad9834: Correct phase range check
Date: Sat, 9 Nov 2024 14:41:26 +0000 [thread overview]
Message-ID: <20241109144126.5efb84b6@jic23-huawei> (raw)
In-Reply-To: <333c54f3-3d4b-4038-94a9-ce8396b452ce@suswa.mountain>
On Thu, 7 Nov 2024 13:32:42 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:
> On Thu, Nov 07, 2024 at 01:10:14AM +0000, Zicheng Qu wrote:
> > User Perspective:
> > When a user sets the phase value, the ad9834_write_phase() is called.
> > The phase register has a 12-bit resolution, so the valid range is 0 to
> > 4095. If the phase offset value of 4096 is input, it effectively exactly
> > equals 0 in the lower 12 bits, meaning no offset.
> >
> > Reasons for the Change:
> > 1) Original Condition (phase > BIT(AD9834_PHASE_BITS)):
> > This condition allows a phase value equal to 2^12, which is 4096.
> > However, this value exceeds the valid 12-bit range, as the maximum valid
> > phase value should be 4095.
> > 2) Modified Condition (phase >= BIT(AD9834_PHASE_BITS)):
> > Ensures that the phase value is within the valid range, preventing
> > invalid datafrom being written.
> >
> > Impact on Subsequent Logic: st->data = cpu_to_be16(addr | phase):
> > If the phase value is 2^12, i.e., 4096 (0001 0000 0000 0000), and addr
> > is AD9834_REG_PHASE0 (1100 0000 0000 0000), then addr | phase results in
> > 1101 0000 0000 0000, occupying DB12. According to the section of WRITING
> > TO A PHASE REGISTER in the datasheet, the MSB 12 PHASE0 bits should be
> > DB11. The original condition leads to incorrect DB12 usage, which
> > contradicts the datasheet and could pose potential issues for future
> > updates if DB12 is used in such related cases.
> >
> > Fixes: 12b9d5bf76bf ("Staging: IIO: DDS: AD9833 / AD9834 driver")
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
> > ---
>
> Fair enough. Thanks.
>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Applied both patches to the fixes-togreg branch of iio.git.
Note they probably won't go upstream now until after rc1.
Thanks,
Jonathan
>
> regards,
> dan carpenter
>
next prev parent reply other threads:[~2024-11-09 14:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-05 14:03 [PATCH 0/2] Correct Phase Range Check for AD9832 and AD9834 Drivers Zicheng Qu
2024-11-05 14:03 ` [PATCH 1/2] staging: iio: ad9834: Correct phase range check Zicheng Qu
2024-11-05 15:54 ` Dan Carpenter
2024-11-05 14:03 ` [PATCH 2/2] staging: iio: ad9832: " Zicheng Qu
2024-11-05 16:15 ` Dan Carpenter
2024-11-07 1:10 ` [PATCH v2 0/2] Fix phase range check in AD9832 and AD9834 drivers Zicheng Qu
2024-11-07 1:10 ` [PATCH v2 1/2] staging: iio: ad9834: Correct phase range check Zicheng Qu
2024-11-07 10:32 ` Dan Carpenter
2024-11-09 14:41 ` Jonathan Cameron [this message]
2024-11-07 1:10 ` [PATCH v2 2/2] staging: iio: ad9832: " Zicheng Qu
2024-11-09 14:39 ` [PATCH v2 0/2] Fix phase range check in AD9832 and AD9834 drivers Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241109144126.5efb84b6@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=dan.carpenter@linaro.org \
--cc=daniel.baluta@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=judy.chenhui@huawei.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=quzicheng@huawei.com \
--cc=shubhrajyoti@ti.com \
--cc=tanghui20@huawei.com \
--cc=zhangqiao22@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox