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

Staging: bcm: led_control.c: Outsourced code chunk

Signed-off-by: default avatarMatthias Beyer <mail@beyermatthias.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e4e9d83e
......@@ -97,38 +97,19 @@ static INT ScaleRateofTransfer(ULONG rate)
return MAX_NUM_OF_BLINKS;
}
static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter,
static INT blink_in_normal_bandwidth(struct bcm_mini_adapter *Adapter,
INT *num_of_time,
INT *num_of_time_tx,
INT *num_of_time_rx,
UCHAR GPIO_Num_tx,
UCHAR uiTxLedIndex,
UCHAR GPIO_Num_rx,
UCHAR uiRxLedIndex,
enum bcm_led_events currdriverstate)
enum bcm_led_events currdriverstate,
ulong *timeout)
{
/* Initial values of TX and RX packets */
ULONG64 Initial_num_of_packts_tx = 0, Initial_num_of_packts_rx = 0;
/* values of TX and RX packets after 1 sec */
ULONG64 Final_num_of_packts_tx = 0, Final_num_of_packts_rx = 0;
/* Rate of transfer of Tx and Rx in 1 sec */
ULONG64 rate_of_transfer_tx = 0, rate_of_transfer_rx = 0;
int Status = STATUS_SUCCESS;
INT num_of_time = 0, num_of_time_tx = 0, num_of_time_rx = 0;
UINT remDelay = 0;
bool bBlinkBothLED = TRUE;
/* UINT GPIO_num = DISABLE_GPIO_NUM; */
ulong timeout = 0;
/* Read initial value of packets sent/received */
Initial_num_of_packts_tx = Adapter->dev->stats.tx_packets;
Initial_num_of_packts_rx = Adapter->dev->stats.rx_packets;
/* Scale the rate of transfer to no of blinks. */
num_of_time_tx = ScaleRateofTransfer((ULONG)rate_of_transfer_tx);
num_of_time_rx = ScaleRateofTransfer((ULONG)rate_of_transfer_rx);
while ((Adapter->device_removed == false)) {
timeout = 50;
/*
* Blink Tx and Rx LED when both Tx and Rx is
* in normal bandwidth
......@@ -138,65 +119,111 @@ static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter,
* Assign minimum number of blinks of
* either Tx or Rx.
*/
if (num_of_time_tx > num_of_time_rx)
num_of_time = num_of_time_rx;
if (*num_of_time_tx > *num_of_time_rx)
*num_of_time = *num_of_time_rx;
else
num_of_time = num_of_time_tx;
if (num_of_time > 0) {
*num_of_time = *num_of_time_tx;
if (*num_of_time > 0) {
/* Blink both Tx and Rx LEDs */
if (LED_Blink(Adapter, 1 << GPIO_Num_tx,
uiTxLedIndex, timeout,
num_of_time, currdriverstate)
uiTxLedIndex, *timeout,
*num_of_time, currdriverstate)
== EVENT_SIGNALED)
return EVENT_SIGNALED;
if (LED_Blink(Adapter, 1 << GPIO_Num_rx,
uiRxLedIndex, timeout,
num_of_time, currdriverstate)
uiRxLedIndex, *timeout,
*num_of_time, currdriverstate)
== EVENT_SIGNALED)
return EVENT_SIGNALED;
}
if (num_of_time == num_of_time_tx) {
if (*num_of_time == *num_of_time_tx) {
/* Blink pending rate of Rx */
if (LED_Blink(Adapter, (1 << GPIO_Num_rx),
uiRxLedIndex, timeout,
num_of_time_rx-num_of_time,
uiRxLedIndex, *timeout,
*num_of_time_rx - *num_of_time,
currdriverstate)
== EVENT_SIGNALED)
return EVENT_SIGNALED;
num_of_time = num_of_time_rx;
*num_of_time = *num_of_time_rx;
} else {
/* Blink pending rate of Tx */
if (LED_Blink(Adapter, 1 << GPIO_Num_tx,
uiTxLedIndex, timeout,
num_of_time_tx-num_of_time,
uiTxLedIndex, *timeout,
*num_of_time_tx - *num_of_time,
currdriverstate)
== EVENT_SIGNALED)
return EVENT_SIGNALED;
num_of_time = num_of_time_tx;
*num_of_time = *num_of_time_tx;
}
} else {
if (num_of_time == num_of_time_tx) {
if (*num_of_time == *num_of_time_tx) {
/* Blink pending rate of Rx */
if (LED_Blink(Adapter, 1 << GPIO_Num_tx,
uiTxLedIndex, timeout,
num_of_time, currdriverstate)
uiTxLedIndex, *timeout,
*num_of_time, currdriverstate)
== EVENT_SIGNALED)
return EVENT_SIGNALED;
} else {
/* Blink pending rate of Tx */
if (LED_Blink(Adapter, 1 << GPIO_Num_rx,
uiRxLedIndex, timeout,
num_of_time, currdriverstate)
uiRxLedIndex, *timeout,
*num_of_time, currdriverstate)
== EVENT_SIGNALED)
return EVENT_SIGNALED;
}
}
return 0;
}
static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter,
UCHAR GPIO_Num_tx,
UCHAR uiTxLedIndex,
UCHAR GPIO_Num_rx,
UCHAR uiRxLedIndex,
enum bcm_led_events currdriverstate)
{
/* Initial values of TX and RX packets */
ULONG64 Initial_num_of_packts_tx = 0, Initial_num_of_packts_rx = 0;
/* values of TX and RX packets after 1 sec */
ULONG64 Final_num_of_packts_tx = 0, Final_num_of_packts_rx = 0;
/* Rate of transfer of Tx and Rx in 1 sec */
ULONG64 rate_of_transfer_tx = 0, rate_of_transfer_rx = 0;
int Status = STATUS_SUCCESS;
INT num_of_time = 0, num_of_time_tx = 0, num_of_time_rx = 0;
UINT remDelay = 0;
/* UINT GPIO_num = DISABLE_GPIO_NUM; */
ulong timeout = 0;
/* Read initial value of packets sent/received */
Initial_num_of_packts_tx = Adapter->dev->stats.tx_packets;
Initial_num_of_packts_rx = Adapter->dev->stats.rx_packets;
/* Scale the rate of transfer to no of blinks. */
num_of_time_tx = ScaleRateofTransfer((ULONG)rate_of_transfer_tx);
num_of_time_rx = ScaleRateofTransfer((ULONG)rate_of_transfer_rx);
while ((Adapter->device_removed == false)) {
timeout = 50;
if (EVENT_SIGNALED == blink_in_normal_bandwidth(Adapter,
&num_of_time,
&num_of_time_tx,
&num_of_time_rx,
GPIO_Num_tx,
uiTxLedIndex,
GPIO_Num_rx,
uiRxLedIndex,
currdriverstate,
&timeout))
return EVENT_SIGNALED;
/*
* If Tx/Rx rate is less than maximum blinks per second,
* wait till delay completes to 1 second
......
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