Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2507221pxb; Sun, 23 Jan 2022 06:56:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKUODrJBfWVZLLN+xTYNICRFH+N5IEQA4VulP75RkB0Pyu7YkIKA1dSpNCbTFQ93ae3Y9v X-Received: by 2002:a63:90c9:: with SMTP id a192mr9134899pge.68.1642949819703; Sun, 23 Jan 2022 06:56:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642949819; cv=none; d=google.com; s=arc-20160816; b=Tyu6y3R2LT3LtIN345MOW/LbQdYHTR2yPRVGDmMJ8CcbHCZ7o6AsVglyiUFYue0kbU jI3/3smm17XlgnN3Gh3ugwStCL/flW8A38JUbiBU7mDW2pNeklxh/Vph+gBxMjdYOX4P 0FxUsO8n0tnwClwI/6d2d7EzL8ydNHuwjuUppXh8nmu//Bc6uj2qaaiBazzyTm34iVwv vmc6fYbg4AebqwvwclYyGcnPIytjL4xg6rzhcJ8jPwXXhCYcE7zU1MTcHFpCZ8aABpnC 9NbLMmrgtJ3Q70HgDhbh5fMpoyhb0dzORPcjS3AYJrOdIlNQ330Y3ExFZrOdrOj7Xd7o fcGg== 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=0r/icLyBiPRWAX9DR8xwoo1Ajn0xsQM7/jQJfiNovl4=; b=RQSK1LNXGjRxj3XrgPvAIyR3dq8C+xUwx3fmX1C/s2UzfFb5DZkxhBicydLTsA7/CJ xPMV7gkYoHEh9d6L7r5zUf0rKZoph4FzT1JBmTkkMXd4iQgd/MN1upVwG+l5p2IJBWD2 v0n/cPQ7pNAizfr8ihsDT7rCaDIcnpmJiXcQmFogBuVr8n4yenlDgMqS/5VaDrDtnaPB yFkPqd7fZ4DyWS9uGiuMgqpnTbt0GFuZI6+l1hOBELi+OVTWviR2LQuNtNKRLjdf8IVW LZWkuXSrmgdtEH0tL+7AJdeUgbzu5W04wwsS0A3uJ7lck0ajgeExZlultoqZfcXwG+8d zQHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NIkPglMl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si10098159pfv.267.2022.01.23.06.56.48; Sun, 23 Jan 2022 06:56:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NIkPglMl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234055AbiAVJS6 (ORCPT + 99 others); Sat, 22 Jan 2022 04:18:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234007AbiAVJSU (ORCPT ); Sat, 22 Jan 2022 04:18:20 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACF3AC061748 for ; Sat, 22 Jan 2022 01:18:20 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id w190so4880433pfw.7 for ; Sat, 22 Jan 2022 01:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0r/icLyBiPRWAX9DR8xwoo1Ajn0xsQM7/jQJfiNovl4=; b=NIkPglMlv2Ah6b+M/D72wGdMSWs329exo2s/sWwo2kEcfCVveRvRW8MflsWkpCHok3 UZJp2re6/JJjOPSx8f/2LE/F4aWPQMMtXDkn8xgg+wi4Q6MmSbCmDvaIcAGT/QwbE6Oi zhQ2nJ1tR6PVO4uBVfjkOAcFQ/7daZCPRGv40= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0r/icLyBiPRWAX9DR8xwoo1Ajn0xsQM7/jQJfiNovl4=; b=bh6Jatf9NTYdNjf7/T+3EUuHWfzwocXM+wsi+apw5roosyRlIUFn7SmKHbA869tRZP pqWu1QsoYSnMCKfIane0qmGnHqJ5iT/MQ0mV/Xz79+kdXJE1MLB51cr4N4W5WuUmdP8g twYyKtukLONteZ6RQRGTSnYIEUjZbKKFMAhrvyaLlbpq6GScDI9VfKiwTFBk8uJV6NeF ZKwRTaXKsYOvtRTW190/xiR/r9ys7bvyVVi11aD2A/9h1cywXNf1zx6p+VoAD55pVov2 Q3UPkIh3cAL18osu4ylyrGnfJt07urAIhiCgni/GkbPPSKDsRTA+oAL2NHAddHi9pq0v GL5A== X-Gm-Message-State: AOAM532/JMEciEUN6LkPM7f6PJfngxVHoApUjPJ6WDiIg2fsOLpAtrmB BSPxh6g4ljBZX2879NEO3Pi5lA== X-Received: by 2002:a65:4685:: with SMTP id h5mr5536639pgr.14.1642843100230; Sat, 22 Jan 2022 01:18:20 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:349f:9373:45d9:eb26]) by smtp.gmail.com with ESMTPSA id s1sm1608100pjn.42.2022.01.22.01.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:19 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/31] clk: mediatek: Implement mtk_clk_unregister_factors() API Date: Sat, 22 Jan 2022 17:17:16 +0800 Message-Id: <20220122091731.283592-17-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog In-Reply-To: <20220122091731.283592-1-wenst@chromium.org> References: <20220122091731.283592-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mtk_clk_register_factors(), as the name suggests, is used to register a given list of fixed factor clks. However it is lacking a counterpart unregister API. Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal. In the header file, the register function's declaration is also reformatted to fit code style guidelines. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mtk.c | 20 ++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 7c0d5706eed7..b267b2f04b84 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -126,6 +126,26 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, } EXPORT_SYMBOL_GPL(mtk_clk_register_factors); +void mtk_clk_unregister_factors(const struct mtk_fixed_factor *clks, int num, + struct clk_onecell_data *clk_data) +{ + int i; + + if (!clk_data) + return; + + for (i = num; i > 0; i--) { + const struct mtk_fixed_factor *ff = &clks[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[ff->id])) + continue; + + clk_unregister_fixed_factor(clk_data->clks[ff->id]); + clk_data->clks[ff->id] = ERR_PTR(-ENOENT); + } +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_factors); + struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, void __iomem *base, spinlock_t *lock) { diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index cc7f920eabb4..4db1a97c1250 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -55,8 +55,10 @@ struct mtk_fixed_factor { .div = _div, \ } -void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, - int num, struct clk_onecell_data *clk_data); +void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, + struct clk_onecell_data *clk_data); +void mtk_clk_unregister_factors(const struct mtk_fixed_factor *clks, int num, + struct clk_onecell_data *clk_data); struct mtk_composite { int id; -- 2.35.0.rc0.227.g00780c9af4-goog