From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA3CC3F5BE1 for ; Fri, 26 Jun 2026 13:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782481162; cv=none; b=jBi/HpDfkQrumVYZDzt7RrQpIApJ4y7UKFebW4UtH/O7Q/ut8VTqI7pDrEYFFhKZ5cGHBDUQeMUOf1UvGkxuR+mYypPuNhKLBI9hDLxzM1mXN/UB+5hQmh9AyJqP4LZsrQ/0/uGgoU++Il6RGNT3FrK2qZ8bA9p5lYO9KoFWM54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782481162; c=relaxed/simple; bh=8IWGMBNMMaYvrEtzeOyPCy0ciX1dHwS/xUpWBpFHs7E=; h=Mime-Version:Content-Type:Date:Message-Id:From:Subject:Cc:To: References:In-Reply-To; b=CTWx6ZK/vr14t8rhuxmQC2m+qrkPki/NMfpNGfkRuWJOjT18iiVBOlqSEdbQvAh7yMPGl/Q7aHrmTFrWBqlMgYxdVzJolJNrv2CyHgPtpTSa8Lwwf5Yr615iAyeBklz9as9nl22wqlpz+igi2/oCRwlj/0c8vyg5ATnybBjTYmg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RyvQoPxa; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RyvQoPxa" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so7011065e9.0 for ; Fri, 26 Jun 2026 06:39:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782481159; x=1783085959; darn=vger.kernel.org; h=in-reply-to:references:to:cc:subject:from:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=178Ey6oKnQQUab4uHEMxdjvdHtzJxPn/oHknzkZEjfI=; b=RyvQoPxaLH4iun2lvEkUBiXqGTKCVdpCMb/IQjZXLaVUSqS2lYbz57n1xT4e3mvjg9 utTOuz3YjE1JZfoxSfEV4eMGX4mWivd3TaTnptTjcPu16n2XAAMlta9hiFiBDwedU5FA 2uwAb/rCh8bDx+LNJ+tIA9HX8vnMH2D0h1tkagN+9lBzzfzhUj0ao+qyUqXZ8yFmAQe7 PYyiBlVXezL7rUC86OBeeR20ihzEGh8GJlMS/AmliE76rITlHATrFbQNQG9pVEXsM1C4 6gIGh+nxmBL3CTzMElbPIEfmQfmyBaKFY5EQ3TNtm2Dpl0Wk2RFtRUBnVJ4EY0/ThdtW aRuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782481159; x=1783085959; h=in-reply-to:references:to:cc:subject:from:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=178Ey6oKnQQUab4uHEMxdjvdHtzJxPn/oHknzkZEjfI=; b=Wjt0/i/j+NlWLvmFZYRrb0eY++9QpXDzOyBn1QWFzntKQy76UWNmVPt3QjRddWfOFH 48iIjsf0vtdqn9xW7Et6STWdG0E76UBJ0/hgljSfa9lrJAT2ofDdwIjbAVCtK+4RN3OB nzIQ9s7w09bYC+zgLNFT7HDSmet0AktJW37JIichLHlzGkynb2F/uhL4x0w2a8SJA5QU GFBQpVbHPXLzARLcpLYq88VlfQXp9gJ1C+J80ABr9zjuybKgiavYAHAtKhdD+xCdL/kE oJHLHkwr7GVrme/PyjMjUWXU4cRDp7WYuP1aDPiEYANalJ5oKuqsm0fq1WJ1Y26ptNhg kIJg== X-Forwarded-Encrypted: i=1; AFNElJ9Xho+UN+z1yV6W8rAOsaacAOpuJZ9MI3N28CTBvyZZRi4fsRE7zD1zb7die1UD9TTVVRMBkbC7tIWGmzM=@vger.kernel.org X-Gm-Message-State: AOJu0YyBQet4ZrpkUzs69mwED/t6AHwWStFTATPTZzuJeUDk7bo8PB6N H0p43/T1ztHk7rO3MsBHfqtdzZlTxtaUeCV9P700EZGCFh9NCFPHo27F X-Gm-Gg: AfdE7clcS18R1w7Vbdhp3Qacmts/ldAneubiPW6tDRCfCrmjlc5BOGA/pW9NWKpl+PC 4IvzoI8DZDKLZPMktkimYEbAiqZ3BmT13oD+3IR5TGrkRpvbTz7N+mg45/2C0O0ZLYhsihzI96y 6/zaK+pDsUlJm7Xp1DeYxGFJfHmfHDpFBiaTekeoq2hHINnk9+XDQ+bdPOV4wPst/s4WuSQE7s3 TluEt1fAEuA5jHbgkNT3fWIOjJtuBSUKK8mHWf137X/o1XP63dMw4Tmi+8rKeopg58DpsoDwbVI swFKOf7wqCfHy9mfYQGHqn5tlcZvLHcO3VHc4yQbMYoSe28bC+JSrrwdPyOG4ln/bnAgrSxdLXC 7peBWal72rFi8nPjsqUuS6483OD0Ra+jf67QMRr3VCVMolQ99CDC35l7w1FevxgV6RSQkcwUIr5 TpXYmbK2/mKnAN23NqPsK3vNc= X-Received: by 2002:a05:600c:3549:b0:492:4363:e7eb with SMTP id 5b1f17b1804b1-492668acc8cmr101181495e9.32.1782481159145; Fri, 26 Jun 2026 06:39:19 -0700 (PDT) Received: from localhost ([2001:4bb8:16f:1117:388:ce2:35e4:fb50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4926c278ab2sm33706745e9.1.2026.06.26.06.39.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Jun 2026 06:39:18 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 26 Jun 2026 15:39:16 +0200 Message-Id: From: "Javier Carrasco" Subject: Re: [PATCH] iio: light: veml6075: fix UV index reported at half value Cc: "David Lechner" , =?utf-8?q?Nuno_S=C3=A1?= , "Andy Shevchenko" , , To: "Shardul Deshpande" , "Jonathan Cameron" , "Javier Carrasco" X-Mailer: aerc 0.21.0-143-g2f3a2e260c09 References: <20260626110400.68885-1-iamsharduld@gmail.com> In-Reply-To: <20260626110400.68885-1-iamsharduld@gmail.com> On Fri Jun 26, 2026 at 1:04 PM CEST, Shardul Deshpande wrote: > veml6075_get_uvi_micro() normalises the UV index for the configured > integration time by dividing the summed, responsivity-weighted UVA/UVB > components by the integration-time scale factor relative to the 50 ms > base case (which is returned undivided). > > The supported integration times are 50, 100, 200, 400 and 800 ms, i.e. > the register field index int_index in 0..4 selects (50 << int_index) ms, > so the correct scale factor is 2^int_index =3D=3D (1 << int_index). > > The code instead divides by (2 << int_index) =3D=3D 2^(int_index + 1), wh= ich > is twice the correct value. The reported UV index is therefore half of > the true value for every integration time except 50 ms (handled as a > separate case). As the driver powers up with VEML6075_IT_100_MS, the UV > index is reported at half value out of the box. > > Divide by (1 << int_index) instead; this also matches the undivided > 50 ms case (1 << 0 =3D=3D 1). > > Fixes: 3b82f43238ae ("iio: light: add VEML6075 UVA and UVB light sensor d= river") > Cc: stable@vger.kernel.org > Signed-off-by: Shardul Deshpande > --- > drivers/iio/light/veml6075.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/light/veml6075.c b/drivers/iio/light/veml6075.c > index 59187244a..af71df69f 100644 > --- a/drivers/iio/light/veml6075.c > +++ b/drivers/iio/light/veml6075.c > @@ -244,7 +244,7 @@ static int veml6075_get_uvi_micro(struct veml6075_dat= a *data, int uva_comp, > case VEML6075_IT_200_MS: > case VEML6075_IT_400_MS: > case VEML6075_IT_800_MS: > - return (uvia_micro + uvib_micro) / (2 << int_index); > + return (uvia_micro + uvib_micro) / (1 << int_index); > default: > return -EINVAL; > } Hi Shardul, thank you for your patch. I agree with your reasoning, but why don't you get rid of the switch once the operation is the same for all cases? Best regards, Javier