From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9854C00528 for ; Sun, 23 Jul 2023 12:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbjGWMr2 (ORCPT ); Sun, 23 Jul 2023 08:47:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjGWMr2 (ORCPT ); Sun, 23 Jul 2023 08:47:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BB9CE54; Sun, 23 Jul 2023 05:47:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0FD0760CFA; Sun, 23 Jul 2023 12:47:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80ECAC433C7; Sun, 23 Jul 2023 12:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690116446; bh=vom/MdLbeAAtjonsKG+U94PwQKGKIWz91c/Gxmed8fc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=H1INqRAYk72xLX1ZxaKxDaKsVxzzMHnOQvE7C3A2CALGMsvyEKlQWWwXZMm8cL5tp KrOST1seFIJkJ/TcBNTSIAQC7iz6tIpAmiPge0EN5UWGWTOe1g52aJuUDVsHSG3F+h Z/8mVjw21Demu1YrWEtLnyqPNX0lcjNFrSW8YsG5nvK0WNqT7AvkKtwqKM/2XivCbP oEJwAGKDFlBLnP6+cEYUo6GFQiwpPBO4iIAtzSTSb25UXPhKRVCilSribaaUGv7vqR SJdNFo6A226XBaFub6z6EOJ6q8bkQZ9xvaXls3/iOEc7Xf8pQs4q6bzXzVqfbdTG3z tRnIUCkP+cfbA== Date: Sun, 23 Jul 2023 13:47:21 +0100 From: Jonathan Cameron To: Andrea Collamati Cc: Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , 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 Message-ID: <20230723134721.1404d533@jic23-huawei> In-Reply-To: <15ee98bd-b92b-8a34-e3f9-a1537edf2da9@gmail.com> References: <3d08130fcb093fea3f755848690db9b2c8e1cb75.1689857295.git.andrea.collamati@gmail.com> <20230720201311.0142db3d@jic23-huawei> <739ea3c7-7181-183c-799d-a3f9403c7f66@gmail.com> <20230723124101.1af2ae2c@jic23-huawei> <15ee98bd-b92b-8a34-e3f9-a1537edf2da9@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Sun, 23 Jul 2023 14:15:10 +0200 Andrea Collamati wrote: > On 7/23/23 13:41, Jonathan Cameron wrote: > >>>> + > >>>> + if (mode =3D=3D MCP4728_VREF_EXTERNAL_VDD && > >>>> + data->channel_data[chan->channel].g_mode =3D=3D MCP4728_GAIN_X= 2) { > >>>> + dev_warn(&data->client->dev, > >>>> + "CH%d: Gain x2 not effective when vref is vdd, force to x1", > >>>> + chan->channel); =20 > >>> Even better if you don't present the option at all and wrap it up in = the > >>> standard ABI of _scale > >>> =20 > >> I think that the solution could be: > >> > >> - Removing custom ABI (vref/gain) > >> > >> - Initialize them at device tree level using two 4-elements arrays. =20 > > If doing with device tree, they should reflect something that is a char= acteristic > > 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. =20 >=20 > SCALE is appropriate. I didn't know that scale_available was a standard A= BI. >=20 > I will follow=C2=A0 the implementation done n https://github.com/torvalds= /linux/blob/c2782531397f5cb19ca3f8f9c17727f1cdf5bee8/drivers/iio/dac/ad5592= r-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 =3D 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