From patchwork Tue Sep 22 23:49:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 521488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3A6F3140770 for ; Wed, 23 Sep 2015 09:51:45 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=BFN8rC3g; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759774AbbIVXt1 (ORCPT ); Tue, 22 Sep 2015 19:49:27 -0400 Received: from mail-ig0-f170.google.com ([209.85.213.170]:37185 "EHLO mail-ig0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758919AbbIVXtZ (ORCPT ); Tue, 22 Sep 2015 19:49:25 -0400 Received: by igbni9 with SMTP id ni9so19339073igb.0; Tue, 22 Sep 2015 16:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b0ooe3a8OXasuiywzALA7xOn3Wi9Hv2z+1beZnEMtfw=; b=BFN8rC3gms+v3HvpwuccJt1ycNqOZwJ5iB1C7Ny5fdNtkiPN7GMvnAhw2YbkvMVyBN NbQKti0tG8txmI2bQ3JJGaEgLX00z27N4hGcTCtexb5heGVae38fS0i2i0pHUeGdZauI Vd4faXvrfvzCEPB5qQVyMbcTXTsP/nkucB1jb76PQh8MkePZ+Gqviaw1HAvLZRCeA+D6 DzXYG40yq9+gDL76c+A6AJUqOzJPVPXCHLEJMr0Nc1RKbsvYXtlp0LtDIJFUHcK5Wv9p rQ3kmnZuARk7oclW8k/BCLe1bQxUo4bVCCfbyK6aA6kO8UB4aKA9TYIy+z4YTBqmHUqv f8Sw== X-Received: by 10.50.8.69 with SMTP id p5mr1846080iga.43.1442965764865; Tue, 22 Sep 2015 16:49:24 -0700 (PDT) Received: from dl.caveonetworks.com (64.2.3.194.ptr.us.xo.net. [64.2.3.194]) by smtp.gmail.com with ESMTPSA id i26sm2325101iod.27.2015.09.22.16.49.23 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 22 Sep 2015 16:49:23 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id t8MNnMpX012970; Tue, 22 Sep 2015 16:49:22 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id t8MNnMfl012969; Tue, 22 Sep 2015 16:49:22 -0700 From: David Daney To: linux-kernel@vger.kernel.org, Bjorn Helgaas , linux-pci@vger.kernel.org, Will Deacon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Marc Zyngier Cc: David Daney Subject: [PATCH v3 1/6] PCI: Add pci_bus_fixup_irqs(). Date: Tue, 22 Sep 2015 16:49:12 -0700 Message-Id: <1442965757-12925-2-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1442965757-12925-1-git-send-email-ddaney.cavm@gmail.com> References: <1442965757-12925-1-git-send-email-ddaney.cavm@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: David Daney pci_bus_fixup_irqs() works like pci_fixup_irqs(), except it only does the fixups for devices on the specified bus. Follow-on patch will use the new function. Signed-off-by: David Daney --- No change from v2. This patch didn't exist in v1 of the set. drivers/pci/setup-irq.c | 30 ++++++++++++++++++++++++++++++ include/linux/pci.h | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c index 95c225b..189ad17 100644 --- a/drivers/pci/setup-irq.c +++ b/drivers/pci/setup-irq.c @@ -66,3 +66,33 @@ void pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *), pdev_fixup_irq(dev, swizzle, map_irq); } EXPORT_SYMBOL_GPL(pci_fixup_irqs); + +struct pci_bus_fixup_cb_info { + u8 (*swizzle)(struct pci_dev *, u8 *); + int (*map_irq)(const struct pci_dev *, u8, u8); +}; + +static int pci_bus_fixup_irq_cb(struct pci_dev *dev, void *arg) +{ + struct pci_bus_fixup_cb_info *info = arg; + + pdev_fixup_irq(dev, info->swizzle, info->map_irq); + return 0; +} + +/* + * Fixup the irqs only for devices on the given bus using supplied + * swizzle and map_irq function pointers + */ +void pci_bus_fixup_irqs(struct pci_bus *bus, + u8 (*swizzle)(struct pci_dev *, u8 *), + int (*map_irq)(const struct pci_dev *, u8, u8)) +{ + struct pci_bus_fixup_cb_info info; + + info.swizzle = swizzle; + info.map_irq = map_irq; + pci_walk_bus(bus, pci_bus_fixup_irq_cb, &info); + +} +EXPORT_SYMBOL_GPL(pci_bus_fixup_irqs); diff --git a/include/linux/pci.h b/include/linux/pci.h index e90eb22..b505b50 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1120,6 +1120,10 @@ void pdev_enable_device(struct pci_dev *); int pci_enable_resources(struct pci_dev *, int mask); void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), int (*)(const struct pci_dev *, u8, u8)); +void pci_bus_fixup_irqs(struct pci_bus *, + u8 (*)(struct pci_dev *, u8 *), + int (*)(const struct pci_dev *, u8, u8)); + #define HAVE_PCI_REQ_REGIONS 2 int __must_check pci_request_regions(struct pci_dev *, const char *); int __must_check pci_request_regions_exclusive(struct pci_dev *, const char *);