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: clk-mt6795-topckgen: Migrate to mtk_clk_simple_probe()

Migrate away from custom probe functions and use the commonized
mtk_clk_simple_{probe, remove}().

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://lore.kernel.org/r/20230120092053.182923-22-angelogioacchino.delregno@collabora.com
Tested-by: Mingming Su <mingming.su@mediatek.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

AngeloGioacchino Del Regno and committed by
Stephen Boyd
72feb6f1 75c12ea3

+16 -74
+16 -74
drivers/clk/mediatek/clk-mt6795-topckgen.c
··· 523 523 DIV_GATE(CLK_TOP_APLL2_DIV5, "apll2_div5", "apll2_div4", 0x12c, 21, 0x12c, 4, 4), 524 524 }; 525 525 526 - 527 - static const struct of_device_id of_match_clk_mt6795_topckgen[] = { 528 - { .compatible = "mediatek,mt6795-topckgen" }, 529 - { /* sentinel */ } 526 + static const struct mtk_clk_desc topck_desc = { 527 + .fixed_clks = fixed_clks, 528 + .num_fixed_clks = ARRAY_SIZE(fixed_clks), 529 + .factor_clks = top_divs, 530 + .num_factor_clks = ARRAY_SIZE(top_divs), 531 + .mux_clks = top_muxes, 532 + .num_mux_clks = ARRAY_SIZE(top_muxes), 533 + .composite_clks = top_aud_divs, 534 + .num_composite_clks = ARRAY_SIZE(top_aud_divs), 535 + .clk_lock = &mt6795_top_clk_lock, 530 536 }; 531 537 532 - static int clk_mt6795_topckgen_probe(struct platform_device *pdev) 533 - { 534 - struct clk_hw_onecell_data *clk_data; 535 - struct device_node *node = pdev->dev.of_node; 536 - void __iomem *base; 537 - int ret; 538 - 539 - base = devm_platform_ioremap_resource(pdev, 0); 540 - if (IS_ERR(base)) 541 - return PTR_ERR(base); 542 - 543 - clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 544 - if (!clk_data) 545 - return -ENOMEM; 546 - 547 - ret = mtk_clk_register_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks), clk_data); 548 - if (ret) 549 - goto free_clk_data; 550 - 551 - ret = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); 552 - if (ret) 553 - goto unregister_fixed_clks; 554 - 555 - ret = mtk_clk_register_muxes(&pdev->dev, top_muxes, 556 - ARRAY_SIZE(top_muxes), node, 557 - &mt6795_top_clk_lock, clk_data); 558 - if (ret) 559 - goto unregister_factors; 560 - 561 - ret = mtk_clk_register_composites(&pdev->dev, top_aud_divs, 562 - ARRAY_SIZE(top_aud_divs), base, 563 - &mt6795_top_clk_lock, clk_data); 564 - if (ret) 565 - goto unregister_muxes; 566 - 567 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 568 - if (ret) 569 - goto unregister_composites; 570 - 571 - return 0; 572 - 573 - unregister_composites: 574 - mtk_clk_unregister_composites(top_aud_divs, ARRAY_SIZE(top_aud_divs), clk_data); 575 - unregister_muxes: 576 - mtk_clk_unregister_muxes(top_muxes, ARRAY_SIZE(top_muxes), clk_data); 577 - unregister_factors: 578 - mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); 579 - unregister_fixed_clks: 580 - mtk_clk_unregister_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks), clk_data); 581 - free_clk_data: 582 - mtk_free_clk_data(clk_data); 583 - return ret; 584 - } 585 - 586 - static int clk_mt6795_topckgen_remove(struct platform_device *pdev) 587 - { 588 - struct device_node *node = pdev->dev.of_node; 589 - struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 590 - 591 - of_clk_del_provider(node); 592 - mtk_clk_unregister_composites(top_aud_divs, ARRAY_SIZE(top_aud_divs), clk_data); 593 - mtk_clk_unregister_muxes(top_muxes, ARRAY_SIZE(top_muxes), clk_data); 594 - mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); 595 - mtk_clk_unregister_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks), clk_data); 596 - mtk_free_clk_data(clk_data); 597 - 598 - return 0; 599 - } 538 + static const struct of_device_id of_match_clk_mt6795_topckgen[] = { 539 + { .compatible = "mediatek,mt6795-topckgen", .data = &topck_desc }, 540 + { /* sentinel */ } 541 + }; 600 542 601 543 static struct platform_driver clk_mt6795_topckgen_drv = { 602 544 .driver = { 603 545 .name = "clk-mt6795-topckgen", 604 546 .of_match_table = of_match_clk_mt6795_topckgen, 605 547 }, 606 - .probe = clk_mt6795_topckgen_probe, 607 - .remove = clk_mt6795_topckgen_remove, 548 + .probe = mtk_clk_simple_probe, 549 + .remove = mtk_clk_simple_remove, 608 550 }; 609 551 module_platform_driver(clk_mt6795_topckgen_drv); 610 552