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 ACCB6C433EF for ; Tue, 15 Feb 2022 07:03:10 +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: Date:CC:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ltayDl05yp7zq4ciKcrxghQ9nR6lSeu31BXum2tY86I=; b=aB+6PQ+DWRRsXz Z78S9g5+voZrjK7k75Jwm8txOkQZ0dpy3EgG1gV6AYe1Iyz0aqUXhxf3FKM+nS0WNNac+RmwEg14p Zbz7xZxpu21Prn91MMt2aOJxNzPBIGNjJJrfYb12z5aVisDJeUN/0Vv+ArCtOxgWdsrNz5vF0fRL3 NK5Zfd5xbllL5yLCI0jhf+ILvV6x75oKk37cPcd3KVFNiNiJKLse/4aoeDfQtaFcPApWT6K3wenjZ Z/itJssD5Um1Rn4ebE1RG2ydZGB5AeeFNu/m9hvSUnbEsea8Fn4wFJywWw/EqKA77KMsz11L4aWBK XKdVxsoxFOgP2bVYBDnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJrqe-000xA1-8A; Tue, 15 Feb 2022 07:02:04 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJrqa-000x7s-Gv; Tue, 15 Feb 2022 07:02:01 +0000 X-UUID: 93297821465445d49b0028020ba8b361-20220215 X-UUID: 93297821465445d49b0028020ba8b361-20220215 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 891360203; Tue, 15 Feb 2022 00:01:57 -0700 Received: from mtkexhb02.mediatek.inc (172.21.101.103) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 14 Feb 2022 23:01:55 -0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkexhb02.mediatek.inc (172.21.101.103) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Feb 2022 15:01:54 +0800 Received: from mtksdccf07 (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 15 Feb 2022 15:01:54 +0800 Message-ID: <69fdff64fd481dea660576e129d6c049daea1aca.camel@mediatek.com> Subject: Re: [PATCH v3 22/31] clk: mediatek: gate: Implement error handling in register API From: Chun-Jie Chen To: Chen-Yu Tsai , Stephen Boyd , Michael Turquette , Matthias Brugger CC: AngeloGioacchino Del Regno , Miles Chen , , , , Date: Tue, 15 Feb 2022 15:01:53 +0800 In-Reply-To: <20220208124034.414635-23-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> <20220208124034.414635-23-wenst@chromium.org> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220214_230200_604017_713B055C X-CRM114-Status: GOOD ( 19.32 ) 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 On Tue, 2022-02-08 at 20:40 +0800, Chen-Yu Tsai wrote: > 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 < > angelogioacchino.delregno@collabora.com> 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, _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel