From patchwork Wed Jun 1 23:15:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 69085 Delivered-To: patch@linaro.org Received: by 10.140.23.41 with SMTP id 38csp53032qgo; Wed, 1 Jun 2016 16:17:34 -0700 (PDT) X-Received: by 10.66.217.202 with SMTP id pa10mr823236pac.29.1464823054197; Wed, 01 Jun 2016 16:17:34 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si53857986pfi.239.2016.06.01.16.17.33; Wed, 01 Jun 2016 16:17:34 -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 S1752694AbcFAXRb (ORCPT + 30 others); Wed, 1 Jun 2016 19:17:31 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35689 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752275AbcFAXQI (ORCPT ); Wed, 1 Jun 2016 19:16:08 -0400 Received: by mail-pa0-f53.google.com with SMTP id xk1so517381pac.2 for ; Wed, 01 Jun 2016 16:16:08 -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=CR7QY535+c+6yKs8HIlFK6Yah3SuPiQ4GtmjEkqxTUg=; b=hJ4duoE+43y7h1TLWuyl3ZpKpYYWJfVynh8l0l9/TFXnd0bKWWtcd7yhE4ZYQwU9Xu NrNz/6WDIvHqTe/+MVNWSPG/GnH12DK7I0FvOwLpa1BigcpVZ0KxY9pwbGj+fD6+/xVE FHsiChe3YtLMAzj3kOSghzoVh6on6TFHzCzDY= 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=CR7QY535+c+6yKs8HIlFK6Yah3SuPiQ4GtmjEkqxTUg=; b=Q0AslRJbr+pr2gAdgqDn0HftBpDZSuE4okAhSd++4CfKJ3SbH8iquJIHIRjRmgM9SQ H+WCTBJ60GopEmaPn4NkyDpA57LTZq0BDydsDdlCRYebhKDhfMkY5JSbZUzoydXWd1Ok s08G56HhEONFRLUwh/IELqJSrGiTLenDkEF4hsMQJv7QLTki0zP9J70iHrDiaArHihan DxJshdmg0jj0r0irgKylxvl23qc5oi0qTODiDafMY6bp6rPXb3LLpxoXeUUhacwcUHQQ U0PIN48KS0gS58zvsGZSLO6bxRoaa6y7nqxcCB6M0gnqUYgQntux7zWLsjJ0QS7ct2wL 00rg== X-Gm-Message-State: ALyK8tI27A/wi6bl+Ezo5s6aqCh4Wgu3/FEZz09lNyzqTiokby0RFhKWBRqsZb3YMUpr7cei X-Received: by 10.66.122.196 with SMTP id lu4mr1175899pab.52.1464822962737; Wed, 01 Jun 2016 16:16:02 -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.16.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 16:16:02 -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, Sudeep Holla Subject: [PATCH 26/34] clk: scpi: Migrate to clk_hw based OF and registration APIs Date: Wed, 1 Jun 2016 16:15:25 -0700 Message-Id: <20160601231533.9354-27-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: Sudeep Holla Signed-off-by: Stephen Boyd --- See commit 58657d189a2f and it's children for details on this new registration API. drivers/clk/clk-scpi.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) -- 2.7.4 diff --git a/drivers/clk/clk-scpi.c b/drivers/clk/clk-scpi.c index 6962ee5d1e9a..2a3e9d8e88b0 100644 --- a/drivers/clk/clk-scpi.c +++ b/drivers/clk/clk-scpi.c @@ -146,13 +146,13 @@ static const struct of_device_id scpi_clk_match[] = { {} }; -static struct clk * +static int scpi_clk_ops_init(struct device *dev, const struct of_device_id *match, struct scpi_clk *sclk, const char *name) { struct clk_init_data init; - struct clk *clk; unsigned long min = 0, max = 0; + int ret; init.name = name; init.flags = 0; @@ -164,18 +164,18 @@ scpi_clk_ops_init(struct device *dev, const struct of_device_id *match, if (init.ops == &scpi_dvfs_ops) { sclk->info = sclk->scpi_ops->dvfs_get_info(sclk->id); if (IS_ERR(sclk->info)) - return NULL; + return PTR_ERR(sclk->info); } else if (init.ops == &scpi_clk_ops) { if (sclk->scpi_ops->clk_get_range(sclk->id, &min, &max) || !max) - return NULL; + return -EINVAL; } else { - return NULL; + return -EINVAL; } - clk = devm_clk_register(dev, &sclk->hw); - if (!IS_ERR(clk) && max) + ret = devm_clk_hw_register(dev, &sclk->hw); + if (!ret && max) clk_hw_set_rate_range(&sclk->hw, min, max); - return clk; + return ret; } struct scpi_clk_data { @@ -183,7 +183,7 @@ struct scpi_clk_data { unsigned int clk_num; }; -static struct clk * +static struct clk_hw * scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data) { struct scpi_clk *sclk; @@ -193,7 +193,7 @@ scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data) for (count = 0; count < clk_data->clk_num; count++) { sclk = clk_data->clk[count]; if (idx == sclk->id) - return sclk->hw.clk; + return &sclk->hw; } return ERR_PTR(-EINVAL); @@ -202,8 +202,7 @@ scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data) static int scpi_clk_add(struct device *dev, struct device_node *np, const struct of_device_id *match) { - struct clk **clks; - int idx, count; + int idx, count, err; struct scpi_clk_data *clk_data; count = of_property_count_strings(np, "clock-output-names"); @@ -222,10 +221,6 @@ static int scpi_clk_add(struct device *dev, struct device_node *np, if (!clk_data->clk) return -ENOMEM; - clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL); - if (!clks) - return -ENOMEM; - for (idx = 0; idx < count; idx++) { struct scpi_clk *sclk; const char *name; @@ -249,15 +244,15 @@ static int scpi_clk_add(struct device *dev, struct device_node *np, sclk->id = val; - clks[idx] = scpi_clk_ops_init(dev, match, sclk, name); - if (IS_ERR_OR_NULL(clks[idx])) + err = scpi_clk_ops_init(dev, match, sclk, name); + if (err) dev_err(dev, "failed to register clock '%s'\n", name); else dev_dbg(dev, "Registered clock '%s'\n", name); clk_data->clk[idx] = sclk; } - return of_clk_add_provider(np, scpi_of_clk_src_get, clk_data); + return of_clk_add_hw_provider(np, scpi_of_clk_src_get, clk_data); } static int scpi_clocks_remove(struct platform_device *pdev)