{
uint8_t buf[0x40];
pciaddr_t bytes;
+ int err;
+ /* Make sure the device has been probed. If not, header_type won't be
+ * set and the rest of this function will fail.
+ */
+ err = pci_device_probe(& priv->base);
+ if (err) {
+ return err;
+ }
+
switch ( priv->header_type & 0x7f ) {
case 0x00:
break;
return ENODEV;
}
- if (priv->bridge.pci == NULL) {
- read_bridge_info(priv);
+ if (!priv->bridge.pci) {
+ return ENODEV;
}
switch ((dev->device_class >> 8) & 0x0ff) {
break;
case 0x04:
+ if (priv->bridge.pci == NULL)
+ read_bridge_info(priv);
+ if (priv->header_type == 0x01) {
*primary_bus = priv->bridge.pci->primary_bus;
*secondary_bus = priv->bridge.pci->secondary_bus;
*subordinate_bus = priv->bridge.pci->subordinate_bus;
+ } else {
+ *primary_bus = dev->bus;
+ *secondary_bus = -1;
+ *subordinate_bus = -1;
+ }
break;
case 0x07:
+ if (priv->bridge.pcmcia == NULL)
+ read_bridge_info(priv);
+ if (priv->header_type == 0x02) {
*primary_bus = priv->bridge.pcmcia->primary_bus;
*secondary_bus = priv->bridge.pcmcia->card_bus;
*subordinate_bus = priv->bridge.pcmcia->subordinate_bus;
+ } else {
+ *primary_bus = dev->bus;
+ *secondary_bus = -1;
+ *subordinate_bus = -1;
+ }
break;
}