summaryrefslogtreecommitdiff
path: root/drivers/staging/ks7010
diff options
context:
space:
mode:
authorTobin C. Harding <me@tobin.cc>2017-04-10 13:15:43 +1000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-04-11 16:03:36 +0200
commit638a75b653c208ff86adeba8fa770685721343e9 (patch)
treea7ba8aa7d456f4c9485aca2ed0bc3b81b87bfaa2 /drivers/staging/ks7010
parentf717248713c9672526005fefd85d6d5bc44d8603 (diff)
staging: ks7010: invert conditional, reduce indentation
A number of functions have blocks of code guarded by an if statement. if (foo) { /* block of code */ } This can, on occasion, more succinctly be expressed as if (!foo) return /* block of code */ This change will mean a number of whitespace issues need to be addressed/fixed. The diff can be a little hard to read when there are multiple lines that are very similar (for example error return code). Splitting the indentation reduction and the whitespace fixes into two separate patches was not found to aid reading the diff. Therefor we fix the whitespace issues at the same time. We need to be very sure to not make any changes to the program logic, this is ensured by only doing what is stated - invert the conditional, fix whitespace. Invert if statement conditionals. Return if new conditional evaluates to true. Reduce level of indentation in subsequent code. Fix white space issues. Signed-off-by: Tobin C. Harding <me@tobin.cc> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/ks7010')
-rw-r--r--drivers/staging/ks7010/ks7010_sdio.c144
1 files changed, 69 insertions, 75 deletions
diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 0185d3d924d8..b34850dddf30 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -312,28 +312,29 @@ static void tx_device_task(struct ks_wlan_private *priv)
int ret;
DPRINTK(4, "\n");
- if (cnt_txqbody(priv) > 0 &&
- atomic_read(&priv->psstatus.status) != PS_SNOOZE) {
- sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];
- if (priv->dev_state >= DEVICE_STATE_BOOT) {
- ret = write_to_device(priv, sp->sendp, sp->size);
- if (ret) {
- DPRINTK(1, "write_to_device error !!(%d)\n", ret);
- queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
- &priv->ks_wlan_hw.rw_wq, 1);
- return;
- }
- }
- kfree(sp->sendp); /* allocated memory free */
- if (sp->complete_handler) /* TX Complete */
- (*sp->complete_handler) (sp->arg1, sp->arg2);
- inc_txqhead(priv);
+ if (cnt_txqbody(priv) <= 0 ||
+ atomic_read(&priv->psstatus.status) == PS_SNOOZE)
+ return;
- if (cnt_txqbody(priv) > 0) {
+ sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];
+ if (priv->dev_state >= DEVICE_STATE_BOOT) {
+ ret = write_to_device(priv, sp->sendp, sp->size);
+ if (ret) {
+ DPRINTK(1, "write_to_device error !!(%d)\n", ret);
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
- &priv->ks_wlan_hw.rw_wq, 0);
+ &priv->ks_wlan_hw.rw_wq, 1);
+ return;
}
}
+ kfree(sp->sendp);
+ if (sp->complete_handler) /* TX Complete */
+ (*sp->complete_handler) (sp->arg1, sp->arg2);
+ inc_txqhead(priv);
+
+ if (cnt_txqbody(priv) > 0) {
+ queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
+ &priv->ks_wlan_hw.rw_wq, 0);
+ }
}
int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,
@@ -535,71 +536,64 @@ static void ks_sdio_interrupt(struct sdio_func *func)
priv = card->priv;
DPRINTK(4, "\n");
- if (priv->dev_state >= DEVICE_STATE_BOOT) {
- ret = ks7010_sdio_read(priv, INT_PENDING, &status,
- sizeof(status));
+ if (priv->dev_state < DEVICE_STATE_BOOT)
+ goto queue_delayed_work;
+
+ ret = ks7010_sdio_read(priv, INT_PENDING, &status, sizeof(status));
+ if (ret) {
+ DPRINTK(1, "read INT_PENDING Failed!!(%d)\n", ret);
+ goto queue_delayed_work;
+ }
+ DPRINTK(4, "INT_PENDING=%02X\n", rw_data);
+
+ /* schedule task for interrupt status */
+ /* bit7 -> Write General Communication B register */
+ /* read (General Communication B register) */
+ /* bit5 -> Write Status Idle */
+ /* bit2 -> Read Status Busy */
+ if (status & INT_GCR_B ||
+ atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
+ ret = ks7010_sdio_read(priv, GCR_B, &rw_data,
+ sizeof(rw_data));
if (ret) {
- DPRINTK(1, "read INT_PENDING Failed!!(%d)\n", ret);
+ DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
goto queue_delayed_work;
}
- DPRINTK(4, "INT_PENDING=%02X\n", rw_data);
-
- /* schedule task for interrupt status */
- /* bit7 -> Write General Communication B register */
- /* read (General Communication B register) */
- /* bit5 -> Write Status Idle */
- /* bit2 -> Read Status Busy */
- if (status & INT_GCR_B ||
- atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
- ret = ks7010_sdio_read(priv, GCR_B, &rw_data,
- sizeof(rw_data));
- if (ret) {
- DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
- goto queue_delayed_work;
- }
- /* DPRINTK(1, "GCR_B=%02X\n", rw_data); */
- if (rw_data == GCR_B_ACTIVE) {
- if (atomic_read(&priv->psstatus.status) ==
- PS_SNOOZE) {
- atomic_set(&priv->psstatus.status,
- PS_WAKEUP);
- priv->wakeup_count = 0;
- }
- complete(&priv->psstatus.wakeup_wait);
+ if (rw_data == GCR_B_ACTIVE) {
+ if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
+ atomic_set(&priv->psstatus.status, PS_WAKEUP);
+ priv->wakeup_count = 0;
}
+ complete(&priv->psstatus.wakeup_wait);
}
+ }
- do {
- /* read (WriteStatus/ReadDataSize FN1:00_0014) */
- ret = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data,
- sizeof(rw_data));
- if (ret) {
- DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n",
- rw_data);
- goto queue_delayed_work;
- }
- DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data);
- rsize = rw_data & RSIZE_MASK;
- if (rsize != 0) /* Read schedule */
- ks_wlan_hw_rx(priv, (uint16_t)(rsize << 4));
-
- if (rw_data & WSTATUS_MASK) {
- if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
- if (cnt_txqbody(priv)) {
- ks_wlan_hw_wakeup_request(priv);
- queue_delayed_work
- (priv->ks_wlan_hw.
- ks7010sdio_wq,
- &priv->ks_wlan_hw.
- rw_wq, 1);
- return;
- }
- } else {
- tx_device_task(priv);
+ do {
+ /* read (WriteStatus/ReadDataSize FN1:00_0014) */
+ ret = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data,
+ sizeof(rw_data));
+ if (ret) {
+ DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n", rw_data);
+ goto queue_delayed_work;
+ }
+ DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data);
+ rsize = rw_data & RSIZE_MASK;
+ if (rsize != 0) /* Read schedule */
+ ks_wlan_hw_rx(priv, (uint16_t)(rsize << 4));
+
+ if (rw_data & WSTATUS_MASK) {
+ if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
+ if (cnt_txqbody(priv)) {
+ ks_wlan_hw_wakeup_request(priv);
+ queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
+ &priv->ks_wlan_hw.rw_wq, 1);
+ return;
}
+ } else {
+ tx_device_task(priv);
}
- } while (rsize);
- }
+ }
+ } while (rsize);
queue_delayed_work:
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,