Received: by 10.192.165.148 with SMTP id m20csp3413539imm; Sun, 29 Apr 2018 22:51:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqiooxRvZ5MrJO0MczSaXBde8KFxKDZ8+9hbnz6Wzf90Lw4GE3t1XQxS3juHDBlg7w0d2LT X-Received: by 2002:a17:902:b492:: with SMTP id y18-v6mr11194782plr.2.1525067471059; Sun, 29 Apr 2018 22:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525067471; cv=none; d=google.com; s=arc-20160816; b=ORT2b8nqV+ZR5oxrWFTrT15Bm6w8e67XiarU4Z1rrwjT/WbqRO8qOgdrpPibCYGLIP Z+qQ/Fe1Yc2Ts+KYq86r9KMoncJ/AW8swY48u1Vzu6dqACGOWrIctN4HXf95S1JfLB/L kAvHq618a6qpIre+yZzSB5vNx4crDtDvJfRuRbLTQkgqESBoiDT71yp02pc5mYnb26a8 81Zif/tCc9e0OWIXQL3dcFnGV/Y814KAXAMLabl2rJj2sEyDZXi4prLT12uyCMk/LC7a qb2Wqju2rOe24AjR1vlSCGuq5pQUbrW1SRCqB3LMMQY+786SiQbR8rjAW+6loypdFp2f Nu1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:to:from :arc-authentication-results; bh=/8WqmZa4S9Z1reyDIjy79ReSbj1WYT7+TDqI1XcnmxI=; b=SWkz9dfUbJX57P2LMaQm4HUhFkShZrJ0SIPZ9i+s+4XY51pTGQxBPbxpNhPhOKzh2U r6kXD2C2AVuOcmkTuq1sIhS/CQTDM623bJpT4I639RkTp1+DMLhjBExxTNjlo3d/tgse tBTlU/c1DGRux4EfAjlAWujnjn/Ew3TezpouLXnOCvShClgyinSq4vsIISIXFXBxFafL 5RwgCTzTkH3eOV3Vke3x/EADnsu8GolASBs8eQ7EcSFs73lgqU/MvponJ5aAoO1WP90w HSoMRErJTIbslEPhi4es921uRujdpm+tbWfW/+3Xa0pZ+t9OIAPhQr2/d7r9dWCgnFi/ I3qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c131si6682859pfg.108.2018.04.29.22.50.57; Sun, 29 Apr 2018 22:51:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752215AbeD3FuQ (ORCPT + 99 others); Mon, 30 Apr 2018 01:50:16 -0400 Received: from david.siemens.de ([192.35.17.14]:41495 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751575AbeD3FtQ (ORCPT ); Mon, 30 Apr 2018 01:49:16 -0400 Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w3U5ml4G013610 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Apr 2018 07:48:47 +0200 Received: from md1f2u6c.ww002.siemens.net ([167.87.54.87]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w3U5mj6t003250; Mon, 30 Apr 2018 07:48:46 +0200 From: Jan Kiszka To: Bjorn Helgaas , Linux Kernel Mailing List , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 03/10] PCI: Factor out __of_pci_get_host_bridge_resources() Date: Mon, 30 Apr 2018 07:48:37 +0200 Message-Id: <35efe707d03c886f1ac1e0c9634810c9da59c88a.1525067324.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kiszka This will be needed for sharing the core logic between current of_pci_get_host_bridge_resources() and upcoming devm_of_pci_get_host_bridge_resources(). Already rename the dev parameter to dev_node in order to free the namespace for a real device parameter. No functional changes. Signed-off-by: Jan Kiszka --- drivers/pci/of.c | 63 ++++++++++++++++++++++++++++---------------------- include/linux/of_pci.h | 4 ++-- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index a28355c273ae..375de447a58e 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -243,26 +243,8 @@ void of_pci_check_probe_only(void) EXPORT_SYMBOL_GPL(of_pci_check_probe_only); #if defined(CONFIG_OF_ADDRESS) -/** - * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT - * @dev: device node of the host bridge having the range property - * @busno: bus number associated with the bridge root bus - * @bus_max: maximum number of buses for this bridge - * @resources: list where the range of resources will be added after DT parsing - * @io_base: pointer to a variable that will contain on return the physical - * address for the start of the I/O range. Can be NULL if the caller doesn't - * expect I/O ranges to be present in the device tree. - * - * It is the caller's job to free the @resources list. - * - * This function will parse the "ranges" property of a PCI host bridge device - * node and setup the resource mapping based on its content. It is expected - * that the property conforms with the Power ePAPR document. - * - * It returns zero if the range parsing has been successful or a standard error - * value if it failed. - */ -int of_pci_get_host_bridge_resources(struct device_node *dev, +static int __of_pci_get_host_bridge_resources( + struct device_node *dev_node, unsigned char busno, unsigned char bus_max, struct list_head *resources, resource_size_t *io_base) { @@ -281,15 +263,15 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, if (!bus_range) return -ENOMEM; - pr_info("host bridge %pOF ranges:\n", dev); + pr_info("host bridge %pOF ranges:\n", dev_node); - err = of_pci_parse_bus_range(dev, bus_range); + err = of_pci_parse_bus_range(dev_node, bus_range); if (err) { bus_range->start = busno; bus_range->end = bus_max; bus_range->flags = IORESOURCE_BUS; pr_info(" No bus range found for %pOF, using %pR\n", - dev, bus_range); + dev_node, bus_range); } else { if (bus_range->end > bus_range->start + bus_max) bus_range->end = bus_range->start + bus_max; @@ -297,7 +279,7 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, pci_add_resource(resources, bus_range); /* Check for ranges property */ - err = of_pci_range_parser_init(&parser, dev); + err = of_pci_range_parser_init(&parser, dev_node); if (err) goto parse_failed; @@ -327,7 +309,7 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, goto parse_failed; } - err = of_pci_range_to_resource(&range, dev, res); + err = of_pci_range_to_resource(&range, dev_node, res); if (err) { kfree(res); continue; @@ -336,13 +318,13 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, if (resource_type(res) == IORESOURCE_IO) { if (!io_base) { pr_err("I/O range found for %pOF. Please provide an io_base pointer to save CPU base address\n", - dev); + dev_node); err = -EINVAL; goto conversion_failed; } if (*io_base != (resource_size_t)OF_BAD_ADDR) pr_warn("More than one I/O resource converted for %pOF. CPU base address for old range lost!\n", - dev); + dev_node); *io_base = range.cpu_addr; } @@ -359,6 +341,33 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, pci_free_resource_list(resources); return err; } + +/** + * of_pci_get_host_bridge_resources() - Parse PCI host bridge resources from DT + * @dev_node: device node of the host bridge having the range property + * @busno: bus number associated with the bridge root bus + * @bus_max: maximum number of buses for this bridge + * @resources: list where the range of resources will be added after DT parsing + * @io_base: pointer to a variable that will contain on return the physical + * address for the start of the I/O range. Can be NULL if the caller doesn't + * expect I/O ranges to be present in the device tree. + * + * It is the caller's job to free the @resources list. + * + * This function will parse the "ranges" property of a PCI host bridge device + * node and setup the resource mapping based on its content. It is expected + * that the property conforms with the Power ePAPR document. + * + * It returns zero if the range parsing has been successful or a standard error + * value if it failed. + */ +int of_pci_get_host_bridge_resources(struct device_node *dev_node, + unsigned char busno, unsigned char bus_max, + struct list_head *resources, resource_size_t *io_base) +{ + return __of_pci_get_host_bridge_resources(dev_node, busno, + bus_max, resources, io_base); +} EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources); #endif /* CONFIG_OF_ADDRESS */ diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index 091033a6b836..74eec1943ad2 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -71,11 +71,11 @@ of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin) #endif #if defined(CONFIG_OF_ADDRESS) -int of_pci_get_host_bridge_resources(struct device_node *dev, +int of_pci_get_host_bridge_resources(struct device_node *dev_node, unsigned char busno, unsigned char bus_max, struct list_head *resources, resource_size_t *io_base); #else -static inline int of_pci_get_host_bridge_resources(struct device_node *dev, +static inline int of_pci_get_host_bridge_resources(struct device_node *dev_node, unsigned char busno, unsigned char bus_max, struct list_head *resources, resource_size_t *io_base) { -- 2.13.6