From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754589AbbCCCum (ORCPT ); Mon, 2 Mar 2015 21:50:42 -0500 Received: from mail-oi0-f47.google.com ([209.85.218.47]:50831 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754355AbbCCCuZ (ORCPT ); Mon, 2 Mar 2015 21:50:25 -0500 Date: Mon, 2 Mar 2015 20:50:20 -0600 From: Bjorn Helgaas To: Yijing Wang Cc: Jiang Liu , linux-pci@vger.kernel.org, Yinghai Lu , linux-kernel@vger.kernel.org, Marc Zyngier , linux-arm-kernel@lists.infradead.org, Russell King , x86@kernel.org, Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , linux-ia64@vger.kernel.org, "David S. Miller" , Guan Xuetao , linux-alpha@vger.kernel.org, linux-m68k@vger.kernel.org, Liviu Dudau , Arnd Bergmann , Geert Uytterhoeven Subject: Re: [PATCH v4 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations Message-ID: <20150303025020.GF11978@google.com> References: <1424938344-4017-1-git-send-email-wangyijing@huawei.com> <1424938344-4017-13-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424938344-4017-13-git-send-email-wangyijing@huawei.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 26, 2015 at 04:12:06PM +0800, Yijing Wang wrote: > Now we have weak functions like pcibios_root_bridge_prepare() > to setup pci host bridge, We could introduce pci_host_bridge_ops > which contain host bridge specific ops to setup pci_host_bridge. > Then host bridge driver could add pci_host_bridge_ops hooks > intead of weak function to setup pci_host_bridge. > This patch add following pci_host_bridge_ops hooks: > > pci_host_bridge_ops { > /* set root bus speed, some platform need this like powerpc */ > void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); > /* setup pci_host_bridge before pci_host_bridge be added to driver core */ > int (*phb_prepare)(struct pci_host_bridge *host); > /* platform specific of scan hook to scan pci device */ > void (*phb_of_scan_bus)(struct pci_host_bridge *); > } > We could easily extend it to support different host bridge > specific operations. > > Signed-off-by: Yijing Wang > --- > drivers/pci/host-bridge.c | 12 ++++++++++-- > drivers/pci/probe.c | 17 +++++++++++------ > include/linux/pci.h | 12 ++++++++++-- > 3 files changed, 31 insertions(+), 10 deletions(-) > > diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c > index b42a4bb..4a2baa2 100644 > --- a/drivers/pci/host-bridge.c > +++ b/drivers/pci/host-bridge.c > @@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev) > } > > struct pci_host_bridge *pci_create_host_bridge( > - struct device *parent, u32 db, > - struct list_head *resources, void *sysdata) > + struct device *parent, u32 db, struct list_head *resources, > + void *sysdata, struct pci_host_bridge_ops *ops) > { > int error; > int bus = PCI_BUSNUM(db); > @@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge( > } > mutex_unlock(&phb_mutex); > > + host->ops = ops; > host->dev.parent = parent; > INIT_LIST_HEAD(&host->windows); > host->dev.release = pci_release_host_bridge_dev; > @@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge( > dev_set_name(&host->dev, "pci%04x:%02x", host->domain, > host->busnum); > > + if (host->ops && host->ops->phb_prepare) { > + error = host->ops->phb_prepare(host); > + if(error) { Whitespace error. > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev) > return (pdev->error_state != pci_channel_io_normal); > } > > +struct pci_host_bridge; > +struct pci_host_bridge_ops { > + void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); > + int (*phb_prepare)(struct pci_host_bridge *host); > + void (*phb_of_scan_bus)(struct pci_host_bridge *); These function pointers don't need a "phb_" prefix.