devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andrea Collamati <andrea.collamati@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] iio: add MCP4728 I2C DAC driver
Date: Sun, 23 Jul 2023 13:47:21 +0100	[thread overview]
Message-ID: <20230723134721.1404d533@jic23-huawei> (raw)
In-Reply-To: <15ee98bd-b92b-8a34-e3f9-a1537edf2da9@gmail.com>

On Sun, 23 Jul 2023 14:15:10 +0200
Andrea Collamati <andrea.collamati@gmail.com> wrote:

> On 7/23/23 13:41, Jonathan Cameron wrote:
> >>>> +
> >>>> +	if (mode == MCP4728_VREF_EXTERNAL_VDD &&
> >>>> +	    data->channel_data[chan->channel].g_mode == MCP4728_GAIN_X2) {
> >>>> +		dev_warn(&data->client->dev,
> >>>> +			 "CH%d: Gain x2 not effective when vref is vdd, force to x1",
> >>>> +			 chan->channel);    
> >>> Even better if you don't present the option at all and wrap it up in the
> >>> standard ABI of _scale
> >>>    
> >> I think that the solution could be:
> >>
> >> - Removing custom ABI (vref/gain)
> >>
> >> - Initialize them at device tree level using two 4-elements arrays.  
> > If doing with device tree, they should reflect something that is a characteristic
> > of how the chips is wired up.  So you would need to explain why that is the case here.
> >
> > However, I'm still not understanding why _SCALE is not appropriate here.  We have
> > a small set of options with well defined scales.  
> 
> SCALE is appropriate. I didn't know that scale_available was a standard ABI.
> 
> I will follow  the implementation done n https://github.com/torvalds/linux/blob/c2782531397f5cb19ca3f8f9c17727f1cdf5bee8/drivers/iio/dac/ad5592r-base.c#L487

That's long out of date wrt to best practice.  Instead follow.
drivers/iio/dac/ad7293.c or any of the other drivers that set
.info_mask_shared_by_*_available = BIT(IIO_CHAN_INFO_SCALE)
and provide the read_avail() callback.

The advantage that brings is that consumer drivers can then
access this information much more simply.

One day we will hopefully finish converting old drivers over to
newer interfaces, but it's slow progress!

Jonathan


      reply	other threads:[~2023-07-23 12:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 15:40 [PATCH v3 0/2] add MCP4728 I2C DAC driver​ Andrea Collamati
2023-07-20 15:40 ` [PATCH v3 1/2] dt-bindings: iio: dac: add mcp4728.yaml Andrea Collamati
2023-07-20 17:01   ` Conor Dooley
2023-07-23  4:59     ` Andrea Collamati
2023-07-21  8:21   ` Krzysztof Kozlowski
2023-07-21  8:22     ` Krzysztof Kozlowski
2023-07-21 12:02       ` Andrea Collamati
2023-07-21 11:58     ` Andrea Collamati
2023-07-21 12:07       ` Krzysztof Kozlowski
2023-07-20 15:40 ` [PATCH v3 2/2] iio: add MCP4728 I2C DAC driver Andrea Collamati
2023-07-20 19:13   ` Jonathan Cameron
2023-07-21 19:47     ` Andrea Collamati
2023-07-23 11:34       ` Jonathan Cameron
2023-07-23  5:09     ` Andrea Collamati
2023-07-23 11:41       ` Jonathan Cameron
2023-07-23 12:15         ` Andrea Collamati
2023-07-23 12:47           ` Jonathan Cameron [this message]

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=20230723134721.1404d533@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andrea.collamati@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).