From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> To: linux-pci@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>, Arnd Bergmann <arnd@arndb.de>, Bjorn Helgaas <bhelgaas@google.com>, Will Deacon <will.deacon@arm.com>, Russell King <linux@armlinux.org.uk>, Pratyush Anand <pratyush.anand@gmail.com>, Jingoo Han <jingoohan1@gmail.com>, Rob Herring <robh@kernel.org>, Simon Horman <horms@verge.net.au>, Mingkai Hu <mingkai.hu@freescale.com>, Tanmay Inamdar <tinamdar@apm.com>, Murali Karicheri <m-karicheri2@ti.com>, Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>, Wenrui Li <wenrui.li@rock-chips.com>, Shawn Lin <shawn.lin@rock-chips.com>, Minghuan Lian <minghuan.Lian@freescale.com>, Gabriele Paoloni <gabriele.paoloni@huawei.com>, Thomas Petazzoni <thomas.petazzoni@free-electrons.com>, Joao Pinto <Joao.Pinto@synopsys.com>, Thierry Reding <thierry.reding@gmail.com>, Michal Simek <michal.simek@xilinx.com>, Stanimir Varbanov <svarbanov@mm-sol.com>, Zhou Wang <wangzhou1@hisilicon.com>, Roy Zang <tie-fei.zang@freescale.com>, Matthew Minter <matt@masarand.com>, Linus Walleij <linus.walleij@linaro.org> Subject: [RFT PATCH v2 06/42] PCI: Add devm_pci_alloc_host_bridge() interface Date: Thu, 8 Jun 2017 15:13:06 +0100 [thread overview] Message-ID: <20170608141342.2018-7-lorenzo.pieralisi@arm.com> (raw) In-Reply-To: <20170608141342.2018-1-lorenzo.pieralisi@arm.com> struct pci_host_bridge can be allocated by PCI host bridge drivers which usually allocate and map memory through devm managed interfaces. Add a devm version for the pci_alloc_host_bridge() interface to simplify PCI host controller drivers porting and simplify the drivers failures paths. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Bjorn Helgaas <bhelgaas@google.com> --- Documentation/driver-model/devres.txt | 1 + drivers/pci/probe.c | 24 ++++++++++++++++++++++-- include/linux/pci.h | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index e72587f..ffbc891 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -342,6 +342,7 @@ PER-CPU MEM devm_free_percpu() PCI + devm_pci_alloc_host_bridge() : managed PCI host bridge allocation devm_pci_remap_cfgspace() : ioremap PCI configuration space devm_pci_remap_cfg_resource() : ioremap PCI configuration space resource pcim_enable_device() : after success, all PCI ops become managed diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index cbf0d0c..e3f6965 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -510,14 +510,18 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent) return b; } -static void pci_release_host_bridge_dev(struct device *dev) +static void devm_pci_release_host_bridge_dev(struct device *dev) { struct pci_host_bridge *bridge = to_pci_host_bridge(dev); if (bridge->release_fn) bridge->release_fn(bridge); +} - pci_free_host_bridge(bridge); +static void pci_release_host_bridge_dev(struct device *dev) +{ + devm_pci_release_host_bridge_dev(dev); + pci_free_host_bridge(to_pci_host_bridge(dev)); } struct pci_host_bridge *pci_alloc_host_bridge(size_t priv) @@ -535,6 +539,22 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv) } EXPORT_SYMBOL(pci_alloc_host_bridge); +struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev, + size_t priv) +{ + struct pci_host_bridge *bridge; + + bridge = devm_kzalloc(dev, sizeof(*bridge) + priv, GFP_KERNEL); + if (!bridge) + return NULL; + + INIT_LIST_HEAD(&bridge->windows); + bridge->dev.release = devm_pci_release_host_bridge_dev; + + return bridge; +} +EXPORT_SYMBOL(devm_pci_alloc_host_bridge); + void pci_free_host_bridge(struct pci_host_bridge *bridge) { pci_free_resource_list(&bridge->windows); diff --git a/include/linux/pci.h b/include/linux/pci.h index 5720635..b21308e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -463,6 +463,8 @@ static inline struct pci_host_bridge *pci_host_bridge_from_priv(void *priv) } struct pci_host_bridge *pci_alloc_host_bridge(size_t priv); +struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev, + size_t priv); void pci_free_host_bridge(struct pci_host_bridge *bridge); int pci_register_host_bridge(struct pci_host_bridge *bridge); struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus); -- 2.10.0
WARNING: multiple messages have this Message-ID (diff)
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi) To: linux-arm-kernel@lists.infradead.org Subject: [RFT PATCH v2 06/42] PCI: Add devm_pci_alloc_host_bridge() interface Date: Thu, 8 Jun 2017 15:13:06 +0100 [thread overview] Message-ID: <20170608141342.2018-7-lorenzo.pieralisi@arm.com> (raw) In-Reply-To: <20170608141342.2018-1-lorenzo.pieralisi@arm.com> struct pci_host_bridge can be allocated by PCI host bridge drivers which usually allocate and map memory through devm managed interfaces. Add a devm version for the pci_alloc_host_bridge() interface to simplify PCI host controller drivers porting and simplify the drivers failures paths. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Bjorn Helgaas <bhelgaas@google.com> --- Documentation/driver-model/devres.txt | 1 + drivers/pci/probe.c | 24 ++++++++++++++++++++++-- include/linux/pci.h | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index e72587f..ffbc891 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -342,6 +342,7 @@ PER-CPU MEM devm_free_percpu() PCI + devm_pci_alloc_host_bridge() : managed PCI host bridge allocation devm_pci_remap_cfgspace() : ioremap PCI configuration space devm_pci_remap_cfg_resource() : ioremap PCI configuration space resource pcim_enable_device() : after success, all PCI ops become managed diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index cbf0d0c..e3f6965 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -510,14 +510,18 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent) return b; } -static void pci_release_host_bridge_dev(struct device *dev) +static void devm_pci_release_host_bridge_dev(struct device *dev) { struct pci_host_bridge *bridge = to_pci_host_bridge(dev); if (bridge->release_fn) bridge->release_fn(bridge); +} - pci_free_host_bridge(bridge); +static void pci_release_host_bridge_dev(struct device *dev) +{ + devm_pci_release_host_bridge_dev(dev); + pci_free_host_bridge(to_pci_host_bridge(dev)); } struct pci_host_bridge *pci_alloc_host_bridge(size_t priv) @@ -535,6 +539,22 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv) } EXPORT_SYMBOL(pci_alloc_host_bridge); +struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev, + size_t priv) +{ + struct pci_host_bridge *bridge; + + bridge = devm_kzalloc(dev, sizeof(*bridge) + priv, GFP_KERNEL); + if (!bridge) + return NULL; + + INIT_LIST_HEAD(&bridge->windows); + bridge->dev.release = devm_pci_release_host_bridge_dev; + + return bridge; +} +EXPORT_SYMBOL(devm_pci_alloc_host_bridge); + void pci_free_host_bridge(struct pci_host_bridge *bridge) { pci_free_resource_list(&bridge->windows); diff --git a/include/linux/pci.h b/include/linux/pci.h index 5720635..b21308e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -463,6 +463,8 @@ static inline struct pci_host_bridge *pci_host_bridge_from_priv(void *priv) } struct pci_host_bridge *pci_alloc_host_bridge(size_t priv); +struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev, + size_t priv); void pci_free_host_bridge(struct pci_host_bridge *bridge); int pci_register_host_bridge(struct pci_host_bridge *bridge); struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus); -- 2.10.0
next prev parent reply other threads:[~2017-06-08 14:13 UTC|newest] Thread overview: 139+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-06-08 14:13 [RFT PATCH v2 00/42] PCI: ARM/ARM64: remove pci_fixup_irqs() usage Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 01/42] PCI: xilinx-nwl: Remove nwl_pcie_enable_msi() unused bus parameter Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 02/42] drivers: pci: host: iproc: Convert link check to raw PCI config accessors Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 15:56 ` Ray Jui 2017-06-08 16:36 ` Lorenzo Pieralisi 2017-06-08 16:36 ` Lorenzo Pieralisi 2017-06-11 4:12 ` Oza Oza 2017-06-11 4:12 ` Oza Oza 2017-06-12 16:13 ` Lorenzo Pieralisi 2017-06-12 16:13 ` Lorenzo Pieralisi 2017-06-12 17:40 ` Oza Oza 2017-06-12 18:52 ` Ray Jui 2017-06-13 8:22 ` Oza Oza 2017-06-13 17:18 ` Ray Jui 2017-06-14 13:39 ` Lorenzo Pieralisi 2017-06-14 13:39 ` Lorenzo Pieralisi 2017-06-21 14:39 ` Oza Oza 2017-06-21 14:39 ` Oza Oza 2017-07-19 12:13 ` Oza Oza 2017-07-19 17:48 ` Lorenzo Pieralisi 2017-07-19 17:48 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 03/42] drivers: pci: host: ftpci100: convert IRQ masking " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-16 9:05 ` Linus Walleij 2017-06-16 9:05 ` Linus Walleij 2017-06-08 14:13 ` [RFT PATCH v2 04/42] PCI: Initialize bridge release function at bridge allocation Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 05/42] PCI: Add pci_free_host_bridge interface Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi [this message] 2017-06-08 14:13 ` [RFT PATCH v2 06/42] PCI: Add devm_pci_alloc_host_bridge() interface Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 07/42] drivers: pci: host: ftpci100: Fix host bridge memory leakage Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-16 9:02 ` Linus Walleij 2017-06-16 9:02 ` Linus Walleij 2017-06-08 14:13 ` [RFT PATCH v2 08/42] drivers: pci: host: tegra: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 09/42] PCI: Introduce pci_scan_root_bus_bridge() Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 10/42] PCI: Make pci_register_host_bridge() PCI core internal Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 11/42] ARM: PCI: bios32: Convert PCI scan API to pci_scan_root_bus_bridge() Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 12/42] PCI: designware: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 13/42] PCI: aardvark: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 14/42] PCI: rcar: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 15/42] PCI: iproc: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 16/42] PCI: versatile: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 17/42] PCI: altera: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 18/42] PCI: xilinx: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 19/42] PCI: xgene: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 20/42] PCI: host-common: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 21/42] PCI: rockchip: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 22/42] PCI: xilinx-nwl: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 23/42] PCI: Remove pci_scan_root_bus_msi() Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 24/42] PCI: Build setup-irq.o on all arches Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 25/42] PCI: Add IRQ mapping function pointers to pci_host_bridge struct Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 26/42] PCI: Add pci_assign_irq() function and have pci_fixup_irqs() use it Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 27/42] OF/PCI: Update of_irq_parse_and_map_pci() comment Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 28/42] PCI: Add a call to pci_assign_irq() in pci_device_probe() Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 29/42] ARM: PCI: Remove pci_fixup_irqs() call for bios32 host controllers Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-07-01 14:06 ` Lorenzo Pieralisi 2017-07-01 14:06 ` Lorenzo Pieralisi 2017-07-02 21:19 ` Bjorn Helgaas 2017-07-02 21:19 ` Bjorn Helgaas 2017-07-03 10:26 ` Lorenzo Pieralisi 2017-07-03 10:26 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 30/42] PCI: tegra: Drop pci_fixup_irqs() Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 31/42] PCI: xilinx: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 32/42] PCI: rcar: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 33/42] PCI: iproc: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 34/42] PCI: designware-host: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 35/42] PCI: ftpci100: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 36/42] PCI: host-common: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 37/42] PCI: versatile: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 38/42] PCI: altera: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 39/42] PCI: xgene: Move to struct pci_host_bridge IRQ mapping functions Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 40/42] PCI: rockchip: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 41/42] PCI: xilinx-nwl: " Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-08 14:13 ` [RFT PATCH v2 42/42] ARM64: PCI: Drop DT IRQ allocation from pcibios_alloc_irq() Lorenzo Pieralisi 2017-06-08 14:13 ` Lorenzo Pieralisi 2017-06-12 15:45 ` [RFT PATCH v2 00/42] PCI: ARM/ARM64: remove pci_fixup_irqs() usage Will Deacon 2017-06-12 15:45 ` Will Deacon 2017-06-12 16:20 ` Lorenzo Pieralisi 2017-06-12 16:20 ` Lorenzo Pieralisi 2017-06-12 23:58 ` Khuong Dinh 2017-06-19 23:12 ` Bjorn Helgaas 2017-06-19 23:12 ` Bjorn Helgaas 2017-06-20 14:44 ` Lorenzo Pieralisi 2017-06-20 14:44 ` Lorenzo Pieralisi 2017-06-21 8:39 ` Linus Walleij 2017-06-21 8:39 ` Linus Walleij 2017-06-21 9:50 ` Lorenzo Pieralisi 2017-06-21 9:50 ` Lorenzo Pieralisi 2017-06-21 10:30 ` Lorenzo Pieralisi 2017-06-21 10:30 ` Lorenzo Pieralisi 2017-06-21 10:45 ` Lorenzo Pieralisi 2017-06-21 10:45 ` Lorenzo Pieralisi 2017-06-21 14:51 ` Linus Walleij 2017-06-21 14:51 ` Linus Walleij 2017-06-21 15:14 ` Linus Walleij 2017-06-21 15:14 ` Linus Walleij 2017-06-21 15:41 ` Lorenzo Pieralisi 2017-06-21 15:41 ` Lorenzo Pieralisi 2017-06-21 16:28 ` Linus Walleij 2017-06-21 16:28 ` Linus Walleij
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170608141342.2018-7-lorenzo.pieralisi@arm.com \ --to=lorenzo.pieralisi@arm.com \ --cc=Joao.Pinto@synopsys.com \ --cc=arnd@arndb.de \ --cc=bharat.kumar.gogada@xilinx.com \ --cc=bhelgaas@google.com \ --cc=gabriele.paoloni@huawei.com \ --cc=horms@verge.net.au \ --cc=jingoohan1@gmail.com \ --cc=linus.walleij@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-pci@vger.kernel.org \ --cc=linux@armlinux.org.uk \ --cc=m-karicheri2@ti.com \ --cc=matt@masarand.com \ --cc=michal.simek@xilinx.com \ --cc=minghuan.Lian@freescale.com \ --cc=mingkai.hu@freescale.com \ --cc=pratyush.anand@gmail.com \ --cc=robh@kernel.org \ --cc=shawn.lin@rock-chips.com \ --cc=svarbanov@mm-sol.com \ --cc=thierry.reding@gmail.com \ --cc=thomas.petazzoni@free-electrons.com \ --cc=tie-fei.zang@freescale.com \ --cc=tinamdar@apm.com \ --cc=wangzhou1@hisilicon.com \ --cc=wenrui.li@rock-chips.com \ --cc=will.deacon@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.