2009-12-16 13:06:16

by Roel Kluin

[permalink] [raw]
Subject: [PATCH] iwmc3200wifi: Fix test of unsigned in iwm_ntf_stop_resume_tx()

`queue' is unsigned so the test did not work.

Signed-off-by: Roel Kluin <[email protected]>
---
Found using coccinelle: http://coccinelle.lip6.fr/

diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c
index 1c57c1f..9ac72e4 100644
--- a/drivers/net/wireless/iwmc3200wifi/rx.c
+++ b/drivers/net/wireless/iwmc3200wifi/rx.c
@@ -1128,7 +1128,7 @@ static int iwm_ntf_stop_resume_tx(struct iwm_priv *iwm, u8 *buf,
struct iwm_tx_queue *txq;
u16 queue = iwm_tid_to_queue(bit);

- if (queue < 0)
+ if (queue == -EINVAL)
continue;

txq = &iwm->txq[queue];


2009-12-16 14:53:22

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] iwmc3200wifi: Fix test of unsigned in iwm_ntf_stop_resume_tx()

On Wed, 2009-12-16 at 14:08 +0100, Roel Kluin wrote:
> `queue' is unsigned so the test did not work.
>
> Signed-off-by: Roel Kluin <[email protected]>
> ---
> Found using coccinelle: http://coccinelle.lip6.fr/
>
> diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c
> index 1c57c1f..9ac72e4 100644
> --- a/drivers/net/wireless/iwmc3200wifi/rx.c
> +++ b/drivers/net/wireless/iwmc3200wifi/rx.c
> @@ -1128,7 +1128,7 @@ static int iwm_ntf_stop_resume_tx(struct iwm_priv *iwm, u8 *buf,
> struct iwm_tx_queue *txq;
> u16 queue = iwm_tid_to_queue(bit);
>
> - if (queue < 0)
> + if (queue == -EINVAL)

I think it's ugly. iwm_tid_to_queue() should return int if it's allowed
to return error codes.

--
Regards,
Pavel Roskin

2009-12-16 15:59:54

by Roel Kluin

[permalink] [raw]
Subject: Re: [PATCH] iwmc3200wifi: Fix test of unsigned in iwm_ntf_stop_resume_tx()

`queue' was unsigned so the test did not work.

Signed-off-by: Roel Kluin <[email protected]>
---
Found using coccinelle: http://coccinelle.lip6.fr/

>> - if (queue < 0)
>> + if (queue == -EINVAL)
>
> I think it's ugly. iwm_tid_to_queue() should return int if it's allowed
> to return error codes.

Ok, how about:

drivers/net/wireless/iwmc3200wifi/iwm.h | 2 +-
drivers/net/wireless/iwmc3200wifi/netdev.c | 2 +-
drivers/net/wireless/iwmc3200wifi/rx.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/iwmc3200wifi/iwm.h b/drivers/net/wireless/iwmc3200wifi/iwm.h
index 5a26bb0..79ffa3b 100644
--- a/drivers/net/wireless/iwmc3200wifi/iwm.h
+++ b/drivers/net/wireless/iwmc3200wifi/iwm.h
@@ -349,7 +349,7 @@ int iwm_up(struct iwm_priv *iwm);
int iwm_down(struct iwm_priv *iwm);

/* TX API */
-u16 iwm_tid_to_queue(u16 tid);
+int iwm_tid_to_queue(u16 tid);
void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages);
void iwm_tx_worker(struct work_struct *work);
int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
index e4f0f87..c4c0d23 100644
--- a/drivers/net/wireless/iwmc3200wifi/netdev.c
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -76,7 +76,7 @@ static int iwm_stop(struct net_device *ndev)
*/
static const u16 iwm_1d_to_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };

-u16 iwm_tid_to_queue(u16 tid)
+int iwm_tid_to_queue(u16 tid)
{
if (tid > IWM_UMAC_TID_NR - 2)
return -EINVAL;
diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c
index 1c57c1f..6d6ed74 100644
--- a/drivers/net/wireless/iwmc3200wifi/rx.c
+++ b/drivers/net/wireless/iwmc3200wifi/rx.c
@@ -1126,7 +1126,7 @@ static int iwm_ntf_stop_resume_tx(struct iwm_priv *iwm, u8 *buf,

if (!stop) {
struct iwm_tx_queue *txq;
- u16 queue = iwm_tid_to_queue(bit);
+ int queue = iwm_tid_to_queue(bit);

if (queue < 0)
continue;

2009-12-16 17:22:00

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] iwmc3200wifi: Fix test of unsigned in iwm_ntf_stop_resume_tx()

On Wed, 2009-12-16 at 17:01 +0100, Roel Kluin wrote:

> Ok, how about:

> -u16 iwm_tid_to_queue(u16 tid)
> +int iwm_tid_to_queue(u16 tid)

That's much better! Thanks!

Reviewed-by: Pavel Roskin <[email protected]>

--
Regards,
Pavel Roskin

2009-12-17 01:26:18

by Zhu Yi

[permalink] [raw]
Subject: Re: [PATCH] iwmc3200wifi: Fix test of unsigned in iwm_ntf_stop_resume_tx()

On Thu, 2009-12-17 at 00:01 +0800, Roel Kluin wrote:
> `queue' was unsigned so the test did not work.
>
> Signed-off-by: Roel Kluin <[email protected]>
> ---
> Found using coccinelle: http://coccinelle.lip6.fr/
>
> >> - if (queue < 0)
> >> + if (queue == -EINVAL)
> >
> > I think it's ugly. iwm_tid_to_queue() should return int if it's allowed
> > to return error codes.
>
> Ok, how about:
>
> drivers/net/wireless/iwmc3200wifi/iwm.h | 2 +-
> drivers/net/wireless/iwmc3200wifi/netdev.c | 2 +-
> drivers/net/wireless/iwmc3200wifi/rx.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/iwmc3200wifi/iwm.h b/drivers/net/wireless/iwmc3200wifi/iwm.h
> index 5a26bb0..79ffa3b 100644
> --- a/drivers/net/wireless/iwmc3200wifi/iwm.h
> +++ b/drivers/net/wireless/iwmc3200wifi/iwm.h
> @@ -349,7 +349,7 @@ int iwm_up(struct iwm_priv *iwm);
> int iwm_down(struct iwm_priv *iwm);
>
> /* TX API */
> -u16 iwm_tid_to_queue(u16 tid);
> +int iwm_tid_to_queue(u16 tid);
> void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages);
> void iwm_tx_worker(struct work_struct *work);
> int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
> diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
> index e4f0f87..c4c0d23 100644
> --- a/drivers/net/wireless/iwmc3200wifi/netdev.c
> +++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
> @@ -76,7 +76,7 @@ static int iwm_stop(struct net_device *ndev)
> */
> static const u16 iwm_1d_to_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
>
> -u16 iwm_tid_to_queue(u16 tid)
> +int iwm_tid_to_queue(u16 tid)
> {
> if (tid > IWM_UMAC_TID_NR - 2)
> return -EINVAL;
> diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c
> index 1c57c1f..6d6ed74 100644
> --- a/drivers/net/wireless/iwmc3200wifi/rx.c
> +++ b/drivers/net/wireless/iwmc3200wifi/rx.c
> @@ -1126,7 +1126,7 @@ static int iwm_ntf_stop_resume_tx(struct iwm_priv *iwm, u8 *buf,
>
> if (!stop) {
> struct iwm_tx_queue *txq;
> - u16 queue = iwm_tid_to_queue(bit);
> + int queue = iwm_tid_to_queue(bit);
>
> if (queue < 0)
> continue;

Good catch. Thanks both for the fix.

Acked-by: Zhu Yi <[email protected]>

Thanks,
-yi