ath6kl: add ath6kl_bmi_read_hi32()
authorKalle Valo <kvalo@qca.qualcomm.com>
Wed, 7 Mar 2012 18:03:59 +0000 (20:03 +0200)
committerKalle Valo <kvalo@qca.qualcomm.com>
Wed, 7 Mar 2012 18:03:59 +0000 (20:03 +0200)
There are few 32 bit reads from the host interest area. Add
ath6kl_bmi_read_hi32() to make it easier to do that. As code is cleaner
this also fixes few checkpatch warnings.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath6kl/bmi.h
drivers/net/wireless/ath/ath6kl/init.c

index e6a7330aadcd89013105d4c4c28c2ce9bf612a71..3c5b382a35293555b691f410db3f30e20d072597 100644 (file)
@@ -231,6 +231,13 @@ struct ath6kl_bmi_target_info {
                ath6kl_bmi_write(ar, addr, (u8 *) &v, sizeof(v));       \
        })
 
+#define ath6kl_bmi_read_hi32(ar, item, val)                            \
+       ({                                                              \
+               u32 addr, *check_type = val;                            \
+               (void) (check_type == val);                             \
+               addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item));      \
+               ath6kl_bmi_read(ar, addr, (u8 *) val, 4);               \
+       })
 
 int ath6kl_bmi_init(struct ath6kl *ar);
 void ath6kl_bmi_cleanup(struct ath6kl *ar);
index da5900d30caa9a97b192768908f58637193f6af6..d1d121dc8970c942cfa24a32ec40fbc5b91d2f1c 100644 (file)
@@ -501,10 +501,7 @@ int ath6kl_configure_target(struct ath6kl *ar)
        /* set the firmware mode to STA/IBSS/AP */
        param = 0;
 
-       if (ath6kl_bmi_read(ar,
-                           ath6kl_get_hi_item_addr(ar,
-                           HI_ITEM(hi_option_flag)),
-                           (u8 *)&param, 4) != 0) {
+       if (ath6kl_bmi_read_hi32(ar, hi_option_flag, &param) != 0) {
                ath6kl_err("bmi_read_memory for setting fwmode failed\n");
                return -EIO;
        }
@@ -1074,17 +1071,11 @@ static int ath6kl_upload_board_file(struct ath6kl *ar)
                ath6kl_bmi_write_hi32(ar, hi_board_data,
                                      ar->hw.board_addr);
        } else {
-               ath6kl_bmi_read(ar,
-                               ath6kl_get_hi_item_addr(ar,
-                               HI_ITEM(hi_board_data)),
-                               (u8 *) &board_address, 4);
+               ath6kl_bmi_read_hi32(ar, hi_board_data, &board_address);
        }
 
        /* determine where in target ram to write extended board data */
-       ath6kl_bmi_read(ar,
-                       ath6kl_get_hi_item_addr(ar,
-                       HI_ITEM(hi_board_ext_data)),
-                       (u8 *) &board_ext_address, 4);
+       ath6kl_bmi_read_hi32(ar, hi_board_ext_data, &board_ext_address);
 
        if (ar->target_type == TARGET_TYPE_AR6003 &&
            board_ext_address == 0) {
@@ -1177,10 +1168,7 @@ static int ath6kl_upload_otp(struct ath6kl *ar)
        }
 
        /* read firmware start address */
-       ret = ath6kl_bmi_read(ar,
-                             ath6kl_get_hi_item_addr(ar,
-                                                     HI_ITEM(hi_app_start)),
-                             (u8 *) &address, sizeof(address));
+       ret = ath6kl_bmi_read_hi32(ar, hi_app_start, &address);
 
        if (ret) {
                ath6kl_err("Failed to read hi_app_start: %d\n", ret);