summaryrefslogtreecommitdiffstats
path: root/src/drivers
diff options
context:
space:
mode:
authorMichael Brown2011-02-09 01:32:58 +0100
committerMichael Brown2011-02-17 02:25:11 +0100
commitf9b3fae8d46a6b1862b3f5b02490e5a8c224286f (patch)
tree1862f41cd2b7ab031780881ed953acc647d38114 /src/drivers
parent[bitops] Add missing __attribute__ (( packed )) (diff)
downloadipxe-f9b3fae8d46a6b1862b3f5b02490e5a8c224286f.tar.gz
ipxe-f9b3fae8d46a6b1862b3f5b02490e5a8c224286f.tar.xz
ipxe-f9b3fae8d46a6b1862b3f5b02490e5a8c224286f.zip
[pci] Use single "busdevfn" field in struct pci_device
Merge the "bus" and "devfn" fields into a single "busdevfn" field, to match the format used by the majority of external code. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/bus/pci.c117
-rw-r--r--src/drivers/net/phantom/phantom.c16
-rw-r--r--src/drivers/net/tg3.c2
-rw-r--r--src/drivers/net/vxge/vxge_main.c5
4 files changed, 69 insertions, 71 deletions
diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c
index 3ff544401..e92f11b2f 100644
--- a/src/drivers/bus/pci.c
+++ b/src/drivers/bus/pci.c
@@ -228,75 +228,72 @@ static void pci_remove ( struct pci_device *pci ) {
*/
static int pcibus_probe ( struct root_device *rootdev ) {
struct pci_device *pci = NULL;
- unsigned int max_bus;
- unsigned int bus;
- unsigned int devfn;
+ unsigned int num_bus;
+ unsigned int busdevfn;
uint8_t hdrtype = 0;
uint32_t tmp;
int rc;
- max_bus = pci_max_bus();
- for ( bus = 0 ; bus <= max_bus ; bus++ ) {
- for ( devfn = 0 ; devfn <= 0xff ; devfn++ ) {
+ num_bus = ( pci_max_bus() + 1 );
+ for ( busdevfn = 0 ; busdevfn < PCI_BUSDEVFN ( num_bus, 0, 0 ) ;
+ busdevfn++ ) {
- /* Allocate struct pci_device */
- if ( ! pci )
- pci = malloc ( sizeof ( *pci ) );
- if ( ! pci ) {
- rc = -ENOMEM;
- goto err;
- }
- memset ( pci, 0, sizeof ( *pci ) );
- pci->bus = bus;
- pci->devfn = devfn;
+ /* Allocate struct pci_device */
+ if ( ! pci )
+ pci = malloc ( sizeof ( *pci ) );
+ if ( ! pci ) {
+ rc = -ENOMEM;
+ goto err;
+ }
+ memset ( pci, 0, sizeof ( *pci ) );
+ pci->busdevfn = busdevfn;
- /* Skip all but the first function on
- * non-multifunction cards
- */
- if ( PCI_FUNC ( devfn ) == 0 ) {
- pci_read_config_byte ( pci, PCI_HEADER_TYPE,
- &hdrtype );
- } else if ( ! ( hdrtype & 0x80 ) ) {
- continue;
- }
+ /* Skip all but the first function on
+ * non-multifunction cards
+ */
+ if ( PCI_FUNC ( busdevfn ) == 0 ) {
+ pci_read_config_byte ( pci, PCI_HEADER_TYPE,
+ &hdrtype );
+ } else if ( ! ( hdrtype & 0x80 ) ) {
+ continue;
+ }
- /* Check for physical device presence */
- pci_read_config_dword ( pci, PCI_VENDOR_ID, &tmp );
- if ( ( tmp == 0xffffffff ) || ( tmp == 0 ) )
- continue;
+ /* Check for physical device presence */
+ pci_read_config_dword ( pci, PCI_VENDOR_ID, &tmp );
+ if ( ( tmp == 0xffffffff ) || ( tmp == 0 ) )
+ continue;
- /* Populate struct pci_device */
- pci->vendor = ( tmp & 0xffff );
- pci->device = ( tmp >> 16 );
- pci_read_config_dword ( pci, PCI_REVISION, &tmp );
- pci->class = ( tmp >> 8 );
- pci_read_config_byte ( pci, PCI_INTERRUPT_LINE,
- &pci->irq );
- pci_read_bases ( pci );
+ /* Populate struct pci_device */
+ pci->vendor = ( tmp & 0xffff );
+ pci->device = ( tmp >> 16 );
+ pci_read_config_dword ( pci, PCI_REVISION, &tmp );
+ pci->class = ( tmp >> 8 );
+ pci_read_config_byte ( pci, PCI_INTERRUPT_LINE,
+ &pci->irq );
+ pci_read_bases ( pci );
- /* Add to device hierarchy */
- snprintf ( pci->dev.name, sizeof ( pci->dev.name ),
- "PCI%02x:%02x.%x", bus,
- PCI_SLOT ( devfn ), PCI_FUNC ( devfn ) );
- pci->dev.desc.bus_type = BUS_TYPE_PCI;
- pci->dev.desc.location = PCI_BUSDEVFN (bus, devfn);
- pci->dev.desc.vendor = pci->vendor;
- pci->dev.desc.device = pci->device;
- pci->dev.desc.class = pci->class;
- pci->dev.desc.ioaddr = pci->ioaddr;
- pci->dev.desc.irq = pci->irq;
- pci->dev.parent = &rootdev->dev;
- list_add ( &pci->dev.siblings, &rootdev->dev.children);
- INIT_LIST_HEAD ( &pci->dev.children );
-
- /* Look for a driver */
- if ( pci_probe ( pci ) == 0 ) {
- /* pcidev registered, we can drop our ref */
- pci = NULL;
- } else {
- /* Not registered; re-use struct pci_device */
- list_del ( &pci->dev.siblings );
- }
+ /* Add to device hierarchy */
+ snprintf ( pci->dev.name, sizeof ( pci->dev.name ),
+ "PCI%02x:%02x.%x", PCI_BUS ( busdevfn ),
+ PCI_SLOT ( busdevfn ), PCI_FUNC ( busdevfn ) );
+ pci->dev.desc.bus_type = BUS_TYPE_PCI;
+ pci->dev.desc.location = pci->busdevfn;
+ pci->dev.desc.vendor = pci->vendor;
+ pci->dev.desc.device = pci->device;
+ pci->dev.desc.class = pci->class;
+ pci->dev.desc.ioaddr = pci->ioaddr;
+ pci->dev.desc.irq = pci->irq;
+ pci->dev.parent = &rootdev->dev;
+ list_add ( &pci->dev.siblings, &rootdev->dev.children);
+ INIT_LIST_HEAD ( &pci->dev.children );
+
+ /* Look for a driver */
+ if ( pci_probe ( pci ) == 0 ) {
+ /* pcidev registered, we can drop our ref */
+ pci = NULL;
+ } else {
+ /* Not registered; re-use struct pci_device */
+ list_del ( &pci->dev.siblings );
}
}
diff --git a/src/drivers/net/phantom/phantom.c b/src/drivers/net/phantom/phantom.c
index f6b2f0064..6a3f5f7bf 100644
--- a/src/drivers/net/phantom/phantom.c
+++ b/src/drivers/net/phantom/phantom.c
@@ -1792,9 +1792,8 @@ static int phantom_map_crb ( struct phantom_nic *phantom,
bar0_start = pci_bar_start ( pci, PCI_BASE_ADDRESS_0 );
bar0_size = pci_bar_size ( pci, PCI_BASE_ADDRESS_0 );
- DBGC ( phantom, "Phantom %p is PCI %02x:%02x.%x with BAR0 at "
- "%08lx+%lx\n", phantom, pci->bus, PCI_SLOT ( pci->devfn ),
- PCI_FUNC ( pci->devfn ), bar0_start, bar0_size );
+ DBGC ( phantom, "Phantom %p is " PCI_FMT " with BAR0 at %08lx+%lx\n",
+ phantom, PCI_ARGS ( pci ), bar0_start, bar0_size );
if ( ! bar0_start ) {
DBGC ( phantom, "Phantom %p BAR not assigned; ignoring\n",
@@ -2057,7 +2056,7 @@ static int phantom_probe ( struct pci_device *pci,
pci_set_drvdata ( pci, netdev );
netdev->dev = &pci->dev;
memset ( phantom, 0, sizeof ( *phantom ) );
- phantom->port = PCI_FUNC ( pci->devfn );
+ phantom->port = PCI_FUNC ( pci->busdevfn );
assert ( phantom->port < PHN_MAX_NUM_PORTS );
settings_init ( &phantom->settings,
&phantom_settings_operations,
@@ -2074,16 +2073,19 @@ static int phantom_probe ( struct pci_device *pci,
* B2 will have this fixed; remove this hack when B1 is no
* longer in use.
*/
- if ( PCI_FUNC ( pci->devfn ) == 0 ) {
+ if ( PCI_FUNC ( pci->busdevfn ) == 0 ) {
unsigned int i;
for ( i = 0 ; i < 8 ; i++ ) {
uint32_t temp;
- pci->devfn = PCI_DEVFN ( PCI_SLOT ( pci->devfn ), i );
+ pci->busdevfn =
+ PCI_BUSDEVFN ( PCI_BUS ( pci->busdevfn ),
+ PCI_SLOT ( pci->busdevfn ), i );
pci_read_config_dword ( pci, 0xc8, &temp );
pci_read_config_dword ( pci, 0xc8, &temp );
pci_write_config_dword ( pci, 0xc8, 0xf1000 );
}
- pci->devfn = PCI_DEVFN ( PCI_SLOT ( pci->devfn ), 0 );
+ pci->busdevfn = PCI_BUSDEVFN ( PCI_BUS ( pci->busdevfn ),
+ PCI_SLOT ( pci->busdevfn ), 0 );
}
/* Initialise the command PEG */
diff --git a/src/drivers/net/tg3.c b/src/drivers/net/tg3.c
index 4ff72ace6..e1562d4c8 100644
--- a/src/drivers/net/tg3.c
+++ b/src/drivers/net/tg3.c
@@ -2909,7 +2909,7 @@ static int tg3_get_device_address(struct tg3 *tp)
struct nic *nic = tp->nic;
uint32_t hi, lo, mac_offset;
- if (PCI_FUNC(tp->pdev->devfn) == 0)
+ if (PCI_FUNC(tp->pdev->busdevfn) == 0)
mac_offset = 0x7c;
else
mac_offset = 0xcc;
diff --git a/src/drivers/net/vxge/vxge_main.c b/src/drivers/net/vxge/vxge_main.c
index e2abafbf9..a85634471 100644
--- a/src/drivers/net/vxge/vxge_main.c
+++ b/src/drivers/net/vxge/vxge_main.c
@@ -511,9 +511,8 @@ vxge_probe(struct pci_device *pdev, const struct pci_device_id *id __unused)
struct vxge_hw_device_hw_info hw_info;
struct vxge_hw_device_version *fw_version;
- vxge_debug(VXGE_INFO, "vxge_probe for device %02X:%02X.%X\n",
- pdev->bus, PCI_SLOT(pdev->devfn),
- PCI_FUNC(pdev->devfn));
+ vxge_debug(VXGE_INFO, "vxge_probe for device " PCI_FMT "\n",
+ PCI_ARGS(pdev));
pci_read_config_byte(pdev, PCI_REVISION_ID, &revision);
titan1 = is_titan1(pdev->device, revision);