diff options
Diffstat (limited to 'drivers/iio/temperature')
-rw-r--r-- | drivers/iio/temperature/mlx90614.c | 21 | ||||
-rw-r--r-- | drivers/iio/temperature/tmp006.c | 5 |
2 files changed, 16 insertions, 10 deletions
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index 7a2b639ea..5d033a5af 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -65,6 +65,13 @@ #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */ +/* Magic constants */ +#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the Kelvin offset */ +#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */ +#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */ +#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */ +#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */ + struct mlx90614_data { struct i2c_client *client; struct mutex lock; /* for EEPROM access only */ @@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev, *val = ret; return IIO_VAL_INT; case IIO_CHAN_INFO_OFFSET: - *val = -13657; - *val2 = 500000; + *val = MLX90614_CONST_OFFSET_DEC; + *val2 = MLX90614_CONST_OFFSET_REM; return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_SCALE: - *val = 20; + *val = MLX90614_CONST_SCALE; return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */ mlx90614_power_get(data, false); @@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev, if (ret < 0) return ret; - if (ret == 65535) { + if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) { *val = 1; *val2 = 0; } else { *val = 0; - *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */ + *val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION; } return IIO_VAL_INT_PLUS_NANO; default: @@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */ if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0)) return -EINVAL; - val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */ + val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX + + val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION; mlx90614_power_get(data, false); mutex_lock(&data->lock); @@ -551,7 +559,6 @@ static const struct dev_pm_ops mlx90614_pm_ops = { static struct i2c_driver mlx90614_driver = { .driver = { .name = "mlx90614", - .owner = THIS_MODULE, .pm = &mlx90614_pm_ops, }, .probe = mlx90614_probe, diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c index 8f21f32f9..e78c1069a 100644 --- a/drivers/iio/temperature/tmp006.c +++ b/drivers/iio/temperature/tmp006.c @@ -36,9 +36,9 @@ #define TMP006_CONFIG_DRDY_EN BIT(8) #define TMP006_CONFIG_DRDY BIT(7) -#define TMP006_CONFIG_MOD_MASK 0x7000 +#define TMP006_CONFIG_MOD_MASK GENMASK(14, 12) -#define TMP006_CONFIG_CR_MASK 0x0e00 +#define TMP006_CONFIG_CR_MASK GENMASK(11, 9) #define TMP006_CONFIG_CR_SHIFT 9 #define TMP006_MANUFACTURER_MAGIC 0x5449 @@ -280,7 +280,6 @@ static struct i2c_driver tmp006_driver = { .driver = { .name = "tmp006", .pm = &tmp006_pm_ops, - .owner = THIS_MODULE, }, .probe = tmp006_probe, .remove = tmp006_remove, |