Linux 4.18.10
[linux/fpc-iii.git] / drivers / clk / loongson1 / clk.c
blobcfcfd143fccb2ac4e2818bb787f650ceec9805fc
1 /*
2 * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
10 #include <linux/clk-provider.h>
11 #include <linux/slab.h>
13 struct clk_hw *__init clk_hw_register_pll(struct device *dev,
14 const char *name,
15 const char *parent_name,
16 const struct clk_ops *ops,
17 unsigned long flags)
19 int ret;
20 struct clk_hw *hw;
21 struct clk_init_data init;
23 /* allocate the divider */
24 hw = kzalloc(sizeof(*hw), GFP_KERNEL);
25 if (!hw)
26 return ERR_PTR(-ENOMEM);
28 init.name = name;
29 init.ops = ops;
30 init.flags = flags | CLK_IS_BASIC;
31 init.parent_names = (parent_name ? &parent_name : NULL);
32 init.num_parents = (parent_name ? 1 : 0);
33 hw->init = &init;
35 /* register the clock */
36 ret = clk_hw_register(dev, hw);
37 if (ret) {
38 kfree(hw);
39 hw = ERR_PTR(ret);
42 return hw;