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

hwmon: (dell-smm) Rework SMM function debugging

Drop #ifdef DEBUG and use ktime_us_delta()
for improved precision.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210814190516.26718-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Armin Wolf and committed by
Guenter Roeck
8713b4a4 782a99c1

+6 -15
+6 -15
drivers/hwmon/dell-smm-hwmon.c
··· 158 158 */ 159 159 static int i8k_smm_func(void *par) 160 160 { 161 - int rc; 161 + ktime_t calltime = ktime_get(); 162 162 struct smm_regs *regs = par; 163 163 int eax = regs->eax; 164 - 165 - #ifdef DEBUG 166 164 int ebx = regs->ebx; 167 - unsigned long duration; 168 - ktime_t calltime, delta, rettime; 169 - 170 - calltime = ktime_get(); 171 - #endif 165 + long long duration; 166 + int rc; 172 167 173 168 /* SMM requires CPU 0 */ 174 169 if (smp_processor_id() != 0) ··· 225 230 if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax) 226 231 rc = -EINVAL; 227 232 228 - #ifdef DEBUG 229 - rettime = ktime_get(); 230 - delta = ktime_sub(rettime, calltime); 231 - duration = ktime_to_ns(delta) >> 10; 232 - pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x (took %7lu usecs)\n", eax, ebx, 233 - (rc ? 0xffff : regs->eax & 0xffff), duration); 234 - #endif 233 + duration = ktime_us_delta(ktime_get(), calltime); 234 + pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x (took %7lld usecs)\n", eax, ebx, 235 + (rc ? 0xffff : regs->eax & 0xffff), duration); 235 236 236 237 return rc; 237 238 }