From patchwork Tue Aug 16 22:38:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9284963 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 02BF2607FD for ; Tue, 16 Aug 2016 22:44:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3AEC285FE for ; Tue, 16 Aug 2016 22:44:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D62EC285E4; Tue, 16 Aug 2016 22:44:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B97928763 for ; Tue, 16 Aug 2016 22:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752831AbcHPWou (ORCPT ); Tue, 16 Aug 2016 18:44:50 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:34049 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752422AbcHPWot (ORCPT ); Tue, 16 Aug 2016 18:44:49 -0400 Received: by mail-pf0-f175.google.com with SMTP id p64so31729121pfb.1 for ; Tue, 16 Aug 2016 15:44:49 -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; bh=QS4J4mzgze4u5vSmObT2j4IeCTooFjxHyA5c2mUu6J4=; b=IIDMKTO8H4BrEkt/lpGrMWez4TdJCuYwJc4fuPpDegLuJLPA9s/EUNQrZC0j7ICLvh IHn+8Bqp8aOK6Vo31oJV0MDh+CTDed3l82iiKoDrgwDjitWRp4TnKTS06Ot4VIv8rOBv BC5C3A6CTLb48/ejbH9eFEf6Wi4mVIWpgoMYY= 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; bh=QS4J4mzgze4u5vSmObT2j4IeCTooFjxHyA5c2mUu6J4=; b=H4pOMBcy+yDOHOo4U7tFi0RpH1zwMGZkEapUe2bpQNoq0aU3C7luyl9v7EppvNV4gp riboCESw5N9cTpl140+zVwlL8O7K3P6iIZt5v80Yh4+tk+iKsTtMaIbVJ0d3Jume4Fwv OCKUBcCv5s+MsBKEZ54DK12N0I7TExKcHlHzT+/TZRq3IQWTVXe7K4EMtUGoJmoN89Cg Lhnc3IxXuIeJsd8mbY9wEecGgDDa+kJGVKDEEN3YpXyEiLIkVyxeOtR7952CdkZDDql8 Iq4gn3SnkwYZLP1Cr7/CczIRDMC/OYXKr42XsIWSeRe+kSBYLdNPEOxCqev0fv2YiuxX Tscg== X-Gm-Message-State: AEkooutuI4wRrOLq/RsFJADR/FUy13hTdQ7hRdUTPyTaCGuvJRXxMuC/V9NRVJNjspCleNvo X-Received: by 10.98.13.84 with SMTP id v81mr68942888pfi.108.1471387139167; Tue, 16 Aug 2016 15:38:59 -0700 (PDT) Received: from localhost.localdomain (ip68-101-172-78.sd.sd.cox.net. [68.101.172.78]) by smtp.gmail.com with ESMTPSA id i62sm41733890pfg.62.2016.08.16.15.38.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Aug 2016 15:38:58 -0700 (PDT) From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Javier Martinez Canillas , Laxman Dewangan , Krzysztof Kozlowski Subject: [PATCH v2] clk: max77686: Migrate to clk_hw based OF and registration APIs Date: Tue, 16 Aug 2016 15:38:56 -0700 Message-Id: <20160816223856.1282-1-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Laxman Dewangan Cc: Krzysztof Kozlowski Signed-off-by: Stephen Boyd Reviewed-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas Reviewed-by: Krzysztof Kozlowski --- drivers/clk/clk-max77686.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c index 19f620856571..b637f5979023 100644 --- a/drivers/clk/clk-max77686.c +++ b/drivers/clk/clk-max77686.c @@ -62,9 +62,8 @@ struct max77686_clk_init_data { struct max77686_clk_driver_data { enum max77686_chip_name chip; - struct clk **clks; struct max77686_clk_init_data *max_clk_data; - struct clk_onecell_data of_data; + size_t num_clks; }; static const struct @@ -160,6 +159,20 @@ static struct clk_ops max77686_clk_ops = { .recalc_rate = max77686_recalc_rate, }; +static struct clk_hw * +of_clk_max77686_get(struct of_phandle_args *clkspec, void *data) +{ + struct max77686_clk_driver_data *drv_data = data; + unsigned int idx = clkspec->args[0]; + + if (idx >= drv_data->num_clks) { + pr_err("%s: invalid index %u\n", __func__, idx); + return ERR_PTR(-EINVAL); + } + + return &drv_data->max_clk_data[idx].hw; +} + static int max77686_clk_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -209,14 +222,8 @@ static int max77686_clk_probe(struct platform_device *pdev) if (!drv_data->max_clk_data) return -ENOMEM; - drv_data->clks = devm_kcalloc(dev, num_clks, - sizeof(*drv_data->clks), GFP_KERNEL); - if (!drv_data->clks) - return -ENOMEM; - for (i = 0; i < num_clks; i++) { struct max77686_clk_init_data *max_clk_data; - struct clk *clk; const char *clk_name; max_clk_data = &drv_data->max_clk_data[i]; @@ -236,30 +243,23 @@ static int max77686_clk_probe(struct platform_device *pdev) max_clk_data->hw.init = &max_clk_data->clk_idata; - clk = devm_clk_register(dev, &max_clk_data->hw); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); + ret = devm_clk_hw_register(dev, &max_clk_data->hw); + if (ret) { dev_err(dev, "Failed to clock register: %d\n", ret); return ret; } - ret = clk_register_clkdev(clk, max_clk_data->clk_idata.name, - NULL); + ret = clk_hw_register_clkdev(&max_clk_data->hw, + max_clk_data->clk_idata.name, NULL); if (ret < 0) { dev_err(dev, "Failed to clkdev register: %d\n", ret); return ret; } - drv_data->clks[i] = clk; } - platform_set_drvdata(pdev, drv_data); - if (parent->of_node) { - drv_data->of_data.clks = drv_data->clks; - drv_data->of_data.clk_num = num_clks; - ret = of_clk_add_provider(parent->of_node, - of_clk_src_onecell_get, - &drv_data->of_data); + ret = of_clk_add_hw_provider(parent->of_node, of_clk_max77686_get, + drv_data); if (ret < 0) { dev_err(dev, "Failed to register OF clock provider: %d\n",