Merge tag 'dax-fix-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm...
[linux-2.6-microblaze.git] / drivers / clk / meson / clk-input.c
1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
2 /*
3  * Copyright (c) 2018 BayLibre, SAS.
4  * Author: Jerome Brunet <jbrunet@baylibre.com>
5  */
6
7 #include <linux/clk.h>
8 #include <linux/clk-provider.h>
9 #include <linux/device.h>
10 #include "clkc.h"
11
12 static const struct clk_ops meson_clk_no_ops = {};
13
14 struct clk_hw *meson_clk_hw_register_input(struct device *dev,
15                                            const char *of_name,
16                                            const char *clk_name,
17                                            unsigned long flags)
18 {
19         struct clk *parent_clk = devm_clk_get(dev, of_name);
20         struct clk_init_data init;
21         const char *parent_name;
22         struct clk_hw *hw;
23         int ret;
24
25         if (IS_ERR(parent_clk))
26                 return (struct clk_hw *)parent_clk;
27
28         hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL);
29         if (!hw)
30                 return ERR_PTR(-ENOMEM);
31
32         parent_name = __clk_get_name(parent_clk);
33         init.name = clk_name;
34         init.ops = &meson_clk_no_ops;
35         init.flags = flags;
36         init.parent_names = &parent_name;
37         init.num_parents = 1;
38         hw->init = &init;
39
40         ret = devm_clk_hw_register(dev, hw);
41
42         return ret ? ERR_PTR(ret) : hw;
43 }
44 EXPORT_SYMBOL_GPL(meson_clk_hw_register_input);