diff mbox series

IIO: hid-sensor-prox: add missing scale attribute

Message ID 20221222120742.232087-1-p.jungkamp@gmx.net
State New
Headers show
Series IIO: hid-sensor-prox: add missing scale attribute | expand

Commit Message

Philipp Jungkamp Dec. 22, 2022, 12:07 p.m. UTC
The hid-sensor-prox returned an empty string on sysfs in_proximity_scale
read. This is due to the the drivers reporting it's scale from an
internal value which is never changed from zero.

Try to query the scale of the HID sensor using hid_sensor_format_scale.

Signed-off-by: Philipp Jungkamp <p.jungkamp@gmx.net>
---
Hello,

While trying to utilize hid_sensor_prox driver I noticed this problem.
Should this be part of the branch created for the other patch series I
have submitted?
See: https://lore.kernel.org/linux-iio/nycvar.YFH.7.76.2212201525010.9000@cbobk.fhfr.pm/T/#u

Regards,
Philipp Jungkamp

 drivers/iio/light/hid-sensor-prox.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.39.0

Comments

Jonathan Cameron Dec. 23, 2022, 2:07 p.m. UTC | #1
On Thu, 22 Dec 2022 13:07:42 +0100
Philipp Jungkamp <p.jungkamp@gmx.net> wrote:

> The hid-sensor-prox returned an empty string on sysfs in_proximity_scale
> read. This is due to the the drivers reporting it's scale from an
> internal value which is never changed from zero.
> 
> Try to query the scale of the HID sensor using hid_sensor_format_scale.
> 
> Signed-off-by: Philipp Jungkamp <p.jungkamp@gmx.net>
> ---
> Hello,
> 
> While trying to utilize hid_sensor_prox driver I noticed this problem.
> Should this be part of the branch created for the other patch series I
> have submitted?
> See: https://lore.kernel.org/linux-iio/nycvar.YFH.7.76.2212201525010.9000@cbobk.fhfr.pm/T/#u

Don't worry about it. I'll pick this up and pull in the hid stuff Jiri
made available once Srinivas and others have had a chance to take a quick look
at it.  Looks correct to me.

Jonathan

> 
> Regards,
> Philipp Jungkamp
> 
>  drivers/iio/light/hid-sensor-prox.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
> index f10fa2abfe72..3322f8e56f41 100644
> --- a/drivers/iio/light/hid-sensor-prox.c
> +++ b/drivers/iio/light/hid-sensor-prox.c
> @@ -222,6 +222,9 @@ static int prox_parse_report(struct platform_device *pdev,
>  	dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index,
>  			st->prox_attr.report_id);
> 
> +	st->scale_precision = hid_sensor_format_scale(usage_id, &st->prox_attr,
> +				&st->scale_pre_decml, &st->scale_post_decml);
> +
>  	return ret;
>  }
> 
> --
> 2.39.0
>
Srinivas Pandruvada Jan. 2, 2023, 4:43 p.m. UTC | #2
On Thu, 2022-12-22 at 13:07 +0100, Philipp Jungkamp wrote:
> The hid-sensor-prox returned an empty string on sysfs
> in_proximity_scale
> read. This is due to the the drivers reporting it's scale from an
> internal value which is never changed from zero.
> 
> Try to query the scale of the HID sensor using
> hid_sensor_format_scale.

By spec there is no unit for this attribute:

"
An application-level or physical collection that identifies
a device that detects human presence (Boolean yes or no).
"

There is no use of calling hid_sensor_format_scale() as there is no
conversion. With the call this is setting scale_pre_decml to 1.

Better to set scale_pre_decml to 1 instead of calling
hid_sensor_format_scale(), which gives wrong impression that we are
converting to some scale.

Thanks,
Srinivas

> 
> Signed-off-by: Philipp Jungkamp <p.jungkamp@gmx.net>
> ---
> Hello,
> 
> While trying to utilize hid_sensor_prox driver I noticed this
> problem.
> Should this be part of the branch created for the other patch series
> I
> have submitted?
> See:
> https://lore.kernel.org/linux-iio/nycvar.YFH.7.76.2212201525010.9000@cbobk.fhfr.pm/T/#u
> 
> Regards,
> Philipp Jungkamp
> 
>  drivers/iio/light/hid-sensor-prox.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/light/hid-sensor-prox.c
> b/drivers/iio/light/hid-sensor-prox.c
> index f10fa2abfe72..3322f8e56f41 100644
> --- a/drivers/iio/light/hid-sensor-prox.c
> +++ b/drivers/iio/light/hid-sensor-prox.c
> @@ -222,6 +222,9 @@ static int prox_parse_report(struct
> platform_device *pdev,
>         dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index,
>                         st->prox_attr.report_id);
> 
> +       st->scale_precision = hid_sensor_format_scale(usage_id, &st-
> >prox_attr,
> +                               &st->scale_pre_decml, &st-
> >scale_post_decml);
> +
>         return ret;
>  }
> 
> --
> 2.39.0
>
diff mbox series

Patch

diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index f10fa2abfe72..3322f8e56f41 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -222,6 +222,9 @@  static int prox_parse_report(struct platform_device *pdev,
 	dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index,
 			st->prox_attr.report_id);

+	st->scale_precision = hid_sensor_format_scale(usage_id, &st->prox_attr,
+				&st->scale_pre_decml, &st->scale_post_decml);
+
 	return ret;
 }