mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-04 18:09:57 +00:00
![Rafael J. Wysocki](/assets/img/avatar_default.png)
* powercap: powercap: intel_rapl: Use topology interface in rapl_init_domains() powercap: intel_rapl: Use topology interface in rapl_add_package() powercap/intel_rapl: add support for AlderLake Mobile powercap/drivers/dtpm: Fix size of object being allocated powercap/drivers/dtpm: Fix an IS_ERR() vs NULL check powercap/drivers/dtpm: Fix some missing unlock bugs powercap/drivers/dtpm: Fix a double shift bug powercap/drivers/dtpm: Fix __udivdi3 and __aeabi_uldivmod unresolved symbols powercap/drivers/dtpm: Add CPU energy model based support powercap/drivers/dtpm: Add API for dynamic thermal power management Documentation/powercap/dtpm: Add documentation for dtpm units: Add Watt units * pm-misc: PM: Kconfig: remove unneeded "default n" options PM: EM: update Kconfig description and drop "default n" option
88 lines
2.1 KiB
C
88 lines
2.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_UNITS_H
|
|
#define _LINUX_UNITS_H
|
|
|
|
#include <linux/math.h>
|
|
|
|
#define MILLIWATT_PER_WATT 1000L
|
|
#define MICROWATT_PER_MILLIWATT 1000L
|
|
#define MICROWATT_PER_WATT 1000000L
|
|
|
|
#define ABSOLUTE_ZERO_MILLICELSIUS -273150
|
|
|
|
static inline long milli_kelvin_to_millicelsius(long t)
|
|
{
|
|
return t + ABSOLUTE_ZERO_MILLICELSIUS;
|
|
}
|
|
|
|
static inline long millicelsius_to_milli_kelvin(long t)
|
|
{
|
|
return t - ABSOLUTE_ZERO_MILLICELSIUS;
|
|
}
|
|
|
|
#define MILLIDEGREE_PER_DEGREE 1000
|
|
#define MILLIDEGREE_PER_DECIDEGREE 100
|
|
|
|
static inline long kelvin_to_millicelsius(long t)
|
|
{
|
|
return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DEGREE);
|
|
}
|
|
|
|
static inline long millicelsius_to_kelvin(long t)
|
|
{
|
|
t = millicelsius_to_milli_kelvin(t);
|
|
|
|
return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE);
|
|
}
|
|
|
|
static inline long deci_kelvin_to_celsius(long t)
|
|
{
|
|
t = milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DECIDEGREE);
|
|
|
|
return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE);
|
|
}
|
|
|
|
static inline long celsius_to_deci_kelvin(long t)
|
|
{
|
|
t = millicelsius_to_milli_kelvin(t * MILLIDEGREE_PER_DEGREE);
|
|
|
|
return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DECIDEGREE);
|
|
}
|
|
|
|
/**
|
|
* deci_kelvin_to_millicelsius_with_offset - convert Kelvin to Celsius
|
|
* @t: temperature value in decidegrees Kelvin
|
|
* @offset: difference between Kelvin and Celsius in millidegrees
|
|
*
|
|
* Return: temperature value in millidegrees Celsius
|
|
*/
|
|
static inline long deci_kelvin_to_millicelsius_with_offset(long t, long offset)
|
|
{
|
|
return t * MILLIDEGREE_PER_DECIDEGREE - offset;
|
|
}
|
|
|
|
static inline long deci_kelvin_to_millicelsius(long t)
|
|
{
|
|
return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DECIDEGREE);
|
|
}
|
|
|
|
static inline long millicelsius_to_deci_kelvin(long t)
|
|
{
|
|
t = millicelsius_to_milli_kelvin(t);
|
|
|
|
return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DECIDEGREE);
|
|
}
|
|
|
|
static inline long kelvin_to_celsius(long t)
|
|
{
|
|
return t + DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS,
|
|
MILLIDEGREE_PER_DEGREE);
|
|
}
|
|
|
|
static inline long celsius_to_kelvin(long t)
|
|
{
|
|
return t - DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS,
|
|
MILLIDEGREE_PER_DEGREE);
|
|
}
|
|
|
|
#endif /* _LINUX_UNITS_H */
|