Re: [PATCH v3 01/10] staging:iio:hmc5843: Use SCALE instead of magn_range

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

 



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




[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