Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp791361lqa; Sun, 28 Apr 2024 04:48:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX30+brY4GEFFjyEHWf7j72WeHwDCWyKnljBXMT5Ut8SDcI80+zVUweFI8igZknDAR1zwi2Ia5IBM+NGvIde+r/vz5i4tkeRLAr9XyYhA== X-Google-Smtp-Source: AGHT+IGiVRE1s5EBO4QbJZVarE8gzW1OkvMhvr4tQvCe4wLWOzBsmUO32ezGPIZn8H4tBId49uOM X-Received: by 2002:a2e:80c1:0:b0:2e0:1414:5eb9 with SMTP id r1-20020a2e80c1000000b002e014145eb9mr1103690ljg.25.1714304883416; Sun, 28 Apr 2024 04:48:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714304883; cv=pass; d=google.com; s=arc-20160816; b=Hl6FiVTNd+Y4I1+5MhvwokhsAUwFvALOf2IzuRF2YbAwRs1AgSjwOlCUdDXcEhraql 65rwgoao7VKyBtvwW75CrBYcTPEXLSldNraZC1o3jV0/gVHb4CcMfO1DLAZLqr6VwTuo zl4Shc4Tj/jmUy+kcaxTVicaXY1y2pSyNHOtd/9iIbKITVMSvueB9fbAUszcIQdxKE6V UyFK+z0xP0HfSiQ/bylGbzzdXG5C4SIAqAPvAuB7KTlqHSUvsTEUMLG6jMN9C/UOQTyl CT0S9nlt5a1tivxRrvxjM678nZehQZqbNvhF0pHRf8+9cJgdgT6ULmvpPgZSNP/EO3sN nNeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=olAS46yWFZOvclmpDyluo/6e0wjdm8S/jgtqYz9pPWI=; fh=8DB6tIUkpL0IZdu9dxFWSGvJFX9NLuggUg1Uso4liJo=; b=iCMSyGcEa/8o/0SE9oK8mvQj52zQTw0vCW1Hh47njCUWYbOi8oF3PiSkqhL8ARKlMA PDGxfLpYUv9S+0v5Sx+SV+c+vCaBlYmKa0X4OMrIklKlBFBzSmkAlWuvzvmMA4rR9Hlo vFmrCVv5ex+B5v9J6mk9JXtDJ1FH9IoEZ5aDbptoo/rWXisKheppHOrnqbb4x9CfZ4uV vG5XjGWfPKqJkoNsHxVdZlmbWI5QwRL+lxokPNUQREv8TxLgixu4P6IWJ+0wbinLcCxk pYblZCTjDpmuejCaip/Nr+Yq3no0z8oad+EX/Z4yLNHB4TMwOwIIyc20GMUcANfkzPUl 1EXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dxkTjxge; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161402-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a28-20020a509b5c000000b005727bdb2e75si846024edj.583.2024.04.28.04.48.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 04:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161402-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dxkTjxge; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161402-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0C0531F2166A for ; Sun, 28 Apr 2024 11:48:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 970975B20F; Sun, 28 Apr 2024 11:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dxkTjxge" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C02945A784; Sun, 28 Apr 2024 11:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714304876; cv=none; b=QBhCOSFoOb9bdmxG4I7NXMfgzcIMXKOQtwYSDOmlSCDu5/4HB6RsMdAV9788+7PrTpKcLleRaMlu4LenPzPNE/9oCVQfLzA06uFWdPX+3PGTFZdRFbGDFpojr1buo2JZwvquMGS6tNkmU6l1JY4tIF1zKmvOGjbtvNFD29iHF14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714304876; c=relaxed/simple; bh=UP0FMpaWFZuZHz6hK4UAG2FkVrrblgaPvg6DkZrg5Lg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nyi6WV6cbhrQw1aSv+9c5smBPpp7o7C57duQKRrwcpolCnhyY3+U1C6H+NdDeBumK57xSALedPISIE0kuRIkqHCScXG1/4C6pb142wpT0R28Cl45oevk4ub4Roo8VWB82ZXz/BFSU3gwzLx42gldSZtfzXLU9x1wyofuIqjgcFc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dxkTjxge; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 292C5C113CC; Sun, 28 Apr 2024 11:47:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714304876; bh=UP0FMpaWFZuZHz6hK4UAG2FkVrrblgaPvg6DkZrg5Lg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dxkTjxgeh7Defs2XPb5SzSwxAvDvBi4MyDLvp+qxFHoN3BFhA48DWltopDCfT/SkU j5t2litY6SbbI8n1bhhCL3eP+mK9tZxxBr4muPum10PMZwkUZg4CEEFSpW6/Mw4TJ0 2pDjWPwNsiuOut9VG67CBHRgRbkcj2EBkEQ2g8wrwUqXjhyTgQkjK2yYUnGzSlNYsv 07n7+1JFNFnNbEp1Dxul6vdL4P6w7Jf6neyO1ZyPbTl+11C051oAF50H4nmHQAHDDZ nKE7mBVzevFbYUDEebCpTKRKzfWj6kjUw2WUbgwBeqbIff+ReJ3J+yItQBI2BLjOLt c/clJx+KHBQEQ== Date: Sun, 28 Apr 2024 12:47:45 +0100 From: Jonathan Cameron To: Subhajit Ghosh Cc: Lars-Peter Clausen , Dan Carpenter , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: light: apds9306: Fix input arguments to in_range() Message-ID: <20240428124745.2cb0e2a2@jic23-huawei> In-Reply-To: <20240427090914.37274-1-subhajit.ghosh@tweaklogic.com> References: <20240427090914.37274-1-subhajit.ghosh@tweaklogic.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 27 Apr 2024 18:39:14 +0930 Subhajit Ghosh wrote: > Third input argument to in_range() function requires the number of > values in range, not the last value in that range. Update macro for > persistence and adaptive threshold to reflect number of values > supported instead of the maximum values supported. > > Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor") > Signed-off-by: Subhajit Ghosh Applied to the togreg branch of iio.git. Pushed out initially as testing for 0-day to take a first look. Thanks, Jonathan > --- > drivers/iio/light/apds9306.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c > index 46c647ccd44c..d6627b3e6000 100644 > --- a/drivers/iio/light/apds9306.c > +++ b/drivers/iio/light/apds9306.c > @@ -55,8 +55,8 @@ > #define APDS9306_ALS_DATA_STAT_MASK BIT(3) > > #define APDS9306_ALS_THRES_VAL_MAX (BIT(20) - 1) > -#define APDS9306_ALS_THRES_VAR_VAL_MAX (BIT(3) - 1) > -#define APDS9306_ALS_PERSIST_VAL_MAX (BIT(4) - 1) > +#define APDS9306_ALS_THRES_VAR_NUM_VALS 8 > +#define APDS9306_ALS_PERSIST_NUM_VALS 16 > #define APDS9306_ALS_READ_DATA_DELAY_US (20 * USEC_PER_MSEC) > #define APDS9306_NUM_REPEAT_RATES 7 > #define APDS9306_INT_SRC_CLEAR 0 > @@ -726,7 +726,7 @@ static int apds9306_event_period_get(struct apds9306_data *data, int *val) > if (ret) > return ret; > > - if (!in_range(period, 0, APDS9306_ALS_PERSIST_VAL_MAX)) > + if (!in_range(period, 0, APDS9306_ALS_PERSIST_NUM_VALS)) > return -EINVAL; > > *val = period; > @@ -738,7 +738,7 @@ static int apds9306_event_period_set(struct apds9306_data *data, int val) > { > struct apds9306_regfields *rf = &data->rf; > > - if (!in_range(val, 0, APDS9306_ALS_PERSIST_VAL_MAX)) > + if (!in_range(val, 0, APDS9306_ALS_PERSIST_NUM_VALS)) > return -EINVAL; > > return regmap_field_write(rf->int_persist_val, val); > @@ -796,7 +796,7 @@ static int apds9306_event_thresh_adaptive_get(struct apds9306_data *data, int *v > if (ret) > return ret; > > - if (!in_range(thr_adpt, 0, APDS9306_ALS_THRES_VAR_VAL_MAX)) > + if (!in_range(thr_adpt, 0, APDS9306_ALS_THRES_VAR_NUM_VALS)) > return -EINVAL; > > *val = thr_adpt; > @@ -808,7 +808,7 @@ static int apds9306_event_thresh_adaptive_set(struct apds9306_data *data, int va > { > struct apds9306_regfields *rf = &data->rf; > > - if (!in_range(val, 0, APDS9306_ALS_THRES_VAR_VAL_MAX)) > + if (!in_range(val, 0, APDS9306_ALS_THRES_VAR_NUM_VALS)) > return -EINVAL; > > return regmap_field_write(rf->int_thresh_var_val, val); > > base-commit: b80ad8e3cd2712b78b98804d1f59199680d8ed91