summaryrefslogtreecommitdiff
path: root/drivers/staging/rts5208/rtsx_chip.c
diff options
context:
space:
mode:
authorFabio Falzoi <fabio.falzoi84@gmail.com>2015-06-14 15:48:51 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-06-17 21:23:15 -0700
commit76d833a8d9425618b7798227554d6a6729f3de5d (patch)
tree13651ad318ab639225cdbf97675f1b28303df5dd /drivers/staging/rts5208/rtsx_chip.c
parent884a27e36e0ebd009f2efc3a0b8d40cb0290907d (diff)
Staging: rts5208: helper function to manage idle
Use a helper function to manage idle state Signed-off-by: Fabio Falzoi <fabio.falzoi84@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/rts5208/rtsx_chip.c')
-rw-r--r--drivers/staging/rts5208/rtsx_chip.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c
index ee331f2e4a0e..01b20fb31c6e 100644
--- a/drivers/staging/rts5208/rtsx_chip.c
+++ b/drivers/staging/rts5208/rtsx_chip.c
@@ -1245,6 +1245,30 @@ static void rtsx_manage_aspm(struct rtsx_chip *chip)
#endif
}
+static void rtsx_manage_idle(struct rtsx_chip *chip)
+{
+ if (chip->idle_counter < IDLE_MAX_COUNT) {
+ chip->idle_counter++;
+ return;
+ }
+
+ if (rtsx_get_stat(chip) == RTSX_STAT_IDLE)
+ return;
+
+ dev_dbg(rtsx_dev(chip), "Idle state!\n");
+ rtsx_set_stat(chip, RTSX_STAT_IDLE);
+
+#if !defined(LED_AUTO_BLINK) && defined(REGULAR_BLINK)
+ chip->led_toggle_counter = 0;
+#endif
+ rtsx_force_power_on(chip, SSC_PDCTL);
+
+ turn_off_led(chip, LED_GPIO);
+
+ if (chip->auto_power_down && !chip->card_ready && !chip->sd_io)
+ rtsx_force_power_down(chip, SSC_PDCTL | OC_PDCTL);
+}
+
void rtsx_polling_func(struct rtsx_chip *chip)
{
if (rtsx_chk_stat(chip, RTSX_STAT_SUSPEND))
@@ -1272,26 +1296,7 @@ void rtsx_polling_func(struct rtsx_chip *chip)
rtsx_manage_aspm(chip);
- if (chip->idle_counter < IDLE_MAX_COUNT) {
- chip->idle_counter++;
- } else {
- if (rtsx_get_stat(chip) != RTSX_STAT_IDLE) {
- dev_dbg(rtsx_dev(chip), "Idle state!\n");
- rtsx_set_stat(chip, RTSX_STAT_IDLE);
-
-#if !defined(LED_AUTO_BLINK) && defined(REGULAR_BLINK)
- chip->led_toggle_counter = 0;
-#endif
- rtsx_force_power_on(chip, SSC_PDCTL);
-
- turn_off_led(chip, LED_GPIO);
-
- if (chip->auto_power_down && !chip->card_ready &&
- !chip->sd_io)
- rtsx_force_power_down(chip,
- SSC_PDCTL | OC_PDCTL);
- }
- }
+ rtsx_manage_idle(chip);
switch (rtsx_get_stat(chip)) {
case RTSX_STAT_RUN: