[PATCH] libertas: cleanup - if-related codingstyle.
Andreas Henriksson
andreas at fjortis.info
Wed Jul 5 14:10:19 EDT 2006
Convert "if ((foo = alloc()) == NULL)" to "foo = alloc(); if (!foo)" and
similar coding-style cleanups related to if's.
Signed-off-by: Andreas Henriksson <andreas at fjortis.info>
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index b43aea1..56df05b 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -237,9 +237,8 @@ static int if_usb_probe(struct usb_inter
/* we found a bulk in endpoint */
PRINTM(INFO, "Bulk in size is %d\n",
endpoint->wMaxPacketSize);
- if (!
- (usb_cardp->rx_urb =
- usb_alloc_urb(0, GFP_KERNEL))) {
+ usb_cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!usb_cardp->rx_urb) {
PRINTM(INFO,
"Rx URB allocation failed\n");
goto dealloc;
@@ -261,9 +260,8 @@ static int if_usb_probe(struct usb_inter
&& ((endpoint->bmAttributes & BULK_ENDPOINT_MASK) ==
BULK_ENDPOINT_FOUND)) {
/* We found bulk out endpoint */
- if (!
- (usb_cardp->tx_urb =
- usb_alloc_urb(0, GFP_KERNEL))) {
+ usb_cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!usb_cardp->tx_urb) {
PRINTM(INFO,
"Tx URB allocation failed\n");
goto dealloc;
@@ -293,9 +291,9 @@ static int if_usb_probe(struct usb_inter
* about keeping pwlanpriv around since it will be set on our
* usb device data in -> add() -> sbi_register_dev().
*/
- if (!(pwlanpriv = usb_cardp->add(usb_cardp))) {
+ pwlanpriv = usb_cardp->add(usb_cardp);
+ if (!pwlanpriv)
goto dealloc;
- }
usb_get_dev(udev);
usb_set_intfdata(intf, usb_cardp);
@@ -334,9 +332,8 @@ static void if_usb_disconnect(struct usb
* Update Surprie removed to TRUE
* Free all the URB's allocated
*/
- if (!Adapter->SurpriseRemoved) {
+ if (!Adapter->SurpriseRemoved)
Adapter->SurpriseRemoved = 1;
- }
/* Unlink and free urb */
if_usb_free(cardp);
@@ -384,7 +381,8 @@ static int usb_tx_block(wlan_private * p
cardp->tx_urb->transfer_flags |= URB_ZERO_PACKET;
- if ((ret = usb_submit_urb(cardp->tx_urb, GFP_ATOMIC))) {
+ ret = usb_submit_urb(cardp->tx_urb, GFP_ATOMIC);
+ if (ret) {
/* transfer failed */
PRINTM(INFO, "usb_submit_urb Failed\n");
@@ -443,12 +441,14 @@ static int __if_usb_submit_rx_urb(wlan_p
ENTER();
- if (!(rinfo = kmalloc(sizeof(struct read_cb_info), GFP_ATOMIC))) {
+ rinfo = kmalloc(sizeof(struct read_cb_info), GFP_ATOMIC);
+ if (!rinfo) {
PRINTM(FATAL, "No free read_callback_info\n");
goto rx_ret;
}
- if (!(skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE))) {
+ skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE);
+ if (!skb) {
PRINTM(FATAL, "No free skb\n");
kfree(rinfo);
goto rx_ret;
@@ -468,7 +468,8 @@ static int __if_usb_submit_rx_urb(wlan_p
cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET;
PRINTM(INFO, "Pointer for rx_urb %p\n", cardp->rx_urb);
- if ((ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC))) {
+ ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC);
+ if (ret) {
/* handle failure conditions */
PRINTM(INFO, "Submit Rx URB failed\n");
ret = WLAN_STATUS_FAILURE;
diff --git a/drivers/net/wireless/libertas/wlan_11d.c b/drivers/net/wireless/libertas/wlan_11d.c
index ce5468f..31db3ce 100644
--- a/drivers/net/wireless/libertas/wlan_11d.c
+++ b/drivers/net/wireless/libertas/wlan_11d.c
@@ -341,9 +341,9 @@ static u8 wlan_region_chan_supported_11d
ENTER();
- if ((cfp = wlan_get_region_cfp_table(region, band, &cfp_no)) == NULL) {
+ cfp = wlan_get_region_cfp_table(region, band, &cfp_no);
+ if (!cfp)
return 0;
- }
for (idx = 0; idx < cfp_no; idx++) {
if (chan == (cfp + idx)->Channel) {
diff --git a/drivers/net/wireless/libertas/wlan_cmd.c b/drivers/net/wireless/libertas/wlan_cmd.c
index 98f4f84..354ee75 100644
--- a/drivers/net/wireless/libertas/wlan_cmd.c
+++ b/drivers/net/wireless/libertas/wlan_cmd.c
@@ -1780,7 +1780,8 @@ int AllocateCmdBuffer(wlan_private * pri
/* Allocate and initialize CmdCtrlNode */
ulBufSize = sizeof(struct CmdCtrlNode) * MRVDRV_NUM_OF_CMD_BUFFER;
- if (!(TempCmdArray = kmalloc(ulBufSize, GFP_KERNEL))) {
+ TempCmdArray = kmalloc(ulBufSize, GFP_KERNEL);
+ if (!TempCmdArray) {
PRINTM(INFO,
"ALLOC_CMD_BUF: Failed to allocate TempCmdArray\n");
ret = WLAN_STATUS_FAILURE;
@@ -1793,7 +1794,8 @@ int AllocateCmdBuffer(wlan_private * pri
/* Allocate and initialize command buffers */
ulBufSize = MRVDRV_SIZE_OF_CMD_BUFFER;
for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
- if (!(pTempVirtualAddr = kmalloc(ulBufSize, GFP_KERNEL))) {
+ pTempVirtualAddr = kmalloc(ulBufSize, GFP_KERNEL);
+ if (!pTempVirtualAddr) {
PRINTM(INFO,
"ALLOC_CMD_BUF: pTempVirtualAddr: out of memory\n");
ret = WLAN_STATUS_FAILURE;
diff --git a/drivers/net/wireless/libertas/wlan_cmdresp.c b/drivers/net/wireless/libertas/wlan_cmdresp.c
index 509272a..bbd28c3 100644
--- a/drivers/net/wireless/libertas/wlan_cmdresp.c
+++ b/drivers/net/wireless/libertas/wlan_cmdresp.c
@@ -908,7 +908,7 @@ int wlan_process_rx_command(wlan_private
}
/* If the command is not successful, cleanup and return failure */
- if ((Result != HostCmd_RESULT_OK || !(RespCmd & 0x8000))) {
+ if (Result != HostCmd_RESULT_OK || !(RespCmd & 0x8000)) {
PRINTM(INFO, "CMD_RESP: command reply %#x result=%#x\n",
resp->Command, resp->Result);
/*
diff --git a/drivers/net/wireless/libertas/wlan_fw.c b/drivers/net/wireless/libertas/wlan_fw.c
index db310d0..3a6094f 100644
--- a/drivers/net/wireless/libertas/wlan_fw.c
+++ b/drivers/net/wireless/libertas/wlan_fw.c
@@ -66,8 +66,9 @@ static int wlan_setup_station_hw(wlan_pr
sbi_disable_host_int(priv);
- if ((ret = request_firmware(&priv->firmware, fw_name,
- priv->hotplug_device)) < 0) {
+ ret = request_firmware(&priv->firmware, fw_name,
+ priv->hotplug_device);
+ if (ret < 0) {
PRINTM(MSG, "request_firmware() failed, error code = %#x\n",
ret);
PRINTM(MSG, "%s not found in /lib/firmware\n", fw_name);
@@ -143,7 +144,8 @@ static int wlan_allocate_adapter(wlan_pr
/* Allocate buffer to store the BSSID list */
ulBufSize = sizeof(struct bss_descriptor) * MRVDRV_MAX_BSSID_LIST;
- if (!(pTempScanTable = kmalloc(ulBufSize, GFP_KERNEL))) {
+ pTempScanTable = kmalloc(ulBufSize, GFP_KERNEL);
+ if (!pTempScanTable) {
wlan_free_adapter(priv);
return WLAN_STATUS_FAILURE;
}
@@ -290,9 +292,9 @@ int wlan_init_fw(wlan_private * priv)
ENTER();
/* Allocate adapter structure */
- if ((ret = wlan_allocate_adapter(priv)) != WLAN_STATUS_SUCCESS) {
+ ret = wlan_allocate_adapter(priv);
+ if (ret != WLAN_STATUS_SUCCESS)
goto done;
- }
/* init adapter structure */
wlan_init_adapter(priv);
@@ -308,7 +310,8 @@ #ifdef REASSOCIATION
#endif /* REASSOCIATION */
/* download fimrware etc. */
- if ((ret = wlan_setup_station_hw(priv)) != WLAN_STATUS_SUCCESS) {
+ ret = wlan_setup_station_hw(priv);
+ if (ret != WLAN_STATUS_SUCCESS) {
ret = WLAN_STATUS_FAILURE;
goto done;
}
More information about the libertas-dev
mailing list