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

Staging: bcm: led_control.c: Outsourced adapter driver state handling

Signed-off-by: default avatarMatthias Beyer <mail@beyermatthias.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9bcfab20
...@@ -661,69 +661,21 @@ static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter, ...@@ -661,69 +661,21 @@ static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) static void handle_adapter_driver_state(struct bcm_mini_adapter *ad,
enum bcm_led_events currdriverstate,
UCHAR GPIO_num,
UCHAR dummyGPIONum,
UCHAR uiLedIndex,
UCHAR dummyIndex,
ulong timeout,
UINT uiResetValue,
UINT uiIndex)
{ {
UINT uiIndex = 0; switch (ad->DriverState) {
UCHAR GPIO_num = 0;
UCHAR uiLedIndex = 0;
UINT uiResetValue = 0;
enum bcm_led_events currdriverstate = 0;
ulong timeout = 0;
INT Status = 0;
UCHAR dummyGPIONum = 0;
UCHAR dummyIndex = 0;
/* currdriverstate = Adapter->DriverState; */
Adapter->LEDInfo.bIdleMode_tx_from_host = false;
/*
* Wait till event is triggered
*
* wait_event(Adapter->LEDInfo.notify_led_event,
* currdriverstate!= Adapter->DriverState);
*/
GPIO_num = DISABLE_GPIO_NUM;
while (TRUE) {
/* Wait till event is triggered */
if ((GPIO_num == DISABLE_GPIO_NUM)
||
((currdriverstate != FW_DOWNLOAD) &&
(currdriverstate != NORMAL_OPERATION) &&
(currdriverstate != LOWPOWER_MODE_ENTER))
||
(currdriverstate == LED_THREAD_INACTIVE))
Status = wait_event_interruptible(
Adapter->LEDInfo.notify_led_event,
currdriverstate != Adapter->DriverState
|| kthread_should_stop());
if (kthread_should_stop() || Adapter->device_removed) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
DBG_LVL_ALL,
"Led thread got signal to exit..hence exiting");
Adapter->LEDInfo.led_thread_running =
BCM_LED_THREAD_DISABLED;
TURN_OFF_LED(1 << GPIO_num, uiLedIndex);
return; /* STATUS_FAILURE; */
}
if (GPIO_num != DISABLE_GPIO_NUM)
TURN_OFF_LED(1 << GPIO_num, uiLedIndex);
if (Adapter->LEDInfo.bLedInitDone == false) {
LedGpioInit(Adapter);
Adapter->LEDInfo.bLedInitDone = TRUE;
}
switch (Adapter->DriverState) {
case DRIVER_INIT: case DRIVER_INIT:
currdriverstate = DRIVER_INIT; currdriverstate = DRIVER_INIT;
/* Adapter->DriverState; */ /* ad->DriverState; */
BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
&uiLedIndex, &dummyIndex, &uiLedIndex, &dummyIndex,
currdriverstate); currdriverstate);
...@@ -733,26 +685,25 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) ...@@ -733,26 +685,25 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
break; break;
case FW_DOWNLOAD: case FW_DOWNLOAD:
/* /*
* BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, * BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS,
* LED_DUMP_INFO, DBG_LVL_ALL, * LED_DUMP_INFO, DBG_LVL_ALL,
* "LED Thread: FW_DN_DONE called\n"); * "LED Thread: FW_DN_DONE called\n");
*/ */
currdriverstate = FW_DOWNLOAD; currdriverstate = FW_DOWNLOAD;
BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
&uiLedIndex, &dummyIndex, &uiLedIndex, &dummyIndex,
currdriverstate); currdriverstate);
if (GPIO_num != DISABLE_GPIO_NUM) { if (GPIO_num != DISABLE_GPIO_NUM) {
timeout = 50; timeout = 50;
LED_Blink(Adapter, 1 << GPIO_num, uiLedIndex, LED_Blink(ad, 1 << GPIO_num, uiLedIndex, timeout,
timeout, -1, currdriverstate); -1, currdriverstate);
} }
break; break;
case FW_DOWNLOAD_DONE: case FW_DOWNLOAD_DONE:
currdriverstate = FW_DOWNLOAD_DONE; currdriverstate = FW_DOWNLOAD_DONE;
BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
&uiLedIndex, &dummyIndex, &uiLedIndex, &dummyIndex, currdriverstate);
currdriverstate);
if (GPIO_num != DISABLE_GPIO_NUM) if (GPIO_num != DISABLE_GPIO_NUM)
TURN_ON_LED(1 << GPIO_num, uiLedIndex); TURN_ON_LED(1 << GPIO_num, uiLedIndex);
break; break;
...@@ -764,9 +715,8 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) ...@@ -764,9 +715,8 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
*/ */
case NO_NETWORK_ENTRY: case NO_NETWORK_ENTRY:
currdriverstate = NO_NETWORK_ENTRY; currdriverstate = NO_NETWORK_ENTRY;
BcmGetGPIOPinInfo(Adapter, &GPIO_num, &dummyGPIONum, BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum,
&uiLedIndex, &dummyGPIONum, &uiLedIndex, &dummyGPIONum, currdriverstate);
currdriverstate);
if (GPIO_num != DISABLE_GPIO_NUM) if (GPIO_num != DISABLE_GPIO_NUM)
TURN_ON_LED(1 << GPIO_num, uiLedIndex); TURN_ON_LED(1 << GPIO_num, uiLedIndex);
break; break;
...@@ -777,14 +727,12 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) ...@@ -777,14 +727,12 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
UCHAR uiLEDTx = 0; UCHAR uiLEDTx = 0;
UCHAR uiLEDRx = 0; UCHAR uiLEDRx = 0;
currdriverstate = NORMAL_OPERATION; currdriverstate = NORMAL_OPERATION;
Adapter->LEDInfo.bIdle_led_off = false; ad->LEDInfo.bIdle_led_off = false;
BcmGetGPIOPinInfo(Adapter, &GPIO_num_tx, BcmGetGPIOPinInfo(ad, &GPIO_num_tx, &GPIO_num_rx,
&GPIO_num_rx, &uiLEDTx, &uiLEDRx, &uiLEDTx, &uiLEDRx, currdriverstate);
currdriverstate);
if ((GPIO_num_tx == DISABLE_GPIO_NUM) && if ((GPIO_num_tx == DISABLE_GPIO_NUM) &&
(GPIO_num_rx == (GPIO_num_rx == DISABLE_GPIO_NUM)) {
DISABLE_GPIO_NUM)) {
GPIO_num = DISABLE_GPIO_NUM; GPIO_num = DISABLE_GPIO_NUM;
} else { } else {
/* /*
...@@ -794,8 +742,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) ...@@ -794,8 +742,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
if (GPIO_num_tx == DISABLE_GPIO_NUM) { if (GPIO_num_tx == DISABLE_GPIO_NUM) {
GPIO_num_tx = GPIO_num_rx; GPIO_num_tx = GPIO_num_rx;
uiLEDTx = uiLEDRx; uiLEDTx = uiLEDRx;
} else if (GPIO_num_rx == } else if (GPIO_num_rx == DISABLE_GPIO_NUM) {
DISABLE_GPIO_NUM) {
GPIO_num_rx = GPIO_num_tx; GPIO_num_rx = GPIO_num_tx;
uiLEDRx = uiLEDTx; uiLEDRx = uiLEDTx;
} }
...@@ -803,7 +750,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) ...@@ -803,7 +750,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
* Blink the LED in proportionate * Blink the LED in proportionate
* to Tx and Rx transmissions. * to Tx and Rx transmissions.
*/ */
LED_Proportional_Blink(Adapter, LED_Proportional_Blink(ad,
GPIO_num_tx, uiLEDTx, GPIO_num_tx, uiLEDTx,
GPIO_num_rx, uiLEDRx, GPIO_num_rx, uiLEDRx,
currdriverstate); currdriverstate);
...@@ -813,19 +760,19 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) ...@@ -813,19 +760,19 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
case LOWPOWER_MODE_ENTER: case LOWPOWER_MODE_ENTER:
currdriverstate = LOWPOWER_MODE_ENTER; currdriverstate = LOWPOWER_MODE_ENTER;
if (DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING == if (DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING ==
Adapter->ulPowerSaveMode) { ad->ulPowerSaveMode) {
/* Turn OFF all the LED */ /* Turn OFF all the LED */
uiResetValue = 0; uiResetValue = 0;
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM) if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM)
TURN_OFF_LED((1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex); TURN_OFF_LED((1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex);
} }
} }
/* Turn off LED And WAKE-UP for Sendinf IDLE mode ACK */ /* Turn off LED And WAKE-UP for Sendinf IDLE mode ACK */
Adapter->LEDInfo.bLedInitDone = false; ad->LEDInfo.bLedInitDone = false;
Adapter->LEDInfo.bIdle_led_off = TRUE; ad->LEDInfo.bIdle_led_off = TRUE;
wake_up(&Adapter->LEDInfo.idleModeSyncEvent); wake_up(&ad->LEDInfo.idleModeSyncEvent);
GPIO_num = DISABLE_GPIO_NUM; GPIO_num = DISABLE_GPIO_NUM;
break; break;
case IDLEMODE_CONTINUE: case IDLEMODE_CONTINUE:
...@@ -838,41 +785,111 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) ...@@ -838,41 +785,111 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
currdriverstate = DRIVER_HALT; currdriverstate = DRIVER_HALT;
GPIO_num = DISABLE_GPIO_NUM; GPIO_num = DISABLE_GPIO_NUM;
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num !=
!= DISABLE_GPIO_NUM) DISABLE_GPIO_NUM)
TURN_OFF_LED((1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex); TURN_OFF_LED((1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex);
} }
/* Adapter->DriverState = DRIVER_INIT; */ /* ad->DriverState = DRIVER_INIT; */
break; break;
case LED_THREAD_INACTIVE: case LED_THREAD_INACTIVE:
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, LED_DUMP_INFO,
DBG_LVL_ALL, "InActivating LED thread..."); DBG_LVL_ALL, "InActivating LED thread...");
currdriverstate = LED_THREAD_INACTIVE; currdriverstate = LED_THREAD_INACTIVE;
Adapter->LEDInfo.led_thread_running = ad->LEDInfo.led_thread_running =
BCM_LED_THREAD_RUNNING_INACTIVELY; BCM_LED_THREAD_RUNNING_INACTIVELY;
Adapter->LEDInfo.bLedInitDone = false; ad->LEDInfo.bLedInitDone = false;
/* disable ALL LED */ /* disable ALL LED */
for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) {
if (Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num !=
!= DISABLE_GPIO_NUM) DISABLE_GPIO_NUM)
TURN_OFF_LED((1 << Adapter->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex); TURN_OFF_LED((1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num), uiIndex);
} }
break; break;
case LED_THREAD_ACTIVE: case LED_THREAD_ACTIVE:
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, LED_DUMP_INFO,
DBG_LVL_ALL, "Activating LED thread again..."); DBG_LVL_ALL, "Activating LED thread again...");
if (Adapter->LinkUpStatus == false) if (ad->LinkUpStatus == false)
Adapter->DriverState = NO_NETWORK_ENTRY; ad->DriverState = NO_NETWORK_ENTRY;
else else
Adapter->DriverState = NORMAL_OPERATION; ad->DriverState = NORMAL_OPERATION;
Adapter->LEDInfo.led_thread_running = ad->LEDInfo.led_thread_running =
BCM_LED_THREAD_RUNNING_ACTIVELY; BCM_LED_THREAD_RUNNING_ACTIVELY;
break; break;
/* return; */ /* return; */
default: default:
break; break;
} }
}
static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
{
UINT uiIndex = 0;
UCHAR GPIO_num = 0;
UCHAR uiLedIndex = 0;
UINT uiResetValue = 0;
enum bcm_led_events currdriverstate = 0;
ulong timeout = 0;
INT Status = 0;
UCHAR dummyGPIONum = 0;
UCHAR dummyIndex = 0;
/* currdriverstate = Adapter->DriverState; */
Adapter->LEDInfo.bIdleMode_tx_from_host = false;
/*
* Wait till event is triggered
*
* wait_event(Adapter->LEDInfo.notify_led_event,
* currdriverstate!= Adapter->DriverState);
*/
GPIO_num = DISABLE_GPIO_NUM;
while (TRUE) {
/* Wait till event is triggered */
if ((GPIO_num == DISABLE_GPIO_NUM)
||
((currdriverstate != FW_DOWNLOAD) &&
(currdriverstate != NORMAL_OPERATION) &&
(currdriverstate != LOWPOWER_MODE_ENTER))
||
(currdriverstate == LED_THREAD_INACTIVE))
Status = wait_event_interruptible(
Adapter->LEDInfo.notify_led_event,
currdriverstate != Adapter->DriverState
|| kthread_should_stop());
if (kthread_should_stop() || Adapter->device_removed) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO,
DBG_LVL_ALL,
"Led thread got signal to exit..hence exiting");
Adapter->LEDInfo.led_thread_running =
BCM_LED_THREAD_DISABLED;
TURN_OFF_LED(1 << GPIO_num, uiLedIndex);
return; /* STATUS_FAILURE; */
}
if (GPIO_num != DISABLE_GPIO_NUM)
TURN_OFF_LED(1 << GPIO_num, uiLedIndex);
if (Adapter->LEDInfo.bLedInitDone == false) {
LedGpioInit(Adapter);
Adapter->LEDInfo.bLedInitDone = TRUE;
}
handle_adapter_driver_state(Adapter,
currdriverstate,
GPIO_num,
dummyGPIONum,
uiLedIndex,
dummyIndex,
timeout,
uiResetValue,
uiIndex
);
} }
Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED; Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED;
} }
......
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