Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1397901

[PATCH 2/5] clk: hisilicon: add hisi_clk_alloc function.

From Jiancheng Xue <xuejiancheng@hisilicon.com>
Newsgroups linux.kernel
Subject [PATCH 2/5] clk: hisilicon: add hisi_clk_alloc function.
Date 2016-05-10 11:40 +0200
Message-ID <rxcj0-8b4-17@gated-at.bofh.it> (permalink)
References <rxcj0-8b4-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Before, there was an ordering issue that the clock provider
had been published in hisi_clk_init before it could provide
valid clocks to consumers. hisi_clk_alloc is just used to
allocate memory space for struct hisi_clock_data. It makes
it possible to publish the provider after the clocks are ready.

Signed-off-by: Jiancheng Xue <xuejiancheng@hisilicon.com>
---
 drivers/clk/hisilicon/clk.c | 29 +++++++++++++++++++++++++++++
 drivers/clk/hisilicon/clk.h |  3 +++
 2 files changed, 32 insertions(+)

diff --git a/drivers/clk/hisilicon/clk.c b/drivers/clk/hisilicon/clk.c
index 9b15adb..78675d1 100644
--- a/drivers/clk/hisilicon/clk.c
+++ b/drivers/clk/hisilicon/clk.c
@@ -37,6 +37,35 @@
 
 static DEFINE_SPINLOCK(hisi_clk_lock);
 
+struct hisi_clock_data *hisi_clk_alloc(struct platform_device *pdev,
+						int nr_clks)
+{
+	struct hisi_clock_data *clk_data;
+	struct resource *res;
+	struct clk **clk_table;
+
+	clk_data = devm_kmalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL);
+	if (!clk_data)
+		return NULL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	clk_data->base = devm_ioremap(&pdev->dev,
+				res->start, resource_size(res));
+	if (!clk_data->base)
+		return NULL;
+
+	clk_table = devm_kmalloc(&pdev->dev, sizeof(struct clk *) * nr_clks,
+				GFP_KERNEL);
+	if (!clk_table)
+		return NULL;
+
+	clk_data->clk_data.clks = clk_table;
+	clk_data->clk_data.clk_num = nr_clks;
+
+	return clk_data;
+}
+EXPORT_SYMBOL_GPL(hisi_clk_alloc);
+
 struct hisi_clock_data *hisi_clk_init(struct device_node *np,
 					     int nr_clks)
 {
diff --git a/drivers/clk/hisilicon/clk.h b/drivers/clk/hisilicon/clk.h
index 20d64af..5fc644f 100644
--- a/drivers/clk/hisilicon/clk.h
+++ b/drivers/clk/hisilicon/clk.h
@@ -30,6 +30,8 @@
 #include <linux/io.h>
 #include <linux/spinlock.h>
 
+struct platform_device;
+
 struct hisi_clock_data {
 	struct clk_onecell_data	clk_data;
 	void __iomem		*base;
@@ -110,6 +112,7 @@ struct clk *hi6220_register_clkdiv(struct device *dev, const char *name,
 	const char *parent_name, unsigned long flags, void __iomem *reg,
 	u8 shift, u8 width, u32 mask_bit, spinlock_t *lock);
 
+struct hisi_clock_data *hisi_clk_alloc(struct platform_device *, int);
 struct hisi_clock_data *hisi_clk_init(struct device_node *, int);
 void hisi_clk_register_fixed_rate(const struct hisi_fixed_rate_clock *,
 				int, struct hisi_clock_data *);
-- 
1.9.1

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] clk: hisilicon: Fix some problems of clk-hi3519 Jiancheng Xue <xuejiancheng@hisilicon.com> - 2016-05-10 11:40 +0200
  [PATCH 1/5] reset: hisilicon: change the definition of hisi_reset_init Jiancheng Xue <xuejiancheng@hisilicon.com> - 2016-05-10 11:40 +0200
    Re: [PATCH 1/5] reset: hisilicon: change the definition of  hisi_reset_init Philipp Zabel <p.zabel@pengutronix.de> - 2016-05-10 13:20 +0200
  [PATCH 3/5] clk: hisilicon: add error processing for hisi_clk_register_* functions Jiancheng Xue <xuejiancheng@hisilicon.com> - 2016-05-10 11:40 +0200
  [PATCH 2/5] clk: hisilicon: add hisi_clk_alloc function. Jiancheng Xue <xuejiancheng@hisilicon.com> - 2016-05-10 11:40 +0200
  [PATCH 5/5] clk: hisilicon: hi3519: add driver remove path and fix some issues Jiancheng Xue <xuejiancheng@hisilicon.com> - 2016-05-10 11:40 +0200
    Re: [PATCH 5/5] clk: hisilicon: hi3519: add driver remove path and  fix some issues Philipp Zabel <p.zabel@pengutronix.de> - 2016-05-10 13:20 +0200
      Re: [PATCH 5/5] clk: hisilicon: hi3519: add driver remove path and  fix some issues Jiancheng Xue <xuejiancheng@hisilicon.com> - 2016-05-10 13:50 +0200

csiph-web