From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 099CFC2BA4C for ; Wed, 26 Jan 2022 07:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237811AbiAZH3a (ORCPT ); Wed, 26 Jan 2022 02:29:30 -0500 Received: from mailgw01.mediatek.com ([60.244.123.138]:57690 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229681AbiAZH33 (ORCPT ); Wed, 26 Jan 2022 02:29:29 -0500 X-UUID: 9c06bc2794244621985796a3c8538f65-20220126 X-UUID: 9c06bc2794244621985796a3c8538f65-20220126 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 448908259; Wed, 26 Jan 2022 15:29:24 +0800 Received: from mtkexhb01.mediatek.inc (172.21.101.102) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 26 Jan 2022 15:29:23 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkexhb01.mediatek.inc (172.21.101.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 26 Jan 2022 15:29:23 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 26 Jan 2022 15:29:23 +0800 From: Miles Chen To: CC: , , , , , , , Subject: Re: [PATCH 21/31] clk: mediatek: cpumux: Implement error handling in register API Date: Wed, 26 Jan 2022 15:29:23 +0800 Message-ID: <20220126072923.10391-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220122091731.283592-22-wenst@chromium.org> References: <20220122091731.283592-22-wenst@chromium.org> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > --- > 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, > -- > 2.35.0.rc0.227.g00780c9af4-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF32FC2BA4C for ; Wed, 26 Jan 2022 07:33: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=aKy4j8kB8SZPICcRAnA3vub2hWnAwwlrGeN5ocW9VzA=; b=SCnGWm1/hJ5YJN nOO6VqU3JC1x4YB2JRb+B5ALgNoAZo6W94W3JFgap3IvZJnrvU2ZNtZIbConDlAvgV60P0Ncg2ZCX wv78i8EoW+dEkOUQsoeRx49cCYEHSfS2VyoXcS19PlqbUvcQBl/1dHa5GVMPgN5Qp9xA3f81uMewp 9dnrHBMld5O6tnkay33mO/Yac06DUW/59zTCS3aMEKJdraY8tEL0qbF1EEcoZp/hnvop2Y6l5BZQk 0YPbaE8mVT4rM8UWIrV0yjt4Uhk4UNmyBMKeeYmcx6TXa3NfMXzaPs5dcDiMnWNI/hIERpWY8hV+C a+PyOxIxnJ3hyJ8pJBCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCcng-00AYmH-AI; Wed, 26 Jan 2022 07:33:04 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCcnd-00AYlL-5l; Wed, 26 Jan 2022 07:33:02 +0000 X-UUID: 1cbec7249f4c4a8887aab55bd8fd7c44-20220126 X-UUID: 1cbec7249f4c4a8887aab55bd8fd7c44-20220126 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2084511258; Wed, 26 Jan 2022 00:32:58 -0700 Received: from mtkexhb01.mediatek.inc (172.21.101.102) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 Jan 2022 23:29:31 -0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkexhb01.mediatek.inc (172.21.101.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 26 Jan 2022 15:29:23 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 26 Jan 2022 15:29:23 +0800 From: Miles Chen To: CC: , , , , , , , Subject: Re: [PATCH 21/31] clk: mediatek: cpumux: Implement error handling in register API Date: Wed, 26 Jan 2022 15:29:23 +0800 Message-ID: <20220126072923.10391-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220122091731.283592-22-wenst@chromium.org> References: <20220122091731.283592-22-wenst@chromium.org> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220125_233301_254387_9DC97DA3 X-CRM114-Status: GOOD ( 19.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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 > --- > 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, > -- > 2.35.0.rc0.227.g00780c9af4-goog _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46FCEC28CF5 for ; Wed, 26 Jan 2022 07:34: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=7kQAfrMV8eqy9Nbj0OkYNQ9uAe0mut6cTEcSrZMynFc=; b=xuSF3gYPjH0jMV sB0ywc48ugoNq9QT7bA4hnPZp/sF2H2G23CxlU1ZcgLLZkLvjC1t57zs2wZLccrBxyjYoTUtZscmn cDr+ygfeWMWZTJv19OC6itqYu6Z920H1wJLIw8EMuPwiy4cMc9/cQLFtSlm2J904Nwvh76qW6wFck mgH1sZdynGlPgAgs8NE2m4RCJ2nCBkx8wt6qsmL0EW7nKQSTBiWdL1ciDsL88c57Ve5hOG+nvFHTi +HQ++ON+JYnYcOofLg6VRyRNsPwEizIimwZNUhKeyaknurwTSKSRs3P6YAJnIC2wsbrvEwGl+RMVX iNVlxHpmAyfLOS2LMFzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCcnj-00AYmT-R8; Wed, 26 Jan 2022 07:33:08 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCcnd-00AYlL-5l; Wed, 26 Jan 2022 07:33:02 +0000 X-UUID: 1cbec7249f4c4a8887aab55bd8fd7c44-20220126 X-UUID: 1cbec7249f4c4a8887aab55bd8fd7c44-20220126 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2084511258; Wed, 26 Jan 2022 00:32:58 -0700 Received: from mtkexhb01.mediatek.inc (172.21.101.102) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 Jan 2022 23:29:31 -0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkexhb01.mediatek.inc (172.21.101.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 26 Jan 2022 15:29:23 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 26 Jan 2022 15:29:23 +0800 From: Miles Chen To: CC: , , , , , , , Subject: Re: [PATCH 21/31] clk: mediatek: cpumux: Implement error handling in register API Date: Wed, 26 Jan 2022 15:29:23 +0800 Message-ID: <20220126072923.10391-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220122091731.283592-22-wenst@chromium.org> References: <20220122091731.283592-22-wenst@chromium.org> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220125_233301_254387_9DC97DA3 X-CRM114-Status: GOOD ( 19.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > The cpumux clk type 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 > --- > 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, > -- > 2.35.0.rc0.227.g00780c9af4-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel