From patchwork Tue Oct 30 08:12:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Changming-R66093 X-Patchwork-Id: 1669081 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 274563FDDA for ; Tue, 30 Oct 2012 08:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756430Ab2J3Iz3 (ORCPT ); Tue, 30 Oct 2012 04:55:29 -0400 Received: from ch1ehsobe001.messaging.microsoft.com ([216.32.181.181]:5990 "EHLO ch1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756425Ab2J3Iz2 (ORCPT ); Tue, 30 Oct 2012 04:55:28 -0400 Received: from mail73-ch1-R.bigfish.com (10.43.68.234) by CH1EHSOBE002.bigfish.com (10.43.70.52) with Microsoft SMTP Server id 14.1.225.23; Tue, 30 Oct 2012 08:55:27 +0000 Received: from mail73-ch1 (localhost [127.0.0.1]) by mail73-ch1-R.bigfish.com (Postfix) with ESMTP id E12426027B; Tue, 30 Oct 2012 08:55:27 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1202h1d1ah1d2ahzz8275bh8275dhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h1155h) Received: from mail73-ch1 (localhost.localdomain [127.0.0.1]) by mail73-ch1 (MessageSwitch) id 1351587325940297_8277; Tue, 30 Oct 2012 08:55:25 +0000 (UTC) Received: from CH1EHSMHS002.bigfish.com (snatpool2.int.messaging.microsoft.com [10.43.68.230]) by mail73-ch1.bigfish.com (Postfix) with ESMTP id E351540150; Tue, 30 Oct 2012 08:55:25 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS002.bigfish.com (10.43.70.2) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 30 Oct 2012 08:55:25 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.318.3; Tue, 30 Oct 2012 08:55:24 +0000 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id q9U8tLaa013156; Tue, 30 Oct 2012 01:55:23 -0700 From: To: CC: Jerry Huang , Anton Vorontsov , Chris Ball Subject: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card Date: Tue, 30 Oct 2012 16:12:47 +0800 Message-ID: <1351584769-16662-2-git-send-email-r66093@freescale.com> X-Mailer: git-send-email 1.6.4 In-Reply-To: <1351584769-16662-1-git-send-email-r66093@freescale.com> References: <1351584769-16662-1-git-send-email-r66093@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Jerry Huang In order to check whether the card has been removed, the function mmc_send_status() will send command CMD13 to card and ask the card to send its status register to sdhc driver, which will generate many interrupts repeatedly and make the system performance bad. Therefore, add callback function get_cd() to check whether the card has been removed when the driver has this callback function. If the card is present, 1 will return, if the card is absent, 0 will return. If the controller will not support this feature, -ENOSYS will return. Signed-off-by: Jerry Huang CC: Anton Vorontsov CC: Chris Ball Reviewed-By: Johan Rudholm Reviewed-By: Johan Rudholm Reviewed-by: Anton Vorontsov --- changes for v2: - when controller don't support get_cd, return -ENOSYS - add the CC changes for v3: - enalbe the controller clock in platform, instead of core changes for v4: - move the detect code to core.c according to the new structure drivers/mmc/core/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 9c162cd..6412355 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2073,7 +2073,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) int _mmc_detect_card_removed(struct mmc_host *host) { - int ret; + int ret = -ENOSYS; if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive) return 0; @@ -2081,7 +2081,13 @@ int _mmc_detect_card_removed(struct mmc_host *host) if (!host->card || mmc_card_removed(host->card)) return 1; - ret = host->bus_ops->alive(host); + if (host->ops->get_cd) { + ret = host->ops->get_cd(host); + if (ret >= 0) + ret = !ret; + } + if (ret < 0) + ret = host->bus_ops->alive(host); if (ret) { mmc_card_set_removed(host->card); pr_debug("%s: card remove detected\n", mmc_hostname(host));