iio: temperature: mlx90632: Interface to change object ambient temperature
Subsystems (2)
Crt Mori
maintainerPATCH v2 1/1 iio: temperature: mlx90632: Interface to change object ambient temperature
Since object temperature might be different than the sensor temperature the infrared sensors should provide an interface to inject ambient temperature. This was in past done via write to ambient temperature interface (in_temp_ambient_raw), but I think most people did not know about it. This solution introduces a new iio type of the CALIBAMBIENT which is hopefully more descriptive and more explicit about the purpose and capabilities of the sensors.
--- drivers/iio/industrialio-core.c | 1 + drivers/iio/temperature/mlx90632.c | 8 +++++++- include/linux/iio/types.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/iio/industrialio-core.c +1 -0
@@ -165,6 +165,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity", [IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio", [IIO_CHAN_INFO_THERMOCOUPLE_TYPE] = "thermocouple_type", + [IIO_CHAN_INFO_CALIBAMBIENT] = "calibambient", };#if defined(CONFIG_DEBUG_FS )
drivers/iio/temperature/mlx90632.c +7 -1
@@ -761,6 +761,9 @@ static int mlx90632_read_raw(struct iio_dev *indio_dev, *val2 = data->emissivity *1000 ; }return IIO_VAL_INT_PLUS_MICRO ; +case IIO_CHAN_INFO_CALIBAMBIENT : + *val = data->object_ambient_temperature; +return IIO_VAL_INT ;default :return -EINVAL ;
@@ -781,6 +784,9 @@ static int mlx90632_write_raw(struct iio_dev *indio_dev,return -EINVAL ; data->emissivity = val *1000 + val2 /1000 ;return 0 ; +case IIO_CHAN_INFO_CALIBAMBIENT : + data->object_ambient_temperature = val; +return 0 ;default :return -EINVAL ; }
@@ -798,7 +804,7 @@ static const struct iio_chan_spec mlx90632_channels[] = { .modified = 1, .channel2 = IIO_MOD_TEMP_OBJECT, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | - BIT(IIO_CHAN_INFO_CALIBEMISSIVITY), + BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) | BIT(IIO_CHAN_INFO_CALIBAMBIENT), }, };
include/linux/iio/types.h +1 -0
@@ -59,6 +59,7 @@ enum iio_chan_info_enum {IIO_CHAN_INFO_CALIBEMISSIVITY ,IIO_CHAN_INFO_OVERSAMPLING_RATIO ,IIO_CHAN_INFO_THERMOCOUPLE_TYPE , + IIO_CHAN_INFO_CALIBAMBIENT, };#endif /* _IIO_TYPES_H_ */
Signature · 1 line
2.25.1
Quoted 8 lines · Crt Mori
Since object temperature might be different than the sensor temperature the infrared sensors should provide an interface to inject ambient temperature. This was in past done via write to ambient temperature interface (
in_temp_ambient_raw), but I think most people did not know about it. This solution introduces a new iio type of the CALIBAMBIENT which is hopefully more descriptive and more explicit about the purpose and capabilities of the sensors.
I'm fine, but one really picky comment below. I don't think a new version is needed till Jonathan will ask for it.
Quoted 25 lines
Signed-off-by Crt Mori <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/iio/industrialio-core.c | 1 + drivers/iio/temperature/mlx90632.c | 8 +++++++- include/linux/iio/types.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-)drivers/iio/industrialio-core.c +1
-0@@ -165,6 +165,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity", [IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio", [IIO_CHAN_INFO_THERMOCOUPLE_TYPE] = "thermocouple_type", + [IIO_CHAN_INFO_CALIBAMBIENT] = "calibambient", };#if defined(CONFIG_DEBUG_FS )drivers/iio/temperature/mlx90632.c +0
-0
drivers/iio/temperature/mlx90632.c static int mlx90632_read_raw(struct iio_dev *indio_dev, · line 763
Quoted 3 lines
drivers/iio/temperature/mlx90632.c +0
-0@@ -761,6 +761,9 @@ static int mlx90632_read_raw(struct iio_dev *indio_dev, *val2 = data->emissivity *1000 ; }return IIO_VAL_INT_PLUS_MICRO ;
Blank line is missed here.
Quoted 40 lines
drivers/iio/temperature/mlx90632.c +7
-1+case IIO_CHAN_INFO_CALIBAMBIENT : + *val = data->object_ambient_temperature; +return IIO_VAL_INT ;default :return -EINVAL ;@@ -781,6 +784,9 @@ static int mlx90632_write_raw(struct iio_dev *indio_dev,return -EINVAL ; data->emissivity = val *1000 + val2 /1000 ;return 0 ; +case IIO_CHAN_INFO_CALIBAMBIENT : + data->object_ambient_temperature = val; +return 0 ;default :return -EINVAL ; }@@ -798,7 +804,7 @@ static const struct iio_chan_spec mlx90632_channels[] = { .modified = 1, .channel2 = IIO_MOD_TEMP_OBJECT, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | - BIT(IIO_CHAN_INFO_CALIBEMISSIVITY), + BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) | BIT(IIO_CHAN_INFO_CALIBAMBIENT), }, };include/linux/iio/types.h +1
-1@@ -59,6 +59,7 @@ enum iio_chan_info_enum {IIO_CHAN_INFO_CALIBEMISSIVITY ,IIO_CHAN_INFO_OVERSAMPLING_RATIO ,IIO_CHAN_INFO_THERMOCOUPLE_TYPE , + IIO_CHAN_INFO_CALIBAMBIENT, };#endif /* _IIO_TYPES_H_ */ --2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 10 lines · On Fri, 4 Sep 2020 15:19:27 +0300 Andy Shevchenko <[email protected]>…
Quoted 8 lines · Crt Mori
Since object temperature might be different than the sensor temperature the infrared sensors should provide an interface to inject ambient temperature. This was in past done via write to ambient temperature interface (
in_temp_ambient_raw), but I think most people did not know about it. This solution introduces a new iio type of the CALIBAMBIENT which is hopefully more descriptive and more explicit about the purpose and capabilities of the sensors.
Quoted 5 lines
I'm fine, but one really picky comment below. I don't think a new version is needed till Jonathan will ask for it.
Quoted 2 lines
Signed-off-by Crt Mori <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
Starting point for a new ABI is docs, so please add to Documentation/ABI/testing/sysfs-bus-iio*
This is a somewhat odd corner case of saying don't use the local measurement but one from 'over there' that we are supplying.
I'd love to come up with a more generic term for that, but if we did I guess we'd back in the position that we are now, with a non-obvious interface for this particular usecase.
So unless anyone else comments, please do a v3 with docs and I'll pick it up.
Thanks,
Jonathan
Quoted 71 lines
Quoted 23 lines
--- drivers/iio/industrialio-core.c | 1 + drivers/iio/temperature/mlx90632.c | 8 +++++++- include/linux/iio/types.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-)drivers/iio/industrialio-core.c +1
-0@@ -165,6 +165,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity", [IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio", [IIO_CHAN_INFO_THERMOCOUPLE_TYPE] = "thermocouple_type", + [IIO_CHAN_INFO_CALIBAMBIENT] = "calibambient", };#if defined(CONFIG_DEBUG_FS )drivers/iio/temperature/mlx90632.c +0
-0drivers/iio/temperature/mlx90632.c static int mlx90632_read_raw(struct iio_dev *indio_dev, · line 763
Quoted 3 lines
drivers/iio/temperature/mlx90632.c +0
-0@@ -761,6 +761,9 @@ static int mlx90632_read_raw(struct iio_dev *indio_dev, *val2 = data->emissivity *1000 ; }return IIO_VAL_INT_PLUS_MICRO ;Blank line is missed here.
Quoted 40 lines
drivers/iio/temperature/mlx90632.c +7
-1+case IIO_CHAN_INFO_CALIBAMBIENT : + *val = data->object_ambient_temperature; +return IIO_VAL_INT ;default :return -EINVAL ;@@ -781,6 +784,9 @@ static int mlx90632_write_raw(struct iio_dev *indio_dev,return -EINVAL ; data->emissivity = val *1000 + val2 /1000 ;return 0 ; +case IIO_CHAN_INFO_CALIBAMBIENT : + data->object_ambient_temperature = val; +return 0 ;default :return -EINVAL ; }@@ -798,7 +804,7 @@ static const struct iio_chan_spec mlx90632_channels[] = { .modified = 1, .channel2 = IIO_MOD_TEMP_OBJECT, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | - BIT(IIO_CHAN_INFO_CALIBEMISSIVITY), + BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) | BIT(IIO_CHAN_INFO_CALIBAMBIENT), }, };include/linux/iio/types.h +1
-1@@ -59,6 +59,7 @@ enum iio_chan_info_enum {IIO_CHAN_INFO_CALIBEMISSIVITY ,IIO_CHAN_INFO_OVERSAMPLING_RATIO ,IIO_CHAN_INFO_THERMOCOUPLE_TYPE , + IIO_CHAN_INFO_CALIBAMBIENT, };#endif /* _IIO_TYPES_H_ */ --2.25.1
Crt Mori
maintainerQuoted 33 lines · Andy Shevchenko
Quoted 8 lines · Crt Mori
Since object temperature might be different than the sensor temperature the infrared sensors should provide an interface to inject ambient temperature. This was in past done via write to ambient temperature interface (
in_temp_ambient_raw), but I think most people did not know about it. This solution introduces a new iio type of the CALIBAMBIENT which is hopefully more descriptive and more explicit about the purpose and capabilities of the sensors.I'm fine, but one really picky comment below. I don't think a new version is needed till Jonathan will ask for it.
Quoted 19 lines
Signed-off-by Crt Mori <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/iio/industrialio-core.c | 1 + drivers/iio/temperature/mlx90632.c | 8 +++++++- include/linux/iio/types.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-)drivers/iio/industrialio-core.c +1
-0@@ -165,6 +165,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity", [IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio", [IIO_CHAN_INFO_THERMOCOUPLE_TYPE] = "thermocouple_type", + [IIO_CHAN_INFO_CALIBAMBIENT] = "calibambient", };
Quoted 12 lines
drivers/iio/temperature/mlx90632.c static int mlx90632_read_raw(struct iio_dev *indio_dev, · line 763
Quoted 9 lines
drivers/iio/industrialio-core.c +0
-0#if defined(CONFIG_DEBUG_FS )drivers/iio/temperature/mlx90632.c +0
-0@@ -761,6 +761,9 @@ static int mlx90632_read_raw(struct iio_dev *indio_dev, *val2 = data->emissivity *1000 ; }return IIO_VAL_INT_PLUS_MICRO ;Blank line is missed here.
I don't have new lines before and after case: in switch statements through whole file, so I decided to remove the blank line 4 rows down as well to keep it all nicely unified in v3.
Quoted 45 lines
Quoted 38 lines
drivers/iio/temperature/mlx90632.c +7
-1+case IIO_CHAN_INFO_CALIBAMBIENT : + *val = data->object_ambient_temperature; +return IIO_VAL_INT ;default :return -EINVAL ;@@ -781,6 +784,9 @@ static int mlx90632_write_raw(struct iio_dev *indio_dev,return -EINVAL ; data->emissivity = val *1000 + val2 /1000 ;return 0 ; +case IIO_CHAN_INFO_CALIBAMBIENT : + data->object_ambient_temperature = val; +return 0 ;default :return -EINVAL ; }@@ -798,7 +804,7 @@ static const struct iio_chan_spec mlx90632_channels[] = { .modified = 1, .channel2 = IIO_MOD_TEMP_OBJECT, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | - BIT(IIO_CHAN_INFO_CALIBEMISSIVITY), + BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) | BIT(IIO_CHAN_INFO_CALIBAMBIENT), }, };include/linux/iio/types.h +1
-1@@ -59,6 +59,7 @@ enum iio_chan_info_enum {IIO_CHAN_INFO_CALIBEMISSIVITY ,IIO_CHAN_INFO_OVERSAMPLING_RATIO ,IIO_CHAN_INFO_THERMOCOUPLE_TYPE , + IIO_CHAN_INFO_CALIBAMBIENT, };#endif /* _IIO_TYPES_H_ */ --Quoted 2 lines
2.25.1
--
With Best Regards,
Andy Shevchenko