From patchwork Wed Jun 1 23:15:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 69081 Delivered-To: patch@linaro.org Received: by 10.140.23.41 with SMTP id 38csp52752qgo; Wed, 1 Jun 2016 16:16:40 -0700 (PDT) X-Received: by 10.98.66.86 with SMTP id p83mr13605869pfa.25.1464823000452; Wed, 01 Jun 2016 16:16:40 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f191si53858190pfc.101.2016.06.01.16.16.40; Wed, 01 Jun 2016 16:16:40 -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 S1752359AbcFAXQL (ORCPT + 30 others); Wed, 1 Jun 2016 19:16:11 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:35908 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751817AbcFAXPt (ORCPT ); Wed, 1 Jun 2016 19:15:49 -0400 Received: by mail-pf0-f173.google.com with SMTP id f144so23298941pfa.3 for ; Wed, 01 Jun 2016 16:15: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:in-reply-to:references; bh=M5Sbecbw+vnDlt/kpFdBQD4RVJEB75sd1qIlCIH3k38=; b=SeV2+ZaVg+IBNMEV1uLUzI4Te0kGdm54HFrMWvpKi2XMftG33sBP+AJdw3ftdE/sKQ l1XHB1ltASEVNELYpGHkhhxVAfTN0LIuyB7w1oI4FE6giIfAhIEWCSFGiMV4XSOkWal/ NVzh85t6GRUlNFusebq10hPpdz9kfXk3TXp6U= 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=M5Sbecbw+vnDlt/kpFdBQD4RVJEB75sd1qIlCIH3k38=; b=ScCRztK6nhpwrDwoj8RxU6cWavgCAKDT9OY8xltYs1sEKRzyFPacDqmbw15JqGoSi2 up01Wksb6LHYPGm9tH19+bSuUAn5VHyX8Q6CbRfkt+BiDl/7hqE5PrE678OtNRCsvSPw 7oJYelMflgKP2Dcp9GseM0u1Rh8ZOCEzbfD/W5RLLnhzSJN+nN1uRFe57oZTysBUBY5f 6DgyxWJF/L7NrEJQIi+jBQsV5gSNfjJzlnky6uScWctfDIKNiY6PrCjqO7ox1g9+7fkq Eo2RWkE8rRd2xaMEBe38uDSPHU8qZdF0mDK5r+KQgHqScFAbVAoyRUIVmLdDGCvregcY 3cQg== X-Gm-Message-State: ALyK8tIOKO6LkMfy4rJ+wii9u+thdcxHntTXA/sYIAxR7UEdo5HV2aUc4FbNHjdzENWgGUrT X-Received: by 10.98.56.141 with SMTP id f135mr13472751pfa.159.1464822948283; Wed, 01 Jun 2016 16:15:48 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 16:15:47 -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, Max Filippov Subject: [PATCH 11/34] clk: cdce: Migrate to clk_hw based OF and registration APIs Date: Wed, 1 Jun 2016 16:15:10 -0700 Message-Id: <20160601231533.9354-12-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: Max Filippov Signed-off-by: Stephen Boyd --- See commit 58657d189a2f and it's children for details on this new registration API. drivers/clk/clk-cdce706.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/drivers/clk/clk-cdce706.c b/drivers/clk/clk-cdce706.c index 01877f64eff6..f21d9092564f 100644 --- a/drivers/clk/clk-cdce706.c +++ b/drivers/clk/clk-cdce706.c @@ -71,7 +71,6 @@ struct cdce706_hw_data { struct cdce706_dev_data *dev_data; unsigned idx; unsigned parent; - struct clk *clk; struct clk_hw hw; unsigned div; unsigned mul; @@ -81,8 +80,6 @@ struct cdce706_hw_data { struct cdce706_dev_data { struct i2c_client *client; struct regmap *regmap; - struct clk_onecell_data onecell; - struct clk *clks[6]; struct clk *clkin_clk[2]; const char *clkin_name[2]; struct cdce706_hw_data clkin[1]; @@ -455,18 +452,19 @@ static int cdce706_register_hw(struct cdce706_dev_data *cdce, struct clk_init_data *init) { unsigned i; + int ret; for (i = 0; i < num_hw; ++i, ++hw) { init->name = clk_names[i]; hw->dev_data = cdce; hw->idx = i; hw->hw.init = init; - hw->clk = devm_clk_register(&cdce->client->dev, + ret = devm_clk_hw_register(&cdce->client->dev, &hw->hw); - if (IS_ERR(hw->clk)) { + if (ret) { dev_err(&cdce->client->dev, "Failed to register %s\n", clk_names[i]); - return PTR_ERR(hw->clk); + return ret; } } return 0; @@ -613,13 +611,23 @@ static int cdce706_register_clkouts(struct cdce706_dev_data *cdce) cdce->clkout[i].parent); } - ret = cdce706_register_hw(cdce, cdce->clkout, - ARRAY_SIZE(cdce->clkout), - cdce706_clkout_name, &init); - for (i = 0; i < ARRAY_SIZE(cdce->clkout); ++i) - cdce->clks[i] = cdce->clkout[i].clk; + return cdce706_register_hw(cdce, cdce->clkout, + ARRAY_SIZE(cdce->clkout), + cdce706_clkout_name, &init); +} - return ret; +static struct clk_hw * +of_clk_cdce_get(struct of_phandle_args *clkspec, void *data) +{ + struct cdce706_dev_data *cdce = data; + unsigned int idx = clkspec->args[0]; + + if (idx >= ARRAY_SIZE(cdce->clkout)) { + pr_err("%s: invalid index %u\n", __func__, idx); + return ERR_PTR(-EINVAL); + } + + return &cdce->clkout[idx].hw; } static int cdce706_probe(struct i2c_client *client, @@ -657,12 +665,8 @@ static int cdce706_probe(struct i2c_client *client, ret = cdce706_register_clkouts(cdce); if (ret < 0) return ret; - cdce->onecell.clks = cdce->clks; - cdce->onecell.clk_num = ARRAY_SIZE(cdce->clks); - ret = of_clk_add_provider(client->dev.of_node, of_clk_src_onecell_get, - &cdce->onecell); - - return ret; + return of_clk_add_hw_provider(client->dev.of_node, of_clk_cdce_get, + cdce); } static int cdce706_remove(struct i2c_client *client)