From: Kalle Valo Date: Thu, 18 Apr 2013 13:53:33 +0300 Subject: [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function In-Reply-To: <516FABED.6050606@tieto.com> (Michal Kazior's message of "Thu, 18 Apr 2013 10:16:45 +0200") References: <1366272512-20489-1-git-send-email-janusz.dziedzic@tieto.com> <516FABED.6050606@tieto.com> Message-ID: <87txn4nm8i.fsf@kamboji.qca.qualcomm.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ath9k-devel@lists.ath9k.org Michal Kazior writes: > On 18/04/13 10:08, Janusz Dziedzic wrote: >> Add ath10k_bmi_read32/ath10k_bmi_write32 functions >> and use them in core layer when read32/write32. >> >> Signed-off-by: Janusz Dziedzic >> --- >> drivers/net/wireless/ath/ath10k/bmi.h | 10 ++++++++++ >> drivers/net/wireless/ath/ath10k/core.c | 24 ++++++++++++------------ >> 2 files changed, 22 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/net/wireless/ath/ath10k/bmi.h b/drivers/net/wireless/ath/ath10k/bmi.h >> index e2bd70b..2035d5d 100644 >> --- a/drivers/net/wireless/ath/ath10k/bmi.h >> +++ b/drivers/net/wireless/ath/ath10k/bmi.h >> @@ -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)); >> +} > > 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. 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; \ }) -- Kalle Valo