Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp684903yba; Fri, 12 Apr 2019 11:32:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvpHxsfKjnnMKpi/FwkLELvRjea1q2oBBEKGFBIC/QdphxmoF6Zxb2EFNls9txXx280pOS X-Received: by 2002:a17:902:4501:: with SMTP id m1mr30553985pld.290.1555093979556; Fri, 12 Apr 2019 11:32:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555093979; cv=none; d=google.com; s=arc-20160816; b=yVexDLOBo4yjBVaBSZtIbAJll4yWPvu2qU0xlU6J2nOZf6O9OgzgFNQEeivLyrJGGs 7wVz2DBFL6mc131Ncefn376wDrCxtEmshGMxFlUgflX92jaTsLGI68Rd7GuDT4Fk31/N dlO4qoLj4Wb+oLhqGGT0GgupTq+0Y9Evm6kXLL4cpSq6KfdLoflJbR4J6hozHxrOwJVn JWDcaO1SegZ9vbMHQIKE1KvmgoWwTuBJaTDYL0IKdNlqr3vrRMWBB/u/JL4DueFsIZ15 zTvPkUMtP8BayYT7sxXpo7fkisIDz/j42C4RmtpE2oHtSSD568rsiNmc8k93XBX4MRnn vnyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7wgGjmir2c6jon+Br+b/VqpA8ugF8C959SJL1y78+bs=; b=0YbgJIDJXNbTncwZ5rSJBLEIBWGhR+OL6JY3SYmykvGkMtUG3EU8t/VQLyKsRTIOO7 fGl92M9rHPJP5iSmXVO8DBOjupi531+uaBGBHwQojIfw7lqpXs+TpGoQgnNr0JwA/9xf 7A6gPnfj3buq8CpUWvg0u0SvdEoAKPhvZFJS+M+vbg5Ml0GSmuuMQK06oxC9Y5HT8Viq SOMZ6W7V6uKJRva6Lue1ElMWyLWbs/WXtIY09iw3gReyYdt3BMmCtrtHJeiPsCUIyeEY oroU9TVNFUdr2EGlgLkDce6XlFycjhS4+a7SwgI1weGIVDzN9jir/O/Zp1ogcyEC8hb+ 2Wag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VBVd1KvY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w125si39651578pfw.137.2019.04.12.11.32.42; Fri, 12 Apr 2019 11:32:59 -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; dkim=pass header.i=@kernel.org header.s=default header.b=VBVd1KvY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727159AbfDLScA (ORCPT + 99 others); Fri, 12 Apr 2019 14:32:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:50478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727059AbfDLSbz (ORCPT ); Fri, 12 Apr 2019 14:31:55 -0400 Received: from mail.kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6DCFA218FF; Fri, 12 Apr 2019 18:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555093914; bh=J/xGoKvpAn8VN6F0LRcxO6cDYVGFyNVvjKQEpBW6ETw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VBVd1KvYbclyKAO7npK8PM617+Ss03DjRysOi2b1hVNA0ZrNqpw7wlHtVoJCMdA9Q 0p4IxcYXtjrXRZ2TDdV0h8p6zVLh2rwnCL9Wdbrs42LFJ38LCBRoLw9qiL+NVjtDxg kjxJDzkM6Ep2j3nvP3vt6jGY3cBPZyvXNcUGGDpc= From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Miquel Raynal , Jerome Brunet , Russell King , Jeffrey Hugo , Chen-Yu Tsai Subject: [PATCH v4 7/9] clk: Look for parents with clkdev based clk_lookups Date: Fri, 12 Apr 2019 11:31:48 -0700 Message-Id: <20190412183150.102131-8-sboyd@kernel.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190412183150.102131-1-sboyd@kernel.org> References: <20190412183150.102131-1-sboyd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In addition to looking for DT based parents, support clkdev based clk_lookups. This should allow non-DT based clk drivers to participate in the parent lookup process. Cc: Miquel Raynal Cc: Jerome Brunet Cc: Russell King Cc: Michael Turquette Cc: Jeffrey Hugo Cc: Chen-Yu Tsai Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 27 ++++++++++++++++++--------- drivers/clk/clk.h | 2 ++ drivers/clk/clkdev.c | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index de49a7c4214b..42f29fd6bfd8 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -324,14 +324,15 @@ static struct clk_core *clk_core_lookup(const char *name) } /** - * clk_core_get - Find the parent of a clk using a clock specifier in DT + * clk_core_get - Find the clk_core parent of a clk * @core: clk to find parent of - * @name: name to search for in 'clock-names' of device providing clk + * @name: name to search for * * This is the preferred method for clk providers to find the parent of a * clk when that parent is external to the clk controller. The parent_names * array is indexed and treated as a local name matching a string in the device - * node's 'clock-names' property. This allows clk providers to use their own + * node's 'clock-names' property or as the 'con_id' matching the device's + * dev_name() in a clk_lookup. This allows clk providers to use their own * namespace instead of looking for a globally unique parent string. * * For example the following DT snippet would allow a clock registered by the @@ -359,15 +360,23 @@ static struct clk_core *clk_core_lookup(const char *name) */ static struct clk_core *clk_core_get(struct clk_core *core, const char *name) { - struct clk_hw *hw; + struct clk_hw *hw = ERR_PTR(-ENOENT); + struct device *dev = core->dev; + const char *dev_id = dev ? dev_name(dev) : NULL; struct device_node *np = core->of_node; - if (!np) - return ERR_PTR(-ENOENT); + if (np) + hw = of_clk_get_hw(np, -1, name); - /* TODO: Support clkdev clk_lookups */ - hw = of_clk_get_hw(np, -1, name); - if (IS_ERR_OR_NULL(hw)) + /* + * If the DT search above couldn't find the provider or the provider + * didn't know about this clk, fallback to looking up via clkdev based + * clk_lookups + */ + if (PTR_ERR(hw) == -ENOENT) + hw = clk_find_hw(dev_id, name); + + if (IS_ERR(hw)) return ERR_CAST(hw); return hw->core; diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index 553f531cc232..d8400d623b34 100644 --- a/drivers/clk/clk.h +++ b/drivers/clk/clk.h @@ -19,6 +19,8 @@ static inline struct clk_hw *of_clk_get_hw(struct device_node *np, } #endif +struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id); + #ifdef CONFIG_COMMON_CLK struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw, const char *dev_id, const char *con_id); diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 6f65bde696da..2afc8df8acff 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -72,7 +72,7 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) return cl; } -static struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id) +struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id) { struct clk_lookup *cl; struct clk_hw *hw = ERR_PTR(-ENOENT); -- Sent by a computer through tubes