All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: "Sean O. Stalley" <sean.stalley@intel.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Read ID & Pointer from PCI Capabilities List in 1 call
Date: Thu, 9 Apr 2015 17:12:56 -0500	[thread overview]
Message-ID: <20150409221256.GO30967@google.com> (raw)
In-Reply-To: <1428009019-19563-1-git-send-email-sean.stalley@intel.com>

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 <sean.stalley@intel.com>

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
> 

      reply	other threads:[~2015-04-09 22:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 21:10 [PATCH] Read ID & Pointer from PCI Capabilities List in 1 call Sean O. Stalley
2015-04-09 22:12 ` Bjorn Helgaas [this message]

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=20150409221256.GO30967@google.com \
    --to=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sean.stalley@intel.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: link
Be 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.