On 10/14/13 22:34, Peter Meerwald wrote: > v2: > * use SCALE instead of CALIBSCALE to control the range/gain > of measurements > Only a couple of tiny little comments. The function *_check_scale does rather more than checking the scale is valid. Perhaps the name could reflect that? Also, would it make more sense to move the shift into that function rather than having it directly afterwards? (I don't really mind about this though!) > Signed-off-by: Peter Meerwald <pmeerw@xxxxxxxxxx> Looking very nice. ... hmc5843_get_scale_index? or with the shift already applied hmc5843_get_scale_regval > +static int hmc5843_check_scale(struct hmc5843_data *data, int val, int val2) > +{ > + int i; > > - if (range > HMC5843_RANGE_GAIN_MAX) { > - count = -EINVAL; > - goto exit; > - } > + if (val != 0) > + return -EINVAL; > > - data->range = range; > - range = range << HMC5843_RANGE_GAIN_OFFSET; > - if (i2c_smbus_write_byte_data(data->client, this_attr->address, range)) > - count = -EINVAL; > + for (i = 0; i < HMC5843_RANGE_GAINS; i++) > + if (val2 == data->variant->regval_to_nanoscale[i]) > + return i; > > -exit: > - mutex_unlock(&data->lock); > - return count; > + return -EINVAL; > } ... > -- 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