diff options
author | Michael Brown | 2005-04-14 15:44:07 +0200 |
---|---|---|
committer | Michael Brown | 2005-04-14 15:44:07 +0200 |
commit | 104880ca19e230ebbe6a4f46fa17e32ff05324f2 (patch) | |
tree | d99a776582dfb278218299f88c3ee8fd8203e631 /src/drivers/bus/mca.c | |
parent | Separate out bus-scanning and device-probing logic. (diff) | |
download | ipxe-104880ca19e230ebbe6a4f46fa17e32ff05324f2.tar.gz ipxe-104880ca19e230ebbe6a4f46fa17e32ff05324f2.tar.xz ipxe-104880ca19e230ebbe6a4f46fa17e32ff05324f2.zip |
Tweak API to allow separation of bus-scanning and device-probing logic.
Diffstat (limited to 'src/drivers/bus/mca.c')
-rw-r--r-- | src/drivers/bus/mca.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/drivers/bus/mca.c b/src/drivers/bus/mca.c index 1d20a665..f87da8d2 100644 --- a/src/drivers/bus/mca.c +++ b/src/drivers/bus/mca.c @@ -49,31 +49,20 @@ static int fill_mca_device ( struct mca_device *mca ) { } /* - * Obtain a struct mca * from a struct dev * + * Find an MCA device matching the specified driver * - * If dev has not previously been used for an MCA device scan, blank - * out struct mca */ -struct mca_device * mca_device ( struct dev *dev ) { - struct mca_device *mca = dev->bus; +int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) { + unsigned int i; + /* Initialise struct mca if it's the first time it's been used. */ if ( mca->magic != mca_magic ) { memset ( mca, 0, sizeof ( *mca ) ); mca->magic = mca_magic; } - mca->dev = dev; - return mca; -} - -/* - * Find an MCA device matching the specified driver - * - */ -int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) { - unsigned int i; /* Iterate through all possible MCA slots, starting where we - * left off/ + * left off */ for ( ; mca->slot < MCA_MAX_SLOT_NR ; mca->slot++ ) { /* If we've already used this device, skip it */ @@ -94,14 +83,7 @@ int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) { if ( MCA_ID ( mca ) == id->id ) { DBG ( "Device %s (driver %s) matches ID %hx\n", id->name, driver->name, id->id ); - if ( mca->dev ) { - mca->dev->name = driver->name; - mca->dev->devid.bus_type - = MCA_BUS_TYPE; - mca->dev->devid.vendor_id - = GENERIC_MCA_VENDOR; - mca->dev->devid.device_id = id->id; - } + mca->name = id->name; mca->already_tried = 1; return 1; } @@ -112,3 +94,22 @@ int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) { mca->slot = 0; return 0; } + +/* + * Find the next MCA device that can be used to boot using the + * specified driver. + * + */ +int find_mca_boot_device ( struct dev *dev, struct mca_driver *driver ) { + struct mca_device *mca = ( struct mca_device * )dev->bus; + + if ( ! find_mca_device ( mca, driver ) ) + return 0; + + dev->name = mca->name; + dev->devid.bus_type = MCA_BUS_TYPE; + dev->devid.vendor_id = GENERIC_MCA_VENDOR; + dev->devid.device_id = MCA_ID ( mca ); + + return 1; +} |