Re: [PATCH v2 2/3] iio: light: Add support for AL3000a illuminance sensor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > > +
> > > +static int al3000a_read_raw(struct iio_dev *indio_dev,
> > > +                         struct iio_chan_spec const *chan, int *val,
> > > +                         int *val2, long mask)
> > > +{
> > > +     struct al3000a_data *data = iio_priv(indio_dev);
> > > +     int ret, gain;
> > > +
> > > +     switch (mask) {
> > > +     case IIO_CHAN_INFO_RAW:
> > > +             ret = regmap_read(data->regmap, AL3000A_REG_DATA, &gain);
> > > +             if (ret < 0)
> > > +                     return ret;
> > > +
> > > +             *val = lux_table[gain & AL3000A_GAIN_MASK];  
> >
> > Why did you chosen to do post-processing in the RAW channel instead
> > doing it in INFO_SCALE (same as al3010 does)?
> >  
> 
> From my observation INFO_SCALE will just perform multiplication of RAW
> to SCALE. In this case values which are read are not actual raw values
> of illumination. Next is my assumption (since there is no datasheet),
> but values obtained from register are similar to values from adc
> thermal sensors, they need be converted via reference table to get
> actual data.

Please add a comment somewhere here to say that we don't know the
relationship of these values to illuminance hence providing
_RAW and _SCALE would not be helpful.

> 
> > Except this, LGTM.
> >
> > Documentation and DT patch:
> >
> > Reviewed-by: David Heidelberg <david@xxxxxxx>  
> > > +
> > > +             return IIO_VAL_INT;
> > > +     case IIO_CHAN_INFO_SCALE:
> > > +             *val = 1;
> > > +

Don't do this.  The above lack of known relationship has to be
expressed by not providing the _scale attribute.

> > > +             return IIO_VAL_INT;
> > > +     default:
> > > +             return -EINVAL;
> > > +     }
> > > +}
> > > +
> > > +static const struct iio_info al3000a_info = {
> > > +     .read_raw       = al3000a_read_raw,
> > > +};






[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux