From patchwork Thu Sep 26 11:29:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 174475 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1921085ill; Thu, 26 Sep 2019 04:31:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV2Nkcjpg2KOhavseXJtCIhIU8cAFymxdYP9dDgC5Jk5SvY3PnabxivSPxi1Xm7QsanhjG X-Received: by 2002:a50:9734:: with SMTP id c49mr3016970edb.93.1569497518322; Thu, 26 Sep 2019 04:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569497518; cv=none; d=google.com; s=arc-20160816; b=XZlBhcomNr14CMFRIo2gJVeDE3aJcPiaQOErANqlizeW00VuW0VGS1lqlqxi57ooxF JY/bYzVssEtUX3C6Q63dafWcpRn/zHAO8Ct1+SkV4EdxBCT6XrAAbbq2gUBgJ1nEYr6f LAXDiSz2Ceu6nkzYmGOtTz8p87xC3YXiYrdgZ2mLvsCux7NawEog9gsIiuY294YY7ALp GG16Dopy4yNvCWpT0rgD7Z2ptORAfryfZgY/FT5wyUGt1mdVxplCq9ZvPx3f0uDbLD5q q3p4QuQbVTPV/uHC2V0MIDDj02qCrn06omJauijM2hwJIbLRNyomCgaoyRWNGZosw64Z b5aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=CVQLahlcO/peyrVMGcW0P4vLEQL8s6mVGnyOrqGBh9U=; b=zhAjzQf44hkxt+nvOgJGdPfWn1LyKhVL1aGqCv1NbpLscQtKHURB9v+3UpIl1De0b1 ZB33gUSXVgSf+LX7jPJa+alxIiiC5p/57i8uhrpzsw5Myi5VWU0CcbbzBrPsKKfD+9D4 psFOOiqZvUqD/fFGOpE7e7EeoniJ0mCbJU16uuSenXiuzhFj+zs/eNFbHh9NRF+rNDqn vxX1SWT0Oh8RG85e0/zVUUEl8LbtL1exy5Aq6/q+0lg1Qpeiw0XUC35UqR7/97hyAxy5 CKAH3ai8gQMVco0ZWJFnhPi76870Me1j8G6vKoG6ti05JkHJQV0kMqMGvnclbhnu2T/y fXhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=jpWByUMO; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i16si833864ejc.140.2019.09.26.04.31.58; Thu, 26 Sep 2019 04:31:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=jpWByUMO; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726824AbfIZLbz (ORCPT + 8 others); Thu, 26 Sep 2019 07:31:55 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:50206 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726710AbfIZLbx (ORCPT ); Thu, 26 Sep 2019 07:31:53 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8QBVj3F026099; Thu, 26 Sep 2019 06:31:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1569497505; bh=CVQLahlcO/peyrVMGcW0P4vLEQL8s6mVGnyOrqGBh9U=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=jpWByUMOSWnhI+HLdzHyh6cGR4z7onhGpi0yIN67E2Acv/Gdwx+zrUqnsiFQpqLPz An/WIkWTeFcaFcFfvxg8uao/Ggny5+Vi0mGzVvHlTPl+ei7nQ7xOzVS2vL82FN8IAB d8PJ8cFhWJtu7FqNnivJBURZKKCgCb7zmVpmW5uw= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8QBVj5h092389 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 26 Sep 2019 06:31:45 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 26 Sep 2019 06:31:37 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 26 Sep 2019 06:31:44 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8QBUTkA069017; Thu, 26 Sep 2019 06:31:41 -0500 From: Kishon Vijay Abraham I To: Bjorn Helgaas , Jonathan Corbet , Rob Herring , Jon Mason , Dave Jiang , Allen Hubbe , Lorenzo Pieralisi CC: Mark Rutland , , , , , , Subject: [RFC PATCH 17/21] PCI: endpoint: *_free_bar() to return error codes on failure Date: Thu, 26 Sep 2019 16:59:29 +0530 Message-ID: <20190926112933.8922-18-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190926112933.8922-1-kishon@ti.com> References: <20190926112933.8922-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Modify pci_epc_get_next_free_bar() and pci_epc_get_first_free_bar() to return error values if there are no free BARs available. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-epc-core.c | 9 ++++----- include/linux/pci-epc.h | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 33c745546a42..a93c78488bca 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -173,8 +173,7 @@ EXPORT_SYMBOL_GPL(of_pci_epc_get_by_name); * Invoke to get the first unreserved BAR that can be used by the endpoint * function. For any incorrect value in reserved_bar return '0'. */ -unsigned int pci_epc_get_first_free_bar(const struct pci_epc_features - *epc_features) +int pci_epc_get_first_free_bar(const struct pci_epc_features *epc_features) { return pci_epc_get_next_free_bar(epc_features, BAR_0); } @@ -188,8 +187,8 @@ EXPORT_SYMBOL_GPL(pci_epc_get_first_free_bar); * Invoke to get the next unreserved BAR starting from @bar that can be used * for endpoint function. For any incorrect value in reserved_bar return '0'. */ -unsigned int pci_epc_get_next_free_bar(const struct pci_epc_features - *epc_features, enum pci_barno bar) +int pci_epc_get_next_free_bar(const struct pci_epc_features + *epc_features, enum pci_barno bar) { unsigned long free_bar; @@ -209,7 +208,7 @@ unsigned int pci_epc_get_next_free_bar(const struct pci_epc_features free_bar = find_next_zero_bit(&free_bar, 6, bar); if (free_bar > 5) - return 0; + return -EINVAL; return free_bar; } diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index 0632a4d4714d..ad8021b0efb7 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -227,10 +227,9 @@ void pci_epc_of_parse_header(struct device_node *node, struct pci_epf_header *header); const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc, u8 func_no, u8 vfunc_no); -unsigned int pci_epc_get_first_free_bar(const struct pci_epc_features - *epc_features); -unsigned int pci_epc_get_next_free_bar(const struct pci_epc_features - *epc_features, enum pci_barno bar); +int pci_epc_get_first_free_bar(const struct pci_epc_features *epc_features); +int pci_epc_get_next_free_bar(const struct pci_epc_features + *epc_features, enum pci_barno bar); struct pci_epc *pci_epc_get(const char *epc_name); void pci_epc_put(struct pci_epc *epc); struct pci_epc *of_pci_epc_get(struct device_node *node, int index);