Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 16 additions & 36 deletions drivers/clk/baikal/clk-baikal.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static long baikal_clk_round_rate(struct clk_hw *hw, unsigned long rate,
return res.a0;
}

const struct clk_ops be_clk_pll_ops = {
static const struct clk_ops be_clk_pll_ops = {
.enable = baikal_clk_enable,
.disable = baikal_clk_disable,
.is_enabled = baikal_clk_is_enabled,
Expand All @@ -223,13 +223,12 @@ const struct clk_ops be_clk_pll_ops = {
.round_rate = baikal_clk_round_rate,
};

static int baikal_clk_probe(struct platform_device *pdev)
static int __init baikal_clk_probe(struct device_node *node)
{
struct clk_init_data init;
struct clk_init_data *init_ch;
struct baikal_clk_cmu *cmu;
struct baikal_clk_cmu **cmu_ch;
struct device_node *node = pdev->dev.of_node;

struct clk *clk;
struct clk_onecell_data *clk_ch;
Expand All @@ -241,10 +240,9 @@ static int baikal_clk_probe(struct platform_device *pdev)
const char *clk_ch_name;
const char *parent_name;

cmu = kmalloc(sizeof(struct baikal_clk_cmu *), GFP_KERNEL);
cmu = kzalloc(sizeof(*cmu), GFP_KERNEL);
if (!cmu) {
pr_err("%s: could not allocate CMU clk\n", __func__);
kfree(cmu);
return -ENOMEM;
}

Expand Down Expand Up @@ -331,8 +329,12 @@ static int baikal_clk_probe(struct platform_device *pdev)
init_ch[i].ops = &be_clk_pll_ops;
init_ch[i].flags = CLK_IGNORE_UNUSED;

cmu_ch[index] = kmalloc(sizeof(struct baikal_clk_cmu),
cmu_ch[index] = kzalloc(sizeof(struct baikal_clk_cmu),
GFP_KERNEL);
if (!cmu_ch[index]) {
pr_err("%s: could not allocate baikal_clk_cmu structure\n", __func__);
return -ENOMEM;
}
cmu_ch[index]->name = clk_ch_name;
cmu_ch[index]->cmu_id = index;
cmu_ch[index]->parent = cmu->cmu_id;
Expand All @@ -357,38 +359,16 @@ static int baikal_clk_probe(struct platform_device *pdev)
clk_prepare_enable(clk_ch->clks[index]);
i++;
}
return of_clk_add_provider(pdev->dev.of_node,
of_clk_src_onecell_get, clk_ch);
return of_clk_add_provider(node, of_clk_src_onecell_get, clk_ch);
}

return of_clk_add_provider(pdev->dev.of_node,
of_clk_src_simple_get, clk);
return of_clk_add_provider(node, of_clk_src_simple_get, clk);
}

static int baikal_clk_remove(struct platform_device *pdev)
{
of_clk_del_provider(pdev->dev.of_node);

return 0;
static void __init baikal_clk_init(struct device_node *np) {
int err = baikal_clk_probe(np);
if (err) {
panic("%s: failed to initialize clock: %d\n", __func__, err);
}
}

static const struct of_device_id baikal_clk_of_match[] = {
{.compatible = "baikal,cmu"},
{ /* sentinel */ }
};

static struct platform_driver baikal_cmu_driver = {
.probe = baikal_clk_probe,
.remove = baikal_clk_remove,
.driver = {
.name = "baikal-cmu",
.of_match_table = baikal_clk_of_match,
},
};

module_platform_driver(baikal_cmu_driver);

MODULE_DESCRIPTION("Baikal-M clock driver");
MODULE_AUTHOR("Ekaterina Skachko <ekaterina.skachko@baikalelectronics.ru>");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:baikal-cmu");
CLK_OF_DECLARE_DRIVER(baikal_cmu, "baikal,cmu", baikal_clk_init);