Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752643AbbFNNtr (ORCPT ); Sun, 14 Jun 2015 09:49:47 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:36422 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752343AbbFNNtd (ORCPT ); Sun, 14 Jun 2015 09:49:33 -0400 From: Fabio Falzoi To: gregkh@linuxfoundation.org Cc: micky_ching@realsil.com.cn, joe@perches.com, dan.carpente@oracle.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Fabio Falzoi Subject: [PATCH 5/7] Staging: rts5208: helper function to manage idle Date: Sun, 14 Jun 2015 15:48:51 +0200 Message-Id: <1434289733-29077-6-git-send-email-fabio.falzoi84@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434289733-29077-1-git-send-email-fabio.falzoi84@gmail.com> References: <1434289733-29077-1-git-send-email-fabio.falzoi84@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2195 Lines: 78 Use a helper function to manage idle state Signed-off-by: Fabio Falzoi --- drivers/staging/rts5208/rtsx_chip.c | 45 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index ee331f2..01b20fb 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: -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/