mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Raffaele Recalcati <lamiaposta71@gmail.com>
To: linux-pm@lists.linux-foundation.org
Cc: davinci-linux-open-source@linux.davincidsp.com,
	linux-kernel@vger.kernel.org,
	Davide Ciminaghi <ciminaghi@gnudd.com>,
	Raffaele Recalcati <raffaele.recalcati@bticino.it>
Subject: [PATCH 3/4] mmc: bus and block device drivers: support for pm_loss
Date: Thu, 12 May 2011 19:11:04 +0200	[thread overview]
Message-ID: <1305220265-9020-4-git-send-email-lamiaposta71@gmail.com> (raw)
In-Reply-To: <1305220265-9020-1-git-send-email-lamiaposta71@gmail.com>

From: Davide Ciminaghi <ciminaghi@gnudd.com>

Signed-off-by: Davide Ciminaghi <ciminaghi@gnudd.com>
Signed-off-by: Raffaele Recalcati <raffaele.recalcati@bticino.it>
---
 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 <linux/mmc/mmc.h>
 #include <linux/mmc/sd.h>
 
+#include <linux/pm.h>
+#include <linux/pm_loss.h>
+
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
@@ -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 <linux/mmc/card.h>
 #include <linux/mmc/host.h>
 
+#include <linux/pm_loss.h>
+
 #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",
-- 
1.7.0.4


  parent reply	other threads:[~2011-05-12 17:11 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12 17:11 pm loss development Raffaele Recalcati
2011-05-12 17:11 ` [PATCH 1/4] export bus_kset Raffaele Recalcati
2011-05-12 19:28   ` Rafael J. Wysocki
2011-05-13 17:11     ` Davide Ciminaghi
2011-05-15 14:13       ` [linux-pm] " Davide Ciminaghi
2011-05-17 23:04         ` Rafael J. Wysocki
2011-05-12 17:11 ` [PATCH 2/4] PM / Loss: power loss management Raffaele Recalcati
2011-05-12 19:57   ` Rafael J. Wysocki
2011-05-13 13:02     ` Davide Ciminaghi
2011-05-17 23:32       ` Rafael J. Wysocki
2011-05-19  9:26         ` Davide Ciminaghi
2011-05-19 14:25           ` [linux-pm] " Alan Stern
2011-05-19 20:52             ` Rafael J. Wysocki
2011-05-12 17:11 ` Raffaele Recalcati [this message]
2011-05-12 17:11 ` [PATCH 4/4] DaVinci: vpfe: support for pm_loss Raffaele Recalcati
2011-05-12 19:27 ` pm loss development Rafael J. Wysocki
2011-05-13  6:39   ` Raffaele Recalcati
2011-05-13 16:54     ` Rafael J. Wysocki
2011-05-14 16:35       ` [linux-pm] " mark gross
2011-05-17 23:07         ` Rafael J. Wysocki
2011-05-18  3:12           ` mark gross
2011-05-18 19:43             ` Rafael J. Wysocki
2011-05-18 22:17               ` Mark Brown
2011-05-19 12:45               ` mark gross
2011-06-02 22:21               ` Pavel Machek
2011-06-14 14:06                 ` mark gross
2011-06-14 14:36                   ` Alan Cox
2011-05-14 20:21       ` Raffaele Recalcati
2011-05-17 23:10         ` Rafael J. Wysocki
2011-05-14 18:53   ` [linux-pm] " Oliver Neukum
2011-05-14 20:34     ` Raffaele Recalcati
2011-05-17 23:06       ` Rafael J. Wysocki
2011-05-14 16:24 ` mark gross
2011-05-14 20:30   ` Raffaele Recalcati
2011-05-14 23:33     ` mark gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305220265-9020-4-git-send-email-lamiaposta71@gmail.com \
    --to=lamiaposta71@gmail.com \
    --cc=ciminaghi@gnudd.com \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=raffaele.recalcati@bticino.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome