From patchwork Fri Apr 24 02:45:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 19721 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3O2jMoY011682 for ; Fri, 24 Apr 2009 02:45:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753717AbZDXCpV (ORCPT ); Thu, 23 Apr 2009 22:45:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752915AbZDXCpV (ORCPT ); Thu, 23 Apr 2009 22:45:21 -0400 Received: from mga14.intel.com ([143.182.124.37]:23158 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753307AbZDXCpU (ORCPT ); Thu, 23 Apr 2009 22:45:20 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 23 Apr 2009 19:45:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.40,238,1239001200"; d="asc'?scan'208";a="135322433" Received: from yhuang-dev.sh.intel.com (HELO [10.239.13.12]) ([10.239.13.12]) by azsmga001.ch.intel.com with ESMTP; 23 Apr 2009 19:45:18 -0700 Subject: [PATCH 1/4] PCI: Add pci_bus_set_ops From: Huang Ying To: Jesse Barnes Cc: Andi Kleen , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Date: Fri, 24 Apr 2009 10:45:17 +0800 Message-Id: <1240541117.6842.676.camel@yhuang-dev.sh.intel.com> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org pci_bus_set_ops changes pci_ops associated with a pci_bus. This can be used by some debug tool such as PCIE AER error injection to fake some PCI configuration registers. Signed-off-by: Huang Ying --- drivers/pci/access.c | 19 +++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 20 insertions(+) --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -66,6 +66,25 @@ EXPORT_SYMBOL(pci_bus_write_config_byte) EXPORT_SYMBOL(pci_bus_write_config_word); EXPORT_SYMBOL(pci_bus_write_config_dword); +/** + * pci_bus_set_ops - Set raw operations of pci bus + * @bus: pci bus struct + * @ops: new raw operations + * + * Return previous raw operations + */ +struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops) +{ + struct pci_ops *old_ops; + unsigned long flags; + + spin_lock_irqsave(&pci_lock, flags); + old_ops = bus->ops; + bus->ops = ops; + spin_unlock_irqrestore(&pci_lock, flags); + return old_ops; +} +EXPORT_SYMBOL(pci_bus_set_ops); /** * pci_read_vpd - Read one entry from Vital Product Data --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -639,6 +639,7 @@ int pci_bus_write_config_word(struct pci int where, u16 val); int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val); +struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops); static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) {