Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3200664imu; Mon, 17 Dec 2018 15:22:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/UjMWzMU748BzcBIHJExRZDrbdtddkStaKNQUCZ8kzXOp0n9KqDhkwGlXCXdBfFFDYvrtfH X-Received: by 2002:a17:902:8e8a:: with SMTP id bg10mr14475500plb.192.1545088935186; Mon, 17 Dec 2018 15:22:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545088935; cv=none; d=google.com; s=arc-20160816; b=fbPSmN7ApzbGumCYDxNiKeRTra0N7hZd76ZFDCDTDD2Mp/+dAyyrldtEGyp2KZnN2r f3Z8LmoZHEdgTjQZ2OIbks7PVBgsT435BRhfLuSwR4U+mBkSShpxhLjhpMqa1lWBR1Br /74upKgdxJEwODNQHade/RpjJmrviZnz3JRWExF78nJ/+2x1f2qu5hko8DHgFLXEgVx6 uBYg5d66cRmg5753b7ymclGKyhkHZxrUddL+GVCL8rVpjoxKrFtZfWsauPkGQ8OA2IqK nWoelFtrmZVkjkyI1Oz84GJAmoczReHr9PgE8tAjSKWQSPEvnSz1Ac7wMGL6IPMFPFuE 218A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=AKxcgbmVgrnYzOEvNC+E0VaiE1aK1XC9JnB0F71H8a8=; b=bqFchSLGypkI7GSuNpCRyYwnnzWcUSeIHypkgnG3BoKMr9AfvbQKQwn/fF48e0uGDC v0FtPl75Zfqm2LOMj4pV6NaqQOerbf85iuPhy7lcgTQbT1P3vcbQn25WkCCW6SFqPC8d f32gNhjJghKxeBr8w7XS8wKcRU3RYcpJyQ9Ib02fjBqxjQPquChPJsruTdToz9xEnUZa RmrKCJgVXqB9/rXOZgbjJ1pBYrdmE+V7omL2+RKBCdd4p5ZIXqGtWS0JxeI+IoZrZ+YF dh5tGqqtbrCNS4nsOS6uyPK8J5IdefOMDCypMLVJUI62xGt0uROZXknGqtuh+a0/g7Yx iuUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=beKm2o94; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x74si12801467pfe.23.2018.12.17.15.22.00; Mon, 17 Dec 2018 15:22:15 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=beKm2o94; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726710AbeLQVcD (ORCPT + 99 others); Mon, 17 Dec 2018 16:32:03 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:41983 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388057AbeLQVbI (ORCPT ); Mon, 17 Dec 2018 16:31:08 -0500 Received: by mail-io1-f68.google.com with SMTP id s22so11153512ioc.8; Mon, 17 Dec 2018 13:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=AKxcgbmVgrnYzOEvNC+E0VaiE1aK1XC9JnB0F71H8a8=; b=beKm2o94nusHOf6fuMk/dauO0FrlUl7LM/3Drezp3v1GQhUZH5f4n9A9JZKPhqd3qc /XNps1Bu6IEMf5blDX3ugwz/vFqQeTYvTZgV/BaJ8xCoKXMy8vaMrcgccVH5lNtTg/gp DnvXE9gXhjfH9f7lQOXRGEVqH1/nP8zKuVM2bNLbSX3eToXX/sXk7lU8yho3p6FxtQbq Xn7/UL1rx+6mtBkvsxa3hrM4dIdpq5N10pyDlX8dD1oAh3hdooxw44Cv/rZjsw+aqKDS a85MyEDGXmK57zKwBkxhn+7ns0IRnJS14U+27BkZWRreHJ8mZPP2lLeh97qqSARBv7kR nvgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=AKxcgbmVgrnYzOEvNC+E0VaiE1aK1XC9JnB0F71H8a8=; b=cVgbFA1Le4EuZ8x9ed5U0HxqnJ/pDyIg6N4CgROC6VMfjC8i6DMzsYLOP59SDKxuXv fZbge8weX0sggCwIBFoy03RMffNyug5NN3sWg0kgBF38q7qr40WY0Vn50LXuRjwaf5Ms YSehapbp4wkV6iy7XhvYZgaHsILf1ZldoYm+AMuxn8WuDU2Bw9Grs31rJ4B4ctVZnJcs JDQoi3IHRTS7BnaP1VBfeIPu4SsAYrcWm+Uf/Vpa4eAlR8NINfEwmtkt/AOxFbKiYt9z bqQBFRprV8A5ScKfldMK/OPTOFyz1r3sxofQiZUxRDfwd/pv6l4w775yWA1RK5y4FzWI TLNw== X-Gm-Message-State: AA+aEWYGETsFqKnHMvQSGPUqPRGcqFaSw6DB2XGsS4IrDVuhXKa2RwDw cKos65LNu7f5FllzlA5+GHxW7nzzPKUP9w== X-Received: by 2002:a5e:8c12:: with SMTP id n18mr11551649ioj.231.1545082266686; Mon, 17 Dec 2018 13:31:06 -0800 (PST) Received: from r2700x.localdomain (c-75-70-96-103.hsd1.co.comcast.net. [75.70.96.103]) by smtp.gmail.com with ESMTPSA id c102sm213008itd.38.2018.12.17.13.31.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Dec 2018 13:31:06 -0800 (PST) Date: Mon, 17 Dec 2018 14:30:59 -0700 From: Jeremy Fertic To: Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 03/11] staging: iio: adt7316: fix dac_bits assignment Message-ID: <20181217213059.GA11856@r2700x.localdomain> References: <20181212005503.28054-1-jeremyfertic@gmail.com> <20181212005503.28054-4-jeremyfertic@gmail.com> <20181216113756.70d76d0a@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181216113756.70d76d0a@archlinux> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 16, 2018 at 11:37:56AM +0000, Jonathan Cameron wrote: > On Tue, 11 Dec 2018 17:54:55 -0700 > Jeremy Fertic wrote: > > > The only assignment to dac_bits is in adt7316_store_da_high_resolution(). > > This function enables or disables 10 bit dac resolution for the adt7316/7 > > and adt7516/7 when they're set to output voltage proportional to > > temperature. Remove these assignments since they're unnecessary for the > > dac high resolution functionality. > > > > Instead, assign a value to dac_bits in adt7316_probe() since the number > > of dac bits might be needed as soon as the device is registered and > > available to userspace. > > > > Signed-off-by: Jeremy Fertic > > I'm a little confused as it seems to me that in the orignal code > if we were setting high resolution 'off' we would fall back to 8 > bits for either type of device. Now you just have a check on the > device type? > > The result will be that we read more bytes than we want to > in show_DAC. > > I'd need a pretty strong argument to persuade me it is worth > supporting the 8 bit mode at all btw on devices that will go > higher. It adds interface complexity and the number of usecases > where the saving in bus traffic is worthwhile are probably fairly > few! > > Jonathan Thanks for the feedback Jonathan, and sorry for the confusion on this one. My commit message should have been clearer. This is not a general purpose option to change the dac resolution. It is specific to an optional feature where one or two of the four dacs can be set to output voltage proportional to temperature. If the user chooses to set dac a and/or dac b to ouput voltage proportional to temperature, this da_high_resolution attribute can optionally be enabled to use 10 bit resolution rather than the default 8 bits. It is only available on the 10 and 12 bit dac devices. If the user attempts to read or write dacs a or b under these settings, the driver's current behaviour is to return an error. The dacs c and d continue to operate normally under these conditions. With the above in mind, dac_bits should have never been assigned to in this da_high_resolution attribute. Before this patch, if the user didn't write to this optional attribute, dac_bits would be 0 since it was never assigned to anywhere else. This would result in incorrect calculations in show_DAC and store_DAC. Jeremy > > --- > > drivers/staging/iio/addac/adt7316.c | 18 +++++++++--------- > > 1 file changed, 9 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c > > index e5e1f9d6357f..a9990e7f2a4d 100644 > > --- a/drivers/staging/iio/addac/adt7316.c > > +++ b/drivers/staging/iio/addac/adt7316.c > > @@ -651,17 +651,10 @@ static ssize_t adt7316_store_da_high_resolution(struct device *dev, > > u8 config3; > > int ret; > > > > - chip->dac_bits = 8; > > - > > - if (buf[0] == '1') { > > + if (buf[0] == '1') > > config3 = chip->config3 | ADT7316_DA_HIGH_RESOLUTION; > > - if (chip->id == ID_ADT7316 || chip->id == ID_ADT7516) > > - chip->dac_bits = 12; > > - else if (chip->id == ID_ADT7317 || chip->id == ID_ADT7517) > > - chip->dac_bits = 10; > > - } else { > > + else > > config3 = chip->config3 & (~ADT7316_DA_HIGH_RESOLUTION); > > - } > > > > ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG3, config3); > > if (ret) > > @@ -2123,6 +2116,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, > > else > > return -ENODEV; > > > > + if (chip->id == ID_ADT7316 || chip->id == ID_ADT7516) > > + chip->dac_bits = 12; > > + else if (chip->id == ID_ADT7317 || chip->id == ID_ADT7517) > > + chip->dac_bits = 10; > > + else > > + chip->dac_bits = 8; > > + > > chip->ldac_pin = devm_gpiod_get_optional(dev, "adi,ldac", GPIOD_OUT_LOW); > > if (IS_ERR(chip->ldac_pin)) { > > ret = PTR_ERR(chip->ldac_pin); >