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: mt2701: 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-2-miles.chen@mediatek.com
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>

authored by

Miles Chen and committed by
Chen-Yu Tsai
973d1607 0d363282

+39 -69
+13 -23
drivers/clk/mediatek/clk-mt2701-bdp.c
··· 94 94 GATE_BDP1(CLK_BDP_HDMI_MON, "hdmi_mon", "hdmi_0_pll340m", 16), 95 95 }; 96 96 97 - static const struct of_device_id of_match_clk_mt2701_bdp[] = { 98 - { .compatible = "mediatek,mt2701-bdpsys", }, 99 - {} 97 + static const struct mtk_clk_desc bdp_desc = { 98 + .clks = bdp_clks, 99 + .num_clks = ARRAY_SIZE(bdp_clks), 100 100 }; 101 101 102 - static int clk_mt2701_bdp_probe(struct platform_device *pdev) 103 - { 104 - struct clk_hw_onecell_data *clk_data; 105 - int r; 106 - struct device_node *node = pdev->dev.of_node; 107 - 108 - clk_data = mtk_alloc_clk_data(CLK_BDP_NR); 109 - 110 - mtk_clk_register_gates(node, bdp_clks, ARRAY_SIZE(bdp_clks), 111 - clk_data); 112 - 113 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 114 - if (r) 115 - dev_err(&pdev->dev, 116 - "could not register clock provider: %s: %d\n", 117 - pdev->name, r); 118 - 119 - return r; 120 - } 102 + static const struct of_device_id of_match_clk_mt2701_bdp[] = { 103 + { 104 + .compatible = "mediatek,mt2701-bdpsys", 105 + .data = &bdp_desc, 106 + }, { 107 + /* sentinel */ 108 + } 109 + }; 121 110 122 111 static struct platform_driver clk_mt2701_bdp_drv = { 123 - .probe = clk_mt2701_bdp_probe, 112 + .probe = mtk_clk_simple_probe, 113 + .remove = mtk_clk_simple_remove, 124 114 .driver = { 125 115 .name = "clk-mt2701-bdp", 126 116 .of_match_table = of_match_clk_mt2701_bdp,
+13 -23
drivers/clk/mediatek/clk-mt2701-img.c
··· 36 36 GATE_IMG(CLK_IMG_VENC, "img_venc", "mm_sel", 9), 37 37 }; 38 38 39 - static const struct of_device_id of_match_clk_mt2701_img[] = { 40 - { .compatible = "mediatek,mt2701-imgsys", }, 41 - {} 39 + static const struct mtk_clk_desc img_desc = { 40 + .clks = img_clks, 41 + .num_clks = ARRAY_SIZE(img_clks), 42 42 }; 43 43 44 - static int clk_mt2701_img_probe(struct platform_device *pdev) 45 - { 46 - struct clk_hw_onecell_data *clk_data; 47 - int r; 48 - struct device_node *node = pdev->dev.of_node; 49 - 50 - clk_data = mtk_alloc_clk_data(CLK_IMG_NR); 51 - 52 - mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks), 53 - clk_data); 54 - 55 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 56 - if (r) 57 - dev_err(&pdev->dev, 58 - "could not register clock provider: %s: %d\n", 59 - pdev->name, r); 60 - 61 - return r; 62 - } 44 + static const struct of_device_id of_match_clk_mt2701_img[] = { 45 + { 46 + .compatible = "mediatek,mt2701-imgsys", 47 + .data = &img_desc, 48 + }, { 49 + /* sentinel */ 50 + } 51 + }; 63 52 64 53 static struct platform_driver clk_mt2701_img_drv = { 65 - .probe = clk_mt2701_img_probe, 54 + .probe = mtk_clk_simple_probe, 55 + .remove = mtk_clk_simple_remove, 66 56 .driver = { 67 57 .name = "clk-mt2701-img", 68 58 .of_match_table = of_match_clk_mt2701_img,
+13 -23
drivers/clk/mediatek/clk-mt2701-vdec.c
··· 47 47 GATE_VDEC1(CLK_VDEC_LARB, "vdec_larb_cken", "mm_sel", 0), 48 48 }; 49 49 50 - static const struct of_device_id of_match_clk_mt2701_vdec[] = { 51 - { .compatible = "mediatek,mt2701-vdecsys", }, 52 - {} 50 + static const struct mtk_clk_desc vdec_desc = { 51 + .clks = vdec_clks, 52 + .num_clks = ARRAY_SIZE(vdec_clks), 53 53 }; 54 54 55 - static int clk_mt2701_vdec_probe(struct platform_device *pdev) 56 - { 57 - struct clk_hw_onecell_data *clk_data; 58 - int r; 59 - struct device_node *node = pdev->dev.of_node; 60 - 61 - clk_data = mtk_alloc_clk_data(CLK_VDEC_NR); 62 - 63 - mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks), 64 - clk_data); 65 - 66 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 67 - if (r) 68 - dev_err(&pdev->dev, 69 - "could not register clock provider: %s: %d\n", 70 - pdev->name, r); 71 - 72 - return r; 73 - } 55 + static const struct of_device_id of_match_clk_mt2701_vdec[] = { 56 + { 57 + .compatible = "mediatek,mt2701-vdecsys", 58 + .data = &vdec_desc, 59 + }, { 60 + /* sentinel */ 61 + } 62 + }; 74 63 75 64 static struct platform_driver clk_mt2701_vdec_drv = { 76 - .probe = clk_mt2701_vdec_probe, 65 + .probe = mtk_clk_simple_probe, 66 + .remove = mtk_clk_simple_remove, 77 67 .driver = { 78 68 .name = "clk-mt2701-vdec", 79 69 .of_match_table = of_match_clk_mt2701_vdec,