All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute.
@ 2021-09-28 16:19 Andriy Tryshnivskyy
  2021-09-28 16:19 ` [PATCH v3 1/1] " Andriy Tryshnivskyy
  2021-09-30 16:40 ` [PATCH v3 0/1] " Jonathan Cameron
  0 siblings, 2 replies; 7+ messages in thread
From: Andriy Tryshnivskyy @ 2021-09-28 16:19 UTC (permalink / raw)
  To: jbhayana, jic23
  Cc: lars, linux-iio, linux-kernel, Vasyl.Vavrychuk, andriy.tryshnivskyy

This patch implements reading "raw" attribute.

The patch is based on v5.14.

Comparing to the previous version it has:
* adaptation for changes in structure scmi_iio_priv (no member named 'handle')

Any comments are very welcome.

Thanks,
Andriy.

Andriy Tryshnivskyy (1):
  iio/scmi: Add reading "raw" attribute.

 drivers/iio/common/scmi_sensors/scmi_iio.c | 45 +++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)


base-commit: 7d2a07b769330c34b4deabeed939325c77a7ec2f
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/1] iio/scmi: Add reading "raw" attribute.
  2021-09-28 16:19 [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute Andriy Tryshnivskyy
@ 2021-09-28 16:19 ` Andriy Tryshnivskyy
  2021-09-30 16:40 ` [PATCH v3 0/1] " Jonathan Cameron
  1 sibling, 0 replies; 7+ messages in thread
From: Andriy Tryshnivskyy @ 2021-09-28 16:19 UTC (permalink / raw)
  To: jbhayana, jic23
  Cc: lars, linux-iio, linux-kernel, Vasyl.Vavrychuk, andriy.tryshnivskyy

Add IIO_CHAN_INFO_RAW to the mask and implement corresponding
reading "raw" attribute in scmi_iio_read_raw.

Signed-off-by: Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>
---
 drivers/iio/common/scmi_sensors/scmi_iio.c | 45 +++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
index 7cf2bf282cef..7ea52186ad50 100644
--- a/drivers/iio/common/scmi_sensors/scmi_iio.c
+++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
@@ -286,6 +286,9 @@ static int scmi_iio_read_raw(struct iio_dev *iio_dev,
 	struct scmi_iio_priv *sensor = iio_priv(iio_dev);
 	s8 scale;
 	int ret;
+	int err;
+	u32 sensor_config;
+	struct scmi_sensor_reading readings[SCMI_IIO_NUM_OF_AXIS];
 
 	switch (mask) {
 	case IIO_CHAN_INFO_SCALE:
@@ -300,6 +303,45 @@ static int scmi_iio_read_raw(struct iio_dev *iio_dev,
 	case IIO_CHAN_INFO_SAMP_FREQ:
 		ret = scmi_iio_get_odr_val(iio_dev, val, val2);
 		return ret ? ret : IIO_VAL_INT_PLUS_MICRO;
+	case IIO_CHAN_INFO_RAW:
+		sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
+					   SCMI_SENS_CFG_SENSOR_ENABLE);
+		err = sensor->sensor_ops->config_set(
+			sensor->ph, sensor->sensor_info->id, sensor_config);
+		if (err) {
+			dev_err(&iio_dev->dev,
+				"Error in enabling sensor %s err %d",
+				sensor->sensor_info->name, err);
+			return err;
+		}
+
+		err = sensor->sensor_ops->reading_get_timestamped(
+			sensor->ph, sensor->sensor_info->id,
+			sensor->sensor_info->num_axis, readings);
+		if (err) {
+			dev_err(&iio_dev->dev,
+				"Error in reading raw attribute for sensor %s err %d",
+				sensor->sensor_info->name, err);
+			return err;
+		}
+
+		sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
+					   SCMI_SENS_CFG_SENSOR_DISABLE);
+		err = sensor->sensor_ops->config_set(
+			sensor->ph, sensor->sensor_info->id, sensor_config);
+		if (err) {
+			dev_err(&iio_dev->dev,
+				"Error in enabling sensor %s err %d",
+				sensor->sensor_info->name, err);
+			return err;
+		}
+		/* Check if raw value fits 32 bits */
+		if (readings[ch->scan_index].value < INT_MIN ||
+		    readings[ch->scan_index].value > INT_MAX)
+			return -ERANGE;
+		/* Use 32-bit value, since practically there is no need in 64 bits */
+		*val = (int)readings[ch->scan_index].value;
+		return IIO_VAL_INT;
 	default:
 		return -EINVAL;
 	}
@@ -381,7 +423,8 @@ static void scmi_iio_set_data_channel(struct iio_chan_spec *iio_chan,
 	iio_chan->type = type;
 	iio_chan->modified = 1;
 	iio_chan->channel2 = mod;
-	iio_chan->info_mask_separate = BIT(IIO_CHAN_INFO_SCALE);
+	iio_chan->info_mask_separate =
+		BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_RAW);
 	iio_chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ);
 	iio_chan->info_mask_shared_by_type_available =
 		BIT(IIO_CHAN_INFO_SAMP_FREQ);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute.
  2021-09-28 16:19 [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute Andriy Tryshnivskyy
  2021-09-28 16:19 ` [PATCH v3 1/1] " Andriy Tryshnivskyy
@ 2021-09-30 16:40 ` Jonathan Cameron
  2021-10-04 23:51   ` Jyoti Bhayana
  1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2021-09-30 16:40 UTC (permalink / raw)
  To: Andriy Tryshnivskyy
  Cc: jbhayana, lars, linux-iio, linux-kernel, Vasyl.Vavrychuk

On Tue, 28 Sep 2021 19:19:56 +0300
Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com> wrote:

> This patch implements reading "raw" attribute.
> 
> The patch is based on v5.14.
> 
> Comparing to the previous version it has:
> * adaptation for changes in structure scmi_iio_priv (no member named 'handle')
> 
Ah.. If you have a case like this where you send out a new version because you've
found an issue yourself, please also reply to the earlier version to say what the
problem was.  That way no one reviews the wrong version :)

Thanks,

Jonathan

> Any comments are very welcome.
> 
> Thanks,
> Andriy.
> 
> Andriy Tryshnivskyy (1):
>   iio/scmi: Add reading "raw" attribute.
> 
>  drivers/iio/common/scmi_sensors/scmi_iio.c | 45 +++++++++++++++++++++-
>  1 file changed, 44 insertions(+), 1 deletion(-)
> 
> 
> base-commit: 7d2a07b769330c34b4deabeed939325c77a7ec2f


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute.
  2021-09-30 16:40 ` [PATCH v3 0/1] " Jonathan Cameron
@ 2021-10-04 23:51   ` Jyoti Bhayana
  2021-10-05 12:51     ` Vasyl Vavrychuk
  0 siblings, 1 reply; 7+ messages in thread
From: Jyoti Bhayana @ 2021-10-04 23:51 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Andriy Tryshnivskyy, Lars-Peter Clausen, linux-iio, linux-kernel,
	Vasyl.Vavrychuk

Hi Andriy,

Please find my feedback below:

> @@ -286,6 +286,9 @@ static int scmi_iio_read_raw(struct iio_dev *iio_dev,
>         struct scmi_iio_priv *sensor = iio_priv(iio_dev);
>         s8 scale;
>         int ret;
> +       int err;


Why do we have two variables with a similar purpose of saving the
return value? Can't ret be used in this case instead of adding a new
one?


In the code below, why is the logic of enabling and disabling the
sensor in this function?  Generally the function to read the sensor
value is just used for the code to read the sensor values ? and not
enable/disable the sensor

>    case IIO_CHAN_INFO_RAW:
> +               sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
> +                                          SCMI_SENS_CFG_SENSOR_ENABLE);
> +               err = sensor->sensor_ops->config_set(
> +                       sensor->ph, sensor->sensor_info->id, sensor_config);
> +               if (err) {
> +                       dev_err(&iio_dev->dev,
> +                               "Error in enabling sensor %s err %d",
> +                               sensor->sensor_info->name, err);
> +                       return err;
> +               }
> +
> +               err = sensor->sensor_ops->reading_get_timestamped(
> +                       sensor->ph, sensor->sensor_info->id,
> +                       sensor->sensor_info->num_axis, readings);
> +               if (err) {
> +                       dev_err(&iio_dev->dev,
> +                               "Error in reading raw attribute for sensor %s err %d",
> +                               sensor->sensor_info->name, err);
> +                       return err;
> +               }
> +
> +               sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
> +                                          SCMI_SENS_CFG_SENSOR_DISABLE);
> +               err = sensor->sensor_ops->config_set(
> +                       sensor->ph, sensor->sensor_info->id, sensor_config);
> +               if (err) {
> +                       dev_err(&iio_dev->dev,
> +                               "Error in enabling sensor %s err %d",
> +                               sensor->sensor_info->name, err);
> +                       return err;
> +               }
> +               /* Check if raw value fits 32 bits */
> +               if (readings[ch->scan_index].value < INT_MIN ||
> +                   readings[ch->scan_index].value > INT_MAX)
> +                       return -ERANGE;
> +               /* Use 32-bit value, since practically there is no need in 64 bits */
> +               *val = (int)readings[ch->scan_index].value;
>
> +               return IIO_VAL_INT;


