[PATCH] smc911x: test after postfix decrement fails in smc911x_{reset,drop_pkt} - Kernel

This is a discussion on [PATCH] smc911x: test after postfix decrement fails in smc911x_{reset,drop_pkt} - Kernel ; When timeout reaches 0 the postfix decrement still subtracts, so the test fails Signed-off-by: Roel Kluin --- diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 76cc1d3..2126d24 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -243,7 +243,7 @@ static void smc911x_reset(struct net_device *dev) do { udelay(10); ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [PATCH] smc911x: test after postfix decrement fails in smc911x_{reset,drop_pkt}

  1. [PATCH] smc911x: test after postfix decrement fails in smc911x_{reset,drop_pkt}

    When timeout reaches 0 the postfix decrement still subtracts, so the test fails

    Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
    ---
    diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
    index 76cc1d3..2126d24 100644
    --- a/drivers/net/smc911x.c
    +++ b/drivers/net/smc911x.c
    @@ -243,7 +243,7 @@ static void smc911x_reset(struct net_device *dev)
    do {
    udelay(10);
    reg = SMC_GET_PMT_CTRL() & PMT_CTRL_READY_;
    - } while ( timeout-- && !reg);
    + } while ( --timeout && !reg);
    if (timeout == 0) {
    PRINTK("%s: smc911x_reset timeout waiting for PM restore\n", dev->name);
    return;
    @@ -267,7 +267,7 @@ static void smc911x_reset(struct net_device *dev)
    resets++;
    break;
    }
    - } while ( timeout-- && (reg & HW_CFG_SRST_));
    + } while ( --timeout && (reg & HW_CFG_SRST_));
    }
    if (timeout == 0) {
    PRINTK("%s: smc911x_reset timeout waiting for reset\n", dev->name);
    @@ -413,7 +413,7 @@ static inline void smc911x_drop_pkt(struct net_device *dev)
    do {
    udelay(10);
    reg = SMC_GET_RX_DP_CTRL() & RX_DP_CTRL_FFWD_BUSY_;
    - } while ( timeout-- && reg);
    + } while ( --timeout && reg);
    if (timeout == 0) {
    PRINTK("%s: timeout waiting for RX fast forward\n", dev->name);
    }
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: [PATCH] smc911x: test after postfix decrement fails in smc911x_{reset,drop_pkt}

    >>>>> "Roel" == Roel Kluin <12o3l@tiscali.nl> writes:

    Roel> When timeout reaches 0 the postfix decrement still subtracts,
    Roel> so the test fails

    Ahh, good catch. Notice that Nicolas isn't the author of smc911x,
    Dustin McIntire is.

    Acked-by: Peter Korsgaard

    Roel> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
    Roel> ---
    Roel> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
    Roel> index 76cc1d3..2126d24 100644
    Roel> --- a/drivers/net/smc911x.c
    Roel> +++ b/drivers/net/smc911x.c
    Roel> @@ -243,7 +243,7 @@ static void smc911x_reset(struct net_device *dev)
    Roel> do {
    Roel> udelay(10);
    Roel> reg = SMC_GET_PMT_CTRL() & PMT_CTRL_READY_;
    Roel> - } while ( timeout-- && !reg);
    Roel> + } while ( --timeout && !reg);
    Roel> if (timeout == 0) {
    Roel> PRINTK("%s: smc911x_reset timeout waiting for PM restore\n", dev->name);
    Roel> return;
    Roel> @@ -267,7 +267,7 @@ static void smc911x_reset(struct net_device *dev)
    Roel> resets++;
    Roel> break;
    Roel> }
    Roel> - } while ( timeout-- && (reg & HW_CFG_SRST_));
    Roel> + } while ( --timeout && (reg & HW_CFG_SRST_));
    Roel> }
    Roel> if (timeout == 0) {
    Roel> PRINTK("%s: smc911x_reset timeout waiting for reset\n", dev->name);
    Roel> @@ -413,7 +413,7 @@ static inline void smc911x_drop_pkt(struct net_device *dev)
    Roel> do {
    Roel> udelay(10);
    Roel> reg = SMC_GET_RX_DP_CTRL() & RX_DP_CTRL_FFWD_BUSY_;
    Roel> - } while ( timeout-- && reg);
    Roel> + } while ( --timeout && reg);
    Roel> if (timeout == 0) {
    Roel> PRINTK("%s: timeout waiting for RX fast forward\n", dev->name);
    Roel> }
    Roel> --

    --
    Bye, Peter Korsgaard
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread