From patchwork Wed Jun 1 23:15:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 69100 Delivered-To: patch@linaro.org Received: by 10.140.23.41 with SMTP id 38csp53779qgo; Wed, 1 Jun 2016 16:19:53 -0700 (PDT) X-Received: by 10.66.66.234 with SMTP id i10mr1184832pat.114.1464823192947; Wed, 01 Jun 2016 16:19:52 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id w1si53891151pfj.95.2016.06.01.16.19.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jun 2016 16:19:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b8FP2-0007ZU-77; Wed, 01 Jun 2016 23:18:20 +0000 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b8FMx-0005GE-Jh for linux-arm-kernel@lists.infradead.org; Wed, 01 Jun 2016 23:16:13 +0000 Received: by mail-pa0-x233.google.com with SMTP id um11so515899pab.0 for ; Wed, 01 Jun 2016 16:15:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J+9xOh4hqQE19Nb3xOsV/t8HQBzGoDBBpDw7LIXe8Vw=; b=gV8MIvz5SxJA3rrIKYV+W78FK/HKu1/CO63ggMgzyBFQ2tNYGqFR8jwJC0bYbUbMbB NRvAPhZyCBzrA7YwkRzlLRPDbU41Ho2CwtH5a0PLEpaG07HjuNLDPh6p4zgMU5UuS1qP U7j4DPdAZL1bh7Z3P/IL/b6DHM/OnBs6EgQy4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=J+9xOh4hqQE19Nb3xOsV/t8HQBzGoDBBpDw7LIXe8Vw=; b=EYtuOHHTzW5eVY+Ikb/SN9+251mkI7Oa6+tgG6AxDbBINRuGXl/mpDm8lCQy1qXsQq +fa3MT0M5e66iIppBLFUczz9gN8e16F0zVm3xAAEFiDqnmgsZBYQlKiyMcnj5Y7m+W0P zlYTowOhsfA4BzKlbpRZ4LXWfikt+hccRM2c+iWjRFPkhD6bab101W2cEYJTMfYHJD5V wVdEYfaLUE67X98U8wE0PyJj7IbF1EixGhss2cdHOIm6WWNFxnpQQsrxRTMrRfa5f+WY 3KcP4Q3NSu7ORGVhmzYKzbLshjni7NrTRoZtuIvVvVfEw2v/ZKneTB0wtgBQq7Nyd5Gv E/Hw== X-Gm-Message-State: ALyK8tLxddbh8s/A39/UiEDCZhXyI5jbmfagNujtc0ttELvy1dNJE5v1lvihRZeopsk9nWZY X-Received: by 10.66.118.106 with SMTP id kl10mr1148934pab.78.1464822954179; Wed, 01 Jun 2016 16:15:54 -0700 (PDT) Received: from localhost.localdomain (pat_11.qualcomm.com. [192.35.156.11]) by smtp.gmail.com with ESMTPSA id r64sm20967395pfi.54.2016.06.01.16.15.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 16:15:53 -0700 (PDT) From: Stephen Boyd To: Michael Turquette , Stephen Boyd Subject: [PATCH 17/34] clk: maxgen: Migrate to clk_hw based OF and registration APIs Date: Wed, 1 Jun 2016 16:15:16 -0700 Message-Id: <20160601231533.9354-18-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0-rc1 In-Reply-To: <20160601231533.9354-1-stephen.boyd@linaro.org> References: <20160601231533.9354-1-stephen.boyd@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160601_161611_817961_BB768214 X-CRM114-Status: GOOD ( 17.32 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:233 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Javier Martinez Canillas , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Now that we have clk_hw based provider APIs to register clks, we can get rid of struct clk pointers while registering clks in these drivers, allowing us to move closer to a clear split of consumer and provider clk APIs. Cc: Javier Martinez Canillas Signed-off-by: Stephen Boyd --- See commit 58657d189a2f and it's children for details on this new registration API. drivers/clk/clk-max-gen.c | 64 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 33 deletions(-) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/clk/clk-max-gen.c b/drivers/clk/clk-max-gen.c index 35af9cb6da4f..4bb53fcf8639 100644 --- a/drivers/clk/clk-max-gen.c +++ b/drivers/clk/clk-max-gen.c @@ -40,6 +40,11 @@ struct max_gen_clk { struct clk_hw hw; }; +struct max_gen_data { + size_t num; + struct max_gen_clk clks[]; +}; + static struct max_gen_clk *to_max_gen_clk(struct clk_hw *hw) { return container_of(hw, struct max_gen_clk, hw); @@ -89,43 +94,48 @@ struct clk_ops max_gen_clk_ops = { }; EXPORT_SYMBOL_GPL(max_gen_clk_ops); -static struct clk *max_gen_clk_register(struct device *dev, - struct max_gen_clk *max_gen) +static int max_gen_clk_register(struct device *dev, struct max_gen_clk *max_gen) { - struct clk *clk; struct clk_hw *hw = &max_gen->hw; int ret; - clk = devm_clk_register(dev, hw); - if (IS_ERR(clk)) - return clk; + ret = devm_clk_hw_register(dev, hw); + if (ret) + return ret; + + return clk_hw_register_clkdev(hw, hw->init->name, NULL); +} - ret = clk_register_clkdev(clk, hw->init->name, NULL); +static struct clk_hw * +of_clk_max_gen_get(struct of_phandle_args *clkspec, void *data) +{ + struct max_gen_data *max_gen_data = data; + unsigned int idx = clkspec->args[0]; - if (ret) - return ERR_PTR(ret); + if (idx >= max_gen_data->num) { + pr_err("%s: invalid index %u\n", __func__, idx); + return ERR_PTR(-EINVAL); + } - return clk; + return &max_gen_data->clks[idx].hw; } int max_gen_clk_probe(struct platform_device *pdev, struct regmap *regmap, u32 reg, struct clk_init_data *clks_init, int num_init) { int i, ret; + struct max_gen_data *max_gen_data; struct max_gen_clk *max_gen_clks; - struct clk **clocks; struct device *dev = pdev->dev.parent; const char *clk_name; struct clk_init_data *init; - clocks = devm_kzalloc(dev, sizeof(struct clk *) * num_init, GFP_KERNEL); - if (!clocks) + max_gen_data = devm_kzalloc(dev, sizeof(*max_gen_data) + + sizeof(*max_gen_data->clks) * num_init, GFP_KERNEL); + if (!max_gen_data) return -ENOMEM; - max_gen_clks = devm_kzalloc(dev, sizeof(struct max_gen_clk) - * num_init, GFP_KERNEL); - if (!max_gen_clks) - return -ENOMEM; + max_gen_clks = max_gen_data->clks; for (i = 0; i < num_init; i++) { max_gen_clks[i].regmap = regmap; @@ -149,29 +159,17 @@ int max_gen_clk_probe(struct platform_device *pdev, struct regmap *regmap, max_gen_clks[i].hw.init = init; - clocks[i] = max_gen_clk_register(dev, &max_gen_clks[i]); - if (IS_ERR(clocks[i])) { - ret = PTR_ERR(clocks[i]); + ret = max_gen_clk_register(dev, &max_gen_clks[i]); + if (ret) { dev_err(dev, "failed to register %s\n", max_gen_clks[i].hw.init->name); return ret; } } - platform_set_drvdata(pdev, clocks); - if (dev->of_node) { - struct clk_onecell_data *of_data; - - of_data = devm_kzalloc(dev, sizeof(*of_data), GFP_KERNEL); - if (!of_data) - return -ENOMEM; - - of_data->clks = clocks; - of_data->clk_num = num_init; - ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, - of_data); - + ret = of_clk_add_hw_provider(dev->of_node, of_clk_max_gen_get, + max_gen_clks); if (ret) { dev_err(dev, "failed to register OF clock provider\n"); return ret;