On Thu, Sep 30, 2021 at 9:36 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Tue, 28 Sep 2021 19:19:56 +0300
> Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com> wrote:
>
> > This patch implements reading "raw" attribute.
> >
> > The patch is based on v5.14.
> >
> > Comparing to the previous version it has:
> > * adaptation for changes in structure scmi_iio_priv (no member named 'handle')
> >
> Ah.. If you have a case like this where you send out a new version because you've
> found an issue yourself, please also reply to the earlier version to say what the
> problem was.  That way no one reviews the wrong version :)
>
> Thanks,
>
> Jonathan
>
> > Any comments are very welcome.
> >
> > Thanks,
> > Andriy.
> >
> > Andriy Tryshnivskyy (1):
> >   iio/scmi: Add reading "raw" attribute.
> >
> >  drivers/iio/common/scmi_sensors/scmi_iio.c | 45 +++++++++++++++++++++-
> >  1 file changed, 44 insertions(+), 1 deletion(-)
> >
> >
> > base-commit: 7d2a07b769330c34b4deabeed939325c77a7ec2f
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute.
  2021-10-04 23:51   ` Jyoti Bhayana
@ 2021-10-05 12:51     ` Vasyl Vavrychuk
  2021-10-06  0:16       ` Jyoti Bhayana
  0 siblings, 1 reply; 7+ messages in thread
From: Vasyl Vavrychuk @ 2021-10-05 12:51 UTC (permalink / raw)
  To: Jyoti Bhayana
  Cc: Lars-Peter Clausen, linux-iio, linux-kernel, Jonathan Cameron,
	Andriy Tryshnivskyy

Hi, Jyoti,

> In the code below, why is the logic of enabling and disabling the
> sensor in this function?  Generally the function to read the sensor
> value is just used for the code to read the sensor values ? and not
> enable/disable the sensor

But to read sensor value we have to enable it first. Other way to enable 
sensor we found is, for example:

   echo 1 > /sys/bus/iio/devices/.../scan_elements/in_anglvel_x_en

But, this command is related to IIO buffers use.

Other sensors drivers enable/disable sensor in read raw too, for 
example, drivers/iio/accel/kxcjk-1013.c has:

   case IIO_CHAN_INFO_RAW:
           mutex_lock(&data->mutex);
           if (iio_buffer_enabled(indio_dev))
                   ret = -EBUSY;
           else {
                   ret = kxcjk1013_set_power_state(data, true);
                   ... reading ...
                   ret = kxcjk1013_set_power_state(data, false);
           }
           mutex_unlock(&data->mutex);

But, after looking on this code I have some questions:

1. Should we block reading raw attribute and IIO buffer enabled, for for 
SCMI sensor it can coexist?
2. Should we wrap reading raw attribute implementation in iio_dev->mlock 
mutex?

>>     case IIO_CHAN_INFO_RAW:
>> +               sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
>> +                                          SCMI_SENS_CFG_SENSOR_ENABLE);
>> +               err = sensor->sensor_ops->config_set(
>> +                       sensor->ph, sensor->sensor_info->id, sensor_config);
>> +               if (err) {
>> +                       dev_err(&iio_dev->dev,
>> +                               "Error in enabling sensor %s err %d",
>> +                               sensor->sensor_info->name, err);
>> +                       return err;
>> +               }
>> +
>> +               err = sensor->sensor_ops->reading_get_timestamped(
>> +                       sensor->ph, sensor->sensor_info->id,
>> +                       sensor->sensor_info->num_axis, readings);
>> +               if (err) {
>> +                       dev_err(&iio_dev->dev,
>> +                               "Error in reading raw attribute for sensor %s err %d",
>> +                               sensor->sensor_info->name, err);
>> +                       return err;
>> +               }
>> +
>> +               sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
>> +                                          SCMI_SENS_CFG_SENSOR_DISABLE);
>> +               err = sensor->sensor_ops->config_set(
>> +                       sensor->ph, sensor->sensor_info->id, sensor_config);
>> +               if (err) {
>> +                       dev_err(&iio_dev->dev,
>> +                               "Error in enabling sensor %s err %d",
>> +                               sensor->sensor_info->name, err);
>> +                       return err;
>> +               }
>> +               /* Check if raw value fits 32 bits */
>> +               if (readings[ch->scan_index].value < INT_MIN ||
>> +                   readings[ch->scan_index].value > INT_MAX)
>> +                       return -ERANGE;
>> +               /* Use 32-bit value, since practically there is no need in 64 bits */
>> +               *val = (int)readings[ch->scan_index].value;
>>
>> +               return IIO_VAL_INT;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute.
  2021-10-05 12:51     ` Vasyl Vavrychuk
