* [PATCH] iio: hid-sensor-prox: Fix invalid read_raw for attention
@ 2024-11-21 9:16 Ricardo Ribalda
2024-11-21 16:44 ` srinivas pandruvada
0 siblings, 1 reply; 4+ messages in thread
From: Ricardo Ribalda @ 2024-11-21 9:16 UTC (permalink / raw)
To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada,
Lars-Peter Clausen
Cc: Jonathan Cameron, linux-input, linux-iio, linux-kernel,
Ricardo Ribalda
The attention channel is a IIO_CHAN_INFO_PROCESSED, not a
IIO_CHAN_INFO_RAW.
Modify prox_read_raw() to support it.
Fixes: 596ef5cf654b ("iio: hid-sensor-prox: Add support for more channels")
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/iio/light/hid-sensor-prox.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index e8e7b2999b4c..8e5d0ad13a5f 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -94,6 +94,7 @@ static int prox_read_raw(struct iio_dev *indio_dev,
*val2 = 0;
switch (mask) {
case IIO_CHAN_INFO_RAW:
+ case IIO_CHAN_INFO_PROCESSED:
if (chan->scan_index >= prox_state->num_channels)
return -EINVAL;
address = prox_state->channel2usage[chan->scan_index];
@@ -107,8 +108,7 @@ static int prox_read_raw(struct iio_dev *indio_dev,
report_id,
SENSOR_HUB_SYNC,
min < 0);
- if (prox_state->channel2usage[chan->scan_index] ==
- HID_USAGE_SENSOR_HUMAN_ATTENTION)
+ if (mask == IIO_CHAN_INFO_PROCESSED)
*val *= 100;
hid_sensor_power_state(&prox_state->common_attributes, false);
ret_type = IIO_VAL_INT;
---
base-commit: decc701f41d07481893fdea942c0ac6b226e84cd
change-id: 20241121-fix-processed-ed1a95641e64
Best regards,
--
Ricardo Ribalda <ribalda@chromium.org>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: hid-sensor-prox: Fix invalid read_raw for attention
2024-11-21 9:16 [PATCH] iio: hid-sensor-prox: Fix invalid read_raw for attention Ricardo Ribalda
@ 2024-11-21 16:44 ` srinivas pandruvada
2024-11-22 7:46 ` Ricardo Ribalda
0 siblings, 1 reply; 4+ messages in thread
From: srinivas pandruvada @ 2024-11-21 16:44 UTC (permalink / raw)
To: Ricardo Ribalda, Jiri Kosina, Jonathan Cameron,
Lars-Peter Clausen
Cc: Jonathan Cameron, linux-input, linux-iio, linux-kernel
On Thu, 2024-11-21 at 09:16 +0000, Ricardo Ribalda wrote:
> The attention channel is a IIO_CHAN_INFO_PROCESSED, not a
> IIO_CHAN_INFO_RAW.
>
> Modify prox_read_raw() to support it.
>
What is the sysfs entry to trigger this IIO_CHAN_INFO_PROCESSED read?
Don't you have an entry *_raw?
Thanks,
Srinivas
> Fixes: 596ef5cf654b ("iio: hid-sensor-prox: Add support for more
> channels")
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/iio/light/hid-sensor-prox.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/light/hid-sensor-prox.c
> b/drivers/iio/light/hid-sensor-prox.c
> index e8e7b2999b4c..8e5d0ad13a5f 100644
> --- a/drivers/iio/light/hid-sensor-prox.c
> +++ b/drivers/iio/light/hid-sensor-prox.c
> @@ -94,6 +94,7 @@ static int prox_read_raw(struct iio_dev *indio_dev,
> *val2 = 0;
> switch (mask) {
> case IIO_CHAN_INFO_RAW:
> + case IIO_CHAN_INFO_PROCESSED:
> if (chan->scan_index >= prox_state->num_channels)
> return -EINVAL;
> address = prox_state->channel2usage[chan-
> >scan_index];
> @@ -107,8 +108,7 @@ static int prox_read_raw(struct iio_dev
> *indio_dev,
>
> report_id,
>
> SENSOR_HUB_SYNC,
> min < 0);
> - if (prox_state->channel2usage[chan->scan_index] ==
> - HID_USAGE_SENSOR_HUMAN_ATTENTION)
> + if (mask == IIO_CHAN_INFO_PROCESSED)
> *val *= 100;
> hid_sensor_power_state(&prox_state-
> >common_attributes, false);
> ret_type = IIO_VAL_INT;
>
> ---
> base-commit: decc701f41d07481893fdea942c0ac6b226e84cd
> change-id: 20241121-fix-processed-ed1a95641e64
>
> Best regards,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: hid-sensor-prox: Fix invalid read_raw for attention
2024-11-21 16:44 ` srinivas pandruvada
@ 2024-11-22 7:46 ` Ricardo Ribalda
2024-11-22 16:31 ` srinivas pandruvada
0 siblings, 1 reply; 4+ messages in thread
From: Ricardo Ribalda @ 2024-11-22 7:46 UTC (permalink / raw)
To: srinivas pandruvada
Cc: Jiri Kosina, Jonathan Cameron, Lars-Peter Clausen,
Jonathan Cameron, linux-input, linux-iio, linux-kernel
On Thu, 21 Nov 2024 at 17:44, srinivas pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> On Thu, 2024-11-21 at 09:16 +0000, Ricardo Ribalda wrote:
> > The attention channel is a IIO_CHAN_INFO_PROCESSED, not a
> > IIO_CHAN_INFO_RAW.
> >
> > Modify prox_read_raw() to support it.
> >
> What is the sysfs entry to trigger this IIO_CHAN_INFO_PROCESSED read?
> Don't you have an entry *_raw?
/sys/.../iio:deviceX/in_attention_input
There is no _raw device for it.
>
>
> Thanks,
> Srinivas
>
> > Fixes: 596ef5cf654b ("iio: hid-sensor-prox: Add support for more
> > channels")
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > ---
> > drivers/iio/light/hid-sensor-prox.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/light/hid-sensor-prox.c
> > b/drivers/iio/light/hid-sensor-prox.c
> > index e8e7b2999b4c..8e5d0ad13a5f 100644
> > --- a/drivers/iio/light/hid-sensor-prox.c
> > +++ b/drivers/iio/light/hid-sensor-prox.c
> > @@ -94,6 +94,7 @@ static int prox_read_raw(struct iio_dev *indio_dev,
> > *val2 = 0;
> > switch (mask) {
> > case IIO_CHAN_INFO_RAW:
> > + case IIO_CHAN_INFO_PROCESSED:
> > if (chan->scan_index >= prox_state->num_channels)
> > return -EINVAL;
> > address = prox_state->channel2usage[chan-
> > >scan_index];
> > @@ -107,8 +108,7 @@ static int prox_read_raw(struct iio_dev
> > *indio_dev,
> >
> > report_id,
> >
> > SENSOR_HUB_SYNC,
> > min < 0);
> > - if (prox_state->channel2usage[chan->scan_index] ==
> > - HID_USAGE_SENSOR_HUMAN_ATTENTION)
> > + if (mask == IIO_CHAN_INFO_PROCESSED)
> > *val *= 100;
> > hid_sensor_power_state(&prox_state-
> > >common_attributes, false);
> > ret_type = IIO_VAL_INT;
> >
> > ---
> > base-commit: decc701f41d07481893fdea942c0ac6b226e84cd
> > change-id: 20241121-fix-processed-ed1a95641e64
> >
> > Best regards,
>
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: hid-sensor-prox: Fix invalid read_raw for attention
2024-11-22 7:46 ` Ricardo Ribalda
@ 2024-11-22 16:31 ` srinivas pandruvada
0 siblings, 0 replies; 4+ messages in thread
From: srinivas pandruvada @ 2024-11-22 16:31 UTC (permalink / raw)
To: Ricardo Ribalda
Cc: Jiri Kosina, Jonathan Cameron, Lars-Peter Clausen,
Jonathan Cameron, linux-input, linux-iio, linux-kernel
On Fri, 2024-11-22 at 08:46 +0100, Ricardo Ribalda wrote:
> On Thu, 21 Nov 2024 at 17:44, srinivas pandruvada
> <srinivas.pandruvada@linux.intel.com> wrote:
> >
> > On Thu, 2024-11-21 at 09:16 +0000, Ricardo Ribalda wrote:
> > > The attention channel is a IIO_CHAN_INFO_PROCESSED, not a
> > > IIO_CHAN_INFO_RAW.
> > >
> > > Modify prox_read_raw() to support it.
> > >
> > What is the sysfs entry to trigger this IIO_CHAN_INFO_PROCESSED
> > read?
> > Don't you have an entry *_raw?
>
> /sys/.../iio:deviceX/in_attention_input
>
> There is no _raw device for it.
>
OK.
> >
> > > Fixes: 596ef5cf654b ("iio: hid-sensor-prox: Add support for more
> > > channels")
> > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > > ---
> > > drivers/iio/light/hid-sensor-prox.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/iio/light/hid-sensor-prox.c
> > > b/drivers/iio/light/hid-sensor-prox.c
> > > index e8e7b2999b4c..8e5d0ad13a5f 100644
> > > --- a/drivers/iio/light/hid-sensor-prox.c
> > > +++ b/drivers/iio/light/hid-sensor-prox.c
> > > @@ -94,6 +94,7 @@ static int prox_read_raw(struct iio_dev
> > > *indio_dev,
> > > *val2 = 0;
> > > switch (mask) {
> > > case IIO_CHAN_INFO_RAW:
> > > + case IIO_CHAN_INFO_PROCESSED:
> > > if (chan->scan_index >= prox_state->num_channels)
> > > return -EINVAL;
> > > address = prox_state->channel2usage[chan-
> > > > scan_index];
> > > @@ -107,8 +108,7 @@ static int prox_read_raw(struct iio_dev
> > > *indio_dev,
> > >
> > > report_id,
> > >
> > > SENSOR_HUB_SYNC,
> > > min <
> > > 0);
> > > - if (prox_state->channel2usage[chan->scan_index] ==
> > > - HID_USAGE_SENSOR_HUMAN_ATTENTION)
> > > + if (mask == IIO_CHAN_INFO_PROCESSED)
Your original change is better. If someone adds a new channel which
also requires IIO_CHAN_INFO_PROCESSED, then they need to change this
line. So I don't think you need this change.
Thanks,
Srinivas
> > > *val *= 100;
> > > hid_sensor_power_state(&prox_state-
> > > > common_attributes, false);
> > > ret_type = IIO_VAL_INT;
> > >
> > > ---
> > > base-commit: decc701f41d07481893fdea942c0ac6b226e84cd
> > > change-id: 20241121-fix-processed-ed1a95641e64
> > >
> > > Best regards,
> >
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-22 16:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-21 9:16 [PATCH] iio: hid-sensor-prox: Fix invalid read_raw for attention Ricardo Ribalda
2024-11-21 16:44 ` srinivas pandruvada
2024-11-22 7:46 ` Ricardo Ribalda
2024-11-22 16:31 ` srinivas pandruvada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).