From: "Franky Lin" <frankyl@broadcom.com>
To: gregkh@suse.de
Cc: devel@linuxdriverproject.org, linux-wireless@vger.kernel.org
Subject: [PATCH 10/20] staging: brcm80211: reduce indentation level in dhd_sdio.c #1
Date: Sun, 2 Oct 2011 10:14:35 -0700 [thread overview]
Message-ID: <1317575685-3156-11-git-send-email-frankyl@broadcom.com> (raw)
In-Reply-To: <1317575685-3156-1-git-send-email-frankyl@broadcom.com>
From: Roland Vossen <rvossen@broadcom.com>
By introducing two new functions.
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Arend van Spriel <arend@broadcom.com>
Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
Signed-off-by: Franky Lin <frankyl@broadcom.com>
---
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 108 ++++++++++++------------
1 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
index 4992d4d..169c6b2 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
@@ -1335,11 +1335,10 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq)
if (pnext) {
brcmf_dbg(GLOM, "allocated %d-byte packet chain for %d subframes\n",
totlen, num);
- if (BRCMF_GLOM_ON() && bus->nextlen) {
- if (totlen != bus->nextlen) {
- brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n",
- bus->nextlen, totlen, rxseq);
- }
+ if (BRCMF_GLOM_ON() && bus->nextlen &&
+ totlen != bus->nextlen) {
+ brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n",
+ bus->nextlen, totlen, rxseq);
}
bus->glom = pfirst;
pfirst = pnext = NULL;
@@ -1753,6 +1752,51 @@ done:
brcmf_sdbrcm_ioctl_resp_wake(bus);
}
+/* Pad read to blocksize for efficiency */
+static void brcmf_pad(struct brcmf_bus *bus, u16 *pad, u16 *rdlen)
+{
+ if (bus->roundup && bus->blocksize && *rdlen > bus->blocksize) {
+ *pad = bus->blocksize - (*rdlen % bus->blocksize);
+ if (*pad <= bus->roundup && *pad < bus->blocksize &&
+ *rdlen + *pad + BRCMF_FIRSTREAD < MAX_RX_DATASZ)
+ *rdlen += *pad;
+ } else if (*rdlen % BRCMF_SDALIGN) {
+ *rdlen += BRCMF_SDALIGN - (*rdlen % BRCMF_SDALIGN);
+ }
+}
+
+static void
+brcmf_alloc_pkt_and_read(struct brcmf_bus *bus, u16 rdlen,
+ struct sk_buff **pkt, u8 **rxbuf)
+{
+ int sdret; /* Return code from calls */
+
+ *pkt = brcmu_pkt_buf_get_skb(rdlen + BRCMF_SDALIGN);
+ if (*pkt == NULL)
+ return;
+
+ pkt_align(*pkt, rdlen, BRCMF_SDALIGN);
+ *rxbuf = (u8 *) ((*pkt)->data);
+ /* Read the entire frame */
+ sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad,
+ SDIO_FUNC_2, F2SYNC,
+ *rxbuf, rdlen, *pkt);
+ bus->f2rxdata++;
+
+ if (sdret < 0) {
+ brcmf_dbg(ERROR, "(nextlen): read %d bytes failed: %d\n",
+ rdlen, sdret);
+ brcmu_pkt_buf_free_skb(*pkt);
+ bus->drvr->rx_errors++;
+ /* Force retry w/normal header read.
+ * Don't attempt NAK for
+ * gSPI
+ */
+ brcmf_sdbrcm_rxfail(bus, true, true);
+ *pkt = NULL;
+ }
+}
+
/* Return true if there may be more frames to read */
static uint
brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished)
@@ -1801,63 +1845,19 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished)
bus->nextlen = 0;
rdlen = len = nextlen << 4;
+ brcmf_pad(bus, &pad, &rdlen);
- /* Pad read to blocksize for efficiency */
- if (bus->roundup && bus->blocksize
- && (rdlen > bus->blocksize)) {
- pad =
- bus->blocksize -
- (rdlen % bus->blocksize);
- if ((pad <= bus->roundup)
- && (pad < bus->blocksize)
- && ((rdlen + pad + BRCMF_FIRSTREAD) <
- MAX_RX_DATASZ))
- rdlen += pad;
- } else if (rdlen % BRCMF_SDALIGN) {
- rdlen += BRCMF_SDALIGN -
- (rdlen % BRCMF_SDALIGN);
- }
-
- /* We use bus->rxctl buffer in WinXP for initial
- * control pkt receives.
- * Later we use buffer-poll for data as well
- * as control packets.
- * This is required because dhd receives full
- * frame in gSPI unlike SDIO.
+ /*
* After the frame is received we have to
* distinguish whether it is data
* or non-data frame.
*/
- /* Allocate a packet buffer */
- pkt = brcmu_pkt_buf_get_skb(rdlen + BRCMF_SDALIGN);
- if (!pkt) {
+ brcmf_alloc_pkt_and_read(bus, rdlen, &pkt, &rxbuf);
+ if (pkt == NULL) {
/* Give up on data, request rtx of events */
- brcmf_dbg(ERROR, "(nextlen): brcmu_pkt_buf_get_skb failed: len %d rdlen %d expected rxseq %d\n",
+ brcmf_dbg(ERROR, "(nextlen): brcmf_alloc_pkt_and_read failed: len %d rdlen %d expected rxseq %d\n",
len, rdlen, rxseq);
continue;
- } else {
- pkt_align(pkt, rdlen, BRCMF_SDALIGN);
- rxbuf = (u8 *) (pkt->data);
- /* Read the entire frame */
- sdret = brcmf_sdcard_recv_buf(bus->sdiodev,
- bus->sdiodev->sbwad,
- SDIO_FUNC_2, F2SYNC,
- rxbuf, rdlen,
- pkt);
- bus->f2rxdata++;
-
- if (sdret < 0) {
- brcmf_dbg(ERROR, "(nextlen): read %d bytes failed: %d\n",
- rdlen, sdret);
- brcmu_pkt_buf_free_skb(pkt);
- bus->drvr->rx_errors++;
- /* Force retry w/normal header read.
- * Don't attempt NAK for
- * gSPI
- */
- brcmf_sdbrcm_rxfail(bus, true, true);
- continue;
- }
}
/* Now check the header */
--
1.7.1
next prev parent reply other threads:[~2011-10-02 17:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-02 17:14 [PATCH 00/20] staging: brcm80211: code clean up Franky Lin
2011-10-02 17:14 ` [PATCH 01/20] staging: brmc80211: removed some unused fmac variable declarations Franky Lin
2011-10-02 17:14 ` [PATCH 02/20] staging: brcm80211: removed unused smac tx ampdu packet queue Franky Lin
2011-10-02 17:14 ` [PATCH 03/20] staging: brcm80211: cleaning up tx rate control code in softmac Franky Lin
2011-10-02 17:14 ` [PATCH 04/20] staging: brcm80211: various __iomem additions to softmac Franky Lin
2011-10-10 14:23 ` Rafał Miłecki
2011-10-10 17:45 ` Dan Carpenter
2011-10-02 17:14 ` [PATCH 05/20] staging: brcm80211: reduced softmac sparse warnings Franky Lin
2011-10-02 17:14 ` [PATCH 06/20] staging: brcm80211: added __iomem qualifier to softmac main.c Franky Lin
2011-10-02 17:14 ` [PATCH 07/20] staging: brcm80211: added __iomem qualifier to softmac dma.c Franky Lin
2011-10-02 17:14 ` [PATCH 08/20] staging: brcm80211: added __iomem qualifier to softmac phy Franky Lin
2011-10-02 17:14 ` [PATCH 09/20] staging: brcm80211: only allow one call to add_interface callback Franky Lin
2011-10-02 17:14 ` Franky Lin [this message]
2011-10-02 17:14 ` [PATCH 11/20] staging: brcm80211: reduce indentation level in dhd_sdio.c #2 Franky Lin
2011-10-02 17:14 ` [PATCH 12/20] staging: brcm80211: reduce indentation level in dhd_sdio.c #3 Franky Lin
2011-10-02 17:14 ` [PATCH 13/20] staging: brcm80211: reducing indentation levels in bcmsdh_sdmmc.c Franky Lin
2011-10-02 17:14 ` [PATCH 14/20] staging: brcm80211: removed unused fullmac spinlock Franky Lin
2011-10-02 17:14 ` [PATCH 15/20] staging: brcm80211: removed unused softmac mimo disable code Franky Lin
2011-10-02 17:14 ` [PATCH 16/20] staging: brcm80211: removed fullmac function brcmf_bus_devreset() Franky Lin
2011-10-02 17:14 ` [PATCH 17/20] staging: brcm80211: removed 'enforce_mutex' parameter in fullmac Franky Lin
2011-10-02 17:14 ` [PATCH 18/20] staging: brcm80211: renamed ioctl functions/structs to dcmd Franky Lin
2011-10-02 17:14 ` [PATCH 19/20] staging: brcm80211: cleaned up buffer len defines in fullmac Franky Lin
2011-10-02 17:14 ` [PATCH 20/20] staging: brcm80211: removed functionality to disable N mode Franky Lin
2011-10-03 23:23 ` [PATCH 00/20] staging: brcm80211: code clean up Greg KH
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=1317575685-3156-11-git-send-email-frankyl@broadcom.com \
--to=frankyl@broadcom.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@suse.de \
--cc=linux-wireless@vger.kernel.org \
/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).