~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/units.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/units.h (Version linux-6.12-rc7) and /include/linux/units.h (Version linux-5.12.19)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _LINUX_UNITS_H                              2 #ifndef _LINUX_UNITS_H
  3 #define _LINUX_UNITS_H                              3 #define _LINUX_UNITS_H
  4                                                     4 
  5 #include <linux/bits.h>                        << 
  6 #include <linux/math.h>                             5 #include <linux/math.h>
  7                                                     6 
  8 /* Metric prefixes in accordance with Système !!   7 #define MILLIWATT_PER_WATT      1000L
  9 #define PETA    1000000000000000ULL            !!   8 #define MICROWATT_PER_MILLIWATT 1000L
 10 #define TERA    1000000000000ULL               !!   9 #define MICROWATT_PER_WATT      1000000L
 11 #define GIGA    1000000000UL                   << 
 12 #define MEGA    1000000UL                      << 
 13 #define KILO    1000UL                         << 
 14 #define HECTO   100UL                          << 
 15 #define DECA    10UL                           << 
 16 #define DECI    10UL                           << 
 17 #define CENTI   100UL                          << 
 18 #define MILLI   1000UL                         << 
 19 #define MICRO   1000000UL                      << 
 20 #define NANO    1000000000UL                   << 
 21 #define PICO    1000000000000ULL               << 
 22 #define FEMTO   1000000000000000ULL            << 
 23                                                << 
 24 #define NANOHZ_PER_HZ           1000000000UL   << 
 25 #define MICROHZ_PER_HZ          1000000UL      << 
 26 #define MILLIHZ_PER_HZ          1000UL         << 
 27                                                << 
 28 #define HZ_PER_KHZ              1000UL         << 
 29 #define HZ_PER_MHZ              1000000UL      << 
 30                                                << 
 31 #define KHZ_PER_MHZ             1000UL         << 
 32 #define KHZ_PER_GHZ             1000000UL      << 
 33                                                << 
 34 #define MILLIWATT_PER_WATT      1000UL         << 
 35 #define MICROWATT_PER_MILLIWATT 1000UL         << 
 36 #define MICROWATT_PER_WATT      1000000UL      << 
 37                                                << 
 38 #define BYTES_PER_KBIT          (KILO / BITS_P << 
 39 #define BYTES_PER_MBIT          (MEGA / BITS_P << 
 40 #define BYTES_PER_GBIT          (GIGA / BITS_P << 
 41                                                    10 
 42 #define ABSOLUTE_ZERO_MILLICELSIUS -273150         11 #define ABSOLUTE_ZERO_MILLICELSIUS -273150
 43                                                    12 
 44 static inline long milli_kelvin_to_millicelsiu     13 static inline long milli_kelvin_to_millicelsius(long t)
 45 {                                                  14 {
 46         return t + ABSOLUTE_ZERO_MILLICELSIUS;     15         return t + ABSOLUTE_ZERO_MILLICELSIUS;
 47 }                                                  16 }
 48                                                    17 
 49 static inline long millicelsius_to_milli_kelvi     18 static inline long millicelsius_to_milli_kelvin(long t)
 50 {                                                  19 {
 51         return t - ABSOLUTE_ZERO_MILLICELSIUS;     20         return t - ABSOLUTE_ZERO_MILLICELSIUS;
 52 }                                                  21 }
 53                                                    22 
 54 #define MILLIDEGREE_PER_DEGREE 1000                23 #define MILLIDEGREE_PER_DEGREE 1000
 55 #define MILLIDEGREE_PER_DECIDEGREE 100             24 #define MILLIDEGREE_PER_DECIDEGREE 100
 56                                                    25 
 57 static inline long kelvin_to_millicelsius(long     26 static inline long kelvin_to_millicelsius(long t)
 58 {                                                  27 {
 59         return milli_kelvin_to_millicelsius(t      28         return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DEGREE);
 60 }                                                  29 }
 61                                                    30 
 62 static inline long millicelsius_to_kelvin(long     31 static inline long millicelsius_to_kelvin(long t)
 63 {                                                  32 {
 64         t = millicelsius_to_milli_kelvin(t);       33         t = millicelsius_to_milli_kelvin(t);
 65                                                    34 
 66         return DIV_ROUND_CLOSEST(t, MILLIDEGRE     35         return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE);
 67 }                                                  36 }
 68                                                    37 
 69 static inline long deci_kelvin_to_celsius(long     38 static inline long deci_kelvin_to_celsius(long t)
 70 {                                                  39 {
 71         t = milli_kelvin_to_millicelsius(t * M     40         t = milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DECIDEGREE);
 72                                                    41 
 73         return DIV_ROUND_CLOSEST(t, MILLIDEGRE     42         return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE);
 74 }                                                  43 }
 75                                                    44 
 76 static inline long celsius_to_deci_kelvin(long     45 static inline long celsius_to_deci_kelvin(long t)
 77 {                                                  46 {
 78         t = millicelsius_to_milli_kelvin(t * M     47         t = millicelsius_to_milli_kelvin(t * MILLIDEGREE_PER_DEGREE);
 79                                                    48 
 80         return DIV_ROUND_CLOSEST(t, MILLIDEGRE     49         return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DECIDEGREE);
 81 }                                                  50 }
 82                                                    51 
 83 /**                                                52 /**
 84  * deci_kelvin_to_millicelsius_with_offset - c     53  * deci_kelvin_to_millicelsius_with_offset - convert Kelvin to Celsius
 85  * @t: temperature value in decidegrees Kelvin     54  * @t: temperature value in decidegrees Kelvin
 86  * @offset: difference between Kelvin and Cels     55  * @offset: difference between Kelvin and Celsius in millidegrees
 87  *                                                 56  *
 88  * Return: temperature value in millidegrees C     57  * Return: temperature value in millidegrees Celsius
 89  */                                                58  */
 90 static inline long deci_kelvin_to_millicelsius     59 static inline long deci_kelvin_to_millicelsius_with_offset(long t, long offset)
 91 {                                                  60 {
 92         return t * MILLIDEGREE_PER_DECIDEGREE      61         return t * MILLIDEGREE_PER_DECIDEGREE - offset;
 93 }                                                  62 }
 94                                                    63 
 95 static inline long deci_kelvin_to_millicelsius     64 static inline long deci_kelvin_to_millicelsius(long t)
 96 {                                                  65 {
 97         return milli_kelvin_to_millicelsius(t      66         return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DECIDEGREE);
 98 }                                                  67 }
 99                                                    68 
