|
@@ -95,15 +95,15 @@
|
|
#define CONF_NOT_USED 0x03
|
|
#define CONF_NOT_USED 0x03
|
|
#define MEAS_CONF_MASK 0x03
|
|
#define MEAS_CONF_MASK 0x03
|
|
|
|
|
|
-static const int regval_to_counts_per_mg[] = {
|
|
|
|
- 1620,
|
|
|
|
- 1300,
|
|
|
|
- 970,
|
|
|
|
- 780,
|
|
|
|
- 530,
|
|
|
|
- 460,
|
|
|
|
- 390,
|
|
|
|
- 280
|
|
|
|
|
|
+static const char *regval_to_scale[] = {
|
|
|
|
+ "0.0000006173",
|
|
|
|
+ "0.0000007692",
|
|
|
|
+ "0.0000010309",
|
|
|
|
+ "0.0000012821",
|
|
|
|
+ "0.0000018868",
|
|
|
|
+ "0.0000021739",
|
|
|
|
+ "0.0000025641",
|
|
|
|
+ "0.0000035714",
|
|
};
|
|
};
|
|
static const int regval_to_input_field_mg[] = {
|
|
static const int regval_to_input_field_mg[] = {
|
|
700,
|
|
700,
|
|
@@ -326,7 +326,7 @@ static IIO_DEVICE_ATTR(meas_conf,
|
|
* 6 | 50
|
|
* 6 | 50
|
|
* 7 | Not used
|
|
* 7 | Not used
|
|
*/
|
|
*/
|
|
-static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("0.5 1 2 5 10 20 50");
|
|
|
|
|
|
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("0.5 1 2 5 10 20 50");
|
|
|
|
|
|
static s32 hmc5843_set_rate(struct i2c_client *client,
|
|
static s32 hmc5843_set_rate(struct i2c_client *client,
|
|
u8 rate)
|
|
u8 rate)
|
|
@@ -468,17 +468,17 @@ static IIO_DEVICE_ATTR(magn_range,
|
|
set_range,
|
|
set_range,
|
|
HMC5843_CONFIG_REG_B);
|
|
HMC5843_CONFIG_REG_B);
|
|
|
|
|
|
-static ssize_t show_gain(struct device *dev,
|
|
|
|
|
|
+static ssize_t show_scale(struct device *dev,
|
|
struct device_attribute *attr,
|
|
struct device_attribute *attr,
|
|
char *buf)
|
|
char *buf)
|
|
{
|
|
{
|
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
|
struct hmc5843_data *data = indio_dev->dev_data;
|
|
struct hmc5843_data *data = indio_dev->dev_data;
|
|
- return sprintf(buf, "%d\n", regval_to_counts_per_mg[data->range]);
|
|
|
|
|
|
+ return strlen(strcpy(buf, regval_to_scale[data->range]));
|
|
}
|
|
}
|
|
-static IIO_DEVICE_ATTR(magn_gain,
|
|
|
|
|
|
+static IIO_DEVICE_ATTR(magn_scale,
|
|
S_IRUGO,
|
|
S_IRUGO,
|
|
- show_gain,
|
|
|
|
|
|
+ show_scale,
|
|
NULL , 0);
|
|
NULL , 0);
|
|
|
|
|
|
static struct attribute *hmc5843_attributes[] = {
|
|
static struct attribute *hmc5843_attributes[] = {
|
|
@@ -486,11 +486,11 @@ static struct attribute *hmc5843_attributes[] = {
|
|
&iio_dev_attr_operating_mode.dev_attr.attr,
|
|
&iio_dev_attr_operating_mode.dev_attr.attr,
|
|
&iio_dev_attr_sampling_frequency.dev_attr.attr,
|
|
&iio_dev_attr_sampling_frequency.dev_attr.attr,
|
|
&iio_dev_attr_magn_range.dev_attr.attr,
|
|
&iio_dev_attr_magn_range.dev_attr.attr,
|
|
- &iio_dev_attr_magn_gain.dev_attr.attr,
|
|
|
|
|
|
+ &iio_dev_attr_magn_scale.dev_attr.attr,
|
|
&iio_dev_attr_magn_x_raw.dev_attr.attr,
|
|
&iio_dev_attr_magn_x_raw.dev_attr.attr,
|
|
&iio_dev_attr_magn_y_raw.dev_attr.attr,
|
|
&iio_dev_attr_magn_y_raw.dev_attr.attr,
|
|
&iio_dev_attr_magn_z_raw.dev_attr.attr,
|
|
&iio_dev_attr_magn_z_raw.dev_attr.attr,
|
|
- &iio_const_attr_available_sampling_frequency.dev_attr.attr,
|
|
|
|
|
|
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
|
|
NULL
|
|
NULL
|
|
};
|
|
};
|
|
|
|
|