From patchwork Mon Mar 6 14:05:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 64691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1867870wrd; Mon, 6 Mar 2023 06:21:13 -0800 (PST) X-Google-Smtp-Source: AK7set+SeFPLQew4uDvxw2eVyeEdHNE8JW2n+JRKJKpmGPVK7zWiEdByHYSLz/oWhXuEWp5ZgG2x X-Received: by 2002:a17:907:c689:b0:914:4164:658a with SMTP id ue9-20020a170907c68900b009144164658amr908424ejc.42.1678112473722; Mon, 06 Mar 2023 06:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678112473; cv=none; d=google.com; s=arc-20160816; b=lmYWYKfsqC1bQkCKlkJFk6C2ASyjOxwkmwn8oZI2spDdy8Bcyx7G4xQILunyTqVDmg ucEztAzLmTSaGxRCuFoVVi5VlTTu6tAWGuZzC+2mbb4Aodvva669s6/iMQu7c/AFDaSQ mdvPZQh6wXluwUw7ZvPryt0llSZUzHnpNBx7gjClxcB0A/FOs7Su5Zp/xFGePZvhCRmT Af+Obtqs/e7TAcFLDMenzz+q8GMkcbq9ykN/XgBs1ksKgm96acxqZxfBztj41PRGL6fB 5S3YOF0IB6FxhCoZBT3CAu9YVe+kpZQQ/s2ZdNUf0uYnTRZBuyk6iFNtHs6K3qzi4LnM gOZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FUKdoVwMAZzoFKBUKkcgIT/Cet5Po4WSpRXoJ0kKs44=; b=KnpPAuufTeLOmCCaWX5jSjQyjX77ZmlsdjrfpM7FndecY+R/en0zw2H6m4Ln/9GbPg HVb4UKL+VHVUFlcQj4aDuRjTGu2ZkR/EFk3LcVjF56OurERhkGzqH5mATBUZ86Z/W6kH u5gc33Iu7t61AO151W5l6ALY2KUm0EUe8cmDovE+EmALyUlvnClu/OYqym1jq5br96Y2 EK8ADpL6q3HcGymrv5JU54yW6CSoNoaWldC1cQByYdUk/A/TA5djuauBv8f//K4gMGGy A2ohBFhuLQoCzxtN6iHpJhESqN7grS+4pFn5hqqKoOWMb4WPoqil8sXAAqBN8Wr3Ggy0 zjtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=PuZZAHGG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id le4-20020a170907170400b009087dc51377si9223161ejc.903.2023.03.06.06.20.50; Mon, 06 Mar 2023 06:21:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=PuZZAHGG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231363AbjCFOJ2 (ORCPT + 99 others); Mon, 6 Mar 2023 09:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbjCFOIk (ORCPT ); Mon, 6 Mar 2023 09:08:40 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08794303F4; Mon, 6 Mar 2023 06:07:28 -0800 (PST) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 0974B6602FEA; Mon, 6 Mar 2023 14:06:38 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1678111600; bh=WQcaXXwOq3O7Y+HQbtaOpT+Y4baqgZ5rlrg81xb5Vxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PuZZAHGGy3eI1AdxvNbapBbGNyCG56L8HWW8Sa5a0pFCfQBJ6YpJymEw+i5KdRTKX fIB7v1UBzzLTnvmEti70wLMd0nH6qgGUt8U0THBF4jBmZyP/yXOaJjaBwY9ZW73hl6 YIIh/aig2B8zeDAZ30bEudPgvMgFxaFnu1kKJkcIMyX/Uolbybrk8Z3r4O7ka0SpXL t6wj3COV98XKVDp8HAztKYUR1B7Mn1ZX9nab5xDuZ+B2ZyVC7sQf1qLQXqIxxt9JY5 QiLNteu/21+4gSM3W8J2vtJMQJ66l4ZOXBGlyICMQRBok26YJCJL9/ub1n7+YTejCH 5c/jjriXDRTXA== From: AngeloGioacchino Del Regno To: mturquette@baylibre.com Cc: sboyd@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, wenst@chromium.org, johnson.wang@mediatek.com, miles.chen@mediatek.com, chun-jie.chen@mediatek.com, daniel@makrotopia.org, fparent@baylibre.com, msp@baylibre.com, nfraprado@collabora.com, rex-bc.chen@mediatek.com, zhaojh329@gmail.com, sam.shih@mediatek.com, edward-jw.yang@mediatek.com, yangyingliang@huawei.com, granquet@baylibre.com, pablo.sun@mediatek.com, sean.wang@mediatek.com, chen.zhong@mediatek.com, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com Subject: [PATCH v6 33/54] clk: mediatek: mt7986-infracfg: Migrate to common probe mechanism Date: Mon, 6 Mar 2023 15:05:22 +0100 Message-Id: <20230306140543.1813621-34-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306140543.1813621-1-angelogioacchino.delregno@collabora.com> References: <20230306140543.1813621-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759628465132353727?= X-GMAIL-MSGID: =?utf-8?q?1759628465132353727?= Convert this driver to use the common mtk_clk_simple_probe() mechanism. While at it, also use module_platform_driver() instead, as this driver just gained a .remove() callback during the conversion. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Chen-Yu Tsai Tested-by: Daniel Golle --- drivers/clk/mediatek/clk-mt7986-infracfg.c | 61 ++++++---------------- 1 file changed, 17 insertions(+), 44 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt7986-infracfg.c b/drivers/clk/mediatek/clk-mt7986-infracfg.c index 0a4bf87ee160..0299faad0733 100644 --- a/drivers/clk/mediatek/clk-mt7986-infracfg.c +++ b/drivers/clk/mediatek/clk-mt7986-infracfg.c @@ -157,57 +157,30 @@ static const struct mtk_gate infra_clks[] = { GATE_INFRA2(CLK_INFRA_IPCIEB_CK, "infra_ipcieb", "sysaxi_sel", 15), }; -static int clk_mt7986_infracfg_probe(struct platform_device *pdev) -{ - struct clk_hw_onecell_data *clk_data; - struct device_node *node = pdev->dev.of_node; - int r; - void __iomem *base; - int nr = ARRAY_SIZE(infra_divs) + ARRAY_SIZE(infra_muxes) + - ARRAY_SIZE(infra_clks); - - base = of_iomap(node, 0); - if (!base) { - pr_err("%s(): ioremap failed\n", __func__); - return -ENOMEM; - } - - clk_data = mtk_alloc_clk_data(nr); - - if (!clk_data) - return -ENOMEM; - - mtk_clk_register_factors(infra_divs, ARRAY_SIZE(infra_divs), clk_data); - mtk_clk_register_muxes(&pdev->dev, infra_muxes, - ARRAY_SIZE(infra_muxes), node, - &mt7986_clk_lock, clk_data); - mtk_clk_register_gates(&pdev->dev, node, infra_clks, - ARRAY_SIZE(infra_clks), clk_data); - - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); - if (r) { - pr_err("%s(): could not register clock provider: %d\n", - __func__, r); - goto free_infracfg_data; - } - return r; - -free_infracfg_data: - mtk_free_clk_data(clk_data); - return r; - -} +static const struct mtk_clk_desc infra_desc = { + .clks = infra_clks, + .num_clks = ARRAY_SIZE(infra_clks), + .factor_clks = infra_divs, + .num_factor_clks = ARRAY_SIZE(infra_divs), + .mux_clks = infra_muxes, + .num_mux_clks = ARRAY_SIZE(infra_muxes), + .clk_lock = &mt7986_clk_lock, +}; static const struct of_device_id of_match_clk_mt7986_infracfg[] = { - { .compatible = "mediatek,mt7986-infracfg", }, - {} + { .compatible = "mediatek,mt7986-infracfg", .data = &infra_desc }, + { /* sentinel */ } }; static struct platform_driver clk_mt7986_infracfg_drv = { - .probe = clk_mt7986_infracfg_probe, .driver = { .name = "clk-mt7986-infracfg", .of_match_table = of_match_clk_mt7986_infracfg, }, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, }; -builtin_platform_driver(clk_mt7986_infracfg_drv); +module_platform_driver(clk_mt7986_infracfg_drv); + +MODULE_DESCRIPTION("MediaTek MT7986 infracfg clocks driver"); +MODULE_LICENSE("GPL");