Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

powercap: intel_rapl: Simplify rapl_compute_time_window_atom()

Restructure to use early return for to_raw case, eliminating
redundant assignments and clarifying conversion paths.

No functional changes.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://patch.msgid.link/20260212233044.329790-5-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Kuppuswamy Sathyanarayanan and committed by
Rafael J. Wysocki
637bf740 c64e89ba

+4 -6
+4 -6
drivers/powercap/intel_rapl_common.c
··· 1145 1145 static u64 rapl_compute_time_window_atom(struct rapl_domain *rd, u64 value, 1146 1146 bool to_raw) 1147 1147 { 1148 + if (to_raw) 1149 + return div64_u64(value, rd->time_unit); 1150 + 1148 1151 /* 1149 1152 * Atom time unit encoding is straight forward val * time_unit, 1150 1153 * where time_unit is default to 1 sec. Never 0. 1151 1154 */ 1152 - if (!to_raw) 1153 - return (value) ? value * rd->time_unit : rd->time_unit; 1154 - 1155 - value = div64_u64(value, rd->time_unit); 1156 - 1157 - return value; 1155 + return (value) ? value * rd->time_unit : rd->time_unit; 1158 1156 } 1159 1157 1160 1158 static int rapl_check_unit_tpmi(struct rapl_domain *rd)