100 static inline long millicelsius_to_deci_kelvin     69 static inline long millicelsius_to_deci_kelvin(long t)
101 {                                                  70 {
102         t = millicelsius_to_milli_kelvin(t);       71         t = millicelsius_to_milli_kelvin(t);
103                                                    72 
104         return DIV_ROUND_CLOSEST(t, MILLIDEGRE     73         return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DECIDEGREE);
105 }                                                  74 }
106                                                    75 
107 static inline long kelvin_to_celsius(long t)       76 static inline long kelvin_to_celsius(long t)
108 {                                                  77 {
109         return t + DIV_ROUND_CLOSEST(ABSOLUTE_     78         return t + DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS,
110                                      MILLIDEGR     79                                      MILLIDEGREE_PER_DEGREE);
111 }                                                  80 }
112                                                    81 
113 static inline long celsius_to_kelvin(long t)       82 static inline long celsius_to_kelvin(long t)
114 {                                                  83 {
115         return t - DIV_ROUND_CLOSEST(ABSOLUTE_     84         return t - DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS,
116                                      MILLIDEGR     85                                      MILLIDEGREE_PER_DEGREE);
117 }                                                  86 }
118                                                    87 
119 #endif /* _LINUX_UNITS_H */                        88 #endif /* _LINUX_UNITS_H */
120                                                    89 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php