Commit 26fba8e4 authored by Matthias Beyer's avatar Matthias Beyer Committed by Greg Kroah-Hartman

Staging: bcm: InterfaceTx.c: Outsourced code chunk

This patch outsources a chunk of code into an own function and refactors
the variable names inside the new function.
Signed-off-by: default avatarMatthias Beyer <mail@beyermatthias.de>
Acked-by: default avatarKevin McKinney <klmckinney1@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5faf3300
#include "headers.h" #include "headers.h"
/*this is transmit call-back(BULK OUT)*/ static void prepare_low_power_mode(struct urb *urb,
static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) struct bcm_interface_adapter *interface,
struct bcm_mini_adapter *ps_adapter,
struct bcm_mini_adapter *ad,
struct bcm_link_request *p_control_msg,
bool *b_power_down_msg)
{ {
struct bcm_usb_tcb *pTcb = (struct bcm_usb_tcb *)urb->context; if (((p_control_msg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) &&
struct bcm_interface_adapter *psIntfAdapter = pTcb->psIntfAdapter; (p_control_msg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE))) {
struct bcm_link_request *pControlMsg =
(struct bcm_link_request *)urb->transfer_buffer;
struct bcm_mini_adapter *psAdapter = psIntfAdapter->psAdapter;
bool bpowerDownMsg = false;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if (unlikely(netif_msg_tx_done(Adapter)))
pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name,
urb->status);
if (urb->status != STATUS_SUCCESS) {
if (urb->status == -EPIPE) {
psIntfAdapter->psAdapter->bEndPointHalted = TRUE;
wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
} else {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND,
DBG_LVL_ALL,
"Tx URB has got cancelled. status :%d",
urb->status);
}
}
pTcb->bUsed = false; *b_power_down_msg = TRUE;
atomic_dec(&psIntfAdapter->uNumTcbUsed);
if (TRUE == psAdapter->bPreparingForLowPowerMode) {
if (((pControlMsg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) &&
(pControlMsg->szData[1] ==
TARGET_CAN_GO_TO_IDLE_MODE))) {
bpowerDownMsg = TRUE;
/* /*
* This covers the bus err while Idle Request msg * This covers the bus err while Idle Request msg
* sent down. * sent down.
*/ */
if (urb->status != STATUS_SUCCESS) { if (urb->status != STATUS_SUCCESS) {
psAdapter->bPreparingForLowPowerMode = false; ps_adapter->bPreparingForLowPowerMode = false;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND,
DBG_LVL_ALL, DBG_LVL_ALL,
"Idle Mode Request msg failed to reach to Modem"); "Idle Mode Request msg failed to reach to Modem");
/* Signalling the cntrl pkt path in Ioctl */ /* Signalling the cntrl pkt path in Ioctl */
wake_up(&psAdapter->lowpower_mode_wait_queue); wake_up(&ps_adapter->lowpower_mode_wait_queue);
StartInterruptUrb(psIntfAdapter); StartInterruptUrb(interface);
goto err_exit; return;
} }
if (psAdapter->bDoSuspend == false) { if (ps_adapter->bDoSuspend == false) {
psAdapter->IdleMode = TRUE; ps_adapter->IdleMode = TRUE;
/* since going in Idle mode completed hence making this var false */ /* since going in Idle mode completed hence making this var false */
psAdapter->bPreparingForLowPowerMode = false; ps_adapter->bPreparingForLowPowerMode = false;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND,
DBG_LVL_ALL, DBG_LVL_ALL,
"Host Entered in Idle Mode State..."); "Host Entered in Idle Mode State...");
/* Signalling the cntrl pkt path in Ioctl*/ /* Signalling the cntrl pkt path in Ioctl*/
wake_up(&psAdapter->lowpower_mode_wait_queue); wake_up(&ps_adapter->lowpower_mode_wait_queue);
} }
} else if ((pControlMsg->Leader.Status == } else if ((p_control_msg->Leader.Status == LINK_UP_CONTROL_REQ) &&
LINK_UP_CONTROL_REQ) && (p_control_msg->szData[0] == LINK_UP_ACK) &&
(pControlMsg->szData[0] == LINK_UP_ACK) && (p_control_msg->szData[1] == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) &&
(pControlMsg->szData[1] == (p_control_msg->szData[2] == SHUTDOWN_ACK_FROM_DRIVER)) {
LINK_SHUTDOWN_REQ_FROM_FIRMWARE) &&
(pControlMsg->szData[2] == SHUTDOWN_ACK_FROM_DRIVER)) {
/* /*
* This covers the bus err while shutdown Request * This covers the bus err while shutdown Request
* msg sent down. * msg sent down.
*/ */
if (urb->status != STATUS_SUCCESS) { if (urb->status != STATUS_SUCCESS) {
psAdapter->bPreparingForLowPowerMode = false; ps_adapter->bPreparingForLowPowerMode = false;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND,
DBG_LVL_ALL, DBG_LVL_ALL,
"Shutdown Request Msg failed to reach to Modem"); "Shutdown Request Msg failed to reach to Modem");
/* Signalling the cntrl pkt path in Ioctl */ /* Signalling the cntrl pkt path in Ioctl */
wake_up(&psAdapter->lowpower_mode_wait_queue); wake_up(&ps_adapter->lowpower_mode_wait_queue);
StartInterruptUrb(psIntfAdapter); StartInterruptUrb(interface);
goto err_exit; return;
} }
bpowerDownMsg = TRUE; *b_power_down_msg = TRUE;
if (psAdapter->bDoSuspend == false) { if (ps_adapter->bDoSuspend == false) {
psAdapter->bShutStatus = TRUE; ps_adapter->bShutStatus = TRUE;
/* /*
* since going in shutdown mode completed hence * since going in shutdown mode completed hence
* making this var false * making this var false
*/ */
psAdapter->bPreparingForLowPowerMode = false; ps_adapter->bPreparingForLowPowerMode = false;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND,
DBG_LVL_ALL, DBG_LVL_ALL,
"Host Entered in shutdown Mode State..."); "Host Entered in shutdown Mode State...");
/* Signalling the cntrl pkt path in Ioctl */ /* Signalling the cntrl pkt path in Ioctl */
wake_up(&psAdapter->lowpower_mode_wait_queue); wake_up(&ps_adapter->lowpower_mode_wait_queue);
} }
} }
if (psAdapter->bDoSuspend && bpowerDownMsg) { if (ps_adapter->bDoSuspend && *b_power_down_msg) {
/* issuing bus suspend request */ /* issuing bus suspend request */
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,
DBG_LVL_ALL,
"Issuing the Bus suspend request to USB stack"); "Issuing the Bus suspend request to USB stack");
psIntfAdapter->bPreparingForBusSuspend = TRUE; interface->bPreparingForBusSuspend = TRUE;
schedule_work(&psIntfAdapter->usbSuspendWork); schedule_work(&interface->usbSuspendWork);
}
}
/*this is transmit call-back(BULK OUT)*/
static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/)
{
struct bcm_usb_tcb *pTcb = (struct bcm_usb_tcb *)urb->context;
struct bcm_interface_adapter *psIntfAdapter = pTcb->psIntfAdapter;
struct bcm_link_request *pControlMsg =
(struct bcm_link_request *)urb->transfer_buffer;
struct bcm_mini_adapter *psAdapter = psIntfAdapter->psAdapter;
bool bpowerDownMsg = false;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if (unlikely(netif_msg_tx_done(Adapter)))
pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name,
urb->status);
if (urb->status != STATUS_SUCCESS) {
if (urb->status == -EPIPE) {
psIntfAdapter->psAdapter->bEndPointHalted = TRUE;
wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
} else {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND,
DBG_LVL_ALL,
"Tx URB has got cancelled. status :%d",
urb->status);
}
} }
pTcb->bUsed = false;
atomic_dec(&psIntfAdapter->uNumTcbUsed);
if (TRUE == psAdapter->bPreparingForLowPowerMode) {
prepare_low_power_mode(urb, psIntfAdapter, psAdapter, Adapter,
pControlMsg, &bpowerDownMsg);
} }
err_exit:
usb_free_coherent(urb->dev, urb->transfer_buffer_length, usb_free_coherent(urb->dev, urb->transfer_buffer_length,
urb->transfer_buffer, urb->transfer_dma); urb->transfer_buffer, urb->transfer_dma);
} }
......
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