@ 2021-10-06  0:16       ` Jyoti Bhayana
  2021-10-08 11:32         ` Andriy Tryshnivskyy
  0 siblings, 1 reply; 7+ messages in thread
From: Jyoti Bhayana @ 2021-10-06  0:16 UTC (permalink / raw)
  To: Vasyl Vavrychuk
  Cc: Lars-Peter Clausen, linux-iio, linux-kernel, Jonathan Cameron,
	Andriy Tryshnivskyy

Hi Vasyl,

Regarding below question, yes reading raw attribute should be blocked
if buffer is enabled for that sensor.

> 1. Should we block reading raw attribute and IIO buffer enabled, for for
> SCMI sensor it can coexist?


PLease see  https://elixir.bootlin.com/linux/latest/source/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c#L667
as well. It has

case IIO_CHAN_INFO_RAW:
ret = iio_device_claim_direct_mode(indio_dev);
if (ret)
return ret;
mutex_lock(&st->lock);
ret = inv_mpu6050_read_channel_data(indio_dev, chan, val);
mutex_unlock(&st->lock);
iio_device_release_direct_mode(indio_dev);
return ret;

Regarding the question below, the answer is yes.

> 2. Should we wrap reading raw attribute implementation in iio_dev->mlock
> mutex?


Thanks, Jyoti





