Skip to content

Commit 2b74c1f

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

File tree

6 files changed

+72
-129
lines changed

6 files changed

+72
-129
lines changed

drivers/clk/mediatek/clk-mt6765-audio.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,23 @@ static const struct mtk_gate audio_clks[] = {
6464
"audio_ck", 7),
6565
};
6666

67-
static int clk_mt6765_audio_probe(struct platform_device *pdev)
68-
{
69-
struct clk_hw_onecell_data *clk_data;
70-
int r;
71-
struct device_node *node = pdev->dev.of_node;
72-
73-
clk_data = mtk_alloc_clk_data(CLK_AUDIO_NR_CLK);
74-
75-
mtk_clk_register_gates(node, audio_clks,
76-
ARRAY_SIZE(audio_clks), clk_data);
77-
78-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
79-
80-
if (r)
81-
pr_err("%s(): could not register clock provider: %d\n",
82-
__func__, r);
83-
84-
return r;
85-
}
67+
static const struct mtk_clk_desc audio_desc = {
68+
.clks = audio_clks,
69+
.num_clks = ARRAY_SIZE(audio_clks),
70+
};
8671

8772
static const struct of_device_id of_match_clk_mt6765_audio[] = {
88-
{ .compatible = "mediatek,mt6765-audsys", },
89-
{}
73+
{
74+
.compatible = "mediatek,mt6765-audsys",
75+
.data = &audio_desc,
76+
}, {
77+
/* sentinel */
78+
}
9079
};
9180

9281
static struct platform_driver clk_mt6765_audio_drv = {
93-
.probe = clk_mt6765_audio_probe,
82+
.probe = mtk_clk_simple_probe,
83+
.remove = mtk_clk_simple_remove,
9484
.driver = {
9585
.name = "clk-mt6765-audio",
9686
.of_match_table = of_match_clk_mt6765_audio,

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

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,23 @@ static const struct mtk_gate cam_clks[] = {
3939
GATE_CAM(CLK_CAM_CCU, "cam_ccu", "mm_ck", 12),
4040
};
4141

42-
static int clk_mt6765_cam_probe(struct platform_device *pdev)
43-
{
44-
struct clk_hw_onecell_data *clk_data;
45-
int r;
46-
struct device_node *node = pdev->dev.of_node;
47-
48-
clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);
49-
50-
mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks), clk_data);
51-
52-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
53-
54-
if (r)
55-
pr_err("%s(): could not register clock provider: %d\n",
56-
__func__, r);
57-
58-
return r;
59-
}
42+
static const struct mtk_clk_desc cam_desc = {
43+
.clks = cam_clks,
44+
.num_clks = ARRAY_SIZE(cam_clks),
45+
};
6046

6147
static const struct of_device_id of_match_clk_mt6765_cam[] = {
62-
{ .compatible = "mediatek,mt6765-camsys", },
63-
{}
48+
{
49+
.compatible = "mediatek,mt6765-camsys",
50+
.data = &cam_desc,
51+
}, {
52+
/* sentinel */
53+
}
6454
};
6555

6656
static struct platform_driver clk_mt6765_cam_drv = {
67-
.probe = clk_mt6765_cam_probe,
57+
.probe = mtk_clk_simple_probe,
58+
.remove = mtk_clk_simple_remove,
6859
.driver = {
6960
.name = "clk-mt6765-cam",
7061
.of_match_table = of_match_clk_mt6765_cam,

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

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,23 @@ static const struct mtk_gate img_clks[] = {
3535
GATE_IMG(CLK_IMG_RSC, "img_rsc", "mm_ck", 5),
3636
};
3737

38-
static int clk_mt6765_img_probe(struct platform_device *pdev)
39-
{
40-
struct clk_hw_onecell_data *clk_data;
41-
int r;
42-
struct device_node *node = pdev->dev.of_node;
43-
44-
clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK);
45-
46-
mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks), clk_data);
47-
48-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
49-
50-
if (r)
51-
pr_err("%s(): could not register clock provider: %d\n",
52-
__func__, r);
53-
54-
return r;
55-
}
38+
static const struct mtk_clk_desc img_desc = {
39+
.clks = img_clks,
40+
.num_clks = ARRAY_SIZE(img_clks),
41+
};
5642

5743
static const struct of_device_id of_match_clk_mt6765_img[] = {
58-
{ .compatible = "mediatek,mt6765-imgsys", },
59-
{}
44+
{
45+
.compatible = "mediatek,mt6765-imgsys",
46+
.data = &img_desc,
47+
}, {
48+
/* sentinel */
49+
}
6050
};
6151

