From patchwork Sat Jan 22 09:17: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: 12720678 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 18EC2C433EF for ; Sat, 22 Jan 2022 09:37: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=eh2V82b9Gv49UKAUOqvIFYL8qdZW33+SK2JLuosbheI=; b=AkBrKNy0RlTgmo s1z/6RlmKkFMq1+S11NxvbN/X7x0dqLb4of34m4SU2W3h/M+A3UtUkiYc4vezT/xHehRXzjOVB0+P rDQNHiSCuaHhR0NTrLzlH7dHbaX1Y8kUCFZe43mDr9DVfsF9/skJZodCxSGGbPL7rzU0x3Y/DAJ/d 94ML5jF6ixa0eOJNQxhRB4EYPpSmjMtegCd4LvEd97/HMU2y0cKPcLv8tjiO7akJQPRLdfHsY0WK7 x1a/wVDhyFvj5zf+VSgKPlO7hdDpXuLOmrDlsxyZik5hXKJU38g33YSg/V0/DVR8n1Kg9+sa68qIy cvlfhdO75VumsRTx70Lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBCok-00GzF2-Ue; Sat, 22 Jan 2022 09:36:19 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBCXo-00Grp0-2U for linux-arm-kernel@lists.infradead.org; Sat, 22 Jan 2022 09:18:50 +0000 Received: by mail-pg1-x533.google.com with SMTP id c5so10237076pgk.12 for ; Sat, 22 Jan 2022 01:18:36 -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=/yYGXqDxo/eWqrROn24aC9cA0IymJmQ8zZXIQFx6Mzg=; b=E3fL9k4nB0J+U7dhnH/244EmdfdD1ulLNX+eG5dBwQJtHMj/EcLeIsfa2TRUuWcGd9 oiNAiHupmkNXYOFsXFJ6LIF2ndolec9H7eZ97eKqnFFN80k3IizBuZjLwuQ1VELWkx31 mochVNtqJ50lh6iJe00VnTcom/Wyt65N6eHLk= 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=/yYGXqDxo/eWqrROn24aC9cA0IymJmQ8zZXIQFx6Mzg=; b=1z5Y8sT/W1n49iS4SVpRfbF/4mu9n3PLg9p3OdiPIf5rK8DBFORCMlp1LizuS6ks1T NdEoTdBJzKzaSY0G2hNPW1MFCrxKgBNh2S+sF3A6sDPWuGP4DP3MW34WAm0/mfUHCKzJ f1q6gEu4IoNhLPMkMlc746EyRDwCIQaBhAGgBPM/1+NplLMD8/WRJun67D0TaR3ti15S 5kqovj6/zkJss+OBJveFeENEZ7OIKvK6z2KOUNXo4M+czdr3fGyOar+8W4b8u9lz5ovP NUpwmPTgGf5qCRefeCOtof4BE0gq+RKLAJksRZ+2hm+dXzy6N13I8EGa8kHeT+CF1+Xl lPIg== X-Gm-Message-State: AOAM5309x5JOU7K0/alod+g27JOBrMw4oDdyLu5Zdbb7oXpy5B+HY8qd vA/D7lVNd9lndfj1g8lyFGOQHMlBe6BFAg== X-Google-Smtp-Source: ABdhPJyf9HKfNksySR0iObSvFPhmBF8ZKz+iwD2Gd4unIv10qS1uI5MvXPoHzlLDKI0sSrcTb0B6jA== X-Received: by 2002:a63:6845:: with SMTP id d66mr5494690pgc.199.1642843115668; Sat, 22 Jan 2022 01:18:35 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:349f:9373:45d9:eb26]) by smtp.gmail.com with ESMTPSA id s1sm1608100pjn.42.2022.01.22.01.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:35 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 23/31] clk: mediatek: mux: Reverse check for existing clk to reduce nesting level Date: Sat, 22 Jan 2022 17:17:23 +0800 Message-Id: <20220122091731.283592-24-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog In-Reply-To: <20220122091731.283592-1-wenst@chromium.org> References: <20220122091731.283592-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220122_011848_187653_9EEED74C X-CRM114-Status: GOOD ( 13.17 ) 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 --- 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;