Skip to content

Commit 973d160

Browse files
milesdotchenwens
authored andcommitted
clk: mediatek: mt2701: use mtk_clk_simple_probe to simplify driver
mtk_clk_simple_probe was added by Chun-Jie to simply common flow of MediaTek clock drivers and ChenYu enhanced the error path of mtk_clk_simple_probe and added mtk_clk_simple_remove. Let's use mtk_clk_simple_probe and mtk_clk_simple_probe in other MediaTek clock drivers as well. Signed-off-by: Miles Chen <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Chen-Yu Tsai <[email protected]>
1 parent 0d36328 commit 973d160

File tree

3 files changed

+39
-69
lines changed

3 files changed

+39
-69
lines changed

drivers/clk/mediatek/clk-mt2701-bdp.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,33 +94,23 @@ static const struct mtk_gate bdp_clks[] = {
9494
GATE_BDP1(CLK_BDP_HDMI_MON, "hdmi_mon", "hdmi_0_pll340m", 16),
9595
};
9696

97-
static const struct of_device_id of_match_clk_mt2701_bdp[] = {
98-
{ .compatible = "mediatek,mt2701-bdpsys", },
99-
{}
97+
static const struct mtk_clk_desc bdp_desc = {
98+
.clks = bdp_clks,
99+
.num_clks = ARRAY_SIZE(bdp_clks),
100100
};
101101

102-
static int clk_mt2701_bdp_probe(struct platform_device *pdev)
103-
{
104-
struct clk_hw_onecell_data *clk_data;
105-
int r;
106-
struct device_node *node = pdev->dev.of_node;
107-
108-
clk_data = mtk_alloc_clk_data(CLK_BDP_NR);
109-
110-
mtk_clk_register_gates(node, bdp_clks, ARRAY_SIZE(bdp_clks),
111-
clk_data);
112-
113-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
114-
if (r)
115-
dev_err(&pdev->dev,
116-
"could not register clock provider: %s: %d\n",
117-
pdev->name, r);
118-
119-
return r;
120-
}
102+
static const struct of_device_id of_match_clk_mt2701_bdp[] = {
103+
{
104+
.compatible = "mediatek,mt2701-bdpsys",
105+
.data = &bdp_desc,
106+
}, {
107+
/* sentinel */
108+
}
109+
};
121110

122111
static struct platform_driver clk_mt2701_bdp_drv = {
123-
.probe = clk_mt2701_bdp_probe,
112+
.probe = mtk_clk_simple_probe,
113+
.remove = mtk_clk_simple_remove,
124114
.driver = {
125115
.name = "clk-mt2701-bdp",
126116
.of_match_table = of_match_clk_mt2701_bdp,

drivers/clk/mediatek/clk-mt2701-img.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,23 @@ static const struct mtk_gate img_clks[] = {
3636
GATE_IMG(CLK_IMG_VENC, "img_venc", "mm_sel", 9),
3737
};
3838

39-
static const struct of_device_id of_match_clk_mt2701_img[] = {
40-
{ .compatible = "mediatek,mt2701-imgsys", },
41-
{}
39+
static const struct mtk_clk_desc img_desc = {
40+
.clks = img_clks,
41+
.num_clks = ARRAY_SIZE(img_clks),
4242
};
4343

44-
static int clk_mt2701_img_probe(struct platform_device *pdev)
45-
{
46-
struct clk_hw_onecell_data *clk_data;
47-
int r;
48-
struct device_node *node = pdev->dev.of_node;
49-
50-
clk_data = mtk_alloc_clk_data(CLK_IMG_NR);
51-
52-
mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks),
53-
clk_data);
54-
55-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
56-
if (r)
57-
dev_err(&pdev->dev,
58-
"could not register clock provider: %s: %d\n",
59-
pdev->name, r);
60-
61-
return r;
62-
}
44+
static const struct of_device_id of_match_clk_mt2701_img[] = {
45+
{
46+
.compatible = "mediatek,mt2701-imgsys",
47+
.data = &img_desc,
48+
}, {
49+
/* sentinel */
50+
}
51+
};
6352

6453
static struct platform_driver clk_mt2701_img_drv = {
65-
.probe = clk_mt2701_img_probe,
54+
.probe = mtk_clk_simple_probe,
55+
.remove = mtk_clk_simple_remove,
6656
.driver = {
6757
.name = "clk-mt2701-img",
6858
.of_match_table = of_match_clk_mt2701_img,

drivers/clk/mediatek/clk-mt2701-vdec.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,23 @@ static const struct mtk_gate vdec_clks[] = {
4747
GATE_VDEC1(CLK_VDEC_LARB, "vdec_larb_cken", "mm_sel", 0),
4848
};
4949

50-
static const struct of_device_id of_match_clk_mt2701_vdec[] = {
51-
{ .compatible = "mediatek,mt2701-vdecsys", },
52-
{}
50+
static const struct mtk_clk_desc vdec_desc = {
51+
.clks = vdec_clks,
52+
.num_clks = ARRAY_SIZE(vdec_clks),
5353
};
5454

55-
static int clk_mt2701_vdec_probe(struct platform_device *pdev)
56-
{
57-
struct clk_hw_onecell_data *clk_data;
58-
int r;
59-
struct device_node *node = pdev->dev.of_node;
60-
61-
clk_data = mtk_alloc_clk_data(CLK_VDEC_NR);
62-
63-
mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks),
64-
clk_data);
65-
66-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
67-
if (r)
68-
dev_err(&pdev->dev,
69-
"could not register clock provider: %s: %d\n",
70-
pdev->name, r);
71-
72-
return r;
73-
}
55+
static const struct of_device_id of_match_clk_mt2701_vdec[] = {
56+
{
57+
.compatible = "mediatek,mt2701-vdecsys",
58+
.data = &vdec_desc,
59+
}, {
60+
/* sentinel */
61+
}
62+
};
7463

7564
static struct platform_driver clk_mt2701_vdec_drv = {
76-
.probe = clk_mt2701_vdec_probe,
65+
.probe = mtk_clk_simple_probe,
66+
.remove = mtk_clk_simple_remove,
7767
.driver = {
7868
.name = "clk-mt2701-vdec",
7969
.of_match_table = of_match_clk_mt2701_vdec,

0 commit comments

Comments
 (0)