From patchwork Wed Feb 2 13:48: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: 12733000 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 01868C433F5 for ; Wed, 2 Feb 2022 14:09: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=ZAC15JeOtZ6DhGlLClWrWMOtdO734cVuAagiW5CHxJQ=; b=gli2p2Bv+CoUFE MhrThl6IVh4XEidEjnCR9jKHks1GgiZxAIz9W/BGVbiJp1XHm6Bz07Kkl/cB9sTD1TBy665Cek+VC zn7lCf91QcT5XvT7Hy5EatCXj0LHMTaq4yEE/dmH5OeOgN6zc1ik/qw2dRveZrjigBUTPFhN18zOM uVk26uufaMiXnK65IP87WzZEK0t6/oYbuEdBKmDmkepXpkfjoQfEbY+hrww8wIeYkWt96c8TKXrxU uMbK4FJuFoAOEtqjg0z6WloniCYR1uzXGreQtJ7C7o6P3uwxn0cma20o76Xo59+2UO8PLcVMjte/Q LaEhsS8Ag5YKwoTsq7Fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFGIh-00FY9k-5p; Wed, 02 Feb 2022 14:07:59 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFG1h-00FPNm-4R for linux-arm-kernel@lists.infradead.org; Wed, 02 Feb 2022 13:50:26 +0000 Received: by mail-pl1-x62e.google.com with SMTP id h14so18314401plf.1 for ; Wed, 02 Feb 2022 05:50:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QNRljrWOAeUndIQnSVvEuUfXq7FasZjB3yC6SLPOuYM=; b=U4vn34H0WZLQA8MoBFSj8XH+wsm8GLd/vRb1NzXQolOCQ6oqrB9XEHDXlwVR+0Yef6 wkYdmZeZSVKK9vVy6IiPGuwINl7+oHUyqqzA63Zn+h4F4mV51am7/giIRB415XQRleoF nPc0iVKyIb/sVzkHaTRkm8kkWuk4z/cWbCzx4= 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=QNRljrWOAeUndIQnSVvEuUfXq7FasZjB3yC6SLPOuYM=; b=lBs1ITcl4niLxfQtHO3WyVr+3Y2MTjhk5GcpBFfrHi3bRP22SC3i7Il+T29K8pJkXj JV59etKMdu7gm8/JGd6igXecl1Br51rt4kasZ59s3Bu9d9Jo3n9knDNOjVS/9Z14N3/I rBhYcFmiIrkuqFMOul34spjfznmPAaJRZhHS4PKS5ANK7cBUP00f5U2cQDBE1Q/AWlSr 1JXuEXFOa4+AjKrjo/cVNPGEOlc3hGoLOFzeVCIe35vDdUxSLez78UceejiGu7LTXxLu 9zaqOfST4RIK2BKeiEtRPnIRO/4NY/0pDgf7EUUqFWMmGIk9xwzNTOjLc+0C1vXCa2FX ZDxw== X-Gm-Message-State: AOAM531hSoj4UI3Rt8xyCM344j3yroyHx6aS2WMhxb5UGmP91HwLcWTN nYg8D3gVzhipjfBD2v27HQJIdQ== X-Google-Smtp-Source: ABdhPJxg9luWRJ9r/j2zVez342YUr/p2ncftDzjGtTu9Ak9s1/hRg0GpZyJdP3tIQGpruvbs2nlMjQ== X-Received: by 2002:a17:903:1110:: with SMTP id n16mr32138856plh.120.1643809824608; Wed, 02 Feb 2022 05:50:24 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:78b5:214c:c81:b9aa]) by smtp.gmail.com with ESMTPSA id w19sm27335684pfu.47.2022.02.02.05.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 05:50:24 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , 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 v2 23/31] clk: mediatek: mux: Reverse check for existing clk to reduce nesting level Date: Wed, 2 Feb 2022 21:48:26 +0800 Message-Id: <20220202134834.690675-24-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.rc2.247.g8bbb082509-goog In-Reply-To: <20220202134834.690675-1-wenst@chromium.org> References: <20220202134834.690675-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220202_055025_202165_CFFB31E7 X-CRM114-Status: GOOD ( 14.27 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 --- 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;