[openib-general] [PATCH 1/6] Add pci_find_ht_capability() for finding Hypertransport capabilities
    Segher Boessenkool 
    segher at kernel.crashing.org
       
    Thu Nov  9 00:01:58 PST 2006
    
    
  
> +int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int  
> ht_cap)
> +{
> +	int rc;
> +	u8 cap, mask;
> +
> +	if (ht_cap == HT_CAPTYPE_SLAVE || ht_cap == HT_CAPTYPE_HOST)
> +		mask = HT_3BIT_CAP_MASK;
> +	else
> +		mask = HT_5BIT_CAP_MASK;
> +
+	pos = pci_find_next_capability(dev, pos, PCI_CAP_ID_HT);
or the caller will loop forever if a second same type HT cap is found.
> +	while (pos) {
> +		rc = pci_read_config_byte(dev, pos + 3, &cap);
> +		if (rc != PCIBIOS_SUCCESSFUL)
> +			return 0;
> +
> +		if ((cap & mask) == ht_cap)
> +			return pos;
> +
> +		pos = pci_find_next_capability(dev, pos, PCI_CAP_ID_HT);
> +	}
> +
> +	return 0;
> +}
Segher
    
    
More information about the general
mailing list