Received: by 10.223.176.5 with SMTP id f5csp994665wra; Fri, 2 Feb 2018 09:24:25 -0800 (PST) X-Google-Smtp-Source: AH8x224PaMHAbFqKzFOqPT6c9Tt047AoZQ+wwCa3JsvYqVxBaRlsJK3C3OZMDqwkUi0/2NR+OWWF X-Received: by 10.99.168.5 with SMTP id o5mr32131558pgf.27.1517592265500; Fri, 02 Feb 2018 09:24:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592265; cv=none; d=google.com; s=arc-20160816; b=rPhMU1wzQLrwdBA1PHpTPuJ+GTbSxjhE+LkOvRrDOUFp92+Pyg7nEhKsUV7dXCD7TM vrXiImes/lPMDyynUb/4SpCJVtg2JWjK+14DMFJZ83mVCdsb82oNmXqpArsCDUVxXBm4 AWGiRK1b1k9XVxPe0Tvj8Et6uqp86oUvH3MXCAqxdCFw1fy2UyTDVjq3S1gex/NllVo/ igcTr7vIIlWFmawnYosiffncDc4XDFCS2my0qeIKIAnyJhWQzrphNOQWs3q/OXRo553x 8brhJ9x2bi2NFXB4aUhU8lp+9rTFD8rjyHO640XUjGdqEXwmHzwoaZxu4LUPP/eWzmml +0UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=P6pRjxwNdx5i2w354yJB6SNcBvjFAveYa3OwtSKp6vI=; b=MCB3XcVR2Ql8U0rNnuhdRZnplidgBaK8wDhHriqttiu2oJK3RNZlHCRxbxSgny+Wi1 g9V1BBw9inspIOyqi6ELWHLfdbixI5DQh3gSog1SfjicmI2zXIjPar+yzYcy7PU6VHi/ HptNC/8e0gZrVKdeUg37/b68CSTAe8ZJsrEvk29V6H6j8Wjrzc5bbmWuRtOPF7NGJN+0 09kDPPVd/W7PMHyIPPucBkBNd76W6zxXIh9RYqjAKoxMsrJsFXtFt35JYf/meE6HDxQ7 VEFU8veKjAlveryAslwvwYllntcDjmwMAOE1g+/jSjJ6U3C4vfaL1CE9AkNlWwxv+TWa 1nHQ== ARC-Authentication-Results: i=1; mx.google.com; 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 u23si1700379pgv.642.2018.02.02.09.24.10; Fri, 02 Feb 2018 09:24: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; 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 S1754031AbeBBRXC (ORCPT + 99 others); Fri, 2 Feb 2018 12:23:02 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40428 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753587AbeBBROO (ORCPT ); Fri, 2 Feb 2018 12:14:14 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 28AA0DA0; Fri, 2 Feb 2018 17:14:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Narcisa Ana Maria Vasile , Matt Ranostay , Jonathan Cameron Subject: [PATCH 4.14 152/156] iio: chemical: ccs811: Fix output of IIO_CONCENTRATION channels Date: Fri, 2 Feb 2018 17:58:53 +0100 Message-Id: <20180202140847.279051738@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Narcisa Ana Maria Vasile commit 8f114acd4e1a9cfa05b70bcc4219bc88197b5c9b upstream. in_concentration_raw should report, according to sysfs-bus-iio documentation, a "Raw (unscaled no offset etc.) percentage reading of a substance." Modify scale to convert from ppm/ppb to percentage: 1 ppm = 0.0001% 1 ppb = 0.0000001% There is no offset needed to convert the ppm/ppb to percentage, so remove offset from IIO_CONCENTRATION (IIO_MOD_CO2) channel. Cc'd stable to reduce chance of userspace breakage in the long run as we fix this wrong bit of ABI usage. Signed-off-by: Narcisa Ana Maria Vasile Reviewed-by: Matt Ranostay Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/chemical/ccs811.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) --- a/drivers/iio/chemical/ccs811.c +++ b/drivers/iio/chemical/ccs811.c @@ -91,7 +91,6 @@ static const struct iio_chan_spec ccs811 .channel2 = IIO_MOD_CO2, .modified = 1, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE), .scan_index = 0, .scan_type = { @@ -245,24 +244,18 @@ static int ccs811_read_raw(struct iio_de switch (chan->channel2) { case IIO_MOD_CO2: *val = 0; - *val2 = 12834; + *val2 = 100; return IIO_VAL_INT_PLUS_MICRO; case IIO_MOD_VOC: *val = 0; - *val2 = 84246; - return IIO_VAL_INT_PLUS_MICRO; + *val2 = 100; + return IIO_VAL_INT_PLUS_NANO; default: return -EINVAL; } default: return -EINVAL; } - case IIO_CHAN_INFO_OFFSET: - if (!(chan->type == IIO_CONCENTRATION && - chan->channel2 == IIO_MOD_CO2)) - return -EINVAL; - *val = -400; - return IIO_VAL_INT; default: return -EINVAL; }