linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Arend van Spriel" <arend@broadcom.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, "Arend van Spriel" <arend@broadcom.com>
Subject: [PATCH 08/13] brcmutil: add macros for setting bitfields using mask/shift operations
Date: Sun, 3 Mar 2013 12:45:27 +0100	[thread overview]
Message-ID: <1362311132-29561-9-git-send-email-arend@broadcom.com> (raw)
In-Reply-To: <1362311132-29561-1-git-send-email-arend@broadcom.com>

Added inline functions to set bitfields in an unsigned integer variable.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 .../net/wireless/brcm80211/include/brcmu_utils.h   |   23 ++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
index 477b92a..82fcfe8 100644
--- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h
+++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
@@ -173,6 +173,29 @@ extern void brcmu_pktq_flush(struct pktq *pq, bool dir,
 /* ip address */
 struct ipv4_addr;
 
+/*
+ * bitfield macros using masking and shift
+ *
+ * remark: the mask parameter should be a shifted mask.
+ */
+static inline void brcmu_maskset32(u32 *var, u32 mask, u8 shift, u32 value)
+{
+	value = (value << shift) & mask;
+	*var = (*var & ~mask) | value;
+}
+static inline u32 brcmu_maskget32(u32 var, u32 mask, u8 shift)
+{
+	return (var & mask) >> shift;
+}
+static inline void brcmu_maskset16(u16 *var, u16 mask, u8 shift, u16 value)
+{
+	value = (value << shift) & mask;
+	*var = (*var & ~mask) | value;
+}
+static inline u16 brcmu_maskget16(u16 var, u16 mask, u8 shift)
+{
+	return (var & mask) >> shift;
+}
 
 /* externs */
 /* format/print */
-- 
1.7.6



  parent reply	other threads:[~2013-03-03 11:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-03 11:45 [PATCH 00/13] brcm80211: cleanup and rework changes Arend van Spriel
2013-03-03 11:45 ` [PATCH 01/13] brcmsmac: radio on led support Arend van Spriel
2013-03-03 11:45 ` [PATCH 02/13] brcmfmac: introduce tracepoints for message logging Arend van Spriel
2013-03-03 11:45 ` [PATCH 03/13] brcmfmac: make debug module parameter more clear Arend van Spriel
2013-03-03 11:45 ` [PATCH 04/13] brcmfmac: cleanup module information macros Arend van Spriel
2013-03-03 11:45 ` [PATCH 05/13] brcmfmac: only do auth_type workaround when no WPA or RSN IE is provided Arend van Spriel
2013-03-03 17:20   ` Johannes Berg
2013-03-03 19:47     ` Arend van Spriel
2013-03-03 20:35       ` Johannes Berg
2013-03-04  8:29         ` Arend van Spriel
2013-03-03 11:45 ` [PATCH 06/13] brcmfmac: remove null-pointer check in .sched_scan_start() callback Arend van Spriel
2013-03-03 11:45 ` [PATCH 07/13] brcmfmac: increase required skbuff headroom for firmware signalling Arend van Spriel
2013-03-03 11:45 ` Arend van Spriel [this message]
2013-03-03 11:45 ` [PATCH 09/13] brcmfmac: add support for TLV based " Arend van Spriel
2013-03-03 11:45 ` [PATCH 10/13] brcmfmac: release transmit packet in brcmf_txcomplete() Arend van Spriel
2013-03-03 11:45 ` [PATCH 11/13] brcmfmac: assure brcmf_txcomplete() is called in failure paths Arend van Spriel
2013-03-03 11:45 ` [PATCH 12/13] brcmutil: add dequeue function with filtering Arend van Spriel
2013-03-03 11:45 ` [PATCH 13/13] brcmfmac: add parameter to brcmf_proto_hdrpush() for data offset Arend van Spriel

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=1362311132-29561-9-git-send-email-arend@broadcom.com \
    --to=arend@broadcom.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).