Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp650858imu; Fri, 11 Jan 2019 06:49:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Cb++HdfTYKOaT8bNDC2vqCmqdZKHmB7IlRkmq7k2r14XsL6OK7Ad88oVG2mV5VLMwPY/U X-Received: by 2002:a63:7306:: with SMTP id o6mr13389679pgc.343.1547218177256; Fri, 11 Jan 2019 06:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547218177; cv=none; d=google.com; s=arc-20160816; b=RnrEKWazTQfhOruupd53lg3HxjA4Wr/KC/7c0ys7zGJFq8rH9PdKbvNuYci3CKJC86 3C6abOPJjZBe8XguZ3w9SqwEwmRBbihtH9WB02jUSitJjgp78K6TmwXuXa06ZuElvYzW 0iiLcKQy1UH1MOQz8vkDuEl0PPwjspCZMcHu8zExoQJzU6hKZplD8uoAK1YT94LQL+uP 3KaDvn5tDgsY9JNLA4MhkX3UK9iocz7nI32g7MgAiGmBNnTbQRyURojEt3VV247RG84q 4I7RkEPTndOC9Te9U7BcBO9r5RwkOY7tO/tqnawDZFpcQAfHVbFnwfPH6rpSofv/VAhV zUHg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AAdBVRiQdXbDZC0kmcSWEQ9IWv21aWK1lr67CszLsmo=; b=d7igxpiSRYeScKnlYwbEfv7kSxwsnsyeTYC0YJPbu4/rDnOJRK75v/1LqW53RdYfPq xOHdVl6/LtawQqbFa0XNsB1N8bxMzu8FifoEmFo0OsIxqkjpck2aXp4uA3PqYin3B0gq HmA14QkPFsuCLLdymjzD6S2yzy6T27mfPXhMWv6nQ64YunXetERrBJBrPabOppBytFxD F3WHlvLz0rxp+KKbsVZ4R3VZuprMKICdIeEcexzyYKENrbJci78N51ZhhBdO+LXnX6RH AdNdksPVxY0IGwdgxBMlc6f7MYIiJsWwWjuqVqxtzxNr4tyww8v4cyAdAEVM2Jw2i2km +myA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wvYju3mQ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k186si76220810pgc.576.2019.01.11.06.49.21; Fri, 11 Jan 2019 06:49:37 -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=wvYju3mQ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387736AbfAKOq2 (ORCPT + 99 others); Fri, 11 Jan 2019 09:46:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:36130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404340AbfAKOnP (ORCPT ); Fri, 11 Jan 2019 09:43:15 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 A61F821848; Fri, 11 Jan 2019 14:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217794; bh=ovmtQlXGn31Rhr/kBzg0WxGis0FDsQeCTnXf2timqLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wvYju3mQVU2PlPriN5QFluCeevHQkTZMReJoj4u1f/pj2aoCNB356nH+O901dO/U0 TioUjijSlFP8rSyDsXYK2AxWBgEn3uQ4w/t/RMlOLS9Y2PaLojrOJARebxCnxeDxSL Mg/A0DtgC3m9e4g3m/x3rMRWN63ObNCc7FdQY/o4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mircea Caprioru , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 4.20 44/65] iio: dac: ad5686: fix bit shift read register Date: Fri, 11 Jan 2019 15:15:30 +0100 Message-Id: <20190111131102.416207544@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mircea Caprioru commit 0e76df5c978338f3051e5126fc0c4245c57a307a upstream. This patch solves the register readback issue with the bit shift. When the dac resolution was lower than the register size (ex. 12 bits out of 16 bits) the readback value was not shifted with the difference in bits and the value was higher. Also a mask is applied on the read value in order to get the value relative to the actual bit size. Fixes: 0357e488b8 ("iio:dac:ad5686: Refactor the driver") Signed-off-by: Mircea Caprioru Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/dac/ad5686.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -124,7 +124,8 @@ static int ad5686_read_raw(struct iio_de mutex_unlock(&indio_dev->mlock); if (ret < 0) return ret; - *val = ret; + *val = (ret >> chan->scan_type.shift) & + GENMASK(chan->scan_type.realbits - 1, 0); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = st->vref_mv;