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) -- With Best Regards, Andy Shevchenko -- 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