From patchwork Mon Mar 21 18:46:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 648661 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 p2LImHG3021608 for ; Mon, 21 Mar 2011 18:48:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753344Ab1CUSri (ORCPT ); Mon, 21 Mar 2011 14:47:38 -0400 Received: from smtp208.alice.it ([82.57.200.104]:50743 "EHLO smtp208.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752468Ab1CUSrQ (ORCPT ); Mon, 21 Mar 2011 14:47:16 -0400 Received: from jcn (79.2.146.74) by smtp208.alice.it (8.5.124.08) id 4C1A271615023888; Mon, 21 Mar 2011 19:46:51 +0100 Received: from ao2 by jcn with local (Exim 4.74) (envelope-from ) id 1Q1k7s-00077D-Pk; Mon, 21 Mar 2011 19:46:48 +0100 From: Antonio Ospite To: linux-mmc@vger.kernel.org Cc: Antonio Ospite , Daniel Ribeiro , David Brownell , Chris Ball , Grant Likely , Ernst Schwab , Sonic Zhang , Linus Walleij , openezx-devel@lists.openezx.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] mmc_spi.c: factor out the check for power capability Date: Mon, 21 Mar 2011 19:46:39 +0100 Message-Id: <1300733202-27316-2-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1300733202-27316-1-git-send-email-ospite@studenti.unina.it> References: <1300733202-27316-1-git-send-email-ospite@studenti.unina.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE 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.6 (demeter1.kernel.org [140.211.167.41]); Mon, 21 Mar 2011 18:48:18 +0000 (UTC) diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index fd877f6..1db18ce 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -152,6 +152,10 @@ struct mmc_spi_host { dma_addr_t ones_dma; }; +static inline int mmc_spi_canpower(struct mmc_spi_host *host) +{ + return host->pdata && host->pdata->setpower; +} /****************************************************************************/ @@ -1187,19 +1191,16 @@ 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 canpower; - - canpower = host->pdata && host->pdata->setpower; dev_dbg(&host->spi->dev, "mmc_spi: power %s (%d)%s\n", mmc_powerstring(ios->power_mode), ios->vdd, - canpower ? ", can switch" : ""); + mmc_spi_canpower(host) ? ", can switch" : ""); /* switch power on/off if possible, accounting for * max 250msec powerup time if needed. */ - if (canpower) { + if (mmc_spi_canpower(host)) { switch (ios->power_mode) { case MMC_POWER_OFF: case MMC_POWER_UP: @@ -1223,7 +1224,8 @@ static void mmc_spi_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) * - MOSI low comes from writing zero * - Chipselect is usually active low... */ - if (canpower && ios->power_mode == MMC_POWER_OFF) { + if (mmc_spi_canpower(host) && + ios->power_mode == MMC_POWER_OFF) { int mres; u8 nullbyte = 0; @@ -1399,7 +1401,7 @@ static int mmc_spi_probe(struct spi_device *spi) dev_warn(&spi->dev, "ASSUMING 3.2-3.4 V slot power\n"); mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34; } - if (host->pdata && host->pdata->setpower) { + if (mmc_spi_canpower(host)) { host->powerup_msecs = host->pdata->powerup_msecs; if (!host->powerup_msecs || host->powerup_msecs > 250) host->powerup_msecs = 250; @@ -1459,7 +1461,7 @@ static int mmc_spi_probe(struct spi_device *spi) host->dma_dev ? "" : ", no DMA", (host->pdata && host->pdata->get_ro) ? "" : ", no WP", - (host->pdata && host->pdata->setpower) + mmc_spi_canpower(host) ? "" : ", no poweroff", (mmc->caps & MMC_CAP_NEEDS_POLL) ? ", cd polling" : "");