public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Ariana.Lazar@microchip.com
Cc: dlechner@baylibre.com, nuno.sa@analog.com,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, jic23@kernel.org, andy@kernel.org,
	krzk+dt@kernel.org, linux-kernel@vger.kernel.org,
	conor+dt@kernel.org
Subject: Re: [PATCH 2/2] iio: dac: add support for Microchip MCP48FEB02
Date: Tue, 17 Feb 2026 09:54:12 +0200	[thread overview]
Message-ID: <aZQepHXptVvBsQuL@smile.fi.intel.com> (raw)
In-Reply-To: <f8e45b0ef7af336dbde04ce53d117c6e47d2190d.camel@microchip.com>

On Mon, Feb 16, 2026 at 02:29:19PM +0000, Ariana.Lazar@microchip.com wrote:

...

> > > +static int mcp48feb02_read_avail(struct iio_dev *indio_dev, struct
> > > iio_chan_spec const *ch,
> > > +                              const int **vals, int *type, int
> > > *length, long info)
> > > +{
> > > +     struct mcp48feb02_data *data = iio_priv(indio_dev);
> > > +
> > > +     switch (info) {
> > > +     case IIO_CHAN_INFO_SCALE:
> > > +             switch (ch->type) {
> > > +             case IIO_VOLTAGE:
> > > +                     if (data->phys_channels >= 4 && (ch->address
> > > % 2))
> > > +                             *vals = data->scale_1;
> > > +                     else
> > > +                             *vals = data->scale;
> > 
> > Actually, if you put the scales as
> > 
> >         int scales[2][2 * MCP48FEB02_MAX_SCALES_CH];
> > 
> > this will become as simple as
> > 
> >                         if (data->phys_channels >= 4)
> >                                 *vals = data->scales[ch->address];
> >                         else
> >                                 *vals = data->scales[0];
> > 
> > OTOH, I am not sure if it can be always as
> > 
> >                         *vals = data->scales[ch->address];
> > 
> > which would be the best approach.
> 
> I am not quite sure I have understood your point of view. In order to
> remove the channel parity check, I would have to declare int
> scales[MCP48FEB02_MAX_CH][2 * MCP48FEB02_MAX_SCALES_CH] (int
> scales[8][6])
> regardless of device's number of channels and number of voltage
> references. This will be quite a lot unnecessary space allocated
> compared to using only two arrays of [2 * MCP48FEB02_MAX_SCALES_CH].
> 
> Another way to avoid these checks is to use a dynamically allocated
> array of scales. Each member points to an array of [2 *
> MCP48FEB02_MAX_SCALES_CH]
> and stores corresponding scale values for each channel, while allowing
> to allocate the actual number of channels the device has rather than
> the maximum.
> 
> Please tell me which version you prefer.

I think something like a second variant. But as it seems going to be an
agreement that this driver is not needed and rather we need to refactor
existing one to add the support for SPI chips, these comments won't make
much value.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-02-17  7:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-12 12:48 [PATCH 0/2] Add support for Microchip MCP48FxBy1/2/4/8 DAC with an SPI Interface Ariana Lazar
2026-02-12 12:48 ` [PATCH 1/2] dt-bindings: iio: dac: add support for Microchip MCP48FEB02 Ariana Lazar
2026-02-12 17:31   ` Rob Herring (Arm)
2026-02-12 18:00   ` Conor Dooley
2026-02-12 20:04     ` Andy Shevchenko
2026-02-16 13:31       ` Ariana.Lazar
2026-02-16 15:37         ` David Lechner
2026-02-16 17:34           ` Conor Dooley
2026-02-16 18:38             ` David Lechner
2026-02-12 12:48 ` [PATCH 2/2] " Ariana Lazar
2026-02-12 14:42   ` Andy Shevchenko
2026-02-16 14:29     ` Ariana.Lazar
2026-02-17  7:54       ` Andy Shevchenko [this message]
2026-02-17 11:38         ` Ariana.Lazar
2026-02-17 12:12           ` Andy Shevchenko
2026-02-15 17:58   ` Jonathan Cameron
2026-02-12 13:39 ` [PATCH 0/2] Add support for Microchip MCP48FxBy1/2/4/8 DAC with an SPI Interface Andy Shevchenko
2026-02-12 17:58   ` Conor Dooley

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=aZQepHXptVvBsQuL@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=Ariana.Lazar@microchip.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.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