From patchwork Mon Nov 19 05:27:24 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: 1763241 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 36D0B3FCA5 for ; Mon, 19 Nov 2012 06:13:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751528Ab2KSGNm (ORCPT ); Mon, 19 Nov 2012 01:13:42 -0500 Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:46895 "EHLO tx2outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750983Ab2KSGNm (ORCPT ); Mon, 19 Nov 2012 01:13:42 -0500 Received: from mail83-tx2-R.bigfish.com (10.9.14.235) by TX2EHSOBE003.bigfish.com (10.9.40.23) with Microsoft SMTP Server id 14.1.225.23; Mon, 19 Nov 2012 06:13:41 +0000 Received: from mail83-tx2 (localhost [127.0.0.1]) by mail83-tx2-R.bigfish.com (Postfix) with ESMTP id AC75A4400E2; Mon, 19 Nov 2012 06:13:41 +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(zzzz1de0h1202h1d1ah1d2ahzz8275bh8275dhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1155h) Received: from mail83-tx2 (localhost.localdomain [127.0.0.1]) by mail83-tx2 (MessageSwitch) id 1353305618974565_17469; Mon, 19 Nov 2012 06:13:38 +0000 (UTC) Received: from TX2EHSMHS012.bigfish.com (unknown [10.9.14.242]) by mail83-tx2.bigfish.com (Postfix) with ESMTP id E85DC100245; Mon, 19 Nov 2012 06:13:38 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS012.bigfish.com (10.9.99.112) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 19 Nov 2012 06:13:38 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.2.318.3; Mon, 19 Nov 2012 06:13:38 +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 qAJ6DYiK018354; Sun, 18 Nov 2012 23:13:35 -0700 From: To: CC: Jerry Huang , Chris Ball Subject: [PATCH 1/3 v5] MMC/SD: Add callback function to detect card Date: Mon, 19 Nov 2012 13:27:24 +0800 Message-ID: <1353302846-19514-1-git-send-email-r66093@freescale.com> X-Mailer: git-send-email 1.6.4 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 Reviewed-by: Johan Rudholm Reviewed-by: Anton Vorontsov CC: Chris Ball --- 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 changes for v5: - reviewed by Anton and Johan, add the reviewed-by. 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 aaed768..1bc1cb5 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2100,7 +2100,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; @@ -2108,7 +2108,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));