Skip to content

Commit 67b5e10

Browse files
easwarhliuw
authored andcommitted
drivers: hv: Convert open-coded timeouts to secs_to_jiffies()
We have several places where timeouts are open-coded as N (seconds) * HZ, but best practice is to use the utility functions from jiffies.h. Convert the timeouts to be compliant. This doesn't fix any bugs, it's a simple code improvement. Signed-off-by: Easwar Hariharan <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Link: https://lore.kernel.org/r/20241030-open-coded-timeouts-v3-2-9ba123facf88@linux.microsoft.com Signed-off-by: Wei Liu <[email protected]> Message-ID: <20241030-open-coded-timeouts-v3-2-9ba123facf88@linux.microsoft.com>
1 parent 91ae69c commit 67b5e10

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

drivers/hv/hv_balloon.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
756756
* adding succeeded, it is ok to proceed even if the memory was
757757
* not onlined in time.
758758
*/
759-
wait_for_completion_timeout(&dm_device.ol_waitevent, 5 * HZ);
759+
wait_for_completion_timeout(&dm_device.ol_waitevent, secs_to_jiffies(5));
760760
post_status(&dm_device);
761761
}
762762
}
@@ -1373,7 +1373,8 @@ static int dm_thread_func(void *dm_dev)
13731373
struct hv_dynmem_device *dm = dm_dev;
13741374

13751375
while (!kthread_should_stop()) {
1376-
wait_for_completion_interruptible_timeout(&dm_device.config_event, 1 * HZ);
1376+
wait_for_completion_interruptible_timeout(&dm_device.config_event,
1377+
secs_to_jiffies(1));
13771378
/*
13781379
* The host expects us to post information on the memory
13791380
* pressure every second.
@@ -1748,7 +1749,7 @@ static int balloon_connect_vsp(struct hv_device *dev)
17481749
if (ret)
17491750
goto out;
17501751

1751-
t = wait_for_completion_timeout(&dm_device.host_event, 5 * HZ);
1752+
t = wait_for_completion_timeout(&dm_device.host_event, secs_to_jiffies(5));
17521753
if (t == 0) {
17531754
ret = -ETIMEDOUT;
17541755
goto out;
@@ -1806,7 +1807,7 @@ static int balloon_connect_vsp(struct hv_device *dev)
18061807
if (ret)
18071808
goto out;
18081809

1809-
t = wait_for_completion_timeout(&dm_device.host_event, 5 * HZ);
1810+
t = wait_for_completion_timeout(&dm_device.host_event, secs_to_jiffies(5));
18101811
if (t == 0) {
18111812
ret = -ETIMEDOUT;
18121813
goto out;

drivers/hv/hv_kvp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ void hv_kvp_onchannelcallback(void *context)
655655
if (host_negotiatied == NEGO_NOT_STARTED) {
656656
host_negotiatied = NEGO_IN_PROGRESS;
657657
schedule_delayed_work(&kvp_host_handshake_work,
658-
HV_UTIL_NEGO_TIMEOUT * HZ);
658+
secs_to_jiffies(HV_UTIL_NEGO_TIMEOUT));
659659
}
660660
return;
661661
}
@@ -724,7 +724,7 @@ void hv_kvp_onchannelcallback(void *context)
724724
*/
725725
schedule_work(&kvp_sendkey_work);
726726
schedule_delayed_work(&kvp_timeout_work,
727-
HV_UTIL_TIMEOUT * HZ);
727+
secs_to_jiffies(HV_UTIL_TIMEOUT));
728728

729729
return;
730730

drivers/hv/hv_snapshot.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ static void vss_send_op(void)
193193
vss_transaction.state = HVUTIL_USERSPACE_REQ;
194194

195195
schedule_delayed_work(&vss_timeout_work, op == VSS_OP_FREEZE ?
196-
VSS_FREEZE_TIMEOUT * HZ : HV_UTIL_TIMEOUT * HZ);
196+
secs_to_jiffies(VSS_FREEZE_TIMEOUT) :
197+
secs_to_jiffies(HV_UTIL_TIMEOUT));
197198

198199
rc = hvutil_transport_send(hvt, vss_msg, sizeof(*vss_msg), NULL);
199200
if (rc) {

drivers/hv/vmbus_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,7 @@ static int vmbus_bus_resume(struct device *dev)
25072507
vmbus_request_offers();
25082508

25092509
if (wait_for_completion_timeout(
2510-
&vmbus_connection.ready_for_resume_event, 10 * HZ) == 0)
2510+
&vmbus_connection.ready_for_resume_event, secs_to_jiffies(10)) == 0)
25112511
pr_err("Some vmbus device is missing after suspending?\n");
25122512

25132513
/* Reset the event for the next suspend. */

0 commit comments

Comments
 (0)