Re: [kvm-unit-tests PATCH v7 06/12] s390x: use get_clock_ms() to calculate a delay in ms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2020-05-26 20:16, Thomas Huth wrote:
On 18/05/2020 18.07, Pierre Morel wrote:
use get_clock_ms() to calculate a delay in ms

Signed-off-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>
---
  lib/s390x/asm/time.h | 10 ++++++++++
  1 file changed, 10 insertions(+)

diff --git a/lib/s390x/asm/time.h b/lib/s390x/asm/time.h
index 25c7a3c..931a119 100644
--- a/lib/s390x/asm/time.h
+++ b/lib/s390x/asm/time.h
@@ -23,4 +23,14 @@ static inline uint64_t get_clock_ms(void)
  	return (clk >> (63 - 51)) / 1000;
  }
+static inline void mdelay(unsigned long ms)
+{
+	unsigned long startclk;
+
+	startclk = get_clock_ms();
+	for (;;)
+		if (get_clock_ms() - startclk > ms)
+			break;

Maybe rather:

     for (;get_clock_ms() - startclk <= ms;)
	;

?
Or:

     while (get_clock_ms() - startclk <= ms)
         ;
?

  Thomas


Hi,

your comment made me realize I did not take care on the wrapping.
I will rework this.

Thanks,
Pierre


--
Pierre Morel
IBM Lab Boeblingen



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux