Skip to content

Commit a481c6c

Browse files
milesdotchenwens
authored andcommitted
clk: mediatek: mt6797: 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 dc6fdd8 commit a481c6c

File tree

3 files changed

+39
-69
lines changed

3 files changed

+39
-69
lines changed

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

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,23 @@ static const struct mtk_gate img_clks[] = {
3232
GATE_IMG(CLK_IMG_LARB6, "img_larb6", "mm_sel", 0),
3333
};
3434

35-
static const struct of_device_id of_match_clk_mt6797_img[] = {
36-
{ .compatible = "mediatek,mt6797-imgsys", },
37-
{}
35+
static const struct mtk_clk_desc img_desc = {
36+
.clks = img_clks,
37+
.num_clks = ARRAY_SIZE(img_clks),
3838
};
3939

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

6049
static struct platform_driver clk_mt6797_img_drv = {
61-
.probe = clk_mt6797_img_probe,
50+
.probe = mtk_clk_simple_probe,
51+
.remove = mtk_clk_simple_remove,
6252
.driver = {
6353
.name = "clk-mt6797-img",
6454
.of_match_table = of_match_clk_mt6797_img,

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

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,33 +49,23 @@ static const struct mtk_gate vdec_clks[] = {
4949
GATE_VDEC1(CLK_VDEC_LARB1_CKEN, "vdec_larb1_cken", "mm_sel", 0),
5050
};
5151

52-
static const struct of_device_id of_match_clk_mt6797_vdec[] = {
53-
{ .compatible = "mediatek,mt6797-vdecsys", },
54-
{}
52+
static const struct mtk_clk_desc vdec_desc = {
53+
.clks = vdec_clks,
54+
.num_clks = ARRAY_SIZE(vdec_clks),
5555
};
5656

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

7766
static struct platform_driver clk_mt6797_vdec_drv = {
78-
.probe = clk_mt6797_vdec_probe,
67+
.probe = mtk_clk_simple_probe,
68+
.remove = mtk_clk_simple_remove,
7969
.driver = {
8070
.name = "clk-mt6797-vdec",
8171
.of_match_table = of_match_clk_mt6797_vdec,

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

Lines changed: 13 additions & 23 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_3, "venc_3", "venc_sel", 12),
3535
};
3636

37-
static const struct of_device_id of_match_clk_mt6797_venc[] = {
38-
{ .compatible = "mediatek,mt6797-vencsys", },
39-
{}
37+
static const struct mtk_clk_desc venc_desc = {
38+
.clks = venc_clks,
39+
.num_clks = ARRAY_SIZE(venc_clks),
4040
};
4141

42-
static int clk_mt6797_venc_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_VENC_NR);
49-
50-
mtk_clk_register_gates(node, venc_clks, ARRAY_SIZE(venc_clks),
51-
clk_data);
52-
53-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
54-
if (r)
55-
dev_err(&pdev->dev,
56-
"could not register clock provider: %s: %d\n",
57-
pdev->name, r);
58-
59-
return r;
60-
}
42+
static const struct of_device_id of_match_clk_mt6797_venc[] = {
43+
{
44+
.compatible = "mediatek,mt6797-vencsys",
45+
.data = &venc_desc,
46+
}, {
47+
/* sentinel */
48+
}
49+
};
6150

6251
static struct platform_driver clk_mt6797_venc_drv = {
63-
.probe = clk_mt6797_venc_probe,
52+
.probe = mtk_clk_simple_probe,
53+
.remove = mtk_clk_simple_remove,
6454
.driver = {
6555
.name = "clk-mt6797-venc",
6656
.of_match_table = of_match_clk_mt6797_venc,

0 commit comments

Comments
 (0)