Received: by 10.213.65.68 with SMTP id h4csp653827imn; Tue, 27 Mar 2018 06:25:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELt0m8oujQY+gDM3M8nohR6ym+IACLByeSfJuCGSr6Zd0anCsUInwLtTsXQTggS9vpxhVV6b X-Received: by 10.98.189.24 with SMTP id a24mr36972014pff.125.1522157118454; Tue, 27 Mar 2018 06:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522157118; cv=none; d=google.com; s=arc-20160816; b=LtjOJ4PtxZ6EwemL89PNqV1T1Mi2ADiI3u7GDDT4KCVKqCdKBAo1aTpHxe9kd5ka9E fQjEYFwpS5Wskvz33asgNwJSgNR+dC8wpIsjjk65UEAmqtJz1GPKsmEUHV0cnw5bbj4z SxSJ+qPMUidY3AG+4d83UECEQ0NLqdaq6N/aYcm3+aZqDV+vSllbGexW5EI1Q6+KSTmb Eb9sczbj4lFFxEdqjwXsSfu+YGvjc4yDZBgyzMnF/EvuVx/dhxuj8vzcSD0txP/zJwhP I/wGOr6alMEeXQAtBVlco6Xcp5uircYN2/WfATHdoC3jpiGnVZ/VvnENcLJI4BmL4db2 FkOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=HkTvn0Y+Uy5znvPZrUbMQ3HzodwrGtwLcXJabNLT7Y8=; b=pzio2Au7sZMdlB6r02SylyKMx9gNAfTb5TKEeFF9PP2i8TF2eIuyAcRl+ExDm5sJXp Lpp+3X7PAd7cmfgT49uAqeOkGqeGPkNHz/TYeyn0Lo4vhpKIPSSuc1Xzq5KvDT44ZESE KQ1u9B/+hOpafKGC7XUBS/3XOm4AWk9BI+vKbmTzw+MW3XaOb+9OZoD00NMTMwq8uHFG b0a183DeGSw0KxCfHiYrShgr6G7IWSAemj3RyvgL9ttWKkHIzCYFrpqBrkaUZTO6ryR3 KLMollVwRHTe3nlNJEwhS22RceXGKcQPbCbtUne5KfMTbdCn7v8p6RrVUu78+0iFRhk7 79fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8si842702pgv.740.2018.03.27.06.25.04; Tue, 27 Mar 2018 06:25:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752955AbeC0NXP (ORCPT + 99 others); Tue, 27 Mar 2018 09:23:15 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:42340 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752416AbeC0NXN (ORCPT ); Tue, 27 Mar 2018 09:23:13 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 97FA321DAAFBA; Tue, 27 Mar 2018 21:23:08 +0800 (CST) Received: from localhost (10.202.226.43) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 27 Mar 2018 21:23:07 +0800 Date: Tue, 27 Mar 2018 14:22:56 +0100 From: Jonathan Cameron To: Peter Rosin CC: Jonathan Cameron , , Hartmut Knaack , Lars-Peter Clausen , "Peter Meerwald-Stadler" , Rob Herring , "Mark Rutland" , "David S. Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Linus Walleij , "Randy Dunlap" , , Subject: Re: [PATCH 3/3] iio: wrapper: unit-converter: new driver Message-ID: <20180327142256.00003056@huawei.com> In-Reply-To: <1e950fde-d3d9-ca9c-1055-7ab8fc57fc4a@axentia.se> References: <20180319170246.26830-1-peda@axentia.se> <20180319170246.26830-4-peda@axentia.se> <20180324140339.4ec66792@archlinux> <1e950fde-d3d9-ca9c-1055-7ab8fc57fc4a@axentia.se> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.43] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Mar 2018 09:42:40 +0200 Peter Rosin wrote: > On 2018-03-24 15:03, Jonathan Cameron wrote: > > On Mon, 19 Mar 2018 18:02:46 +0100 > > Peter Rosin wrote: > > > >> If an ADC channel measures the midpoint of a voltage divider, the > >> interesting voltage is often the voltage over the full resistance. > >> E.g. if the full voltage it too big for the ADC to handle. > >> Likewise, if an ADC channel measures the voltage across a resistor, > >> the interesting value is often the current through the resistor. > >> > >> This driver solves both problems by allowing to linearly scale a channel > >> and by allowing changes to the type of the channel. Or both. > >> > >> Signed-off-by: Peter Rosin > > A few comments inline, but basically the code looks fine, just questions > > around naming and bindings to answer. > > > > Thanks, > > > > Jonathan > > > > *snip* > > >> +static int unit_converter_write_raw(struct iio_dev *indio_dev, > >> + struct iio_chan_spec const *chan, > >> + int val, int val2, long mask) > >> +{ > >> + struct unit_converter *uc = iio_priv(indio_dev); > >> + > >> + switch (mask) { > >> + case IIO_CHAN_INFO_RAW: > >> + return iio_write_channel_raw(uc->parent, val); > > Talk me through the logic of having this... Supporting a DAC? > > Bindings don't talk about that possibility... > > There's no logic at all, and I don't need it. It's just leftovers, > should I remove it? > > >> + } > >> + > >> + return -EINVAL; > >> +} > >> + > > *snip* > > >> +static int unit_converter_configure_channel(struct device *dev, > >> + struct unit_converter *uc, > >> + enum iio_chan_type type) > >> +{ > >> + struct iio_chan_spec *chan = &uc->chan; > >> + struct iio_chan_spec const *pchan = uc->parent->channel; > >> + int ret; > >> + > >> + chan->indexed = 1; > >> + chan->output = pchan->output; > >> + chan->ext_info = uc->ext_info; > >> + > >> + if (type == -1) { > >> + ret = iio_get_channel_type(uc->parent, &type); > >> + if (ret < 0) { > >> + dev_err(dev, "failed to get parent channel type\n"); > >> + return ret; > >> + } > >> + } > >> + chan->type = type; > >> + > >> + if (iio_channel_has_info(pchan, IIO_CHAN_INFO_RAW)) > >> + chan->info_mask_separate |= BIT(IIO_CHAN_INFO_RAW); > > if the parent doesn't support RAW, is there a lot of point in carrying on? > > Nope, better to error out I suppose. But I'm not familiar with channels > without RAW, what alternatives are there anyway? Potentially _PROCESSED though that will need somewhat different handling. A nasty trick for that might be to map it to RAW and then have the SCALE reflect the divider circuit scale only. It's perfectly possible to have channels with neither _RAW or _PROCESSED but I suspect we don't care about them here. There might be an application that needs to do buffered data flows in the long run, but we can figure out how to do that when one exists. It won't be a huge amount more than you have here, though we might need a trigger pass through as well to allow you to set the trigger for the front end and having it automatically applied to the backend. Jonathan > > >> + if (iio_channel_has_info(pchan, IIO_CHAN_INFO_SCALE)) > >> + chan->info_mask_separate |= BIT(IIO_CHAN_INFO_SCALE); > >> + > >> + if (iio_channel_has_available(pchan, IIO_CHAN_INFO_RAW)) > >> + chan->info_mask_separate_available |= BIT(IIO_CHAN_INFO_RAW); > >> + > >> + chan->channel = 0; > >> + > >> + return 0; > >> +} > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html