2015-05-12 18:26:46

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH] carl9170: match wait_for_completion_timeout return type

Return type of wait_for_completion_timeout is unsigned long not int.
An appropriately named unsigned long is added, and the assignments
as well as error checking fixed up.

API conformance testing for completions with coccinelle spatches are being
used to locate API usage inconsistencies:
./drivers/net/wireless/ath/carl9170/usb.c:675
int return assigned to unsigned long

Patch was compile tested with x86_64_defconfig + CONFIG_ATH_CARDS=m,
CONFIG_CARL9170=m

Patch is against 4.1-rc3 (localversion-next is -next-20150512)

Signed-off-by: Nicholas Mc Guire <[email protected]>
---
drivers/net/wireless/ath/carl9170/usb.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/usb.c b/drivers/net/wireless/ath/carl9170/usb.c
index c9f9331..76842e6 100644
--- a/drivers/net/wireless/ath/carl9170/usb.c
+++ b/drivers/net/wireless/ath/carl9170/usb.c
@@ -651,6 +651,7 @@ int carl9170_exec_cmd(struct ar9170 *ar, const enum carl9170_cmd_oids cmd,
unsigned int plen, void *payload, unsigned int outlen, void *out)
{
int err = -ENOMEM;
+ unsigned long time_left;

if (!IS_ACCEPTING_CMD(ar))
return -EIO;
@@ -672,8 +673,8 @@ int carl9170_exec_cmd(struct ar9170 *ar, const enum carl9170_cmd_oids cmd,
err = __carl9170_exec_cmd(ar, &ar->cmd, false);

if (!(cmd & CARL9170_CMD_ASYNC_FLAG)) {
- err = wait_for_completion_timeout(&ar->cmd_wait, HZ);
- if (err == 0) {
+ time_left = wait_for_completion_timeout(&ar->cmd_wait, HZ);
+ if (time_left == 0) {
err = -ETIMEDOUT;
goto err_unbuf;
}
--
1.7.10.4



2015-05-13 14:40:42

by Christian Lamparter

[permalink] [raw]
Subject: Re: [PATCH] carl9170: match wait_for_completion_timeout return type

On Tue, May 12, 2015 at 8:18 PM, Nicholas Mc Guire <[email protected]> wrote:
> Return type of wait_for_completion_timeout is unsigned long not int.
> An appropriately named unsigned long is added, and the assignments
> as well as error checking fixed up.
>
> API conformance testing for completions with coccinelle spatches are being
> used to locate API usage inconsistencies:
> ./drivers/net/wireless/ath/carl9170/usb.c:675
> int return assigned to unsigned long
>
> Patch was compile tested with x86_64_defconfig + CONFIG_ATH_CARDS=m,
> CONFIG_CARL9170=m
>
> Patch is against 4.1-rc3 (localversion-next is -next-20150512)
>
> Signed-off-by: Nicholas Mc Guire <[email protected]>
Acked-by: Christian Lamparter <[email protected]>

2015-05-26 13:57:51

by Kalle Valo

[permalink] [raw]
Subject: Re: carl9170: match wait_for_completion_timeout return type


> Return type of wait_for_completion_timeout is unsigned long not int.
> An appropriately named unsigned long is added, and the assignments
> as well as error checking fixed up.
>
> API conformance testing for completions with coccinelle spatches are being
> used to locate API usage inconsistencies:
> ./drivers/net/wireless/ath/carl9170/usb.c:675
> int return assigned to unsigned long
>
> Patch was compile tested with x86_64_defconfig + CONFIG_ATH_CARDS=m,
> CONFIG_CARL9170=m
>
> Patch is against 4.1-rc3 (localversion-next is -next-20150512)
>
> Signed-off-by: Nicholas Mc Guire <[email protected]>
> Acked-by: Christian Lamparter <[email protected]>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo