Kelvin Cheung | a8e3ced | 2016-09-19 12:38:54 +0800 | [diff] [blame] | 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 | |
Stephen Boyd | 0f51659 | 2018-11-30 12:59:38 -0800 | [diff] [blame^] | 13 | #include "clk.h" |
| 14 | |
Kelvin Cheung | a8e3ced | 2016-09-19 12:38:54 +0800 | [diff] [blame] | 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; |
Stephen Boyd | 0f51659 | 2018-11-30 12:59:38 -0800 | [diff] [blame^] | 32 | init.flags = flags; |
| 33 | init.parent_names = parent_name ? &parent_name : NULL; |
| 34 | init.num_parents = parent_name ? 1 : 0; |
Kelvin Cheung | a8e3ced | 2016-09-19 12:38:54 +0800 | [diff] [blame] | 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 | } |