On Tue, Oct 5, 2021 at 5:52 AM Vasyl Vavrychuk
<vasyl.vavrychuk@opensynergy.com> wrote:
>
> Hi, Jyoti,
>
> > In the code below, why is the logic of enabling and disabling the
> > sensor in this function?  Generally the function to read the sensor
> > value is just used for the code to read the sensor values ? and not
> > enable/disable the sensor
>
> But to read sensor value we have to enable it first. Other way to enable
> sensor we found is, for example:
>
>    echo 1 > /sys/bus/iio/devices/.../scan_elements/in_anglvel_x_en
>
> But, this command is related to IIO buffers use.
>
> Other sensors drivers enable/disable sensor in read raw too, for
> example, drivers/iio/accel/kxcjk-1013.c has:
>
>    case IIO_CHAN_INFO_RAW:
>            mutex_lock(&data->mutex);
>            if (iio_buffer_enabled(indio_dev))
>                    ret = -EBUSY;
>            else {
>                    ret = kxcjk1013_set_power_state(data, true);
>                    ... reading ...
>                    ret = kxcjk1013_set_power_state(data, false);
>            }
>            mutex_unlock(&data->mutex);
>
> But, after looking on this code I have some questions:
>
> 1. Should we block reading raw attribute and IIO buffer enabled, for for
> SCMI sensor it can coexist?
> 2. Should we wrap reading raw attribute implementation in iio_dev->mlock
> mutex?
>
> >>     case IIO_CHAN_INFO_RAW:
> >> +               sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
> >> +                                          SCMI_SENS_CFG_SENSOR_ENABLE);
> >> +               err = sensor->sensor_ops->config_set(
> >> +                       sensor->ph, sensor->sensor_info->id, sensor_config);
> >> +               if (err) {
> >> +                       dev_err(&iio_dev->dev,
> >> +                               "Error in enabling sensor %s err %d",
> >> +                               sensor->sensor_info->name, err);
> >> +                       return err;
> >> +               }
> >> +
> >> +               err = sensor->sensor_ops->reading_get_timestamped(
> >> +                       sensor->ph, sensor->sensor_info->id,
> >> +                       sensor->sensor_info->num_axis, readings);
> >> +               if (err) {
> >> +                       dev_err(&iio_dev->dev,
> >> +                               "Error in reading raw attribute for sensor %s err %d",
> >> +                               sensor->sensor_info->name, err);
> >> +                       return err;
> >> +               }
> >> +
> >> +               sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
> >> +                                          SCMI_SENS_CFG_SENSOR_DISABLE);
> >> +               err = sensor->sensor_ops->config_set(
> >> +                       sensor->ph, sensor->sensor_info->id, sensor_config);
> >> +               if (err) {
> >> +                       dev_err(&iio_dev->dev,
> >> +                               "Error in enabling sensor %s err %d",
> >> +                               sensor->sensor_info->name, err);
> >> +                       return err;
> >> +               }
> >> +               /* Check if raw value fits 32 bits */
> >> +               if (readings[ch->scan_index].value < INT_MIN ||
> >> +                   readings[ch->scan_index].value > INT_MAX)
> >> +                       return -ERANGE;
> >> +               /* Use 32-bit value, since practically there is no need in 64 bits */
> >> +               *val = (int)readings[ch->scan_index].value;
> >>
> >> +               return IIO_VAL_INT;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute.
  2021-10-06  0:16       ` Jyoti Bhayana
@ 2021-10-08 11:32         ` Andriy Tryshnivskyy
  0 siblings, 0 replies; 7+ messages in thread
