From: Zhu Yi <yi.zhu@intel.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org, Zhu Yi <yi.zhu@intel.com>
Subject: [PATCH 19/28] iwlwifi: make iwl_get_bits inline function from macro
Date: Wed, 8 Aug 2007 15:33:36 +0800 [thread overview]
Message-ID: <1186558470949-git-send-email-yi.zhu@intel.com> (raw)
In-Reply-To: <11865584683474-git-send-email-yi.zhu@intel.com>
Make iwl_get_bits and iwl_set_bits inline functions from the original
macro implementation. Add IWL_SET_BITS16 for 16-bits value setting.
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
---
drivers/net/wireless/iwl-4965.c | 6 ++--
drivers/net/wireless/iwl-helpers.h | 53 +++++++++++++++++++++---------------
2 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c
index de5b541..258879c 100644
--- a/drivers/net/wireless/iwl-4965.c
+++ b/drivers/net/wireless/iwl-4965.c
@@ -2815,11 +2815,11 @@ int iwl4965_tx_queue_update_wr_ptr(struct iwl_priv *priv,
len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
- IWL_SET_BITS(shared_data->queues_byte_cnt_tbls[txq_id].
- tfd_offset[txq->q.first_empty], byte_cnt, len);
+ IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
+ tfd_offset[txq->q.first_empty], byte_cnt, len);
if (txq->q.first_empty < IWL4965_MAX_WIN_SIZE)
- IWL_SET_BITS(shared_data->queues_byte_cnt_tbls[txq_id].
+ IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
tfd_offset[IWL4965_QUEUE_SIZE + txq->q.first_empty],
byte_cnt, len);
diff --git a/drivers/net/wireless/iwl-helpers.h b/drivers/net/wireless/iwl-helpers.h
index c0ea48e..6281e3d 100644
--- a/drivers/net/wireless/iwl-helpers.h
+++ b/drivers/net/wireless/iwl-helpers.h
@@ -59,13 +59,14 @@
* NOTE: If used from IWL_GET_BITS then pos and len are compile-constants and
* will collapse to minimal code by the compiler.
*/
-#define iwl_get_bits(src, pos, len) \
-({ \
- u32 __tmp = le32_to_cpu(src); \
- __tmp >>= pos; \
- __tmp &= (1UL << len) - 1; \
- __tmp; \
-})
+static inline u32 iwl_get_bits(__le32 src, u8 pos, u8 len)
+{
+ u32 tmp = le32_to_cpu(src);
+
+ tmp >>= pos;
+ tmp &= (1UL << len) - 1;
+ return tmp;
+}
/**
* iwl_set_bits - Set a hardware bit-field value
@@ -80,13 +81,23 @@
* NOTE: If used IWL_SET_BITS pos and len will be compile-constants and
* will collapse to minimal code by the compiler.
*/
-#define iwl_set_bits(dst, pos, len, val) \
-({ \
- u32 __tmp = le32_to_cpu(*dst); \
- __tmp &= ~((1ULL << (pos+len)) - (1 << pos)); \
- __tmp |= (val & ((1UL << len) - 1)) << pos; \
- *dst = cpu_to_le32(__tmp); \
-})
+static inline void iwl_set_bits(__le32 *dst, u8 pos, u8 len, int val)
+{
+ u32 tmp = le32_to_cpu(*dst);
+
+ tmp &= ~((1UL << (pos + len)) - (1UL << pos));
+ tmp |= (val & ((1UL << len) - 1)) << pos;
+ *dst = cpu_to_le32(tmp);
+}
+
+static inline void iwl_set_bits16(__le16 *dst, u8 pos, u8 len, int val)
+{
+ u32 tmp = le16_to_cpu(*dst);
+
+ tmp &= ~((1UL << (pos + len)) - (1UL << pos));
+ tmp |= (val & ((1UL << len) - 1)) << pos;
+ *dst = cpu_to_le16(tmp);
+}
/*
* The bit-field definitions in iwl-xxxx-hw.h are in the form of:
@@ -110,18 +121,16 @@
* and iwl_{get,set}_bits.
*
*/
-#define _IWL_SET_BITS(s, d, o, l, v) \
- iwl_set_bits(&s.d, o, l, v)
-
#define IWL_SET_BITS(s, sym, v) \
- _IWL_SET_BITS((s), IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \
- IWL_ ## sym ## _LEN, (v))
+ iwl_set_bits(&(s).IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \
+ IWL_ ## sym ## _LEN, (v))
-#define _IWL_GET_BITS(s, v, o, l) \
- iwl_get_bits(s.v, o, l)
+#define IWL_SET_BITS16(s, sym, v) \
+ iwl_set_bits16(&(s).IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \
+ IWL_ ## sym ## _LEN, (v))
#define IWL_GET_BITS(s, sym) \
- _IWL_GET_BITS((s), IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \
+ iwl_get_bits((s).IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \
IWL_ ## sym ## _LEN)
/* Debug and printf string expansion helpers for printing bitfields */
--
1.5.2
next prev parent reply other threads:[~2007-08-08 7:37 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <11865584251026-git-send-email-yi.zhu@intel.com>
2007-08-08 7:33 ` [PATCH 01/28] iwlwifi: fix a lot of checkpatch.pl warnings Zhu Yi
2007-08-08 7:33 ` [PATCH 02/28] iwlwifi: add more Kconfig options Zhu Yi
2007-08-08 7:33 ` [PATCH 03/28] iwlwifi: Endianity fix for 4965 rate scaling Zhu Yi
2007-08-08 7:33 ` [PATCH 04/28] iwlwifi: Endianity fix for 4965 rx chain selection Zhu Yi
2007-08-08 7:33 ` [PATCH 05/28] iwlwifi: optimize iwl_queue_{inc|dec}_wrap implementation Zhu Yi
2007-08-08 7:33 ` [PATCH 06/28] iwlwifi: use mask operation to replace '%' for index calculation Zhu Yi
2007-08-08 7:33 ` [PATCH 07/28] iwlwifi: make local functions static Zhu Yi
2007-08-08 7:33 ` [PATCH 08/28] iwlwifi: some coding styles cleanup Zhu Yi
2007-08-08 7:33 ` [PATCH 09/28] iwlwifi: replace unnecessary GFP_ATOMIC with GFP_KERNEL Zhu Yi
2007-08-08 7:33 ` [PATCH 10/28] iwlwifi: remove priv stuff zeroing in iwl_pci_probe Zhu Yi
2007-08-08 7:33 ` [PATCH 11/28] iwlwifi: add name for some PCI configuration space registers Zhu Yi
2007-08-08 7:33 ` [PATCH 12/28] iwlwifi: shorten some structure and function names Zhu Yi
2007-08-08 7:33 ` [PATCH 13/28] iwlwifi: define iwl_rx_reply_scan only when CONFIG_IWLWIFI_DEBUG enabled Zhu Yi
2007-08-08 7:33 ` [PATCH 14/28] iwlwifi: remove redundant quotes Zhu Yi
2007-08-08 7:33 ` [PATCH 15/28] iwlwifi: Endianity fix for rxon host commands Zhu Yi
2007-08-08 7:33 ` [PATCH 16/28] iwlwifi: Endianity fix for beacon host command Zhu Yi
2007-08-08 7:33 ` [PATCH 17/28] iwlwifi: Endianity fix for channel number Zhu Yi
2007-08-08 7:33 ` [PATCH 18/28] iwlwifi: shorten more function names Zhu Yi
2007-08-08 7:33 ` Zhu Yi [this message]
2007-08-08 7:33 ` [PATCH 20/28] iwlwifi: remove BIT_FMT and BIT_ARG Zhu Yi
2007-08-08 7:33 ` [PATCH 21/28] iwlwifi: remove WLAN_FC_GET_TYPE macros Zhu Yi
2007-08-08 7:33 ` [PATCH 22/28] iwlwifi: replace private snprint_line with common hex_dump_xxx Zhu Yi
2007-08-08 7:33 ` [PATCH 23/28] iwlwifi: Endianity fix for frame control Zhu Yi
2007-08-08 7:33 ` [PATCH 24/28] iwlwifi: Endianity fix for ct kill configuration Zhu Yi
2007-08-08 7:33 ` [PATCH 25/28] iwlwifi: remove unused snprint_line Zhu Yi
2007-08-08 7:33 ` [PATCH 26/28] iwlwifi: Enhance ISR/RX/CMD debug messages Zhu Yi
2007-08-08 7:33 ` [PATCH 27/28] iwlwifi: Correct missing hardware detection in iwl_isr() Zhu Yi
2007-08-08 7:33 ` [PATCH 28/28] iwlwifi: Streamline irq_tasklet() when ISR debug not used Zhu Yi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1186558470949-git-send-email-yi.zhu@intel.com \
--to=yi.zhu@intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).