From patchwork Wed Jun 1 23:15:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 69101 Delivered-To: patch@linaro.org Received: by 10.140.23.41 with SMTP id 38csp53787qgo; Wed, 1 Jun 2016 16:19:53 -0700 (PDT) X-Received: by 10.67.14.7 with SMTP id fc7mr1118636pad.1.1464823193528; Wed, 01 Jun 2016 16:19:53 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xb3si13469177pab.132.2016.06.01.16.19.53; Wed, 01 Jun 2016 16:19:53 -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=@linaro.org; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752749AbcFAXTk (ORCPT + 30 others); Wed, 1 Jun 2016 19:19:40 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:33191 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752120AbcFAXQB (ORCPT ); Wed, 1 Jun 2016 19:16:01 -0400 Received: by mail-pf0-f177.google.com with SMTP id b124so23338244pfb.0 for ; Wed, 01 Jun 2016 16:16:01 -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=DYI2tmYzOYsfMFc0rUr7gnAmoajm4XxD0XeqQbajWT4=; b=GD9Yy5PiZAy90C9rwCC7qYdnICfeG/TWivAWLG71qOrl3aLNyTXm3wcSj0zXbdzDOC Akzp0CQQ2O7p9lypJd+uUw1dLQRc5olq6lrSJx3bufjEi+H+cHbeFHTXqSY+Q0EU6AYO N2W1OKGuKxQ3iKj0b2AOpr4rmtZRKmqM8ahXY= 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=DYI2tmYzOYsfMFc0rUr7gnAmoajm4XxD0XeqQbajWT4=; b=hk2WC4GNyLiN14ipFy9sp4GU52UcUEpTO4vNFuumYaoq0fdYqwsi++2xec1kRlpk/6 VwHPnQdpaIWXKO06gmxWkqx8K9z6HJGGvLqhOConjnERdCBF6zK3ohaMT+BIEqXiopxo 0MXeuda/9rYsoLqjJAE9iEGC8yyt//x7qDuma3ZHBVtSAhW5JXBIJurwAWFUduf+jIZl nNyp1yCr/Mq38K+ZbgbAgyTsitXGuA/10/AJCXH4iadsR1H7qDKpPww8tf52r7JRzb+u /KsiZuyjb5E7YANbMGpaDdv9+ZM3kwOBrr53se3RXz/QTXaVn0yn0PgQek9UO5FvYoYV XxIw== X-Gm-Message-State: ALyK8tLGNbpO+CNi+ApDQGn4DphjPgKwmC/FV3f4zxBcnzuD1LTnoAfPwcMuNpVLCDuN+/mv X-Received: by 10.98.26.210 with SMTP id a201mr13483733pfa.46.1464822960823; Wed, 01 Jun 2016 16:16:00 -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.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 16:16:00 -0700 (PDT) From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Chris Zhong Subject: [PATCH 24/34] clk: rk808: Migrate to clk_hw based OF and registration APIs Date: Wed, 1 Jun 2016 16:15:23 -0700 Message-Id: <20160601231533.9354-25-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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: Chris Zhong Signed-off-by: Stephen Boyd --- See commit 58657d189a2f and it's children for details on this new registration API. drivers/clk/clk-rk808.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/drivers/clk/clk-rk808.c b/drivers/clk/clk-rk808.c index 74383039761e..f7e0dd181946 100644 --- a/drivers/clk/clk-rk808.c +++ b/drivers/clk/clk-rk808.c @@ -26,7 +26,6 @@ struct rk808_clkout { struct rk808 *rk808; - struct clk_onecell_data clk_data; struct clk_hw clkout1_hw; struct clk_hw clkout2_hw; }; @@ -85,14 +84,28 @@ static const struct clk_ops rk808_clkout2_ops = { .recalc_rate = rk808_clkout_recalc_rate, }; +static struct clk_hw * +of_clk_rk808_get(struct of_phandle_args *clkspec, void *data) +{ + struct rk808_clkout *rk808_clkout = data; + unsigned int idx = clkspec->args[0]; + + if (idx >= 2) { + pr_err("%s: invalid index %u\n", __func__, idx); + return ERR_PTR(-EINVAL); + } + + return idx ? &rk808_clkout->clkout2_hw : &rk808_clkout->clkout1_hw; +} + static int rk808_clkout_probe(struct platform_device *pdev) { struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); struct i2c_client *client = rk808->i2c; struct device_node *node = client->dev.of_node; struct clk_init_data init = {}; - struct clk **clk_table; struct rk808_clkout *rk808_clkout; + int ret; rk808_clkout = devm_kzalloc(&client->dev, sizeof(*rk808_clkout), GFP_KERNEL); @@ -101,11 +114,6 @@ static int rk808_clkout_probe(struct platform_device *pdev) rk808_clkout->rk808 = rk808; - clk_table = devm_kcalloc(&client->dev, RK808_NR_OUTPUT, - sizeof(struct clk *), GFP_KERNEL); - if (!clk_table) - return -ENOMEM; - init.parent_names = NULL; init.num_parents = 0; init.name = "rk808-clkout1"; @@ -116,10 +124,9 @@ static int rk808_clkout_probe(struct platform_device *pdev) of_property_read_string_index(node, "clock-output-names", 0, &init.name); - clk_table[0] = devm_clk_register(&client->dev, - &rk808_clkout->clkout1_hw); - if (IS_ERR(clk_table[0])) - return PTR_ERR(clk_table[0]); + ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout1_hw); + if (ret) + return ret; init.name = "rk808-clkout2"; init.ops = &rk808_clkout2_ops; @@ -129,16 +136,11 @@ static int rk808_clkout_probe(struct platform_device *pdev) of_property_read_string_index(node, "clock-output-names", 1, &init.name); - clk_table[1] = devm_clk_register(&client->dev, - &rk808_clkout->clkout2_hw); - if (IS_ERR(clk_table[1])) - return PTR_ERR(clk_table[1]); - - rk808_clkout->clk_data.clks = clk_table; - rk808_clkout->clk_data.clk_num = RK808_NR_OUTPUT; + ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout2_hw); + if (ret) + return ret; - return of_clk_add_provider(node, of_clk_src_onecell_get, - &rk808_clkout->clk_data); + return of_clk_add_hw_provider(node, of_clk_rk808_get, &rk808_clkout); } static int rk808_clkout_remove(struct platform_device *pdev)