FreeBSD/sys/dev/pci/pci.c
/*
 * Adjusts a PCI-e capability register by clearing the bits in mask
 * and setting the bits in (value & mask).  Bits not set in mask are
 * not adjusted.
 *
 * Returns the old value on success or all ones on failure.
 */
Adjusts a PCI-e capability register by clearing the bits in mask
and setting the bits in (value & mask).  Bits not set in mask are
not adjusted.

Returns the old value on success or all ones on failure.
Adjusts a PCI - e capability register by clearing the bits in mask and setting the bits in ( value & mask ) . Bits not set in mask are not adjusted . Returns the old value on success or all ones on failure .
uint32_t
pcie_adjust_config(device_t dev, int reg, uint32_t mask, uint32_t value,
    int width)
{
	struct pci_devinfo *dinfo = device_get_ivars(dev);
	uint32_t old, new;
	int cap;
	cap = dinfo->cfg.pcie.pcie_location;
	if (cap == 0) {
		if (width == 2)
			return (0xffff);
		return (0xffffffff);
	}
	old = pci_read_config(dev, cap + reg, width);
	new = old & ~mask;
	new |= (value & mask);
	pci_write_config(dev, cap + reg, new, width);
	return (old);
}
uint32_t pcie_adjust_config ( device_t dev , int reg , uint32_t mask , uint32_t value , int width ) { struct pci_devinfo * dinfo = device_get_ivars ( dev ) ; uint32_t old , new ; int cap ; cap = dinfo -> cfg . pcie . pcie_location ; if ( cap == 0 ) { if ( width == 2 ) return ( 0xffff ) ; return ( 0xffffffff ) ; } old = pci_read_config ( dev , cap + reg , width ) ; new = old & ~ mask ; new |= ( value & mask ) ; pci_write_config ( dev , cap + reg , new , width ) ; return ( old ) ; }
Adjusts a PCI-e capability register by clearing the bits in mask
 and setting the bits in (value & mask).
Adjusts a PCI - e capability register by clearing the bits in mask and setting the bits in ( value & mask ) .