Skip to content

Commit f3e4e73

Browse files
milesdotchenwens
authored andcommitted
clk: mediatek: mt2712: 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 973d160 commit f3e4e73

File tree

6 files changed

+72
-132
lines changed

6 files changed

+72
-132
lines changed

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

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,23 @@ static const struct mtk_gate bdp_clks[] = {
5858
GATE_BDP(CLK_BDP_TVD_CBUS, "bdp_tvd_cbus", "mm_sel", 30),
5959
};
6060

61-
static int clk_mt2712_bdp_probe(struct platform_device *pdev)
62-
{
63-
struct clk_hw_onecell_data *clk_data;
64-
int r;
65-
struct device_node *node = pdev->dev.of_node;
66-
67-
clk_data = mtk_alloc_clk_data(CLK_BDP_NR_CLK);
68-
69-
mtk_clk_register_gates(node, bdp_clks, ARRAY_SIZE(bdp_clks),
70-
clk_data);
71-
72-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
73-
74-
if (r != 0)
75-
pr_err("%s(): could not register clock provider: %d\n",
76-
__func__, r);
77-
78-
return r;
79-
}
61+
static const struct mtk_clk_desc bdp_desc = {
62+
.clks = bdp_clks,
63+
.num_clks = ARRAY_SIZE(bdp_clks),
64+
};
8065

8166
static const struct of_device_id of_match_clk_mt2712_bdp[] = {
82-
{ .compatible = "mediatek,mt2712-bdpsys", },
83-
{}
67+
{
68+
.compatible = "mediatek,mt2712-bdpsys",
69+
.data = &bdp_desc,
70+
}, {
71+
/* sentinel */
72+
}
8473
};
8574

8675
static struct platform_driver clk_mt2712_bdp_drv = {
87-
.probe = clk_mt2712_bdp_probe,
76+
.probe = mtk_clk_simple_probe,
77+
.remove = mtk_clk_simple_remove,
8878
.driver = {
8979
.name = "clk-mt2712-bdp",
9080
.of_match_table = of_match_clk_mt2712_bdp,

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

Lines changed: 12 additions & 22 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_CAM_SV2_EN, "img_cam_sv2_en", "mm_sel", 11),
3737
};
3838

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

5944
static const struct of_device_id of_match_clk_mt2712_img[] = {
60-
{ .compatible = "mediatek,mt2712-imgsys", },
61-
{}
45+
{
46+
.compatible = "mediatek,mt2712-imgsys",
47+
.data = &img_desc,
48+
}, {
49+
/* sentinel */
50+
}
6251
};
6352

6453
static struct platform_driver clk_mt2712_img_drv = {
65-
.probe = clk_mt2712_img_probe,
54+
.probe = mtk_clk_simple_probe,
55+
.remove = mtk_clk_simple_remove,
6656
.driver = {
6757
.name = "clk-mt2712-img",
6858
.of_match_table = of_match_clk_mt2712_img,

drivers/clk/mediatek/clk-mt2712-jpgdec.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,23 @@ static const struct mtk_gate jpgdec_clks[] = {
3232
GATE_JPGDEC(CLK_JPGDEC_JPGDEC, "jpgdec_jpgdec", "jpgdec_sel", 4),
3333
};
3434

35-
static int clk_mt2712_jpgdec_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_JPGDEC_NR_CLK);
42-
43-
mtk_clk_register_gates(node, jpgdec_clks, ARRAY_SIZE(jpgdec_clks),
44-
clk_data);
45-
46-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
47-
48-
if (r != 0)
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 jpgdec_desc = {
36+
.clks = jpgdec_clks,
37+
.num_clks = ARRAY_SIZE(jpgdec_clks),
38+
};
5439

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

6049
static struct platform_driver clk_mt2712_jpgdec_drv = {
61-
.probe = clk_mt2712_jpgdec_probe,
50+
.probe = mtk_clk_simple_probe,
51+
.remove = mtk_clk_simple_remove,
6252
.driver = {
6353
.name = "clk-mt2712-jpgdec",
6454
.of_match_table = of_match_clk_mt2712_jpgdec,

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

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,23 @@ static const struct mtk_gate mfg_clks[] = {
3131
GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_sel", 0),
3232
};
3333

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

5439
static const struct of_device_id of_match_clk_mt2712_mfg[] = {
55-
{ .compatible = "mediatek,mt2712-mfgcfg", },
56-
{}
40+
{
41+
.compatible = "mediatek,mt2712-mfgcfg",
42+
.data = &mfg_desc,
43+
}, {
44+
/* sentinel */
45+
}
5746
};
5847

5948
static struct platform_driver clk_mt2712_mfg_drv = {
60-
.probe = clk_mt2712_mfg_probe,
49+
.probe = mtk_clk_simple_probe,
50+
.remove = mtk_clk_simple_remove,
6151
.driver = {
6252
.name = "clk-mt2712-mfg",
6353
.of_match_table = of_match_clk_mt2712_mfg,

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

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,23 @@ static const struct mtk_gate vdec_clks[] = {
5050
GATE_VDEC1(CLK_VDEC_IMGRZ_CKEN, "vdec_imgrz_cken", "vdec_sel", 1),
5151
};
5252

53-
static int clk_mt2712_vdec_probe(struct platform_device *pdev)
54-
{
55-
struct clk_hw_onecell_data *clk_data;
56-
int r;
57-
struct device_node *node = pdev->dev.of_node;
58-
59-
clk_data = mtk_alloc_clk_data(CLK_VDEC_NR_CLK);
60-
61-
mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks),
62-
clk_data);
63-
64-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
65-
66-
if (r != 0)
67-
pr_err("%s(): could not register clock provider: %d\n",
68-
__func__, r);
69-
70-
return r;
71-
}
53+
static const struct mtk_clk_desc vdec_desc = {
54+
.clks = vdec_clks,
55+
.num_clks = ARRAY_SIZE(vdec_clks),
56+
};
7257

7358
static const struct of_device_id of_match_clk_mt2712_vdec[] = {
74-
{ .compatible = "mediatek,mt2712-vdecsys", },
75-
{}
59+
{
60+
.compatible = "mediatek,mt2712-vdecsys",
61+
.data = &vdec_desc,
62+
}, {
63+
/* sentinel */
64+
}
7665
};
7766

7867
static struct platform_driver clk_mt2712_vdec_drv = {
79-
.probe = clk_mt2712_vdec_probe,
68+
.probe = mtk_clk_simple_probe,
69+
.remove = mtk_clk_simple_remove,
8070
.driver = {
8171
.name = "clk-mt2712-vdec",
8272
.of_match_table = of_match_clk_mt2712_vdec,

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

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

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

5641
static const struct of_device_id of_match_clk_mt2712_venc[] = {
57-
{ .compatible = "mediatek,mt2712-vencsys", },
58-
{}
42+
{
43+
.compatible = "mediatek,mt2712-vencsys",
44+
.data = &venc_desc,
45+
}, {
46+
/* sentinel */
47+
}
5948
};
6049

6150
static struct platform_driver clk_mt2712_venc_drv = {
62-
.probe = clk_mt2712_venc_probe,
51+
.probe = mtk_clk_simple_probe,
52+
.remove = mtk_clk_simple_remove,
6353
.driver = {
6454
.name = "clk-mt2712-venc",
6555
.of_match_table = of_match_clk_mt2712_venc,

0 commit comments

Comments
 (0)