From: Nicholas Mc Guire <hofrat@osadl.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Sven Van Asbroeck <thesven73@gmail.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Nicholas Mc Guire <hofrat@osadl.org>
Subject: [PATCH V3] staging: fieldbus: anybus-s: consolidate wait_for_completion_timeout return handling
Date: Mon, 29 Apr 2019 08:05:40 +0200 [thread overview]
Message-ID: <1556517940-13725-2-git-send-email-hofrat@osadl.org> (raw)
In-Reply-To: <1556517940-13725-1-git-send-email-hofrat@osadl.org>
wait_for_completion_timeout() returns unsigned long (0 on timeout or
remaining jiffies) not int - so this type error allows for a
theoretically int overflow - though not in this case where TIMEOUT is
only HZ*2). To fix this type inconsistency the completion is wrapped
into the if() rather than introducing an additional unsigned long
variable.
Along with fixing this type inconsistency the fall-through if is
consolidated to a single if-block.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
Problem located with experimental API conformance checking cocci script
V3: As requested by Sven Van Asbroeck <thesven73@gmail.com> cleanup
the commit message to make it more clear what the impact of the
proposed change is....lets see if this is any better.
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 + OF=y, 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
next prev parent reply other threads:[~2019-04-29 6:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-29 6:05 [PATCH V2] staging: fieldbus: anybus-s: force endiannes annotation Nicholas Mc Guire
2019-04-29 6:05 ` Nicholas Mc Guire [this message]
2019-04-29 14:01 ` [PATCH V3] staging: fieldbus: anybus-s: consolidate wait_for_completion_timeout return handling Sven Van Asbroeck
2019-04-29 14:03 ` [PATCH V2] staging: fieldbus: anybus-s: force endiannes annotation Sven Van Asbroeck
2019-04-30 2:22 ` Nicholas Mc Guire
2019-04-30 3:02 ` Al Viro
2019-04-30 3:33 ` Nicholas Mc Guire
2019-04-30 4:19 ` Al Viro
2019-04-30 13:32 ` Sven Van Asbroeck
2019-04-30 14:03 ` Greg Kroah-Hartman
2019-04-30 14:22 ` Sven Van Asbroeck
2019-04-30 14:26 ` Sven Van Asbroeck
2019-04-30 14:27 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1556517940-13725-2-git-send-email-hofrat@osadl.org \
--to=hofrat@osadl.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thesven73@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).