Re: [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function

2013-04-18 Thread Michal Kazior
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 janusz.dzied...@tieto.com
 ---
   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.


-- Pozdrawiam / Best regards, Michal Kazior.
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function

2013-04-18 Thread Janusz.Dziedzic
-Original Message-
From: ath9k-devel-boun...@lists.ath9k.org [mailto:ath9k-devel-
boun...@lists.ath9k.org] On Behalf Of Michal Kazior
Sent: 18 kwietnia 2013 10:17
To: ath9k-devel@lists.ath9k.org
Subject: Re: [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32
function

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 janusz.dzied...@tieto.com
 ---
   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.

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

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function

2013-04-18 Thread Kalle Valo
Michal Kazior michal.kaz...@tieto.com 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 janusz.dzied...@tieto.com
 ---
   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
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel