[LinuxBIOS] [PATCH] v3 drop malloc, clean up device model

ron minnich rminnich at gmail.com
Fri Jun 29 18:36:23 CEST 2007


vice/device.h
===================================================================
--- include/device/device.h	(revision 417)
+++ include/device/device.h	(working copy)
@@ -112,18 +112,22 @@
 	void (*set_link)(struct device * dev, unsigned int link);
 	void (*reset_bus)(struct bus *bus);

-	/* a constructor. The constructor for a given device is defined in
the device source file.
-	 * When is this called? Not for the static tree. When the scan bus
code finds a new device, it must
-	 * create it and insert it into the device tree. To do this, it
calls a device constructor.
-	 * The set of all device constructors is concatenated into the
constructors array of structures via the usual
-	 * gcc hack of naming a segment.

Let's drop the "gcc hack" comment, it no longer applies.

Index: device/device.c
===================================================================
--- device/device.c	(revision 417)
+++ device/device.c	(working copy)

-//      spin_lock(&dev_lock);
+	spin_lock(&dev_lock);

 	/* Find the last child of our parent. */
 	for (child = parent->children; child && child->sibling; /* */) {
 		child = child->sibling;
 	}

-	dev = constructor(devid);
+	dev = new_device();
 	if (!dev)
-		printk(BIOS_DEBUG, "%s: No constructor, going with empty dev",
-		       dev_id_string(devid));
+		return NULL;

are you missing a spin_unlock here? If we are doing lock/unlock then
the failure case should probably be a goto Error in the kernel style,
so we don' t leave a dangling lock.


 thanks,

ron




More information about the coreboot mailing list