Re: [PATCH v2 2/5] staging:iio:hmc5843: Split hmc5843.c to multiple files

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

 



When you compare the old and new versions of hmc5843_read_raw() then it
appears there is a bug fix or something which hasn't been documentented
in the changelog.

> -static int hmc5843_read_raw(struct iio_dev *indio_dev,
> -			    struct iio_chan_spec const *chan,
> -			    int *val, int *val2, long mask)
> -{
> -	struct hmc5843_data *data = iio_priv(indio_dev);
> -	int rval;
> -	int ret;
> -
> -	switch (mask) {
> -	case IIO_CHAN_INFO_RAW:
> -		return hmc5843_read_measurement(data, chan->scan_index, val);
> -	case IIO_CHAN_INFO_SCALE:
> -		ret = regmap_read(data->regmap, HMC5843_CONFIG_REG_B, &rval);
> -		if (ret < 0)
> -			return ret;
> -		*val = 0;
> -		*val2 = data->variant->regval_to_nanoscale[rval >> HMC5843_RANGE_GAIN_OFFSET];
> -		return IIO_VAL_INT_PLUS_NANO;
> -	case IIO_CHAN_INFO_SAMP_FREQ:
> -		ret = regmap_read(data->regmap, HMC5843_CONFIG_REG_A, &rval);
> -		if (ret < 0)
> -			return ret;
> -		rval &= HMC5843_RATE_MASK;
                ^^^^^^^^^^^^^^^^^^^^^^^^^
HMC5843_RATE_MASK is 0x1c.

> -		*val = data->variant->regval_to_samp_freq[rval][0];
> -		*val2 = data->variant->regval_to_samp_freq[rval][1];
> -		return IIO_VAL_INT_PLUS_MICRO;
> -	}
> -	return -EINVAL;
> -}

> +static int hmc5843_read_raw(struct iio_dev *indio_dev,
> +			    struct iio_chan_spec const *chan,
> +			    int *val, int *val2, long mask)
> +{
> +	struct hmc5843_data *data = iio_priv(indio_dev);
> +	int rval;
> +	int ret;
> +
> +	switch (mask) {
> +	case IIO_CHAN_INFO_RAW:
> +		return hmc5843_read_measurement(data, chan->scan_index, val);
> +	case IIO_CHAN_INFO_SCALE:
> +		ret = regmap_read(data->regmap, HMC5843_CONFIG_REG_B, &rval);
> +		if (ret < 0)
> +			return ret;
> +		rval >>= HMC5843_RANGE_GAIN_OFFSET;
> +		*val = 0;
> +		*val2 = data->variant->regval_to_nanoscale[rval];
> +		return IIO_VAL_INT_PLUS_NANO;
> +	case IIO_CHAN_INFO_SAMP_FREQ:
> +		ret = regmap_read(data->regmap, HMC5843_CONFIG_REG_A, &rval);
> +		if (ret < 0)
> +			return ret;
> +		rval >>= HMC5843_RATE_OFFSET;
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
HMC5843_RATE_OFFSET is 0x02.

> +		*val = data->variant->regval_to_samp_freq[rval][0];
> +		*val2 = data->variant->regval_to_samp_freq[rval][1];
> +		return IIO_VAL_INT_PLUS_MICRO;
> +	}
> +	return -EINVAL;
> +}

Ideally this patch would be a straight move and no code changes.

regards,
dan carpenter
--
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