Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2507269pxb; Sun, 23 Jan 2022 06:57:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUu/h2HtE7KzIhFCBtGCtQ+3cjCC82mygJT7qw3kLI1pG5MVxSM3ybv9fmxlwzqfxDKFL7 X-Received: by 2002:a05:6a00:c88:b0:4c2:c642:f21e with SMTP id a8-20020a056a000c8800b004c2c642f21emr11080243pfv.42.1642949828267; Sun, 23 Jan 2022 06:57:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642949828; cv=none; d=google.com; s=arc-20160816; b=X8F4xnTZto6PvCNBFy+vKGC4JJnIP2LGMBiya1CbtmA5J2j3hIhRbfvVvjzFlizG3l pO7ePrlllOstJvgCBZGhXAS/KkYIJmJYHlpD/fe2NbLe0ffEzvfwIf8aJ9aSQ80yvJpc ac6FOEXMjsdYWUU8Xi3iEqa1VinOD+1gPVayOqEP0w8x3hp9X03Z/L0s2FleGNQHmU2I PxXHjre5JR2eVdUWmWmgIhA2XE78omRxaS0MDQbYx/jnF8UVhk5Sox07RqebAuRwox2P JJZioz4ExA8HeFA/n0k7i/q68Xqnep2nFz9s3xtd06c8ckLWoRx+Va9rhY7d+6iDYEoe 1EQg== 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=/W+xKFLd9pAMfBNMVJ4svP7XH9i2778pmii7z75+YJU=; b=m8NcUVlKSI9cQHhoPPPzifvYQd+kdhH5jHzMK1JOvUNr8g651lieDAXcl+ZqhJwkDO 9eEtwtaodcPJ5zVjBAqdTQpNWoc9Q5QoOMj8q3DIg8b2AsaxDl3Z1L7oEvtt3RdYKx4Y Kk+w2Tbw6fEjJ+z5PSc3xY6S6P4ZIGbDwUNXofH62zU98codaTsH9WnmuqZ5i2SoA5FK 55TZxu1cbbXgXgwbDYkgRkqfPRWeUkpDi2HfyiObD2BoCVP9wRsZLDZmjf/KmstkMT1h aasUexNA4E79/LH3Ukh7RPjtj654DV6amv0IpoR+FzdR4z3ghRrXhsWnGYLxXR5lk1um uQcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gGYae5ca; 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 d4si13474679pgi.499.2022.01.23.06.56.56; Sun, 23 Jan 2022 06:57:08 -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=gGYae5ca; 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 S234210AbiAVJTP (ORCPT + 99 others); Sat, 22 Jan 2022 04:19:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234211AbiAVJSh (ORCPT ); Sat, 22 Jan 2022 04:18:37 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187A1C06175C for ; Sat, 22 Jan 2022 01:18:25 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id s2-20020a17090ad48200b001b501977b23so10760056pju.2 for ; Sat, 22 Jan 2022 01:18:25 -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=/W+xKFLd9pAMfBNMVJ4svP7XH9i2778pmii7z75+YJU=; b=gGYae5caEwlDlR3SVSNgX/JX1yhbQuv8yWgfZAa2aQstNGgg3l5EKYMgRQhKmoQSgY hae5FE9AcZC/I7yfenInwQdl6GqU1xGGl44VsdAoRBX4Pzp711KfRxPc7RplsHvYkLiN GRkaRSRjncUeyzOms95i9xiNVQSLxX0+flLBA= 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=/W+xKFLd9pAMfBNMVJ4svP7XH9i2778pmii7z75+YJU=; b=21TR89R73uibsVjh2fd41TAVFrwMszEhgSceDRVcPWcts6z7Tal/EG7DCeeHcTcqAp lQ3Ljvltre+Z75846XkJRBYUyHMhcpZ7Scr4e2ltiwCZsZ9Lyu4QVf9gVLtHQP9qk5Vi WPCf7Oai5eoxU7AiBpSsSr5O/nMqET3Vp3wwa4Ziat+YQjIqE7lEp6pT37xJAZHnKpdM 1FjNSZPA+xtyAomCzVSUhG4AwjVbZnnB5bfyuPTm7JFVMf3xQU/B0i4EUlI9UVaNicgp NeU/xwmXc72iBhV/E0A3LQRL7z4n+NKfPdw6XlyjUy0m71+UNZyF50tfR3oIiZAmi7ZA BS4Q== X-Gm-Message-State: AOAM533VZl1AMFRRYF1PD60lGM2psvcRHQSeM/fuuQvHfXtn6zCOUJ9x HHz2vDJh4RtBliX55jtZS/wXTA== X-Received: by 2002:a17:90a:9488:: with SMTP id s8mr4431625pjo.40.1642843104700; Sat, 22 Jan 2022 01:18:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:24 -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 18/31] clk: mediatek: Implement mtk_clk_unregister_composites() API Date: Sat, 22 Jan 2022 17:17:18 +0800 Message-Id: <20220122091731.283592-19-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_composites(), as the name suggests, is used to register a given list of composite 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 | 41 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 3a6dfe445e63..2150ed8678e0 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -233,6 +233,27 @@ struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, return ERR_PTR(ret); } +static void mtk_clk_unregister_composite(struct clk *clk) +{ + struct clk_hw *hw = __clk_get_hw(clk); + struct clk_composite *composite = to_clk_composite(hw); + struct clk_mux *mux = NULL; + struct clk_gate *gate = NULL; + struct clk_divider *div = NULL; + + if (composite->mux_hw) + mux = to_clk_mux(composite->mux_hw); + if (composite->gate_hw) + gate = to_clk_gate(composite->gate_hw); + if (composite->rate_hw) + div = to_clk_divider(composite->rate_hw); + + clk_unregister_composite(clk); + kfree(div); + kfree(gate); + kfree(mux); +} + void mtk_clk_register_composites(const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data) @@ -259,6 +280,26 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs, } EXPORT_SYMBOL_GPL(mtk_clk_register_composites); +void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int num, + struct clk_onecell_data *clk_data) +{ + int i; + + if (!clk_data) + return; + + for (i = num; i > 0; i--) { + const struct mtk_composite *mc = &mcs[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[mc->id])) + continue; + + mtk_clk_unregister_composite(clk_data->clks[mc->id]); + clk_data->clks[mc->id] = ERR_PTR(-ENOENT); + } +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_composites); + void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data) diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index e3ae22fb0334..3c3a934f53cd 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -153,6 +153,8 @@ struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, void mtk_clk_register_composites(const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int num, + struct clk_onecell_data *clk_data); struct mtk_clk_divider { int id; -- 2.35.0.rc0.227.g00780c9af4-goog