From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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 9779B31C567 for ; Sat, 25 Jul 2026 21:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785014865; cv=none; b=XWWaxwe4pJKYevT8HwtACG8S3RxLWMGM+tQK6+wv7q7FxJTNKeXhbLynQkKZo5e80q5dYWnY2TBNNcj2O0lOUW2hJuJC1UiKT3lh11sPXVLeKCxLdofDC7jj9miFtT6Ur/H8MoCUFeZh9i1TZl6aUU/5bu6biTMg9ftISOmuqBc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785014865; c=relaxed/simple; bh=bbm4G5+H9qfb8kAzKuMXadu3Ig3vcGs1sJQxmJ+HtZg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=og6uBVIqNt6dv3t2UQQQATGUZs8SkLbLQUXmIkriQ4tnxlRJRvmzfzEI7LnpwM1JnBAB/WlizyZTyGpwDhBmNIO39ipYYz+ZKT3OCLEFPpVCxPL+Ao4zj3okIBorGNMkuJIM+zw659p//LMIHW9wk19eG4qQ2onoZTk5GfPRy2Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=C584+aqt; arc=none smtp.client-ip=209.85.210.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="C584+aqt" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-7eb64371a2aso884049a34.0 for ; Sat, 25 Jul 2026 14:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1785014862; x=1785619662; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=iTxBT1gKsJ/ZJU0nGnVJ/OW01XixCAwYOpDLYsOlEto=; b=C584+aqt62LUgakZB23AVgf0PSafz0GxjMEXqoScfI9910wbp1R3j32/1TNjnquq7t hBTV+ihYU/EbDN3z6/roYkNFxqxsVkYMZ2PXdMmj2Ly0Buf/am9NEdV1hZYGdqU6qeoo gaf3y8UVty2tF0db25jg/mFPrrhCGM8+9MS+apMlevtH08r75jfJNRTTlqKrKoP07w+U NNHV9jTt5f2ieSUIQpDLMF9mI+GVwdQYWKabF4VAnmusoceRSWRBZ60oZDr8BepQuNHv 25dEGKetu8kosQFDLjkU6+yce4PZKPtjH+r77JjPVLeIW68fxO3tWKP0ouiUm4pOtDRl Cfng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785014862; x=1785619662; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iTxBT1gKsJ/ZJU0nGnVJ/OW01XixCAwYOpDLYsOlEto=; b=JOsWGtQNalCabtUCMvbv27RMVwUzCjfkW+q3O/fl8ryhIJqrt5B9/u+xgDzj4iohEt rqO4p8aXAE3sSMrDcGpImgcz0LUjC4kRnU16F0zBlmIuRuI/e/IiOR9uDGRT13rXYz7L 75NPuLcTrdNyo3N+UDg1DlJhAu1ZEipmwN+npFLCRkq6gkEm6RWMBgR39wLUesSJsio0 beSgmaF/Fr/KuDIBfw78f3+BV6dWr9Z1mUkFkn213fii81EU+wx4S4L395UIDb8cnFeC tmltB99Z/QlcixPYAd3exDnJZ6kI5uD+evv1+A2IDyrXBWLVeS96w49X9qgdDhYDJB1K Ybaw== X-Forwarded-Encrypted: i=1; AHgh+Roni9XdjpQxqrH7Smp6QPK/e6OO/FEd/4Czth33UrfpkIUs548E0DEgf+ljDL7hHqTtq9NWnxU08puzQgU=@vger.kernel.org X-Gm-Message-State: AOJu0Yxn3RDQzJ4O3JfqnHxFvJUV1scDhZ9vz1BKip9g41dVNPPzNhtY olYbZ2g/N64G/4vUYeZxQHclJreQ38SreBMwE3t88yHTg8hoiEbrC9WQFKBO6X/itSM= X-Gm-Gg: AR+sD10oGl0j3IK08xfS896cHnGD2y8ZL5cLDtOn5AT1MCIY+KoiAmt1kWiX2iErlSA E5MS/LsvkSzorvNFA1hXv5bh/q0XabQXwL8fT4k6c3xWEZka3T2pv3lhVOGETMa+Ozj33+vDYhR qA44FOvWtFVU3cRq6ecD4MHiM1CbDWMLj6zyQD7qSePi2RncJm5Jm7T3aPJSoCNYyD23GGWceoe lVXLsKG7Y8Fo3P3eQl0UVpEaQdO9+g12swx2x6kKauzjhNxSWtEvS0KCYDpBTNw8WvZbeh0uwvW E6RjAW78p+LSNoBfw7ZQWDjaXH52VTI9Vu8PkV4uHDZ4UbwmoDS8EgOvLfiimGcMM+V4eg7q54K Bn8ei3Ow+FCsazxFxOmYBv4Ht6Af7zQDlj6G4B1AK0WXzsB7VL20yJ3HZ82UzTlOl7VlaAI5XPQ aCiiJ8TxyGFYpzTMLjm9RCD7uhuaBkctSUg5Z0h+ViHQosbdI= X-Received: by 2002:a05:6830:6687:b0:7e9:f6ca:e59d with SMTP id 46e09a7af769-7ee78d635ffmr2550024a34.19.1785014862492; Sat, 25 Jul 2026 14:27:42 -0700 (PDT) Received: from ?IPV6:2600:8803:e7e4:500:105e:29ca:45cc:c7? ([2600:8803:e7e4:500:105e:29ca:45cc:c7]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7ee29e2643fsm8885592a34.9.2026.07.25.14.27.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Jul 2026 14:27:41 -0700 (PDT) Message-ID: <99422b78-20e7-4222-a2d8-ca778a3a618b@baylibre.com> Date: Sat, 25 Jul 2026 16:27:39 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] iio: light: tsl2772: fix ALS calibscale readback To: Yuanshen Cao , Jonathan Cameron , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260724-tsl2772-calibscale-fix-v1-1-00a7789f4deb@gmail.com> Content-Language: en-US From: David Lechner In-Reply-To: <20260724-tsl2772-calibscale-fix-v1-1-00a7789f4deb@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 7/24/26 6:46 PM, Yuanshen Cao wrote: > The read_raw() implementation uses IIO_LIGHT to distinguish between the > ambient light and proximity channels when handling > IIO_CHAN_INFO_CALIBSCALE. > > However, the ALS channel is registered as IIO_INTENSITY, while > write_raw() correctly writes to IIO_INTENSITY. As a result, reading > in_intensity0_calibscale incorrectly returns the proximity gain instead > of the ALS gain. > > This causes the following user-visible behavior: > - Writing in_intensity0_calibscale appears to have no effect because the > readback reports the proximity gain. > - Writing in_proximity0_calibscale causes both in_proximity0_calibscale > and in_intensity0_calibscale to report the same value. > > Fix this by checking for IIO_INTENSITY in read_raw(), matching the > channel definition and the existing write_raw() implementation. > > Signed-off-by: Yuanshen Cao > --- > drivers/iio/light/tsl2772.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c > index 244f44379c36..2287585711c6 100644 > --- a/drivers/iio/light/tsl2772.c > +++ b/drivers/iio/light/tsl2772.c > @@ -1274,7 +1274,7 @@ static int tsl2772_read_raw(struct iio_dev *indio_dev, > } > break; > case IIO_CHAN_INFO_CALIBSCALE: > - if (chan->type == IIO_LIGHT) > + if (chan->type == IIO_INTENSITY) > *val = tsl2772_als_gain[chip->settings.als_gain]; > else > *val = tsl2772_prox_gain[chip->settings.prox_gain]; > > --- > base-commit: 1590cf0329716306e948a8fc29f1d3ee87d3989f > change-id: 20260724-tsl2772-calibscale-fix-0cc42518d5fc > > Best regards, > -- > Yuanshen Cao > Reviewed-by: David Lechner