clk.c (841B)
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com> 4 */ 5 6#include <linux/clk-provider.h> 7#include <linux/slab.h> 8 9#include "clk.h" 10 11struct 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) 16{ 17 int ret; 18 struct clk_hw *hw; 19 struct clk_init_data init; 20 21 /* allocate the divider */ 22 hw = kzalloc(sizeof(*hw), GFP_KERNEL); 23 if (!hw) 24 return ERR_PTR(-ENOMEM); 25 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; 32 33 /* register the clock */ 34 ret = clk_hw_register(dev, hw); 35 if (ret) { 36 kfree(hw); 37 hw = ERR_PTR(ret); 38 } 39 40 return hw; 41}