Commit dc6fdd8a authored by Miles Chen's avatar Miles Chen Committed by Chen-Yu Tsai
Browse files

clk: mediatek: mt6779: 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: default avatarMiles Chen <miles.chen@mediatek.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220922091841.4099-5-miles.chen@mediatek.com


Signed-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
parent 2b74c1f6
Loading
Loading
Loading
Loading
+13 −16
Original line number Diff line number Diff line
@@ -89,26 +89,23 @@ static const struct mtk_gate audio_clks[] = {
		    "audio_h_sel", 31),
};

static const struct of_device_id of_match_clk_mt6779_aud[] = {
	{ .compatible = "mediatek,mt6779-audio", },
	{}
static const struct mtk_clk_desc audio_desc = {
	.clks = audio_clks,
	.num_clks = ARRAY_SIZE(audio_clks),
};

static int clk_mt6779_aud_probe(struct platform_device *pdev)
static const struct of_device_id of_match_clk_mt6779_aud[] = {
	{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_AUD_NR_CLK);

	mtk_clk_register_gates(node, audio_clks, ARRAY_SIZE(audio_clks),
			       clk_data);

	return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
		.compatible = "mediatek,mt6779-audio",
		.data = &audio_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt6779_aud_drv = {
	.probe = clk_mt6779_aud_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt6779-aud",
		.of_match_table = of_match_clk_mt6779_aud,
+13 −16
Original line number Diff line number Diff line
@@ -38,26 +38,23 @@ static const struct mtk_gate cam_clks[] = {
	GATE_CAM(CLK_CAM_FAKE_ENG, "camsys_fake_eng", "cam_sel", 14),
};

static const struct of_device_id of_match_clk_mt6779_cam[] = {
	{ .compatible = "mediatek,mt6779-camsys", },
	{}
static const struct mtk_clk_desc cam_desc = {
	.clks = cam_clks,
	.num_clks = ARRAY_SIZE(cam_clks),
};

static int clk_mt6779_cam_probe(struct platform_device *pdev)
static const struct of_device_id of_match_clk_mt6779_cam[] = {
	{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);

	mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks),
			       clk_data);

	return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
		.compatible = "mediatek,mt6779-camsys",
		.data = &cam_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt6779_cam_drv = {
	.probe = clk_mt6779_cam_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt6779-cam",
		.of_match_table = of_match_clk_mt6779_cam,
+13 −16
Original line number Diff line number Diff line
@@ -30,26 +30,23 @@ static const struct mtk_gate img_clks[] = {
	GATE_IMG(CLK_IMG_WPE_A, "imgsys_wpe_a", "img_sel", 7),
};

static const struct of_device_id of_match_clk_mt6779_img[] = {
	{ .compatible = "mediatek,mt6779-imgsys", },
	{}
static const struct mtk_clk_desc img_desc = {
	.clks = img_clks,
	.num_clks = ARRAY_SIZE(img_clks),
};

static int clk_mt6779_img_probe(struct platform_device *pdev)
static const struct of_device_id of_match_clk_mt6779_img[] = {
	{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK);

	mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks),
			       clk_data);

	return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
		.compatible = "mediatek,mt6779-imgsys",
		.data = &img_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt6779_img_drv = {
	.probe = clk_mt6779_img_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt6779-img",
		.of_match_table = of_match_clk_mt6779_img,
+13 −16
Original line number Diff line number Diff line
@@ -32,26 +32,23 @@ static const struct mtk_gate ipe_clks[] = {
	GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "ipe_sel", 6),
};

static const struct of_device_id of_match_clk_mt6779_ipe[] = {
	{ .compatible = "mediatek,mt6779-ipesys", },
	{}
static const struct mtk_clk_desc ipe_desc = {
	.clks = ipe_clks,
	.num_clks = ARRAY_SIZE(ipe_clks),
};

static int clk_mt6779_ipe_probe(struct platform_device *pdev)
static const struct of_device_id of_match_clk_mt6779_ipe[] = {
	{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_IPE_NR_CLK);

	mtk_clk_register_gates(node, ipe_clks, ARRAY_SIZE(ipe_clks),
			       clk_data);

	return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
		.compatible = "mediatek,mt6779-ipesys",
		.data = &ipe_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt6779_ipe_drv = {
	.probe = clk_mt6779_ipe_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt6779-ipe",
		.of_match_table = of_match_clk_mt6779_ipe,
+12 −15
Original line number Diff line number Diff line
@@ -27,26 +27,23 @@ static const struct mtk_gate mfg_clks[] = {
	GATE_MFG(CLK_MFGCFG_BG3D, "mfg_bg3d", "mfg_sel", 0),
};

static int clk_mt6779_mfg_probe(struct platform_device *pdev)
{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_MFGCFG_NR_CLK);

	mtk_clk_register_gates(node, mfg_clks, ARRAY_SIZE(mfg_clks),
			       clk_data);

	return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
}
static const struct mtk_clk_desc mfg_desc = {
	.clks = mfg_clks,
	.num_clks = ARRAY_SIZE(mfg_clks),
};

static const struct of_device_id of_match_clk_mt6779_mfg[] = {
	{ .compatible = "mediatek,mt6779-mfgcfg", },
	{}
	{
		.compatible = "mediatek,mt6779-mfgcfg",
		.data = &mfg_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt6779_mfg_drv = {
	.probe = clk_mt6779_mfg_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt6779-mfg",
		.of_match_table = of_match_clk_mt6779_mfg,
Loading