From patchwork Wed Oct 2 08:30:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 2973391 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1AD719F88A for ; Wed, 2 Oct 2013 08:31:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCA3C2012C for ; Wed, 2 Oct 2013 08:31:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A92A62018C for ; Wed, 2 Oct 2013 08:31:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753380Ab3JBIbP (ORCPT ); Wed, 2 Oct 2013 04:31:15 -0400 Received: from mail-la0-f43.google.com ([209.85.215.43]:60287 "EHLO mail-la0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753151Ab3JBIbO (ORCPT ); Wed, 2 Oct 2013 04:31:14 -0400 Received: by mail-la0-f43.google.com with SMTP id ep20so342040lab.16 for ; Wed, 02 Oct 2013 01:31:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sbfgtevs/LBaedWKYPaeBziMPZOpGp9zTJLy5y41fB8=; b=BBFyw3YMkKIyXLLToLZHbk1tE4aVK0+OlViNJllFKR3OQQ5wpZsHVqkQAjWokCbjDz zuhDiXTIlh+6fSG7o6QyLJgnYR4QgFKnWekhsQkX1I5ovAh0SCUCoOfoQYyNxK1Y/qr+ 2CMV8b/0fIh43BRXxA+YydqoVPFvry6Y8ldb5x/qA5OV2ovZONRG6pJ4PTPitB0lp023 qNu0a4BUcwdRT/ihQTgz4hyVNWP9yOqWnN6vtlCiK9lJJRNgHn22fDNwVkGwhWBgRE+S uwDAguIHlDJN5zg1DyOD2ZWAabGFZMeszKwqTK5aeuESp9Ki28c3ZHTBMyl9Ukf/H5wf /QWw== X-Gm-Message-State: ALoCoQlhb80tYVyXvCifDFUP26nVBljkBpXEcsnFLAZ7xOhPrC8cIAem+xUkjrSJI+FS532b1bDJ X-Received: by 10.112.29.147 with SMTP id k19mr1269520lbh.9.1380702673049; Wed, 02 Oct 2013 01:31:13 -0700 (PDT) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id e4sm890041lba.15.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:12 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , Guennadi Liakhovetski Subject: [PATCH 6/7] mmc: sh_mmcif: Simplify clock and power setup in set_ios Date: Wed, 2 Oct 2013 10:30:50 +0200 Message-Id: <1380702651-13389-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1380702651-13389-1-git-send-email-ulf.hansson@linaro.org> References: <1380702651-13389-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch intend to simplify code in sh_mmcif_set_ios for how clock and power are being configured. Cc: Guennadi Liakhovetski Signed-off-by: Ulf Hansson --- drivers/mmc/host/sh_mmcif.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index e234856..0c3a5cf 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -244,7 +244,6 @@ struct sh_mmcif_host { size_t blocksize; int sg_idx; int sg_blkidx; - bool power; bool card_present; bool ccs_enable; /* Command Completion Signal support */ bool clk_ctrl2_enable; @@ -964,14 +963,13 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq) sh_mmcif_start_cmd(host, mrq); } -static void sh_mmcif_set_power(struct sh_mmcif_host *host, struct mmc_ios *ios) +static void sh_mmcif_set_power(struct sh_mmcif_host *host, unsigned short vdd) { struct mmc_host *mmc = host->mmc; if (!IS_ERR(mmc->supply.vmmc)) /* Errors ignored... */ - mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, - ios->power_mode ? ios->vdd : 0); + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); } static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) @@ -997,37 +995,22 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) sh_mmcif_request_dma(host, host->pd->dev.platform_data); host->card_present = true; } - sh_mmcif_set_power(host, ios); - } else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { - /* clock stop */ - sh_mmcif_clock_control(host, 0); - if (ios->power_mode == MMC_POWER_OFF) { - if (host->card_present) { - sh_mmcif_release_dma(host); - host->card_present = false; - } - } - if (host->power) { - host->power = false; - if (ios->power_mode == MMC_POWER_OFF) - sh_mmcif_set_power(host, ios); + sh_mmcif_set_power(host, ios->vdd); + sh_mmcif_sync_reset(host); + } else if (ios->power_mode == MMC_POWER_OFF) { + if (host->card_present) { + sh_mmcif_release_dma(host); + host->card_present = false; } - host->state = STATE_IDLE; - goto ret; + sh_mmcif_set_power(host, 0); } - if (ios->clock) { - if (!host->power) { - host->power = true; - sh_mmcif_sync_reset(host); - } - sh_mmcif_clock_control(host, ios->clock); - } + sh_mmcif_clock_control(host, ios->clock); host->timing = ios->timing; host->bus_width = ios->bus_width; host->state = STATE_IDLE; -ret: + pm_runtime_mark_last_busy(mmc_dev(mmc)); pm_runtime_put_autosuspend(mmc_dev(mmc)); } @@ -1417,8 +1400,6 @@ static int sh_mmcif_probe(struct platform_device *pdev) platform_set_drvdata(pdev, host); - host->power = false; - host->hclk = clk_get(&pdev->dev, NULL); if (IS_ERR(host->hclk)) { ret = PTR_ERR(host->hclk);