From patchwork Mon Jan 21 13:03:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 14178 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 C091623DFE for ; Mon, 21 Jan 2013 13:08:08 +0000 (UTC) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by fiordland.canonical.com (Postfix) with ESMTP id 6EDFFA191B7 for ; Mon, 21 Jan 2013 13:08:08 +0000 (UTC) Received: by mail-vc0-f177.google.com with SMTP id m18so1238169vcm.36 for ; Mon, 21 Jan 2013 05:08:08 -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:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=rV9sselj5bSkevdpA9wPJhlM9f5d2izYCE8MvPryR4Y=; b=CCCjYx1Wyr/rEg3AsaNkWG8+rEWBw3rbJHnM9wp6Pj2MBKqbGE85+9OXAsmGuIfPrZ Us9mDfpMFGL9qXh0lA2kWP4zk4A2ZmvtmtSOtNxqbmPxeDMBkK+kIspVCrmjiK4khSHO pB1Z+8Q26JRDoOO/2QzVTNnEC+ujSrceN4f4q28Ga1/oS+BmerWIpkCt4i2yPTapRGol fsXtvg2IM5tMnlSnJ0U/7aK/T6nMr9TPd/IqJl1i2ovGWWWqPZ/g5Z2JyiFJ6Gb5rvq8 6WoVF6MDkp2udNjDGrkmgcO5ufXX4q9Uzm3lBm9jVrCVCPPkL6fK01XbW11NUOaIG4MM J82g== X-Received: by 10.52.88.168 with SMTP id bh8mr16575740vdb.51.1358773687783; Mon, 21 Jan 2013 05:08:07 -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 st5csp200230veb; Mon, 21 Jan 2013 05:08:06 -0800 (PST) X-Received: by 10.68.224.130 with SMTP id rc2mr29457714pbc.156.1358773685606; Mon, 21 Jan 2013 05:08:05 -0800 (PST) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by mx.google.com with ESMTPS id y1si14002134pav.248.2013.01.21.05.08.05 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jan 2013 05:08:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.47 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.220.47; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.47 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by mail-pa0-f47.google.com with SMTP id fa10so3396462pad.6 for ; Mon, 21 Jan 2013 05:08:05 -0800 (PST) X-Received: by 10.69.1.66 with SMTP id be2mr28394255pbd.42.1358773684599; Mon, 21 Jan 2013 05:08:04 -0800 (PST) Received: from localhost.localdomain ([115.241.62.242]) by mx.google.com with ESMTPS id p9sm9264583pao.29.2013.01.21.05.07.59 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jan 2013 05:08:03 -0800 (PST) From: Rajagopal Venkat To: mturquette@linaro.org Cc: patches@linaro.org, linaro-dev@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Rajagopal Venkat Subject: [PATCH] clk: allow reparenting of a clock to the orphan list Date: Mon, 21 Jan 2013 18:33:57 +0530 Message-Id: <1358773437-21163-1-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQk3lBfuXLWGMv6hQPudZdQ6ZvZ/JJL51Li39gu6RHyDzi5CZpbBwfT1v/0mhFJqiAugFq5d Allow reparenting of a clock(multiple and single parent) to the orphan list when new parent clock is NULL. Signed-off-by: Rajagopal Venkat --- drivers/clk/clk.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index e964994..5c9277a 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1102,7 +1102,7 @@ void __clk_reparent(struct clk *clk, struct clk *new_parent) struct dentry *new_parent_d; #endif - if (!clk || !new_parent) + if (!clk) return; hlist_del(&clk->child_node); @@ -1140,11 +1140,14 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent) { struct clk *old_parent; unsigned long flags; - int ret = -EINVAL; - u8 i; + int ret = 0; + u8 i = 0; old_parent = clk->parent; + if (clk->num_parents == 1 || !parent) + goto migrate; + if (!clk->parents) clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents), GFP_KERNEL); @@ -1165,11 +1168,13 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent) } if (i == clk->num_parents) { + ret = -EINVAL; pr_debug("%s: clock %s is not a possible parent of clock %s\n", __func__, parent->name, clk->name); goto out; } +migrate: /* migrate prepare and enable */ if (clk->prepare_count) __clk_prepare(parent); @@ -1181,7 +1186,8 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent) spin_unlock_irqrestore(&enable_lock, flags); /* change clock input source */ - ret = clk->ops->set_parent(clk->hw, i); + if (clk->ops->set_parent) + ret = clk->ops->set_parent(clk->hw, i); /* clean up old prepare and enable */ spin_lock_irqsave(&enable_lock, flags); @@ -1215,7 +1221,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent) if (!clk || !clk->ops) return -EINVAL; - if (!clk->ops->set_parent) + if (clk->num_parents > 1 && !clk->ops->set_parent) return -ENOSYS; /* prevent racing with updates to the clock topology */ @@ -1226,7 +1232,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent) /* propagate PRE_RATE_CHANGE notifications */ if (clk->notifier_count) - ret = __clk_speculate_rates(clk, parent->rate); + ret = __clk_speculate_rates(clk, parent ? parent->rate : 0); /* abort if a driver objects */ if (ret == NOTIFY_STOP)