public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: rodrigo.alencar@analog.com
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Jonathan Cameron <jic23@kernel.org>,
	David Lechner <dlechner@baylibre.com>,
	Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH RFC v2 4/9] iio: frequency: ad9910: add digital ramp generator support
Date: Wed, 18 Mar 2026 21:14:14 +0200	[thread overview]
Message-ID: <abr5hoBIQLlcOk_v@ashevche-desk.local> (raw)
In-Reply-To: <20260318-ad9910-iio-driver-v2-4-e79f93becf11@analog.com>

On Wed, Mar 18, 2026 at 05:56:04PM +0000, Rodrigo Alencar via B4 Relay wrote:

> Add DRG channels with destination selection (frequency, phase, or
> amplitude), operating mode control, configurable upper/lower limits,
> increment/decrement step sizes, and step rate settings for the digital
> ramp generator.

...

> +static ssize_t ad9910_drg_attrs_read(struct iio_dev *indio_dev,
> +				     uintptr_t private,
> +				     const struct iio_chan_spec *chan,
> +				     char *buf)
> +{
> +	struct ad9910_state *st = iio_priv(indio_dev);
> +	unsigned int type;
> +	int vals[2];
> +	u64 tmp64;
> +
> +	guard(mutex)(&st->lock);
> +
> +	switch (chan->channel) {
> +	case AD9910_CHANNEL_DRG_RAMP_UP:
> +		tmp64 = FIELD_GET(AD9910_DRG_STEP_INC_MSK,
> +				  st->reg[AD9910_REG_DRG_STEP].val64);
> +		break;
> +	case AD9910_CHANNEL_DRG_RAMP_DOWN:
> +		tmp64 = FIELD_GET(AD9910_DRG_STEP_DEC_MSK,
> +				  st->reg[AD9910_REG_DRG_STEP].val64);
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	switch (private) {
> +	case AD9910_DRG_FREQ_STEP:
> +		type = IIO_VAL_INT_PLUS_MICRO;
> +		tmp64 *= st->data.sysclk_freq_hz;

> +		vals[0] = upper_32_bits(tmp64);
> +		vals[1] = upper_32_bits((u64)lower_32_bits(tmp64) * MICRO);

Not sure if wordparts.h fits here, esp. taking into account...

> +		break;
> +	case AD9910_DRG_PHASE_STEP:
> +		type = IIO_VAL_INT_PLUS_NANO;
> +		tmp64 *= AD9910_PI_NANORAD;
> +		tmp64 >>= 31;
> +		vals[0] = div_u64_rem(tmp64, NANO, &vals[1]);
> +		break;
> +	case AD9910_DRG_AMP_STEP:
> +		type = IIO_VAL_INT_PLUS_NANO;
> +		vals[0] = 0;
> +		vals[1] = tmp64 * NANO >> 32;

...open coded approach here. I think the open coded calculations.

> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return iio_format_value(buf, type, ARRAY_SIZE(vals), vals);
> +}


-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-03-18 19:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 17:56 [PATCH RFC v2 0/9] AD9910 Direct Digital Synthesizer Rodrigo Alencar via B4 Relay
2026-03-18 17:56 ` [PATCH RFC v2 1/9] dt-bindings: iio: frequency: add ad9910 Rodrigo Alencar via B4 Relay
2026-03-19 17:25   ` Conor Dooley
2026-03-20 11:21     ` Rodrigo Alencar
2026-03-20 14:00       ` Conor.Dooley
2026-03-20 17:14       ` Conor Dooley
2026-03-18 17:56 ` [PATCH RFC v2 2/9] iio: frequency: ad9910: initial driver implementation Rodrigo Alencar via B4 Relay
2026-03-22 16:50   ` Jonathan Cameron
2026-03-23 10:34     ` Rodrigo Alencar
2026-03-23 11:00       ` Andy Shevchenko
2026-03-18 17:56 ` [PATCH RFC v2 3/9] iio: frequency: ad9910: add simple parallel port mode support Rodrigo Alencar via B4 Relay
2026-03-18 18:28   ` Andy Shevchenko
2026-03-22 16:52     ` Jonathan Cameron
2026-03-23 10:39     ` Rodrigo Alencar
2026-03-23 11:01       ` Andy Shevchenko
2026-03-18 17:56 ` [PATCH RFC v2 4/9] iio: frequency: ad9910: add digital ramp generator support Rodrigo Alencar via B4 Relay
2026-03-18 19:14   ` Andy Shevchenko [this message]
2026-03-18 17:56 ` [PATCH RFC v2 5/9] iio: frequency: ad9910: add RAM mode support Rodrigo Alencar via B4 Relay
2026-03-22 17:05   ` Jonathan Cameron
2026-03-18 17:56 ` [PATCH RFC v2 6/9] iio: frequency: ad9910: add output shift keying support Rodrigo Alencar via B4 Relay
2026-03-18 17:56 ` [PATCH RFC v2 7/9] iio: frequency: ad9910: add channel labels Rodrigo Alencar via B4 Relay
2026-03-18 17:56 ` [PATCH RFC v2 8/9] Documentation: ABI: testing: add docs for ad9910 sysfs entries Rodrigo Alencar via B4 Relay
2026-03-22 17:22   ` Jonathan Cameron
2026-03-23 11:36     ` Rodrigo Alencar
2026-03-18 17:56 ` [PATCH RFC v2 9/9] docs: iio: add documentation for ad9910 driver Rodrigo Alencar via B4 Relay
2026-03-22 17:34   ` Jonathan Cameron
2026-03-23 11:58     ` Rodrigo Alencar

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=abr5hoBIQLlcOk_v@ashevche-desk.local \
    --to=andriy.shevchenko@intel.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=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=rodrigo.alencar@analog.com \
    --cc=skhan@linuxfoundation.org \
    /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