Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / clk / loongson1 / clk.c
blobf336a3126d31655ec97b10c6a336c6b78d75fdea
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com>
4 */
6 #include <linux/clk-provider.h>
7 #include <linux/slab.h>
9 #include "clk.h"
11 struct clk_hw *__init clk_hw_register_pll(struct device *dev,
12 const char *name,
13 const char *parent_name,
14 const struct clk_ops *ops,
15 unsigned long flags)
17 int ret;
18 struct clk_hw *hw;
19 struct clk_init_data init;
21 /* allocate the divider */
22 hw = kzalloc(sizeof(*hw), GFP_KERNEL);
23 if (!hw)
24 return ERR_PTR(-ENOMEM);
26 init.name = name;
27 init.ops = ops;
28 init.flags = flags;
29 init.parent_names = parent_name ? &parent_name : NULL;
30 init.num_parents = parent_name ? 1 : 0;
31 hw->init = &init;
33 /* register the clock */
34 ret = clk_hw_register(dev, hw);
35 if (ret) {
36 kfree(hw);
37 hw = ERR_PTR(ret);
40 return hw;