Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1299237imu; Tue, 11 Dec 2018 16:59:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/XE+F6VJ3cxU6a2mxJJISWAfq+RIWpZgb0DjAF5Ro+AALi/vRTsAnq/hWhVdpeqiIiWf3Bi X-Received: by 2002:a17:902:ba89:: with SMTP id k9mr18356514pls.189.1544576357898; Tue, 11 Dec 2018 16:59:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544576357; cv=none; d=google.com; s=arc-20160816; b=W+Ir6aGH70RW9qVL52NYzFXcCSLCweP66mEZ4qb3NYtWR2CUov/nYxnIBZL+v/oTEO gcrjPtre3ODOuzd5vpRuimg3f9EyyZi/xLpiMPD2fznOhrBWo2V0c5cbUDYyuYkFuEcF wLk0kJHZ8cRVMz8O4SJpyWpIyAU3YW78b3X0CmJnG2ATxRzGqm+XCKkCqul5cEhu2+FX 7Mpat6KPIgyDFfQHjVSjN42mW21ZYicuxoDn0p00KbrO3UaIKL79mvlCz0SvKswooTrC hckja8jQ+dEXrspWnkUeSoiiAGNvT1fnUfCLs5q3FN5Ovoy+czFwqSalTbVZo7n/fWp+ dy9A== 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:date:subject:cc:to:from :dkim-signature; bh=R9m4u/5qRzRhLWACB0cQ5SHyFZ5Alna3mIM8KLpqRaI=; b=YHstYKvxZ9qP/KHPr9NjYQhH3nTKcxy0sFE3lytbWSvIAsz2ChVOLOTufgc5jWuzUT UN7JpcdVWnfc+DGrc/xr90oy0JGP0bWq1O5vDWRkXZ6iBgPOLRwTyFdWpbqSU18YAepk Gd6UEsKTW5l1r1ChVkJABcaed5+t7hN/QPjiuP//aiz8VYGZ3ZaLP55FFpmbtIMxiPcE do0Jqh2iPWOyxgeOaSu8OIHNrgRMmYZ44u9joSsFKNqkm8bDH4Sms4UOKU4kxwSh5k/u dnwTQVdIJ7QEX6P79q69J5SlbwEuDD9ohyTzhutQYbYO9LVymBC+dTdhcok/h3aFczgR ZVAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ayHUN/rm"; 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 f38si13155581pgf.206.2018.12.11.16.59.00; Tue, 11 Dec 2018 16:59:17 -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="ayHUN/rm"; 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 S1726480AbeLLA42 (ORCPT + 99 others); Tue, 11 Dec 2018 19:56:28 -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-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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.19.1