Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp714801iob; Wed, 4 May 2022 06:38:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx744nMiPTqQIAQkxcRGYz8Cx766HViQWwmKid91B37NTwbUdzjkU1/Tuzu2JN8txtfYlfu X-Received: by 2002:a65:6051:0:b0:39d:1b00:e473 with SMTP id a17-20020a656051000000b0039d1b00e473mr17461389pgp.578.1651671534687; Wed, 04 May 2022 06:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651671534; cv=none; d=google.com; s=arc-20160816; b=iOoH2YpCEV5bvVIHavjCsMXseN74D5AfUAv5MrGCVo3P7Jsn/fg85DMaqpZ7VKR/je MCUaDHE/jyJciXY+Lqf2DYn66IuZMr0kbHaBfoj/eDtJD/fXRv4mTR0pvJwMTPdBR28h c/6jgWJ2AxnUtkAPgH0ImHBz2aLcGkAayw25cf+uQR9wdZ+e6UHw/qTCKEQvw5I7G9Wi Frgc0b/hqWZ/Shc4X1U2CL2ROJghTX3xSYKVWR7iZzuuyuAUOWZYL36BI424ykOSwkap EQnkrY9iiJSWMNZy3Q19svtdMSbigBbtF+dYjtCXfBXK5NiXSHZMhPqzKLwiBm07jip8 9tRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=oslhO17dYHGFIhWNNUG9XBnFq2z7WSrBbWWUbSeRRGk=; b=WEw/sNWgdEdN5S1hBKYo8YvHKQMsMIhr3RDUwl0PkjezVaLtEqNJKPQhC1nO5v+IHj kyU6uuh7TM/5HuzMHyLd7SuJ6yE8vqDdKVoUD9DSJNGOdqUpKxGnQLSSV/N3eYsNQFR1 7acNKFVL2C0E9Z4AFSy/1K2wu/TXvl5hg55hY+BOAxxHjNsRGGCbbuRYk4WvLjE/yP9K ipkz1bhrY/poyj23IDkwvP8PfA0gQ+XR7gDaEojFFReGKhaUmuFnDKZ69qfXCb/HjvNz 136YZAAZ2r7kzmsOmaYN9JnT4BV62ANz+IKnqLk0A1H1CONGT3hc0NrVGmMiFAaGCP3R F18Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=hg6fXzul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a170902e5c300b0015904e23e37si11405248plf.59.2022.05.04.06.38.38; Wed, 04 May 2022 06:38:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=hg6fXzul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242948AbiECV1n (ORCPT + 99 others); Tue, 3 May 2022 17:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242900AbiECV1X (ORCPT ); Tue, 3 May 2022 17:27:23 -0400 Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F264D4198D; Tue, 3 May 2022 14:23:36 -0700 (PDT) Received: from mail.baikalelectronics.ru (unknown [192.168.51.25]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 5607716D1; Wed, 4 May 2022 00:24:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.ru 5607716D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1651613050; bh=oslhO17dYHGFIhWNNUG9XBnFq2z7WSrBbWWUbSeRRGk=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=hg6fXzul40AbgnhsWa/mt14/U61QAgb7Tv3MAONU1943Vu6RXmXADFl0MPk+Bfk+N f47aaEzcQRSJ7NvKQAthj2Wp78pYKoRl+Y8A/nDsuzmKSRyVPZ/zaP2NxHe26SsJss +7ysQfqaNQijiR/TRDdb8nRE4OjbTBrwjTUIgy2s= Received: from localhost (192.168.53.207) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 4 May 2022 00:23:36 +0300 From: Serge Semin To: Jingoo Han , Gustavo Pimentel , Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Frank Li , Manivannan Sadhasivam , , Subject: [PATCH v2 11/13] PCI: dwc-plat: Simplify the probe method return value handling Date: Wed, 4 May 2022 00:22:58 +0300 Message-ID: <20220503212300.30105-12-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220503212300.30105-1-Sergey.Semin@baikalelectronics.ru> References: <20220503212300.30105-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The whole switch-case-logic implemented in the DWC PCIe RC/EP probe procedure doesn't seem well thought through. First of all the ret variable is unused in the EP-case and is only partly involved in the RC-case of the switch-case statement, which unnecessary complicates the code. Secondly the probe method will return zero if an unknown mode is detected. That is improbable situation since the OF-device data is initialized only with valid modes, but such code is still wrong at least from maintainability point of view. So let's convert the switch-case part of the probe function to being more coherent. We suggest to use the local ret variable to preserve the status of the case-clauses and return its value from the probe procedure after the work is done. Signed-off-by: Serge Semin Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-designware-plat.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-plat.c b/drivers/pci/controller/dwc/pcie-designware-plat.c index 0c5de87d3cc6..fea785096261 100644 --- a/drivers/pci/controller/dwc/pcie-designware-plat.c +++ b/drivers/pci/controller/dwc/pcie-designware-plat.c @@ -153,20 +153,21 @@ static int dw_plat_pcie_probe(struct platform_device *pdev) return -ENODEV; ret = dw_plat_add_pcie_port(dw_plat_pcie, pdev); - if (ret < 0) - return ret; break; case DW_PCIE_EP_TYPE: if (!IS_ENABLED(CONFIG_PCIE_DW_PLAT_EP)) return -ENODEV; pci->ep.ops = &pcie_ep_ops; - return dw_pcie_ep_init(&pci->ep); + ret = dw_pcie_ep_init(&pci->ep); + break; default: dev_err(dev, "INVALID device type %d\n", dw_plat_pcie->mode); + ret = -EINVAL; + break; } - return 0; + return ret; } static const struct dw_plat_pcie_of_data dw_plat_pcie_rc_of_data = { -- 2.35.1