From patchwork Thu Jan 24 16:45:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 14277 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 0DAAD23F79 for ; Thu, 24 Jan 2013 16:46:20 +0000 (UTC) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by fiordland.canonical.com (Postfix) with ESMTP id 565C5A1950C for ; Thu, 24 Jan 2013 16:46:19 +0000 (UTC) Received: by mail-ve0-f182.google.com with SMTP id pb11so1584105veb.13 for ; Thu, 24 Jan 2013 08:46:18 -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=afZ9mgSmpnfr+kUmol00AWOfm2ph5e3C0i+PL3d895A=; b=T6YjNaB3smUvQjy6P9yy9ZT8riEchLindCTTAWuGhs0aah7WC/RxYl0a2LMkaWBHkz wj4A0LHNWe8NXkgXJfQJ9U5YTUemabaIgaRVsaU57zhshQvvV7b47kMfWi6uSjqd09y2 ckhsJzMOLFyHJy6bqXmtTXCOR+FwGzbyYqwRoJtYrubinux6PcDshvTBrw6+Ib94kBRu WtxcrQ5XpiJTQFGtLJU/gsXSbuN4xwNDnoeYbIftFYbpFShXe5knCdMGLHK8Psy0GTMP rcIXVGaJ27hU/UDNGq6+/cu+S8P5uat6VYlCPnSiaNj/2uMd1uNeLkVS27sckDm3W+bt gyGA== X-Received: by 10.52.34.108 with SMTP id y12mr2319331vdi.8.1359045978583; Thu, 24 Jan 2013 08:46:18 -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 st5csp74440veb; Thu, 24 Jan 2013 08:46:18 -0800 (PST) X-Received: by 10.194.108.229 with SMTP id hn5mr4401254wjb.8.1359045977612; Thu, 24 Jan 2013 08:46:17 -0800 (PST) Received: from eu1sys200aog118.obsmtp.com (eu1sys200aog118.obsmtp.com [207.126.144.145]) by mx.google.com with SMTP id 47si42570200eea.245.2013.01.24.08.46.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 24 Jan 2013 08:46:17 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.145 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.145; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.145 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 eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKUQFlViowBEFoTs2GZp16p6m0RCivCcJt@postini.com; Thu, 24 Jan 2013 16:46:17 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 7ADA71C7; Thu, 24 Jan 2013 16:46:13 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0F20F500D; Thu, 24 Jan 2013 16:46:13 +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 relay1.stm.gmessaging.net (Postfix) with ESMTPS id 4603524C2F1; Thu, 24 Jan 2013 17:46:04 +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; Thu, 24 Jan 2013 17:46:11 +0100 From: Ulf Hansson To: , Mike Turquette Cc: Linus Walleij , Philippe Begnic , Ulf Hansson Subject: [PATCH 3/4] clk: Introduce optional unprepare_unused callback Date: Thu, 24 Jan 2013 17:45:55 +0100 Message-ID: <1359045956-30741-4-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1359045956-30741-1-git-send-email-ulf.hansson@stericsson.com> References: <1359045956-30741-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQk7HwqxpYWT4kFjWt/JcOuKpADsAfMCzTTL+3rMesqXzyG7PLR62NpJSF/t+N6NSHRFqfou From: Ulf Hansson An unprepare_unused callback is introduced due to the same reasons to why the disable_unused callback was added. During the clk_disable_unused sequence, those clk_hw that needs specific treatment with regards to being unprepared, shall implement the unprepare_unused callback. Signed-off-by: Ulf Hansson Acked-by: Linus Walleij --- drivers/clk/clk.c | 7 +++++-- include/linux/clk-provider.h | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0944348..d8dc6d7c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -358,9 +358,12 @@ static void clk_unprepare_unused_subtree(struct clk *clk) if (clk->flags & CLK_IGNORE_UNUSED) return; - if (__clk_is_prepared(clk)) - if (clk->ops->unprepare) + if (__clk_is_prepared(clk)) { + if (clk->ops->unprepare_unused) + clk->ops->unprepare_unused(clk->hw); + else if (clk->ops->unprepare) clk->ops->unprepare(clk->hw); + } } /* caller must hold prepare_lock */ diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 86ff6be..9e97fb4 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -49,6 +49,10 @@ struct clk_hw; * This function is allowed to sleep. Optional, if this op is not * set then the prepare count will be used. * + * @unprepare_unused: Unprepare the clock atomically. Only called from + * clk_disable_unused for prepare clocks with special needs. + * Called with prepare mutex held. This function may sleep. + * * @enable: Enable the clock atomically. This must not return until the * clock is generating a valid clock signal, usable by consumer * devices. Called with enable_lock held. This function must not @@ -113,6 +117,7 @@ struct clk_ops { int (*prepare)(struct clk_hw *hw); void (*unprepare)(struct clk_hw *hw); int (*is_prepared)(struct clk_hw *hw); + void (*unprepare_unused)(struct clk_hw *hw); int (*enable)(struct clk_hw *hw); void (*disable)(struct clk_hw *hw); int (*is_enabled)(struct clk_hw *hw);