Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / clk / uniphier / clk-uniphier-fixed-factor.c
bloba6a37a6bca3ab047725621a0c8dcfb0a9d07aa20
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5 */
7 #include <linux/clk-provider.h>
8 #include <linux/device.h>
10 #include "clk-uniphier.h"
12 struct clk_hw *uniphier_clk_register_fixed_factor(struct device *dev,
13 const char *name,
14 const struct uniphier_clk_fixed_factor_data *data)
16 struct clk_fixed_factor *fix;
17 struct clk_init_data init;
18 int ret;
20 fix = devm_kzalloc(dev, sizeof(*fix), GFP_KERNEL);
21 if (!fix)
22 return ERR_PTR(-ENOMEM);
24 init.name = name;
25 init.ops = &clk_fixed_factor_ops;
26 init.flags = data->parent_name ? CLK_SET_RATE_PARENT : 0;
27 init.parent_names = data->parent_name ? &data->parent_name : NULL;
28 init.num_parents = data->parent_name ? 1 : 0;
30 fix->mult = data->mult;
31 fix->div = data->div;
32 fix->hw.init = &init;
34 ret = devm_clk_hw_register(dev, &fix->hw);
35 if (ret)
36 return ERR_PTR(ret);
38 return &fix->hw;