Re: [PATCH v3 0/1] iio/scmi: Add reading "raw" attribute.

From: Jyoti Bhayana
Date: Mon Oct 04 2021 - 19:51:16 EST


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@xxxxxxxxxx> wrote:
>
> On Tue, 28 Sep 2021 19:19:56 +0300
> Andriy Tryshnivskyy <andriy.tryshnivskyy@xxxxxxxxxxxxxxx> 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
>