From patchwork Tue Jan 15 22:45:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 14084 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 E5AAD24194 for ; Tue, 15 Jan 2013 22:45:15 +0000 (UTC) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by fiordland.canonical.com (Postfix) with ESMTP id 62BB4A198CC for ; Tue, 15 Jan 2013 22:45:15 +0000 (UTC) Received: by mail-vc0-f171.google.com with SMTP id n11so714641vch.30 for ; Tue, 15 Jan 2013 14:45:14 -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:content-type:mime-version :content-transfer-encoding:to:from:in-reply-to:cc:references :message-id:user-agent:subject:date:x-gm-message-state; bh=NP0afm2SsY4KhHi6q/P0+Ag/2tiyf7TmbNW4VqZ5O+s=; b=MGUzW5cM7g31jqmKmi0lazFKaxdSyPVL7HsufEBbksP155yJq88DmAeiUAaxuOdXop PgZEfSaEHwQ3o/23VMRSX2EBjBOmrypfnth3VCgzmw9VcRDVRJefKxznEyqjKMlT62lW eQM8xWFv2MX+oqrs1wIANmOdga/cPm4En5+9Gk+5xCzjlAZUDyFtCV6SgitOm5KBuKVA 2AtOYHMLySwMp5zZyAXYZY0iHgFuXOJbg5cXWqUtFPdKkr943iFbTN6zBxoJUgb1ssqt AI6dGtX0Gv7SYLa3Bi2unZFuEFSp5OVdo7IRvOcCFS6s/eDO+NQmbrT29ITzc3RgRpqu OcTA== X-Received: by 10.52.90.241 with SMTP id bz17mr93384021vdb.40.1358289914567; Tue, 15 Jan 2013 14:45:14 -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 st5csp137666veb; Tue, 15 Jan 2013 14:45:13 -0800 (PST) X-Received: by 10.68.233.99 with SMTP id tv3mr86943590pbc.64.1358289912804; Tue, 15 Jan 2013 14:45:12 -0800 (PST) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx.google.com with ESMTPS id ac7si19260499pbd.253.2013.01.15.14.45.10 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jan 2013 14:45:12 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of mturquette@linaro.org) client-ip=209.85.220.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of mturquette@linaro.org) smtp.mail=mturquette@linaro.org Received: by mail-pa0-f46.google.com with SMTP id bh2so387377pad.19 for ; Tue, 15 Jan 2013 14:45:10 -0800 (PST) X-Received: by 10.68.134.228 with SMTP id pn4mr48466013pbb.31.1358289910793; Tue, 15 Jan 2013 14:45:10 -0800 (PST) Received: from localhost (adsl-69-228-82-185.dsl.pltn13.pacbell.net. [69.228.82.185]) by mx.google.com with ESMTPS id sb3sm10960303pbc.44.2013.01.15.14.45.06 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 15 Jan 2013 14:45:08 -0800 (PST) MIME-Version: 1.0 To: Rajagopal Venkat , From: Mike Turquette In-Reply-To: <1357712988-22317-1-git-send-email-rajagopal.venkat@linaro.org> Cc: patches@linaro.org, linaro-dev@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Rajagopal Venkat References: <1357650191-30842-1-git-send-email-rajagopal.venkat@linaro.org> <1357712988-22317-1-git-send-email-rajagopal.venkat@linaro.org> Message-ID: <20130115224502.23734.7414@quantum> User-Agent: alot/0.3.3+ Subject: Re: [PATCH] clk: remove unreachable code Date: Tue, 15 Jan 2013 14:45:02 -0800 X-Gm-Message-State: ALoCoQkseu7cwyUEneymQxcqQZcGhymhIHbzk1BxOuOi62I/9w4IQefOsaK3pB/9HX86TVmgetl7 Quoting Rajagopal Venkat (2013-01-08 22:29:48) > while reparenting a clock, NULL check is done for clock in > consideration and its new parent. So re-check is not required. > If done, else part becomes unreachable. > > Signed-off-by: Rajagopal Venkat > --- > drivers/clk/clk.c | 13 ++----------- > 1 file changed, 2 insertions(+), 11 deletions(-) > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index 251e45d..1c4097c 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -1040,7 +1040,6 @@ void __clk_reparent(struct clk *clk, struct clk *new_parent) > { > #ifdef CONFIG_COMMON_CLK_DEBUG > struct dentry *d; > - struct dentry *new_parent_d; > #endif > > if (!clk || !new_parent) > @@ -1048,22 +1047,14 @@ void __clk_reparent(struct clk *clk, struct clk *new_parent) > > hlist_del(&clk->child_node); > > - if (new_parent) > - hlist_add_head(&clk->child_node, &new_parent->children); > - else > - hlist_add_head(&clk->child_node, &clk_orphan_list); > + hlist_add_head(&clk->child_node, &new_parent->children); Rajagopal, You found a bug, but not the right one :) This change would result in never moving a clock into the orphan list if the parent is missing. The right thing to do is to allow the operation to succeed and migrate this clock into the orphan list. In keeping with the clk.h api we need to treat struct clk new_parent as an opaque cookie and not care whether or not it is NULL. Untested patch below fixes the real bug: >From a4d56e3ee51452366365749873710e16631e9de7 Mon Sep 17 00:00:00 2001 From: Mike Turquette Date: Tue, 15 Jan 2013 14:39:06 -0800 Subject: [PATCH] clk: allow re-parenting to NULL clks __clk_reparent presently bails early if the new parent of a clk is NULL. This is wrong and prevents dynamically migrating clocks into the orphan list. The fix is to remove the NULL pointer check for new_parent in __clk_parent. Signed-off-by: Mike Turquette --- drivers/clk/clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 593a2e4..f056230 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1186,7 +1186,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);