Re: [PATCH v5 4/4] iio: accel: adxl345: add sampling frequency support

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

 



2018年7月5日(木) 7:06 Andy Shevchenko <andy.shevchenko@xxxxxxxxx>:
>
> On Sat, Jun 30, 2018 at 7:32 PM, Akinobu Mita <akinobu.mita@xxxxxxxxx> wrote:
> > The ADXL345 provides selectable output data rate.  This adds the iio
> > channel information for the sampling frequency with that feature.
>
> > +       case IIO_CHAN_INFO_SAMP_FREQ:
> > +               n = div_s64(val * NHZ_PER_HZ + val2, ADXL345_BASE_RATE_NANO_HZ);
>
> > +               n = ilog2(max_t(s64, n, 1));
>
> (1)
>
> > +
> > +               return regmap_update_bits(data->regmap, ADXL345_REG_BW_RATE,
> > +                                         ADXL345_BW_RATE,
>
> > +                                         min_t(int, n, ADXL345_BW_RATE));
>
> (2)
>
> Yes, looks pretty much good!
> Though, bit manipulations would be sligtly shorter
>
> Instead of (1) and (2) just do
>
> clamp_t(ilog2(n), 0, ..._RATE)

Sounds good.  I'll use clamp_val() instead of clamp_t().

        n = clamp_val(ilog2(n), 0, ADXL345_BW_RATE);
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux