From patchwork Mon Sep 27 08:42:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 211452 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8R8dp0c015315 for ; Mon, 27 Sep 2010 08:42:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754255Ab0I0ImY (ORCPT ); Mon, 27 Sep 2010 04:42:24 -0400 Received: from arkanian.console-pimps.org ([212.110.184.194]:44853 "EHLO arkanian.console-pimps.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758881Ab0I0ImX (ORCPT ); Mon, 27 Sep 2010 04:42:23 -0400 Received: by arkanian.console-pimps.org (Postfix, from userid 1000) id 324D64432F; Mon, 27 Sep 2010 09:42:20 +0100 (BST) From: Matt Fleming To: Chris Ball Cc: Jaehoon Chung , linux-mmc@vger.kernel.org, Kyungmin Park , Marek Szyprowski , Andrew Morton , Ben Hutchings , Yunpeng Gao , zhangfei gao Subject: [PATCH V2 1/2] mmc: Add helper function to check if a card is removable Date: Mon, 27 Sep 2010 09:42:19 +0100 Message-Id: <1285576940-27587-2-git-send-email-matt@console-pimps.org> X-Mailer: git-send-email 1.7.2.2.162.g5cba1 In-Reply-To: <1285576940-27587-1-git-send-email-matt@console-pimps.org> References: <1285576940-27587-1-git-send-email-matt@console-pimps.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 27 Sep 2010 08:42:25 +0000 (UTC) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 5db49b1..7c12612 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -58,6 +58,7 @@ int mmc_assume_removable; #else int mmc_assume_removable = 1; #endif +EXPORT_SYMBOL(mmc_assume_removable); module_param_named(removable, mmc_assume_removable, bool, 0644); MODULE_PARM_DESC( removable, diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 9d9eef5..a2ca770 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -58,7 +58,6 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr); /* Module parameters */ extern int use_spi_crc; -extern int mmc_assume_removable; /* Debugfs information for hosts and cards */ void mmc_add_host_debugfs(struct mmc_host *host); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 6909a54..6570c03 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -685,7 +685,7 @@ static void mmc_attach_bus_ops(struct mmc_host *host) { const struct mmc_bus_ops *bus_ops; - if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable) + if (!mmc_card_is_removable(host)) bus_ops = &mmc_ops_unsafe; else bus_ops = &mmc_ops; diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 0f52410..bc745e1 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -750,7 +750,7 @@ static void mmc_sd_attach_bus_ops(struct mmc_host *host) { const struct mmc_bus_ops *bus_ops; - if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable) + if (!mmc_card_is_removable(host)) bus_ops = &mmc_sd_ops_unsafe; else bus_ops = &mmc_sd_ops; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index ded4017..23a4864 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -267,5 +267,13 @@ static inline void mmc_set_disable_delay(struct mmc_host *host, host->disable_delay = disable_delay; } +/* Module parameter */ +extern int mmc_assume_removable; + +static inline int mmc_card_is_removable(struct mmc_host *host) +{ + return (!(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable); +} + #endif