6252
static struct platform_driver clk_mt6765_img_drv = {
63-
.probe = clk_mt6765_img_probe,
53+
.probe = mtk_clk_simple_probe,
54+
.remove = mtk_clk_simple_remove,
6455
.driver = {
6556
.name = "clk-mt6765-img",
6657
.of_match_table = of_match_clk_mt6765_img,

drivers/clk/mediatek/clk-mt6765-mipi0a.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,23 @@ static const struct mtk_gate mipi0a_clks[] = {
3232
"mipi0a_csr_0a", "f_fseninf_ck", 1),
3333
};
3434

35-
static int clk_mt6765_mipi0a_probe(struct platform_device *pdev)
36-
{
37-
struct clk_hw_onecell_data *clk_data;
38-
int r;
39-
struct device_node *node = pdev->dev.of_node;
40-
41-
clk_data = mtk_alloc_clk_data(CLK_MIPI0A_NR_CLK);
42-
43-
mtk_clk_register_gates(node, mipi0a_clks,
44-
ARRAY_SIZE(mipi0a_clks), clk_data);
45-
46-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
47-
48-
if (r)
49-
pr_err("%s(): could not register clock provider: %d\n",
50-
__func__, r);
51-
52-
return r;
53-
}
35+
static const struct mtk_clk_desc mipi0a_desc = {
36+
.clks = mipi0a_clks,
37+
.num_clks = ARRAY_SIZE(mipi0a_clks),
38+
};
5439

5540
static const struct of_device_id of_match_clk_mt6765_mipi0a[] = {
56-
{ .compatible = "mediatek,mt6765-mipi0a", },
57-
{}
41+
{
42+
.compatible = "mediatek,mt6765-mipi0a",
43+
.data = &mipi0a_desc,
44+
}, {
45+
/* sentinel */
46+
}
5847
};
5948

6049
static struct platform_driver clk_mt6765_mipi0a_drv = {
61-
.probe = clk_mt6765_mipi0a_probe,
50+
.probe = mtk_clk_simple_probe,
51+
.remove = mtk_clk_simple_remove,
6252
.driver = {
6353
.name = "clk-mt6765-mipi0a",
6454
.of_match_table = of_match_clk_mt6765_mipi0a,

drivers/clk/mediatek/clk-mt6765-mm.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,23 @@ static const struct mtk_gate mm_clks[] = {
6161
GATE_MM(CLK_MM_F26M_HRTWT, "mm_hrtwt", "f_f26m_ck", 29),
6262
};
6363

64-
static int clk_mt6765_mm_probe(struct platform_device *pdev)
65-
{
66-
struct clk_hw_onecell_data *clk_data;
67-
int r;
68-
struct device_node *node = pdev->dev.of_node;
69-
70-
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
71-
72-
mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), clk_data);
73-
74-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
75-
76-
if (r)
77-
pr_err("%s(): could not register clock provider: %d\n",
78-
__func__, r);
79-
80-
return r;
81-
}
64+
static const struct mtk_clk_desc mm_desc = {
65+
.clks = mm_clks,
66+
.num_clks = ARRAY_SIZE(mm_clks),
67+
};
8268

8369
static const struct of_device_id of_match_clk_mt6765_mm[] = {
84-
{ .compatible = "mediatek,mt6765-mmsys", },
85-
{}
70+
{
71+
.compatible = "mediatek,mt6765-mmsys",
72+
.data = &mm_desc,
73+
}, {
74+
/* sentinel */
75+
}
8676
};
8777

8878
static struct platform_driver clk_mt6765_mm_drv = {
89-
.probe = clk_mt6765_mm_probe,
79+
.probe = mtk_clk_simple_probe,
80+
.remove = mtk_clk_simple_remove,
9081
.driver = {
9182
.name = "clk-mt6765-mm",
9283
.of_match_table = of_match_clk_mt6765_mm,

drivers/clk/mediatek/clk-mt6765-vcodec.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,23 @@ static const struct mtk_gate venc_clks[] = {
3434
GATE_VENC(CLK_VENC_SET3_VDEC, "venc_set3_vdec", "mm_ck", 12),
3535
};
3636

37-
static int clk_mt6765_vcodec_probe(struct platform_device *pdev)
38-
{
39-
struct clk_hw_onecell_data *clk_data;
40-
int r;
41-
struct device_node *node = pdev->dev.of_node;
42-
43-
clk_data = mtk_alloc_clk_data(CLK_VENC_NR_CLK);
44-
45-
mtk_clk_register_gates(node, venc_clks,
46-
ARRAY_SIZE(venc_clks), clk_data);
47-
48-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
49-
50-
if (r)
51-
pr_err("%s(): could not register clock provider: %d\n",
52-
__func__, r);
53-
54-
return r;
55-
}
37+
static const struct mtk_clk_desc venc_desc = {
38+
.clks = venc_clks,
39+
.num_clks = ARRAY_SIZE(venc_clks),
40+
};
5641

5742
static const struct of_device_id of_match_clk_mt6765_vcodec[] = {
58-
{ .compatible = "mediatek,mt6765-vcodecsys", },
59-
{}
43+
{
44+
.compatible = "mediatek,mt6765-vcodecsys",
45+
.data = &venc_desc,
46+
}, {
47+
/* sentinel */
48+
}
6049
};
6150

6251
static struct platform_driver clk_mt6765_vcodec_drv = {
63-
.probe = clk_mt6765_vcodec_probe,
52+
.probe = mtk_clk_simple_probe,
53+
.remove = mtk_clk_simple_remove,
6454
.driver = {
6555
.name = "clk-mt6765-vcodec",
6656
.of_match_table = of_match_clk_mt6765_vcodec,

0 commit comments

Comments
 (0)