ath10k: add bmi_read32/bmi_write32 function
PATCH 1/1 ath10k: add bmi_read32/bmi_write32 function
Add ath10k_bmi_read32/ath10k_bmi_write32 functions and use them in core layer when read32/write32.
--- drivers/net/wireless/ath/ath10k/bmi.h | 10 ++++++++++ drivers/net/wireless/ath/ath10k/core.c | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath10k/bmi.h +10 -0
@@ -191,6 +191,16 @@ int ath10k_bmi_read_memory(struct ath10k *ar, u32 address, void *buffer, u32 length);int ath10k_bmi_write_memory (struct ath10k *ar,u32 address,const void *buffer,u32 length); +static inline int ath10k_bmi_read32 (struct ath10k *ar,u32 address, +void *buffer) +{ +return ath10k_bmi_read_memory (ar, address, buffer,sizeof (u32)); +} +static inline int ath10k_bmi_write32 (struct ath10k *ar,u32 address, +void *buffer) +{ +return ath10k_bmi_write_memory (ar, address, buffer,sizeof (u32)); +}int ath10k_bmi_execute (struct ath10k *ar,u32 address,u32 *param);int ath10k_bmi_lz_stream_start (struct ath10k *ar,u32 address);int ath10k_bmi_lz_data (struct ath10k *ar,const void *buffer,u32 length);
drivers/net/wireless/ath/ath10k/core.c +12 -12
@@ -150,7 +150,7 @@ static int ath10k_init_configure_target(struct ath10k *ar) param_target =__cpu_to_le32 (HTC_PROTOCOL_VERSION ); host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_app_host_interest)); - ret =ath10k_bmi_write_memory (ar, host_addr, (u8 *)¶m_target,4 ); + ret =ath10k_bmi_write32 (ar, host_addr, (u8 *)¶m_target);if (ret) {ath10k_err ("settings HTC version failed\n" );return ret;
@@ -159,7 +159,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)/* set the firmware mode to STA/IBSS/AP */ host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_option_flag)); - ret =ath10k_bmi_read_memory (ar, host_addr, (u8 *)¶m_target,4 ); + ret =ath10k_bmi_read32 (ar, host_addr, (u8 *)¶m_target); param_host =__le32_to_cpu (param_target);if (ret) {ath10k_err ("setting firmware mode (1/2) failed\n" );
@@ -182,7 +182,7 @@ static int ath10k_init_configure_target(struct ath10k *ar) param_target =__cpu_to_le32 (param_host); host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_option_flag)); - ret =ath10k_bmi_write_memory (ar, host_addr, (u8 *)¶m_target,4 ); + ret =ath10k_bmi_write32 (ar, host_addr, (u8 *)¶m_target);if (ret) {ath10k_err ("setting firmware mode (2/2) failed\n" );return ret;
@@ -192,7 +192,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)/* We do all byte-swapping on the host */ host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_be)); - ret =ath10k_bmi_write_memory (ar, host_addr, (u8 *)¶m_target,4 ); + ret =ath10k_bmi_write32 (ar, host_addr, (u8 *)¶m_target);if (ret) {ath10k_err ("setting host CPU BE mode failed\n" );return ret;
@@ -202,7 +202,7 @@ static int ath10k_init_configure_target(struct ath10k *ar) param_target =__cpu_to_le32 (0 ); host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_fw_swap)); - ret =ath10k_bmi_write_memory (ar, host_addr, (u8 *)¶m_target,4 ); + ret =ath10k_bmi_write32 (ar, host_addr, (u8 *)¶m_target);if (ret) {ath10k_err ("setting FW data/desc swap flags failed\n" );
@@ -296,7 +296,7 @@ static int ath10k_init_transfer_bin_file(struct ath10k *ar,/* Determine where in Target RAM to write Board Data */ host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_board_ext_data)); -ath10k_bmi_read_memory (ar, host_addr, (u8 *)¶m_target,4 ); +ath10k_bmi_read32 (ar, host_addr, (u8 *)¶m_target); board_ext_address =__le32_to_cpu (param_target); ath10k_dbg(ATH10K_DBG_BOOT,
@@ -327,7 +327,7 @@ static int ath10k_init_transfer_bin_file(struct ath10k *ar, param_target =__cpu_to_le32 ((board_ext_data_size <<16 ) |1 ); host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_board_ext_data_config)); -ath10k_bmi_write_memory (ar, host_addr, (u8 *)¶m_target,4 ); +ath10k_bmi_write32 (ar, host_addr, (u8 *)¶m_target); fw_entry_size = board_data_size; }
@@ -368,7 +368,7 @@ static int ath10k_init_download_firmware(struct ath10k *ar)/* Determine where in Target RAM to write Board Data */ host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_board_data)); -ath10k_bmi_read_memory (ar, host_addr, (u8 *)¶m_target,4 ); +ath10k_bmi_read32 (ar, host_addr, (u8 *)¶m_target); address =__le32_to_cpu (param_target);if (!address) {
@@ -388,7 +388,7 @@ static int ath10k_init_download_firmware(struct ath10k *ar) param_target =__cpu_to_le32 (1 ); host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_board_data_initialized)); -ath10k_bmi_write_memory (ar, host_addr, (u8 *)¶m_target,4 ); +ath10k_bmi_write32 (ar, host_addr, (u8 *)¶m_target);/* Transfer One Time Programmable data */ address = ar->hw_params.patch_load_addr;
@@ -419,12 +419,12 @@ static int ath10k_init_download_firmware(struct ath10k *ar) param_target =__cpu_to_le32 (7 ); host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_dbg_uart_txpin)); -ath10k_bmi_write_memory (ar, host_addr, (u8 *)¶m_target,4 ); +ath10k_bmi_write32 (ar, host_addr, (u8 *)¶m_target); param_target =__cpu_to_le32 (1 ); host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_serial_enable)); -ath10k_bmi_write_memory (ar, host_addr, (u8 *)¶m_target,4 ); +ath10k_bmi_write32 (ar, host_addr, (u8 *)¶m_target); }else {/* * Explicitly setting UART prints to zero as target turns it on
@@ -433,7 +433,7 @@ static int ath10k_init_download_firmware(struct ath10k *ar) param_target =__cpu_to_le32 (0 ); host_addr =host_interest_item_address (ar->target_type,HI_ITEM (hi_serial_enable)); -ath10k_bmi_write_memory (ar, host_addr, (u8 *)¶m_target,4 ); +ath10k_bmi_write32 (ar, host_addr, (u8 *)¶m_target); }ath10k_dbg (ATH10K_DBG_CORE ,"Firmware downloaded\n" );
Signature · 1 line
1.7.9.5
PATCH 1/1 ath10k: add bmi_read32/bmi_write32 function
Quoted 17 lines · Janusz Dziedzic
Add ath10k_bmi_read32/ath10k_bmi_write32 functions and use them in core layer when read32/write32.
Signed-off-by Janusz Dziedzic <[email protected]>--- drivers/net/wireless/ath/ath10k/bmi.h | 10 ++++++++++ drivers/net/wireless/ath/ath10k/core.c | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-)drivers/net/wireless/ath/ath10k/bmi.h +0
-0@@ -191,6 +191,16 @@ int ath10k_bmi_read_memory(struct ath10k *ar, u32 address, void *buffer, u32 length);int ath10k_bmi_write_memory (struct ath10k *ar,u32 address,const void *buffer,u32 length);
drivers/net/wireless/ath/ath10k/bmi.h int ath10k_bmi_read_memory(struct ath10k *ar, u32 address, · line 203
Quoted 10 lines
drivers/net/wireless/ath/ath10k/bmi.h +10
-0+static inline int ath10k_bmi_read32 (struct ath10k *ar,u32 address, +void *buffer) +{ +return ath10k_bmi_read_memory (ar, address, buffer,sizeof (u32)); +} +static inline int ath10k_bmi_write32 (struct ath10k *ar,u32 address, +void *buffer) +{ +return ath10k_bmi_write_memory (ar, address, buffer,sizeof (u32)); +}
I think these functions should do endianess converions so it is not necessary at call sites anymore.
Also the buffer could be a u32* instead of a void* implicitly stating what the functions are meant to do.
-- Pozdrawiam / Best regards, Michal Kazior.
PATCH 1/1 ath10k: add bmi_read32/bmi_write32 function
Quoted 1 line
-----Original Message-----
From: [email protected] [mailto:ath9k-devel-
Quoted 38 lines
bounces at lists.ath9k.org] On Behalf Of Michal Kazior
Sent: 18 kwietnia 2013 10:17
To: ath9k-devel at lists.ath9k.org
Subject: Re: [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 functiondrivers/net/wireless/ath/ath10k/bmi.h int ath10k_bmi_read_memory(struct ath10k *ar,
Quoted 15 lines · Janusz Dziedzic
Add ath10k_bmi_read32/ath10k_bmi_write32 functions and use them in core layer when read32/write32.
Signed-off-by Janusz Dziedzic <[email protected]>--- drivers/net/wireless/ath/ath10k/bmi.h | 10 ++++++++++ drivers/net/wireless/ath/ath10k/core.c | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-)drivers/net/wireless/ath/ath10k/bmi.h +0
-0@@ -191,6 +191,16 @@ int ath10k_bmi_read_memory(struct ath10k *ar,u32 address,
drivers/net/wireless/ath/ath10k/bmi.h int ath10k_bmi_read_memory(struct ath10k *ar, u32 address,
Quoted 11 lines
drivers/net/wireless/ath/ath10k/bmi.h +8
-0void *buffer, u32 length);int ath10k_bmi_write_memory (struct ath10k *ar,u32 address,const void *buffer,u32 length); +static inline int ath10k_bmi_read32 (struct ath10k *ar,u32 address, +void *buffer) +{ +return ath10k_bmi_read_memory (ar, address, buffer,sizeof (u32)); } +static inline int ath10k_bmi_write32 (struct ath10k *ar,u32 address, +void *buffer) +{ +return ath10k_bmi_write_memory (ar, address, buffer,sizeof (u32)); }I think these functions should do endianess converions so it is not necessary at call sites anymore.
Quoted 3 lines
Also the buffer could be a u32* instead of a void* implicitly stating what the functions are meant to do.
OK, I will also change parameters list here and will move host_interest_item_address() to bmi layer. So, seems more work required here.
BR
Janusz
PATCH 1/1 ath10k: add bmi_read32/bmi_write32 function
In reply to Michal KaziorQuoted 32 lines · Michal Kazior
Quoted 17 lines · Janusz Dziedzic
Add ath10k_bmi_read32/ath10k_bmi_write32 functions and use them in core layer when read32/write32.
Signed-off-by Janusz Dziedzic <[email protected]>--- drivers/net/wireless/ath/ath10k/bmi.h | 10 ++++++++++ drivers/net/wireless/ath/ath10k/core.c | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-)drivers/net/wireless/ath/ath10k/bmi.h +0
-0@@ -191,6 +191,16 @@ int ath10k_bmi_read_memory(struct ath10k *ar, u32 address, void *buffer, u32 length);int ath10k_bmi_write_memory (struct ath10k *ar,u32 address,const void *buffer,u32 length);drivers/net/wireless/ath/ath10k/bmi.h int ath10k_bmi_read_memory(struct ath10k *ar, u32 address, · line 203
Quoted 10 lines
drivers/net/wireless/ath/ath10k/bmi.h +10
-0+static inline int ath10k_bmi_read32 (struct ath10k *ar,u32 address, +void *buffer) +{ +return ath10k_bmi_read_memory (ar, address, buffer,sizeof (u32)); +} +static inline int ath10k_bmi_write32 (struct ath10k *ar,u32 address, +void *buffer) +{ +return ath10k_bmi_write_memory (ar, address, buffer,sizeof (u32)); +}I think these functions should do endianess converions so it is not necessary at call sites anymore.
Quoted 2 lines
Also the buffer could be a u32* instead of a void* implicitly stating what the functions are meant to do.
Yeah, the idea is that the wrappers simplify writing to registers instead of duplicating the same code in every register access.
I think we can just follow what ath6kl does:
#define ath6kl_bmi_write_hi32(ar, item, val) \
({ \
u32 addr; \
__le32 v; \
\
addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item)); \
v = cpu_to_le32(val); \
ath6kl_bmi_write(ar, addr, (u8 *) &v, sizeof(v)); \
})#define ath6kl_bmi_read_hi32(ar, item, val) \
({ \
u32 addr, *check_type = val; \
__le32 tmp; \
int ret; \
\
(void) (check_type == val); \
addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item)); \
ret = ath6kl_bmi_read(ar, addr, (u8 *) &tmp, 4); \
*val = le32_to_cpu(tmp); \
ret; \
})Signature · 1 line
Kalle Valo