From patchwork Thu Feb 11 12:59:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 61754 Delivered-To: patches@linaro.org Received: by 10.112.43.199 with SMTP id y7csp175029lbl; Thu, 11 Feb 2016 05:00:11 -0800 (PST) X-Received: by 10.25.24.68 with SMTP id o65mr15298621lfi.156.1455195611584; Thu, 11 Feb 2016 05:00:11 -0800 (PST) Return-Path: Received: from mail-lf0-x22e.google.com (mail-lf0-x22e.google.com. [2a00:1450:4010:c07::22e]) by mx.google.com with ESMTPS id ko18si4227164lbb.81.2016.02.11.05.00.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 05:00:11 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22e as permitted sender) client-ip=2a00:1450:4010:c07::22e; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22e as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-lf0-x22e.google.com with SMTP id 78so30957899lfy.3 for ; Thu, 11 Feb 2016 05:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=83bYG5jD5FWYxmktnofufBBAF4k2mLAn9dnIM5FIKWA=; b=FmcYN4GGMP8TwH39172akFjp1xBbcLOqEaP8w3eYjZFJa33rxSYNIQo8NEusZqtaFL sQ8cFvgQwYKsfQPBq4MtVNqODwOo6ks5fExA5iGhKpg0iSqlMK4m7lvYbflGBviVPIhk 7TN+QWGDWT5Ae5n0rm1wukbidyeW+11me06Ec= 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; bh=83bYG5jD5FWYxmktnofufBBAF4k2mLAn9dnIM5FIKWA=; b=HhL3/wQA8H5sD8TKwtYQSfZhT9p7E29v663WfMSbg1Z7em1u85KYLmggFvj+qz9dg5 MJvFGQDxOl1QmwUYB0Fm4fKXjplUEgkoPjGR3h76tnHSspih+GiyuRJ5N9usN52z121K 4/SCDRsGjXrPAx/K5uocUOOUfNDm7drBP9qLcs9xHcMMgyAosiaeafKLhwO0DhQYnD7n ShLvzbWK9jsJabP7mjtBhwejdPiLDXsewXBIOrsRRuybC3KFLu62E2aGhR8X7d43g10/ V0d2pR2cx5wKYyFrFOIaiBY+AQQy8KWHaQYnfn9K5fDNljrjXDLbIWlA/dO4oHiVSC6x PnXg== X-Gm-Message-State: AG10YOSDVhudNB6h7U2r7tvbgsh2vgnaUY+DTppQyI6hDdxxoFdBo57I5hWdOslfgR/EivIVp3E= X-Received: by 10.25.168.67 with SMTP id r64mr4539545lfe.104.1455195610881; Thu, 11 Feb 2016 05:00:10 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id dm7sm1179635lbc.32.2016.02.11.05.00.09 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Feb 2016 05:00:10 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Kuninori Morimoto , Geert Uytterhoeven , Nguyen Viet Dung , Magnus Damm , Simon Horman , Laurent Pinchart Subject: [PATCH 1/3] mmc: sh_mmcif: Make sure the device stays active when needed in ->probe() Date: Thu, 11 Feb 2016 13:59:53 +0100 Message-Id: <1455195595-5121-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 While accessing the device, make sure it stays active by increasing the runtime PM usage count for it. Let's also defer to enable runtime PM until we really need access to the device. This also enables the error path in ->probe() to become simpler. Signed-off-by: Ulf Hansson --- drivers/mmc/host/sh_mmcif.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 8d870ce..c6c2a08 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -1519,23 +1519,23 @@ static int sh_mmcif_probe(struct platform_device *pdev) platform_set_drvdata(pdev, host); - pm_runtime_enable(dev); - host->power = false; - host->clk = devm_clk_get(dev, NULL); if (IS_ERR(host->clk)) { ret = PTR_ERR(host->clk); dev_err(dev, "cannot get clock: %d\n", ret); - goto err_pm; + goto err_host; } ret = clk_prepare_enable(host->clk); if (ret < 0) - goto err_pm; + goto err_host; sh_mmcif_clk_setup(host); - ret = pm_runtime_resume(dev); + pm_runtime_enable(dev); + host->power = false; + + ret = pm_runtime_get_sync(dev); if (ret < 0) goto err_clk; @@ -1579,12 +1579,13 @@ static int sh_mmcif_probe(struct platform_device *pdev) sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0xffff, clk_get_rate(host->clk) / 1000000UL); + pm_runtime_put(dev); clk_disable_unprepare(host->clk); return ret; err_clk: clk_disable_unprepare(host->clk); -err_pm: + pm_runtime_put_sync(dev); pm_runtime_disable(dev); err_host: mmc_free_host(mmc);