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 X-Patchwork-Id: 2012211 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id F3B173FD1A for ; Mon, 21 Jan 2013 13:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754001Ab3AUNIH (ORCPT ); Mon, 21 Jan 2013 08:08:07 -0500 Received: from mail-pb0-f52.google.com ([209.85.160.52]:62048 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753668Ab3AUNIG (ORCPT ); Mon, 21 Jan 2013 08:08:06 -0500 Received: by mail-pb0-f52.google.com with SMTP id ro2so3305563pbb.25 for ; Mon, 21 Jan 2013 05:08:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=rV9sselj5bSkevdpA9wPJhlM9f5d2izYCE8MvPryR4Y=; b=EWauM5TjVhJYRSCDFVE/qy1Jtiu/9XCnCGLUoLpP81Dfs7iuZwZ524geQqFR0jAFrj YKdX3jTJTBAZJ+IJaPNRK9NiESPL3m1YVcRni2XGj0mnlPw26ixvGlAiR8fE0rsP3N/Y l21KVAUYNgxnUeVVNfZ/RTK2WhPWgikcU6sqB1fki3fi5vxvB3ceLE9AsnH3flNfrqTD YGsRNofZ4wTlhwH+QShzAEdHIUoxK1xZlprfUt9QfgukIQisDhiqkU6LE52VIT4wP8fX 5l5g2rrIVba6bpYhWA8MK8OOR0B5fpGM+z3xINew7hXQM2bZJ+W0JOBe4qpv5CM2r5G6 fuxw== 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: ALoCoQm7zZoscNEVLTJbnpDFS6Rx09iRBaaO64alhikwIDluCN134Iiz0YtzGIt/+cB7dq8eLsMX Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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)