Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4296345imu; Mon, 28 Jan 2019 22:12:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN5jYCnqNiebNhxd8wxulsk2oR6jOtJP8GXtzlZHOgFfv873qhoCouK+2+Og0qxFCHrHs96c X-Received: by 2002:a17:902:9f93:: with SMTP id g19mr24394205plq.195.1548742340796; Mon, 28 Jan 2019 22:12:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548742340; cv=none; d=google.com; s=arc-20160816; b=0p1UJal30nLOjhQgPRH8+pQQPjOljm9LBjo8mWkUH4orT7ZmSKcPJSpLwa10KTQIh4 c3bPkYXTtnh4QhJLw+98epwKeOdZ/k/fuckL+0OI75GIQEUgDW6XXsPvSV4KnXkPj5MK hsgmKUUAkS6WKGZa4HXFwlTuPreaV/yub0vn/21E2FjBg2e+O2GZLZErwaU4GWBIqBN4 QBK42+GvOhOIRyEMG52DPis0Wx49L/fvnWESBL0DG9vwaMWsVhg+mE223HJ8rLWo7eFk 6jhsGy9dV9jy2GuYX60ZfavVZRaoOzJ9eJ6DfQfmmFWJCK7qE1xlWK4OvFAw4Y+ypTBn V3Ng== 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=PIK1yvOKYJToXSRTUTyAqu7PNMg2m+4EuYl/oXj+gPU=; b=fxD4KmiR4Eo5iK5/MIJGqulC09Y/nnQcNvdT1RHhn6L3B1qWuhx6+G9y0t1J/M8QLs OTux4DLA3eHRFjS4EK4OR5OSt3L0L2GyWxl790nFIcWPX0Q0wBp7ZlmNrVK19jQ3Jdmu Y1RU7z+7RgfSQ8vr7UcRYre2Ev7jgC1IRytw7rCSnqNV8Cs/3709Fuy3x0bQ+YcGXrwx QgOqeE76NVV1c23WoVWY9pMJ3wGPfEVvxAvBZEZSblnXM4BSzy9dSMegVlSroPkbyleD /QMZ7oJh1F59eGbyubQ5pLPFHOgGjDNmmU2dKIOOrEz67ykCASfAs3wQBczKxEVKLVtc VIAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="otJTGT/9"; 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 o7si33134696pgg.118.2019.01.28.22.12.05; Mon, 28 Jan 2019 22:12:20 -0800 (PST) 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="otJTGT/9"; 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 S1727676AbfA2GKw (ORCPT + 99 others); Tue, 29 Jan 2019 01:10:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:33450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbfA2GK0 (ORCPT ); Tue, 29 Jan 2019 01:10:26 -0500 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 4ED102184D; Tue, 29 Jan 2019 06:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548742224; bh=M+W9UixXghcZ2tQo1f3291ReSl8cVMi29InxnarTtdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=otJTGT/9KbicncNoFfTcIJPsST9iDaNbuERW4fqLWz/bpD/WTuOJokbmivJaoCBNm JrWXJ3qYazdCA9ETdJBQmJHtEWLxSPtZsnJ8XydL+JYLNQ+55LbaWbxYdLX2ona6ko +l+d+sFLEX4dLKkW4Q8/vtDRac06nudsDwC7fcQE= 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 Subject: [PATCH 5/9] clk: Inform the core about consumer devices Date: Mon, 28 Jan 2019 22:10:17 -0800 Message-Id: <20190129061021.94775-6-sboyd@kernel.org> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190129061021.94775-1-sboyd@kernel.org> References: <20190129061021.94775-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 We'd like to have a pointer to the device that's consuming a particular clk in the clk framework so we can link the consumer to the clk provider with a PM device link. Add a device argument to clk_hw_create_clk() for this so it can be used in subsequent patches to add and remove the link. Cc: Miquel Raynal Cc: Jerome Brunet Cc: Russell King Cc: Michael Turquette Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 7 +++++-- drivers/clk/clk.h | 7 +++++-- drivers/clk/clkdev.c | 16 +++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d4c4cab42375..73f8a287bf42 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -85,6 +85,7 @@ struct clk_core { struct clk { struct clk_core *core; + struct device *dev; const char *dev_id; const char *con_id; unsigned long min_rate; @@ -3323,6 +3324,7 @@ static void free_clk(struct clk *clk) /** * clk_hw_create_clk: Allocate and link a clk consumer to a clk_core given * a clk_hw + * @dev: clk consumer device * @hw: clk_hw associated with the clk being consumed * @dev_id: string describing device name * @con_id: connection ID string on device @@ -3331,7 +3333,7 @@ static void free_clk(struct clk *clk) * consumers. It connects a consumer to the clk_core and clk_hw structures * used by the framework and clk provider respectively. */ -struct clk *clk_hw_create_clk(struct clk_hw *hw, +struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw, const char *dev_id, const char *con_id) { struct clk *clk; @@ -3345,6 +3347,7 @@ struct clk *clk_hw_create_clk(struct clk_hw *hw, clk = alloc_clk(core, dev_id, con_id); if (IS_ERR(clk)) return clk; + clk->dev = dev; if (!try_module_get(core->owner)) { free_clk(clk); @@ -4161,7 +4164,7 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) { struct clk_hw *hw = of_clk_get_hw_from_clkspec(clkspec); - return clk_hw_create_clk(hw, NULL, __func__); + return clk_hw_create_clk(NULL, hw, NULL, __func__); } EXPORT_SYMBOL_GPL(of_clk_get_from_provider); diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index cdac6dfa8094..fda0ad483416 100644 --- a/drivers/clk/clk.h +++ b/drivers/clk/clk.h @@ -10,6 +10,8 @@ */ struct clk_hw; +struct device; +struct of_phandle_args; #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) int of_parse_clkspec(const struct device_node *np, int index, const char *name, @@ -18,13 +20,14 @@ struct clk_hw *of_clk_get_hw_from_clkspec(struct of_phandle_args *clkspec); #endif #ifdef CONFIG_COMMON_CLK -struct clk *clk_hw_create_clk(struct clk_hw *hw, +struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw, const char *dev_id, const char *con_id); void __clk_put(struct clk *clk); #else /* All these casts to avoid ifdefs in clkdev... */ static inline struct clk * -clk_hw_create_clk(struct clk_hw *hw, const char *dev_id, const char *con_id) +clk_hw_create_clk(struct device *dev, struct clk_hw *hw, const char *dev_id, + const char *con_id) { return (struct clk *)hw; } diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 5ebb2119c0b9..f2f4f2afd28c 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -51,7 +51,7 @@ static struct clk *__of_clk_get(struct device_node *np, { struct clk_hw *hw = of_clk_get_hw(np, index, con_id); - return clk_hw_create_clk(hw, dev_id, con_id); + return clk_hw_create_clk(NULL, hw, dev_id, con_id); } struct clk *of_clk_get(struct device_node *np, int index) @@ -130,7 +130,8 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) return cl; } -struct clk *clk_get_sys(const char *dev_id, const char *con_id) +static struct clk *__clk_get_sys(struct device *dev, const char *dev_id, + const char *con_id) { struct clk_lookup *cl; struct clk *clk = NULL; @@ -141,7 +142,7 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id) if (!cl) goto out; - clk = clk_hw_create_clk(cl->clk_hw, dev_id, con_id); + clk = clk_hw_create_clk(dev, cl->clk_hw, dev_id, con_id); if (IS_ERR(clk)) cl = NULL; out: @@ -149,6 +150,11 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id) return cl ? clk : ERR_PTR(-ENOENT); } + +struct clk *clk_get_sys(const char *dev_id, const char *con_id) +{ + return __clk_get_sys(NULL, dev_id, con_id); +} EXPORT_SYMBOL(clk_get_sys); struct clk *clk_get(struct device *dev, const char *con_id) @@ -159,10 +165,10 @@ struct clk *clk_get(struct device *dev, const char *con_id) if (dev && dev->of_node) { hw = of_clk_get_hw(dev->of_node, 0, con_id); if (!IS_ERR(hw) || PTR_ERR(hw) == -EPROBE_DEFER) - return clk_hw_create_clk(hw, dev_id, con_id); + return clk_hw_create_clk(dev, hw, dev_id, con_id); } - return clk_get_sys(dev_id, con_id); + return __clk_get_sys(dev, dev_id, con_id); } EXPORT_SYMBOL(clk_get); -- Sent by a computer through tubes