From patchwork Thu May 12 17:11:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raffaele Recalcati X-Patchwork-Id: 780582 Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4CHDhQG026107 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 12 May 2011 17:14:03 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id p4CHCNl6012365 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 12 May 2011 12:12:23 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id p4CHCMW4003350; Thu, 12 May 2011 12:12:22 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 760878062A; Thu, 12 May 2011 12:12:22 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 5D87D80639 for ; Thu, 12 May 2011 12:11:27 -0500 (CDT) Received: from red.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id p4CHBRlc024988 for ; Thu, 12 May 2011 12:11:27 -0500 (CDT) Received: from psmtp.com (na3sys009amx184.postini.com [74.125.149.165]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id p4CHBQFi002633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 12 May 2011 12:11:26 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]) (using TLSv1) by na3sys009amx184.postini.com ([74.125.148.10]) with SMTP; Thu, 12 May 2011 13:11:26 EDT Received: by wyb42 with SMTP id 42so1522461wyb.4 for ; Thu, 12 May 2011 10:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=U/rbYsrV8hrCGFH4stHb+eQ1GuLSeICh1ycQP2+oNoc=; b=gum7QQTHckQbBotC8WNT7zYbTmoTlDa+FJfTrcu+dx0YhMMwJkymmD3KW9GGMchdlx ltFADdVDhAPaiAil4hUu1yJcVDF+t5O2W9Nax0Fmwp3CtpF45ea6mqJ1+T+U3TeUKyHl RInNoDqDOBrMnYaUApRBbJOvAr85YFwtOTZvQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=T/GFkl3VvmaS6lHDmc0CMYCS7HNvVoy+5a3Hul0bmm3OfPJLvnXP5z+hObvDMbrF+M Ox4AnPWAb7E07nUpvjBHvPYLKee/CCntwc5QNfTISU4nW4XAPyXUVK5bwO4O6BDHEcKd 7H73Ng4DA+pxbCqjyw1ihAeX+HA9OOvOssCo4= Received: by 10.216.135.67 with SMTP id t45mr434191wei.80.1305220284534; Thu, 12 May 2011 10:11:24 -0700 (PDT) Received: from localhost.localdomain (host41-16-static.112-2-b.business.telecomitalia.it [2.112.16.41]) by mx.google.com with ESMTPS id c43sm719446weo.18.2011.05.12.10.11.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 May 2011 10:11:23 -0700 (PDT) From: Raffaele Recalcati To: linux-pm@lists.linux-foundation.org Subject: [PATCH 3/4] mmc: bus and block device drivers: support for pm_loss Date: Thu, 12 May 2011 19:11:04 +0200 Message-Id: <1305220265-9020-4-git-send-email-lamiaposta71@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1305220265-9020-1-git-send-email-lamiaposta71@gmail.com> References: <1305220265-9020-1-git-send-email-lamiaposta71@gmail.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:75.76080/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: davinci-linux-open-source@linux.davincidsp.com, Raffaele Recalcati , linux-kernel@vger.kernel.org, Davide Ciminaghi X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 12 May 2011 17:14:04 +0000 (UTC) From: Davide Ciminaghi Signed-off-by: Davide Ciminaghi Signed-off-by: Raffaele Recalcati --- drivers/mmc/card/block.c | 48 +++++++++++++++++++++++++++++++++++++++++++- drivers/mmc/core/bus.c | 49 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 90 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index bfc8a8a..c88afef 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -37,6 +37,9 @@ #include #include +#include +#include + #include #include @@ -755,14 +758,55 @@ static int mmc_blk_resume(struct mmc_card *card) } return 0; } -#else + +#ifdef CONFIG_PM_LOSS + +#define dev_to_mmc_card(d) container_of(d, struct mmc_card, dev) + +static int mmc_blk_power_changed(struct device *dev, + enum sys_power_state s) +{ + struct mmc_card *card = dev_to_mmc_card(dev); + struct mmc_blk_data *md = mmc_get_drvdata(card); + + switch (s) { + case SYS_PWR_GOOD: + pr_debug_pm_loss("mmc_blk_power_changed(%d)\n", s); + mmc_blk_set_blksize(md, card); + mmc_queue_resume(&md->queue); + break; + case SYS_PWR_FAILING: + pr_debug_pm_loss("mmc_blk_power_changed(%d)\n", s); + mmc_queue_suspend(&md->queue); + break; + default: + BUG(); + } + return 0; +} + +static const struct dev_pm_ops mmc_blk_pm_ops = { + .power_changed = mmc_blk_power_changed, +}; + +#define MMC_BLK_DEV_PM_OPS_PTR (&mmc_blk_pm_ops) + +#else /* !CONFIG_PM_LOSS */ + +#define MMC_BLK_DEV_PM_OPS_PTR NULL + +#endif /* !CONFIG_PM_LOSS */ + +#else /* !CONFIG_PM */ #define mmc_blk_suspend NULL #define mmc_blk_resume NULL -#endif +#define MMC_BLK_DEV_PM_OPS_PTR NULL +#endif /* !CONFIG_PM */ static struct mmc_driver mmc_driver = { .drv = { .name = "mmcblk", + .pm = MMC_BLK_DEV_PM_OPS_PTR, }, .probe = mmc_blk_probe, .remove = mmc_blk_remove, diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 63667a8..548d3a9 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -19,6 +19,8 @@ #include #include +#include + #include "core.h" #include "sdio_cis.h" #include "bus.h" @@ -163,19 +165,56 @@ static int mmc_runtime_idle(struct device *dev) return pm_runtime_suspend(dev); } +#define MMC_PM_RUNTIME_OPS_INIT \ +.runtime_suspend = mmc_runtime_suspend, \ +.runtime_resume = mmc_runtime_resume, \ +.runtime_idle = mmc_runtime_idle, + +#else /* !CONFIG_PM_RUNTIME */ + +#define MMC_PM_RUNTIME_OPS_INIT + +#endif /* !CONFIG_PM_RUNTIME */ + +#ifdef CONFIG_PM_LOSS + +static int mmc_bus_power_changed(struct device *dev, + enum sys_power_state s) +{ + int ret = 0; + + pr_debug_pm_loss("mmc_bus_power_changed()\n"); + + if (dev->driver && dev->driver->pm && + dev->driver->pm->power_changed) + ret = dev->driver->pm->power_changed(dev, s); + + return ret; +} + +#define MMC_PM_LOSS_OPS_INIT \ +.power_changed = mmc_bus_power_changed, + +#else /* !CONFIG_PM_LOSS */ + +#define MMC_PM_LOSS_OPS_INIT + +#endif /* !CONFIG_PM_LOSS */ + +#if defined CONFIG_PM_RUNTIME || defined CONFIG_PM_LOSS + static const struct dev_pm_ops mmc_bus_pm_ops = { - .runtime_suspend = mmc_runtime_suspend, - .runtime_resume = mmc_runtime_resume, - .runtime_idle = mmc_runtime_idle, + MMC_PM_RUNTIME_OPS_INIT + MMC_PM_LOSS_OPS_INIT }; #define MMC_PM_OPS_PTR (&mmc_bus_pm_ops) -#else /* !CONFIG_PM_RUNTIME */ +#else /* !(CONFIG_PM_RUNTIME || CONFIG_PM_LOSS) */ #define MMC_PM_OPS_PTR NULL -#endif /* !CONFIG_PM_RUNTIME */ +#endif /* !(CONFIG_PM_RUNTIME || CONFIG_PM_LOSS) */ static struct bus_type mmc_bus_type = { .name = "mmc",