ath5k: fix off-by-one in gpio checks
authorBob Copeland <me@bobcopeland.com>
Thu, 1 Jan 2009 20:01:45 +0000 (15:01 -0500)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Jan 2009 20:59:45 +0000 (15:59 -0500)
Sanity checks against AR5K_NUM_GPIO were all broken.  This doesn't
currently cause any problems since we only use the first four gpios.

Changes-licensed-under: ISC

Reported-by: Andreas Mohr <andi@lisas.de>
Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath5k/gpio.c

index b77205adc18025278f06d5adc84ee694a5fea03f..64a27e73d02ed6f87cc9299ea78aa56603ad5a58 100644 (file)
@@ -83,7 +83,7 @@ void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state)
 int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio)
 {
        ATH5K_TRACE(ah->ah_sc);
-       if (gpio > AR5K_NUM_GPIO)
+       if (gpio >= AR5K_NUM_GPIO)
                return -EINVAL;
 
        ath5k_hw_reg_write(ah,
@@ -99,7 +99,7 @@ int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio)
 int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio)
 {
        ATH5K_TRACE(ah->ah_sc);
-       if (gpio > AR5K_NUM_GPIO)
+       if (gpio >= AR5K_NUM_GPIO)
                return -EINVAL;
 
        ath5k_hw_reg_write(ah,
@@ -115,7 +115,7 @@ int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio)
 u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio)
 {
        ATH5K_TRACE(ah->ah_sc);
-       if (gpio > AR5K_NUM_GPIO)
+       if (gpio >= AR5K_NUM_GPIO)
                return 0xffffffff;
 
        /* GPIO input magic */
@@ -131,7 +131,7 @@ int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val)
        u32 data;
        ATH5K_TRACE(ah->ah_sc);
 
-       if (gpio > AR5K_NUM_GPIO)
+       if (gpio >= AR5K_NUM_GPIO)
                return -EINVAL;
 
        /* GPIO output magic */
@@ -154,7 +154,7 @@ void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio,
        u32 data;
 
        ATH5K_TRACE(ah->ah_sc);
-       if (gpio > AR5K_NUM_GPIO)
+       if (gpio >= AR5K_NUM_GPIO)
                return;
 
        /*