Received: by 10.213.65.68 with SMTP id h4csp1766689imn; Mon, 19 Mar 2018 12:40:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELt5stWL3JQvZWJ809eH1jZqR3p7/R4/IIS+bTmiy9MqozhA73C39O48QIoJF95txR3620Y3 X-Received: by 2002:a17:902:3f83:: with SMTP id a3-v6mr5457031pld.279.1521488448507; Mon, 19 Mar 2018 12:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521488448; cv=none; d=google.com; s=arc-20160816; b=PQR3wGpNs4jGqIW1Mp+GX8l7vkV/Vj8fyJfYOs5R4CGIxar30XBs4MmR3gQCu3OKJL qjnYNyOVD+81Lp6DjT7Dki7rQ3egv/wBLPpDQNDrdfH/TUh6syk9P8dbRm9vMNyhp77z 7dm5c+cEu1Q8wfelbGwpAn1psXmlLqw71y6gRDWGcQi4H1+GJqNrt8Cp00mF2kGWToeD 8B+8dhgJvM7ibrAs+lU06PPg69zvvHLQbpBs0ATdfAz+PQCjDFyUWTBjHhCF845aBh8w gePkcARGT4i12DzdwMSGNXiUnwXk63fOpDjdcV1RnQ6Fn2iJ/nuKUt9inYr2o0GFhloo 8OLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dmarc-filter:arc-authentication-results; bh=7RRtBVr2e8k4GUjI5+n8196gLL5SnuUbFyZKPZ/1XL8=; b=uZk334+mSznva4p8yM+m0G3kiTlMPv2RK4j013hHKjgsJCDBXJSW3jAarN2Vo9KDB6 Uge33gmbN2rz8kJzwREXZDucQT++OTUQPWau2ZK9l/exvAbgzZ8u24E2bAdiJ7UeBRyc T8m+Wdgebp9SHHqKNylWUGgNhoNfvW4QJW/iM8hOwUCB9RMJCPTbymkel8IJKS64re41 umLDxQBY/pSDPKkrf3Bj8kWi9ROu2PfbTOItXCuZBIyFdMo/GZ05EVpbCsj62qTcg7Rd 6rnBgutbIFgYBmTZQsAoZFN5cahqvrJRqEHqZ5AW6XyDbeOz//2djIkT6uywDiOeJRN3 AvAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si225316pgp.285.2018.03.19.12.40.34; Mon, 19 Mar 2018 12:40:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936136AbeCSTjF convert rfc822-to-8bit (ORCPT + 99 others); Mon, 19 Mar 2018 15:39:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:57556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031169AbeCSSV4 (ORCPT ); Mon, 19 Mar 2018 14:21:56 -0400 Received: from localhost (unknown [104.132.1.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 152A2204EF; Mon, 19 Mar 2018 18:21:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 152A2204EF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sboyd@kernel.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Jolly Shah , linux-clk@vger.kernel.org, mark.rutland@arm.com, michal.simek@xilinx.com, mturquette@baylibre.com, robh+dt@kernel.org, sboyd@codeaurora.org From: Stephen Boyd In-Reply-To: <1519856861-31384-2-git-send-email-jollys@xilinx.com> Cc: rajanv@xilinx.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jolly Shah , Jolly Shah , Tejas Patel , Shubhrajyoti Datta References: <1519856861-31384-1-git-send-email-jollys@xilinx.com> <1519856861-31384-2-git-send-email-jollys@xilinx.com> Message-ID: <152148371542.242365.18433130635050412528@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH 1/3] drivers: clk: Add clk_get_children support Date: Mon, 19 Mar 2018 11:21:55 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Jolly Shah (2018-02-28 14:27:39) > From: Jolly Shah > > This API helps to determine the users for any clock. Ok, but why do you need it? > > Signed-off-by: Jolly Shah > Signed-off-by: Tejas Patel > Signed-off-by: Shubhrajyoti Datta > --- > drivers/clk/clk.c | 28 ++++++++++++++++++++++++++++ > include/linux/clk-provider.h | 1 + > 2 files changed, 29 insertions(+) > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index 0f686a9..947a18b 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -274,6 +274,34 @@ struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw) > } > EXPORT_SYMBOL_GPL(clk_hw_get_parent); > > +static unsigned int sibling; Looks very thread unsafe! > + > +static void clk_show_subtree(struct clk_core *c, > + int level) > +{ > + struct clk_core *child; > + > + if (!c) > + return; > + > + if (level == 1) > + sibling++; > + > + hlist_for_each_entry(child, &c->children, child_node) > + clk_show_subtree(child, level + 1); > +} > + > +unsigned int clk_get_children(char *name) > +{ > + struct clk_core *core; > + struct clk *pclk = __clk_lookup(name); > + > + sibling = 0; > + core = pclk->core; > + clk_show_subtree(core, 0); > + return sibling; > +} > + > static struct clk_core *__clk_lookup_subtree(const char *name, > struct clk_core *core) > { > diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h > index f711be6..e94dfb2 100644 > --- a/include/linux/clk-provider.h > +++ b/include/linux/clk-provider.h > @@ -745,6 +745,7 @@ unsigned int __clk_get_enable_count(struct clk *clk); > unsigned long clk_hw_get_rate(const struct clk_hw *hw); > unsigned long __clk_get_flags(struct clk *clk); > unsigned long clk_hw_get_flags(const struct clk_hw *hw); > +unsigned int clk_get_children(char *name); And uses a string lookup instead of having the clk_hw pointer in hand. No thanks.