All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] staging: fieldbus: anybus-s: consolidate wait_for_completion_timeout return handling
@ 2019-04-28  2:33 Nicholas Mc Guire
  2019-04-28  2:33 ` [PATCH] staging: fieldbus: anybus-s: force endiannes annotation Nicholas Mc Guire
  2019-04-28 14:23 ` [PATCH V2] staging: fieldbus: anybus-s: consolidate wait_for_completion_timeout return handling Sven Van Asbroeck
  0 siblings, 2 replies; 4+ messages in thread
From: Nicholas Mc Guire @ 2019-04-28  2:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Sven Van Asbroeck, devel, linux-kernel, Nicholas Mc Guire

wait_for_completion_timeout() returns unsigned long (0 on timeout or
remaining jiffies) not int - so rather than introducing an additional
variable simply wrap the completion into an if().

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

Problem located with experimental API conformance checking cocci script

V2: The original patch's logic was wrong as it was skipping the 
    fall-through if so using the fix proposed by Sven Van Asbroeck 
    <thesven73@gmail.com> - This solution also eliminates the need
    to introduce an additional variable - Thanks !

Patch was compile-tested with. x86_64_defconfig + FIELDBUS_DEV=m,
HMS_ANYBUSS_BUS=m
(with an unrelated sparse warnings (cast to restricted __be16))

Patch is against 5.1-rc6 (localversion-next is next-20190426)

 drivers/staging/fieldbus/anybuss/host.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
index e34d424..6227daf 100644
--- a/drivers/staging/fieldbus/anybuss/host.c
+++ b/drivers/staging/fieldbus/anybuss/host.c
@@ -1325,11 +1325,11 @@ anybuss_host_common_probe(struct device *dev,
 	 *   interrupt came in: ready to go !
 	 */
 	reset_deassert(cd);
-	ret = wait_for_completion_timeout(&cd->card_boot, TIMEOUT);
-	if (ret == 0)
+	if (!wait_for_completion_timeout(&cd->card_boot, TIMEOUT)) {
 		ret = -ETIMEDOUT;
-	if (ret < 0)
 		goto err_reset;
+	}
+
 	/*
 	 * according to the anybus docs, we're allowed to read these
 	 * without handshaking / reserving the area
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-28 14:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-28  2:33 [PATCH V2] staging: fieldbus: anybus-s: consolidate wait_for_completion_timeout return handling Nicholas Mc Guire
2019-04-28  2:33 ` [PATCH] staging: fieldbus: anybus-s: force endiannes annotation Nicholas Mc Guire
2019-04-28 14:32   ` Sven Van Asbroeck
2019-04-28 14:23 ` [PATCH V2] staging: fieldbus: anybus-s: consolidate wait_for_completion_timeout return handling Sven Van Asbroeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.