Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753317AbbFNNu3 (ORCPT ); Sun, 14 Jun 2015 09:50:29 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:33612 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752132AbbFNNta (ORCPT ); Sun, 14 Jun 2015 09:49:30 -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 3/7] Staging: rts5208: helper function to manage ss Date: Sun, 14 Jun 2015 15:48:49 +0200 Message-Id: <1434289733-29077-4-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: 2430 Lines: 101 Use a helper function to manage ss_counter Signed-off-by: Fabio Falzoi --- drivers/staging/rts5208/rtsx_chip.c | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 5946cc4..373ccd0 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1184,10 +1184,40 @@ static void rtsx_manage_sd_lock(struct rtsx_chip *chip) #endif } -void rtsx_polling_func(struct rtsx_chip *chip) +static bool rtsx_is_ss_allowed(struct rtsx_chip *chip) +{ + u32 val; + + if (!chip->ss_en || CHECK_PID(chip, 0x5288)) + return false; + + if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip)) { + rtsx_read_cfg_dw(chip, 1, 0x04, &val); + if (val & 0x07) + return false; + } + + return true; +} + +static void rtsx_manage_ss(struct rtsx_chip *chip) { - bool ss_allowed; + if (!rtsx_is_ss_allowed(chip) || chip->sd_io) + return; + + if (rtsx_get_stat(chip) != RTSX_STAT_IDLE) { + chip->ss_counter = 0; + return; + } + if (chip->ss_counter < (chip->ss_idle_period / POLLING_INTERVAL)) + chip->ss_counter++; + else + rtsx_exclusive_enter_ss(chip); +} + +void rtsx_polling_func(struct rtsx_chip *chip) +{ if (rtsx_chk_stat(chip, RTSX_STAT_SUSPEND)) return; @@ -1209,37 +1239,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) rtsx_init_cards(chip); - if (chip->ss_en) { - ss_allowed = true; - - if (CHECK_PID(chip, 0x5288)) { - ss_allowed = false; - } else { - if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip)) { - u32 val; - - rtsx_read_cfg_dw(chip, 1, 0x04, &val); - if (val & 0x07) - ss_allowed = false; - } - } - } else { - ss_allowed = false; - } - - if (ss_allowed && !chip->sd_io) { - if (rtsx_get_stat(chip) != RTSX_STAT_IDLE) { - chip->ss_counter = 0; - } else { - if (chip->ss_counter < - (chip->ss_idle_period / POLLING_INTERVAL)) { - chip->ss_counter++; - } else { - rtsx_exclusive_enter_ss(chip); - return; - } - } - } + rtsx_manage_ss(chip); if (CHECK_PID(chip, 0x5208)) { rtsx_monitor_aspm_config(chip); -- 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/