From patchwork Tue Oct 22 14:07:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 3082961 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 84789BF924 for ; Tue, 22 Oct 2013 14:08:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA6492039B for ; Tue, 22 Oct 2013 14:07:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A892120381 for ; Tue, 22 Oct 2013 14:07:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752822Ab3JVOHy (ORCPT ); Tue, 22 Oct 2013 10:07:54 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:38080 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752351Ab3JVOHx (ORCPT ); Tue, 22 Oct 2013 10:07:53 -0400 Received: by mail-lb0-f169.google.com with SMTP id o14so2591499lbi.0 for ; Tue, 22 Oct 2013 07:07:52 -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=Gs3S0Wz+CHF18ExBnsmoYG7ycHYdMi3r+OFwuAVG1Bk=; b=E6N2WpimqnpvyL/R6Hlf6Mj6eUGj2Q9IOuY2Gsmz32sGuI4c7O3JjBj9hQSiOVKf+5 iob8RdfkUFb9bLSEA98m1u0FN82HX+siZ9AkmwsyxmhyjJX7HqXTnxWDaDVOABifrP0T PCj0kgr8BDF038j4MvNa+lV06dD95SYmssrVyX9g3eAn1h2uNQRr51JRLxvg/M5k5iAd T8d6tMctLhA2pxeq/hO0UYrnIjQ5VVLJBUQAob75vUTCpyJ/Q8elGtv90vyt4jcjknBs pUnfVFyTJ3hSefh413Wr6fcvvSGInA9EuShrBRlPqBpBYTB3RmzFhzLwKRk0Go2o5a9l QBnw== X-Gm-Message-State: ALoCoQnx69XQG+83UCTEf09jAslBau1F6vy/kUDOtLDsPQL+RRtrtbL8PQ2s1A67ifRGWKrs6bsv X-Received: by 10.152.27.67 with SMTP id r3mr1506378lag.50.1382450872357; Tue, 22 Oct 2013 07:07:52 -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 ur6sm15932916lbc.5.2013.10.22.07.07.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 07:07:51 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , Guennadi Liakhovetski Subject: [PATCH v2 6/7] mmc: sh_mmcif: Simplify clock and power setup in set_ios Date: Tue, 22 Oct 2013 16:07:25 +0200 Message-Id: <1382450846-17144-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1382450846-17144-1-git-send-email-ulf.hansson@linaro.org> References: <1382450846-17144-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.3 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 a1f421b..07c3af5 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; @@ -977,14 +976,13 @@ static int sh_mmcif_clk_update(struct sh_mmcif_host *host) return ret; } -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) @@ -1010,37 +1008,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)); } @@ -1430,8 +1413,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);