From: Andriy Tryshnivskyy @ 2021-10-08 11:32 UTC (permalink / raw)
  To: Jyoti Bhayana, Vasyl Vavrychuk
  Cc: Lars-Peter Clausen, linux-iio, linux-kernel, Jonathan Cameron

Hi Jyoti and Vasyl,

Thanks for your review.
I will provide new patch version soon.

Thanks,
Andriy

On 06.10.21 03:16, Jyoti Bhayana wrote:

> CAUTION: This email originated from outside of the organization.
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
>
> Hi Vasyl,
>
> Regarding below question, yes reading raw attribute should be blocked
> if buffer is enabled for that sensor.
>
>> 1. Should we block reading raw attribute and IIO buffer enabled, for for
>> SCMI sensor it can coexist?
>
> PLease see  https://elixir.bootlin.com/linux/latest/source/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c#L667
> as well. It has
>
> case IIO_CHAN_INFO_RAW:
> ret = iio_device_claim_direct_mode(indio_dev);
> if (ret)
> return ret;
> mutex_lock(&st->lock);
> ret = inv_mpu6050_read_channel_data(indio_dev, chan, val);
> mutex_unlock(&st->lock);
> iio_device_release_direct_mode(indio_dev);
> return ret;
>
> Regarding the question below, the answer is yes.
>
>> 2. Should we wrap reading raw attribute implementation in iio_dev->mlock
>> mutex?
>
> Thanks, Jyoti
>
>
>
>
>
> On Tue, Oct 5, 2021 at 5:52 AM Vasyl Vavrychuk
> <vasyl.vavrychuk@opensynergy.com> wrote:
>> Hi, Jyoti,
>>
>>> In the code below, why is the logic of enabling and disabling the
>>> sensor in this function?  Generally the function to read the sensor
>>> value is just used for the code to read the sensor values ? and not
>>> enable/disable the sensor
>> But to read sensor value we have to enable it first. Other way to enable
>> sensor we found is, for example:
>>
>>     echo 1 > /sys/bus/iio/devices/.../scan_elements/in_anglvel_x_en
>>
>> But, this command is related to IIO buffers use.
>>
>> Other sensors drivers enable/disable sensor in read raw too, for
>> example, drivers/iio/accel/kxcjk-1013.c has:
>>
>>     case IIO_CHAN_INFO_RAW:
>>             mutex_lock(&data->mutex);
>>             if (iio_buffer_enabled(indio_dev))
>>                     ret = -EBUSY;
>>             else {
>>                     ret = kxcjk1013_set_power_state(data, true);
>>                     ... reading ...
>>                     ret = kxcjk1013_set_power_state(data, false);
>>             }
>>             mutex_unlock(&data->mutex);
>>
>> But, after looking on this code I have some questions:
>>
>> 1. Should we block reading raw attribute and IIO buffer enabled, for for
>> SCMI sensor it can coexist?
>> 2. Should we wrap reading raw attribute implementation in iio_dev->mlock
>> mutex?
>>
>>>>      case IIO_CHAN_INFO_RAW:
>>>> +               sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
>>>> +                                          SCMI_SENS_CFG_SENSOR_ENABLE);
>>>> +               err = sensor->sensor_ops->config_set(
>>>> +                       sensor->ph, sensor->sensor_info->id, sensor_config);
>>>> +               if (err) {
>>>> +                       dev_err(&iio_dev->dev,
>>>> +                               "Error in enabling sensor %s err %d",
>>>> +                               sensor->sensor_info->name, err);
>>>> +                       return err;
>>>> +               }
>>>> +
>>>> +               err = sensor->sensor_ops->reading_get_timestamped(
>>>> +                       sensor->ph, sensor->sensor_info->id,
>>>> +                       sensor->sensor_info->num_axis, readings);
>>>> +               if (err) {
>>>> +                       dev_err(&iio_dev->dev,
>>>> +                               "Error in reading raw attribute for sensor %s err %d",
>>>> +                               sensor->sensor_info->name, err);
>>>> +                       return err;
>>>> +               }
>>>> +
>>>> +               sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
>>>> +                                          SCMI_SENS_CFG_SENSOR_DISABLE);
>>>> +               err = sensor->sensor_ops->config_set(
>>>> +                       sensor->ph, sensor->sensor_info->id, sensor_config);
>>>> +               if (err) {
>>>> +                       dev_err(&iio_dev->dev,
>>>> +                               "Error in enabling sensor %s err %d",
>>>> +                               sensor->sensor_info->name, err);
>>>> +                       return err;
>>>> +               }
>>>> +               /* Check if raw value fits 32 bits */
>>>> +               if (readings[ch->scan_index].value < INT_MIN ||
>>>> +                   readings[ch->scan_index].value > INT_MAX)
>>>> +                       return -ERANGE;
>>>> +               /* Use 32-bit value, since practically there is no need in 64 bits */
>>>> +               *val = (int)readings[ch->scan_index].value;
>>>>
>>>> +               return IIO_VAL_INT;

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-08 11:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 16:19 [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute Andriy Tryshnivskyy
2021-09-28 16:19 ` [PATCH v3 1/1] " Andriy Tryshnivskyy
2021-09-30 16:40 ` [PATCH v3 0/1] " Jonathan Cameron
2021-10-04 23:51   ` Jyoti Bhayana
2021-10-05 12:51     ` Vasyl Vavrychuk
2021-10-06  0:16       ` Jyoti Bhayana
2021-10-08 11:32         ` Andriy Tryshnivskyy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.