Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2826644imu; Sun, 23 Dec 2018 08:39:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ntQbyhPWuJWg+vlJU0UQPE117EjR6JXYvdwZDo6QYG4jXYnN7y0V9og8t+3K7a2l4+VRB X-Received: by 2002:a63:a064:: with SMTP id u36mr9715144pgn.145.1545583165137; Sun, 23 Dec 2018 08:39:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545583165; cv=none; d=google.com; s=arc-20160816; b=gcUOC14EmgJ9tUtSdKqlonANqvWKzsW338JgKIXErxtD16AYiIRdD7bd4gQJAQWihB 8CVRJrgwpW5Rn3DjSst05d6rrrzX1Zy1YvcrG4DHmMg+RgE76YvRrg6KxXXdWsS05Qz2 cp64L1KIh56YKmPYPz9nQIcymxWbdILMDHYJVm8883DSioNwZtjnpvxKNf/xpEY3o7FU nr9YX/6XrpZZNwncOnTpOEtsvOOCPMCYascQxYW3LwGppK6H1ofhkUkPHu4DuVEqrh85 9yZWvK+uoAQfbpNIdQGA0yxgOnovQRMBA/Fa3+mQgq7kgb8IrHrLPOPkFJWrbVAnk/eD Hu1A== 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=8yZFL/zwD25f09AodsHo5P6etccInIazFV7uoFevqFM=; b=flH9i0qh4hqgIn8+ssWggHKIkdwBhacskqmPp+eRdOamIm15aMdZAwMGYqsbOlZEop 67QdozVtlidqrehwGbS0ggMuc9nQP5JK0TY8DnxiAjoTYoxHF9Q3O4v60IPTyG85BeVw 8dSThT7U2eQ2MsbFGXbcbtx8uuOBYciDPeUze4Zoq/1R8Y+2380XGuUIihwChf4mCi6L htJuALD3bQHy6goo702Fd3JiYjO2atc/2A62N3RJUAM9ZOsVLc2N6Aai5pacED5j80ZN GPMUt7RRww0g5Iff+rnYS8HyW0SW60NEJ2T78OIvvBF3ifv4odv2Gxj9QneJmfX3aK30 4biA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mFs+FMUq; 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 a1si26754700pld.249.2018.12.23.08.39.10; Sun, 23 Dec 2018 08:39: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=@gmail.com header.s=20161025 header.b=mFs+FMUq; 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 S1726774AbeLWE6c (ORCPT + 99 others); Sat, 22 Dec 2018 23:58:32 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:34724 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbeLWE62 (ORCPT ); Sat, 22 Dec 2018 23:58:28 -0500 Received: by mail-io1-f67.google.com with SMTP id l22so38445ioh.1; Sat, 22 Dec 2018 20:58:28 -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=8yZFL/zwD25f09AodsHo5P6etccInIazFV7uoFevqFM=; b=mFs+FMUqu3q9ekZtjSITBt0goNkoTX8vuMp1uOHkd0Q6AIHs0UeMBB+NLdSQXOtWyc kn9okEWP+2ksHpqyj4cVm9kfIVmIJioHZ9EVMLGS0uSO3WjXFw43tkwUASLe32OHpNxV Dhj3Q1FySbdbcPCllvrfFdLEUfmm866Fp2pmuuXqhMlgRqrz3dKCWAyGKF0ig/kPpwDY y0XP1UqxzJgij4b+Bnmckjj28yiWYXiYEPU9Zl7WAWVIXqa/fp8sXwjLcmxusEMLk0wo +1ruNSbdCzR56CEJGMrKbaJiNNH7u92W9XOyZOnawrv8OLsqKnHGaGWK2sjuwQQWy/SP 8iOw== 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=8yZFL/zwD25f09AodsHo5P6etccInIazFV7uoFevqFM=; b=LLdoZ2OL1m8fRTAITYTyh02EWMIZtODxW7PQvdy9VtvsHY6GpOtw7RDcHRlRmjQP6E ubo1fMKPc44B3lD96PITUZNT4Bpq/WZL96UV1YSQpbl8LMvBQwQsgxZhiWmItzluuOE2 JrK2cal9emHERdWwSVwB9G/42mrSOiSPbLEsR75bPY1tvFuxgzAv+maZorr5SvBbKu8a UYT+fNEqUkDp5ITWayk1g9hCjeLa4eOW0lCSOgLUNm0ve2wyjJIjlFKzRV+8OaXhr9oL u0EE89K9k3g+yks1fgI3OtkSoqVE7jZCVOJQdUxfJK6GxLF5H3EJnrhD50G23jODEb0n VGZg== X-Gm-Message-State: AJcUukdC5w9bqDNxQpYETg39sajLufTvmJ1Zm57L6uWvgmdbMWOfBIhA y31rUbE+lZhKH8KZGDRr4So= X-Received: by 2002:a6b:e919:: with SMTP id u25mr6013502iof.132.1545541108043; Sat, 22 Dec 2018 20:58:28 -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 15sm8435378itv.11.2018.12.22.20.58.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Dec 2018 20:58:27 -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 v2 2/4] staging: iio: adt7316: fix handling of dac high resolution option Date: Sat, 22 Dec 2018 21:57:41 -0700 Message-Id: <20181223045743.10716-3-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181223045743.10716-1-jeremyfertic@gmail.com> References: <20181223045743.10716-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 adt7316/7 and adt7516/7 have the option to output voltage proportional to temperature on dac a and/or dac b. The default dac resolution in this mode is 8 bits with the dac high resolution option enabling 10 bits. None of these settings affect dacs c and d. 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, the driver currently allows the user to write to the ADT7316_DA_HIGH_RESOLUTION bit regardless of the device in use. Add a check to return an error in the case of an adt7318 or adt7519. Remove the else statement that clears the ADT7316_DA_HIGH_RESOLUTION bit. Instead, clear it before conditionally enabling it, depending on user input. This matches the typical pattern in the driver when an attribute is a boolean. Fixes: 35f6b6b86ede ("staging: iio: new ADT7316/7/8 and ADT7516/7/9 driver") 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 e17c1cb12c94..80cc3420036b 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -633,9 +633,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"); } @@ -652,10 +650,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