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: 12738654 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 3E1E4C433F5 for ; Tue, 8 Feb 2022 13:00: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=Kb864e60m6BeB0zUiaN2rjdGdutZbmvsBncXQn9RFvg=; b=ihbn2ZFKRthCrH HUXBGqszRfRwmPOn07CkPLtRpacqWKhaX26n8km4wm6ID0f3WwfiwknG81UtcfE6pFewCvPvBquY7 PQcdvLx0DoxUckcRSMupGeeVlfI4QH+qgw4wrlFTZKtdYz/y5LIzNfoJOdqU/R27FES6q+bV9wsBo B0cP/aB3hq3+mIJFiXLXdOxeQT6abYrtWaWiY2AmHhc1UGVHVIrA4GbJFNl/RHZIjwL1et2AiBYwy T+yAqcJ5oHjbMO/a/e5vx4hEnriBMnPZms7fEHCe87oA5L/cVDKqhvNdTqO4fSRaxRQX2XxDEmZCr T+U06+HAcvoR8UM8d7iQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHQ4m-00DvGh-1e; Tue, 08 Feb 2022 12:58:33 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHPoR-00DneE-FX for linux-arm-kernel@lists.infradead.org; Tue, 08 Feb 2022 12:41:41 +0000 Received: by mail-pf1-x430.google.com with SMTP id y5so17715604pfe.4 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=0zZm4Dv9NxcxLjVwBlh5RYBeyo2J5iSuo9ChCAXtsEcBbNILXCm6bNijwb7vceKd8n MbMeAxH9wQ3zPOH2SNl9DxpZ27L/D1Qd/WlPuMMHmtHSsPI7e0rnS3C+DgUWIxji8ywK UIWbYAHkYZ/M69PoYNNyt3A9ehna/ysuOqBQe2ILanzruGkld0RkVAS4uNlhGtSy0QKF 6cG98hwNwQoRO1lDyUoejrJhxPy0l8AwNMdN2sianxlZtjyyezFWDIeKTUlcqIuAmejA gucPDPK45OTdLOOP+Y15Kce6k13gZfuvARJBzvAa38fdWgY25cOJMZ3y//YCKktAVLgr IA4A== X-Gm-Message-State: AOAM530Ju5Ya3wAo7utGe+6oG1lJ8yFzCzD8mQPuFnxwtKdCeCu5Zn3G 0oRYTCu0BYeEDSb/ujvuoVUlLQ== 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_044139_581641_2D276E44 X-CRM114-Status: GOOD ( 13.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: , 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 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;