linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Ospite <ospite@studenti.unina.it>
To: linux-mmc@vger.kernel.org
Cc: Antonio Ospite <ospite@studenti.unina.it>,
	Chris Ball <cjb@laptop.org>,
	Grant Likely <grant.likely@secretlab.ca>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	openezx-devel@lists.openezx.org,
	spi-devel-general@lists.sourceforge.net
Subject: [RESEND PATCH 3/4] mmc_spi.c: factor out a mmc_spi_setpower() function
Date: Thu, 21 Apr 2011 14:27:52 +0200	[thread overview]
Message-ID: <1303388873-15467-4-git-send-email-ospite@studenti.unina.it> (raw)
In-Reply-To: <1303388873-15467-1-git-send-email-ospite@studenti.unina.it>

Factor out a mmc_spi_setpower() function so to make changing it more
elegant without adding too much stuff to mmc_spi_set_ios().

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
---
 drivers/mmc/host/mmc_spi.c |   43 +++++++++++++++++++++++++++++++------------
 1 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 9eae23c..0f3672d 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1221,6 +1221,26 @@ static void mmc_spi_shutdownsequence(struct mmc_spi_host *host)
 	}
 }
 
+static inline int mmc_spi_setpower(struct mmc_spi_host *host,
+					unsigned char power_mode,
+					unsigned int vdd)
+{
+	/* switch power on/off if possible, accounting for
+	 * max 250msec powerup time if needed.
+	 */
+	if (mmc_spi_canpower(host)) {
+		switch (power_mode) {
+		case MMC_POWER_OFF:
+		case MMC_POWER_UP:
+			host->pdata->setpower(&host->spi->dev, vdd);
+			if (power_mode == MMC_POWER_UP)
+				msleep(host->powerup_msecs);
+		}
+	}
+
+	return 0;
+}
+
 static char *mmc_powerstring(u8 power_mode)
 {
 	switch (power_mode) {
@@ -1236,24 +1256,23 @@ static void mmc_spi_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	struct mmc_spi_host *host = mmc_priv(mmc);
 
 	if (host->power_mode != ios->power_mode) {
+		int ret;
 
 		dev_dbg(&host->spi->dev, "mmc_spi: power %s (%d)%s\n",
 				mmc_powerstring(ios->power_mode),
 				ios->vdd,
 				mmc_spi_canpower(host) ? ", can switch" : "");
 
-		/* switch power on/off if possible, accounting for
-		 * max 250msec powerup time if needed.
-		 */
-		if (mmc_spi_canpower(host)) {
-			switch (ios->power_mode) {
-			case MMC_POWER_OFF:
-			case MMC_POWER_UP:
-				host->pdata->setpower(&host->spi->dev,
-						ios->vdd);
-				if (ios->power_mode == MMC_POWER_UP)
-					msleep(host->powerup_msecs);
-			}
+		ret = mmc_spi_setpower(host, ios->power_mode, ios->vdd);
+		if (ret) {
+			dev_err(mmc_dev(mmc), "unable to set power\n");
+			/*
+			 * The .set_ios() function in the mmc_host_ops
+			 * struct return void, and failing to set the
+			 * power should be rare so we print an error and
+			 * return here.
+			 */
+			return;
 		}
 
 		/* See 6.4.1 in the simplified SD card physical spec 2.0 */
-- 
1.7.4.4


  parent reply	other threads:[~2011-04-21 12:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1300733202-27316-1-git-send-email-ospite@studenti.unina.it>
2011-04-21 12:27 ` [RESEND PATCH 0/4] mmc_spi: Add support for regulator framework Antonio Ospite
2011-04-21 12:27   ` [RESEND PATCH 1/4] mmc_spi.c: factor out the check for power capability Antonio Ospite
2011-04-21 12:27   ` [RESEND PATCH 2/4] mmc_spi.c: factor out the SD card shutdown sequence Antonio Ospite
2011-04-21 12:27   ` Antonio Ospite [this message]
2011-04-21 12:27   ` [RESEND PATCH 4/4] mmc_spi.c: add support for the regulator framework Antonio Ospite
2011-04-21 12:40     ` Mark Brown
2011-04-21 12:49       ` Antonio Ospite
2011-04-26 21:21         ` Daniel Ribeiro
2011-04-22 12:43       ` [PATCH v2 " Antonio Ospite
2011-05-06 14:30         ` Antonio Ospite
2011-05-11 10:39         ` [PATCH v3] " Antonio Ospite
     [not found]           ` <1305110379-17218-1-git-send-email-ospite-aNJ+ML1ZbiP93QAQaVx+gl6hYfS7NtTn@public.gmane.org>
2011-05-11 13:08             ` Mark Brown
2011-05-11 20:53               ` Antonio Ospite
2011-05-11 20:57                 ` Mark Brown
2011-05-18 17:23                   ` Antonio Ospite
2011-05-18 19:42                     ` Mark Brown
2011-05-23 15:10                       ` Antonio Ospite
2011-05-30  9:07                         ` Antonio Ospite
2011-05-30 10:14                           ` Mark Brown
2011-05-30 10:57                             ` Antonio Ospite
2011-05-31 10:05                               ` Mark Brown

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=1303388873-15467-4-git-send-email-ospite@studenti.unina.it \
    --to=ospite@studenti.unina.it \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=cjb@laptop.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-mmc@vger.kernel.org \
    --cc=openezx-devel@lists.openezx.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    /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;
as well as URLs for NNTP newsgroup(s).