From: Quytelda Kahja <quytelda@tamalin.org>
To: gregkh@linuxfoundation.org, wsa@the-dreams.de
Cc: devel@driverdev.osuosl.org,
driverdev-devel@linuxdriverproject.org,
linux-kernel@vger.kernel.org,
Quytelda Kahja <quytelda@tamalin.org>
Subject: [PATCH 1/4] Staging: ks7010: sdio: Fix multiple use of arguments in RX/TX queue macros.
Date: Fri, 16 Feb 2018 18:20:50 -0800 [thread overview]
Message-ID: <20180217022053.24692-1-quytelda@tamalin.org> (raw)
Use GCC extensions to prevent macro arguments from accidentally being evaluated
multiple times when the macro is called.
Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
drivers/staging/ks7010/ks7010_sdio.c | 40 ++++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 8cfdff198334..ffa7e2382353 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -32,19 +32,33 @@ static const struct sdio_device_id ks7010_sdio_ids[] = {
};
MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids);
-#define inc_txqhead(priv) \
- (priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE)
-#define inc_txqtail(priv) \
- (priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE)
-#define cnt_txqbody(priv) \
- (((priv->tx_dev.qtail + TX_DEVICE_BUFF_SIZE) - (priv->tx_dev.qhead)) % TX_DEVICE_BUFF_SIZE)
-
-#define inc_rxqhead(priv) \
- (priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE)
-#define inc_rxqtail(priv) \
- (priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE)
-#define cnt_rxqbody(priv) \
- (((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - (priv->rx_dev.qhead)) % RX_DEVICE_BUFF_SIZE)
+#define inc_txqhead(priv) \
+ ({ typeof(priv) priv_ = (priv); \
+ unsigned int next_qhead = priv_->tx_dev.qhead + 1; \
+ priv_->tx_dev.qhead = next_qhead % TX_DEVICE_BUFF_SIZE; })
+#define inc_txqtail(priv) \
+ ({ typeof(priv) priv_ = (priv); \
+ unsigned int next_qtail = priv_->tx_dev.qtail + 1; \
+ priv_->tx_dev.qtail = next_qtail % TX_DEVICE_BUFF_SIZE; })
+#define cnt_txqbody(priv) \
+ ({ typeof(priv) priv_ = (priv); \
+ unsigned int left_cnt = \
+ priv_->tx_dev.qtail + TX_DEVICE_BUFF_SIZE; \
+ (left_cnt - (priv_->tx_dev.qhead)) % TX_DEVICE_BUFF_SIZE; })
+
+#define inc_rxqhead(priv) \
+ ({ typeof(priv) priv_ = (priv); \
+ unsigned int next_qhead = priv_->rx_dev.qhead + 1; \
+ priv_->rx_dev.qhead = next_qhead % RX_DEVICE_BUFF_SIZE; })
+#define inc_rxqtail(priv) \
+ ({ typeof(priv) priv_ = (priv); \
+ unsigned int next_qtail = priv_->rx_dev.qtail + 1; \
+ priv_->rx_dev.qtail = next_qtail % RX_DEVICE_BUFF_SIZE; })
+#define cnt_rxqbody(priv) \
+ ({ typeof(priv) priv_ = (priv); \
+ unsigned int left_cnt = \
+ priv_->rx_dev.qtail + RX_DEVICE_BUFF_SIZE; \
+ (left_cnt - (priv_->rx_dev.qhead)) % RX_DEVICE_BUFF_SIZE; })
/* Read single byte from device address into byte (CMD52) */
static int ks7010_sdio_readb(struct ks_wlan_private *priv, unsigned int address,
--
2.16.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next reply other threads:[~2018-02-17 2:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-17 2:20 Quytelda Kahja [this message]
2018-02-19 9:25 ` Dan Carpenter
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=20180217022053.24692-1-quytelda@tamalin.org \
--to=quytelda@tamalin.org \
--cc=devel@driverdev.osuosl.org \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@the-dreams.de \
/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
all inboxes | Powered by JetHome®