From patchwork Wed Dec 12 00:54:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6F3C112E for ; Wed, 12 Dec 2018 00:55:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6A7329FF0 for ; Wed, 12 Dec 2018 00:55:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA9442A17B; Wed, 12 Dec 2018 00:55:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5807B29FF0 for ; Wed, 12 Dec 2018 00:55:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726266AbeLLAzp (ORCPT ); Tue, 11 Dec 2018 19:55:45 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:38527 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbeLLAzp (ORCPT ); Tue, 11 Dec 2018 19:55:45 -0500 Received: by mail-io1-f68.google.com with SMTP id l14so13449195ioj.5; Tue, 11 Dec 2018 16:55:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ry4gCuZwxl4eTtZDuPmKDxqeBqB1zeEesHvItHlLEa8=; b=kC4WdKD2r4PK0fbt9txKCC70r/0VAPoug/fgGzehJXaG/ALY478m74qCbDxsAj1KPl IDGQFjptY3jSUs2FfR+v4bEx2ELuZ8wS+7lmO0nx8wF1gGiN5M+zgIF16hURNxLdZlTU qnrv72e42CXgWZ6xpfVf+HSST0Z4gJNPwKrupeAySvzi1tDnhnfUgHCHtPSCu/t1JVxV ToeP6es9391XvIJveMWt0ezWZUBRVh89mQZJIabr0Rs1n5wQQVUJfAo8tcVS7KnRlbSO rRQqbUHtst8WvsahzPYiye9H0M9Y2ky4eNFig9prLjobe8jfWK4vyOLBu9PNGXf3tJFg /mdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ry4gCuZwxl4eTtZDuPmKDxqeBqB1zeEesHvItHlLEa8=; b=eyqYOW3Hg1MRvCwIopZlmAtElyCDlSFqy0VAA8AId+y4vBH+A0YWZyxlANZnWdy1ME wxQF5UK+ei515kWSD3kwxILbXvchwcM+LqRk4dkxRPQxvp8gS54USyQp1bFQacr0AJ2V n1+r8Q016z8h4jrPiDJ2ZCRrEeApv3eXRgyEK7QIGU69t6r2/gs5NScu2eS9tnMTacde e+FSMKL5UHe0F5IbIdTZlsGvqYnQjDL680/xHrHNNghPuWhB9SPScMMOTDK05IDHSemd zn6kFNKDnpjLMKA/iMAz78aj2LYQcGBPpsNvAFqkUgKBloIsg12QofBlHZldeBl9q4va vAog== X-Gm-Message-State: AA+aEWbl4iQUsSOKYza2H2RVEX6LZ9n5rjX7g66L9qM1sv5RKEcbzBq6 cE5HN14zvO2pRhjjYmzC5dCQINT2o0U87g== X-Google-Smtp-Source: AFSGD/V7KmA8s/g3ILTXk/GLlykDvOAr2VRl/J308rm2jFuHubMr1hNkdsnQAlQ/d2sfrW+VmAAKZw== X-Received: by 2002:a6b:d005:: with SMTP id x5mr15420936ioa.46.1544576144438; Tue, 11 Dec 2018 16:55:44 -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 l186sm1952445itl.22.2018.12.11.16.55.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:44 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 01/11] staging: iio: adt7316: fix register and bit definitions Date: Tue, 11 Dec 2018 17:54:53 -0700 Message-Id: <20181212005503.28054-2-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change two register addresses and one bit definition to match the datasheet. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index dc93e85808e0..1fa4a4c2b4f3 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -59,8 +59,8 @@ #define ADT7316_CONFIG1 0x18 #define ADT7316_CONFIG2 0x19 #define ADT7316_CONFIG3 0x1A -#define ADT7316_LDAC_CONFIG 0x1B -#define ADT7316_DAC_CONFIG 0x1C +#define ADT7316_DAC_CONFIG 0x1B +#define ADT7316_LDAC_CONFIG 0x1C #define ADT7316_INT_MASK1 0x1D #define ADT7316_INT_MASK2 0x1E #define ADT7316_IN_TEMP_OFFSET 0x1F @@ -117,7 +117,7 @@ */ #define ADT7316_ADCLK_22_5 0x1 #define ADT7316_DA_HIGH_RESOLUTION 0x2 -#define ADT7316_DA_EN_VIA_DAC_LDCA 0x4 +#define ADT7316_DA_EN_VIA_DAC_LDCA 0x8 #define ADT7516_AIN_IN_VREF 0x10 #define ADT7316_EN_IN_TEMP_PROP_DACA 0x20 #define ADT7316_EN_EX_TEMP_PROP_DACB 0x40 From patchwork Wed Dec 12 00:54:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0269D1751 for ; Wed, 12 Dec 2018 00:55:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E67D929FF0 for ; Wed, 12 Dec 2018 00:55:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA9722A17B; Wed, 12 Dec 2018 00:55:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 910F029FF0 for ; Wed, 12 Dec 2018 00:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726343AbeLLAzr (ORCPT ); Tue, 11 Dec 2018 19:55:47 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:50643 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726238AbeLLAzq (ORCPT ); Tue, 11 Dec 2018 19:55:46 -0500 Received: by mail-it1-f196.google.com with SMTP id z7so6616229iti.0; Tue, 11 Dec 2018 16:55:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WutpXEqDWOEGA5iAvwKj2DUy8q71VLFNSfE3FWc9wZU=; b=dIABhlg2XMLiVd1VF+HfKfYAO4bnlFUHi260Y11mf4RIRr+wegR7J23F3h2dhqPSBH 7Dsa898p4RqLoYIPWtMuI5QMo6otxyeYC2Qw8vzVoDT2qEnoTCMSf8v+9DgNIx5O+Kg2 rjo7J3Y3nxffYJrVAVdPgHqiFHk/hI6pp7MluO8iLWW/jRtovQ6SmnXdLGxISRmPUJaH 9S2YyO6SGtrGJiGKSLFVOitHgl/FSrqhTjiNwJzZoiLS9vEd21NiypcMtDFAozAnllbk 3qpvzlf0akjr4f22NT13WLX880lmxrsLG7aRjLnhTav6QXUKc7r29x08BJwDywDJ79qp RCuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WutpXEqDWOEGA5iAvwKj2DUy8q71VLFNSfE3FWc9wZU=; b=idS1W26HtBZEsU/cY6wnpwlrYim5QWJY1tv/EdcoHCWw//cpX1Tnm5WkZ+T+VuXEnO n1+rJJnzp9SfvOjHBMYETRKjolK75mOgTqlewtlTzjHlGp20FbUPZqnIdDNWszRv/x8R kZ46czMFs3wJFrWwLv2hhkEuWbSTC4TKAk2KUPBCEQPDQG0gNEe2WISXxfs5fUyGUGr5 Ym4Dj4IuYyppLDJ6RDZ3yylX7SiLhGtT72aGKtMr3wBAMSeRigr17g2KNvkhKiwtKYfu 3PI2mDIVh65KcJvMWYgUOQcNRvX2TrFzLAikRo0w1W0vZa8kv9st1mLqDnLTbUJLgJ3N SYQQ== X-Gm-Message-State: AA+aEWZribKfdQH2K7UclPigosgmkAvYIsNPESMY/+R61kys5Ql4Npib yf4LYkLj8+IGEa7lcAmoocM= X-Google-Smtp-Source: AFSGD/WHf90gOW9ZEg2Es87ClvbpOEcJc3p/q7CUQwNPDxSbALRSaxo38G5pq1I5oegyVWyqX18qXg== X-Received: by 2002:a24:6983:: with SMTP id e125mr4049738itc.26.1544576145387; Tue, 11 Dec 2018 16:55:45 -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 l186sm1952445itl.22.2018.12.11.16.55.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:44 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 02/11] staging: iio: adt7316: invert the logic of the check for an ldac pin Date: Tue, 11 Dec 2018 17:54:54 -0700 Message-Id: <20181212005503.28054-3-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ADT7316_DA_EN_VIA_DAC_LDCA is set when the dac and ldac registers are being used to update the dacs instead of the ldac pin. ADT7516_SEL_AIN3 is an adc input that shares the ldac pin. Only set these bits if an ldac pin is not being used. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 1fa4a4c2b4f3..e5e1f9d6357f 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2130,7 +2130,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, return ret; } - if (chip->ldac_pin) { + if (!chip->ldac_pin) { chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) chip->config1 |= ADT7516_SEL_AIN3; From patchwork Wed Dec 12 00:54:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F62F112E for ; Wed, 12 Dec 2018 00:56:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F52329FF0 for ; Wed, 12 Dec 2018 00:56:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 634972A17B; Wed, 12 Dec 2018 00:56:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C8F429FF0 for ; Wed, 12 Dec 2018 00:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726282AbeLLA4r (ORCPT ); Tue, 11 Dec 2018 19:56:47 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:39742 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbeLLAzs (ORCPT ); Tue, 11 Dec 2018 19:55:48 -0500 Received: by mail-io1-f68.google.com with SMTP id k7so13460431iob.6; Tue, 11 Dec 2018 16:55:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c5E07akhdcWo/3PoSb43yQur9QVQnOkKDZoez6erp7I=; b=d9ypycKjkwzd6rqksdJh8AddulggNHT3Ns1qjmlEnNh8wwTtLc+J4H1BvdGsAnt5Dp 1YI0J2ebEyMRqEiMVhqp1EU+V7LhEqA3CPPILSPl4vOhr18NOMNxX8u/bzjsSEfA+OEV zThWhGujFHVV28PQNekszZW9gmhkr5mtr2exH2fFMEJEzXUI57zXQaMkx+v1R8dMFqLc nxBgEqtRMkfHOSVLL+TwXnPEgXcQLta+lEX/5zaGqRzDUG8x1lNtEV785f1TQJ3P4/+b +RnB0qgdakTrqnepEyHEnMiEUzV/N2okeeReMygGDOpqp0dNEHJTX66KqkJ/I1/hdrlo ZXQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c5E07akhdcWo/3PoSb43yQur9QVQnOkKDZoez6erp7I=; b=Yoqbx1y+wdFpz7NrxDxBQKmZVnEDcIt8LRAp+VL8rMJJcL0MayJ8e62jSXYA4GkZVn 2ZICRPaLoc5/WOQkfHgZ3g1AfBS0fuU911Pd8b4iYTmg0byd5QaID7O6psl/K50AF1iU uKnRvfHpl0EG5saN/byyup4yJpeVJAf1iknrgpBSL8a33t5Ski8jydorQRl5vzfLMOkD 2L3yCuifbFWGXQYTDYG3d9if0IgxqfeUOWJxabZ6GMywrdMaFHTeAUn7MzZ4lDdqDOrd qFNcSNXi1UV3yUtn01LimRCK7fPalWygZibQHUQjqCSZReSJzy8EAiFfxXS77yDb3VEh 3Ytw== X-Gm-Message-State: AA+aEWZGMCmAGUB6w4BZOzV+4P1GPt4ZyyNozlFiE5ea4G6xtm2Qb9eY jNGJvHM3hHCnwoIRepf2pG8= X-Google-Smtp-Source: AFSGD/W9lZHjxkQ4LfQfOa89lNKtI/Wf2Sjgfy7IBPZBbs6hTi8RZjmQkGfOLV6GttLxw7d2tZuhWg== X-Received: by 2002:a5d:9405:: with SMTP id v5mr2635510ion.250.1544576146266; Tue, 11 Dec 2018 16:55:46 -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 l186sm1952445itl.22.2018.12.11.16.55.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:45 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 03/11] staging: iio: adt7316: fix dac_bits assignment Date: Tue, 11 Dec 2018 17:54:55 -0700 Message-Id: <20181212005503.28054-4-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); From patchwork Wed Dec 12 00:54:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A461D112E for ; Wed, 12 Dec 2018 00:56:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D07A29FF0 for ; Wed, 12 Dec 2018 00:56:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E21B2A17B; Wed, 12 Dec 2018 00:56:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18C2129FF0 for ; Wed, 12 Dec 2018 00:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726457AbeLLA40 (ORCPT ); Tue, 11 Dec 2018 19:56:26 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:51248 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbeLLAzs (ORCPT ); Tue, 11 Dec 2018 19:55:48 -0500 Received: by mail-it1-f194.google.com with SMTP id x19so6590893itl.1; Tue, 11 Dec 2018 16:55:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R9m4u/5qRzRhLWACB0cQ5SHyFZ5Alna3mIM8KLpqRaI=; b=ayHUN/rmzuj91miDhLWFP2JBJGfpKbx165FbXSx6ISN8AMG6AZWWMzxV5xEvvIql+H LSC/YPjPrUuzI12XKh00ZAOvN2fvnYhT1CR3dJqWQCsjcSEoR/8A6QMi+/cYyYJzJmNx SB6upjXwcLQxzaLl2rWIuVq52pg5gfotT9yFJoziQdzIqvZHaKKQlfKCpcOsLsl86urS Yoj0ExdRyXcuJokv0JT7isWXmPfClRC/WD8ofz71Gll6W3cE8g4hFcnSIPsN54Ci4nKK OXW3a88aOVfllJmfPE6NnfOGW+HcOEBtwoesekOLtK1lfMPJrkP0RUGvbdZPHgOUt4B7 olsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R9m4u/5qRzRhLWACB0cQ5SHyFZ5Alna3mIM8KLpqRaI=; b=EY4P9KUUk++K5T9fABQb1FS0mfV8EXd3E/2PRHXuBEwDjbaItEagAkk20JixCv883s 12NRtVqZWWoxxWA7mYdvWgB8pw4fIOXPRJ+CsXgAwSLb+9Wnl6cs5Ktfgl62m0EyKNwY hLhLNMiRkEqkTy9Y1xJTqY9l2xXmqcLAaxiIok+nJ/dOce7ZGkhK/55oPRrtys+2cENg mm2I/YlF4SpJeSwLlaQhMR0rQ/5wZ0KYruW+jhm5lZ4dlIQjUTUY8vTzK39K3YdVpfL2 QQV62c3hu9IvJgozxYkYJM0XbO2HJYvCckV4naDXptBG0ptoMZItpA3hLZRoQpE+71Ya sneA== X-Gm-Message-State: AA+aEWbT4lMIgWHQhRdRQZ3u91cMZgSidn/aVHgylh+2FmDtKKSpio/5 Z46MABLChOJfa9jc2jbGTdk= X-Google-Smtp-Source: AFSGD/VcQRj3/cdGYpYQvSYIt9y3IIBSkosId3WSXwPeN7Jt0dngo4LfLpSSPjP0aqQ/oQwrlg7J7g== X-Received: by 2002:a24:3046:: with SMTP id q67mr4458295itq.42.1544576147179; Tue, 11 Dec 2018 16:55:47 -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 l186sm1952445itl.22.2018.12.11.16.55.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:46 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 04/11] staging: iio: adt7316: fix handling of dac high resolution option Date: Tue, 11 Dec 2018 17:54:56 -0700 Message-Id: <20181212005503.28054-5-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The dac high resolution option 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 the "1 (12 bits)" output from the show function since that is not an option for this mode. Return "1 (10 bits)" if the device is one of the above mentioned chips and the dac high resolution mode is enabled. In the store function, return an error if the device does not support this mode. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index a9990e7f2a4d..eee7c04f93f4 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -632,9 +632,7 @@ static ssize_t adt7316_show_da_high_resolution(struct device *dev, struct adt7316_chip_info *chip = iio_priv(dev_info); if (chip->config3 & ADT7316_DA_HIGH_RESOLUTION) { - if (chip->id == ID_ADT7316 || chip->id == ID_ADT7516) - return sprintf(buf, "1 (12 bits)\n"); - if (chip->id == ID_ADT7317 || chip->id == ID_ADT7517) + if (chip->id != ID_ADT7318 && chip->id != ID_ADT7519) return sprintf(buf, "1 (10 bits)\n"); } @@ -651,10 +649,12 @@ static ssize_t adt7316_store_da_high_resolution(struct device *dev, u8 config3; int ret; + if (chip->id == ID_ADT7318 || chip->id == ID_ADT7519) + return -EPERM; + + config3 = chip->config3 & (~ADT7316_DA_HIGH_RESOLUTION); if (buf[0] == '1') - config3 = chip->config3 | ADT7316_DA_HIGH_RESOLUTION; - else - config3 = chip->config3 & (~ADT7316_DA_HIGH_RESOLUTION); + config3 |= ADT7316_DA_HIGH_RESOLUTION; ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG3, config3); if (ret) From patchwork Wed Dec 12 00:54:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52888112E for ; Wed, 12 Dec 2018 00:56:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41AFE2A150 for ; Wed, 12 Dec 2018 00:56:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 346D92B2B6; Wed, 12 Dec 2018 00:56:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC12E2A150 for ; Wed, 12 Dec 2018 00:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726363AbeLLAzv (ORCPT ); Tue, 11 Dec 2018 19:55:51 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:38531 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726354AbeLLAzt (ORCPT ); Tue, 11 Dec 2018 19:55:49 -0500 Received: by mail-io1-f67.google.com with SMTP id l14so13449296ioj.5; Tue, 11 Dec 2018 16:55:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BqAI0hgInZRj/HqBspWobjcKVjc1X8/CWrZ8LYW+zYw=; b=rOJtOOj1/y0YQUdYJ6Z0+0sKiPNOzB6zvmboZBJGRE2W2t3EWjhe9w/TD5V7rP4n1y C+FvH/UmfcZ+FBWdJX2lj9EFh4mSTpFfJ0DEzyrT3LwELXen1MLNLbDmHWV8IKpdhnx8 kNzLv7z6vnEFNgXiEqHqw8Xj/eRqfI03MN3s7+MOCyhqcYs4zXVpkJXgIYyrydOqxZs6 HtIKyXG4A7bibmbeQfRYaCPj+k2IsN99SWBZotuE8oH6tv+YGtJdiN9e7PeC122jNk2a y9fTMr2ZOu6Td0UJuzzp7beNEWESvLf+1L2kqNTWKLjsux+lhW+8yHUXnNHJ/i4lCqoE ebNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BqAI0hgInZRj/HqBspWobjcKVjc1X8/CWrZ8LYW+zYw=; b=SRxRZTo/wHeA8lbB24jazJFdWGLddOQlEY/YdAPNkXTgHSweNed7CfNahkMRt1xaWn ocP21wI4Ui2OGTN41/QnprR24QDXDwyrvHNFmuUvLsoDN65fYgP97t+oZNa9OcSkob0/ iNrE1dnXgRwJaVMJebFtx99PpoE98wTcP/NNbap0kJlvzOzUsYm0kPXtwY86Y4SSsziZ 8gRiy8UP9ZqPOQg768UwQRkHqpu+YKP5JWN3KhLeLpzFispH9fRAYZZ1ONflmudOZIqG 4sa6J+EKHct7RS9VzRYGyxcHCgkisu+YkU2DVHo0f4dBAd9urdVxFfSE/IhYA/Yte2mr Hzww== X-Gm-Message-State: AA+aEWbf75Prs78mij9x5SZaUE5kOH+1Mee9XdQ0W243kFxC8UupYRwC SJ+aEz2hzijz4wFNBDhYaHI= X-Google-Smtp-Source: AFSGD/WObtNO2qHxwlg71Fiw23sLuwOvHNO26nAw9w3l66/EHzGSTgS52c7Iqpgn//u6SlEKq02mTw== X-Received: by 2002:a6b:b28a:: with SMTP id b132mr15048308iof.256.1544576148191; Tue, 11 Dec 2018 16:55:48 -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 l186sm1952445itl.22.2018.12.11.16.55.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:47 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 05/11] staging: iio: adt7316: fix the dac read calculation Date: Tue, 11 Dec 2018 17:54:57 -0700 Message-Id: <20181212005503.28054-6-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The calculation of the current dac value is using the wrong bits of the dac lsb register. Create two macros to shift the lsb register value into lsb position, depending on whether the dac is 10 or 12 bit. Initialize data to 0 so, with an 8 bit dac, the msb register value can be bitwise ORed with data. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index eee7c04f93f4..b7d12d003ddc 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -47,6 +47,8 @@ #define ADT7516_MSB_AIN3 0xA #define ADT7516_MSB_AIN4 0xB #define ADT7316_DA_DATA_BASE 0x10 +#define ADT7316_DA_10_BIT_LSB_SHIFT 6 +#define ADT7316_DA_12_BIT_LSB_SHIFT 4 #define ADT7316_DA_MSB_DATA_REGS 4 #define ADT7316_LSB_DAC_A 0x10 #define ADT7316_MSB_DAC_A 0x11 @@ -1403,7 +1405,7 @@ static IIO_DEVICE_ATTR(ex_analog_temp_offset, 0644, static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip, int channel, char *buf) { - u16 data; + u16 data = 0; u8 msb, lsb, offset; int ret; @@ -1428,7 +1430,11 @@ static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip, if (ret) return -EIO; - data = (msb << offset) + (lsb & ((1 << offset) - 1)); + if (chip->dac_bits == 12) + data = lsb >> ADT7316_DA_12_BIT_LSB_SHIFT; + else if (chip->dac_bits == 10) + data = lsb >> ADT7316_DA_10_BIT_LSB_SHIFT; + data |= msb << offset; return sprintf(buf, "%d\n", data); } From patchwork Wed Dec 12 00:54:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E53BB1869 for ; Wed, 12 Dec 2018 00:56:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D623B2A150 for ; Wed, 12 Dec 2018 00:56:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7C112B2B6; Wed, 12 Dec 2018 00:56:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 786502A150 for ; Wed, 12 Dec 2018 00:56:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726220AbeLLA4Z (ORCPT ); Tue, 11 Dec 2018 19:56:25 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:52910 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726238AbeLLAzu (ORCPT ); Tue, 11 Dec 2018 19:55:50 -0500 Received: by mail-it1-f194.google.com with SMTP id g76so6587968itg.2; Tue, 11 Dec 2018 16:55:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8x3EfAi+dwJT7LG9r3AqAVh9KBm9FxEhlGxf1nFjco4=; b=ONp0a3WsAdCvn6qEPX78E5QC9Mz6d6oRqo1iXX2JUGBV985+YrC2aEi0zru+q7VFfK 6csxPZpiGZhsFx4/ttWg8jxX8prv2ZmZtOYSulIvoDhSAHs2OwBK4J87Jho8O1K43AAX 60hYcWdRVgTjsEmP2KwN/Qz6QCfK2LaYMDZyyFjmmkjupBeKC0RyyzNCkUPXOw+Pk2PV /HsXdOdgZgnijJgsVkq+aFnnoGtwmEUdaYnJu9VoUw51j5JhX05u0bKdBJW8V5pGLgDH A+CQiHENTWdqQ1QUtkoOHWQw+FEdEj3oOXkMZo1yD8gcVMTgWcBB2XLFJc/V6zVgaiYg /Q0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8x3EfAi+dwJT7LG9r3AqAVh9KBm9FxEhlGxf1nFjco4=; b=d6paOC2xvJ+iXWrVObNlnHWeYIVqADW6oEZEJu6vGjktQt9zXuLQkqDMM52ZGzflyM O+4RQuf00TXmKxVr/bv2ftqxsKDwnnGr2oxlvrDH1ZpNeuj3sgu7jbTTeLtXe13yl+vC nGPQi1Uvku+ORoGXtJBqzdqWu6gxjhBvbTPoN2cf+M/fogewPKswI3dc2SeYkY3A5Kou 4WTkjJhfCR6ykTy7HXy4xjHti4zxwXxq9tp8vlGXypqCtHgMPQGbuihGzAieVf0zcNLO 9bUWV7P8MW80rpn/6Hhmv3f8kqQNpJEoJ7GsGvbs7/as5JQnetP2hx3Reh764oXCfjzL eDjQ== X-Gm-Message-State: AA+aEWaoDInGH14gWcC2S0I5XgzfjXm0E5Fz4iUmVoape9A0julPzxHK 3Ix9gc5KlsC+l2YdQB0cj5w= X-Google-Smtp-Source: AFSGD/U40Oc5azHSTu6+wK0HUW3z50CL3HQhebMK6cXLmPgfP06ZvdgJZnW2t/ruxxoSoludBIfWEw== X-Received: by 2002:a24:1c04:: with SMTP id c4mr4403205itc.79.1544576149095; Tue, 11 Dec 2018 16:55:49 -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 l186sm1952445itl.22.2018.12.11.16.55.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:48 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 06/11] staging: iio: adt7316: fix the dac write calculation Date: Tue, 11 Dec 2018 17:54:58 -0700 Message-Id: <20181212005503.28054-7-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The lsb calculation is not masking the correct bits from the user input. Subtract 1 from (1 << offset) to correctly set up the mask to be applied to user input. The lsb register stores its value starting at the bit 7 position. adt7316_store_DAC() currently assumes the value is at the other end of the register. Shift the lsb value before storing it in a new variable lsb_reg, and write this variable to the lsb register. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index b7d12d003ddc..77ef3c209b67 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1442,7 +1442,7 @@ static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip, static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip, int channel, const char *buf, size_t len) { - u8 msb, lsb, offset; + u8 msb, lsb, lsb_reg, offset; u16 data; int ret; @@ -1460,9 +1460,13 @@ static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip, return -EINVAL; if (chip->dac_bits > 8) { - lsb = data & (1 << offset); + lsb = data & ((1 << offset) - 1); + if (chip->dac_bits == 12) + lsb_reg = lsb << ADT7316_DA_12_BIT_LSB_SHIFT; + else + lsb_reg = lsb << ADT7316_DA_10_BIT_LSB_SHIFT; ret = chip->bus.write(chip->bus.client, - ADT7316_DA_DATA_BASE + channel * 2, lsb); + ADT7316_DA_DATA_BASE + channel * 2, lsb_reg); if (ret) return -EIO; } From patchwork Wed Dec 12 00:54:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7B1A1869 for ; Wed, 12 Dec 2018 00:56:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7DF029FF0 for ; Wed, 12 Dec 2018 00:56:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABABD2A17B; Wed, 12 Dec 2018 00:56:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62F682A150 for ; Wed, 12 Dec 2018 00:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbeLLAzw (ORCPT ); Tue, 11 Dec 2018 19:55:52 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:34181 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbeLLAzv (ORCPT ); Tue, 11 Dec 2018 19:55:51 -0500 Received: by mail-io1-f68.google.com with SMTP id r9so13509003ioa.1; Tue, 11 Dec 2018 16:55:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L/atx7BGCxztBzsTRzroAA6bFNlexZMNZDiBGowfY84=; b=YTgUhfA3XhydP/im3xH6xglj1N2s9OHvGOGTkriBOvGGU150UMBz5iqAjyQ0daUPIu kEUan9F49Owy953ty7gDVs6CY4sx7XrN3LXoG4g/P2Wqd3FWEYhe2Z2SPXpFqR+4aK+K t+gP598UpePVn1DDRNNM7+BeV0iKY6BTTguGCr12/StVEcZspDRkMo7/vXKA9t+aplAk A7ZRUBQSrBJXgoOS8Y4MI262kqKQAgy5GnwVU2C3CTLBQD0us/MLMReUwLUE5hYDffFf RinoZaOtG60QcgOqwY8kU/m8xEQEQHqBvliORX0cfI5nPW9o5ot41afUYEfzPno6XQ04 55XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L/atx7BGCxztBzsTRzroAA6bFNlexZMNZDiBGowfY84=; b=an3bFm5/1RBzhVkMjbjDq4CuPpvXmSvdRXQnk91bUgotcu1cD5rswLxDp1/v/ZV8KL UaEGRfipHXVV4p97p5qxSmNBdVOtMFTQI++h++tLQzxBRcwhJFNwObUKzodFt0sMyJHY uh7o/omu0oxdpF3pDuzmeOrxmFJV0sdEtbEb90/f+Ttusc87LY1IGm7VWhQpKxSAnOcL TOhvU/OPfrM0WovrFW43aUpHCe+aZWchiZJppquyZa1csuuDvr/POeo0uWLXHtWqOcxR /+pWu30h2mIHyUrfiSlc9B+ithLwDb6EhQ8MvrfVKH/GOpLA0sAEGJKqTKjZyedw6DNW RYiw== X-Gm-Message-State: AA+aEWbVJiIGGk2/yhT1YccLjeMBw2qxuMU/kpj5S3wgKkbg3iYDCgIG Mr9IU4eCqgvVeIER8m++4Pw= X-Google-Smtp-Source: AFSGD/Ws5mxQcEZcvO9LhJ5V3G9Wl/Uzf4T/qPMB2FqbhVfV9YU9cXn9Tff/hWyg2hQa7CNhI90HtQ== X-Received: by 2002:a5d:9b9a:: with SMTP id r26mr15497659iom.232.1544576149999; Tue, 11 Dec 2018 16:55:49 -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 l186sm1952445itl.22.2018.12.11.16.55.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:49 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 07/11] staging: iio: adt7316: use correct variable in DAC_internal_Vref read Date: Tue, 11 Dec 2018 17:54:59 -0700 Message-Id: <20181212005503.28054-8-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The dac internal vref settings are part of the ldac config register rather than the dac config register. Change the variable being used so the read returns the correct result. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 77ef3c209b67..98101a7157d2 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1056,10 +1056,10 @@ static ssize_t adt7316_show_DAC_internal_Vref(struct device *dev, if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) return sprintf(buf, "0x%x\n", - (chip->dac_config & ADT7516_DAC_IN_VREF_MASK) >> + (chip->ldac_config & ADT7516_DAC_IN_VREF_MASK) >> ADT7516_DAC_IN_VREF_OFFSET); return sprintf(buf, "%d\n", - !!(chip->dac_config & ADT7316_DAC_IN_VREF)); + !!(chip->ldac_config & ADT7316_DAC_IN_VREF)); } static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev, From patchwork Wed Dec 12 00:55:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65BFC1751 for ; Wed, 12 Dec 2018 00:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 547A629FF0 for ; Wed, 12 Dec 2018 00:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 489B12A17B; Wed, 12 Dec 2018 00:55:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F35DB29FF0 for ; Wed, 12 Dec 2018 00:55:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726375AbeLLAzw (ORCPT ); Tue, 11 Dec 2018 19:55:52 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:32833 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbeLLAzv (ORCPT ); Tue, 11 Dec 2018 19:55:51 -0500 Received: by mail-it1-f194.google.com with SMTP id m8so12288724itk.0; Tue, 11 Dec 2018 16:55:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zwgJV9Fuz7Xdf+vTXkcn64lPHT6DvBIVIzf4MQogFUA=; b=WwZFee984BbBT6+Sd4HICnfMvb+SOQg3oIRS7Js5rQAOGp5Hb3ZSMfI3rSIwv3//tf TeH3NZxZFm6hIBQfA23W148OvOH+wx5W2HgzjX4Vkpv60ZXZvAj3bB4ZqpwPSoVUVfQH A6b0QLuZeYBVRvjBv8l+tDoll5neYhvTAtFtTRTuuGEWocai0sjW6bvGMOtxroKbtohZ UWN2vjrVrew9nP3XCNUHib0cFStqbSaRtjwjb93S7r+vUeZfKTfWEvKcE/F3LTN4o2t8 ny2PZRds0Rejej8CSLt1XafygrK88SwbGi+VBQWvzI5Rx+Lf4/aXUNCMYyyelWk/a6XE HfIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zwgJV9Fuz7Xdf+vTXkcn64lPHT6DvBIVIzf4MQogFUA=; b=VKavA1rQeiPcT14QlRgYnAQZmXyEy+W9UEUmyQzyXy+3N3mlz2PZWFRnXEAlndZa5F 11fOJ5Tw2NQjYpQXF7Gfi9E1ZT/sdENbUReKr6ygrA/P8CpMBiAzFQb++dZzgDPceQ2S LtJfFPnDkuZLWTZRF0N7pI2ExZxBLMFOA9vgEwj1ci4aCUuKbbm/vUW3t/RlCYv+vAhm mWHf8qEmKr5ma8N8AoW3uy8PDmHHOwkI8N7nLy0rN/UbT4BuM3oMi5oJuFiQW7AigtlH u08gNy6CT7DlxtKBSO9z3gqy4Si4dfz6y6Ll5DpjHt8rhzSL3zAVLLvTFMeQxGhZ7myn ueQA== X-Gm-Message-State: AA+aEWYn5DYM106gxxQ5T7LJIvfZYY71sNHAqCFyDOSi2Z4qzq/dcmZf EG0PEg3DhNLmBYwfA+bJj9M= X-Google-Smtp-Source: AFSGD/Wx6SqdWGLHShKm1B4ZcKSIDpFDBw3fNmmK+DQl5mEHJ3y1Yolug9rZaWaUiNLYeDUBjN+wHA== X-Received: by 2002:a24:19d5:: with SMTP id b204mr4218585itb.6.1544576150954; Tue, 11 Dec 2018 16:55:50 -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 l186sm1952445itl.22.2018.12.11.16.55.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:50 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 08/11] staging: iio: adt7316: allow adt751x to use internal vref for all dacs Date: Tue, 11 Dec 2018 17:55:00 -0700 Message-Id: <20181212005503.28054-9-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With adt7516/7/9, internal vref is available for dacs a and b, dacs c and d, or all dacs. The driver doesn't currently support internal vref for all dacs. Change the else if to an if so both bits are checked rather than just one or the other. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 98101a7157d2..3348fdf08f2e 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1081,7 +1081,7 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev, ldac_config = chip->ldac_config & (~ADT7516_DAC_IN_VREF_MASK); if (data & 0x1) ldac_config |= ADT7516_DAC_AB_IN_VREF; - else if (data & 0x2) + if (data & 0x2) ldac_config |= ADT7516_DAC_CD_IN_VREF; } else { ret = kstrtou8(buf, 16, &data); From patchwork Wed Dec 12 00:55:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CD94112E for ; Wed, 12 Dec 2018 00:56:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D76629FF0 for ; Wed, 12 Dec 2018 00:56:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 019932A17B; Wed, 12 Dec 2018 00:56:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B85029FF0 for ; Wed, 12 Dec 2018 00:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726241AbeLLA4T (ORCPT ); Tue, 11 Dec 2018 19:56:19 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:46409 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbeLLAzw (ORCPT ); Tue, 11 Dec 2018 19:55:52 -0500 Received: by mail-io1-f68.google.com with SMTP id v10so13427388ios.13; Tue, 11 Dec 2018 16:55:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JuTVzGlrd5P62PmG1C4j7pV1yedB7ZGV8yxuvoLTCUk=; b=nE9dzQCJntmbkZDYcuB0f+5CpI3dPJBVZLHrbsFI98fR9TAsoFsDQCEFQ1B7X4Co8S tecCA7jCXf/g7ddZOc+7TINyGNGhadYfqtBSdnYy7yx46RgqSZkdU4h+NUq5TbDvrfOp DUHqDMzxmZ/CuxIuynSpPmAB4XauAfGojrWAKcvXUTNUIOrbYb8ix+6rCsK2idISqqmG igJnceluGbxVNu4pl+p4x5IVuwWhDcz91DSOR6FKr9E4FrgDwJsW4+xYdR7vwr4hh3yO Q2km4flG5IWkAde0zyDZ1udb5qbfcBHlQ1AtXTcyA7NFbEuRgm81DfrFEplqMPw6s4FY Gamw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JuTVzGlrd5P62PmG1C4j7pV1yedB7ZGV8yxuvoLTCUk=; b=rutHdwu3r6ujBN85h+U423S3Bj2o4Vh1hZukcczUV2tCbisJRw3BeYHaOKieapK+Vc XoOSSxAjV7Fz4vsNx0HmI6qRNAfpzE5dS0O/J7/JEMqCtTL7yp38pPoj2PYJI8NQieIf /yltLgKCLeGTodhXFifwcfx+EcCE5PWh+tf8IR3fAM4BYVoUGs2n09964hioxg13F3w2 kzSNlK6XM39zqLOkgLXywArMxawOQZzffvv/mQN1zkZJcLcb9WiEUewfM+/L9SEADUHF vjo7fRWokC2etfS7nutzRAXqVGxa2NMzscPJYJnIClRpyTZg7DE24NlQbYdsmKZlL5t+ 1gUQ== X-Gm-Message-State: AA+aEWZpQ70VAL/XHlvUP8meOKV6PGs0My4PUWvqiBgKPv0bH8wNkde3 2DdynD9M/Z7M3PgyaeFFzAM= X-Google-Smtp-Source: AFSGD/XNg3HpCB72+QnrSv2pJhuwVhhGx9pLoGBz42yt8vFDigh25JESqZx8dWegswa6y605546pTA== X-Received: by 2002:a5e:8f09:: with SMTP id c9mr2173301iok.241.1544576151886; Tue, 11 Dec 2018 16:55:51 -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 l186sm1952445itl.22.2018.12.11.16.55.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:51 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 09/11] staging: iio: adt7316: remove dac vref buffer bypass from adt751x Date: Tue, 11 Dec 2018 17:55:01 -0700 Message-Id: <20181212005503.28054-10-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The option to allow the external vref to bypass the reference buffer is only available for adt7316/7/8. Remove the attributes for adt751x as well as the chip->id checks from the show and store functions. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 3348fdf08f2e..bca599d8c51c 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -964,9 +964,6 @@ static ssize_t adt7316_show_DA_AB_Vref_bypass(struct device *dev, struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); - if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) - return -EPERM; - return sprintf(buf, "%d\n", !!(chip->dac_config & ADT7316_VREF_BYPASS_DAC_AB)); } @@ -981,9 +978,6 @@ static ssize_t adt7316_store_DA_AB_Vref_bypass(struct device *dev, u8 dac_config; int ret; - if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) - return -EPERM; - dac_config = chip->dac_config & (~ADT7316_VREF_BYPASS_DAC_AB); if (buf[0] == '1') dac_config |= ADT7316_VREF_BYPASS_DAC_AB; @@ -1009,9 +1003,6 @@ static ssize_t adt7316_show_DA_CD_Vref_bypass(struct device *dev, struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); - if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) - return -EPERM; - return sprintf(buf, "%d\n", !!(chip->dac_config & ADT7316_VREF_BYPASS_DAC_CD)); } @@ -1026,9 +1017,6 @@ static ssize_t adt7316_store_DA_CD_Vref_bypass(struct device *dev, u8 dac_config; int ret; - if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) - return -EPERM; - dac_config = chip->dac_config & (~ADT7316_VREF_BYPASS_DAC_CD); if (buf[0] == '1') dac_config |= ADT7316_VREF_BYPASS_DAC_CD; @@ -1713,8 +1701,6 @@ static struct attribute *adt7516_attributes[] = { &iio_dev_attr_DAC_update_mode.dev_attr.attr, &iio_dev_attr_all_DAC_update_modes.dev_attr.attr, &iio_dev_attr_update_DAC.dev_attr.attr, - &iio_dev_attr_DA_AB_Vref_bypass.dev_attr.attr, - &iio_dev_attr_DA_CD_Vref_bypass.dev_attr.attr, &iio_dev_attr_DAC_internal_Vref.dev_attr.attr, &iio_dev_attr_VDD.dev_attr.attr, &iio_dev_attr_in_temp.dev_attr.attr, From patchwork Wed Dec 12 00:55:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725399 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63558112E for ; Wed, 12 Dec 2018 00:56:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5190F29FF0 for ; Wed, 12 Dec 2018 00:56:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45C152A17B; Wed, 12 Dec 2018 00:56:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6F5829FF0 for ; Wed, 12 Dec 2018 00:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbeLLA4M (ORCPT ); Tue, 11 Dec 2018 19:56:12 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:50655 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726378AbeLLAzx (ORCPT ); Tue, 11 Dec 2018 19:55:53 -0500 Received: by mail-it1-f195.google.com with SMTP id z7so6616520iti.0; Tue, 11 Dec 2018 16:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R4U3PNF7JZZPKLCYh0Oave/Y3+d9jjju4/OWSW4r6jQ=; b=aIwD8A2Kcld+gp/b1xdxZy0FZTjXcslHyF694uIJTlbT1P229Bu50T2bSZdHcNMErF 40uRUYksS7Rts3ar07s0MWKjBHP8fruipwTOb/mBJu/oy6LYc4GhJgtToKerFTNexbQp kdMEBbqVkezlX1Q8JoGS9ov9EXp3OYeve9zm7arlwVjwVhoQ8NL0yqrpMuFbQFMHtnE/ fSVt6eXVVQubH1oTTfgioWfUvTQSI4NHLY441d4jJyKWXm/owPT6U2W4BWFqM1GyLImU mGVrGpejKGkCKaVX3anWqZkqGeDpdttmKG/Kv1RWFXjRwIpg+Sv9pqAwXbkeYMrZZ3SM oqIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R4U3PNF7JZZPKLCYh0Oave/Y3+d9jjju4/OWSW4r6jQ=; b=hXATk9QP1IWkt+D9O+t04VW6pDYaGz+V+wTd7GUo+0lgYTPaccH1AD9NruM83iNmXk JQGzTVf/EJZl3sc6syrHByf+ja8pJmMvt0tE2+sWlpziBCVk+I3gZN7OCdC6W4dPG5RN SGBo9ThjyuEcjhwvmVQTm+Em4/PPEiDqmIMO4rqe0i/COaoZSuKaCRDBcYAk5BZGHiB2 PhakmGEdtjZJgQ818fEj0fT8tr8EJkiymAnTHlrQ3YYIv36t0VFU39iT9BhyYhTexvnv J/rhxnyoUkIomXk4DD+ZFWuKZxNmW7PDpsd7HPjBp0AlWShaOZalZBkyC3mUnG1xyJAj aryw== X-Gm-Message-State: AA+aEWbIHPFitpA3VhCbt8WEB319h736BonMfPa/rsd+h8bzZPHmGSbf 7/AocIR5yy3rcscyldrYb3E= X-Google-Smtp-Source: AFSGD/W2Gxx6S/m6J0d6dJgKQge+oX6kcvwOsjxxwwp8E32NXGM15q51WVH+b041wG5NMi/JUxIa1A== X-Received: by 2002:a24:4709:: with SMTP id t9mr4551515itb.47.1544576152796; Tue, 11 Dec 2018 16:55:52 -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 l186sm1952445itl.22.2018.12.11.16.55.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:52 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 10/11] staging: iio: adt7316: change interpretation of write to dac update mode Date: Tue, 11 Dec 2018 17:55:02 -0700 Message-Id: <20181212005503.28054-11-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) From patchwork Wed Dec 12 00:55:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 97C51112E for ; Wed, 12 Dec 2018 00:56:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8782529FF0 for ; Wed, 12 Dec 2018 00:56:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B9ED2A17B; Wed, 12 Dec 2018 00:56:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2331C29FF0 for ; Wed, 12 Dec 2018 00:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726400AbeLLAz4 (ORCPT ); Tue, 11 Dec 2018 19:55:56 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:39752 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbeLLAzz (ORCPT ); Tue, 11 Dec 2018 19:55:55 -0500 Received: by mail-io1-f67.google.com with SMTP id k7so13460611iob.6; Tue, 11 Dec 2018 16:55:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TPkjkn4TiJ7mp9DhGzQAAKMsgbvt73YionGsm/gSjY4=; b=R4BhEUmK6ZviloqxhFxozlbCP7iAwAVvHN7kvWcqq3m24OtBxNuxS6vYZkvTVj4XOh n+sNJpu0QImgOe/b+lZYFS9+V+npCAII6yn9NjvmfeldowfKOylKTZmHohdwxgMHJs/Q VdGEdLm/ymO+DFdmQttDtgB/TSZ0ORmwZX9foMkpUxwjIQAj7PPyIHlAzVdPDTOZe6RM rH1jYtD/aZAtW67iJ1C0hwf+nO1FGt6nGhfBHlCkfGye7o3Tgs3fE7IfCTEL/3DVOQ15 PY7sII97JfOk8unTA7C4iP1vq0R2A1146H2A4qzqObAvYICjsiEeNrbFW6HH4eXoaJ6b LV0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TPkjkn4TiJ7mp9DhGzQAAKMsgbvt73YionGsm/gSjY4=; b=Lv/2nSWY7xbrBYoDKGEllL0SrP3oncZHJZ1MqFPeVgp1P+DI0qYYZYtdXwwimKUqSg hPBIeEmI7+o7CzAnj/0I4wqSSS5Ruz8bdn7St9IhhnStNzaNbblLpznZsgw6jJ3rWcYz /PCJIjBqSO9bvOlB8i/iuidPLKcH5gIats9Fl8mOFBqJWMsN8IEPUpirwgLvQ8qZetH4 Q/NGjmJboJTXaa3lI8RTE/4r0OSfzbD1UROAD5QeoMtUbY68Km1Rr4r3k26E5ITN4tN9 AhmkRb8hDtoJrEoCqEDpnFoWeLaMlDmcXf+1PXapTxk0un4BTLsP5Uwe82XWIdB+Ggyi W8HA== X-Gm-Message-State: AA+aEWbI2OYL8aQgYPrfJ+WsBZdcTu4qNCYLWxz8PJhw9ycaYx9taIZk ctpHCd4SNs4LqW5Xq6cqTKY= X-Google-Smtp-Source: AFSGD/U85FP8yW06Gpays7eYyLSdl3+J/nNGtrs8TRb6qbpA1f0F8xFbR1gWjVWPyUshtaHS7yNPHA== X-Received: by 2002:a5d:8b0b:: with SMTP id k11mr14074813ion.213.1544576153694; Tue, 11 Dec 2018 16:55:53 -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 l186sm1952445itl.22.2018.12.11.16.55.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:53 -0800 (PST) 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, Jeremy Fertic Subject: [PATCH 11/11] staging: iio: adt7316: correct spelling of ADT7316_DA_EN_VIA_DAC_LDCA Date: Tue, 11 Dec 2018 17:55:03 -0700 Message-Id: <20181212005503.28054-12-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change LDCA to LDAC. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 58b462ad0c83..020d695ded97 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -119,7 +119,7 @@ */ #define ADT7316_ADCLK_22_5 0x1 #define ADT7316_DA_HIGH_RESOLUTION 0x2 -#define ADT7316_DA_EN_VIA_DAC_LDCA 0x8 +#define ADT7316_DA_EN_VIA_DAC_LDAC 0x8 #define ADT7516_AIN_IN_VREF 0x10 #define ADT7316_EN_IN_TEMP_PROP_DACA 0x20 #define ADT7316_EN_EX_TEMP_PROP_DACB 0x40 @@ -847,7 +847,7 @@ static ssize_t adt7316_show_DAC_update_mode(struct device *dev, struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); - if (!(chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA)) + if (!(chip->config3 & ADT7316_DA_EN_VIA_DAC_LDAC)) return sprintf(buf, "manual\n"); switch (chip->dac_config & ADT7316_DA_EN_MODE_MASK) { @@ -876,7 +876,7 @@ static ssize_t adt7316_store_DAC_update_mode(struct device *dev, u8 data; int ret; - if (!(chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA)) + if (!(chip->config3 & ADT7316_DA_EN_VIA_DAC_LDAC)) return -EPERM; ret = kstrtou8(buf, 10, &data); @@ -907,7 +907,7 @@ static ssize_t adt7316_show_all_DAC_update_modes(struct device *dev, struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); - if (chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA) + if (chip->config3 & ADT7316_DA_EN_VIA_DAC_LDAC) return sprintf(buf, "0 - auto at any MSB DAC writing\n" "1 - auto at MSB DAC AB and CD writing\n" "2 - auto at MSB DAC ABCD writing\n" @@ -929,7 +929,7 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, u8 data; int ret; - if (chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA) { + if (chip->config3 & ADT7316_DA_EN_VIA_DAC_LDAC) { if ((chip->dac_config & ADT7316_DA_EN_MODE_MASK) != ADT7316_DA_EN_MODE_LDAC) return -EPERM; @@ -2128,7 +2128,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, } if (!chip->ldac_pin) { - chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; + chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDAC; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) chip->config1 |= ADT7516_SEL_AIN3; }