From patchwork Fri Mar 1 12:47:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 15198 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8F9EE23E27 for ; Fri, 1 Mar 2013 13:10:02 +0000 (UTC) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by fiordland.canonical.com (Postfix) with ESMTP id 259A2A181AB for ; Fri, 1 Mar 2013 13:10:02 +0000 (UTC) Received: by mail-ve0-f172.google.com with SMTP id cz11so2920181veb.3 for ; Fri, 01 Mar 2013 05:10:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:content-type:x-gm-message-state; bh=imrBC4516UKBG5dtge39r99SYB8FRt6OfLtlU0g0YXc=; b=EoDeuBorvtTLQlC1ZfTtmqCPZiW8Z8TUNwplZBAy8gSDgjsQiybP9xDdqvrY7RMkq0 kYSLi9CNCTXbfdmwMiC/lDrCsVrmcoRgHrh0srlJ80/+sFJ+gq1aANLkF4xAhjJYrSEq RsPvqzqyouCdRFNEuk2qZpA53b/SeHDKbJ6OXO5bUYy5qI0aTPEfVvJsCzaJOzAKp2F0 jQim/CxP6tHn9PBeEpyv46JODhxqJ8asBupDFVdaHpaJ3Y3DtMRcAa6UyLBsupRT20GX SNrlW1yYqw8AIuljffTsrFInHERoqoEhODBCV95MAXg3fi5Rjb5lwyy1uzd6nbN9yScl Qyfg== X-Received: by 10.52.29.18 with SMTP id f18mr3471718vdh.57.1362143401689; Fri, 01 Mar 2013 05:10:01 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp32003veb; Fri, 1 Mar 2013 05:10:00 -0800 (PST) X-Received: by 10.14.204.195 with SMTP id h43mr18735171eeo.14.1362143400319; Fri, 01 Mar 2013 05:10:00 -0800 (PST) Received: from eu1sys200aog108.obsmtp.com (eu1sys200aog108.obsmtp.com [207.126.144.125]) by mx.google.com with SMTP id g8si18430533eem.59.2013.03.01.05.09.57 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 01 Mar 2013 05:09:59 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.125 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.125; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.125 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob108.postini.com ([207.126.147.11]) with SMTP ID DSNKUTCopJDH9UlUNwE1tgravjJ8iPapRTiD@postini.com; Fri, 01 Mar 2013 13:09:59 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 481F91E2; Fri, 1 Mar 2013 12:47:29 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id AB5844DF1; Fri, 1 Mar 2013 12:47:29 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 8000CA8074; Fri, 1 Mar 2013 13:47:24 +0100 (CET) Received: from steludxu1397.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 1 Mar 2013 13:47:29 +0100 From: Ulf Hansson To: , Chris Ball Cc: Johan Rudholm , Ulf Hansson Subject: [PATCH 2/3] mmc: core: Add bus_ops for runtime pm callbacks Date: Fri, 1 Mar 2013 13:47:14 +0100 Message-ID: <1362142035-8403-3-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1362142035-8403-1-git-send-email-ulf.hansson@stericsson.com> References: <1362142035-8403-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQn3eZNGBKOd96eOjPEaBxPgqHtwUppCTB3qpnBilcUqFoGC8uOoK3e3S/IAmymLsDKEoykL From: Ulf Hansson SDIO is the only protocol that uses runtime pm for the card device right now. To provide the option for sd and mmc to use runtime pm as well the bus_ops callback are extended with two new functions. One for runtime_suspend and one for runtime_resume. This patch will also implement the callbacks for SDIO to make sure existing functionallity is maintained. Signed-off-by: Ulf Hansson --- drivers/mmc/core/bus.c | 14 ++++++++++++-- drivers/mmc/core/core.h | 2 ++ drivers/mmc/core/sdio.c | 20 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index e219c97..d9e8c2b 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -151,15 +151,25 @@ static int mmc_bus_resume(struct device *dev) static int mmc_runtime_suspend(struct device *dev) { struct mmc_card *card = mmc_dev_to_card(dev); + struct mmc_host *host = card->host; + int ret = 0; + + if (host->bus_ops->runtime_suspend) + ret = host->bus_ops->runtime_suspend(host); - return mmc_power_save_host(card->host); + return ret; } static int mmc_runtime_resume(struct device *dev) { struct mmc_card *card = mmc_dev_to_card(dev); + struct mmc_host *host = card->host; + int ret = 0; + + if (host->bus_ops->runtime_resume) + ret = host->bus_ops->runtime_resume(host); - return mmc_power_restore_host(card->host); + return ret; } static int mmc_runtime_idle(struct device *dev) diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index b9f18a2..9445519 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -22,6 +22,8 @@ struct mmc_bus_ops { void (*detect)(struct mmc_host *); int (*suspend)(struct mmc_host *); int (*resume)(struct mmc_host *); + int (*runtime_suspend)(struct mmc_host *); + int (*runtime_resume)(struct mmc_host *); int (*power_save)(struct mmc_host *); int (*power_restore)(struct mmc_host *); int (*alive)(struct mmc_host *); diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index aa0719a..0e6e8c1 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -988,6 +988,24 @@ static int mmc_sdio_resume(struct mmc_host *host) return err; } +static int mmc_sdio_runtime_suspend(struct mmc_host *host) +{ + /* + * Once sdio clients has entirely switched to runtime pm we wrap + * the call to power_save here. + */ + return mmc_power_save_host(host); +} + +static int mmc_sdio_runtime_resume(struct mmc_host *host) +{ + /* + * Once sdio clients has entirely switched to runtime pm we wrap + * the call to power_restore here. + */ + return mmc_power_restore_host(host); +} + static int mmc_sdio_power_restore(struct mmc_host *host) { int ret; @@ -1054,6 +1072,8 @@ static const struct mmc_bus_ops mmc_sdio_ops = { .detect = mmc_sdio_detect, .suspend = mmc_sdio_suspend, .resume = mmc_sdio_resume, + .runtime_suspend = mmc_sdio_runtime_suspend, + .runtime_resume = mmc_sdio_runtime_resume, .power_restore = mmc_sdio_power_restore, .alive = mmc_sdio_alive, };