Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <miles.chen@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220922091841.4099-4-miles.chen@mediatek.com
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>

authored by

Miles Chen and committed by
Chen-Yu Tsai
2b74c1f6 f3e4e735

+72 -129
+12 -22
drivers/clk/mediatek/clk-mt6765-audio.c
··· 64 64 "audio_ck", 7), 65 65 }; 66 66 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 + }; 86 71 87 72 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 + } 90 79 }; 91 80 92 81 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, 94 84 .driver = { 95 85 .name = "clk-mt6765-audio", 96 86 .of_match_table = of_match_clk_mt6765_audio,
+12 -21
drivers/clk/mediatek/clk-mt6765-cam.c
··· 39 39 GATE_CAM(CLK_CAM_CCU, "cam_ccu", "mm_ck", 12), 40 40 }; 41 41 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 + }; 60 46 61 47 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 + } 64 54 }; 65 55 66 56 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, 68 59 .driver = { 69 60 .name = "clk-mt6765-cam", 70 61 .of_match_table = of_match_clk_mt6765_cam,
+12 -21
drivers/clk/mediatek/clk-mt6765-img.c
··· 35 35 GATE_IMG(CLK_IMG_RSC, "img_rsc", "mm_ck", 5), 36 36 }; 37 37 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 + }; 56 42 57 43 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 + } 60 50 }; 61 51 62 52 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, 64 55 .driver = { 65 56 .name = "clk-mt6765-img", 66 57 .of_match_table = of_match_clk_mt6765_img,
+12 -22
drivers/clk/mediatek/clk-mt6765-mipi0a.c
··· 32 32 "mipi0a_csr_0a", "f_fseninf_ck", 1), 33 33 }; 34 34 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 + }; 54 39 55 40 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 + } 58 47 }; 59 48 60 49 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, 62 52 .driver = { 63 53 .name = "clk-mt6765-mipi0a", 64 54 .of_match_table = of_match_clk_mt6765_mipi0a,
+12 -21
drivers/clk/mediatek/clk-mt6765-mm.c
··· 61 61 GATE_MM(CLK_MM_F26M_HRTWT, "mm_hrtwt", "f_f26m_ck", 29), 62 62 }; 63 63 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 + }; 82 68 83 69 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 + } 86 76 }; 87 77 88 78 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, 90 81 .driver = { 91 82 .name = "clk-mt6765-mm", 92 83 .of_match_table = of_match_clk_mt6765_mm,
+12 -22
drivers/clk/mediatek/clk-mt6765-vcodec.c
··· 34 34 GATE_VENC(CLK_VENC_SET3_VDEC, "venc_set3_vdec", "mm_ck", 12), 35 35 }; 36 36 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 + }; 56 41 57 42 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 + } 60 49 }; 61 50 62 51 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, 64 54 .driver = { 65 55 .name = "clk-mt6765-vcodec", 66 56 .of_match_table = of_match_clk_mt6765_vcodec,