From: Barnabás Pőcze Date: Wed, 3 Feb 2021 21:55:27 +0000 (+0000) Subject: platform/x86: ideapad-laptop: use msecs_to_jiffies() helper instead of hand-crafted... X-Git-Tag: v5.12-rc1~123^2~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=40e0447d6f8052e241a1082bd97f8f3e40ed499d;p=thirdparty%2Fkernel%2Flinux.git platform/x86: ideapad-laptop: use msecs_to_jiffies() helper instead of hand-crafted formula The current code used a hand-crafted formula to convert milliseconds to jiffies, replace it with the msecs_to_jiffies() function. Furthermore, use a while loop instead of for loop for shorter lines and simplicity. Signed-off-by: Barnabás Pőcze Link: https://lore.kernel.org/r/20210203215403.290792-11-pobrn@protonmail.com Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 5978770bac2a2..bb7eb9c1f0ecb 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -221,8 +222,9 @@ static int read_ec_data(acpi_handle handle, int cmd, unsigned long *data) if (method_vpcw(handle, 1, cmd)) return -1; - for (end_jiffies = jiffies+(HZ)*IDEAPAD_EC_TIMEOUT/1000+1; - time_before(jiffies, end_jiffies);) { + end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; + + while (time_before(jiffies, end_jiffies)) { schedule(); if (method_vpcr(handle, 1, &val)) return -1; @@ -247,8 +249,9 @@ static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data) if (method_vpcw(handle, 1, cmd)) return -1; - for (end_jiffies = jiffies+(HZ)*IDEAPAD_EC_TIMEOUT/1000+1; - time_before(jiffies, end_jiffies);) { + end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; + + while (time_before(jiffies, end_jiffies)) { schedule(); if (method_vpcr(handle, 1, &val)) return -1;