From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: rodrigo.alencar@analog.com
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH 1/3] iio: frequency: adf41513: driver implementation
Date: Thu, 13 Nov 2025 10:13:56 -0300 [thread overview]
Message-ID: <aRXZlMsPjIGWJ_oc@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <20251110-adf41513-iio-driver-v1-1-2df8be0fdc6e@analog.com>
Hi Rodrigo,
A couple of comments inline since this is on the mailing list.
As mentioned in the other thread, we ought to continue the review of this internally.
On 11/10, Rodrigo Alencar via B4 Relay wrote:
> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
>
> - ADF41513: 1 GHz to 26.5 GHz frequency range
> - ADF41510: 1 GHz to 10 GHz frequency range
> - Integer-N and fractional-N operation modes
> - Ultra-low phase noise (-235 dBc/Hz integer-N, -231 dBc/Hz fractional-N)
> - High maximum PFD frequency (250 MHz integer-N, 125 MHz fractional-N)
> - 25-bit fixed modulus or 49-bit variable modulus fractional modes
> - Programmable charge pump currents with 16x range
> - Digital lock detect functionality
> - Phase resync capability for consistent output phase
> - Clock framework integration for system clock generation
>
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
> ---
...
> +
> +static int adf41513_parse_uhz(const char *str, u64 *freq_uhz)
> +{
> + u64 uhz = 0;
> + int f_count = ADF41513_HZ_DECIMAL_PRECISION;
> + bool frac_part = false;
> +
> + if (str[0] == '+')
> + str++;
> +
> + while (*str && f_count > 0) {
> + if ('0' <= *str && *str <= '9') {
> + uhz = uhz * 10 + *str - '0';
> + if (frac_part)
> + f_count--;
> + } else if (*str == '\n') {
> + if (*(str + 1) == '\0')
> + break;
> + return -EINVAL;
> + } else if (*str == '.' && !frac_part) {
> + frac_part = true;
> + } else {
> + return -EINVAL;
> + }
> + str++;
> + }
> +
> + for (; f_count > 0; f_count--)
> + uhz *= 10;
> +
> + *freq_uhz = uhz;
> +
> + return 0;
> +}
didn't check the details, but can't the sub-Hz resolution be supported with
.write_raw_get_fmt()?
e.g.
static int adf41513_write_raw_get_fmt(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, long mask)
{
switch (mask) {
case IIO_CHAN_INFO_FREQUENCY:
return IIO_VAL_INT_64;
default:
return IIO_VAL_INT_PLUS_MICRO;
}
}
static const struct iio_info adf41513_info = {
...
.write_raw_get_fmt = adf41513_write_raw_get_fmt(),
};
...
> +
> +static ssize_t adf41513_write(struct iio_dev *indio_dev,
> + uintptr_t private,
> + const struct iio_chan_spec *chan,
> + const char *buf, size_t len)
> +{
> + struct adf41513_state *st = iio_priv(indio_dev);
> + unsigned long long readin;
> + unsigned long tmp;
> + u64 freq_uhz;
> + int ret;
> +
> + guard(mutex)(&st->lock);
> +
> + switch ((u32)private) {
> + case ADF41513_FREQ:
> + ret = adf41513_parse_uhz(buf, &freq_uhz);
> + if (ret)
> + return ret;
> + ret = adf41513_set_frequency(st, freq_uhz, ADF41513_SYNC_DIFF);
> + break;
> + case ADF41513_FREQ_REFIN:
> + ret = kstrtoull(buf, 10, &readin);
> + if (ret)
> + return ret;
> +
> + if (readin < ADF41513_MIN_REF_FREQ || readin > ADF41513_MAX_REF_FREQ) {
Can, alternatively, this check be made with in_range() macro?
If so, then
#include <linux/minmax.h>
Same question/suggestion to other similar value bounds checks throughout the driver.
> + ret = -EINVAL;
> + break;
> + }
> +
With best regards,
Marcelo
next prev parent reply other threads:[~2025-11-13 13:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 15:44 [PATCH 0/3] ADF41513/ADF41510 PLL frequency synthesizers Rodrigo Alencar via B4 Relay
2025-11-10 15:44 ` [PATCH 1/3] iio: frequency: adf41513: driver implementation Rodrigo Alencar via B4 Relay
2025-11-10 16:30 ` Andy Shevchenko
2025-11-10 16:41 ` Andy Shevchenko
2025-11-16 16:07 ` Jonathan Cameron
2025-11-11 8:43 ` Nuno Sá
2025-11-13 13:13 ` Marcelo Schmitt [this message]
2025-11-13 14:39 ` Nuno Sá
2025-11-10 15:44 ` [PATCH 2/3] dt-bindings: iio: frequency: add adf41513 Rodrigo Alencar via B4 Relay
2025-11-11 8:05 ` Krzysztof Kozlowski
2025-11-13 13:21 ` Marcelo Schmitt
2025-11-10 15:44 ` [PATCH 3/3] docs: iio: add documentation for adf41513 driver Rodrigo Alencar via B4 Relay
2025-11-10 16:38 ` [PATCH 0/3] ADF41513/ADF41510 PLL frequency synthesizers Andy Shevchenko
2025-11-16 16:10 ` Jonathan Cameron
2025-11-17 8:37 ` Nuno Sá
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=aRXZlMsPjIGWJ_oc@debian-BULLSEYE-live-builder-AMD64 \
--to=marcelo.schmitt1@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rodrigo.alencar@analog.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