Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1575427imu; Sun, 16 Dec 2018 04:08:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/UHe2yTed+7/Q6bTq6VnwGuvVo36UDexiK4STitIUhjIyMbDrQrices911DqzIrgbi2c/4g X-Received: by 2002:a62:4e49:: with SMTP id c70mr9213484pfb.167.1544962105444; Sun, 16 Dec 2018 04:08:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544962105; cv=none; d=google.com; s=arc-20160816; b=VOtD01U8K0axE71gTGY0FHB4neDFCZGI89vWK4srHWXOlKm31WdvxZNJLbmPjsnrGZ sRmBcWAvg1h3mVAz2JeC5mdL58HuGEcwRKInQokzmDB6vEcvFbF5jbAuZOh4XmuHPUKF 3njbQiZWGO+63+8VvztFwb7gbX/FGeM8aNZ11eUatKyMQF3ufkOmweAwicswFpMK9elc W4t6IaNhx1N1XdCaU+k5z5Yfn7mHWvN9i8ATYel0t37K/XA+o9SFME39A4NiWEmtSuax dLvfcQsCUnhizOpF8xxLIz6AlQVl80tl1SaYmrXMDx10VeS30fTyvLyKLatr1KgqdwWc Hxyw== 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=NKOKbqwwJcYZ0yJgxVwpl3jDLPqYBoNhK1fxghSfSYc=; b=jahfs1nIJ30AGJLjDUOkcl5noj4JBp/SVYH8T2SSKMi8oYkXmSCvEypgVtjWzd0a7J wCFyOGOu2p4x2G3TIkSZc49FVCaIGZlvYYyL1dlchDJXAqQuHrkdj23eek2pE1iDQxvD Y9mdyPh8zZ1QfqrJpNDX7eMtYmzwR1Z/StkqtsyIXie5I4rCuqjicORKE/2mZU/A+o2o duuZVMvegQBBNUWdMxpfJQIkfjS8Tb9OxbfbLwZAnBV+bfuUH9ld110M0wGCXH9Bb4Js NjVjA1cR5Z7uZRLWJpwb8olpky3N1XCtuW9QXBGLvuHkdth6WF1yXzjGNf8IhW75rqke uOFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RWjc89Rl; 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 i12si8098750plt.213.2018.12.16.04.08.09; Sun, 16 Dec 2018 04:08:25 -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=RWjc89Rl; 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 S1730382AbeLPL7X (ORCPT + 99 others); Sun, 16 Dec 2018 06:59:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:37706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730021AbeLPL7X (ORCPT ); Sun, 16 Dec 2018 06:59:23 -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 EF343217FA; Sun, 16 Dec 2018 11:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544961562; bh=H++/7yGd5WGvrdilgvsCYCAdVkH/i0RPLtdlOZiM/3I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RWjc89Rlk1KdV72SYwJOfyXH14awr3pjkIqeJ9Qvaffvf/PtZlXbkDrRCMixOXt0C HcaR2mzEPvYI4jniiTZMjniJshC/XAXgBEasDiSp0nGsQA/q5VrumpGJ0ai97KgYSU Z81klGRcXa0/m7D3UirJV47T2SHm7TQhmkNpWC1g= Date: Sun, 16 Dec 2018 11:59:17 +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 10/11] staging: iio: adt7316: change interpretation of write to dac update mode Message-ID: <20181216115917.0c9739eb@archlinux> In-Reply-To: <20181212005503.28054-11-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> <20181212005503.28054-11-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:55:02 -0700 Jeremy Fertic wrote: > Based on the output of adt7316_show_all_DAC_update_modes() and > adt7316_show_DAC_update_mode(), adt7316_store_DAC_update_mode() should > expect the user to enter an integer input from 0 to 3. The user input is > currently expected to account for the actual bit positions in the register. > For example, choosing option 3 would require a write of 0x30 (actually 48 > since it expects base 10). To address this inconsistency, create a shift > macro to be used in the valid input check as well as the calculation for > the register write. > > Signed-off-by: Jeremy Fertic As I mentioned, long term this interface is going to need to be replaced with something more generic. Probably something like the power down modes where we use a string to describe what is going on on. Still this is a step in the right direction even if we may go further shortly! Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it, Thanks, Jonathan > --- > I'm not sure if this patch is appropriate since it's making a user visible > change. I've included it since the driver is still in staging. > > drivers/staging/iio/addac/adt7316.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c > index bca599d8c51c..58b462ad0c83 100644 > --- a/drivers/staging/iio/addac/adt7316.c > +++ b/drivers/staging/iio/addac/adt7316.c > @@ -129,6 +129,7 @@ > */ > #define ADT7316_DA_2VREF_CH_MASK 0xF > #define ADT7316_DA_EN_MODE_MASK 0x30 > +#define ADT7316_DA_EN_MODE_SHIFT 4 > #define ADT7316_DA_EN_MODE_SINGLE 0x00 > #define ADT7316_DA_EN_MODE_AB_CD 0x10 > #define ADT7316_DA_EN_MODE_ABCD 0x20 > @@ -879,11 +880,11 @@ static ssize_t adt7316_store_DAC_update_mode(struct device *dev, > return -EPERM; > > ret = kstrtou8(buf, 10, &data); > - if (ret || data > ADT7316_DA_EN_MODE_MASK) > + if (ret || data > (ADT7316_DA_EN_MODE_MASK >> ADT7316_DA_EN_MODE_SHIFT)) > return -EINVAL; > > dac_config = chip->dac_config & (~ADT7316_DA_EN_MODE_MASK); > - dac_config |= data; > + dac_config |= data << ADT7316_DA_EN_MODE_SHIFT; > > ret = chip->bus.write(chip->bus.client, ADT7316_DAC_CONFIG, dac_config); > if (ret)