mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:38:03 +00:00
fpga: dfl: fme: use SI unit prefix macros
Substitute SI prefixes MILLI for temperature and MICRO for power, which are exported via the hwmon sysfs interface in m°C and ųW, respectively. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Peter Colberg <peter.colberg@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Xu Yilun <yilun.xu@intel.com> Link: https://lore.kernel.org/r/20230705033548.10737-1-peter.colberg@intel.com Signed-off-by: Xu Yilun <yilun.xu@intel.com>
This commit is contained in:
parent
06c2afb862
commit
1b75f5e9f4
@ -19,6 +19,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/units.h>
|
||||
#include <linux/fpga-dfl.h>
|
||||
|
||||
#include "dfl.h"
|
||||
@ -231,19 +232,19 @@ static int thermal_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
|
||||
switch (attr) {
|
||||
case hwmon_temp_input:
|
||||
v = readq(feature->ioaddr + FME_THERM_RDSENSOR_FMT1);
|
||||
*val = (long)(FIELD_GET(FPGA_TEMPERATURE, v) * 1000);
|
||||
*val = (long)(FIELD_GET(FPGA_TEMPERATURE, v) * MILLI);
|
||||
break;
|
||||
case hwmon_temp_max:
|
||||
v = readq(feature->ioaddr + FME_THERM_THRESHOLD);
|
||||
*val = (long)(FIELD_GET(TEMP_THRESHOLD1, v) * 1000);
|
||||
*val = (long)(FIELD_GET(TEMP_THRESHOLD1, v) * MILLI);
|
||||
break;
|
||||
case hwmon_temp_crit:
|
||||
v = readq(feature->ioaddr + FME_THERM_THRESHOLD);
|
||||
*val = (long)(FIELD_GET(TEMP_THRESHOLD2, v) * 1000);
|
||||
*val = (long)(FIELD_GET(TEMP_THRESHOLD2, v) * MILLI);
|
||||
break;
|
||||
case hwmon_temp_emergency:
|
||||
v = readq(feature->ioaddr + FME_THERM_THRESHOLD);
|
||||
*val = (long)(FIELD_GET(TRIP_THRESHOLD, v) * 1000);
|
||||
*val = (long)(FIELD_GET(TRIP_THRESHOLD, v) * MILLI);
|
||||
break;
|
||||
case hwmon_temp_max_alarm:
|
||||
v = readq(feature->ioaddr + FME_THERM_THRESHOLD);
|
||||
@ -382,15 +383,15 @@ static int power_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
|
||||
switch (attr) {
|
||||
case hwmon_power_input:
|
||||
v = readq(feature->ioaddr + FME_PWR_STATUS);
|
||||
*val = (long)(FIELD_GET(PWR_CONSUMED, v) * 1000000);
|
||||
*val = (long)(FIELD_GET(PWR_CONSUMED, v) * MICRO);
|
||||
break;
|
||||
case hwmon_power_max:
|
||||
v = readq(feature->ioaddr + FME_PWR_THRESHOLD);
|
||||
*val = (long)(FIELD_GET(PWR_THRESHOLD1, v) * 1000000);
|
||||
*val = (long)(FIELD_GET(PWR_THRESHOLD1, v) * MICRO);
|
||||
break;
|
||||
case hwmon_power_crit:
|
||||
v = readq(feature->ioaddr + FME_PWR_THRESHOLD);
|
||||
*val = (long)(FIELD_GET(PWR_THRESHOLD2, v) * 1000000);
|
||||
*val = (long)(FIELD_GET(PWR_THRESHOLD2, v) * MICRO);
|
||||
break;
|
||||
case hwmon_power_max_alarm:
|
||||
v = readq(feature->ioaddr + FME_PWR_THRESHOLD);
|
||||
@ -415,7 +416,7 @@ static int power_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
|
||||
int ret = 0;
|
||||
u64 v;
|
||||
|
||||
val = clamp_val(val / 1000000, 0, PWR_THRESHOLD_MAX);
|
||||
val = clamp_val(val / MICRO, 0, PWR_THRESHOLD_MAX);
|
||||
|
||||
mutex_lock(&pdata->lock);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user