Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755562AbbDIWNH (ORCPT ); Thu, 9 Apr 2015 18:13:07 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:35804 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755021AbbDIWNA (ORCPT ); Thu, 9 Apr 2015 18:13:00 -0400 Date: Thu, 9 Apr 2015 17:12:56 -0500 From: Bjorn Helgaas To: "Sean O. Stalley" Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Read ID & Pointer from PCI Capabilities List in 1 call Message-ID: <20150409221256.GO30967@google.com> References: <1428009019-19563-1-git-send-email-sean.stalley@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1428009019-19563-1-git-send-email-sean.stalley@intel.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 Content-Length: 1440 Lines: 51 On Thu, Apr 02, 2015 at 02:10:19PM -0700, Sean O. Stalley wrote: > Reading both fields at the same time lets us parse the > list with half the number of configspace reads. > > Signed-off-by: Sean O. Stalley Applied to pci/misc for v4.1, thanks Sean! > --- > drivers/pci/pci.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index 5e3c8e9..db7f3d6 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -145,19 +145,22 @@ static int __pci_find_next_cap_ttl(struct pci_bus *bus, unsigned int devfn, > u8 pos, int cap, int *ttl) > { > u8 id; > + u16 ent; > + > + pci_bus_read_config_byte(bus, devfn, pos, &pos); > > while ((*ttl)--) { > - pci_bus_read_config_byte(bus, devfn, pos, &pos); > if (pos < 0x40) > break; > pos &= ~3; > - pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID, > - &id); > + pci_bus_read_config_word(bus, devfn, pos, &ent); > + > + id = ent & 0xff; > if (id == 0xff) > break; > if (id == cap) > return pos; > - pos += PCI_CAP_LIST_NEXT; > + pos = (ent >> 8); > } > return 0; > } > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/