Commit 638a75b6 authored by Tobin C. Harding's avatar Tobin C. Harding Committed by Greg Kroah-Hartman

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: default avatarTobin C. Harding <me@tobin.cc>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f7172487
...@@ -312,28 +312,29 @@ static void tx_device_task(struct ks_wlan_private *priv) ...@@ -312,28 +312,29 @@ static void tx_device_task(struct ks_wlan_private *priv)
int ret; int ret;
DPRINTK(4, "\n"); DPRINTK(4, "\n");
if (cnt_txqbody(priv) > 0 && if (cnt_txqbody(priv) <= 0 ||
atomic_read(&priv->psstatus.status) != PS_SNOOZE) { atomic_read(&priv->psstatus.status) == PS_SNOOZE)
sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; return;
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) { 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, 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, 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) ...@@ -535,71 +536,64 @@ static void ks_sdio_interrupt(struct sdio_func *func)
priv = card->priv; priv = card->priv;
DPRINTK(4, "\n"); DPRINTK(4, "\n");
if (priv->dev_state >= DEVICE_STATE_BOOT) { if (priv->dev_state < DEVICE_STATE_BOOT)
ret = ks7010_sdio_read(priv, INT_PENDING, &status, goto queue_delayed_work;
sizeof(status));
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) { if (ret) {
DPRINTK(1, "read INT_PENDING Failed!!(%d)\n", ret); DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
goto queue_delayed_work; goto queue_delayed_work;
} }
DPRINTK(4, "INT_PENDING=%02X\n", rw_data); if (rw_data == GCR_B_ACTIVE) {
if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
/* schedule task for interrupt status */ atomic_set(&priv->psstatus.status, PS_WAKEUP);
/* bit7 -> Write General Communication B register */ priv->wakeup_count = 0;
/* 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);
} }
complete(&priv->psstatus.wakeup_wait);
} }
}
do { do {
/* read (WriteStatus/ReadDataSize FN1:00_0014) */ /* read (WriteStatus/ReadDataSize FN1:00_0014) */
ret = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, ret = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data,
sizeof(rw_data)); sizeof(rw_data));
if (ret) { if (ret) {
DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n", DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n", rw_data);
rw_data); goto queue_delayed_work;
goto queue_delayed_work; }
} DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data);
DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data); rsize = rw_data & RSIZE_MASK;
rsize = rw_data & RSIZE_MASK; if (rsize != 0) /* Read schedule */
if (rsize != 0) /* Read schedule */ ks_wlan_hw_rx(priv, (uint16_t)(rsize << 4));
ks_wlan_hw_rx(priv, (uint16_t)(rsize << 4));
if (rw_data & WSTATUS_MASK) {
if (rw_data & WSTATUS_MASK) { if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { if (cnt_txqbody(priv)) {
if (cnt_txqbody(priv)) { ks_wlan_hw_wakeup_request(priv);
ks_wlan_hw_wakeup_request(priv); queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
queue_delayed_work &priv->ks_wlan_hw.rw_wq, 1);
(priv->ks_wlan_hw. return;
ks7010sdio_wq,
&priv->ks_wlan_hw.
rw_wq, 1);
return;
}
} else {
tx_device_task(priv);
} }
} else {
tx_device_task(priv);
} }
} while (rsize); }
} } while (rsize);
queue_delayed_work: queue_delayed_work:
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment