Re: [PATCH v2 2/5] staging:iio:hmc5843: Split hmc5843.c to multiple files
From: Dan Carpenter
Date: Tue Jul 08 2014 - 04:24:24 EST
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-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/