From patchwork Tue Feb 8 12:40:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738604 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 8059EC433F5 for ; Tue, 8 Feb 2022 12:41:35 +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=LA87flmi3CcuKJYZzEDa9IflHH2Ruwl48dW+Ox+CgyI=; b=2LsGmFJksZOFqH cqgw5To54U3UHFeApSZmVKLcsEpBL36yV+wNoHWbpA5X7Dz+ps7GgBP6noOw6PovfigaMH0tinBN1 A1dmNcO3jG3LdpDYlZNkvYNKCbmbdXM2iLXagHFOuF4IzlpvqLfV8Ix++Gd//X+Xs2jSDwTcE7DxC OCdDKfN73uMWMJZz4jQg5cfuVgcKHO3Cba8IsU59OsipCAsTKACbNycnsKrDqIDkTDzTNowhxzmcG iIKCqS4lEJPl9dFSPHhBbKoV8GEFEjXcy2gY0K3Qpnh86YrtG5aSZFpfwzV0CNbiqEYKrDQcSsiLi acQ39qXyXCQI7XZM5ocA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoG-00DnY4-GT; Tue, 08 Feb 2022 12:41:28 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPng-00DnGJ-JT for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:40:54 +0000 Received: by mail-pj1-x1032.google.com with SMTP id d9-20020a17090a498900b001b8bb1d00e7so2596259pjh.3 for ; Tue, 08 Feb 2022 04:40:51 -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=AG7JP3PmNd1EdvNHfZQCnHdtS8h0RT7R6zED7dijliQ=; b=GkXiVgi6P5XFN318B4BLQ2z310OMACd/EFqC0tE2le1ZztIwJf+SnhUObQ+MJ6zT7V OLbpf4T0ja8OkynRbZKfQaCGIDjxoJBrMhsMzolUyb3NOaW04IwjA6WtrnoUWyM4wiKR v0xJbLOT7/3dz/zdmYDLa22LLdOh01xQgk+T0= 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=AG7JP3PmNd1EdvNHfZQCnHdtS8h0RT7R6zED7dijliQ=; b=f6H/IEBin2Rt4igWh5azwBkuRkVYJ7r/k81jC2Hp4p4jjLO5khYyngS05IILRL5tmA TTKHDqPXZBqeWdcIPpNJM+8bf28v2Zk4dsb+SgUzAQPnjbWc27FpyewfIeO6RR6Y+ooj 1PXYHfhlkW5EXaIIYjwcyn0Do874qwBRxfTLRbgP9b/dG+H0es6olfvTB35lqgYWJf3X IdSmU8xFNJWYg6B0gca9fUMuwiZvaDL1+8p60Alafv05JM/SXtO2FUO86W5viPfPa5LG tbtq5u8SB0fEQ7uB41KuW7NnWdTZX4g3s5dbMKtYjrDszQnhaZ48brNYqM3Xl+iNItv1 kHFQ== X-Gm-Message-State: AOAM533AmcHAC6WSwjZuj/LHLsAzpAaBf8Wh6v8tuAUzIxnnGy8YpQXj cLOJUtGTp9G5xl0oLt0wowk5GMI8wyoX6w== X-Google-Smtp-Source: ABdhPJwuFITGMv7hSWZiicKfreHbP0qxbpac0MmUj3+5Sa/OT+2vcrS0hRAdQj2Rs2AtUEpwXQ9cxw== X-Received: by 2002:a17:902:ce8b:: with SMTP id f11mr4348415plg.40.1644324051390; Tue, 08 Feb 2022 04:40:51 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:40:51 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 01/31] clk: mediatek: Use %pe to print errors Date: Tue, 8 Feb 2022 20:40:04 +0800 Message-Id: <20220208124034.414635-2-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044052_676554_5878798E X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org If %pe is used to print errors, a string representation of the error would be printed instead of a number as with %ld. Also, all the sites printing errors are deriving the error code from a pointer. Using %pe is more straightforward. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-apmixed.c | 2 +- drivers/clk/mediatek/clk-cpumux.c | 6 ++---- drivers/clk/mediatek/clk-mtk.c | 18 ++++++------------ drivers/clk/mediatek/clk-mux.c | 6 ++---- drivers/clk/mediatek/clk-pll.c | 3 +-- drivers/clk/mediatek/reset.c | 3 +-- 6 files changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/clk/mediatek/clk-apmixed.c b/drivers/clk/mediatek/clk-apmixed.c index caa9119413f1..a29339cc26c4 100644 --- a/drivers/clk/mediatek/clk-apmixed.c +++ b/drivers/clk/mediatek/clk-apmixed.c @@ -92,7 +92,7 @@ struct clk * __init mtk_clk_register_ref2usb_tx(const char *name, clk = clk_register(NULL, &tx->hw); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", name, clk); kfree(tx); } diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.c index e188018bc906..cab5095416b6 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -87,8 +87,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, regmap = device_node_to_regmap(node); if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %ld\n", node, - PTR_ERR(regmap)); + pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); return PTR_ERR(regmap); } @@ -97,8 +96,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, clk = mtk_clk_register_cpumux(mux, regmap); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - mux->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", mux->name, clk); continue; } diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 8d5791b3f460..519a461cbb6f 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -70,8 +70,7 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, rc->rate); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - rc->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", rc->name, clk); continue; } @@ -97,8 +96,7 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, CLK_SET_RATE_PARENT, ff->mult, ff->div); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - ff->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", ff->name, clk); continue; } @@ -122,8 +120,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, regmap = device_node_to_regmap(node); if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %ld\n", node, - PTR_ERR(regmap)); + pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); return PTR_ERR(regmap); } @@ -141,8 +138,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, gate->shift, gate->ops, gate->flags, dev); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - gate->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", gate->name, clk); continue; } @@ -264,8 +260,7 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs, clk = mtk_clk_register_composite(mc, base, lock); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - mc->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", mc->name, clk); continue; } @@ -293,8 +288,7 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, mcd->div_width, mcd->clk_divider_flags, lock); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - mcd->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", mcd->name, clk); continue; } diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 6d3a50eb7d6f..89f23e111d91 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -175,8 +175,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, regmap = device_node_to_regmap(node); if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %ld\n", node, - PTR_ERR(regmap)); + pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); return PTR_ERR(regmap); } @@ -187,8 +186,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, clk = mtk_clk_register_mux(mux, regmap, lock); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - mux->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", mux->name, clk); continue; } diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 60d7ffa0b924..f04f724e12e5 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -378,8 +378,7 @@ void mtk_clk_register_plls(struct device_node *node, clk = mtk_clk_register_pll(pll, base); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - pll->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", pll->name, clk); continue; } diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c index ffe464ce7ff8..bcec4b89f449 100644 --- a/drivers/clk/mediatek/reset.c +++ b/drivers/clk/mediatek/reset.c @@ -100,8 +100,7 @@ static void mtk_register_reset_controller_common(struct device_node *np, regmap = device_node_to_regmap(np); if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %ld\n", np, - PTR_ERR(regmap)); + pr_err("Cannot find regmap for %pOF: %pe\n", np, regmap); return; } From patchwork Tue Feb 8 12:40:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738605 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 998CBC433EF for ; Tue, 8 Feb 2022 12:42:12 +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=+kVhkFngw+whYzLtnhmZAmRT9NFiSPXAx+FX+smNzKc=; b=PGxzAdSp3kUPGj RVkBE0dgkEEVwYUBRi3d3FtcBmgPeilICcBLwggkhlk3Xg8Sw23XsSQAZCojvvomuhW6MhMC9wpFR zeEVVeixMz7HDX8zo9Z3kyXMu8JQlteLV6P8nHWPG94eEjm5cDKDH94AzA8bX2CQTptMcAAn5frGc vVGlXc9vWFBPiMY+h3JdJ05M05y6Fyi4R4KGG+z9iAnaoAPDviSbSv6NiWuf0cyB3cl/hn+vR5nQF hbk0eLTxi9o3OjEYbmg1JsOhLzURqPB/gSePVKpuse4SkEu1TVdsEsECiFEL1DilXUkUbh3lRhIeJ LrHdd9OD4aScGYxzqLjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPop-00DnqF-KX; Tue, 08 Feb 2022 12:42:03 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPni-00DnHN-Mp for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:40:57 +0000 Received: by mail-pj1-x1029.google.com with SMTP id c5-20020a17090a1d0500b001b904a7046dso417973pjd.1 for ; Tue, 08 Feb 2022 04:40:54 -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=sJY5Um+e3Zhwa51B9/uiFlDKmQ6du7mYuS31VfH399Q=; b=SDUVezZ2U7t3EKc/zBv6B+CFLef3IyaUyi9jwAdEPdFHZ4OhbAldQvTrcFyF4SpMpw XbL84xhIgwY3GULLblL6VThNKqcL6YfvDQmb6FFmCF/+07WiwmAJYzh3n0JhpmU5gUF4 b6b0N6R1MGh0WZrzWv0zOuyg3Nen/apn0TFfE= 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=sJY5Um+e3Zhwa51B9/uiFlDKmQ6du7mYuS31VfH399Q=; b=LSLWbhaC2kGkiK0LZ+j8lVMkvbMFy1sWV/uj6ZPL9y4bE9170zYX41FvbqKRePwCFN if23/Hw25F7kuFJD4hDEpG7HUf9AGIUNCA5N3P9zHHC8cMPiVWz3owvThYfoawQb1D90 14Hg029Dd7xkoiqEdb39ylFAOf+63GEvi8MefP3mXcge5K2QmGEP0P02r4hXnUXz3Q1L ffs0Zc9kc/59kaBN2goPRkxsfSGfID/pub7DC96gEgQptfXhdsYgR3ga5olHSwcmDl9u SFoMAKIBfRae18j5nYIiLMiKRkPnTz8x7UWkFvKxXcS3/VxqI6+BVWoMtt403MpTiC7z TUrQ== X-Gm-Message-State: AOAM530I28E2a4oJHwuf7bKO9Orr3XFmIu4jyUFoR5BygEWLYTKJDfS+ K+8gh16dUbnBaWAndJBy6vlJkQ== X-Google-Smtp-Source: ABdhPJzIptVfF9/Nr+7xAEGmtgdzohLMSJf77H6U3m66Hps5mBQCBofvJaIC8Rc4OcVkb/jxNFfcfA== X-Received: by 2002:a17:902:7e06:: with SMTP id b6mr4461526plm.58.1644324053538; Tue, 08 Feb 2022 04:40:53 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:40:53 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/31] clk: mediatek: gate: Consolidate gate type clk related code Date: Tue, 8 Feb 2022 20:40:05 +0800 Message-Id: <20220208124034.414635-3-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044054_839844_99F31B9F X-CRM114-Status: GOOD ( 19.29 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Right now some bits of the gate type clk code are in clk-gate.[ch], but other bits are in clk-mtk.[ch]. This is different from the cpumux and mux type clks, for which all of the code are found in the same files. Move the functions that register multiple clks from a given list, mtk_clk_register_gates_with_dev() and mtk_clk_register_gates(), to clk-gate.[ch] to consolidate all the code for the gate type clks. This commit only moves code with minor whitespace fixups to correct the code style. Further improvements, such as internalizing various functions and structures will be done in later commits. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-gate.c | 53 ++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-gate.h | 25 ++++++++++++++++ drivers/clk/mediatek/clk-mtk.c | 51 ------------------------------- drivers/clk/mediatek/clk-mtk.h | 25 ---------------- 4 files changed, 77 insertions(+), 77 deletions(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c index 5d88b428565b..54921768bfba 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -11,9 +11,9 @@ #include #include #include +#include #include -#include "clk-mtk.h" #include "clk-gate.h" static u32 mtk_get_clockgating(struct clk_hw *hw) @@ -182,4 +182,55 @@ struct clk *mtk_clk_register_gate( } EXPORT_SYMBOL_GPL(mtk_clk_register_gate); +int mtk_clk_register_gates_with_dev(struct device_node *node, + const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data, + struct device *dev) +{ + int i; + struct clk *clk; + struct regmap *regmap; + + if (!clk_data) + return -ENOMEM; + + regmap = device_node_to_regmap(node); + if (IS_ERR(regmap)) { + pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); + return PTR_ERR(regmap); + } + + for (i = 0; i < num; i++) { + const struct mtk_gate *gate = &clks[i]; + + if (!IS_ERR_OR_NULL(clk_data->clks[gate->id])) + continue; + + clk = mtk_clk_register_gate(gate->name, gate->parent_name, + regmap, + gate->regs->set_ofs, + gate->regs->clr_ofs, + gate->regs->sta_ofs, + gate->shift, gate->ops, + gate->flags, dev); + + if (IS_ERR(clk)) { + pr_err("Failed to register clk %s: %pe\n", gate->name, clk); + continue; + } + + clk_data->clks[gate->id] = clk; + } + + return 0; +} + +int mtk_clk_register_gates(struct device_node *node, + const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data) +{ + return mtk_clk_register_gates_with_dev(node, clks, num, clk_data, NULL); +} +EXPORT_SYMBOL_GPL(mtk_clk_register_gates); + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-gate.h b/drivers/clk/mediatek/clk-gate.h index 3c3329ec54b7..432b571d23b3 100644 --- a/drivers/clk/mediatek/clk-gate.h +++ b/drivers/clk/mediatek/clk-gate.h @@ -43,6 +43,22 @@ struct clk *mtk_clk_register_gate( unsigned long flags, struct device *dev); +struct mtk_gate_regs { + u32 sta_ofs; + u32 clr_ofs; + u32 set_ofs; +}; + +struct mtk_gate { + int id; + const char *name; + const char *parent_name; + const struct mtk_gate_regs *regs; + int shift; + const struct clk_ops *ops; + unsigned long flags; +}; + #define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, \ _ops, _flags) { \ .id = _id, \ @@ -57,4 +73,13 @@ struct clk *mtk_clk_register_gate( #define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops) \ GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0) +int mtk_clk_register_gates(struct device_node *node, + const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data); + +int mtk_clk_register_gates_with_dev(struct device_node *node, + const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data, + struct device *dev); + #endif /* __DRV_CLK_GATE_H */ diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 519a461cbb6f..0c5db3c71fdd 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -106,57 +106,6 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, } EXPORT_SYMBOL_GPL(mtk_clk_register_factors); -int mtk_clk_register_gates_with_dev(struct device_node *node, - const struct mtk_gate *clks, - int num, struct clk_onecell_data *clk_data, - struct device *dev) -{ - int i; - struct clk *clk; - struct regmap *regmap; - - if (!clk_data) - return -ENOMEM; - - regmap = device_node_to_regmap(node); - if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); - return PTR_ERR(regmap); - } - - for (i = 0; i < num; i++) { - const struct mtk_gate *gate = &clks[i]; - - if (!IS_ERR_OR_NULL(clk_data->clks[gate->id])) - continue; - - clk = mtk_clk_register_gate(gate->name, gate->parent_name, - regmap, - gate->regs->set_ofs, - gate->regs->clr_ofs, - gate->regs->sta_ofs, - gate->shift, gate->ops, gate->flags, dev); - - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", gate->name, clk); - continue; - } - - clk_data->clks[gate->id] = clk; - } - - return 0; -} - -int mtk_clk_register_gates(struct device_node *node, - const struct mtk_gate *clks, - int num, struct clk_onecell_data *clk_data) -{ - return mtk_clk_register_gates_with_dev(node, - clks, num, clk_data, NULL); -} -EXPORT_SYMBOL_GPL(mtk_clk_register_gates); - 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 0ff289d93452..bdec7dc5e07a 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -150,31 +150,6 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data); -struct mtk_gate_regs { - u32 sta_ofs; - u32 clr_ofs; - u32 set_ofs; -}; - -struct mtk_gate { - int id; - const char *name; - const char *parent_name; - const struct mtk_gate_regs *regs; - int shift; - const struct clk_ops *ops; - unsigned long flags; -}; - -int mtk_clk_register_gates(struct device_node *node, - const struct mtk_gate *clks, int num, - struct clk_onecell_data *clk_data); - -int mtk_clk_register_gates_with_dev(struct device_node *node, - const struct mtk_gate *clks, - int num, struct clk_onecell_data *clk_data, - struct device *dev); - struct mtk_clk_divider { int id; const char *name; From patchwork Tue Feb 8 12:40:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738606 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 F361AC433F5 for ; Tue, 8 Feb 2022 12:42:29 +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=04pYuIU6TTgGDuPeDGxny87VB9SN9JFjLZOxlCv2BTY=; b=XBgU0l73g+r1bW 8cRBM1N9kEowxsIx1rKi0uTnqW+idcUgo2Albr9M/v5T7lxnNoq+W7J4nsJ06evp7Crnkv92ctbzq FZfLZZIV4YTC4tJ69TG3LlxhoNDZ17ibdhNqk7Zth5eCio0NK/cOfxQu+WvC+T8dOR3qKJ5ThvOHC 9frg37XCBqpFBRMQ6TjpRuEZF1lwiyoqqzwG7qPe6AcCd8GxgTgb6p6W7IWSzn31hOJpp7pIxPVtH lAu6DxkEB89e3cR9KxRBlmb8Pxo58WVygGwDonJLv9pf1naTICnUvWboBLwAlAN+PFX+dQ978Mz+9 FzGYgRg2OdK++W3kimVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPp8-00DnyN-Lb; Tue, 08 Feb 2022 12:42:22 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPnk-00DnI6-Rr for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:40:58 +0000 Received: by mail-pj1-x102e.google.com with SMTP id a11-20020a17090a740b00b001b8b506c42fso2042412pjg.0 for ; Tue, 08 Feb 2022 04:40:56 -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=k5f5ueREUhNKaNea+d6Y8OsMbGygtw5GeTytAmFGzJI=; b=oIsehmLAYwVfNbEk+D3rGN2aZ2qvp+2Ti6TckVMasoOcRO3jVB2kNdazDES4vbc0th abX/gbG0UE40Zdcrbro4yVKD+SwTxElSrv1NvwmY0z5+OXL5EoRC17Pymnlz6LfYYvoO VszG5MkA/u5NfexVYpwOBVgrMTDz0aX8/CKo8= 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=k5f5ueREUhNKaNea+d6Y8OsMbGygtw5GeTytAmFGzJI=; b=ZH+4jLN3t/7axiDtq4uRSQUMii8EC3qADPx1awEAf8aOkRiakUdrisgUljDncmGASQ SXr8YHYZIzb+u46+5lYkUlXaumSmi7Fqau6fLa68VogNcNU2Z3fmoD/APZGCnPXI+Hev vNmRHfYs/MwUi54gpToUSagSf873S6vTkzxVISCOBZg4vAqbCaj2WPq7s+hzlxGuASZd 5MbHIzasggEcrC1eEseP5aNuxpLPYbu1YXNCUUUCuKieTfLSoytp8YIEtwuRwNIPIOn2 d0NYFVrtkFeGY8/DacgUe1T+sQb+SgZbqXpiCLWq3rQWOelM/+BMhogEwNxFrIMoPK7n nB3w== X-Gm-Message-State: AOAM533R58b8mao96pE1kuEhoEDc+1zauUgcaBgzPeaklKJicO3OfIew 7VqbfzuSYiHLyVBPne3LFGyn1w== X-Google-Smtp-Source: ABdhPJxCyZCBP077kL5suUbOgmN6OSfj50effrOlWrM8Ayk5VmMNxB9fDjdTZsR1KKGIm+0Q4DJ3zQ== X-Received: by 2002:a17:902:a603:: with SMTP id u3mr4460583plq.113.1644324055679; Tue, 08 Feb 2022 04:40:55 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:40:55 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 03/31] clk: mediatek: gate: Internalize clk implementation Date: Tue, 8 Feb 2022 20:40:06 +0800 Message-Id: <20220208124034.414635-4-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044056_923126_DD28EC20 X-CRM114-Status: GOOD ( 15.24 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org struct mtk_clk_gate and mtk_clk_register_gate() are not used outside of the gate clk library. Only the API that handles a list of clks is used by the individual platform clk drivers. Internalize the parts that aren't used outside of the implementation. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-gate.c | 35 ++++++++++++++++++++++----------- drivers/clk/mediatek/clk-gate.h | 31 ++--------------------------- 2 files changed, 25 insertions(+), 41 deletions(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c index 54921768bfba..e51cfd8c653c 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -11,11 +11,28 @@ #include #include #include +#include +#include #include #include +#include #include "clk-gate.h" +struct mtk_clk_gate { + struct clk_hw hw; + struct regmap *regmap; + int set_ofs; + int clr_ofs; + int sta_ofs; + u8 bit; +}; + +static inline struct mtk_clk_gate *to_mtk_clk_gate(struct clk_hw *hw) +{ + return container_of(hw, struct mtk_clk_gate, hw); +} + static u32 mtk_get_clockgating(struct clk_hw *hw) { struct mtk_clk_gate *cg = to_mtk_clk_gate(hw); @@ -140,17 +157,12 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = { }; EXPORT_SYMBOL_GPL(mtk_clk_gate_ops_no_setclr_inv); -struct clk *mtk_clk_register_gate( - const char *name, - const char *parent_name, - struct regmap *regmap, - int set_ofs, - int clr_ofs, - int sta_ofs, - u8 bit, - const struct clk_ops *ops, - unsigned long flags, - struct device *dev) +static struct clk *mtk_clk_register_gate(const char *name, + const char *parent_name, + struct regmap *regmap, int set_ofs, + int clr_ofs, int sta_ofs, u8 bit, + const struct clk_ops *ops, + unsigned long flags, struct device *dev) { struct mtk_clk_gate *cg; struct clk *clk; @@ -180,7 +192,6 @@ struct clk *mtk_clk_register_gate( return clk; } -EXPORT_SYMBOL_GPL(mtk_clk_register_gate); int mtk_clk_register_gates_with_dev(struct device_node *node, const struct mtk_gate *clks, int num, diff --git a/drivers/clk/mediatek/clk-gate.h b/drivers/clk/mediatek/clk-gate.h index 432b571d23b3..3d75521ba20c 100644 --- a/drivers/clk/mediatek/clk-gate.h +++ b/drivers/clk/mediatek/clk-gate.h @@ -7,42 +7,15 @@ #ifndef __DRV_CLK_GATE_H #define __DRV_CLK_GATE_H -#include #include - -struct clk; - -struct mtk_clk_gate { - struct clk_hw hw; - struct regmap *regmap; - int set_ofs; - int clr_ofs; - int sta_ofs; - u8 bit; -}; - -static inline struct mtk_clk_gate *to_mtk_clk_gate(struct clk_hw *hw) -{ - return container_of(hw, struct mtk_clk_gate, hw); -} +#include +#include extern const struct clk_ops mtk_clk_gate_ops_setclr; extern const struct clk_ops mtk_clk_gate_ops_setclr_inv; extern const struct clk_ops mtk_clk_gate_ops_no_setclr; extern const struct clk_ops mtk_clk_gate_ops_no_setclr_inv; -struct clk *mtk_clk_register_gate( - const char *name, - const char *parent_name, - struct regmap *regmap, - int set_ofs, - int clr_ofs, - int sta_ofs, - u8 bit, - const struct clk_ops *ops, - unsigned long flags, - struct device *dev); - struct mtk_gate_regs { u32 sta_ofs; u32 clr_ofs; From patchwork Tue Feb 8 12:40:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738607 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 6D76CC433EF for ; Tue, 8 Feb 2022 12:42:31 +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=M8MD2B9MozJDs7Nhnrtb89FH1Zrge3OmuiWe0fCEue4=; b=d6xI4R9dzbnNIw aehKKSJOVGgIc7es/lp3tFLJX//0tVmiEOwMY3pOo71h1+Wc2D+tjQKIj0dh9ghg1XG4kbLJm2VXP 5qDeMIywPmWASKOenCFC4Jc/q7K0H2yQ3Yz8A5LfAEKjUDegd0IoNgguexeTdkG0y/RuiAIY949cy uomAJGWPsGc9zs5a+IEI2j2VW9WOEwToQNjCxPoJup45hHvdPu1hYpJwQKp7fZEnXTkfZ15jiJubK 0huKnwTD5nmg5EyoJ8dc5dmZT5Sf2i8xjvFyubeYj5ReAaO7fu10pPXlBdTtyCsZr73+clivId9gm ReR3DWyMfs/o+/VTEVqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPpA-00Dnz8-56; Tue, 08 Feb 2022 12:42:24 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPnm-00DnJG-Qy for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:00 +0000 Received: by mail-pf1-x431.google.com with SMTP id b3so149527pfg.7 for ; Tue, 08 Feb 2022 04:40:58 -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=pBFx2NNySizl9K48zr+VPwNldMAmerPdyAm7Jk3BRWk=; b=dKOOzV/fLazBCNFOIEnm1JNdL32Rklrc3AbJNCzgIvQQSjUM4aXSr94j4xzxA420JJ D8hO08EooGKH7idQcvWrNue3Isw+YvpvtEimDh2FSFcw7oRHBX0zj8OIb+SVz4BL/Hde g44pgl8RqHpLGee8woAw3B4+pA2cYunOCzqlw= 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=pBFx2NNySizl9K48zr+VPwNldMAmerPdyAm7Jk3BRWk=; b=e2hmd6Hwu7K7TADuiDly1WmIblGzFYXmWHkL2p2w5SqalVl5Sg/RlJG4xv+UNXpO9N LRaIcIq08NzC+XyPQDwOc17noX3lFx8pLcNMLiNFKFHCdtcJqXbQQOrDxb9wfXPLXSz9 1lMDhGXmAzFxTHNUhiJVsug0TDPzLAd7417WdexWaECoDCKBNVTsamtuv8JdEHQ8kTEh gcC92pAoStdt+9lzhD8OxPNJrSTSKKB7qysYO5ft/VDsyz2PTJHZ0TqIZ5D29E885yCN JWbLJ7av2h09pzpIIwnyT86KKErtw9jnSAoC3r+Lek9ABSqefMRWf2C3MLZSEQP+p55y NfRw== X-Gm-Message-State: AOAM530z3cJETjxeLnR0a9+Ju+M5VSlQI7CxD+nxCeXPPFoWe9zRKlgQ 4sXXyw0PfH6DRwKVZ3hJug3cug== X-Google-Smtp-Source: ABdhPJybGo2oMnaPzu5i0PbVYfVuPU0yopXfczB8i1F8jCKZPXGGmiUODMzI2ZCp579316g2u8sY3g== X-Received: by 2002:a63:5460:: with SMTP id e32mr3327867pgm.330.1644324057786; Tue, 08 Feb 2022 04:40:57 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:40:57 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/31] clk: mediatek: gate: Implement unregister API Date: Tue, 8 Feb 2022 20:40:07 +0800 Message-Id: <20220208124034.414635-5-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044058_913712_F555F36C X-CRM114-Status: GOOD ( 14.05 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The gate 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 gate type clk. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-gate.c | 35 +++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-gate.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c index e51cfd8c653c..ed1ad5535d41 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -193,6 +193,21 @@ static struct clk *mtk_clk_register_gate(const char *name, return clk; } +static void mtk_clk_unregister_gate(struct clk *clk) +{ + struct mtk_clk_gate *cg; + struct clk_hw *hw; + + hw = __clk_get_hw(clk); + if (!hw) + return; + + cg = to_mtk_clk_gate(hw); + + clk_unregister(clk); + kfree(cg); +} + int mtk_clk_register_gates_with_dev(struct device_node *node, const struct mtk_gate *clks, int num, struct clk_onecell_data *clk_data, @@ -244,4 +259,24 @@ int mtk_clk_register_gates(struct device_node *node, } EXPORT_SYMBOL_GPL(mtk_clk_register_gates); +void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data) +{ + int i; + + if (!clk_data) + return; + + for (i = num; i > 0; i--) { + const struct mtk_gate *gate = &clks[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[gate->id])) + continue; + + mtk_clk_unregister_gate(clk_data->clks[gate->id]); + clk_data->clks[gate->id] = ERR_PTR(-ENOENT); + } +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_gates); + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-gate.h b/drivers/clk/mediatek/clk-gate.h index 3d75521ba20c..344adffb6578 100644 --- a/drivers/clk/mediatek/clk-gate.h +++ b/drivers/clk/mediatek/clk-gate.h @@ -55,4 +55,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, struct clk_onecell_data *clk_data, struct device *dev); +void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data); + #endif /* __DRV_CLK_GATE_H */ From patchwork Tue Feb 8 12:40:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738608 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 51297C433F5 for ; Tue, 8 Feb 2022 12:42:52 +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=fJx0OCWOfJR+CdaS1g1N1Cgv5GyzSHXqkUAanayC6GI=; b=QnuBvrXJqEkUzB 87xPObGjF0J2QBNN3U4+WRa7gR3iDtLG0bkwg1NJ7CeO+KBqSErwJu8mW7unRa2MahlCq0zjx4s3K ppda+gDxHp7887f/poDSk11JSptbAIuMwOwHJOZyDOnBu312c7vTMBr2a0cj3oYmTyZzR8FtYk6gj spQTn/phNRiC4af2dnhL0Qe0HJrnNstVn4Ri/FGtTaK4f2VSp9+D10INlpS9yYwEG0DPcN6jP+Qi/ pr8W9rnDRRRyRI8mSl+r4YXTjpGWalI6SQZ4Na1dkrmpLJHEKZkOHkMMW2Eczh0pawtD0covycF9I I1uFXvIY6ehVka0ugXBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPpV-00DoCD-9P; Tue, 08 Feb 2022 12:42:45 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPno-00DnKU-DI for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:02 +0000 Received: by mail-pj1-x1032.google.com with SMTP id y9so8503364pjf.1 for ; Tue, 08 Feb 2022 04:41:00 -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=Rg7A4+9l27NSY42Qe+sFkyiXBBTKwVjr3yLAs4KlFxg=; b=mlwzzpOJIyTPenSMBs+vzWOWF4s11a2iKpFwkjBFPNJ2wIbzWSCm8BTUlwqJX+N1Cu DAaDL0V7f8HlDhF8CB7YxNR7wAJCaLZbAsPEdi1EBt+rrzIFaTDaUeoFbcQryratNDJV YBaoXUES6ZVTjN7uqH5rf2Bc0DEByC092aAME= 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=Rg7A4+9l27NSY42Qe+sFkyiXBBTKwVjr3yLAs4KlFxg=; b=rR4nGH+JSsm9B5Vzrm5/EAX81JLA30V/5V1FIMftFIAWFDDg9hNFS93Oj1kbHGZxAI 5QfxtCkc9RlmZeQMldj/a1fH3RyuL+akqckw8/hqDntEvPy9ZrPJ90Imbik/M5pbqzpp Uv56eLjDSHQRLt6FJbR2bRhws8OmgjC7EnjNgN06NjMr5xAl0vChoURwPyOcnUWUGJyt 4kboDQNbJyJXMWVL42B0FNN+l+tSA92YfpgNgBPiMhru2F2ZOwcQn5E/9QiCG2xsdMGu 5ZcGqp+7XXCtvRcXU4BftnXs6mA/3y9qhqCaRosC5ZpBAwa83VjPN69Oi+YhBgjOdU+2 SN2w== X-Gm-Message-State: AOAM530Z7UKdd0gczxljgSp/8ZQ21xUca6kgzSr9rV31l38obe2dqCqy TdYJwB0mhPD22wIZlVneUW3i9g== X-Google-Smtp-Source: ABdhPJwyIYewICHmp67Gv493qjDoHahQ0wtK5N12U7VeDgZpqQE8uKBp4aXA9WxD/jUC6YVuudwbvQ== X-Received: by 2002:a17:90a:7a82:: with SMTP id q2mr1183088pjf.40.1644324059938; Tue, 08 Feb 2022 04:40:59 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:40:59 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/31] clk: mediatek: gate: Clean up included headers Date: Tue, 8 Feb 2022 20:40:08 +0800 Message-Id: <20220208124034.414635-6-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044100_480839_1F736181 X-CRM114-Status: GOOD ( 10.59 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included. Get rid of the unused ones, and add the ones that should be included directly. On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-gate.c | 11 +++-------- drivers/clk/mediatek/clk-gate.h | 10 +++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c index ed1ad5535d41..e8881ae1489a 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -4,18 +4,13 @@ * Author: James Liao */ -#include -#include - -#include -#include -#include -#include #include -#include #include #include +#include #include +#include +#include #include "clk-gate.h" diff --git a/drivers/clk/mediatek/clk-gate.h b/drivers/clk/mediatek/clk-gate.h index 344adffb6578..6b5738826a22 100644 --- a/drivers/clk/mediatek/clk-gate.h +++ b/drivers/clk/mediatek/clk-gate.h @@ -7,9 +7,13 @@ #ifndef __DRV_CLK_GATE_H #define __DRV_CLK_GATE_H -#include -#include -#include +#include + +struct clk; +struct clk_onecell_data; +struct clk_ops; +struct device; +struct device_node; extern const struct clk_ops mtk_clk_gate_ops_setclr; extern const struct clk_ops mtk_clk_gate_ops_setclr_inv; From patchwork Tue Feb 8 12:40:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738619 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 B8219C433EF for ; Tue, 8 Feb 2022 12:43:48 +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=Uzh89BiMbR2aztbGTvwOv8oL68abcvwIClBE2yYRNvM=; b=LLkIV1swrglh8E msYML+FntoPc8RsWp0mT+9BbL4aWIsosmGQbBultjlfd3wi9rIXMHl5S2FiO1Ynsd2IU6xPAVk3fo lOQh3/yeOWjxKgL9FWFQfi5LZ2xMTM+HXlRc6Uz6P3L0oNDuQOb0w+Mu/4VYTjuHvsNof/kR3ajoc u3uc78znv45/5+PojvGe+2vCDFtnyx9gf7ZBAcs/sK+FAZUlSypx9FuiM8pe+YrO4MIK0kE2mtm4e //Qo+q74vgDdK1l6WyQYAFUuR1ae/u/GB69Ug9Bnio7V7m5YPoECZO3fbobEMVr/AoQgkDXBJGzTG Gezv7GgWMqeRSOcZ4X9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPqP-00Dohc-E1; Tue, 08 Feb 2022 12:43:41 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPnr-00DnLT-6f for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:04 +0000 Received: by mail-pl1-x632.google.com with SMTP id j4so1442727plj.8 for ; Tue, 08 Feb 2022 04:41:02 -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=yu5wC4iGlAJptCPwbvLdBvXWnUX/vMCoe837u17t2vE=; b=WYmMFm75NEaKiAQgXHcNywEYl4EfNKMdlnHmbH+Y/S70IQ6WZ9BTZFIM6qXllePpzx VqxfGa3WakmxF3TFYcuEqxxCXNGBaGXzpSF7WpnjK4acriB5IPWJHkzpCdKwAC2iXA2q MpfJH/5jIsHVddh1YI+t3DBLCwl7un6kbnAxA= 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=yu5wC4iGlAJptCPwbvLdBvXWnUX/vMCoe837u17t2vE=; b=UsKzf8P4kGXNR1NfAjFJTFf2rG0tktLlFOGazQkf8JfPxHJIqal/CX3vr4b43UL3FY Fakh4Av7pSkbqQPWt7IS3XQuGgGrQ4OVX2Px/Aj0UPRSKEr3Rmgc1Cp8mvfqdb7uiuY1 QYWyOhHSemsp8t9YQR6WOOW62Q096yCjH4lD8uScUBh2zOmMdGzYSkQac6l/IjeinEh3 TRkbct2yIdmS4Yh4nBBliLtuXIS1HI4kowhmQQna35LjBkOw4IbbOlnG3JYOXUZ3RFoE 9XxE4BnS0mwpsm+Wi97jOW12USXQcTW9opeZRpOXBPHGDklM4Zl0XTXH8zxKX31U69Hg Hm6A== X-Gm-Message-State: AOAM531hUBrY0e07uOQ7UBvO/Osc9YW9XaHEwhKbDYAOwtXZiAGuVjjd rYQjgJ1hJvayCXiFPhegy482wg== X-Google-Smtp-Source: ABdhPJzUeRlYjgcD/Tizn2yiqNMWwskxr1QbMAtRHQShttT8ptqsm5WTOeTXEuEiu4TrR1RbEMFh/Q== X-Received: by 2002:a17:902:6b8c:: with SMTP id p12mr4434188plk.51.1644324062033; Tue, 08 Feb 2022 04:41:02 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:01 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 06/31] clk: mediatek: cpumux: Implement unregister API Date: Tue, 8 Feb 2022 20:40:09 +0800 Message-Id: <20220208124034.414635-7-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044103_257681_B3A755D1 X-CRM114-Status: GOOD ( 13.11 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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 Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- 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 */ From patchwork Tue Feb 8 12:40:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738620 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 490F6C433EF for ; Tue, 8 Feb 2022 12:43:56 +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=XB2G0tfPHMxkGR7DgLKC1EysQss+Qv1LVfQ05+ayLjk=; b=3t7ieA8x7RELpV mm1Ksy/Avczf/ZKvIa3NQToZ5i5gkMd9mZw0/fAmPZKPhBozfaAU80+4Atv6G5iY+Jj+S2JOz46en xdy7Wy8kDdqbX4fUGdCwUVkox40Ndl9RhOq1Fv2Babsnhya6C2kGli6Cw//mwU95IMN/siHc3N6Qh t6PA2Rg/hCFOIDpjrVNzEQv58IFtvyunyxIh4MSU3WooqKF/IYjXCZhRaa0XhkeM4UBAE1xe/7tlS /L/Hg5QvRPfxlQe+KvZYiUsoo5y7n7x5MwK9aNo94qU4hn+syk6VcRaMU0T49R195pURvNNpj6rP5 0ngJdIuY83L4GI3rx7ig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPqV-00DolP-JR; Tue, 08 Feb 2022 12:43:47 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPnt-00DnMW-8W for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:06 +0000 Received: by mail-pj1-x102b.google.com with SMTP id v4so10209500pjh.2 for ; Tue, 08 Feb 2022 04:41:04 -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=iNXCz8EKk1VR4agv1nk/pR4RM+PZmf+e9yRG2bvKFuM=; b=FaLgS8JBXSx2rVQXT64+Rqa2xv8iXnhXcaxplMpKSmYnFH93Ujylq6y4Cl6nyd/sAH WQfwAS1n/fUwhgBYIe1KmVkTBNXyXUHhRiExOGRjWRVg/4G87sHy17Rcuz1/8y4EO++T 6VK2V+jUdpukhI1bpN+MT9dUVWszTMuJ5z9NM= 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=iNXCz8EKk1VR4agv1nk/pR4RM+PZmf+e9yRG2bvKFuM=; b=vIPC12kVboPEziGTeOmtAZh9cKDKBlLAhcEkCe6Tzlivrknhi0rddjY0Vit83tE1NM lDR1jDYQoCAK0C6NQ6zifIPEcU0abGiSrg27n5v81minBavPehKDSD6HEwaqybMgmO4u BwvRacYsC9Y/xDw3oBIKpoUfGE+/YBgZMbbue2pHH4t3jmLkIWPcmJjwog9e+H3RGpu6 kDmPkorRIs+xSNRkRIANEhLix7cyQNabjIsAGHaPbSznIm6o01MeAlOTf9kOoXtt9RjG eeCNF+jD7cMRUREsu4WLqKPVuyhsl54E46633VdwRqn/x26ysLFrjNoGvFoLckTGGiQA AA8g== X-Gm-Message-State: AOAM531ztlWHPbxbbCP7ayi9QCI+4sXi3ewjZnbo8z2YJIDkJOWBOPsL ZL76UISvmoDLrAjRJgBNbrwgpg== X-Google-Smtp-Source: ABdhPJxCsDQjhQfSgwvXF6h1UuMsst6PTHnyW2BLFIfU9v0XAu5TwkzHqYQzzLVcalU0yaSD5TQ4Og== X-Received: by 2002:a17:902:f651:: with SMTP id m17mr4251259plg.106.1644324064142; Tue, 08 Feb 2022 04:41:04 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:03 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 07/31] clk: mediatek: cpumux: Internalize struct mtk_clk_cpumux Date: Tue, 8 Feb 2022 20:40:10 +0800 Message-Id: <20220208124034.414635-8-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044105_355616_F3177331 X-CRM114-Status: GOOD ( 12.02 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org struct mtk_clk_cpumux is an implementation detail of the cpumux clk type, and is not used outside of the implementation. Internalize the definition to minimize leakage of details and shrink the header file. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-cpumux.c | 8 ++++++++ drivers/clk/mediatek/clk-cpumux.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.c index 99a819e3673f..344c6399b22f 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -12,6 +12,14 @@ #include "clk-mtk.h" #include "clk-cpumux.h" +struct mtk_clk_cpumux { + struct clk_hw hw; + struct regmap *regmap; + u32 reg; + u32 mask; + u8 shift; +}; + static inline struct mtk_clk_cpumux *to_mtk_clk_cpumux(struct clk_hw *_hw) { return container_of(_hw, struct mtk_clk_cpumux, hw); diff --git a/drivers/clk/mediatek/clk-cpumux.h b/drivers/clk/mediatek/clk-cpumux.h index fda7770fd803..a538f2bbef0d 100644 --- a/drivers/clk/mediatek/clk-cpumux.h +++ b/drivers/clk/mediatek/clk-cpumux.h @@ -7,14 +7,6 @@ #ifndef __DRV_CLK_CPUMUX_H #define __DRV_CLK_CPUMUX_H -struct mtk_clk_cpumux { - struct clk_hw hw; - struct regmap *regmap; - u32 reg; - u32 mask; - u8 shift; -}; - int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data); From patchwork Tue Feb 8 12:40:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738621 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 6F8EAC433F5 for ; Tue, 8 Feb 2022 12:44:23 +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=eILmAINe7Hvyua7TM3We+/2dC+SHttAFCGH9hIcXUFQ=; b=pW/fgXLIgHBivt cXtrUVHt+w0tLP6AdlEyPun2hmFgZo0H3Cg+zX8Qq9Eoln+J6TakUi/pwb1HWqh6jhQ8XR4HWk52+ n6JZ4D/zXN2q9W+UYk2Jv2eMyNyAaP6DrSVXW65CvmMIS+iEE9cTYoFxt5zE2zdVrujnvUJoNTOfJ p6kAwlp7A6Clk9Krq5gpnhBRCG65gtW+e0clbd1d/jlVFUAo0oissynaxybnEjxZ24/pl6dAMPMNc DCx1F8HNuW7wxY6lD0689PeT7fnMch+7FQQQB0TcdPIH4zTiybqFCKO1wGCF01MSRqwfaip1e0A+d LMwW5zYsyr7+E8dp0irQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPqx-00Dp1u-M1; Tue, 08 Feb 2022 12:44:15 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPnu-00DnNP-Nq for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:08 +0000 Received: by mail-pf1-x431.google.com with SMTP id x65so4130875pfx.12 for ; Tue, 08 Feb 2022 04:41:06 -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=3RinXQyHKb00TzypPmHwtAZLN3N95NjRwsCDNBAlwr4=; b=YZFeequlV6N1Zm6zx7AjhJ88s7J6s6lm6hq4eZItcgFo8pOMuTMvZ3hzVnj93mM/dX wFnDMu6mWWqvp29XUfzBr/4uMQmuOz5VTOtSzqPo+a2U6tTImCdnPb+fMYPH/Zv/Jw9S 1JOy9pLaEPyxVRAAQJ5IQs+EJiibHDKam75NU= 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=3RinXQyHKb00TzypPmHwtAZLN3N95NjRwsCDNBAlwr4=; b=cTUVl9zp4lh8ez15+u+qHyZiCU8D+vabPdkYmnVuUXYIc2Xj8TnO3KLXehfAA53yVc 1xBHh9/UICr/6kBPDZwpBo3f0JjNgd75Uuvzbj3h4MWU31x0efk6EECW2BqaaL1Xk7/g JqXdaE2FbUfuo2DoPIzZTGNVKTIEPi51KQKhX55cerxQwyomaZI2+tJUqFxADURolkvi 84zUXR+/LWEJHfP2y4zbLIqoUzvvgz8Mn7CmTVYKGZC4K3q0rqvjgOWNx/4RONHSzE6M GV2+RZc5p1xDwQrPMByZ0jgmuLmUqnetMAWfsqp7bHg3c5hvqV/vdLCEJW7ympH1vATW MN1g== X-Gm-Message-State: AOAM533B7DmDaqb5+BAHtTsqsBmhry/mIa2FDaLnp/NaGt2GcfCCe2Mk JQfNpXDIwPjrx1Za/IkJOe2xQA== X-Google-Smtp-Source: ABdhPJyVR6nI8dkkBw1DN8QU+KXFRS3jfBjQoqHIXzT0wpt+HFO/COZLgDxQ8jisVm0UKOLWRVS5qA== X-Received: by 2002:a05:6a00:d72:: with SMTP id n50mr4229384pfv.51.1644324066273; Tue, 08 Feb 2022 04:41:06 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:06 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 08/31] clk: mediatek: cpumux: Clean up included headers Date: Tue, 8 Feb 2022 20:40:11 +0800 Message-Id: <20220208124034.414635-9-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044106_821565_D546010A X-CRM114-Status: GOOD ( 10.56 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Some headers with the declaration of functions and structures aren't directly included. Explicitly include them so that future changes to other headers would not result in an unexpected build break. On the header side, add forward declarations for any data structures whose pointers are used in function signatures. No headers are required. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-cpumux.c | 3 +++ drivers/clk/mediatek/clk-cpumux.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.c index 344c6399b22f..658aee789f44 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -5,8 +5,11 @@ */ #include +#include +#include #include #include +#include #include #include "clk-mtk.h" diff --git a/drivers/clk/mediatek/clk-cpumux.h b/drivers/clk/mediatek/clk-cpumux.h index a538f2bbef0d..b07e89f7c283 100644 --- a/drivers/clk/mediatek/clk-cpumux.h +++ b/drivers/clk/mediatek/clk-cpumux.h @@ -7,6 +7,10 @@ #ifndef __DRV_CLK_CPUMUX_H #define __DRV_CLK_CPUMUX_H +struct clk_onecell_data; +struct device_node; +struct mtk_composite; + int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data); From patchwork Tue Feb 8 12:40:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738622 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 88E75C433F5 for ; Tue, 8 Feb 2022 12:45:11 +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=wGoUUskrlorpG13wDnJ3zvD/4hRa1Ak2ZgaR6hEF+6I=; b=Hedhq2Wq2Rz9sc 0nvfz7fO9nQXqtHbFNfcWwP33uwbLLUhj+5tiXlsKKkFMkOO0OLzXDZvicgCZBz6D75fo/FeakaO+ 5SnQiBazw18e/9gvBrPMxHsGLrXZVtMKFRtVXpq6BJ1zgcc5cpsWhh0l8RICD+fj21louSLvENvAt P7oVU0LxeCRdwnsOBPgPMIfPN3s5+b38weEq4QQ6t2LYPWuOEd4GRv4awBDCkSFc3hsLjbMoO4439 IoROVL5hr8GXexQDzaCBbEsWzFIDByllUqQt6c9aNkXc8JCJrTCdOI6a9PFMgxfcdWAefXRlURUI8 W4n4XZSDokRw1f7EAa4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPrk-00DpST-B9; Tue, 08 Feb 2022 12:45:04 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPnx-00DnOs-Iw for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:11 +0000 Received: by mail-pf1-x429.google.com with SMTP id r19so2894725pfh.6 for ; Tue, 08 Feb 2022 04:41:08 -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=6xS+neFrZyvEZNRNB9ZEba3UAvEdbGsDMRKP0HcrjcY=; b=S07qFfLfXlPlsPEig0kql0KSa3Jwo8SnBQAniFpfSEt9bWaC7EuaBBykud2oDeT8G6 bWdAShALpo3BV05Wa4VxHyeKeKxQDfw48INJq9ihtQsnkh9uY8EGClLBviYeRIMV/hcK c/Wk9uji3P9bOqNUWYUwA/ukYeig7GR8nG0Fc= 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=6xS+neFrZyvEZNRNB9ZEba3UAvEdbGsDMRKP0HcrjcY=; b=iPIIxRaGTz8GBvGvQpArvGVqM6oIXv73U3oKjrvcqFNQ4JySbZF95lhLSMOoQ7ufV2 JZfg7IK0ZupiRAXDPjzgP3N0M6qKWPLDykGyCKhv+hfWurfwOHw3v3W17P5JsbmfMa5e TDVJqFllquIN9d+WWaee6/Y/gpniU+if9Uqc8BGtBtzi1Jet+xUDIL/Gg3JaULi92USM A9K/BocYr9vNsErNmgHqTi7cMbl7MercxySUhwtFz16pQWD+9tJbFMuVTzWLKbUC6vi6 m17E52c1UPOUkVtgG/ATAzsAIUhsr5ER1/AvHToAaEFjZ8SCgBG+TsxwXf21ZptfTcTR cY2Q== X-Gm-Message-State: AOAM532FGzNxwPAuRoy5a3oh5T3cmWzKXkNUYW4vCCNlwwsGbuFkwk4r izkak1zwfu9ebBjGiWpktU/Hdw== X-Google-Smtp-Source: ABdhPJyVSydPTJsnGkAvXxmo8hgAw+u0iFkTHDeyOosu8dCP1EYmO/Ag1a/kFhiD/Fw6iflEFWaCjg== X-Received: by 2002:a63:5144:: with SMTP id r4mr3338517pgl.382.1644324068384; Tue, 08 Feb 2022 04:41:08 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:08 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/31] clk: mediatek: mux: Implement unregister API Date: Tue, 8 Feb 2022 20:40:12 +0800 Message-Id: <20220208124034.414635-10-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044109_664912_398D95ED X-CRM114-Status: GOOD ( 13.65 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The mux 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 mux type clk. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mux.c | 35 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mux.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 89f23e111d91..6f0c22a699c3 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -164,6 +164,21 @@ static struct clk *mtk_clk_register_mux(const struct mtk_mux *mux, return clk; } +static void mtk_clk_unregister_mux(struct clk *clk) +{ + struct mtk_clk_mux *mux; + struct clk_hw *hw; + + hw = __clk_get_hw(clk); + if (!hw) + return; + + mux = to_mtk_clk_mux(hw); + + clk_unregister(clk); + kfree(mux); +} + int mtk_clk_register_muxes(const struct mtk_mux *muxes, int num, struct device_node *node, spinlock_t *lock, @@ -198,4 +213,24 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, } EXPORT_SYMBOL_GPL(mtk_clk_register_muxes); +void mtk_clk_unregister_muxes(const struct mtk_mux *muxes, int num, + struct clk_onecell_data *clk_data) +{ + int i; + + if (!clk_data) + return; + + for (i = num; i > 0; i--) { + const struct mtk_mux *mux = &muxes[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) + continue; + + mtk_clk_unregister_mux(clk_data->clks[mux->id]); + clk_data->clks[mux->id] = ERR_PTR(-ENOENT); + } +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_muxes); + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h index 27841d649118..cb2ac4f04c58 100644 --- a/drivers/clk/mediatek/clk-mux.h +++ b/drivers/clk/mediatek/clk-mux.h @@ -88,4 +88,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, spinlock_t *lock, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_muxes(const struct mtk_mux *muxes, int num, + struct clk_onecell_data *clk_data); + #endif /* __DRV_CLK_MTK_MUX_H */ From patchwork Tue Feb 8 12:40:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738623 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 C4DE9C433F5 for ; Tue, 8 Feb 2022 12:45:13 +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=zZ1RVn3GgYiCE7vPaSGdedMMGjH0le6RJluIk9e3kUQ=; b=RQl5O2H3oh6Mg1 EtzSk75djgjUQNNQ5OLYec5cR79E0aQ1WF81uuSpBMkeu8hOZtCEFvd/DOq+ZpIh3krINSYlLFGEI 8m+R6DmicZ8Urkio3acUVB49zUxvjcXkzwGNlD9q3xeDAi4bs/mcvZBe95Fcob5yoDIwh7CXth47F wnPaNKUcJkCEx+ZFZohfagZmVRVUoqajTGEHxXseB931DBPa7gExAc5ETfkDB7WWsRsXo1OtD7l7W YHRSjyfUQPS8Idw+MX1LDAJqkgZIDSTgRstTaHIEQ29jpRmhZRvSOx5RFRInB+gBm06VPu+zvhilL z0mfJdUixA4+Hrfpa1nA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPrl-00DpTI-RI; Tue, 08 Feb 2022 12:45:05 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPnz-00DnPm-4Y for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:12 +0000 Received: by mail-pf1-x431.google.com with SMTP id e28so18649222pfj.5 for ; Tue, 08 Feb 2022 04:41:11 -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=QqCKqTMNdoAp7+sGE2nBPkF6G+PqsK55lVYsLHkGo/c=; b=ldnpoFu3DD5eloRyku85uykx5dM7xP/9mliT08SVLlpMajfgHSGH62rCzJ7c2wiNU9 tLL99iJhWybm+mEdugFj5TJyCm7plg0oChYxRHmaGsrtcDKb/ToB6sgRmlJ5IYoL4AiX +T3px2SJjDdQxkj9GahSUkyDg6YawanCTC39Q= 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=QqCKqTMNdoAp7+sGE2nBPkF6G+PqsK55lVYsLHkGo/c=; b=MQV2pY8cLzZwRZItDMOM3nCgjPaRcCt4ORGRIcKw9mMdCEY/I9YT+t54zEzl1WN0eJ yeL7e2Ir6odiAOI/ACrqI0c23zTEEpG6jnFKyKgb47pwV2mGpVXS9hwQIWAVg07k1Zmr 7tz9IvRNgaWG9/m8Xm1wX16Msdx7E5vgpJ3o9xyrrkKG2SVMR2SFKOkrhgyh/lI216Bl Dck/uzj7yUJk5BHdei0ZZb3cSsPYZnjQhdevsCj+aTi+iojzvXtPuQNxijTkDYmXKwR8 9ghuJxKlBqheCw2z6uH9zUqEyAfPHkcj4x7uIXE6Pzzrzm2pLMqjmf1915SnN5zadP1C g4Dg== X-Gm-Message-State: AOAM53209/sX4rLwLdjLXhGZcDIgro3grzYVFlPNWPPIeBx9tZzAEJvU tWL/6hOSozNGCh6CMUtxgF2CPw== X-Google-Smtp-Source: ABdhPJxWcJrY0ZpPqfzhQI+lhqCGqXjIUU+JarLsOFyR0SfIZyB4euS/X0UN+worLnBp2w2IQ1isSg== X-Received: by 2002:a05:6a00:2283:: with SMTP id f3mr4248506pfe.24.1644324070536; Tue, 08 Feb 2022 04:41:10 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:10 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/31] clk: mediatek: mux: Internalize struct mtk_clk_mux Date: Tue, 8 Feb 2022 20:40:13 +0800 Message-Id: <20220208124034.414635-11-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044111_217857_F80954C9 X-CRM114-Status: GOOD ( 12.56 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org struct mtk_clk_mux is an implementation detail of the mux clk type, and is not used outside of the implementation. Internalize the definition to minimize leakage of details and shrink the header file. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mux.c | 8 ++++++++ drivers/clk/mediatek/clk-mux.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 6f0c22a699c3..2d4d8dc0120a 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -13,6 +13,14 @@ #include "clk-mtk.h" #include "clk-mux.h" +struct mtk_clk_mux { + struct clk_hw hw; + struct regmap *regmap; + const struct mtk_mux *data; + spinlock_t *lock; + bool reparent; +}; + static inline struct mtk_clk_mux *to_mtk_clk_mux(struct clk_hw *hw) { return container_of(hw, struct mtk_clk_mux, hw); diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h index cb2ac4f04c58..38a2b6014b08 100644 --- a/drivers/clk/mediatek/clk-mux.h +++ b/drivers/clk/mediatek/clk-mux.h @@ -9,14 +9,6 @@ #include -struct mtk_clk_mux { - struct clk_hw hw; - struct regmap *regmap; - const struct mtk_mux *data; - spinlock_t *lock; - bool reparent; -}; - struct mtk_mux { int id; const char *name; From patchwork Tue Feb 8 12:40:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738624 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 22D92C433F5 for ; Tue, 8 Feb 2022 12:45:48 +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=WjeqvbxZimYk89OvxODLCWwcyPpI2suCS9QOzJcTMhA=; b=Npqc2qkZrb7Ikd ebup+BGK4ByoMFS1v3/sOuG+RG5udAK0pBYQB/6KhT5w09zCu69YYzzWqiH0/p0pyh0qXGGqnW4Q8 1sdlRY9tSPixVGXnQH4LcXjSbpXyH2we4mNgFoaivfm87YwblB4IWu4tZM2EjUEfUg0EYpjeSir2B eu5VtBGXr5r6GatOHb1JLeP15R+pYc9K7mkynTS2pZ3YP4SbeMPmB1Za0+KPFO4OahlHA+OQvGCKP 9PsZOE9ddAOczYB85n+qPA6PRC6nuibxOBCT50tnskSMWLYpvbn3PnTn+Y+5hmJGfX9huIftdOOoe 5dQUkFPPU5h1n36uGLwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPsK-00DplT-3Z; Tue, 08 Feb 2022 12:45:40 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPo1-00DnQr-5g for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:14 +0000 Received: by mail-pf1-x42d.google.com with SMTP id b3so150594pfg.7 for ; Tue, 08 Feb 2022 04:41:13 -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=1TZM8PREBca7FhBIqkK5TTjacax9psRQ+lcxgoGzOac=; b=IZq5kTRtSIhS2WplXP6OWmMM9gugZL0etNS2hOiiAKeUTokmQNLVM3QCZUd+xo6w1b vRhhg+kgnMMqqvJQ3MJg3SeG7GhOho2JnIxPw15s1+uVDvVltw9+xVruBsV1ATn3GY8M 8TFoRv3HgNjLs4CFru8cGPXiRQzotHrFeftDw= 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=1TZM8PREBca7FhBIqkK5TTjacax9psRQ+lcxgoGzOac=; b=KQgRITmXHcHWuS0COjMq3jDqNOMndcgHeR9DAPVFJUAzoH57OSLyR8QiHLNezKg6/+ pYAfmRLZgV2q5NMOap5TgRulxB3Qyl9ifl3NF14pA07eQm5jOk7Omdmwkr2bt03cmYXT nqcMDM33DCguMYd9kU2DbIWs4axrLtUw8WDluEEu3aiZC/filrzvMpu6oa4xrI1Gsx5R uITsVGmN6aMHxPOalSAQeaH/P36C5mKYsBLP+OUc8dZGspKYSV7txh8UpdeT68mXum1j /QJ16oP8/UeYSyOgrxi1WnFxfs4aSLTnCOEnSyVbEWcIvhfjMN/UnvVCKe9goy0o64RL Kb/A== X-Gm-Message-State: AOAM5306u/PbqVFxk/woJSZy+cXLaYhIqTZOCJngqXEGUEsDHHgou2bv uUOcS2CczprJ22tS9GtvqrOiFg== X-Google-Smtp-Source: ABdhPJzGbRmwB7Ijypv5ad/Be1a0AHal20/jqqhu5PrT8YWb6VHkulJZxUxHpXwmHTgsZ58Jrbt7Ow== X-Received: by 2002:aa7:94a9:: with SMTP id a9mr4258241pfl.78.1644324072723; Tue, 08 Feb 2022 04:41:12 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:12 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 11/31] clk: mediatek: mux: Clean up included headers Date: Tue, 8 Feb 2022 20:40:14 +0800 Message-Id: <20220208124034.414635-12-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044113_256441_242461B0 X-CRM114-Status: GOOD ( 11.02 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included. Get rid of the unused ones, and add the ones that should be included directly. On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mux.c | 11 +++++++---- drivers/clk/mediatek/clk-mux.h | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 2d4d8dc0120a..01af6a52711a 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -4,13 +4,16 @@ * Author: Owen Chen */ -#include -#include -#include +#include +#include +#include +#include #include #include +#include +#include +#include -#include "clk-mtk.h" #include "clk-mux.h" struct mtk_clk_mux { diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h index 38a2b6014b08..903a3c937959 100644 --- a/drivers/clk/mediatek/clk-mux.h +++ b/drivers/clk/mediatek/clk-mux.h @@ -7,7 +7,13 @@ #ifndef __DRV_CLK_MTK_MUX_H #define __DRV_CLK_MTK_MUX_H -#include +#include +#include + +struct clk; +struct clk_onecell_data; +struct clk_ops; +struct device_node; struct mtk_mux { int id; From patchwork Tue Feb 8 12:40:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738625 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 647E0C433F5 for ; Tue, 8 Feb 2022 12:46:51 +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=hepZro3IIxjZNR8jS1+pWOt7F/MHERWGuzGK47UN/QM=; b=F/WjJX+toXJNNy F8ZRrWVeErvDh8F8OAe0vMtvQfh+2wnpQJUc2DYF3By1A7XMhPlbjHBNmVusqczwVn3QfPAjfu+AU Aeme8/xO3LeH/FCdgeQ4zZsvy+YCH3CAQf53ujw17D54tSU0LtUbjQKd1qA+gaS4ms0H3pOwifrq0 +Un+22STRaPERq+KOjPXv3AZON96A0NwQAVlZP3Td8m0M2l+U4xJUaQcbXlCGiLr07tuGIlf/RN6S ZFvxhAK8t6h+K2ZjUt3ZKQU6fOEHlMwIAt9Ca8DkAA17C1ZKGy1eNucxOwT5KdslvCf6U+i1sqYon gU7mcOqNbp45dMCJj9eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPtJ-00DqGn-Sk; Tue, 08 Feb 2022 12:46:41 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPo4-00DnS2-9V for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:18 +0000 Received: by mail-pf1-x42f.google.com with SMTP id n32so18629802pfv.11 for ; Tue, 08 Feb 2022 04:41:15 -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=LMw2k5UL8LR4Yb0p4V2esvN2YQJYQMBshCfNffwFElc=; b=RW+Im4XH206lOo5th9VGiQEIeV+PbWZ5ic2PSd8cSmBZc4quR45Gh8FHJqhmvonPUZ YIehMR9jehOA7NvUr2WiVSYv5ilJ7JJ6eNaNQhw6/qYMUhm2e/O6ikPGUdo/Ng7Yy0qv g4x8LqfFWBODQTOtGaO4xUdufku13OmZgfkpg= 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=LMw2k5UL8LR4Yb0p4V2esvN2YQJYQMBshCfNffwFElc=; b=dRN/MvuYIO50t3uV6hdrPd9rRY/Iu+UHdf4Fjd1rTDnLr5kIDMZsYjlWnwETGo5Ykn RXOQH3/5kqMhu1sKVEa66AD6Y6Mg2Kx5MLsTQ5dM/mIeJ6nc19FT+pH+Mj8s0yd6gHpy qiQGWVNYOU1rVofNTqU3DqklXyI5bk1hatqNebhdyKFSNHvtrsPjM4YhvqvlaIS1+HTj d/q436bOrGqgjwyjfr2x1wQ0bb+OJxL3zpcDbrA0WpPD5rXO2tzy4mH89AMzOYXtT5O6 2c2TCCc4i8mVfvix0dDacE/5aKBGtpB8iDmwEB4Bhguyok8XMys1pkCfHtLwX4YzC5Ij tv3w== X-Gm-Message-State: AOAM531bRmTvrLxMdffIW6dSdsh23RN9D7HvLvpGpHyfxjx5xzsezQSz WtBuPgepDQ51Yv5u59ke0E7qNIz7lWFW3g== X-Google-Smtp-Source: ABdhPJxcS5+wNjDql0VH3YNNeL+bx6Mi47AbAGMX3vY3EFJgHPv7nFPDM8isNHojI01M5XiUpzXapg== X-Received: by 2002:a62:e409:: with SMTP id r9mr4330573pfh.44.1644324074868; Tue, 08 Feb 2022 04:41:14 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:14 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 12/31] clk: mediatek: pll: Split definitions into separate header file Date: Tue, 8 Feb 2022 20:40:15 +0800 Message-Id: <20220208124034.414635-13-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044116_366619_9CA4B4E0 X-CRM114-Status: GOOD ( 19.20 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org When the PLL type clk was implemented in the MediaTek clk driver library, the data structure definitions and function declaration were put in the common header file. Since it is its own type of clk, and not all platform clk drivers utilize it, having the definitions in the common header results in wasted cycles during compilation. Split out the related definitions and declarations into its own header file, and include that only in the platform clk drivers that need it. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mt2701.c | 5 +- drivers/clk/mediatek/clk-mt2712.c | 3 +- drivers/clk/mediatek/clk-mt6765.c | 3 +- drivers/clk/mediatek/clk-mt6779.c | 3 +- drivers/clk/mediatek/clk-mt6797.c | 3 +- drivers/clk/mediatek/clk-mt7622.c | 5 +- drivers/clk/mediatek/clk-mt7629.c | 5 +- drivers/clk/mediatek/clk-mt7986-apmixed.c | 4 +- drivers/clk/mediatek/clk-mt8135.c | 3 +- drivers/clk/mediatek/clk-mt8167.c | 3 +- drivers/clk/mediatek/clk-mt8173.c | 5 +- drivers/clk/mediatek/clk-mt8183.c | 3 +- drivers/clk/mediatek/clk-mt8192.c | 3 +- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 1 + drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 1 + drivers/clk/mediatek/clk-mt8516.c | 3 +- drivers/clk/mediatek/clk-mtk.h | 39 -------------- drivers/clk/mediatek/clk-pll.c | 1 + drivers/clk/mediatek/clk-pll.h | 55 ++++++++++++++++++++ 19 files changed, 91 insertions(+), 57 deletions(-) create mode 100644 drivers/clk/mediatek/clk-pll.h diff --git a/drivers/clk/mediatek/clk-mt2701.c b/drivers/clk/mediatek/clk-mt2701.c index 695be0f77427..1eb3e4563c3f 100644 --- a/drivers/clk/mediatek/clk-mt2701.c +++ b/drivers/clk/mediatek/clk-mt2701.c @@ -10,9 +10,10 @@ #include #include -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mt2712.c b/drivers/clk/mediatek/clk-mt2712.c index a3bd9a107209..ff72b9ab945b 100644 --- a/drivers/clk/mediatek/clk-mt2712.c +++ b/drivers/clk/mediatek/clk-mt2712.c @@ -13,8 +13,9 @@ #include #include -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-pll.h" +#include "clk-mtk.h" #include diff --git a/drivers/clk/mediatek/clk-mt6765.c b/drivers/clk/mediatek/clk-mt6765.c index d77ea5aff292..24829ca3bd1f 100644 --- a/drivers/clk/mediatek/clk-mt6765.c +++ b/drivers/clk/mediatek/clk-mt6765.c @@ -12,9 +12,10 @@ #include #include -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" #include "clk-mux.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mt6779.c b/drivers/clk/mediatek/clk-mt6779.c index 9825385c9f94..7b61664da18f 100644 --- a/drivers/clk/mediatek/clk-mt6779.c +++ b/drivers/clk/mediatek/clk-mt6779.c @@ -10,9 +10,10 @@ #include #include +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mt6797.c b/drivers/clk/mediatek/clk-mt6797.c index 428eb24ffec5..02259e81625a 100644 --- a/drivers/clk/mediatek/clk-mt6797.c +++ b/drivers/clk/mediatek/clk-mt6797.c @@ -9,8 +9,9 @@ #include #include -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-mt7622.c index ef5947e15c75..0e1fb30a1e98 100644 --- a/drivers/clk/mediatek/clk-mt7622.c +++ b/drivers/clk/mediatek/clk-mt7622.c @@ -11,9 +11,10 @@ #include #include -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include #include /* for consumer */ diff --git a/drivers/clk/mediatek/clk-mt7629.c b/drivers/clk/mediatek/clk-mt7629.c index a0ee079670c7..c0e023bf31eb 100644 --- a/drivers/clk/mediatek/clk-mt7629.c +++ b/drivers/clk/mediatek/clk-mt7629.c @@ -12,9 +12,10 @@ #include #include -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mt7986-apmixed.c b/drivers/clk/mediatek/clk-mt7986-apmixed.c index 98ec3887585f..21d4c82e782a 100644 --- a/drivers/clk/mediatek/clk-mt7986-apmixed.c +++ b/drivers/clk/mediatek/clk-mt7986-apmixed.c @@ -10,9 +10,11 @@ #include #include #include -#include "clk-mtk.h" + #include "clk-gate.h" +#include "clk-mtk.h" #include "clk-mux.h" +#include "clk-pll.h" #include #include diff --git a/drivers/clk/mediatek/clk-mt8135.c b/drivers/clk/mediatek/clk-mt8135.c index 9b4b645aea99..09ad272d51f1 100644 --- a/drivers/clk/mediatek/clk-mt8135.c +++ b/drivers/clk/mediatek/clk-mt8135.c @@ -11,8 +11,9 @@ #include #include -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" static DEFINE_SPINLOCK(mt8135_clk_lock); diff --git a/drivers/clk/mediatek/clk-mt8167.c b/drivers/clk/mediatek/clk-mt8167.c index e5ea10e31799..812b33a57530 100644 --- a/drivers/clk/mediatek/clk-mt8167.c +++ b/drivers/clk/mediatek/clk-mt8167.c @@ -12,8 +12,9 @@ #include #include -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mt8173.c b/drivers/clk/mediatek/clk-mt8173.c index 8f898ac476c0..46b7655feeaa 100644 --- a/drivers/clk/mediatek/clk-mt8173.c +++ b/drivers/clk/mediatek/clk-mt8173.c @@ -8,9 +8,10 @@ #include #include -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mt8183.c b/drivers/clk/mediatek/clk-mt8183.c index 5046852eb0fd..68496554dd3d 100644 --- a/drivers/clk/mediatek/clk-mt8183.c +++ b/drivers/clk/mediatek/clk-mt8183.c @@ -11,9 +11,10 @@ #include #include +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mt8192.c b/drivers/clk/mediatek/clk-mt8192.c index 79ddb3cc0b98..ab27cd66b866 100644 --- a/drivers/clk/mediatek/clk-mt8192.c +++ b/drivers/clk/mediatek/clk-mt8192.c @@ -12,9 +12,10 @@ #include #include +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c index 6156ceeed71e..5b1b7dc447eb 100644 --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c @@ -5,6 +5,7 @@ #include "clk-gate.h" #include "clk-mtk.h" +#include "clk-pll.h" #include #include diff --git a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c b/drivers/clk/mediatek/clk-mt8195-apusys_pll.c index f1c84186346e..db449ff877d7 100644 --- a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c +++ b/drivers/clk/mediatek/clk-mt8195-apusys_pll.c @@ -4,6 +4,7 @@ // Author: Chun-Jie Chen #include "clk-mtk.h" +#include "clk-pll.h" #include #include diff --git a/drivers/clk/mediatek/clk-mt8516.c b/drivers/clk/mediatek/clk-mt8516.c index 9d4261ecc760..a37143f920ce 100644 --- a/drivers/clk/mediatek/clk-mt8516.c +++ b/drivers/clk/mediatek/clk-mt8516.c @@ -11,8 +11,9 @@ #include #include -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index bdec7dc5e07a..168220f85489 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -179,45 +179,6 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num); void mtk_free_clk_data(struct clk_onecell_data *clk_data); -#define HAVE_RST_BAR BIT(0) -#define PLL_AO BIT(1) - -struct mtk_pll_div_table { - u32 div; - unsigned long freq; -}; - -struct mtk_pll_data { - int id; - const char *name; - u32 reg; - u32 pwr_reg; - u32 en_mask; - u32 pd_reg; - u32 tuner_reg; - u32 tuner_en_reg; - u8 tuner_en_bit; - int pd_shift; - unsigned int flags; - const struct clk_ops *ops; - u32 rst_bar_mask; - unsigned long fmin; - unsigned long fmax; - int pcwbits; - int pcwibits; - u32 pcw_reg; - int pcw_shift; - u32 pcw_chg_reg; - const struct mtk_pll_div_table *div_table; - const char *parent_name; - u32 en_reg; - u8 pll_en_bit; /* Assume 0, indicates BIT(0) by default */ -}; - -void mtk_clk_register_plls(struct device_node *node, - const struct mtk_pll_data *plls, int num_plls, - struct clk_onecell_data *clk_data); - struct clk *mtk_clk_register_ref2usb_tx(const char *name, const char *parent_name, void __iomem *reg); diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index f04f724e12e5..64f59554bc9b 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -13,6 +13,7 @@ #include #include "clk-mtk.h" +#include "clk-pll.h" #define REG_CON0 0 #define REG_CON1 4 diff --git a/drivers/clk/mediatek/clk-pll.h b/drivers/clk/mediatek/clk-pll.h new file mode 100644 index 000000000000..d01b0c38311d --- /dev/null +++ b/drivers/clk/mediatek/clk-pll.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2014 MediaTek Inc. + * Author: James Liao + */ + +#ifndef __DRV_CLK_MTK_PLL_H +#define __DRV_CLK_MTK_PLL_H + +#include + +struct clk_ops; +struct clk_onecell_data; +struct device_node; + +struct mtk_pll_div_table { + u32 div; + unsigned long freq; +}; + +#define HAVE_RST_BAR BIT(0) +#define PLL_AO BIT(1) + +struct mtk_pll_data { + int id; + const char *name; + u32 reg; + u32 pwr_reg; + u32 en_mask; + u32 pd_reg; + u32 tuner_reg; + u32 tuner_en_reg; + u8 tuner_en_bit; + int pd_shift; + unsigned int flags; + const struct clk_ops *ops; + u32 rst_bar_mask; + unsigned long fmin; + unsigned long fmax; + int pcwbits; + int pcwibits; + u32 pcw_reg; + int pcw_shift; + u32 pcw_chg_reg; + const struct mtk_pll_div_table *div_table; + const char *parent_name; + u32 en_reg; + u8 pll_en_bit; /* Assume 0, indicates BIT(0) by default */ +}; + +void mtk_clk_register_plls(struct device_node *node, + const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data); + +#endif /* __DRV_CLK_MTK_PLL_H */ From patchwork Tue Feb 8 12:40:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738626 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 59794C433F5 for ; Tue, 8 Feb 2022 12:47:31 +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=Isc5QLgc/pNY31WXDGgFnk8dYjXriWe6Nz+x8Z1riC4=; b=W7KojaZNWyytG3 HZ5qPYxebyiXdVeh0Aid29pdgEPO4JKClCeyigTK1ntwWXtzjWr9EuzApY7qeo4aj9ueX4ewUxGPm pAujx9FybAzMwQs2Cs20xBr8jhLSp6snkOZR0zPZJ7DeeNgyVFCl3UqI4LYQ31LIpBxhHOIi4eZbI YOHY4WAGIzsxEGNmD0fZt3YuvA/OUkVkxD4E9tHIEHpzh09rPBsJ0JqSe51xlXdugzR61CVXoIS1k d/5U39oh3VTe1fKocAVcDokcsOZSmyynby9BfC+Vv2jGygd0kuTDoI/dIA+Aje1Sn8L2JP/IldS6J oUKaTf0/gy9QZ6QLBsVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPtz-00Dqaw-LH; Tue, 08 Feb 2022 12:47:23 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPo6-00DnSh-Ep for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:20 +0000 Received: by mail-pl1-x62b.google.com with SMTP id 10so5818844plj.1 for ; Tue, 08 Feb 2022 04:41:17 -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=ucbCQXspAieTR5IRJ88apHKs0Oo+TcGwEm7YM7yoBFE=; b=oHY673UW7vPbSg3PGRcTlPVTR8Y6tSg1ME93cddkHRfN3evzBumjNKPjS9MMXetvGz cyaPopBpjfAlMvtxCgg+GHb5cpygQczzim0Yug0Mh8xdzazLH7miTaVhCIIXd9h9QdUn 7TbUW0Nsppw/Izk8VE5AGFZaPWyj9T5IpYftw= 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=ucbCQXspAieTR5IRJ88apHKs0Oo+TcGwEm7YM7yoBFE=; b=b0JrHr0LgyIpJKodDO1QcIzx5TBFNR6AvFjd27biGg5gj15C8v1+sgsF8D/+glgNDM k+/xSMnS69/WD0WW7oz/JJjIibaMGABBBz8cBTBktZ2D02r5X/0IQmHMgGS2+X7w/d3E 87KtNbnAdeLCMw+DsYleUG2kYkh66TTGBO1PDo9yKkDttnEGz+HhREqbjdp1EMDMS78d qagPgaQiizmsrkgDB/Ez+f6uxHixEDkkguPK5YsRSI/sMVBuv4zvA/EbSV0QvkFcF0EK FhWe+oiqdei958AGC6VsydtglaG7hufbjC6pANW9fJJuosBd+a6Hfl3E83rnisQiHsTi 2bTg== X-Gm-Message-State: AOAM533PPZABnwuqkQk4F+CIoXk8kHNMGt0pTj5DHJUCGDLLsqv0YHLH 1nj9og2Bb3szOcMzyHaxAzALXQ== X-Google-Smtp-Source: ABdhPJxdkJmcSGDXCQW6yjqpsQN+RjwrIexHzblWHmuV0z4WVMDQoML2GrmGp6e07CaXZlQ30GG28g== X-Received: by 2002:a17:902:7048:: with SMTP id h8mr4338247plt.40.1644324077323; Tue, 08 Feb 2022 04:41:17 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:17 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 13/31] clk: mediatek: pll: Implement unregister API Date: Tue, 8 Feb 2022 20:40:16 +0800 Message-Id: <20220208124034.414635-14-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044118_596290_1202B295 X-CRM114-Status: GOOD ( 16.78 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The PLL 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 PLL type clk. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-pll.c | 55 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-pll.h | 2 ++ 2 files changed, 57 insertions(+) diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 64f59554bc9b..b54e33b75d4e 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -360,6 +360,21 @@ static struct clk *mtk_clk_register_pll(const struct mtk_pll_data *data, return clk; } +static void mtk_clk_unregister_pll(struct clk *clk) +{ + struct clk_hw *hw; + struct mtk_clk_pll *pll; + + hw = __clk_get_hw(clk); + if (!hw) + return; + + pll = to_mtk_clk_pll(hw); + + clk_unregister(clk); + kfree(pll); +} + void mtk_clk_register_plls(struct device_node *node, const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data) { @@ -388,4 +403,44 @@ void mtk_clk_register_plls(struct device_node *node, } EXPORT_SYMBOL_GPL(mtk_clk_register_plls); +static __iomem void *mtk_clk_pll_get_base(struct clk *clk, + const struct mtk_pll_data *data) +{ + struct clk_hw *hw = __clk_get_hw(clk); + struct mtk_clk_pll *pll = to_mtk_clk_pll(hw); + + return pll->base_addr - data->reg; +} + +void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data) +{ + __iomem void *base = NULL; + int i; + + if (!clk_data) + return; + + for (i = num_plls; i > 0; i--) { + const struct mtk_pll_data *pll = &plls[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[pll->id])) + continue; + + /* + * This is quite ugly but unfortunately the clks don't have + * any device tied to them, so there's no place to store the + * pointer to the I/O region base address. We have to fetch + * it from one of the registered clks. + */ + base = mtk_clk_pll_get_base(clk_data->clks[pll->id], pll); + + mtk_clk_unregister_pll(clk_data->clks[pll->id]); + clk_data->clks[pll->id] = ERR_PTR(-ENOENT); + } + + iounmap(base); +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_plls); + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-pll.h b/drivers/clk/mediatek/clk-pll.h index d01b0c38311d..a889b1e472e7 100644 --- a/drivers/clk/mediatek/clk-pll.h +++ b/drivers/clk/mediatek/clk-pll.h @@ -51,5 +51,7 @@ struct mtk_pll_data { void mtk_clk_register_plls(struct device_node *node, const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data); #endif /* __DRV_CLK_MTK_PLL_H */ From patchwork Tue Feb 8 12:40:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738627 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 7C3EAC433EF for ; Tue, 8 Feb 2022 12:48:21 +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=AfIOyrVtwhs+IxCMkCYLrce1pgq9b6TcKY8H3RcnPkw=; b=VxqqB1DzLfVMma v9BgyMi1eFrUeakNsHOIuuK3U13CHE6TEkYz4tcnuj9SvkUdB7FPW3oekdlyWERzUMaYCSD0qvIb1 qdblSkwld6FT7KqBW/psvNFRt/yX2UyGgOr4zUUcpmmDmvcJAX5Q0aKDuaGQnbPbFnqdPmbhHBgPS bSCuJ5AJeB9r4NjH2c51DCh2e6mULdQ/c3oDUkxlar/7fTiwP3lnKR2ByGxqc/OaeqNfq/QRZxG4R FgMPstbikao7o4j+aEtOISTfKYIt8lpn992C09Dy/SwEgR2Y0GHGnbg1pfoEZ2q/juVwggWP05tcw YFoAHKuUSVUWkSQbpP+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPun-00Dqyh-Me; Tue, 08 Feb 2022 12:48:13 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPo7-00DnTt-TN for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:21 +0000 Received: by mail-pf1-x42b.google.com with SMTP id n32so18630104pfv.11 for ; Tue, 08 Feb 2022 04:41:19 -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=VHqh/ijWzTkcfpqZcH5Nz4N1ISUlPyaJ60Q4OawbBT8=; b=VnE41xebylDSIYGhpkKNh6ZSVZj7DTmMZVRnyN0MXW4J5q0SI5huCttg3YkTT/ADYt 3DheENGasIAUHE7ketk881llrCYZtC31y558+C3G/eh93+rEmIPR374s5tVphnYIuS50 EcGL+mY2csHY5WHy0gsEFrhBXtCv3+HUfvyEI= 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=VHqh/ijWzTkcfpqZcH5Nz4N1ISUlPyaJ60Q4OawbBT8=; b=fBTB4I4S/1QUvInfduVG/d2pARiSj/ccwgo35wzdbAB6W1QeaxZeWPr159JsebqJB1 jZb9ty18gZaggv3d9s0rIqMRjF/rqqB/BxHsN9XV03O737PoRkwuQYyPio7yweVv+5Dl gbuGPBTYBG25xbua7KJDD8L0ZpF9LG6k1rHUa7rPMd8dlQvu0WiS3YMnEY8EQrf+ue80 Js+D0+3K1qBwYs156zuHgkUgInorosenCIfTCZnNGJrb4LAu0BvVGqmIeKrasUhRO2AX vdRKxklGuO0CMh1T3/u6jjrsupb+6v4f64Y/hY9nvouJplubbAfjYP4vfjE/yD3H1FGA Bsag== X-Gm-Message-State: AOAM532tvbx5AOtD1Of64hSBXddYDlzUqvcK/W363oDqXyezV79rUjgC D7fIkdD2TmZWxf04zn1UFExxdA== X-Google-Smtp-Source: ABdhPJzo0Dp/SCBcUkYHyRIcTeVZXRqv8ziFNxicZ9SLxGT7dPNBKPsfl76t0sK8wZgzQsmDxW8paw== X-Received: by 2002:a65:4b82:: with SMTP id t2mr3342176pgq.607.1644324079445; Tue, 08 Feb 2022 04:41:19 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:19 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 14/31] clk: mediatek: pll: Clean up included headers Date: Tue, 8 Feb 2022 20:40:17 +0800 Message-Id: <20220208124034.414635-15-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044119_997215_04599DB5 X-CRM114-Status: GOOD ( 11.51 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included. Get rid of the unused ones, and add the ones that should be included directly. Also, copy the MHZ macro from clk-mtk.h, and drop clk-mtk.h from the included headers. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-pll.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index b54e33b75d4e..8439d37e354d 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -4,17 +4,19 @@ * Author: James Liao */ -#include -#include +#include +#include +#include +#include #include #include +#include #include -#include -#include -#include "clk-mtk.h" #include "clk-pll.h" +#define MHZ (1000 * 1000) + #define REG_CON0 0 #define REG_CON1 4 From patchwork Tue Feb 8 12:40:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738628 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 5DE63C433EF for ; Tue, 8 Feb 2022 12:48:24 +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=kjnMVKR3yPkYOoI1Y9VGbcEeOMtv/+Morf1sK0Xj30Y=; b=17ydVtgb0G30CT LyDjIkzREfrk5l2ODPpJkBwPIDzgd7RkWGhrSCBkS2ufbZV1EmFd97ajb2v/BCUfxjNXfa7RyMfS4 huV2vQj1cs51wYYEGs/FQoBlYdFA3wjeY1vQ3mfFhAuZPICYe4IkDYxEjjAtq9QMpzYXf2GINJTEu wWbiUH1h0XFokQ9oXo9xXfbXXfXgpxD6eCqzDv9aGHoiTcn2wMyW347SN43WSrFkrP+5JDMRf2YeD uEaOW2JWfevrJjYX5JWtpkB9kQry0rtWPaaqqZtve8+vrhoNgsN4ScXGaO56tpekUPgWLmZcp2W7j 2lhXaqwLFF+pT1HttRuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPuq-00Dqzv-5N; Tue, 08 Feb 2022 12:48:16 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoA-00DnUx-1M for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:23 +0000 Received: by mail-pl1-x629.google.com with SMTP id 10so5818975plj.1 for ; Tue, 08 Feb 2022 04:41:21 -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=hPoHx0MxVy2mprDlmk7WfXEAU5PM2SDXULV3Mk0XUS0=; b=OfHhLbHzk0vts8tueG1EzqqelkQHhva27fwdv4krb3Fqvz8/E1nF+x19VySsFkliJS QWpDJWRJFXUmL6Vs+5UTz8L/HVVxgqR7JTPnT6sc5tF+oL15DU1X5WddfafuoaVI61Bn UoAL6xF9lxyN/QfNm6ivb7WFoGU109XuRiHx4= 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=hPoHx0MxVy2mprDlmk7WfXEAU5PM2SDXULV3Mk0XUS0=; b=iGUtdHtjWwjLmcNTerU9JDLRB5Bamark9Ma6S1YKN8/Wav7qP6FVxfLdejnCsYmXEJ IkrtQPEUH8ZiFxmMV/sX2gmBOZjjaCQwdOZ+umvaTJwZOipTAAJ0T8HoC2yrlOpxmuY3 BD2XCgAtSf/fwQonnJhIvt985R7ZedbhwLbo4pWPR2vLaJ3ZHWUUBdDFO4cMWXqEKNax VygWziNPrEQ+Iu35AyBcklPEaY4jWrERkncKNdf9r+b9pxhOXRPhYH8RzOfK6zcX8boJ gGZcE6XuiIHV/rgZVaiYO33vFkKBnBVOCHlfETaBITzC/cCCTXWbSZcESr5KzEfNyKto LVRA== X-Gm-Message-State: AOAM533Y6/lX27GjSioAwU7DNvE85hC32UFLON3fCHC4s55nJeQyJ/KY TyrrQgGuodALY9dvQm/ZDEcc7w== X-Google-Smtp-Source: ABdhPJymp3eMV72+HQHSFM6knL5LU/F4l+dnd3TBAdTXc+SFrQG9SpNis495KvAMIpZm6L+mhFZQBQ== X-Received: by 2002:a17:90a:c283:: with SMTP id f3mr1171840pjt.138.1644324081530; Tue, 08 Feb 2022 04:41:21 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:21 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 15/31] clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API Date: Tue, 8 Feb 2022 20:40:18 +0800 Message-Id: <20220208124034.414635-16-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044122_126658_52151322 X-CRM114-Status: GOOD ( 14.98 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org mtk_clk_register_fixed_clks(), as the name suggests, is used to register a given list of fixed rate 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 Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- 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 0c5db3c71fdd..7c0d5706eed7 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -80,6 +80,26 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, } EXPORT_SYMBOL_GPL(mtk_clk_register_fixed_clks); +void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *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_clk *rc = &clks[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[rc->id])) + continue; + + clk_unregister_fixed_rate(clk_data->clks[rc->id]); + clk_data->clks[rc->id] = ERR_PTR(-ENOENT); + } +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_fixed_clks); + void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, struct clk_onecell_data *clk_data) { diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 168220f85489..cc7f920eabb4 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -34,8 +34,10 @@ struct mtk_fixed_clk { .rate = _rate, \ } -void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, - int num, struct clk_onecell_data *clk_data); +void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, + struct clk_onecell_data *clk_data); +void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int num, + struct clk_onecell_data *clk_data); struct mtk_fixed_factor { int id; From patchwork Tue Feb 8 12:40:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738642 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 82D29C433F5 for ; Tue, 8 Feb 2022 12:49:33 +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=M9XKG1/xcxN4TybCvqcoyslUjiuBJaCP3JRDrxtZjNA=; b=X2s7ihebW67Y3Y NVTqwRfaNEPgfC7EDt+XnR551U2CqGGBurA+Be/+HuHuMCB2MKmc7G/M8eT/FrycoMxpJhDh//CkC l+r0TUu61JJ8trYm8hlm8dHLeGeVwwalmgca4mFdZCUYZC2frQ6iqBRjLVsuRI8tafBWWqfX7oL6/ 3vIaZ9NUXkZGJa3GEMnTBgaqHfQFrdmYlxrrob1tL0M7iH8gMJ4PDQgTFoWoG+p4naL2qd25+jTfB rER9U66D9LlfcfzOScJhDmhnpGxyKGf/7xu4G3NQ8PrzWInNTwOZ65CHM+msDltaPeownNnsgHwdc gDLpDfksO6zciD9mEhwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPvw-00DrWh-JT; Tue, 08 Feb 2022 12:49:24 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoC-00DnW0-Qu for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:26 +0000 Received: by mail-pf1-x435.google.com with SMTP id e28so18650069pfj.5 for ; Tue, 08 Feb 2022 04:41:24 -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=0jvgrG3Dmpy1I6S7Dz5gEHIA3LIp2Xa/xR1uXh6G5dU=; b=OO1r4dxadJOGLUSOKAN0tmHzPQa1/FnX57PE28Fw2+knHtrP1i77Wg2a5G/AUHfj7F XJe4SgQaXUtNYtLJaaI40p7JgRIe15fGPHDGLYG3xHdNTVULkjQ59t51I+2PyOThCt2P 5n4cgfYK6ehEyeCRKJw4xyfPqumGi9TgdpYyk= 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=0jvgrG3Dmpy1I6S7Dz5gEHIA3LIp2Xa/xR1uXh6G5dU=; b=jKw99HZQp7k0pPMOxOAd4GBmP/7wHpd0iDYLwOSILUVSxFGTb/W01x9lnW9vDtcnys 1S94cZhnlfcvCNX+5XoMZFj0Tpa72qLqA8KjskRRbhUBQuNzIPu5CmZ+OdWAFgj7mxcN SADzPWpOPoN+cNlr41qvtVXQU5JdecAkWEMg3A7KUCjNLTsNVtEi9UFN5TbqwJ1aLA4q fTNv+Z0+DsYX+Ym52na0FHbavgF8AD3wQwFbsBT+crVrh8zI+4PDaFXMxLL59RRuOOiM lB4Kg910eNn+vDr5m1x8CSKH1Imz/E1MXc7Pas4CMwW1dGDLIgzqogX2o5SE+oTgtQpM KQUA== X-Gm-Message-State: AOAM532FZbFCmrtgoP1RsoBrxjN0aTlujOw7K4o+6qWTzfZNrRhUFeER cIdjGJ+ZLMQFVUjI/YVkzADXlg== X-Google-Smtp-Source: ABdhPJxlQ6xRfe3jgexdVmS/BecwJ0yJF53+WUSqv5aNmcGH8QFSxeRwNVd6B/u1PMoMOp5zWvGwTA== X-Received: by 2002:a63:9307:: with SMTP id b7mr3353508pge.291.1644324083669; Tue, 08 Feb 2022 04:41:23 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:23 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 16/31] clk: mediatek: Implement mtk_clk_unregister_factors() API Date: Tue, 8 Feb 2022 20:40:19 +0800 Message-Id: <20220208124034.414635-17-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044124_887102_D48CC9C0 X-CRM114-Status: GOOD ( 14.99 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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 Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- 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; From patchwork Tue Feb 8 12:40:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738643 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 60245C433FE for ; Tue, 8 Feb 2022 12:50:32 +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=PoneurH0MluNpfLnf8sv8GBQdUs/KOAR1EeHNzV+DyE=; b=bEyYpAEt8X/fc0 2JDK6RO3nniHx4JiHOaRobjarovsa3r4+jtJSpAj/SJcxZe3jcI4pcH4SMc1cRNe/70KMKET6pbV8 F9xRm+/Ys9yv8mHxqZFyNXAUetWULz9VVkFwxGibzF5ussIogVR8IFehPFFyDucTjM400vjZISYk/ nZBC7TGzzO1m81ZrE2ed9/bKDqzTAp361m8m+V5/bDRVe7RbzDzS27U9G4lLIF6jMWdlDQaX/bqlu +fbvfpV5dmogijduZjGdXquhcLHUmf1Ny+NyvWfOdotf7kAQ9riyUk/QAGZRurzsdNQRUsd6fzpQJ BR+wCgUxOs7dFoBiCIZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPwu-00Drwn-T7; Tue, 08 Feb 2022 12:50:24 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoE-00DnWw-Go for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:28 +0000 Received: by mail-pj1-x102d.google.com with SMTP id y15-20020a17090a474f00b001b88562650aso1537043pjg.0 for ; Tue, 08 Feb 2022 04:41:26 -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=R3JoellM0j3/drkIwePqf6xNXC0okTaVtKIbynTeAOc=; b=cDbvFXn+++jD2RBihOfm+4NuHtNk8YlQxYmPjF35O1yrsUbdXxfadniAuG4XR5nFwS 6AjlYWaCgdXKEQ9wtER+Kay6SUeGumXjw601aAOrw5/VgQcSA14qgibFM3JGqGXyIn/9 ETByjiRDfguEMxbmnwqFjDAIY6/V0+X2N5eCw= 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=R3JoellM0j3/drkIwePqf6xNXC0okTaVtKIbynTeAOc=; b=Q7IYXRiq1t29l6Jb/GxYr1kaZuSUkadzS2P0PaysMt6jmaSI3uEPYCCfAPGY0X4lFO GxaWMAf6QdAp9oRlN/53BoFdN6S8kqQQHIy3V1dHq6WuOFDnEWDgkF4QxUcF39WFT28U UeffxVicVUh6/HS8TGn55ZzR+WvXBGPn4ITa83MFgPao3MZckAuTuDQffVRVE3bKwL5H bwfbvuct4GlUcItW5TYSBXJm66ncziVL94XXli7rvaGKBl40bFQsOrnaalx10nJmUEVR AAcSwfVBnX5JMVGjuP7Rl9RTu7k5LOpWRsGyuXQP7HsAlQZWwcBpvOatncY6pE8b3Bnn odlg== X-Gm-Message-State: AOAM531nLFqe8H/Y6B6wKwxOkVU9qgqvYFCFgY551DMtkvdi5ztMFJ0G VkJA4bpOd+JxQ2538vSVI/+Rqw== X-Google-Smtp-Source: ABdhPJySG6k3d+lfO+J6p0YF76ehegEmYbi/IhHoJqpoMykEiunvLKUkSg7jAzY0zepF1RSOzn+Q1w== X-Received: by 2002:a17:90b:3a86:: with SMTP id om6mr1151521pjb.99.1644324085808; Tue, 08 Feb 2022 04:41:25 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:25 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 17/31] clk: mediatek: Implement mtk_clk_unregister_divider_clks() API Date: Tue, 8 Feb 2022 20:40:20 +0800 Message-Id: <20220208124034.414635-18-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044126_578108_50ECA3D8 X-CRM114-Status: GOOD ( 15.75 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org mtk_clk_register_divider_clks(), as the name suggests, is used to register a given list of divider 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 Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 19 +++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 8 +++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index b267b2f04b84..3a6dfe445e63 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -286,6 +286,25 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, } } +void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, + struct clk_onecell_data *clk_data) +{ + int i; + + if (!clk_data) + return; + + for (i = num; i > 0; i--) { + const struct mtk_clk_divider *mcd = &mcds[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[mcd->id])) + continue; + + clk_unregister_divider(clk_data->clks[mcd->id]); + clk_data->clks[mcd->id] = ERR_PTR(-ENOENT); + } +} + int mtk_clk_simple_probe(struct platform_device *pdev) { const struct mtk_clk_desc *mcd; diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 4db1a97c1250..e3ae22fb0334 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -176,9 +176,11 @@ struct mtk_clk_divider { .div_width = _width, \ } -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); +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); +void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, + struct clk_onecell_data *clk_data); struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num); void mtk_free_clk_data(struct clk_onecell_data *clk_data); From patchwork Tue Feb 8 12:40:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738644 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 416B1C433F5 for ; Tue, 8 Feb 2022 12:51:53 +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=G93HCyM+/H3qnVlOaZBKSPbAD73hrxpt4Cg1vgsLThM=; b=Z2xg3ptHLt2pMI 33T17TJer9bcWg/r6fXvhIpccAsnatXJGpSVWg+ExThH2XSmB1jtKw7YXuS4V8r7O6EHaRS8Wn0J4 L2Vq2+7MlQOu0ogmGyFStirc7K+nZ4rfIQdTjW88SpVQiHHqO6daoyicTO1GQTkM9D9ZhO0iireNd BX285MlBdZGrZAtbbgYd2OJPdYzmrlts+JB9PmTMrDHaPClmJUvYxPQkkGT7NkIJXZ3DRSc5H6zmd IER0BZic2+rjQiP7MG27mWVInwUUL71nwIhff2xSS+25/y/MRy0frnWRCNP1vuDCJcWkK+8nQs0wb xy0WN39g5j4tOITrdxlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPyB-00DsXA-02; Tue, 08 Feb 2022 12:51:43 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoH-00DnY5-8R for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:30 +0000 Received: by mail-pf1-x42a.google.com with SMTP id p43so1080020pfw.1 for ; Tue, 08 Feb 2022 04:41:28 -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=rLQw4RJqDZVMPw30M9uz1PhQpXBhvEj1u6VLau9OtwY=; b=jL2a5QDyajKzOUAWV5B0Nd19HhIgfINHJvM9WNEn6b+LxDB4bDUyKQZLkDZMB1szH8 sSKODHRSvOsJrGymmMHci7fr5tCxsmLXcZm38aNquOg8tvsqskd0Of82WHAiGSpdjBVg LJb7i6DxEMHHloBmjgN+29AbkGYR//LBVbPzo= 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=rLQw4RJqDZVMPw30M9uz1PhQpXBhvEj1u6VLau9OtwY=; b=RpxbxlBrOfGF960THr0pB6noCrkGC264Pa/oJXzc30PjwNS4tio8J0/RQQHhImxaMx P1a7N8wE74GBQJ+p89kNn3OpHSV1sBfJlsvZclrRaF4DvC2oWMfJwcop7l8iFa7GKuVu xMqRGQhEmPPDPGVwY6CoaXiSK1bycNLndxX98N2vUDSGbykgDdM9V3Y9OZneacCsJQAF V68NlmI9c2jesSvCwZBcuHFYhoPQ/HDunMVUWg+fDoICQT3rsQ398bCeClr6AqP2BkRF xAWHs6ZrRMdhqGSVYHCUG4zSHGebaKzrlg99f3Egi0yEBn8MFMGIZYHZOxgDFL+Khn9Y 1+0w== X-Gm-Message-State: AOAM530YwT5dtqt0KD96Eqtc4lGOB3vMJZBtcnspSNgACby9ye5Jf0Jy +5NrOAGRtJ+tflAMEVCEI+TH/A== X-Google-Smtp-Source: ABdhPJyoH//QGDvsw16k4jMFINHEtKQ6bLu2VPWjf6rsSG2qmmitjA3mxEh+PsT2umh3po921k0HrQ== X-Received: by 2002:a63:2f82:: with SMTP id v124mr3314490pgv.139.1644324088094; Tue, 08 Feb 2022 04:41:28 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:27 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 18/31] clk: mediatek: Implement mtk_clk_unregister_composites() API Date: Tue, 8 Feb 2022 20:40:21 +0800 Message-Id: <20220208124034.414635-19-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044129_314125_5926C24C X-CRM114-Status: GOOD ( 14.52 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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 Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Miles Chen Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 46 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 2 ++ 2 files changed, 48 insertions(+) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 3a6dfe445e63..869e6ae55c82 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -233,6 +233,32 @@ 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; + struct clk_composite *composite; + struct clk_mux *mux = NULL; + struct clk_gate *gate = NULL; + struct clk_divider *div = NULL; + + hw = __clk_get_hw(clk); + if (!hw) + return; + + composite = to_clk_composite(hw); + 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 +285,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; From patchwork Tue Feb 8 12:40:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738645 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 422D0C433F5 for ; Tue, 8 Feb 2022 12:52:05 +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=2HuFjPtosHNnYwGAIu1d+fgFffb5m0z+fODcbMrKtqw=; b=liqC/9A37tId82 wqZgr/psCshyjY/vw7Anel3/mYX+y5wkd0X/QCAgDER+i21NyjiNwJ0kpvEz7d8RHq22YLl9Zxezo 64Qm4MIQ8kE2QE04w9/6MjsliShLDbwSx/7tjoH/22UzP65id74SgYET8ujr4TEOTvHJLf7HzKyRy dn53QJTkrP4F3dvOiw0RVqL/xLyW1lk+Au1wlajhnZIGDqtze+bwujyBOuDwG6mqatNo0dKDy4LCk ibu4aGEhiQApDMUVZPt3t+VovPlZ4VzsH/8WeagVGTGZLSFlV/bVGVIT6BZg4xS/ptRIjtzAcuIYP WCw/Xry8aLgtK3hixNUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPyM-00DscS-3m; Tue, 08 Feb 2022 12:51:54 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoJ-00DnZT-FQ for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:33 +0000 Received: by mail-pf1-x42c.google.com with SMTP id e28so18650524pfj.5 for ; Tue, 08 Feb 2022 04:41:30 -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=eHwaFCxTmQBqke38QY+U5TZZstQq9O/KJJL77r3W7Ws=; b=nvJ9cLw2nqPy00A1rg0QyEIyTWd8T9dpFDluSxKOq9Tn01B1Y1MbhjQSTCkrI27lra TPGEARXZUBxH7ykfmmOa39dR6Oy6acq0JeHZz8WIgow8M1VrhGsVwV07krTMrsDqoSNI XG0NVawmgtjcczlzwoL1Zq8zDR39B0P7nUe1s= 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=eHwaFCxTmQBqke38QY+U5TZZstQq9O/KJJL77r3W7Ws=; b=XZ4m/HFox7osCTwovzJ5dL5xGXct86Wu36+FKj2gaoyavoR7/Rzl/IGpBehV0XJdoi PI/iPLLOEoElcMfaR4UW/jpR/vRF6AFxsPS/09kiUN7aPUuUUB/kEDFrk8TueMIWEkDs /gBGlMDYMRbs5zIFWEOOCgJricwM5duH/Z7vv0mOT59/4cDIRCWefIW7e/aa53dEt6ge sUZGRpuWgK4JMY1wV3QnNinKGeOWUgh7bUaREfbEIIv96LrwDVSbYJEp8W2bZc1zavb6 cV/BSTlnJpxOPITcVpQL1DyfbQypeSBTHZRIEVMDISZZYbfKws9DA/Iga3O3Iw2enI1W r2Yw== X-Gm-Message-State: AOAM532YGH2tUxIvpKgquR7vcnKaCQyuU6aucaznE+NRU2JNMnNQSo1I whWyQvZMlmDsm0bF9Yg5zpTmYg== X-Google-Smtp-Source: ABdhPJyYdWVRlyhjrE40StYyFinJI1sYaLoiAb4EohqiUabCdb/YfzS2WfyZVC3UGTCq7xluaPc2Xw== X-Received: by 2002:a63:8142:: with SMTP id t63mr3362355pgd.256.1644324090238; Tue, 08 Feb 2022 04:41:30 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:30 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 19/31] clk: mediatek: Add mtk_clk_simple_remove() Date: Tue, 8 Feb 2022 20:40:22 +0800 Message-Id: <20220208124034.414635-20-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044131_594634_0A6592A8 X-CRM114-Status: GOOD ( 12.30 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org In commit c58cd0e40ffa ("clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers"), a generic probe function was added to simplify clk drivers that only needed to support clk gates. However due to the lack of unregister APIs, a corresponding remove function was not added. Now that the unregister APIs have been implemented, add aforementioned remove function to make it complete. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 15 +++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 869e6ae55c82..f108786caeda 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -374,6 +374,8 @@ int mtk_clk_simple_probe(struct platform_device *pdev) if (r) goto free_data; + platform_set_drvdata(pdev, clk_data); + return r; free_data: @@ -381,4 +383,17 @@ int mtk_clk_simple_probe(struct platform_device *pdev) return r; } +int mtk_clk_simple_remove(struct platform_device *pdev) +{ + const struct mtk_clk_desc *mcd = of_device_get_match_data(&pdev->dev); + struct clk_onecell_data *clk_data = platform_get_drvdata(pdev); + struct device_node *node = pdev->dev.of_node; + + of_clk_del_provider(node); + mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 3c3a934f53cd..4fa658f5d934 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -202,5 +202,6 @@ struct mtk_clk_desc { }; int mtk_clk_simple_probe(struct platform_device *pdev); +int mtk_clk_simple_remove(struct platform_device *pdev); #endif /* __DRV_CLK_MTK_H */ From patchwork Tue Feb 8 12:40:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738646 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 BC0E6C433F5 for ; Tue, 8 Feb 2022 12:53:42 +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=nHF3YukmqR155f72Bje07flOD1RuIRkrd/P8C5y35xI=; b=G9S83IXXD2dPti Oq0WQ61RZCTM3AiNwHdfHmBuqUCdcJSJunGCM/G7ywYX0A27ouQR9BMhcyC8cEFWLkurpknGlHQKD +a3T+Xu73+KbSLjvcwdrtSI3e0JdZQVZEYau8qAmiw/IRTFGAjwKCuYcFauoPod3xdYeUZ2uyguDK pZVZkfRznEDC2HSrWNyBvI5qq1SHzZXj5ZClQWWAPNjNVD7BgFv1l01Wop/zvWJkWx23SFG/OXwjx YjY0UreCgnv1tbeacZLD0ROdqvT5c2Y6iPkjGprduNuqYf77jmZFzK7z586kH/yhND9Kp779AhTG5 XLjb7txgYljVLOnNV2rA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPzx-00DtI7-3V; Tue, 08 Feb 2022 12:53:33 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoK-00Dnag-Rw for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:34 +0000 Received: by mail-pl1-x62b.google.com with SMTP id y18so4114653plb.11 for ; Tue, 08 Feb 2022 04:41:32 -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=VlKtM6FjYA2dZO07upzgd9Pj04Wu97J4dVvK+jUNEck=; b=OrSsQvFFXKSurEYBIMXb9+NOJkRn42Oayov78oivR7/II3RzfciYs9zq3TiYOFrMzf 3SFpboZilv9rJrVtd6Mqd+OI2aCWZyLByJAU36g2KxT8SNQmX4c40+48wnG5jbzXE7Yp XwQ3RYW83qUfjx5/1bULaTZ4NuYSzeASJdaqY= 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=VlKtM6FjYA2dZO07upzgd9Pj04Wu97J4dVvK+jUNEck=; b=ovssSbbyZNqRG/eEWgnfQmVBF2AhwvjOU4rQppbpLQvthgp5fuSn7wJZE+A49WMgq0 9LpgiDXuH0dMJUDTYwSsjwAWxo+s1nUlrSJheiH8Neo6TuCC6lbgjzO/4gNRF/iiEFYC Lgytu2l8KrU1Dp8LjH2zTA/Tcp0sFT6pESCpv4LkdqmOGvA61PcnImLUm8Y9Mik30gSt oxsUlj7Z5EnrzLk9iJoAyAM4P0hj1s5rvS/tQG1cmu0REhOV8g1qvsUtCZSdqZfIuCHG QtQ2GqpQ8tcDmzQ6lmHWV60yPglK3kZpIZ7XjJIhtqYSlPk5M/i++mnqrxFbdg80Pf8q 2Ang== X-Gm-Message-State: AOAM5331YSkregSmFnYbpuecfTClPndpIGEjZBWJiWUuUCe3fAnliUFL FfSIfEzodbTCVRzlrhpNoVY5wQ== X-Google-Smtp-Source: ABdhPJyZtnIS5wvMBJfJ1PfBAFwhwCamW3QkOJc8pTKF0a7UI+1Dj2KYovaMuZBY9GlrF4L1rpycuQ== X-Received: by 2002:a17:902:a603:: with SMTP id u3mr4462853plq.113.1644324092333; Tue, 08 Feb 2022 04:41:32 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:32 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 20/31] clk: mediatek: mtk: Clean up included headers Date: Tue, 8 Feb 2022 20:40:23 +0800 Message-Id: <20220208124034.414635-21-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044132_996283_4D4E2E26 X-CRM114-Status: GOOD ( 10.74 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included. Get rid of the unused ones, and add the ones that should be included directly. On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 13 ++++++------- drivers/clk/mediatek/clk-mtk.h | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index f108786caeda..5618c84e4e08 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -4,17 +4,16 @@ * Author: James Liao */ -#include -#include +#include +#include #include #include -#include -#include -#include -#include #include -#include +#include +#include #include +#include +#include #include "clk-mtk.h" #include "clk-gate.h" diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 4fa658f5d934..7f902581a115 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -7,19 +7,19 @@ #ifndef __DRV_CLK_MTK_H #define __DRV_CLK_MTK_H -#include -#include #include -#include - -struct clk; -struct clk_onecell_data; +#include +#include +#include +#include #define MAX_MUX_GATE_BIT 31 #define INVALID_MUX_GATE_BIT (MAX_MUX_GATE_BIT + 1) #define MHZ (1000 * 1000) +struct platform_device; + struct mtk_fixed_clk { int id; const char *name; From patchwork Tue Feb 8 12:40:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738651 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 4F92BC433EF for ; Tue, 8 Feb 2022 12:56:28 +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=Lb2+s6uCDLTmu7VyVgeksLbxxTlwwgbR0H4jLwpXAEE=; b=kI5BtEhujWvo+o JH2PjhKhRPzPjaJuYzlxvgFYYM2RZk7JAl2w4+lEf6P5ju2OPiBNiMkAzEWoK0fyTc+eiJlu8cpcb 1LyEbcp3UOA7a02Dw4hVWVvTfgmMA9viB/SHFEv7hoWxV47HNROLEpJQj+plKc1k4nz9DgAH6LYPK hRx4MPH0Q6LPRmhJM9QmMpkdqZEXekfcsGhSHQvy5s7gY+tjr87tH5jS6TlnaP7MQ22zCnRci1Rnk oN/qV/zAFtxjBL0TXXLJuhRLl1mEdJc3Tck04wGnZA2QDb4HX9lEILrBz+jF7KZF8jfzVNRruFpkQ c+r7/XLjc7Reck6pUnug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQ2e-00DuRX-6T; Tue, 08 Feb 2022 12:56:20 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoN-00Dnbx-3S for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:37 +0000 Received: by mail-pj1-x102b.google.com with SMTP id m7so16088163pjk.0 for ; Tue, 08 Feb 2022 04:41:34 -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=haCUKocersM2g//bqn162Qgjk6DgHWiyvTJMF5LIhWw=; b=M5jgrIfhxC3Ll3awR5T/EnAv44rvXW+k+Lm7AQnR3Voo/+J434lWom64lKJIfHW/cl bbJ4/NkcAMG7j9u2VNGPeha843F9tsH16GYZcBXjNE1AifaS85v+HaHEIl1Evh2aglFz VWZ5L03Ul4UGHHUuej8bAw7/iQcTu3MZubKqg= 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=haCUKocersM2g//bqn162Qgjk6DgHWiyvTJMF5LIhWw=; b=vpa5k7px5A2HML9GdQZtOaxKAtmqHjP6ktLkdjHQIeNN/hA33DyZHqUQUWLouPAvH8 wqe31AEO2LEI/SnHIrT6Ui/FKUtuPUQ3z3DC8BhsljbF4NTWi7+1XkUVuUirUmFFbhy0 ou9ocHLPaqgOOQ2cIh5raqM/yOcgn0BZvOmAEb/1XzS6C5ZKUlwZk9HID0B87HzlMo5h ezD9BwvjxwU79Nnzgat344iqKUtdpvv47RzKBLhLF/S1KSvJ9LbedKC6ufOwgPn3+efL s4WWNT82S161/RTvxVZ7EuM+T2kaP8mioivGIqgyDtGlpoD8WK9l1wpB2nTKCwyO2t5t Kxnw== X-Gm-Message-State: AOAM533gSQK7LSIdY6LLc6+vtWmgnJZEyf5n2HSgdV7RPyBNbLWIWHOV 5JdytvsSgfrIhEfgHRpdPWB2Mw== X-Google-Smtp-Source: ABdhPJwC7im+Wu7WK7r8anEyQqm3GCI3zaun1ihNvzqAS141M0dKaySmYd4Yoapf0HcUrCF7/0wMeg== X-Received: by 2002:a17:903:187:: with SMTP id z7mr4252301plg.123.1644324094451; Tue, 08 Feb 2022 04:41:34 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:34 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 21/31] clk: mediatek: cpumux: Implement error handling in register API Date: Tue, 8 Feb 2022 20:40:24 +0800 Message-Id: <20220208124034.414635-22-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044135_276380_955C69BE X-CRM114-Status: GOOD ( 13.25 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The cpumux clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed. Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-cpumux.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.c index 658aee789f44..499c60432280 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -123,13 +123,26 @@ int mtk_clk_register_cpumuxes(struct device_node *node, clk = mtk_clk_register_cpumux(mux, regmap); if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mux->name, clk); - continue; + goto err; } clk_data->clks[mux->id] = clk; } return 0; + +err: + while (--i >= 0) { + const struct mtk_composite *mux = &clks[i]; + + 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); + } + + return PTR_ERR(clk); } void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num, From patchwork Tue Feb 8 12:40:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738652 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 B82CFC433EF for ; Tue, 8 Feb 2022 12:56:32 +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=G7PKXnkwO393HtG22zbOq1qTpmFrPanVk1uho/RuH/c=; b=HnnzZiie4nmTrm epQhKmcEFrBJGNcFCeZjxyKI2m45i5dO83v2/+RMj18wJmbQs4WkOf6yzCtViUJNhz3ImlZaTLmP7 TUWTRmYcGIeBKzNAjwbDfJTCmSsdhJkUC6J5vChLuVWAy2mHm/3pJejC3EtdL2VNE+MZ+mZEOml40 SU1G3jswTqGFwHXt3A3Szw+Ec0AAqY9spP/PfpnoHAPZokyRrCLvquId9phOpwxdmM47kvUZzVFBB xQWUYgkYU3IzoxpV2EiR+7/wfW7w9RW4HoXHkuihXLxu+FcliGx+widgwsXksGa3TlRntZGtMDHtD MtrTIkK28VLXr+6kcnRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQ2j-00DuTH-8G; Tue, 08 Feb 2022 12:56:25 +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 1nHPoP-00Dnd0-Qc for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:39 +0000 Received: by mail-pl1-x635.google.com with SMTP id x4so6144297plb.4 for ; Tue, 08 Feb 2022 04:41:37 -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=4j0R3HNeSGc+g80776sCkQCAjbvK19KbOBB/hGRldNk=; b=acB1/7BjmdHubG8NFsy4k7UA6MfRRMn4I+NVgkiU8wubRqG3ZE/NU9WNV3bqc/gc74 f7yUl7C2eXS9BMC73EIc0+SXkB9SG9YhdoTVoZBgR1zXx+yMoe3c93OhwzqC8A+U2INA xrjNY7XBULuhL4YJPxoFrfx4sT02hLUb1ds6U= 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=4j0R3HNeSGc+g80776sCkQCAjbvK19KbOBB/hGRldNk=; b=qWie8ytxb1ktmENbiR1m/nX9v7HCUAAu1mXidnt1KvWXk83KIb8Ec5IbkTZoembCQj sj6XuFkPdSgafWW6Yl/f3bdPGRwBCx3PJ5t+t/ulNLxb98kmhredDjn2qC0uAK/D5lKy NR7H/tfSfJwwfiwcH7uq+FM45pQh8YHmZqr1tqfQq6P+xaSOpB1/d6dHugGJhkJnrNXk h3fzskXmHJpoT97inDjMbIYItja+z7BvR0XIzE8OSkuyohPOtYAmKyKzWWOlSiP33FAR 37V9ivtxb3ULX92u7Ii8yeR+0xYEFftzsJCw/8F7eOg6x9jE6AAJWdY8IX5Fgq67S/eo IM2w== X-Gm-Message-State: AOAM5335qEyt1z6YCy/G8nJN7/vmYu+Pqado4/wzh+FFYNgKUS4VhYzy KxN8U0qffV9hYin3SYvlq+0INQ== X-Google-Smtp-Source: ABdhPJzeLyoZfZy0zfpCnekQyWJxm9Sx4ZNhG5yQw9XmEnf8kxkhVQqUSq9kr4wYr+yQxWqGmBAj1Q== X-Received: by 2002:a17:902:f651:: with SMTP id m17mr4253231plg.106.1644324096651; Tue, 08 Feb 2022 04:41:36 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:36 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 22/31] clk: mediatek: gate: Implement error handling in register API Date: Tue, 8 Feb 2022 20:40:25 +0800 Message-Id: <20220208124034.414635-23-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044137_945911_331D80D1 X-CRM114-Status: GOOD ( 13.35 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The gate clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed. Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-gate.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c index e8881ae1489a..631ff170b7b9 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -237,13 +237,26 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", gate->name, clk); - continue; + goto err; } clk_data->clks[gate->id] = clk; } return 0; + +err: + while (--i >= 0) { + const struct mtk_gate *gate = &clks[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[gate->id])) + continue; + + mtk_clk_unregister_gate(clk_data->clks[gate->id]); + clk_data->clks[gate->id] = ERR_PTR(-ENOENT); + } + + return PTR_ERR(clk); } int mtk_clk_register_gates(struct device_node *node, From patchwork Tue Feb 8 12:40:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738658 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 39784C433EF for ; Tue, 8 Feb 2022 12:59:46 +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=guC1JJ1PVKQks2S7smSEZN1p1fpmMFJWLkacdznLxOc=; b=K3i6R9vWSKJRMU oePLV0aCEPvznA7iq+aKntL0U7pRi0SjsEovEWhXqGVA4T0Z38Cr9tmKBIXjpRLVaxk12ycyJrYaX CoiQJoVEaQC78Y/aIGKhuA6Z8xgU6UQeK6j5yyWPgtaO4VGSUj7w2j7zllHynEc6bprjiUXEjpy0A lpaFXW6C6bNvlvNgDgeohJg1KNcpcCgvrgN4WKhQlEiKp1GESlc7XzIPLYb0tKc8rJdI+ultc1NIz 3MdYnvtYFml8SpRwVHE0cD2gFM9ON8L7v72Fb22huOueJvcyAD1AElATTmYERvIt0gsOxkvNLvAcd uP5my/kj903rh8LPox2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQ5p-00DvdU-2D; Tue, 08 Feb 2022 12:59:37 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoT-00DneF-Eu for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:43 +0000 Received: by mail-pf1-x42e.google.com with SMTP id i17so18618514pfq.13 for ; Tue, 08 Feb 2022 04:41:39 -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=ga+gjzrzR/LMbGVHXMahoAG4teobfaMr0L0SPMOkFuM=; b=RZ9aNJj6d+PjwBnU0ZJr9mX0nqK+z2KPKSE1hVDOXS6VR7K79uaqtUSEcm7xi/csiT PWkXmSg1lDYbXRJVyBHvI8LGnEa9ps7DiMTFIno+JyB6kH8xzJ+339+ev6Rsm53OTn79 B3I6j48uRr2+5wLm760I9Q9pCw2Z3sZkrOEYQ= 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=ga+gjzrzR/LMbGVHXMahoAG4teobfaMr0L0SPMOkFuM=; b=r76ORe9vXBAIXu1iMiIHmRkwotMf87q90cJo/bwE4xvzeRgY7PESSbY8p/VA+Mhy3/ 5t+zAcvojvNSBLuLeSjX2w79JxQuRWUdVTiWVK5fLAeIsRDL1KBmKMuCGDdaeQiAKRSJ 7BAIyqbKfwyPsigivu0imsIL/wZO8idTugyaS3Uh3oBta63Tuj5Aq3oPBkP3raw4/dbt vQbixhqk+LyzprF45cq+3739UWx4O1SwT79h7/xVAdeDg1cGqt1SmqiATM16hETa5th5 gkcV1F+Ta3OosoOKT9cY97ukRSGbvjMDXHW/56HBoqiB00Lehl1AscpyWpgYuYddZJa9 1OLQ== X-Gm-Message-State: AOAM533zVni3SKsf3pGS8cn7qaHLVXX1OaE1YwxJq7dkuQalAEUk0CS8 8VZN2XEFaDcq7gdN70+hNjuQCA== X-Google-Smtp-Source: ABdhPJw8d0noYcaqrmuUm0oYUt6VCRIRuANK5szIhgF5+nvEpUNbWJNicRVw/Rm/sTOyay6sR7vcPA== X-Received: by 2002:a63:2a86:: with SMTP id q128mr3374314pgq.53.1644324098777; Tue, 08 Feb 2022 04:41:38 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:38 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 23/31] clk: mediatek: mux: Reverse check for existing clk to reduce nesting level Date: Tue, 8 Feb 2022 20:40:26 +0800 Message-Id: <20220208124034.414635-24-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044141_542433_B5C3898A X-CRM114-Status: GOOD ( 12.66 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The clk registration code here currently does: if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) { ... do clk registration ... } This extra level of nesting wastes screen real estate. Reduce the nesting level by reversing the conditional shown above. Other than that, functionality is not changed. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mux.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 01af6a52711a..70aa42144632 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -208,16 +208,17 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, for (i = 0; i < num; i++) { const struct mtk_mux *mux = &muxes[i]; - if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) { - clk = mtk_clk_register_mux(mux, regmap, lock); + if (!IS_ERR_OR_NULL(clk_data->clks[mux->id])) + continue; - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", mux->name, clk); - continue; - } + clk = mtk_clk_register_mux(mux, regmap, lock); - clk_data->clks[mux->id] = clk; + if (IS_ERR(clk)) { + pr_err("Failed to register clk %s: %pe\n", mux->name, clk); + continue; } + + clk_data->clks[mux->id] = clk; } return 0; From patchwork Tue Feb 8 12:40:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738659 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 49E31C433F5 for ; Tue, 8 Feb 2022 13:00:37 +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=HnXziMC0es7glFWavxmLNBxnYXcRnVClYyCUmdjbPW8=; b=QHAhyijbEHs35J WqIqSupjOJZAfNHaOA7f2mmt+d4dhnPfbXUh/njQniJnDOoX6h7DITGeWyI9ihFx3XqY+nijt2sZP d1c9C2Y3XUhAIcBKYvetI0Q1tA7amKnTTOE0GpYsMaWKYJnMZrGNvyiIAMvOFsp+HLVeOJ6eRtckE oDBW4COApS3kVXCJT70cJ7wXE6JOlq4B/Kino0qkBn+EMGP49oGyEJdeKPG+UjR9H0Qg3Vn9+CNKa a0Gfky53hYfKmF4IO+54dKWNdzxE8XjRtwx9opLwYW1ylaWULi3pXgXb7+wauFB432ewPwcPe62Q7 G6e0gl7Pl88SI67aGQSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQ6f-00DvxK-Dz; Tue, 08 Feb 2022 13:00:29 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoT-00DnfB-UP for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:45 +0000 Received: by mail-pf1-x429.google.com with SMTP id d187so18625400pfa.10 for ; Tue, 08 Feb 2022 04:41:41 -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=UxXHG53mykHwbXXXl6QinzYax9pQXchal111embQm8Q=; b=oX4x1gvQjxvxSt4a/L+sGTUd80SmwHzdFN5Di9Fue38kDqvXUicpxO4zseU/lOEIYT cCZpokdDjO6vKZyA+BfDjWw73ltev/kGx/z465m1SrygfkxAGYV584mSARhMIv/6FS3C zKkYrGl7gWKvOYNIBF4QdYZIzlKskCD0Ca5v4= 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=UxXHG53mykHwbXXXl6QinzYax9pQXchal111embQm8Q=; b=HGiNsUb64LSfz71pDsyWR5EsFZbpVFsBArKL4nl9XS+83nhOO+aCQe/aXXImr9mP1L ixif3YC4o0FNYZiMt52sk2ORZU+81wEtGqFKR/zItE9LIp5+c+5kSfdDJSCXxIv8YqlA 5bJLSXO//XMOJwYMwYL6kqbTBJ/aC9oYg5ssgvF5G8hJn7nZUUBsUXqrtqhMvCjMkR9+ K8gmmoqrqlAqURwaHC7g4+4ADu9Ipvd1EbDTvocE9h3P07VdrlHyVTK8lsc45hqPPa1D 73ZumZjThqSX1llVjvZyq4Y79U1JmCAlkHnZP1ubHBW4F6TnE/Yovo2SdYyWcw5dgzSJ wxow== X-Gm-Message-State: AOAM5337u8uw5OLZwas16WlayVPGN5p5gfy4AOltXydDMPMLMrO9D9bj v2b0UA88XWr4GOWMXxEKmre40mYZ4USxpg== X-Google-Smtp-Source: ABdhPJxTJoAFPatZ+sQYfPsLCiW0XuU5pPQ74xytkcecYomRMstYp5V5YnaiscvqnVCpRyddm8Fe7Q== X-Received: by 2002:a05:6a00:1253:: with SMTP id u19mr4397090pfi.8.1644324100988; Tue, 08 Feb 2022 04:41:40 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:40 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 24/31] clk: mediatek: mux: Implement error handling in register API Date: Tue, 8 Feb 2022 20:40:27 +0800 Message-Id: <20220208124034.414635-25-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044142_067171_61539D11 X-CRM114-Status: GOOD ( 13.45 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The mux clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed. Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mux.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 70aa42144632..f51e67650f03 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -215,13 +215,26 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mux->name, clk); - continue; + goto err; } clk_data->clks[mux->id] = clk; } return 0; + +err: + while (--i >= 0) { + const struct mtk_mux *mux = &muxes[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) + continue; + + mtk_clk_unregister_mux(clk_data->clks[mux->id]); + clk_data->clks[mux->id] = ERR_PTR(-ENOENT); + } + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_muxes); From patchwork Tue Feb 8 12:40:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738660 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 94619C433EF for ; Tue, 8 Feb 2022 13:01:30 +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=YZj8kQh9xVjPdSfFXFonJyWLDC3DN/8kQ6ZuX0jNUwI=; b=vy04hEhxNX0FQg HoZNCWry+9PsjSSifTj7LxE5ynr1v1jYBrXc0AcMWLJnKW+XIr+gYrpxaituZwjXtiLOUak9dwNi6 FRCQgH/Nr80C9R7MktQ/dPtTKGCPvAimoBmrh85hp2tbCTQyed/TN2N+IlqSvwDlRWb3Lyw9u9YIF 1lOoSyfhEVC3wKGpHYR778jy+vBpNoG9DPm/LupC5y8FF43F2zCNxh/1itZ/KhSGCDUMWXh0ZBTr8 6c3TwX8kCTh/FbroHCHWt66My4x0Nxa+6NkZSTWOWiD8bGyGW3YqEszA32YcANMiKLzYaXMVedkLS ja07HYQGV/MMR3SNyPvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQ7V-00DwIt-Tr; Tue, 08 Feb 2022 13:01:21 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoV-00DngQ-R9 for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:46 +0000 Received: by mail-pf1-x42d.google.com with SMTP id i186so18703728pfe.0 for ; Tue, 08 Feb 2022 04:41:43 -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=rT0ZvlEjSEX8tKc4measdB3BcCgivnDIA3yZFD+PibQ=; b=kox8FsUbNjIpYMZjXcKa8GmJjInsgqKSj6osghdWW2iJEPN5D0RfPCqjSjc0mBLHm3 cWKgdgVcYOe/kIJnYOhYLE1pzYP7ghXt3SJm85YA6d4HNNzZPzVzFNs0MgtJbmp8p13+ SbAKAiMbVvblV3oKQC17IG7WEoFyeSha3YpuM= 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=rT0ZvlEjSEX8tKc4measdB3BcCgivnDIA3yZFD+PibQ=; b=mChBMjlUEVCY3bl6GsfyxUJRD2x1P7qfY7a7WlZaKtRDj0ScMxCtE9whM4fGWl5hn/ /i1UcTCQ/0LjksuC3fOU2ejEyLg39Yx7+ZZCTGvqwbRPnxQ8tQ/5+0iK1MOYf0ucko4A fJdArn+ellzjz2FL4s88wfpZToXNoWFU2PMfriAd9rdgK/0CECp/rIJDmlkYFGxa8r3/ 7djotj9z/eqy0PUrsw8T0nWLNDKhJlamZyDH3ErIzY7XJyBxudInrG9VoRJLi4T3B1// 9jvbj4bsodgycYbYb5U0SURMc9nB0b4W2UNJxXjMtNQ11dck73Xm6Xyo54/43BI9JjM6 WAjw== X-Gm-Message-State: AOAM531alGEc8BeoYlUyjLa1SBjqeARK66k0LCjLVoBKos+ZEzOQ80aK R5/dSYXF0IY0pG0qqUvpgWVYxA== X-Google-Smtp-Source: ABdhPJx1ycT0FAJzg22IJjUEMsQqtSxdDyCkyduFu9zf4zZCUNd6bsoPyFYslN+f4ib6yI/1sZfQNA== X-Received: by 2002:a62:86c9:: with SMTP id x192mr4244674pfd.54.1644324103129; Tue, 08 Feb 2022 04:41:43 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:42 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 25/31] clk: mediatek: pll: Implement error handling in register API Date: Tue, 8 Feb 2022 20:40:28 +0800 Message-Id: <20220208124034.414635-26-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044144_019237_67F17997 X-CRM114-Status: GOOD ( 15.48 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The pll clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed. Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, and unmap the I/O space, is done in the new error path. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-pll.c | 23 +++++++++++++++++++---- drivers/clk/mediatek/clk-pll.h | 6 +++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 8439d37e354d..817a80293bfc 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -377,8 +377,9 @@ static void mtk_clk_unregister_pll(struct clk *clk) kfree(pll); } -void mtk_clk_register_plls(struct device_node *node, - const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data) +int mtk_clk_register_plls(struct device_node *node, + const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data) { void __iomem *base; int i; @@ -387,7 +388,7 @@ void mtk_clk_register_plls(struct device_node *node, base = of_iomap(node, 0); if (!base) { pr_err("%s(): ioremap failed\n", __func__); - return; + return -EINVAL; } for (i = 0; i < num_plls; i++) { @@ -397,11 +398,25 @@ void mtk_clk_register_plls(struct device_node *node, if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", pll->name, clk); - continue; + goto err; } clk_data->clks[pll->id] = clk; } + + return 0; + +err: + while (--i >= 0) { + const struct mtk_pll_data *pll = &plls[i]; + + mtk_clk_unregister_pll(clk_data->clks[pll->id]); + clk_data->clks[pll->id] = ERR_PTR(-ENOENT); + } + + iounmap(base); + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_plls); diff --git a/drivers/clk/mediatek/clk-pll.h b/drivers/clk/mediatek/clk-pll.h index a889b1e472e7..bf06e44caef9 100644 --- a/drivers/clk/mediatek/clk-pll.h +++ b/drivers/clk/mediatek/clk-pll.h @@ -48,9 +48,9 @@ struct mtk_pll_data { u8 pll_en_bit; /* Assume 0, indicates BIT(0) by default */ }; -void mtk_clk_register_plls(struct device_node *node, - const struct mtk_pll_data *plls, int num_plls, - struct clk_onecell_data *clk_data); +int mtk_clk_register_plls(struct device_node *node, + const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data); void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data); From patchwork Tue Feb 8 12:40:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738661 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 77045C433F5 for ; Tue, 8 Feb 2022 13:02:17 +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=s1Y8YenxZS0h7qM1vmiqsPFpINiAyJDnhS+PgKOspuE=; b=CMMQmb9vA+WGg8 uBnLDSc8A/nNghGIFB4WXSaglYq7vTnD1zjojwuQtY8q+F6pgNai2Y/K0yzmvJS+s2E7mxedVGuva z8AC9Yy7d8B8vU35558HmOnwZV4q/AVd0dVL2qXS56rW+HE3mKupHYDt1uX4VXZPKUJSiKz7tsKql b+EMqwdySPXok5bbb8cuIaojpqmv/UVTlbLvaW/6AXdxLKHK1Oo95ahrlYN6joeZGJd3jpzkKMRY9 3pHwaScNh2zuI+YjOEAe708zqzdFpl2F4vYONQ24d9U3t27jEaGQROyidzAebKtB6/cH0z48EY8J8 vtw7iPYh4jJkVXmMuUnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQ8F-00Dwci-3C; Tue, 08 Feb 2022 13:02:07 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoY-00DnhU-3U for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:49 +0000 Received: by mail-pf1-x435.google.com with SMTP id i17so18619092pfq.13 for ; Tue, 08 Feb 2022 04:41:45 -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=zOlNpEXDepZ4yjtrYbOEiToTrqDlKq5iRLx8moaIIHQ=; b=mpvH+3lilXr1A1JO1zFLSNPtwT6aQRcdbO1xuAOunzhTdBkypDvwK6diRK3aANzkFc AchHtI8htBGnpofq5uUFgsLi5WF8yY0WgvyT6jVevIRsEOhvMlw4L9guuf1KRxzRyxFb hsyLlMDVWBp1rQrE0O/0fvF8n3wjymQkcdRlU= 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=zOlNpEXDepZ4yjtrYbOEiToTrqDlKq5iRLx8moaIIHQ=; b=F5r+CUd5b7g6HDIM3lXm9/goj9j17bR/qp/+/ZhNdThYgLKHl1tAkWjKGFznrRSPc4 xaXBG1AjRwn4hEayNw1mGFgWwoqong/UwM/FGyc7V3sQEyh3MgMK2uMAumygKE4i/TXn XD2Emq7W58/IFOYDZGh91czp98kUrOkUVU4besev2FEvDX8yMwlDPEVLc4xwoMkDXxcs k3bWY5edThSnQDC2zaKYJxubOP7Sjp20hPQZDF1ztG6znHwgnFQX+n/ZRueMBBpzZvO6 1M/kCA6LOgQ9XSp4Rjd6cL0xBEst6leNuTYyz2xAXKi7AjIicDlPwpIY/wFQ+OBZXg3o us7Q== X-Gm-Message-State: AOAM530xB3S7TxK8qbi6liHs6DGMBEBz92/BT72QVDCmQ40iTPBZl8Ix FOje4sNJX0UHMQCIfm4+Gx0kVw== X-Google-Smtp-Source: ABdhPJx3bYQ0yptzfAlsZj/t5fo77StxTCrCRo53y3yujaAJF8VjMwm3Z1dpBlyvAbBVyIdcieibPw== X-Received: by 2002:a05:6a00:1892:: with SMTP id x18mr4206790pfh.20.1644324105289; Tue, 08 Feb 2022 04:41:45 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:45 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 26/31] clk: mediatek: mtk: Implement error handling in register APIs Date: Tue, 8 Feb 2022 20:40:29 +0800 Message-Id: <20220208124034.414635-27-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044146_191565_F41863E6 X-CRM114-Status: GOOD ( 18.40 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The remaining clk registration functions do not stop or return errors if any clk failed to be registered, nor do they implement error handling paths. This may result in a partially working device if any step fails. Make the register functions return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path. This also makes the |struct clk_data *| argument mandatory, as it is used to track the list of clks registered. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 118 ++++++++++++++++++++++++++------- drivers/clk/mediatek/clk-mtk.h | 20 +++--- 2 files changed, 103 insertions(+), 35 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 5618c84e4e08..8f15e9de742e 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -53,16 +53,19 @@ void mtk_free_clk_data(struct clk_onecell_data *clk_data) kfree(clk_data); } -void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, - int num, struct clk_onecell_data *clk_data) +int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, + struct clk_onecell_data *clk_data) { int i; struct clk *clk; + if (!clk_data) + return -ENOMEM; + for (i = 0; i < num; i++) { const struct mtk_fixed_clk *rc = &clks[i]; - if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[rc->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[rc->id])) continue; clk = clk_register_fixed_rate(NULL, rc->name, rc->parent, 0, @@ -70,12 +73,26 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", rc->name, clk); - continue; + goto err; } - if (clk_data) - clk_data->clks[rc->id] = clk; + clk_data->clks[rc->id] = clk; } + + return 0; + +err: + while (--i >= 0) { + const struct mtk_fixed_clk *rc = &clks[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[rc->id])) + continue; + + clk_unregister_fixed_rate(clk_data->clks[rc->id]); + clk_data->clks[rc->id] = ERR_PTR(-ENOENT); + } + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_fixed_clks); @@ -99,16 +116,19 @@ void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int num, } EXPORT_SYMBOL_GPL(mtk_clk_unregister_fixed_clks); -void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, - int num, struct clk_onecell_data *clk_data) +int mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, + struct clk_onecell_data *clk_data) { int i; struct clk *clk; + if (!clk_data) + return -ENOMEM; + for (i = 0; i < num; i++) { const struct mtk_fixed_factor *ff = &clks[i]; - if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[ff->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[ff->id])) continue; clk = clk_register_fixed_factor(NULL, ff->name, ff->parent_name, @@ -116,12 +136,26 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", ff->name, clk); - continue; + goto err; } - if (clk_data) - clk_data->clks[ff->id] = clk; + clk_data->clks[ff->id] = clk; + } + + return 0; + +err: + while (--i >= 0) { + const struct mtk_fixed_factor *ff = &clks[i]; + + 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); } + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_factors); @@ -258,13 +292,16 @@ static void mtk_clk_unregister_composite(struct clk *clk) 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) +int mtk_clk_register_composites(const struct mtk_composite *mcs, int num, + void __iomem *base, spinlock_t *lock, + struct clk_onecell_data *clk_data) { struct clk *clk; int i; + if (!clk_data) + return -ENOMEM; + for (i = 0; i < num; i++) { const struct mtk_composite *mc = &mcs[i]; @@ -275,12 +312,26 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs, if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mc->name, clk); - continue; + goto err; } - if (clk_data) - clk_data->clks[mc->id] = clk; + clk_data->clks[mc->id] = clk; + } + + return 0; + +err: + while (--i >= 0) { + const struct mtk_composite *mc = &mcs[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[mcs->id])) + continue; + + mtk_clk_unregister_composite(clk_data->clks[mc->id]); + clk_data->clks[mc->id] = ERR_PTR(-ENOENT); } + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_composites); @@ -304,17 +355,20 @@ void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int num, } 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) +int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, + void __iomem *base, spinlock_t *lock, + struct clk_onecell_data *clk_data) { struct clk *clk; int i; + if (!clk_data) + return -ENOMEM; + for (i = 0; i < num; i++) { const struct mtk_clk_divider *mcd = &mcds[i]; - if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[mcd->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[mcd->id])) continue; clk = clk_register_divider(NULL, mcd->name, mcd->parent_name, @@ -323,12 +377,26 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mcd->name, clk); - continue; + goto err; } - if (clk_data) - clk_data->clks[mcd->id] = clk; + clk_data->clks[mcd->id] = clk; + } + + return 0; + +err: + while (--i >= 0) { + const struct mtk_clk_divider *mcd = &mcds[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[mcd->id])) + continue; + + mtk_clk_unregister_composite(clk_data->clks[mcd->id]); + clk_data->clks[mcd->id] = ERR_PTR(-ENOENT); } + + return PTR_ERR(clk); } void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 7f902581a115..bf6565aa7319 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -34,8 +34,8 @@ struct mtk_fixed_clk { .rate = _rate, \ } -void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, - struct clk_onecell_data *clk_data); +int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, + struct clk_onecell_data *clk_data); void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int num, struct clk_onecell_data *clk_data); @@ -55,8 +55,8 @@ 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); +int 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); @@ -150,9 +150,9 @@ struct mtk_composite { struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, void __iomem *base, spinlock_t *lock); -void mtk_clk_register_composites(const struct mtk_composite *mcs, - int num, void __iomem *base, spinlock_t *lock, - struct clk_onecell_data *clk_data); +int 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); @@ -178,9 +178,9 @@ struct mtk_clk_divider { .div_width = _width, \ } -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); +int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, + void __iomem *base, spinlock_t *lock, + struct clk_onecell_data *clk_data); void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, struct clk_onecell_data *clk_data); From patchwork Tue Feb 8 12:40:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738662 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 6B74EC433EF for ; Tue, 8 Feb 2022 13:02:29 +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=I+l6T6MQxCKNU9gHPcY/Ogr5Na/n7Px9eyavIWyXi+Y=; b=UYuN/eGZOC57Fy /RDNBjehuuAxBNnRJ4+lJ10VuHxfgT5BqAfZjlhoYtvGG4GtmAiBohuqof9GiQlMXSbiVjYBaC2yy h9HU1JgVyQQWyTe5zgIh4mWeUzqrh0BAHp/Tz++lHI7X6s2uFSEnCTd0lyvMhDr9QmqzBLBE4hsYK NfGqGfVgtcTMvKqeWfe8w/mJlVBmEbUfQCzIlp5E9JzAkO0NR4mg0sVlXg9eE8xErwvkWGSzr3nK8 CIoxAA85cFDAkpczCqluy2T9nqe0h57DsMwV/OIALAGBupdhUdq5CC7gq8A/8YaK7KxkRT0AeDik7 CzwXPvUKdygUPErcVeXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQ8R-00Dwhj-4Q; Tue, 08 Feb 2022 13:02:19 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoa-00DniV-48 for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:49 +0000 Received: by mail-pf1-x434.google.com with SMTP id x65so4133819pfx.12 for ; Tue, 08 Feb 2022 04:41:47 -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=2a4Zov6E++VeMpVDqW+bpg0HKHZjA85AGbm7eJFVTok=; b=UK5/1wa6pFIEPSGIZaow9B/7baK1t3FJYJLgwb//r3zSSqpTXDRnxHEtqo3e0adC3V 3aFMXbNUsIQLBfSowdTPw9DEb+wFWm8V8JuIkNw+9K9ajSZSe3Vko+pogXCBEENcmzOi uPGk6nvYOoXU/ewsdDAwwCjd3kCEl8FyF1iks= 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=2a4Zov6E++VeMpVDqW+bpg0HKHZjA85AGbm7eJFVTok=; b=eh+OAKjxdoFmfTjA4IVl0licDmVMbadCpPq5r2i4y3q1tUjAMh/KIpOR+FDJKkDAIf m555NtOrxhoVedHKN1dCzpZ3WTMzK4On+vsxlpClK+nkCzVBjcq0T7Ei/pFfzRfmRmzZ eepUKJkUo37ja7RZa8G/TfZKe0gD52qECdRfAJAeuWO6BWUzEQ4PoCzaDrMrNxjnO1hv jThQb5CZ0QYWbo2eskPrP2mJWVvnTPKF9r5tjP90CQ8Y3QohwegbLjnkTvp8K8XoLl3y uia/mhPCVLXDS02XAwlP4GlvzNV+pfB4BJtDMnI5pcxN4sVvr2NP2wWvXeRQiKPy7aiw DZ8g== X-Gm-Message-State: AOAM532+KNZC5y1N1lVtKUxmgY/V8TJbw4Jf1O8DLg+VQNm3DA1abgXR JhICPAQdnugJw80V+2BPQaTclg== X-Google-Smtp-Source: ABdhPJxFX/826gPUwmwjQsBpabmmOS6aCRXpKBLH1nSGwHhUQ3qT7hUm02w9dIiJLfy6PTmB2Rv/SQ== X-Received: by 2002:a63:d943:: with SMTP id e3mr3365014pgj.427.1644324107392; Tue, 08 Feb 2022 04:41:47 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:47 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 27/31] clk: mediatek: Unregister clks in mtk_clk_simple_probe() error path Date: Tue, 8 Feb 2022 20:40:30 +0800 Message-Id: <20220208124034.414635-28-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044148_202293_AF1C6CE9 X-CRM114-Status: GOOD ( 11.46 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Until now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths. Now that the library does have APIs to unregister clks, use them in the error path of mtk_clk_simple_probe() to do proper cleanup. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 8f15e9de742e..0e027be0d5fc 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -439,12 +439,14 @@ int mtk_clk_simple_probe(struct platform_device *pdev) r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); if (r) - goto free_data; + goto unregister_clks; platform_set_drvdata(pdev, clk_data); return r; +unregister_clks: + mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data); free_data: mtk_free_clk_data(clk_data); return r; From patchwork Tue Feb 8 12:40:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738671 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 97ACCC433EF for ; Tue, 8 Feb 2022 13:04:05 +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=nDdgk013v3BQWKTVEttWEg1kqTRIezsgtwYg9o5DXp4=; b=39vvJKRaLHdV9m tLNvk+0JbpsJkKbAsn8mNUjbDLq974GgO65uVhwHEDYH5N916YJe6RKDJFt9C1wcC7gw9HCKbQ2hH vfwIMzmGlcaWaz8EFWF22xWc7NYlflHDwH+ioH5Qi0AYHAoliCS7qq22WfEFnDAhKmtA/Sq59qRt8 0PakdVFSMIEAfL86QqQR7Y/dmB63JTMhWcCm5goeKNcGZTViBWcMBAg6gw8LdlHRERDEcg1xcM4Dr wVAOkznGuTaqx9V94OyYHOYo36L+YFNarYReAIEwVyfyWAW7H/QJEh/ebxEK3uC7Mt2xmVcjJbwFa VxK6VtkHiahCe9sYg7SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQA2-00DxPA-0m; Tue, 08 Feb 2022 13:03:58 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoc-00DnjW-41 for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:53 +0000 Received: by mail-pj1-x102e.google.com with SMTP id ki18-20020a17090ae91200b001b8be87e9abso1515160pjb.1 for ; Tue, 08 Feb 2022 04:41:50 -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=f58A/1DtWFAR6i5/+w1ZQ8Tebq6XEefT77x9yip685A=; b=dAxJ1uY0JeJ42b2+NiCsfx/Pt5X/LtfjX+5tx3nMzwMh3jdmABwDd/vi41hBsxB99d HZ3l5hiMF1lnHHafiU/FYqwX5Iv3F41ismnHxX+CoaEKPqW374BHRSMYFQFIMU5Wxl5R uhzZUjCuhr7XtovsJHy2VG1Bp7YRnzc9RnE94= 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=f58A/1DtWFAR6i5/+w1ZQ8Tebq6XEefT77x9yip685A=; b=ukZV4Y6o5qZbWi0oP/7N9SnZ92tEZ8altGUrbf4ir6jUHtJjEcEyeQM7dthWb51BVJ f2pFeU2hph4qoMDyR6v4dpn3s8LE1bB5GFwKCWagvgsb91wriFJYcXv6qVS4l6GSUGB8 T67eT0a6vcC6HqPnx1tekOuTM0YuZfVa7MZCXPa0Q3g5Wg8qOF0pcBxE/zWjv2pmO6PT TlZgEOUc6X7ANOClLoa6qVbrdgdI0YX2aqOswt7ifMQHMoX2pT8eek58ycIpV2t5c3Gk PW5/9FA5iyzFVYq6HpBloLZoFTARldxllgZpclxWk/5pNYkeI6UsahwPDzY0UaFww7eW Buiw== X-Gm-Message-State: AOAM533IXrx0LXMtvuTM94XxtaOjhzb8PdAv+zNt+4M6rh3XoLYHmvRa g8mWCgtApFzbiZG57Z4DzbE3+Q== X-Google-Smtp-Source: ABdhPJxh3EZ7l73kasR4nbML+pFZXLWwRtlMNJHU9EoD3F/hf7VKmbXwT4gY8hNmeA9an1RBHQUbCw== X-Received: by 2002:a17:902:c111:: with SMTP id 17mr3142063pli.96.1644324109514; Tue, 08 Feb 2022 04:41:49 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:49 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 28/31] clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() Date: Tue, 8 Feb 2022 20:40:31 +0800 Message-Id: <20220208124034.414635-29-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044150_255462_0B32D068 X-CRM114-Status: GOOD ( 12.09 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Various small clock controllers only have clock gates, and utilize mtk_clk_simple_probe() as their driver probe function. Now that we have a matching remove function, hook it up for the relevant drivers. This was done with the following command: sed -i -e '/mtk_clk_simple_probe/a \ .remove = mtk_clk_simple_remove,' drivers/clk/mediatek/clk-mt8195-*.c Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mt8195-cam.c | 1 + drivers/clk/mediatek/clk-mt8195-ccu.c | 1 + drivers/clk/mediatek/clk-mt8195-img.c | 1 + drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c | 1 + drivers/clk/mediatek/clk-mt8195-infra_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-ipe.c | 1 + drivers/clk/mediatek/clk-mt8195-mfg.c | 1 + drivers/clk/mediatek/clk-mt8195-peri_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-scp_adsp.c | 1 + drivers/clk/mediatek/clk-mt8195-vdec.c | 1 + drivers/clk/mediatek/clk-mt8195-venc.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp0.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp1.c | 1 + drivers/clk/mediatek/clk-mt8195-wpe.c | 1 + 14 files changed, 14 insertions(+) diff --git a/drivers/clk/mediatek/clk-mt8195-cam.c b/drivers/clk/mediatek/clk-mt8195-cam.c index 3d261fc3848e..e4d00fe6e757 100644 --- a/drivers/clk/mediatek/clk-mt8195-cam.c +++ b/drivers/clk/mediatek/clk-mt8195-cam.c @@ -134,6 +134,7 @@ static const struct of_device_id of_match_clk_mt8195_cam[] = { static struct platform_driver clk_mt8195_cam_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-cam", .of_match_table = of_match_clk_mt8195_cam, diff --git a/drivers/clk/mediatek/clk-mt8195-ccu.c b/drivers/clk/mediatek/clk-mt8195-ccu.c index f846f1d73605..4e326b6301ba 100644 --- a/drivers/clk/mediatek/clk-mt8195-ccu.c +++ b/drivers/clk/mediatek/clk-mt8195-ccu.c @@ -42,6 +42,7 @@ static const struct of_device_id of_match_clk_mt8195_ccu[] = { static struct platform_driver clk_mt8195_ccu_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-ccu", .of_match_table = of_match_clk_mt8195_ccu, diff --git a/drivers/clk/mediatek/clk-mt8195-img.c b/drivers/clk/mediatek/clk-mt8195-img.c index 22b52a8f15fe..12f5c436d075 100644 --- a/drivers/clk/mediatek/clk-mt8195-img.c +++ b/drivers/clk/mediatek/clk-mt8195-img.c @@ -88,6 +88,7 @@ static const struct of_device_id of_match_clk_mt8195_img[] = { static struct platform_driver clk_mt8195_img_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-img", .of_match_table = of_match_clk_mt8195_img, diff --git a/drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c b/drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c index 4ab312eb26a5..fbc809d05072 100644 --- a/drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c +++ b/drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c @@ -58,6 +58,7 @@ static const struct of_device_id of_match_clk_mt8195_imp_iic_wrap[] = { static struct platform_driver clk_mt8195_imp_iic_wrap_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-imp_iic_wrap", .of_match_table = of_match_clk_mt8195_imp_iic_wrap, diff --git a/drivers/clk/mediatek/clk-mt8195-infra_ao.c b/drivers/clk/mediatek/clk-mt8195-infra_ao.c index 5f9b69967459..8ebe3b9415c4 100644 --- a/drivers/clk/mediatek/clk-mt8195-infra_ao.c +++ b/drivers/clk/mediatek/clk-mt8195-infra_ao.c @@ -198,6 +198,7 @@ static const struct of_device_id of_match_clk_mt8195_infra_ao[] = { static struct platform_driver clk_mt8195_infra_ao_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-infra_ao", .of_match_table = of_match_clk_mt8195_infra_ao, diff --git a/drivers/clk/mediatek/clk-mt8195-ipe.c b/drivers/clk/mediatek/clk-mt8195-ipe.c index fc1d42b6ac84..b0d745cf7752 100644 --- a/drivers/clk/mediatek/clk-mt8195-ipe.c +++ b/drivers/clk/mediatek/clk-mt8195-ipe.c @@ -43,6 +43,7 @@ static const struct of_device_id of_match_clk_mt8195_ipe[] = { static struct platform_driver clk_mt8195_ipe_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-ipe", .of_match_table = of_match_clk_mt8195_ipe, diff --git a/drivers/clk/mediatek/clk-mt8195-mfg.c b/drivers/clk/mediatek/clk-mt8195-mfg.c index aca6d9c0837c..9411c556a5a9 100644 --- a/drivers/clk/mediatek/clk-mt8195-mfg.c +++ b/drivers/clk/mediatek/clk-mt8195-mfg.c @@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8195_mfg[] = { static struct platform_driver clk_mt8195_mfg_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-mfg", .of_match_table = of_match_clk_mt8195_mfg, diff --git a/drivers/clk/mediatek/clk-mt8195-peri_ao.c b/drivers/clk/mediatek/clk-mt8195-peri_ao.c index 907a92b22de8..2f6b3bb657db 100644 --- a/drivers/clk/mediatek/clk-mt8195-peri_ao.c +++ b/drivers/clk/mediatek/clk-mt8195-peri_ao.c @@ -54,6 +54,7 @@ static const struct of_device_id of_match_clk_mt8195_peri_ao[] = { static struct platform_driver clk_mt8195_peri_ao_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-peri_ao", .of_match_table = of_match_clk_mt8195_peri_ao, diff --git a/drivers/clk/mediatek/clk-mt8195-scp_adsp.c b/drivers/clk/mediatek/clk-mt8195-scp_adsp.c index 26b4846c5894..e16c383f631b 100644 --- a/drivers/clk/mediatek/clk-mt8195-scp_adsp.c +++ b/drivers/clk/mediatek/clk-mt8195-scp_adsp.c @@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8195_scp_adsp[] = { static struct platform_driver clk_mt8195_scp_adsp_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-scp_adsp", .of_match_table = of_match_clk_mt8195_scp_adsp, diff --git a/drivers/clk/mediatek/clk-mt8195-vdec.c b/drivers/clk/mediatek/clk-mt8195-vdec.c index a1df04f42a90..a1446b666385 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdec.c +++ b/drivers/clk/mediatek/clk-mt8195-vdec.c @@ -96,6 +96,7 @@ static const struct of_device_id of_match_clk_mt8195_vdec[] = { static struct platform_driver clk_mt8195_vdec_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-vdec", .of_match_table = of_match_clk_mt8195_vdec, diff --git a/drivers/clk/mediatek/clk-mt8195-venc.c b/drivers/clk/mediatek/clk-mt8195-venc.c index 7339851a0856..622f57804f96 100644 --- a/drivers/clk/mediatek/clk-mt8195-venc.c +++ b/drivers/clk/mediatek/clk-mt8195-venc.c @@ -61,6 +61,7 @@ static const struct of_device_id of_match_clk_mt8195_venc[] = { static struct platform_driver clk_mt8195_venc_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-venc", .of_match_table = of_match_clk_mt8195_venc, diff --git a/drivers/clk/mediatek/clk-mt8195-vpp0.c b/drivers/clk/mediatek/clk-mt8195-vpp0.c index c3241466a8d0..bf2939c3a023 100644 --- a/drivers/clk/mediatek/clk-mt8195-vpp0.c +++ b/drivers/clk/mediatek/clk-mt8195-vpp0.c @@ -102,6 +102,7 @@ static const struct of_device_id of_match_clk_mt8195_vpp0[] = { static struct platform_driver clk_mt8195_vpp0_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-vpp0", .of_match_table = of_match_clk_mt8195_vpp0, diff --git a/drivers/clk/mediatek/clk-mt8195-vpp1.c b/drivers/clk/mediatek/clk-mt8195-vpp1.c index ce0b9a40a179..ffd52c762890 100644 --- a/drivers/clk/mediatek/clk-mt8195-vpp1.c +++ b/drivers/clk/mediatek/clk-mt8195-vpp1.c @@ -100,6 +100,7 @@ static const struct of_device_id of_match_clk_mt8195_vpp1[] = { static struct platform_driver clk_mt8195_vpp1_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-vpp1", .of_match_table = of_match_clk_mt8195_vpp1, diff --git a/drivers/clk/mediatek/clk-mt8195-wpe.c b/drivers/clk/mediatek/clk-mt8195-wpe.c index 274d60838d8e..b483fab10e18 100644 --- a/drivers/clk/mediatek/clk-mt8195-wpe.c +++ b/drivers/clk/mediatek/clk-mt8195-wpe.c @@ -135,6 +135,7 @@ static const struct of_device_id of_match_clk_mt8195_wpe[] = { static struct platform_driver clk_mt8195_wpe_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name = "clk-mt8195-wpe", .of_match_table = of_match_clk_mt8195_wpe, From patchwork Tue Feb 8 12:40:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738672 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 98D2EC433EF for ; Tue, 8 Feb 2022 13:04:41 +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=c/7hluz1GrsrQnqBeufPtPKCemFAp6KviEuRmDSpILs=; b=WtqO8+zEMhOArl w0XgjODB+6f4pCGajGtF/zlmmfaKlADtY04m4vvigFiZGNv7HBFJRK+p5MnhYu1P9JuIHnX5w+RWl xPMBVZ2XQchlNsId+9gs/pnHKvBjSm8v21vhX6Rln5Zlasd2CCfRhu74HI5E+uDhRJr8qWlP/PnLZ t4fw5JCBHx/w0Ns/zpoIXoMKkwO7+H24i5nwWFFJtUBASaSJGFevUowoX1q9WGpxO9s7kB6DmIjYS ivyIrgS7R7UxuZ1XlqRm3CJnsH+Mb9qvRJ6T8/Ks68KmEXCiIJee+DTOk51laIpP6kEP5Sv75CU93 2l0Nyi+5FF9HZbtPBQ3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQAc-00Dxf3-5e; Tue, 08 Feb 2022 13:04:34 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoe-00Dnku-IE for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:54 +0000 Received: by mail-pf1-x433.google.com with SMTP id d187so18626127pfa.10 for ; Tue, 08 Feb 2022 04:41:52 -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=xQYgt3QgtF2LKqHQFrC88zvLPa0lBRjCLZf9LxJ/ets=; b=PTrB6iawyPIGirYG4b5/ASRbq8cAXNLl2+9H+SsEVOhpHDioapf8D795bOuyB1Vzt+ D7iK/QAZBbVNs3n0Uh48XNOiKVqYmIJcav6+gLIRs2cHTzUwI9XmIC8iudvh87dIKEuE MKrB6vnf59XhrPYB9ENKj6YN1eXJbtBkiWBXU= 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=xQYgt3QgtF2LKqHQFrC88zvLPa0lBRjCLZf9LxJ/ets=; b=B17vLXP2eUIJeVXDO0kKydHEaUUW8Vq5lsZhUL0AmFuoMLFwoJZuZ1PQObmxLaIX7r AsB0M71twd/1mkQIyjph8t7mJ0oZZsFcHy6ZW9fCnHnJguqfRz3+jFtm/fhSfbcwqNKR unt/1qiEA/bVYgNvI2wHLomi5d6iIFVjVa7+VYoeEojsa21EY0IZJ1JlI0iCRQA1rqy4 IEeDrz4BAllHJsfUguzMA0iOxz4+gN2szxBjpguP314fXYIPC3SsLlAl0XITsLrTV2ay cHCbWq80H0xlnHLFeQcVnxCsfJ6jzREC2fW799Yds9MUvweHGPS6VjA0mAa6GXJuxVz5 SspQ== X-Gm-Message-State: AOAM5328ajR7Fh1pitmFxCF0oQOxNzXTculEvExLzVUAXf4/4yWKAt86 0fzwR0M1H8QtGOqeYzSgDaY8YginVytuMw== X-Google-Smtp-Source: ABdhPJye9xIwNE3PNFsoBEXbqwqREmnxZwGI394gtD4ROpx9kUF2yM+rAGbVJ76CmcyLN8yUhD1OGg== X-Received: by 2002:a63:86:: with SMTP id 128mr3314659pga.13.1644324111661; Tue, 08 Feb 2022 04:41:51 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:51 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 29/31] clk: mediatek: mt8195: Implement error handling in probe functions Date: Tue, 8 Feb 2022 20:40:32 +0800 Message-Id: <20220208124034.414635-30-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044152_637244_09CE081F X-CRM114-Status: GOOD ( 14.23 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Until now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths. Now that the library does have APIs to unregister clks, use them in the error path of the probe functions for the mt8195 clk drivers to do proper cleanup. Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 13 ++++-- drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 9 +++- drivers/clk/mediatek/clk-mt8195-topckgen.c | 49 +++++++++++++++----- drivers/clk/mediatek/clk-mt8195-vdo0.c | 4 +- drivers/clk/mediatek/clk-mt8195-vdo1.c | 4 +- 5 files changed, 61 insertions(+), 18 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c index 5b1b7dc447eb..d0fdb5a4a921 100644 --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c @@ -120,17 +120,24 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) if (!clk_data) return -ENOMEM; - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); - r = mtk_clk_register_gates(node, apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); + r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); if (r) goto free_apmixed_data; + r = mtk_clk_register_gates(node, apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); + if (r) + goto unregister_plls; + r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); if (r) - goto free_apmixed_data; + goto unregister_gates; return r; +unregister_gates: + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); +unregister_plls: + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); free_apmixed_data: mtk_free_clk_data(clk_data); return r; diff --git a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c b/drivers/clk/mediatek/clk-mt8195-apusys_pll.c index db449ff877d7..f489b57e325e 100644 --- a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c +++ b/drivers/clk/mediatek/clk-mt8195-apusys_pll.c @@ -66,13 +66,18 @@ static int clk_mt8195_apusys_pll_probe(struct platform_device *pdev) if (!clk_data) return -ENOMEM; - mtk_clk_register_plls(node, apusys_plls, ARRAY_SIZE(apusys_plls), clk_data); - r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + r = mtk_clk_register_plls(node, apusys_plls, ARRAY_SIZE(apusys_plls), clk_data); if (r) goto free_apusys_pll_data; + r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + if (r) + goto unregister_plls; + return r; +unregister_plls: + mtk_clk_unregister_plls(apusys_plls, ARRAY_SIZE(apusys_plls), clk_data); free_apusys_pll_data: mtk_free_clk_data(clk_data); return r; diff --git a/drivers/clk/mediatek/clk-mt8195-topckgen.c b/drivers/clk/mediatek/clk-mt8195-topckgen.c index 3e2aba9c40bb..3631f49a5e5a 100644 --- a/drivers/clk/mediatek/clk-mt8195-topckgen.c +++ b/drivers/clk/mediatek/clk-mt8195-topckgen.c @@ -1239,25 +1239,52 @@ static int clk_mt8195_topck_probe(struct platform_device *pdev) goto free_top_data; } - mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), - top_clk_data); - mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); - mtk_clk_register_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), node, - &mt8195_clk_lock, top_clk_data); - mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes), base, - &mt8195_clk_lock, top_clk_data); - mtk_clk_register_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), base, - &mt8195_clk_lock, top_clk_data); - r = mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks), top_clk_data); + r = mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), + top_clk_data); if (r) goto free_top_data; + r = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); + if (r) + goto unregister_fixed_clks; + + r = mtk_clk_register_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), node, + &mt8195_clk_lock, top_clk_data); + if (r) + goto unregister_factors; + + r = mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes), base, + &mt8195_clk_lock, top_clk_data); + if (r) + goto unregister_muxes; + + r = mtk_clk_register_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), base, + &mt8195_clk_lock, top_clk_data); + if (r) + goto unregister_composite_muxes; + + r = mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks), top_clk_data); + if (r) + goto unregister_composite_divs; + r = of_clk_add_provider(node, of_clk_src_onecell_get, top_clk_data); if (r) - goto free_top_data; + goto unregister_gates; return r; +unregister_gates: + mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data); +unregister_composite_divs: + mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data); +unregister_composite_muxes: + mtk_clk_unregister_composites(top_muxes, ARRAY_SIZE(top_muxes), top_clk_data); +unregister_muxes: + mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data); +unregister_factors: + mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); +unregister_fixed_clks: + mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data); free_top_data: mtk_free_clk_data(top_clk_data); return r; diff --git a/drivers/clk/mediatek/clk-mt8195-vdo0.c b/drivers/clk/mediatek/clk-mt8195-vdo0.c index f7ff7618c714..af34eb564b1d 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdo0.c +++ b/drivers/clk/mediatek/clk-mt8195-vdo0.c @@ -105,10 +105,12 @@ static int clk_mt8195_vdo0_probe(struct platform_device *pdev) r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); if (r) - goto free_vdo0_data; + goto unregister_gates; return r; +unregister_gates: + mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data); free_vdo0_data: mtk_free_clk_data(clk_data); return r; diff --git a/drivers/clk/mediatek/clk-mt8195-vdo1.c b/drivers/clk/mediatek/clk-mt8195-vdo1.c index 03df8eae8838..6b502bbc730c 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdo1.c +++ b/drivers/clk/mediatek/clk-mt8195-vdo1.c @@ -122,10 +122,12 @@ static int clk_mt8195_vdo1_probe(struct platform_device *pdev) r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); if (r) - goto free_vdo1_data; + goto unregister_gates; return r; +unregister_gates: + mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data); free_vdo1_data: mtk_free_clk_data(clk_data); return r; From patchwork Tue Feb 8 12:40:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738673 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 67DEFC433EF for ; Tue, 8 Feb 2022 13:05:33 +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=0stj9F0dUKxJBFHo/kEx434P6PKk2EGuQtR57yWscog=; b=DpKlITGrJUBtXF Gj6xfFByxTecS1I04VKEtUcueMurC4vClSMfnT34oT0K2iba5Rw3aXuUUv/lLFKgP1VzdeFHPhBVb HqKLCeYHki9HYym2SOquN97b9KpiL9RBVYeD2WkeL4KOC2Y/L0MkfNZ7X2FMCImGpNNl+6g/tbP1f 1JMkzg44xd9l2gZYZ5yqT7mF9j6WZTf3rDzLszy4e1JPTG95szYAIuuqFpWW3K+ZuwO+ZmGHHQck0 C+NxjWdS/dbhuadnxAtUkd8xi3409EGTB7Q8qFC8i9BKHE0hgyCs4VSoeznCU6iguwLZ3quwIc9w7 XQSivRYHtwH3GJy9VQcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQBS-00Dy1m-7e; Tue, 08 Feb 2022 13:05:26 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPog-00Dnm0-M2 for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:56 +0000 Received: by mail-pj1-x1034.google.com with SMTP id om7so2928011pjb.5 for ; Tue, 08 Feb 2022 04:41:54 -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=su8yB3PhAikF3CbTDZ6t9xjvJ0+tVV3Q7sMK1qov3u8=; b=dawlL8uPpwEhEdNzpFhriSJEc1UtRFiXuNLnUzi+5qbBM87ysJgWjelVSEpVjER5Jx joGv/TplaF0PTc6D/bNC1/u/UXy0U65BtryhYLyNRH9tBW5x3jFSaV3tmczcjqcWZiQL b+ndNi9SCeiJkOOce7Rr7EGiWg81mozts7FXw= 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=su8yB3PhAikF3CbTDZ6t9xjvJ0+tVV3Q7sMK1qov3u8=; b=uFNU1m3gvkaa5Q0mgRxyGFjGfR6EN72oArkXjN0MHixFHzYFjZffLOzfERXhTGoHBv 53eBxI3F7D01ZxmY3RG96V1NSVsMEQwUsZ4BjSddv4pEkG1c4A+FFME1WpgKFlV6oGn8 FwrhHX9ByMmlwRQebOc3l08nAvVaH9xxfMNqxqa5oXFnb+Hxyg5Kl4tK2Ho+sZYDukGb 6lW2wYzT5coJGapAF8uMKfqw3Tdl85sE9jn91YtPlK0n+eMqMLI/iaFTIy7OjBsZsPCj Y7V/wygG+LjOy4mcH22zkvfU1TKMam3/JtoimQgd/46OKDneqgwyClDPr27e7w6fMbKb gAwA== X-Gm-Message-State: AOAM532tsoywk5j8Mr9BSTs22cNT9lGtfxQMlC6Fzq5AX+pMW5ZQtjWT Mg1cQ+THvv+TKcONuF9GhYwWbg== X-Google-Smtp-Source: ABdhPJzfeIV9hW4JatNPV1xSEsdpC0w96N8R32l6fhq4Zd+WxyYTQiY+H/KMNwMzwxkzPNn53nCdVA== X-Received: by 2002:a17:902:ecc9:: with SMTP id a9mr4084829plh.121.1644324113776; Tue, 08 Feb 2022 04:41:53 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:53 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 30/31] clk: mediatek: mt8195: Implement remove functions Date: Tue, 8 Feb 2022 20:40:33 +0800 Message-Id: <20220208124034.414635-31-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044154_736361_A5DC3AB0 X-CRM114-Status: GOOD ( 15.16 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Until now the mediatek clk driver library did not have any way to unregister clks, and so none of the drivers implemented remove functions. Now that the library does have APIs to unregister clks, use them to implement remove functions for the mt8195 clk drivers. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno --- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 16 ++++++++++++++++ drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 15 +++++++++++++++ drivers/clk/mediatek/clk-mt8195-topckgen.c | 20 ++++++++++++++++++++ drivers/clk/mediatek/clk-mt8195-vdo0.c | 16 ++++++++++++++++ drivers/clk/mediatek/clk-mt8195-vdo1.c | 16 ++++++++++++++++ 5 files changed, 83 insertions(+) diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c index d0fdb5a4a921..eecc7035a56a 100644 --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c @@ -132,6 +132,8 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) if (r) goto unregister_gates; + platform_set_drvdata(pdev, clk_data); + return r; unregister_gates: @@ -143,8 +145,22 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) return r; } +static int clk_mt8195_apmixed_remove(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + struct clk_onecell_data *clk_data = platform_get_drvdata(pdev); + + of_clk_del_provider(node); + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + static struct platform_driver clk_mt8195_apmixed_drv = { .probe = clk_mt8195_apmixed_probe, + .remove = clk_mt8195_apmixed_remove, .driver = { .name = "clk-mt8195-apmixed", .of_match_table = of_match_clk_mt8195_apmixed, diff --git a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c b/drivers/clk/mediatek/clk-mt8195-apusys_pll.c index f489b57e325e..8cd88dfc3283 100644 --- a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c +++ b/drivers/clk/mediatek/clk-mt8195-apusys_pll.c @@ -74,6 +74,8 @@ static int clk_mt8195_apusys_pll_probe(struct platform_device *pdev) if (r) goto unregister_plls; + platform_set_drvdata(pdev, clk_data); + return r; unregister_plls: @@ -83,6 +85,18 @@ static int clk_mt8195_apusys_pll_probe(struct platform_device *pdev) return r; } +static int clk_mt8195_apusys_pll_remove(struct platform_device *pdev) +{ + struct clk_onecell_data *clk_data = platform_get_drvdata(pdev); + struct device_node *node = pdev->dev.of_node; + + of_clk_del_provider(node); + mtk_clk_unregister_plls(apusys_plls, ARRAY_SIZE(apusys_plls), clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + static const struct of_device_id of_match_clk_mt8195_apusys_pll[] = { { .compatible = "mediatek,mt8195-apusys_pll", }, {} @@ -90,6 +104,7 @@ static const struct of_device_id of_match_clk_mt8195_apusys_pll[] = { static struct platform_driver clk_mt8195_apusys_pll_drv = { .probe = clk_mt8195_apusys_pll_probe, + .remove = clk_mt8195_apusys_pll_remove, .driver = { .name = "clk-mt8195-apusys_pll", .of_match_table = of_match_clk_mt8195_apusys_pll, diff --git a/drivers/clk/mediatek/clk-mt8195-topckgen.c b/drivers/clk/mediatek/clk-mt8195-topckgen.c index 3631f49a5e5a..b602fcd7f1d1 100644 --- a/drivers/clk/mediatek/clk-mt8195-topckgen.c +++ b/drivers/clk/mediatek/clk-mt8195-topckgen.c @@ -1271,6 +1271,8 @@ static int clk_mt8195_topck_probe(struct platform_device *pdev) if (r) goto unregister_gates; + platform_set_drvdata(pdev, top_clk_data); + return r; unregister_gates: @@ -1290,8 +1292,26 @@ static int clk_mt8195_topck_probe(struct platform_device *pdev) return r; } +static int clk_mt8195_topck_remove(struct platform_device *pdev) +{ + struct clk_onecell_data *top_clk_data = platform_get_drvdata(pdev); + struct device_node *node = pdev->dev.of_node; + + of_clk_del_provider(node); + mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data); + mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data); + mtk_clk_unregister_composites(top_muxes, ARRAY_SIZE(top_muxes), top_clk_data); + mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data); + mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); + mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data); + mtk_free_clk_data(top_clk_data); + + return 0; +} + static struct platform_driver clk_mt8195_topck_drv = { .probe = clk_mt8195_topck_probe, + .remove = clk_mt8195_topck_remove, .driver = { .name = "clk-mt8195-topck", .of_match_table = of_match_clk_mt8195_topck, diff --git a/drivers/clk/mediatek/clk-mt8195-vdo0.c b/drivers/clk/mediatek/clk-mt8195-vdo0.c index af34eb564b1d..3bc7ed19d550 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdo0.c +++ b/drivers/clk/mediatek/clk-mt8195-vdo0.c @@ -107,6 +107,8 @@ static int clk_mt8195_vdo0_probe(struct platform_device *pdev) if (r) goto unregister_gates; + platform_set_drvdata(pdev, clk_data); + return r; unregister_gates: @@ -116,8 +118,22 @@ static int clk_mt8195_vdo0_probe(struct platform_device *pdev) return r; } +static int clk_mt8195_vdo0_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *node = dev->parent->of_node; + struct clk_onecell_data *clk_data = platform_get_drvdata(pdev); + + of_clk_del_provider(node); + mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + static struct platform_driver clk_mt8195_vdo0_drv = { .probe = clk_mt8195_vdo0_probe, + .remove = clk_mt8195_vdo0_remove, .driver = { .name = "clk-mt8195-vdo0", }, diff --git a/drivers/clk/mediatek/clk-mt8195-vdo1.c b/drivers/clk/mediatek/clk-mt8195-vdo1.c index 6b502bbc730c..90c738a85ff1 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdo1.c +++ b/drivers/clk/mediatek/clk-mt8195-vdo1.c @@ -124,6 +124,8 @@ static int clk_mt8195_vdo1_probe(struct platform_device *pdev) if (r) goto unregister_gates; + platform_set_drvdata(pdev, clk_data); + return r; unregister_gates: @@ -133,8 +135,22 @@ static int clk_mt8195_vdo1_probe(struct platform_device *pdev) return r; } +static int clk_mt8195_vdo1_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *node = dev->parent->of_node; + struct clk_onecell_data *clk_data = platform_get_drvdata(pdev); + + of_clk_del_provider(node); + mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + static struct platform_driver clk_mt8195_vdo1_drv = { .probe = clk_mt8195_vdo1_probe, + .remove = clk_mt8195_vdo1_remove, .driver = { .name = "clk-mt8195-vdo1", }, From patchwork Tue Feb 8 12:40:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12738674 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 49A9FC433F5 for ; Tue, 8 Feb 2022 13:05:37 +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=SwWbQlCy3DmiHLK3QV/Asb23xA8kHCIlKb8ig3OuE94=; b=fPkeDV23kcjhUn P/nsp/4EcELNG5Gv0kMrnju3N31JDV/NnQmvIH56h7O9GwleSqKcnzajSGYof1psE2ufHrMILQMHF u7ZFj/qp/rXlWHxqzl2P2KeriwHgQgsLAFw8kokEoawnEdz4tpxWeBCuc67BJEpYnYfh5AiYr14Ps NxMvDf0XJKB/3ppyMvVTF5X7HD3dtP+8pEIOmSW9XfvfJ8VfTTmt3ja1+8g5wu4o7a+6iOA3XflYA 3dAfv4sTyi02RkJudWB4q61S+cyKpgZJPIcBU8rtSrFej0cJLveabJHcIgRmsxiIsvkUr3jlMroFT DqK2oURR2uetj2Tld0LA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQBV-00Dy3K-Nm; Tue, 08 Feb 2022 13:05:29 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoi-00DnnB-F8 for linux-mediatek@lists.infradead.org; Tue, 08 Feb 2022 12:41:58 +0000 Received: by mail-pf1-x436.google.com with SMTP id b3so153729pfg.7 for ; Tue, 08 Feb 2022 04:41:56 -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=0/UlhVOdAnU6SizqlzMjYxwU3c7ZqzxGr+vvCSOLKss=; b=Dt9AfISg1ZkV2/kJIuMU7nn3K/UEJs+AGGZj8+C5VXuJC8f63RU3oHLEdy9b8qg0Fg OIZGnUKyWeUx7BNKIzEk6KZpYCY/PaEfTafdqxdOo7NYXsCiZYdqCw2lTVTBCRUEluFk YpenvdzYfy2uJ64eQm34eHRCyq8MUrHb39Fz8= 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=0/UlhVOdAnU6SizqlzMjYxwU3c7ZqzxGr+vvCSOLKss=; b=qeFMQyTMMzp8GhmVjDSVLh3ka8KvoZZVUfTxRMGdPNKxgD9BCJKIwKxjk6irmtKKnn vi/lqqzsHMmWx6/jIqJ5pZ/iDW23ianNh922CsT9QG2UDc7bhA/dktXMEDrF/ijFNTQA tizirkwd1wVakBad93JO3b96/upVIah9qt3bMfKQ5ewH6Eb57owKgKB0F2A1yiuqKH+g pbqIZXmd1NxzICx9VYimaHJTmeTHRnnTDCI0m+7HHV4/eaqPr0m5hzx7LQzSHxFQAVl7 AKVB0JPCl+SZDS1lb38XUBoIK8yVHYK4DEF2dnhjD6QPeSwBfLSNl9aTCu1XqBveaOLb GLxQ== X-Gm-Message-State: AOAM530z/NIoDCG3OFDhLl6UHMF/gwNtLiN3x/OYbLA8ejz+VJsPBZeS TI6oFqvsw9itC3i1l88TqgL/Jw== X-Google-Smtp-Source: ABdhPJwhJLcvpb8S62B7N3C1BWrhd9hXr0mGHQTU2r1oJfFvkqMkkgu1//UJNeCPWx6z8TnlXiIHUA== X-Received: by 2002:aa7:8bcf:: with SMTP id s15mr4185498pfd.16.1644324115911; Tue, 08 Feb 2022 04:41:55 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:55 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 31/31] clk: mediatek: Warn if clk IDs are duplicated Date: Tue, 8 Feb 2022 20:40:34 +0800 Message-Id: <20220208124034.414635-32-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_044156_603516_1C9E9EB5 X-CRM114-Status: GOOD ( 13.34 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The Mediatek clk driver library handles duplicate clock IDs in two different ways: either ignoring the duplicate entry, or overwriting the old clk. Either way may cause unexpected behavior, and the latter also causes an orphan clk that cannot be cleaned up. Align the behavior so that later duplicate entries are ignored, and a warning printed. The warning will also aid in making the issue noticeable. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno --- drivers/clk/mediatek/clk-cpumux.c | 6 ++++++ drivers/clk/mediatek/clk-gate.c | 5 ++++- drivers/clk/mediatek/clk-mtk.c | 18 ++++++++++++++---- drivers/clk/mediatek/clk-mux.c | 5 ++++- drivers/clk/mediatek/clk-pll.c | 6 ++++++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.c index 499c60432280..c11b3fae622e 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -120,6 +120,12 @@ int mtk_clk_register_cpumuxes(struct device_node *node, for (i = 0; i < num; i++) { const struct mtk_composite *mux = &clks[i]; + if (!IS_ERR_OR_NULL(clk_data->clks[mux->id])) { + pr_warn("%pOF: Trying to register duplicate clock ID: %d\n", + node, mux->id); + continue; + } + clk = mtk_clk_register_cpumux(mux, regmap); if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mux->name, clk); diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c index 631ff170b7b9..da52023f8455 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -224,8 +224,11 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, for (i = 0; i < num; i++) { const struct mtk_gate *gate = &clks[i]; - if (!IS_ERR_OR_NULL(clk_data->clks[gate->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[gate->id])) { + pr_warn("%pOF: Trying to register duplicate clock ID: %d\n", + node, gate->id); continue; + } clk = mtk_clk_register_gate(gate->name, gate->parent_name, regmap, diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 0e027be0d5fc..b4063261cf56 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -65,8 +65,10 @@ int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, for (i = 0; i < num; i++) { const struct mtk_fixed_clk *rc = &clks[i]; - if (!IS_ERR_OR_NULL(clk_data->clks[rc->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[rc->id])) { + pr_warn("Trying to register duplicate clock ID: %d\n", rc->id); continue; + } clk = clk_register_fixed_rate(NULL, rc->name, rc->parent, 0, rc->rate); @@ -128,8 +130,10 @@ int mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, for (i = 0; i < num; i++) { const struct mtk_fixed_factor *ff = &clks[i]; - if (!IS_ERR_OR_NULL(clk_data->clks[ff->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[ff->id])) { + pr_warn("Trying to register duplicate clock ID: %d\n", ff->id); continue; + } clk = clk_register_fixed_factor(NULL, ff->name, ff->parent_name, CLK_SET_RATE_PARENT, ff->mult, ff->div); @@ -305,8 +309,11 @@ int mtk_clk_register_composites(const struct mtk_composite *mcs, int num, for (i = 0; i < num; i++) { const struct mtk_composite *mc = &mcs[i]; - if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[mc->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[mc->id])) { + pr_warn("Trying to register duplicate clock ID: %d\n", + mc->id); continue; + } clk = mtk_clk_register_composite(mc, base, lock); @@ -368,8 +375,11 @@ int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, for (i = 0; i < num; i++) { const struct mtk_clk_divider *mcd = &mcds[i]; - if (!IS_ERR_OR_NULL(clk_data->clks[mcd->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[mcd->id])) { + pr_warn("Trying to register duplicate clock ID: %d\n", + mcd->id); continue; + } clk = clk_register_divider(NULL, mcd->name, mcd->parent_name, mcd->flags, base + mcd->div_reg, mcd->div_shift, diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index f51e67650f03..21ad5a4afd65 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -208,8 +208,11 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, for (i = 0; i < num; i++) { const struct mtk_mux *mux = &muxes[i]; - if (!IS_ERR_OR_NULL(clk_data->clks[mux->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[mux->id])) { + pr_warn("%pOF: Trying to register duplicate clock ID: %d\n", + node, mux->id); continue; + } clk = mtk_clk_register_mux(mux, regmap, lock); diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 817a80293bfc..ccaa2085ab4d 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -394,6 +394,12 @@ int mtk_clk_register_plls(struct device_node *node, for (i = 0; i < num_plls; i++) { const struct mtk_pll_data *pll = &plls[i]; + if (!IS_ERR_OR_NULL(clk_data->clks[pll->id])) { + pr_warn("%pOF: Trying to register duplicate clock ID: %d\n", + node, pll->id); + continue; + } + clk = mtk_clk_register_pll(pll, base); if (IS_ERR(clk)) {