Message ID | 20231215160159.648963-1-srinivas.pandruvada@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-1245-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9381482dys; Fri, 15 Dec 2023 08:02:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGFNp++wpRFbpl+cba3tsLzJnW48k++JVVwFPm1xs3B3WqSLnn1Yv5n2PqyubPa4aQ3qt7 X-Received: by 2002:a50:9eee:0:b0:550:4421:bba4 with SMTP id a101-20020a509eee000000b005504421bba4mr5507226edf.63.1702656160101; Fri, 15 Dec 2023 08:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702656160; cv=none; d=google.com; s=arc-20160816; b=xaVfpj52/hIHa07hTwcPXrKhl3+G6Xk3lUbTBbtu4XfnF/JigK2/oGQpl90Dez2Njt /qd6TCakPHaMmX1J/wRGPAyoIz1lOBgeI0NQvQkydl3p0jb9QBz82wHi0hvw6oMCLP2t uwEfs9UZglmrzfu9/HzoE1UkJEJLGoIhA5ku7JkRfcb/sW0HZX9hwa190m0bF+UVuu3B VZOgXRviR39/31AKOfZs9x5RcTgakRXnLwWg7L/R3n9lC1IBkLTtatsNwThote+EQl60 dGytFZyvyjQFMc/M7MGt0QhGj9yf/Rj6K6XR+x9WApCKaeNKNSdmL7yeySAUdmyg/GpN +grw== ARC-Message-Signature: i=1; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=GRhabRPNumJo47QobSnqzY3biBfCttbjRvdF4noPEOM=; fh=7o7u0REjo27AroWG654FakG9q9tmY8lcPc4viP1ImLc=; b=sW6q4cJwWnYJlS/5yeQXlgOFNK7QRZPcFu5Yq+/McWa2kFDuhf4mTx230Z5CmRaieH mvB+DD6W/Wif6pkbllWgxocX2ajUi23+oBAsplRUPp0jA2Ak2gKzRSVVEu+c6lM4otTZ hx1GoFC51mne0aGm53LOpNFIScFYdzQddEOq+BdOVsW1W6UJ2O1jLvZxTnNDeL48dpkr AxxnVW+UprCqVAzB1C6j/EW0Dp2IJIAiLtnNXBDiNQ8bTeoYmRAfYNQ1u2hRxL+jRHQj 2oXSYTCa+amSpIVp7e24ovMMx8WO6M5K72TT6g7cXXb07unTZT4HlWGWzR++6IOrI2g0 HQ8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EkTbs8Sv; spf=pass (google.com: domain of linux-kernel+bounces-1245-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1245-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j12-20020a05640211cc00b005527f199072si1527516edw.239.2023.12.15.08.02.39 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 08:02:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1245-ouuuleilei=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=@intel.com header.s=Intel header.b=EkTbs8Sv; spf=pass (google.com: domain of linux-kernel+bounces-1245-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1245-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 8A53B1F24A77 for <ouuuleilei@gmail.com>; Fri, 15 Dec 2023 16:02:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE6C73A8FD; Fri, 15 Dec 2023 16:02:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EkTbs8Sv" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 5E95F36AE0; Fri, 15 Dec 2023 16:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702656142; x=1734192142; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=T9RSzfQqw97u35cP02echEw6kn4/I1wBERkazpCYse0=; b=EkTbs8SvvR7AaB51QsNZO88wzFpbWK5raXEw/acUXUV3+d3DjA1jgrk+ rmgNV49L3O87SFWyKtzk4qdGELRTCc//CjlAMp3aHWOv0AObN3OWqfaPJ uJF5lsNU7AmFdAxnYdh5PZciJyOhH3EwPSlieYLRCxBYRBeKvCEidN7wO o48T3FvxoqVgxp+8W/clSVr4nNd0oJ7iyWos+NldW8PcK0rPdTkL8ebZR 88b0gEpP72/eOOWXCtA91DzGst29IB0DgtnkBO0YjwvhX6VaKRks8KakH tmxmneJ2X4zKUb4nHMu7aaxOF6UkwBjeWmRzm5FRkzCwVCrVvVSjEUJrK w==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="13973685" X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="13973685" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2023 08:02:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="948010121" X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="948010121" Received: from spandruv-desk.jf.intel.com ([10.54.75.14]) by orsmga005.jf.intel.com with ESMTP; 15 Dec 2023 08:02:20 -0800 From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> To: jikos@kernel.org, jic23@kernel.org, lars@metafoo.de, Basavaraj.Natikar@amd.com Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>, =?utf-8?q?Thomas?= =?utf-8?q?_Wei=C3=9Fschuh?= <thomas@t-8ch.de>, stable@vger.kernel.org Subject: [PATCH] iio: light: hid-sensor-als: Avoid failure for chromaticity support Date: Fri, 15 Dec 2023 08:01:59 -0800 Message-Id: <20231215160159.648963-1-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785364385429583597 X-GMAIL-MSGID: 1785364385429583597 |
Series |
iio: light: hid-sensor-als: Avoid failure for chromaticity support
|
|
Commit Message
srinivas pandruvada
Dec. 15, 2023, 4:01 p.m. UTC
With the commit ee3710f39f9d ("iio: hid-sensor-als: Add light chromaticity
support"), there is an assumption that the every HID ALS descriptor has
support of usage ids for chromaticity support. If they are not present,
probe fails for the driver . This breaks ALS functionality on majority of
platforms.
It is possible that chromaticity usage ids are not present. When not
present, restrict number of IIO channels to not include support for
chromaticity and continue.
Fixes: ee3710f39f9d ("iio: hid-sensor-als: Add light chromaticity support")
Reported-by: Thomas Weißschuh <thomas@t-8ch.de>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218223
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: stable@vger.kernel.org
---
drivers/iio/light/hid-sensor-als.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
Comments
On 2023-12-15 08:01:59-0800, Srinivas Pandruvada wrote: > With the commit ee3710f39f9d ("iio: hid-sensor-als: Add light chromaticity > support"), there is an assumption that the every HID ALS descriptor has > support of usage ids for chromaticity support. If they are not present, > probe fails for the driver . This breaks ALS functionality on majority of > platforms. > > It is possible that chromaticity usage ids are not present. When not > present, restrict number of IIO channels to not include support for > chromaticity and continue. > > Fixes: ee3710f39f9d ("iio: hid-sensor-als: Add light chromaticity support") > Reported-by: Thomas Weißschuh <thomas@t-8ch.de> > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218223 > Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> > Cc: stable@vger.kernel.org > --- > drivers/iio/light/hid-sensor-als.c | 24 ++++++++++++++++-------- > 1 file changed, 16 insertions(+), 8 deletions(-) Thanks! Tested-by: Thomas Weißschuh <linux@weissschuh.net> # on Framework 13 AMD
On Fri, 15 Dec 2023 08:01:59 -0800 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> wrote: > With the commit ee3710f39f9d ("iio: hid-sensor-als: Add light chromaticity > support"), there is an assumption that the every HID ALS descriptor has > support of usage ids for chromaticity support. If they are not present, > probe fails for the driver . This breaks ALS functionality on majority of > platforms. > > It is possible that chromaticity usage ids are not present. When not > present, restrict number of IIO channels to not include support for > chromaticity and continue. > > Fixes: ee3710f39f9d ("iio: hid-sensor-als: Add light chromaticity support") > Reported-by: Thomas Weißschuh <thomas@t-8ch.de> > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218223 > Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> > Cc: stable@vger.kernel.org > --- > drivers/iio/light/hid-sensor-als.c | 24 ++++++++++++++++-------- > 1 file changed, 16 insertions(+), 8 deletions(-) > > diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c > index f17304b54468..9941b0b927c7 100644 > --- a/drivers/iio/light/hid-sensor-als.c > +++ b/drivers/iio/light/hid-sensor-als.c > @@ -303,11 +303,14 @@ static int als_parse_report(struct platform_device *pdev, > struct hid_sensor_hub_device *hsdev, > struct iio_chan_spec *channels, > unsigned usage_id, > - struct als_state *st) > + struct als_state *st, > + int *max_channels) > { > int ret; > int i; > > + *max_channels = CHANNEL_SCAN_INDEX_MAX; > + > for (i = 0; i <= CHANNEL_SCAN_INDEX_ILLUM; ++i) { > ret = sensor_hub_input_get_attribute_info(hsdev, > HID_INPUT_REPORT, > @@ -326,8 +329,12 @@ static int als_parse_report(struct platform_device *pdev, > usage_id, > HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE, > &st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP]); > - if (ret < 0) > - return ret; > + if (ret < 0) { > + *max_channels = CHANNEL_SCAN_INDEX_ILLUM; > + ret = 0; > + goto skip_color_chromaticity; > + } > + > als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP, > st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size); > > @@ -354,6 +361,7 @@ static int als_parse_report(struct platform_device *pdev, > st->als[next_scan_index].report_id); > } > > +skip_color_chromaticity: > st->scale_precision = hid_sensor_format_scale(usage_id, > &st->als[CHANNEL_SCAN_INDEX_INTENSITY], > &st->scale_pre_decml, &st->scale_post_decml); > @@ -364,7 +372,7 @@ static int als_parse_report(struct platform_device *pdev, > /* Function to initialize the processing for usage id */ > static int hid_als_probe(struct platform_device *pdev) > { > - int ret = 0; > + int ret = 0, max_channels; > static const char *name = "als"; > struct iio_dev *indio_dev; > struct als_state *als_state; > @@ -398,15 +406,15 @@ static int hid_als_probe(struct platform_device *pdev) > > ret = als_parse_report(pdev, hsdev, > (struct iio_chan_spec *)indio_dev->channels, > - hsdev->usage, > - als_state); > + hsdev->usage, als_state, &max_channels); > if (ret) { > dev_err(&pdev->dev, "failed to setup attributes\n"); > return ret; > } > > - indio_dev->num_channels = > - ARRAY_SIZE(als_channels); > + /* +1 to include time stamp */ > + indio_dev->num_channels = max_channels + 1; In the current array the timestamp channel isn't the next one, so how does this work? I think we either have to form the channel array dynamically or pick between one that does have the colour info and one that doesn't for the original case. Given timing we may just need to revert the broken patch and revisit this next cycle. Jonathan > + > indio_dev->info = &als_info; > indio_dev->name = name; > indio_dev->modes = INDIO_DIRECT_MODE;
On Sun, 2023-12-17 at 14:35 +0000, Jonathan Cameron wrote: > On Fri, 15 Dec 2023 08:01:59 -0800 > Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> wrote: > > > With the commit ee3710f39f9d ("iio: hid-sensor-als: Add light > > chromaticity > > support"), there is an assumption that the every HID ALS descriptor > > has > > support of usage ids for chromaticity support. If they are not > > present, > > probe fails for the driver . This breaks ALS functionality on > > majority of > > platforms. > > > > It is possible that chromaticity usage ids are not present. When > > not > > present, restrict number of IIO channels to not include support for > > chromaticity and continue. > > > > Fixes: ee3710f39f9d ("iio: hid-sensor-als: Add light chromaticity > > support") > > Reported-by: Thomas Weißschuh <thomas@t-8ch.de> > > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218223 > > Signed-off-by: Srinivas Pandruvada > > <srinivas.pandruvada@linux.intel.com> > > Cc: stable@vger.kernel.org > > --- > > drivers/iio/light/hid-sensor-als.c | 24 ++++++++++++++++-------- > > 1 file changed, 16 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/iio/light/hid-sensor-als.c > > b/drivers/iio/light/hid-sensor-als.c > > index f17304b54468..9941b0b927c7 100644 > > --- a/drivers/iio/light/hid-sensor-als.c > > +++ b/drivers/iio/light/hid-sensor-als.c > > @@ -303,11 +303,14 @@ static int als_parse_report(struct > > platform_device *pdev, > > struct hid_sensor_hub_device > > *hsdev, > > struct iio_chan_spec *channels, > > unsigned usage_id, > > - struct als_state *st) > > + struct als_state *st, > > + int *max_channels) > > { > > int ret; > > int i; > > > > + *max_channels = CHANNEL_SCAN_INDEX_MAX; > > + > > for (i = 0; i <= CHANNEL_SCAN_INDEX_ILLUM; ++i) { > > ret = sensor_hub_input_get_attribute_info(hsdev, > > HID_INPUT_REPORT, > > @@ -326,8 +329,12 @@ static int als_parse_report(struct > > platform_device *pdev, > > usage_id, > > HID_USAGE_SENSOR_LIGHT_COLOR_TEMPER > > ATURE, > > &st- > > >als[CHANNEL_SCAN_INDEX_COLOR_TEMP]); > > - if (ret < 0) > > - return ret; > > + if (ret < 0) { > > + *max_channels = CHANNEL_SCAN_INDEX_ILLUM; > > + ret = 0; > > + goto skip_color_chromaticity; > > + } > > + > > als_adjust_channel_bit_mask(channels, > > CHANNEL_SCAN_INDEX_COLOR_TEMP, > > st- > > >als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size); > > > > @@ -354,6 +361,7 @@ static int als_parse_report(struct > > platform_device *pdev, > > st->als[next_scan_index].report_id); > > } > > > > +skip_color_chromaticity: > > st->scale_precision = hid_sensor_format_scale(usage_id, > > &st- > > >als[CHANNEL_SCAN_INDEX_INTENSITY], > > &st->scale_pre_decml, &st- > > >scale_post_decml); > > @@ -364,7 +372,7 @@ static int als_parse_report(struct > > platform_device *pdev, > > /* Function to initialize the processing for usage id */ > > static int hid_als_probe(struct platform_device *pdev) > > { > > - int ret = 0; > > + int ret = 0, max_channels; > > static const char *name = "als"; > > struct iio_dev *indio_dev; > > struct als_state *als_state; > > @@ -398,15 +406,15 @@ static int hid_als_probe(struct > > platform_device *pdev) > > > > ret = als_parse_report(pdev, hsdev, > > (struct iio_chan_spec *)indio_dev- > > >channels, > > - hsdev->usage, > > - als_state); > > + hsdev->usage, als_state, > > &max_channels); > > if (ret) { > > dev_err(&pdev->dev, "failed to setup > > attributes\n"); > > return ret; > > } > > > > - indio_dev->num_channels = > > - ARRAY_SIZE(als_channels); > > + /* +1 to include time stamp */ > > + indio_dev->num_channels = max_channels + 1; > > In the current array the timestamp channel isn't the next one, so how > does this work? > > I think we either have to form the channel array dynamically or pick > between > one that does have the colour info and one that doesn't for the > original case. > You are right, let me resubmit. > Given timing we may just need to revert the broken patch and revisit > this next > cycle. This is better. I will send a revert. Thanks, Srinivas > > Jonathan > > > > + > > indio_dev->info = &als_info; > > indio_dev->name = name; > > indio_dev->modes = INDIO_DIRECT_MODE; >
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index f17304b54468..9941b0b927c7 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -303,11 +303,14 @@ static int als_parse_report(struct platform_device *pdev, struct hid_sensor_hub_device *hsdev, struct iio_chan_spec *channels, unsigned usage_id, - struct als_state *st) + struct als_state *st, + int *max_channels) { int ret; int i; + *max_channels = CHANNEL_SCAN_INDEX_MAX; + for (i = 0; i <= CHANNEL_SCAN_INDEX_ILLUM; ++i) { ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT, @@ -326,8 +329,12 @@ static int als_parse_report(struct platform_device *pdev, usage_id, HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE, &st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP]); - if (ret < 0) - return ret; + if (ret < 0) { + *max_channels = CHANNEL_SCAN_INDEX_ILLUM; + ret = 0; + goto skip_color_chromaticity; + } + als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP, st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size); @@ -354,6 +361,7 @@ static int als_parse_report(struct platform_device *pdev, st->als[next_scan_index].report_id); } +skip_color_chromaticity: st->scale_precision = hid_sensor_format_scale(usage_id, &st->als[CHANNEL_SCAN_INDEX_INTENSITY], &st->scale_pre_decml, &st->scale_post_decml); @@ -364,7 +372,7 @@ static int als_parse_report(struct platform_device *pdev, /* Function to initialize the processing for usage id */ static int hid_als_probe(struct platform_device *pdev) { - int ret = 0; + int ret = 0, max_channels; static const char *name = "als"; struct iio_dev *indio_dev; struct als_state *als_state; @@ -398,15 +406,15 @@ static int hid_als_probe(struct platform_device *pdev) ret = als_parse_report(pdev, hsdev, (struct iio_chan_spec *)indio_dev->channels, - hsdev->usage, - als_state); + hsdev->usage, als_state, &max_channels); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); return ret; } - indio_dev->num_channels = - ARRAY_SIZE(als_channels); + /* +1 to include time stamp */ + indio_dev->num_channels = max_channels + 1; + indio_dev->info = &als_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE;