From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9B71C433EF for ; Sat, 22 Jan 2022 09:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4uUbg0M/SlGsI5RVHmvlUO8VEpy0aoSN/irIVAc5Bg0=; b=R5oWOn4x7rdJcc DP1lM4FM7i8fOlE5cMcjuXszBTiQDKl2bY2ksVZnwPDNfGFKP+kL6+Uc4tI3K+OBQ2ogci7V8ouW0 ZjbTWX8dATRS8ymqRKmjx5HUoHJ12yJsko+VvkORrMUjtREuIlwpbeQYRZ0PcCIRHSeLzU1q3n9an msAuBUq7Azo/1g4KRC621x3RFIGXAO5bXjzOU9aRZ0L7SdEey+NIwTDBMLyfcB2FzAwMVKYCsxlOf sNYitM5GnZGSmRmhZFn5s7DH3813e3ESXeZqDRgmDJ+38r7WMtF0gQokRBd3epf+dt1tpjuPX144T xpHLSiYDaXxi2TmbtVOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBCbZ-00Gtpb-RK; Sat, 22 Jan 2022 09:22:42 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBCXB-00GrWZ-Kb for linux-arm-kernel@lists.infradead.org; Sat, 22 Jan 2022 09:18:11 +0000 Received: by mail-pl1-x635.google.com with SMTP id h13so10355847plf.2 for ; Sat, 22 Jan 2022 01:18:09 -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=0spPJqiyNma/JSwRciV7mlMnnEsvRwtK+rQFLo/is08=; b=R5I+rW3l2T7KAn4/rCa8lKm7eS2I2p6sSb3KmPPOSFkb/KVSuHM2ugYPUK2urOucUw c5fT9x7ax3oC7MX6mJoQlM1ax7e3Szh3BjrHbbzk/rFWLszCC+ly912TNdKHd4RpV+7V yJzMESoZicfzqEsL148u85ddGQQPdAixS56Sk= 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=0spPJqiyNma/JSwRciV7mlMnnEsvRwtK+rQFLo/is08=; b=nmfSbRbkBKQmTrI2DVi424lxFt9P2QrLsHCZaYiYhd/eP4ULEaM/DkDYrOg0vPJdds omD61NNJHBB4w5eMTSvzC9nasYScLBjcTCsxiC7Cy02P86Hm5QfjUtfD/5xlXm+/CNy5 ltiJEid/8D17clsndnsJNdg5xfhKteP5X4At86X9VlpmQxArDAkNimUCdM4BkQZs0SN4 YEt4u4ocfIY0h0vPd0lmXFXcCZvf6IY+QNklcCigLYz+GO8J+AvDgVpBU1bonHu0bIZB HK6WnUetAefrDi6VXmXNoLMe9ucp55T9pLxU+Vcz4BKQuLQez6OWn8NdCSf4CQpS4FZc CbIQ== X-Gm-Message-State: AOAM533TCiG3bU+3pZuwTJhyIKrBNmojJLoRYk1wMkxskR+ZHRv6TOAm W/VgyIxRtB7jojTBSZuccBG6Zn92MDE+Tg== X-Google-Smtp-Source: ABdhPJyVK4Mt3oHJEIY99aJdCQK6gKiDhx4ht4FV9+3LLoe55aexZOXvspZbiR84kJ+rQS5uLuDxzw== X-Received: by 2002:a05:6a00:2151:b0:4a2:5c9a:f0a9 with SMTP id o17-20020a056a00215100b004a25c9af0a9mr6679544pfk.39.1642843077957; Sat, 22 Jan 2022 01:17:57 -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.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:17:57 -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 06/31] clk: mediatek: cpumux: Implement unregister API Date: Sat, 22 Jan 2022 17:17:06 +0800 Message-Id: <20220122091731.283592-7-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220122_011809_751637_1B454459 X-CRM114-Status: GOOD ( 13.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The cpumux clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal. Add a matching unregister function for the cpumux type clk. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-cpumux.c | 31 +++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-cpumux.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.c index cab5095416b6..99a819e3673f 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -77,6 +77,21 @@ mtk_clk_register_cpumux(const struct mtk_composite *mux, return clk; } +static void mtk_clk_unregister_cpumux(struct clk *clk) +{ + struct mtk_clk_cpumux *cpumux; + struct clk_hw *hw; + + hw = __clk_get_hw(clk); + if (!hw) + return; + + cpumux = to_mtk_clk_cpumux(hw); + + clk_unregister(clk); + kfree(cpumux); +} + int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data) @@ -106,4 +121,20 @@ int mtk_clk_register_cpumuxes(struct device_node *node, return 0; } +void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num, + struct clk_onecell_data *clk_data) +{ + int i; + + for (i = num; i > 0; i--) { + const struct mtk_composite *mux = &clks[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) + continue; + + mtk_clk_unregister_cpumux(clk_data->clks[mux->id]); + clk_data->clks[mux->id] = ERR_PTR(-ENOENT); + } +} + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-cpumux.h b/drivers/clk/mediatek/clk-cpumux.h index 2aaf1afd4e5f..fda7770fd803 100644 --- a/drivers/clk/mediatek/clk-cpumux.h +++ b/drivers/clk/mediatek/clk-cpumux.h @@ -19,4 +19,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num, + struct clk_onecell_data *clk_data); + #endif /* __DRV_CLK_CPUMUX_H */ -- 2.35.0.rc0.227.g00780c9af4-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel