Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, "Daniel Schaefer" <dhs@frame.work>,
	"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
	"Jonathan Cameron" <jonathan.cameron@oss.qualcomm.com>,
	"Sasha Levin" <sashal@kernel.org>,
	"Sven Vainküla" <sven@xn--vainkla-r2a.ee>
Subject: [PATCH 7.2 05/10] iio: hid-sensor: als: scale each channel individually
Date: Fri, 30 Oct 2026 13:15:06 +0100	[thread overview]
Message-ID: <20261030121255.387630811@linuxfoundation.org> (raw)
In-Reply-To: <20261030121255.257615100@linuxfoundation.org>

7.2-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Daniel Schaefer <dhs@frame.work>

[ Upstream commit cad928dad9a4c26aa56b4223dc2a29bca517fb5f ]

Some sensors have multiple channels (not just brightness but color ALS
sensors) with different scaling factors.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Link: https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/merge_requests/413
Tested-by: Sven Vainküla <sven@xn--vainkla-r2a.ee> #Asus ProArt PX13 laptop.
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/light/hid-sensor-als.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 6bf1bc9a38fe6..8f2affb226a35 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -33,9 +33,9 @@ struct als_state {
 		u32 illum[CHANNEL_SCAN_INDEX_MAX];
 		aligned_s64 timestamp;
 	} scan;
-	int scale_pre_decml;
-	int scale_post_decml;
-	int scale_precision;
+	int scale_pre_decml[CHANNEL_SCAN_INDEX_MAX];
+	int scale_post_decml[CHANNEL_SCAN_INDEX_MAX];
+	int scale_precision[CHANNEL_SCAN_INDEX_MAX];
 	int value_offset;
 	int num_channels;
 	s64 timestamp;
@@ -175,9 +175,11 @@ static int als_read_raw(struct iio_dev *indio_dev,
 		ret_type = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_SCALE:
-		*val = als_state->scale_pre_decml;
-		*val2 = als_state->scale_post_decml;
-		ret_type = als_state->scale_precision;
+		if (chan->scan_index >= CHANNEL_SCAN_INDEX_MAX)
+			return -EINVAL;
+		*val = als_state->scale_pre_decml[chan->scan_index];
+		*val2 = als_state->scale_post_decml[chan->scan_index];
+		ret_type = als_state->scale_precision[chan->scan_index];
 		break;
 	case IIO_CHAN_INFO_OFFSET:
 		*val = als_state->value_offset;
@@ -331,6 +333,10 @@ static int als_parse_report(struct platform_device *pdev,
 		};
 		++index;
 
+		st->scale_precision[i] = hid_sensor_format_scale(usage_id,
+					&st->als[i], &st->scale_pre_decml[i],
+					&st->scale_post_decml[i]);
+
 		dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
 			st->als[i].report_id);
 	}
@@ -340,10 +346,6 @@ static int als_parse_report(struct platform_device *pdev,
 	if (index)
 		ret = 0;
 
-	st->scale_precision = hid_sensor_format_scale(usage_id,
-				&st->als[CHANNEL_SCAN_INDEX_INTENSITY],
-				&st->scale_pre_decml, &st->scale_post_decml);
-
 	return ret;
 }
 
-- 
2.53.0




  parent reply	other threads:[~2026-10-30 12:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 12:15 [PATCH 7.2 00/10] 7.2.15-rc1 review Greg Kroah-Hartman
2026-10-30 12:15 ` [PATCH 7.2 01/10] ksmbd: wait for negotiation before receiving another PDU Greg Kroah-Hartman
2026-10-30 12:15 ` [PATCH 7.2 02/10] smb: smbdirect: dont wait for RDMA_CM_EVENT_DISCONNECTED in smbdirect_socket_destroy_sync() Greg Kroah-Hartman
2026-10-30 12:15 ` [PATCH 7.2 03/10] smb: smbdirect: release failed pending sockets of a listener Greg Kroah-Hartman
2026-10-30 12:42   ` 이성현
2026-10-30 12:15 ` [PATCH 7.2 04/10] smb: smbdirect: dont hand out already failed sockets in smbdirect_socket_accept() Greg Kroah-Hartman
2026-10-30 12:15 ` Greg Kroah-Hartman [this message]
2026-10-30 12:15 ` [PATCH 7.2 06/10] platform: cznic: turris-omnia-mcu: Add missing MODULE_DEVICE_TABLE() Greg Kroah-Hartman
2026-10-30 12:15 ` [PATCH 7.2 07/10] kbuild: link-vmlinux.sh: improve detection of third pass requirement Greg Kroah-Hartman
2026-10-30 12:15 ` [PATCH 7.2 08/10] exec: cancel io_uring requests before de_thread() Greg Kroah-Hartman
2026-10-30 12:15 ` [PATCH 7.2 09/10] fork: move the coredump and exec checks into create_io_thread() Greg Kroah-Hartman
2026-10-30 12:15 ` [PATCH 7.2 10/10] fork: dont create io threads once PF_POSTCOREDUMP is set Greg Kroah-Hartman
2026-10-30 12:20 ` [PATCH 7.2 00/10] 7.2.15-rc1 review Peter Schneider
2026-10-30 12:51   ` Greg Kroah-Hartman
2026-10-30 12:58     ` Peter Schneider
2026-10-30 13:12 ` Brett A C Sheffield
2026-10-30 13:47 ` Pavel Machek
2026-10-30 14:01 ` Miguel Ojeda
2026-10-30 21:05 ` Shuah Khan
2026-10-30 22:06 ` Florian Fainelli
2026-10-30 23:56 ` Ron Economos
2026-10-31  1:01 ` Peter Schneider
2026-10-31  8:17 ` Barry K. Nathan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261030121255.387630811@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dhs@frame.work \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=sven@xn--vainkla-r2a.ee \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox