Merge tag 'drm-misc-next-2019-01-07-1' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-2.6-microblaze.git] / drivers / clk / loongson1 / clk.c
1 /*
2  * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com>
3  *
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  */
9
10 #include <linux/clk-provider.h>
11 #include <linux/slab.h>
12
13 #include "clk.h"
14
15 struct clk_hw *__init clk_hw_register_pll(struct device *dev,
16                                           const char *name,
17                                           const char *parent_name,
18                                           const struct clk_ops *ops,
19                                           unsigned long flags)
20 {
21         int ret;
22         struct clk_hw *hw;
23         struct clk_init_data init;
24
25         /* allocate the divider */
26         hw = kzalloc(sizeof(*hw), GFP_KERNEL);
27         if (!hw)
28                 return ERR_PTR(-ENOMEM);
29
30         init.name = name;
31         init.ops = ops;
32         init.flags = flags;
33         init.parent_names = parent_name ? &parent_name : NULL;
34         init.num_parents = parent_name ? 1 : 0;
35         hw->init = &init;
36
37         /* register the clock */
38         ret = clk_hw_register(dev, hw);
39         if (ret) {
40                 kfree(hw);
41                 hw = ERR_PTR(ret);
42         }
43
44         return hw;
45 }