From patchwork Tue Jul 9 15:44:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremie Samuel X-Patchwork-Id: 2825339 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 78F279F7D6 for ; Tue, 9 Jul 2013 15:44:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31070201BB for ; Tue, 9 Jul 2013 15:44:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCFDF2011D for ; Tue, 9 Jul 2013 15:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751905Ab3GIPos (ORCPT ); Tue, 9 Jul 2013 11:44:48 -0400 Received: from co202.xi-lite.net ([149.6.83.202]:45925 "EHLO co202.xi-lite.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751942Ab3GIPoq (ORCPT ); Tue, 9 Jul 2013 11:44:46 -0400 Received: from ONYX.xi-lite.lan (unknown [193.34.35.244]) by co202.xi-lite.net (Postfix) with ESMTPS id 6C3CD168A7E; Tue, 9 Jul 2013 18:05:03 +0200 (CEST) Received: from jerk.parrot.biz (46.218.109.88) by mail.xi-lite.com (193.34.32.105) with Microsoft SMTP Server (TLS) id 8.1.336.0; Tue, 9 Jul 2013 16:45:40 +0100 From: Jeremie Samuel To: Chris Ball CC: , , , Jeremie Samuel Subject: [PATCH 5/8] sdhci: Delay led blinking Date: Tue, 9 Jul 2013 17:44:09 +0200 Message-ID: <1373384652-21958-6-git-send-email-jeremie.samuel.ext@parrot.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373384652-21958-1-git-send-email-jeremie.samuel.ext@parrot.com> References: <1373384652-21958-1-git-send-email-jeremie.samuel.ext@parrot.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function sdhci_led_control is called in an atomic context by the led_trigger driver. So, it is necessary to delay the activation or deactivation of the led. Signed-off-by: Jeremie Samuel --- drivers/mmc/host/sdhci.c | 42 ++++++++++++++++++++++-------------------- include/linux/mmc/sdhci.h | 1 + 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 21ef1e0..9a7471c 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -281,8 +281,14 @@ static void sdhci_activate_led(struct sdhci_host *host) u8 ctrl; ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); - ctrl |= SDHCI_CTRL_LED; - sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); +#ifdef SDHCI_USE_LEDS_CLASS + if (host->brightness && !(ctrl & SDHCI_CTRL_LED)) { +#else + if (!(ctrl & SDHCI_CTRL_LED)) { +#endif + ctrl |= SDHCI_CTRL_LED; + sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); + } } static void sdhci_deactivate_led(struct sdhci_host *host) @@ -290,8 +296,14 @@ static void sdhci_deactivate_led(struct sdhci_host *host) u8 ctrl; ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); - ctrl &= ~SDHCI_CTRL_LED; - sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); +#ifdef SDHCI_USE_LEDS_CLASS + if (!host->brightness && (ctrl & SDHCI_CTRL_LED)) { +#else + if (ctrl & SDHCI_CTRL_LED) { +#endif + ctrl &= ~SDHCI_CTRL_LED; + sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); + } } #ifdef SDHCI_USE_LEDS_CLASS @@ -299,19 +311,11 @@ static void sdhci_led_control(struct led_classdev *led, enum led_brightness brightness) { struct sdhci_host *host = container_of(led, struct sdhci_host, led); - unsigned long flags; - - spin_lock_irqsave(&host->lock, flags); if (host->runtime_suspended) - goto out; + return; - if (brightness == LED_OFF) - sdhci_deactivate_led(host); - else - sdhci_activate_led(host); -out: - spin_unlock_irqrestore(&host->lock, flags); + host->brightness = brightness; } #endif @@ -1338,9 +1342,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) WARN_ON(host->mrq != NULL); -#ifndef SDHCI_USE_LEDS_CLASS sdhci_activate_led(host); -#endif /* * Ensure we don't send the STOP for non-SET_BLOCK_COUNTED @@ -2164,15 +2166,15 @@ static void sdhci_finish_work(struct work_struct *wk) host->cmd = NULL; host->data = NULL; -#ifndef SDHCI_USE_LEDS_CLASS - sdhci_deactivate_led(host); -#endif - mmiowb(); spin_unlock_irqrestore(&host->lock, flags); mmc_request_done(host->mmc, mrq); sdhci_runtime_pm_put(host); + + spin_lock_irqsave(&host->lock, flags); + sdhci_deactivate_led(host); + spin_unlock_irqrestore(&host->lock, flags); } static void sdhci_timeout_work(struct work_struct *wk) diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h index 0cc97ce..adb95c3 100644 --- a/include/linux/mmc/sdhci.h +++ b/include/linux/mmc/sdhci.h @@ -115,6 +115,7 @@ struct sdhci_host { #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) struct led_classdev led; /* LED control */ char led_name[32]; + enum led_brightness brightness; #endif spinlock_t lock; /* Mutex */