Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1557327imu; Sun, 16 Dec 2018 03:40:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/WsZQiXs4xsCS9BoYgMwohkh88KSe1lkYiCyDIbTH+GAYFBxixOtYdS1F4APNmZVBYijx0k X-Received: by 2002:a63:ec13:: with SMTP id j19mr8715488pgh.6.1544960412654; Sun, 16 Dec 2018 03:40:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544960412; cv=none; d=google.com; s=arc-20160816; b=b0/1G4D6QgKR/7dddk4eZdjJyq6f45/alUZjZ3me8h9IlsnGJlJQPvaw9xyMZPatTI 4wxZrVKB+8lFfYq6FIgU0WTJ9r92J/RLAO+CgPLfEb79gLeaxxAcnM+8mukDUX43+eE+ Yedc1Lg5l4d8Td0NxwrtHUGoYMUZ+A9cV0jxD0k62eGYU+Oq/Peh9gQxI70u0PCZoEBq UKJ+Jta5/FKNQzVO5uOws8yXGS20LJRJXvfdp8gzxPLlZOrL+/r2GtozgsZcRrCN4Qq9 uus3aAJL4squDpO2yNGMdkrEQwD5JBxOk/F7RRYF5lGjVhePVhjOCWsSyNSeydZCSEdj t+uA== 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=jvi7XEQysJwk8bxXTWnnStBVIkULCesMCLGD92gxMsg=; b=StqDwDzcO+6dGIxiM38O/u0yscTYdwXYZOBlgcaP82H9NvVrVZ+dQqprdKeEa2Nw4s cZXBT4a5+ykjSYek0Szsuw/Oy3cKDHgsri+H70cHHQzaWHSbfJ+NdlypGj3yMX7a+li4 KeBPwibk/B2QaESnbDvBKNYKOZl6BQPCPf2zJDbmRqkp85q3iqux+i2tqxtyKb3r+XP/ RFj/ltZenPVl4IPM5zTTT75jnH40/FUj3ScNuAM9yT8HUrHgZ2LWLsZ976o9/RIoKcjh 1SpU4He9PmrdUu9uCByvi/LOQrGZrsZln44iUoOXOMicOE58aNuIeD/APGCfJGNTZhsA 5OAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=angTVWlQ; 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 a35si8554669pla.226.2018.12.16.03.39.57; Sun, 16 Dec 2018 03:40:12 -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=@kernel.org header.s=default header.b=angTVWlQ; 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 S1730212AbeLPLiD (ORCPT + 99 others); Sun, 16 Dec 2018 06:38:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:52104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729820AbeLPLiC (ORCPT ); Sun, 16 Dec 2018 06:38:02 -0500 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 CD17A2086C; Sun, 16 Dec 2018 11:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544960281; bh=M6XUzuVDGLO/6xOZ3iXrKw7tPNKFVRPI8SwQOMFRp3w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=angTVWlQcOhD3OetVpkgAdJu1cQEKQco1yTm52Iz5NDQdh3lNjSUPOGdpuGyDDm6x PFK6B+f9g3ogHaQ6XCqPZ/AorRJTH6tKGiANupiF/J8zycnAqfW1wKA/ohUS5J9smS /CTk773lSq8igCzMycNi5ZUw6SpCWs/+t6mTAB3U= Date: Sun, 16 Dec 2018 11:37:56 +0000 From: Jonathan Cameron To: Jeremy Fertic 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: <20181216113756.70d76d0a@archlinux> In-Reply-To: <20181212005503.28054-4-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> <20181212005503.28054-4-jeremyfertic@gmail.com> X-Mailer: Claws Mail 3.17.2 (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 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 > --- > 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);