Skip to content

Commit dc6fdd8

Browse files
milesdotchenwens
authored andcommitted
clk: mediatek: mt6779: 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 2b74c1f commit dc6fdd8

File tree

7 files changed

+90
-111
lines changed

7 files changed

+90
-111
lines changed

drivers/clk/mediatek/clk-mt6779-aud.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,23 @@ static const struct mtk_gate audio_clks[] = {
8989
"audio_h_sel", 31),
9090
};
9191

92-
static const struct of_device_id of_match_clk_mt6779_aud[] = {
93-
{ .compatible = "mediatek,mt6779-audio", },
94-
{}
92+
static const struct mtk_clk_desc audio_desc = {
93+
.clks = audio_clks,
94+
.num_clks = ARRAY_SIZE(audio_clks),
9595
};
9696

97-
static int clk_mt6779_aud_probe(struct platform_device *pdev)
98-
{
99-
struct clk_hw_onecell_data *clk_data;
100-
struct device_node *node = pdev->dev.of_node;
101-
102-
clk_data = mtk_alloc_clk_data(CLK_AUD_NR_CLK);
103-
104-
mtk_clk_register_gates(node, audio_clks, ARRAY_SIZE(audio_clks),
105-
clk_data);
106-
107-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
108-
}
97+
static const struct of_device_id of_match_clk_mt6779_aud[] = {
98+
{
99+
.compatible = "mediatek,mt6779-audio",
100+
.data = &audio_desc,
101+
}, {
102+
/* sentinel */
103+
}
104+
};
109105

110106
static struct platform_driver clk_mt6779_aud_drv = {
111-
.probe = clk_mt6779_aud_probe,
107+
.probe = mtk_clk_simple_probe,
108+
.remove = mtk_clk_simple_remove,
112109
.driver = {
113110
.name = "clk-mt6779-aud",
114111
.of_match_table = of_match_clk_mt6779_aud,

drivers/clk/mediatek/clk-mt6779-cam.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,23 @@ static const struct mtk_gate cam_clks[] = {
3838
GATE_CAM(CLK_CAM_FAKE_ENG, "camsys_fake_eng", "cam_sel", 14),
3939
};
4040

41-
static const struct of_device_id of_match_clk_mt6779_cam[] = {
42-
{ .compatible = "mediatek,mt6779-camsys", },
43-
{}
41+
static const struct mtk_clk_desc cam_desc = {
42+
.clks = cam_clks,
43+
.num_clks = ARRAY_SIZE(cam_clks),
4444
};
4545

46-
static int clk_mt6779_cam_probe(struct platform_device *pdev)
47-
{
48-
struct clk_hw_onecell_data *clk_data;
49-
struct device_node *node = pdev->dev.of_node;
50-
51-
clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);
52-
53-
mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks),
54-
clk_data);
55-
56-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
57-
}
46+
static const struct of_device_id of_match_clk_mt6779_cam[] = {
47+
{
48+
.compatible = "mediatek,mt6779-camsys",
49+
.data = &cam_desc,
50+
}, {
51+
/* sentinel */
52+
}
53+
};
5854

5955
static struct platform_driver clk_mt6779_cam_drv = {
60-
.probe = clk_mt6779_cam_probe,
56+
.probe = mtk_clk_simple_probe,
57+
.remove = mtk_clk_simple_remove,
6158
.driver = {
6259
.name = "clk-mt6779-cam",
6360
.of_match_table = of_match_clk_mt6779_cam,

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

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,23 @@ static const struct mtk_gate img_clks[] = {
3030
GATE_IMG(CLK_IMG_WPE_A, "imgsys_wpe_a", "img_sel", 7),
3131
};
3232

33-
static const struct of_device_id of_match_clk_mt6779_img[] = {
34-
{ .compatible = "mediatek,mt6779-imgsys", },
35-
{}
33+
static const struct mtk_clk_desc img_desc = {
34+
.clks = img_clks,
35+
.num_clks = ARRAY_SIZE(img_clks),
3636
};
3737

38-
static int clk_mt6779_img_probe(struct platform_device *pdev)
39-
{
40-
struct clk_hw_onecell_data *clk_data;
41-
struct device_node *node = pdev->dev.of_node;
42-
43-
clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK);
44-
45-
mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks),
46-
clk_data);
47-
48-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
49-
}
38+
static const struct of_device_id of_match_clk_mt6779_img[] = {
39+
{
40+
.compatible = "mediatek,mt6779-imgsys",
41+
.data = &img_desc,
42+
}, {
43+
/* sentinel */
44+
}
45+
};
5046

5147
static struct platform_driver clk_mt6779_img_drv = {
52-
.probe = clk_mt6779_img_probe,
48+
.probe = mtk_clk_simple_probe,
49+
.remove = mtk_clk_simple_remove,
5350
.driver = {
5451
.name = "clk-mt6779-img",
5552
.of_match_table = of_match_clk_mt6779_img,

drivers/clk/mediatek/clk-mt6779-ipe.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,23 @@ static const struct mtk_gate ipe_clks[] = {
3232
GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "ipe_sel", 6),
3333
};
3434

35-
static const struct of_device_id of_match_clk_mt6779_ipe[] = {
36-
{ .compatible = "mediatek,mt6779-ipesys", },
37-
{}
35+
static const struct mtk_clk_desc ipe_desc = {
36+
.clks = ipe_clks,
37+
.num_clks = ARRAY_SIZE(ipe_clks),
3838
};
3939

40-
static int clk_mt6779_ipe_probe(struct platform_device *pdev)
41-
{
42-
struct clk_hw_onecell_data *clk_data;
43-
struct device_node *node = pdev->dev.of_node;
44-
45-
clk_data = mtk_alloc_clk_data(CLK_IPE_NR_CLK);
46-
47-
mtk_clk_register_gates(node, ipe_clks, ARRAY_SIZE(ipe_clks),
48-
clk_data);
49-
50-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
51-
}
40+
static const struct of_device_id of_match_clk_mt6779_ipe[] = {
41+
{
42+
.compatible = "mediatek,mt6779-ipesys",
43+
.data = &ipe_desc,
44+
}, {
45+
/* sentinel */
46+
}
47+
};
5248

5349
static struct platform_driver clk_mt6779_ipe_drv = {
54-
.probe = clk_mt6779_ipe_probe,
50+
.probe = mtk_clk_simple_probe,
51+
.remove = mtk_clk_simple_remove,
5552
.driver = {
5653
.name = "clk-mt6779-ipe",
5754
.of_match_table = of_match_clk_mt6779_ipe,

drivers/clk/mediatek/clk-mt6779-mfg.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,23 @@ static const struct mtk_gate mfg_clks[] = {
2727
GATE_MFG(CLK_MFGCFG_BG3D, "mfg_bg3d", "mfg_sel", 0),
2828
};
2929

30-
static int clk_mt6779_mfg_probe(struct platform_device *pdev)
31-
{
32-
struct clk_hw_onecell_data *clk_data;
33-
struct device_node *node = pdev->dev.of_node;
34-
35-
clk_data = mtk_alloc_clk_data(CLK_MFGCFG_NR_CLK);
36-
37-
mtk_clk_register_gates(node, mfg_clks, ARRAY_SIZE(mfg_clks),
38-
clk_data);
39-
40-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
41-
}
30+
static const struct mtk_clk_desc mfg_desc = {
31+
.clks = mfg_clks,
32+
.num_clks = ARRAY_SIZE(mfg_clks),
33+
};
4234

4335
static const struct of_device_id of_match_clk_mt6779_mfg[] = {
44-
{ .compatible = "mediatek,mt6779-mfgcfg", },
45-
{}
36+
{
37+
.compatible = "mediatek,mt6779-mfgcfg",
38+
.data = &mfg_desc,
39+
}, {
40+
/* sentinel */
41+
}
4642
};
4743

4844
static struct platform_driver clk_mt6779_mfg_drv = {
49-
.probe = clk_mt6779_mfg_probe,
45+
.probe = mtk_clk_simple_probe,
46+
.remove = mtk_clk_simple_remove,
5047
.driver = {
5148
.name = "clk-mt6779-mfg",
5249
.of_match_table = of_match_clk_mt6779_mfg,

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

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,23 @@ static const struct mtk_gate vdec_clks[] = {
3939
GATE_VDEC1_I(CLK_VDEC_LARB1, "vdec_larb1_cken", "vdec_sel", 0),
4040
};
4141

42-
static const struct of_device_id of_match_clk_mt6779_vdec[] = {
43-
{ .compatible = "mediatek,mt6779-vdecsys", },
44-
{}
42+
static const struct mtk_clk_desc vdec_desc = {
43+
.clks = vdec_clks,
44+
.num_clks = ARRAY_SIZE(vdec_clks),
4545
};
4646

47-
static int clk_mt6779_vdec_probe(struct platform_device *pdev)
48-
{
49-
struct clk_hw_onecell_data *clk_data;
50-
struct device_node *node = pdev->dev.of_node;
51-
52-
clk_data = mtk_alloc_clk_data(CLK_VDEC_GCON_NR_CLK);
53-
54-
mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks),
55-
clk_data);
56-
57-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
58-
}
47+
static const struct of_device_id of_match_clk_mt6779_vdec[] = {
48+
{
49+
.compatible = "mediatek,mt6779-vdecsys",
50+
.data = &vdec_desc,
51+
}, {
52+
/* sentinel */
53+
}
54+
};
5955

6056
static struct platform_driver clk_mt6779_vdec_drv = {
61-
.probe = clk_mt6779_vdec_probe,
57+
.probe = mtk_clk_simple_probe,
58+
.remove = mtk_clk_simple_remove,
6259
.driver = {
6360
.name = "clk-mt6779-vdec",
6461
.of_match_table = of_match_clk_mt6779_vdec,

drivers/clk/mediatek/clk-mt6779-venc.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,23 @@ static const struct mtk_gate venc_clks[] = {
3030
GATE_VENC_I(CLK_VENC_GCON_GALS, "venc_gals", "venc_sel", 28),
3131
};
3232

33-
static const struct of_device_id of_match_clk_mt6779_venc[] = {
34-
{ .compatible = "mediatek,mt6779-vencsys", },
35-
{}
33+
static const struct mtk_clk_desc venc_desc = {
34+
.clks = venc_clks,
35+
.num_clks = ARRAY_SIZE(venc_clks),
3636
};
3737

38-
static int clk_mt6779_venc_probe(struct platform_device *pdev)
39-
{
40-
struct clk_hw_onecell_data *clk_data;
41-
struct device_node *node = pdev->dev.of_node;
42-
43-
clk_data = mtk_alloc_clk_data(CLK_VENC_GCON_NR_CLK);
44-
45-
mtk_clk_register_gates(node, venc_clks, ARRAY_SIZE(venc_clks),
46-
clk_data);
47-
48-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
49-
}
38+
static const struct of_device_id of_match_clk_mt6779_venc[] = {
39+
{
40+
.compatible = "mediatek,mt6779-vencsys",
41+
.data = &venc_desc,
42+
}, {
43+
/* sentinel */
44+
}
45+
};
5046

5147
static struct platform_driver clk_mt6779_venc_drv = {
52-
.probe = clk_mt6779_venc_probe,
48+
.probe = mtk_clk_simple_probe,
49+
.remove = mtk_clk_simple_remove,
5350
.driver = {
5451
.name = "clk-mt6779-venc",
5552
.of_match_table = of_match_clk_mt6779_venc,

0 commit comments

Comments
 (0)