Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1651380 > unrolled thread

[PATCH v2] ktime: Simplify ktime_compare implementation

Started byMariusz Skamra <mariuszx.skamra@intel.com>
First post2017-05-26 15:10 +0200
Last post2017-05-26 15:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] ktime: Simplify ktime_compare implementation Mariusz Skamra <mariuszx.skamra@intel.com> - 2017-05-26 15:10 +0200

#1651380 — [PATCH v2] ktime: Simplify ktime_compare implementation

FromMariusz Skamra <mariuszx.skamra@intel.com>
Date2017-05-26 15:10 +0200
Subject[PATCH v2] ktime: Simplify ktime_compare implementation
Message-ID<tLnaa-6jc-23@gated-at.bofh.it>
ktime_sub can be used here instread of two conditional checks.

Signed-off-by: Mariusz Skamra <mariuszx.skamra@intel.com>
Acked-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@intel.com>
---
 include/linux/ktime.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 0c8bd45..04817b1 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -108,11 +108,7 @@ static inline ktime_t timeval_to_ktime(struct timeval tv)
  */
 static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2)
 {
-	if (cmp1 < cmp2)
-		return -1;
-	if (cmp1 > cmp2)
-		return 1;
-	return 0;
+	return ktime_sub(cmp1, cmp2);
 }
 
 /**
-- 
2.1.4

--------------------------------------------------------------------

Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek
przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by
others is strictly prohibited.

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web