lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 21 Mar 2011 19:46:41 +0100
From:	Antonio Ospite <ospite@...denti.unina.it>
To:	linux-mmc@...r.kernel.org
Cc:	Antonio Ospite <ospite@...denti.unina.it>,
	Daniel Ribeiro <drwyrm@...il.com>,
	David Brownell <dbrownell@...rs.sourceforge.net>,
	Chris Ball <cjb@...top.org>,
	Grant Likely <grant.likely@...retlab.ca>,
	Ernst Schwab <eschwab@...ine.de>,
	Sonic Zhang <sonic.zhang@...log.com>,
	Linus Walleij <linus.walleij@...ricsson.com>,
	openezx-devel@...ts.openezx.org, linux-kernel@...r.kernel.org
Subject: [PATCH 3/4] mmc_spi.c: factor out a mmc_spi_setpower() function

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@...denti.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 fe0fdc4..5e4b2c7 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.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