[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1556339208-7722-1-git-send-email-hofrat@osadl.org>
Date: Sat, 27 Apr 2019 06:26:48 +0200
From: Nicholas Mc Guire <hofrat@...dl.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Sven Van Asbroeck <thesven73@...il.com>,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
Nicholas Mc Guire <hofrat@...dl.org>
Subject: [PATCH RFC] staging: fieldbus: anybus-s: use proper type for wait_for_completion_timeout
wait_for_completion_timeout() returns unsigned long (0 on timeout or
remaining jiffies) not int. thus there is no negative case to check for
here.
Signed-off-by: Nicholas Mc Guire <hofrat@...dl.org>
---
Problem located with experimental API conformance checking cocci script
Q: It is not really clear if the proposed fix is the right thing here or if
this should not be using wait_for_completion_interruptible - which would
return -ERESTARTSYS on interruption. Someone that knows the details of
this driver would need to check what condition should initiate the
goto err_reset; which was actually unreachable in the current code.
Patch was compile-tested with. x86_64_defconfig + FIELDBUS_DEV=m,
HMS_ANYBUSS_BUS=m
(some unrelated sparse warnings (cast to restricted __be16))
Patch is against 5.1-rc6 (localversion-next is next-20190426)
drivers/staging/fieldbus/anybuss/host.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
index e34d424..c52d715 100644
--- a/drivers/staging/fieldbus/anybuss/host.c
+++ b/drivers/staging/fieldbus/anybuss/host.c
@@ -1263,6 +1263,7 @@ anybuss_host_common_probe(struct device *dev,
const struct anybuss_ops *ops)
{
int ret, i;
+ unsigned long time_left;
u8 val[4];
u16 fieldbus_type;
struct anybuss_host *cd;
@@ -1325,11 +1326,9 @@ 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)
+ time_left = wait_for_completion_timeout(&cd->card_boot, TIMEOUT);
+ if (time_left == 0)
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
Powered by blists - more mailing lists