Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2994798imm; Sun, 19 Aug 2018 09:38:33 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwF5VBT+C/yoAouEMrC8vSCXpa5lSrP7opEalSgpF1Nj2gQfr7+w2fgM3tp8FEkPCj0XoXH X-Received: by 2002:a62:2c95:: with SMTP id s143-v6mr44689227pfs.3.1534696713108; Sun, 19 Aug 2018 09:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534696713; cv=none; d=google.com; s=arc-20160816; b=F0nOJptbAcVk4OfKS6gzzwkNoioEqTJyUDO8ybNKpyUIVRY3eTWhHheBOxdSSNbRJk Rz5FJwCMxnYRah5Xf1fWjuN8zIEJ/Pjvsar/9Wg1kb3grPUYZLwmdJ+nvq31Of7A5Lzz vKGyo0yhQhYI7VIzK2dtbZ48tT9XPpxfQlBUSrROXxd2Ak3fm7IJ+qglRaEsqTU3KTHq LBr6ZRLCbnWpy4H/z2OJDvpmY+p4udmSnYvzyu9kQ2o4XSeaPapnVaQEHHTEw22PV2mu JFLSFjRoimQDIS5lCKnEnUVzgZys6qqzFZiAWa8k60Pjv0ffONk8LOnXF7wwqquxzL9t rFOg== 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:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=yQlipEGS2op8OnLk1vkvg20Z3AF1HfCe+8y8YDQaE9E=; b=n2IZRC5+kEAwT104NMB1Pr2NkwnnTUrUcwaPGWjOxOuWhTiIPtmsRiwX9Yt/lqh8Dr 9qgOE+J2K4XkknNESHsH8WyKdXmE+w5f6++p6bXOnulYOmq95npRjlFiqrvEzsTyU3iY Y6waLqWwUqvOSoXvGNcRMrjLAKo9FbsMHL+A13ktySLxNe5k3noBQYHiNHZx/U1KJ5yM 8YethG5HL/d71YmVsCOhs7CGDLeSIRHpv4s/bm0sYHYLizn/qwZawz84/j3Ll3Ws8TO8 evYNGEORxBjVd07CMKOl5nduBD/fOvUlaKxPK3UcEgphd67adtHIMDPTmkB1FYj7T+rO 0FKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eMy6d6Qo; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17-v6si7735782pfd.76.2018.08.19.09.38.04; Sun, 19 Aug 2018 09:38:33 -0700 (PDT) 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=eMy6d6Qo; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726796AbeHSThS (ORCPT + 99 others); Sun, 19 Aug 2018 15:37:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:48722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726686AbeHSThS (ORCPT ); Sun, 19 Aug 2018 15:37:18 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 42F0B20779; Sun, 19 Aug 2018 16:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1534695918; bh=DZ/3L7AmLPBaTaCXAlKBD5TYNAX6eJZYWnnXpKEwwSw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eMy6d6QoNIcsmgOKDQVmeLmPaqIzXszsI9yHIfgoEcea/Weug9it/oDrCMfotPtZW krjbkiOLLQcdt1UtzXwMeS7+QNQRMbtPue3aHAvijZ2ncRB2kMnLpcI7wjOghGMf4v ckJ8k8076zvSM5AWjmflL1HDc6Vmy3b2Imq+YDCc= Date: Sun, 19 Aug 2018 17:25:14 +0100 From: Jonathan Cameron To: Himanshu Jha Cc: dpfrey@gmail.com, daniel.baluta@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: chemical: bme680: Add check for val2 in the write_raw function Message-ID: <20180819172514.370d34fb@archlinux> In-Reply-To: <20180811102636.6171-1-himanshujha199640@gmail.com> References: <20180811102636.6171-1-himanshujha199640@gmail.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 11 Aug 2018 15:56:36 +0530 Himanshu Jha wrote: > val2 is responsible for the floating part of the number to be > written to the device. We don't need the floating part > while writing the oversampling ratio for BME680 since the > available oversampling ratios are pure natural numbers. > > So, add a sanity check to make sure val2 is 0. > > Signed-off-by: Himanshu Jha As discussed in David's patch series v3, I think this is still relevant but now needs an update to cover the new code. Thanks, Jonathan > --- > drivers/iio/chemical/bme680_core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c > index 7d9bb62baa3f..9d5a05e054d1 100644 > --- a/drivers/iio/chemical/bme680_core.c > +++ b/drivers/iio/chemical/bme680_core.c > @@ -852,6 +852,9 @@ static int bme680_write_raw(struct iio_dev *indio_dev, > { > struct bme680_data *data = iio_priv(indio_dev); > > + if (val2 != 0) > + return -EINVAL; > + > switch (mask) { > case IIO_CHAN_INFO_OVERSAMPLING_RATIO: > switch (chan->type) {