Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2526654imd; Sun, 28 Oct 2018 12:00:14 -0700 (PDT) X-Google-Smtp-Source: AJdET5fzTYlSBFtIUjh6xQnzV2+l2E2IcSesdgszoYKtYqiR6OKqfRnEi/ixbAxxaC/rEy0ziTAx X-Received: by 2002:a63:2c8a:: with SMTP id s132-v6mr10794118pgs.73.1540753214470; Sun, 28 Oct 2018 12:00:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540753214; cv=none; d=google.com; s=arc-20160816; b=CJQ1f/h6Yy9sQrcU1BgMlI1vxwmZEwNDBOLzzkzPoSfMkbbM0DWqbeiwEnHBfPMJTr wzlM44oGMkgxcyJIL9OB5EBlfqGsyocagdo96ixlpAw7UlpWhCrOI2cBmR47maLD7LbC bgbiwV4LkP9huxi9aN9uOJh3xbIwNB2LuXjPQbRVqRNY9BJRqfIhq5bLu7tVV9bJyhy2 wRzHp5HrbNa3tGS/lT/XOf1iAZsHVAqUtF5OFBCU3sprgQofJrW6qOHQlae/PY4y8ukv jwpRZCNlwRmjtFqwopXiG+SoGSL36YWPZIyA1AwUlVxKRY1Vnalf3MiyldyUCqBQ4t8Y 8DCg== 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 :dkim-signature; bh=MeXeQ3dQtGIu3EQf83VA7X/gZYmwsdMI1x5ySvtdXB4=; b=rCZyl6KlvCF0zRNFd+kdHr+1Nm1D8rJFkUmTZEmCb6QC3rwrVN9n7wHdghhdQ6PGGS 2B60ZsovysvOrDO7WpA8U2FGjW88TIVM2+fiIiC38v7EI+FVkoKo2sI9WtYEh6XJzUSs gGgxAcxAIlCLJ5xzXaB7jpRvqJuZ+UO1A2xJ4tHu8krm41C/SRE3LKMhV/39gfWgzof7 Mf4+uLPGGjm0EohncduoMwsXZBN8oQnLR16G/qDVBLCyNuZIcRbYvh4u2uDwbZhtvpWd pxRK7xqxwQren2Y4E4ZBnSrT5oG7e5jeA0x3VYtlRXwm7xgPB7/KNQ29GK00p4ynA2BI PL6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EwWtc7Zf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4-v6si14612482pli.119.2018.10.28.11.59.58; Sun, 28 Oct 2018 12:00:14 -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; dkim=pass header.i=@kernel.org header.s=default header.b=EwWtc7Zf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727346AbeJ2Dnl (ORCPT + 99 others); Sun, 28 Oct 2018 23:43:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:53704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbeJ2Dnk (ORCPT ); Sun, 28 Oct 2018 23:43:40 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 908D720843; Sun, 28 Oct 2018 18:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540753089; bh=VxHGpKTmt+3YiecjO4HIGrE86L25Lq5qFyt+1fyfUFs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EwWtc7ZfFiKKJzWwfB3hAtrrldBO6gH9MwkTUJXrMJNJKKB2aET+jv66QC3E9bBod ieToTyfRKWi+COYOLG1HR1RiFDFxeX5Twd72+29A5fNaH4fCvID0GPk7i8h255gQ7A KeFQwf/Dn9rdP/+yrPtm774buAAPWS8BPb5SiQIk= Date: Sun, 28 Oct 2018 18:58:03 +0000 From: Jonathan Cameron To: Renato Lui Geh Cc: lars@metafoo.de, Michael.Hennerich@analog.com, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, alexandru.Ardelean@analog.com, stefan.popa@analog.com, giuliano.belinassi@usp.br, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: Re: [PATCH v2 1/2] staging: iio: ad7780: update voltage on read Message-ID: <20181028185803.6dc8bb57@archlinux> In-Reply-To: <20181028165231.2det3cq3u7r6qoxj@renatolg> References: <1f7b2c6ee0e18b1c43a8b27f482b08313c52d4e9.1540506298.git.renatogeh@gmail.com> <20181028155611.67abeafb@archlinux> <20181028165231.2det3cq3u7r6qoxj@renatolg> X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 28 Oct 2018 13:52:32 -0300 Renato Lui Geh wrote: > Hi Jonathan, > > Thank you for the review. > > >> + voltage_uv = regulator_get_voltage(st->reg); > >> + if (voltage_uv) > >> + st->int_vref_mv = voltage_uv/1000; > >> *val = st->int_vref_mv * st->gain; > >Is there actually a reason (now) to have the stashed value > >of int_vref_mv in the state structure? > > From probe: > > if (voltage_uv) > st->int_vref_mv = voltage_uv / 1000; > else > dev_warn(&spi->dev, "Reference voltage unspecified\n"); > > So the idea was to, when voltage_uv = 0, return the previous voltage. > Should I instead handle this as an error the same way as in probe? > I would return it as an error. I can't really see how we would get this to occur if the bindings are all correct and appropriate driver support is there for the regulator to actually let us use it. If we wanted to handle the case of no regulator having been provided cleanly then we should it using an optional regulator get, and not provide the scale attribute at all if we can't know what it will read. This is a weird enough corner case though that I just wouldn't bother handling it as anything other than an error. > Thanks, > Renato Thanks, Jonathan