diff --git a/device/device.c b/device/device.c index 3240fe7900..3246193f80 100644 --- a/device/device.c +++ b/device/device.c @@ -87,21 +87,6 @@ static struct device *new_device(void) return &devs[devcnt]; } -/** - * Initialization tasks for the device tree code. - * - * At present, merely sets up last_dev_p, which used to be done by - * Fucking Magic (FM) in the config tool. - */ -void dev_init(void) -{ - struct device *dev; - - for (dev = all_devices; dev; dev = dev->next) { - last_dev_p = &dev->next; - } -} - /** * The default constructor, which simply sets the ops pointer. * @@ -148,6 +133,30 @@ struct constructor *find_constructor(struct device_id *id) return NULL; } +/** + * Initialization tasks for the device tree code. + * + * Sets up last_dev_p, which used to be done by + * Fucking Magic (FM) in the config tool. Also, for each of the + * devices, tries to find the constructor, and from there, the ops, + * for the device. + */ +void dev_init(void) +{ + struct device *dev; + struct constructor *c; + + for (dev = all_devices; dev; dev = dev->next) { + c = find_constructor(&dev->id); + /* note the difference from the constructor function below. + * we are not allocating the device here, just setting the ops. + */ + if (c) + dev->ops = c->ops; + last_dev_p = &dev->next; + } +} + /** * Given a path, find a constructor, and run it. * @@ -725,6 +734,9 @@ void dev_phase2(void) printk(BIOS_DEBUG, "Phase 2: Early setup...\n"); for (dev = all_devices; dev; dev = dev->next) { printk(BIOS_SPEW, "%s: dev %s: ", __FUNCTION__, dev->dtsname); + printk(BIOS_SPEW, "%s: ops %p ops->phase2_setup_scan_bus %p\n", + __FUNCTION__, dev->ops, + dev->ops? dev->ops->phase2_setup_scan_bus : "None"); if (dev->ops && dev->ops->phase2_setup_scan_bus) { printk(BIOS_SPEW, "Calling phase2 phase2_setup_scan_bus..."); diff --git a/include/device/device.h b/include/device/device.h index fad48d9c33..37b8379915 100644 --- a/include/device/device.h +++ b/include/device/device.h @@ -185,9 +185,11 @@ struct device { struct device * next; /* chain of all devices */ struct device_path path; + struct device_id id; char dtsname[MAX_DTSNAME_SIZE]; /* the name from the dts */ - unsigned vendor; - unsigned device; + /* XXX remove this soon */ + unsigned device, vendor; + /* XXX */ u16 status; u8 revision; u8 cache_line;