summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/devices/device.c30
-rw-r--r--src/devices/device_util.c16
2 files changed, 27 insertions, 19 deletions
diff --git a/src/devices/device.c b/src/devices/device.c
index ebac1a073e..fafa59924e 100644
--- a/src/devices/device.c
+++ b/src/devices/device.c
@@ -66,12 +66,10 @@ DECLARE_SPIN_LOCK(dev_lock)
*
* @see device_path
*/
-device_t alloc_dev(struct bus *parent, struct device_path *path)
+static device_t __alloc_dev(struct bus *parent, struct device_path *path)
{
device_t dev, child;
- spin_lock(&dev_lock);
-
/* Find the last child of our parent. */
for (child = parent->children; child && child->sibling; /* */ )
child = child->sibling;
@@ -99,11 +97,37 @@ device_t alloc_dev(struct bus *parent, struct device_path *path)
last_dev->next = dev;
last_dev = dev;
+ return dev;
+}
+
+device_t alloc_dev(struct bus *parent, struct device_path *path)
+{
+ device_t dev;
+ spin_lock(&dev_lock);
+ dev = __alloc_dev(parent, path);
spin_unlock(&dev_lock);
return dev;
}
/**
+ * See if a device structure already exists and if not allocate it.
+ *
+ * @param parent The bus to find the device on.
+ * @param path The relative path from the bus to the appropriate device.
+ * @return Pointer to a device structure for the device on bus at path.
+ */
+device_t alloc_find_dev(struct bus *parent, struct device_path *path)
+{
+ device_t child;
+ spin_lock(&dev_lock);
+ child = find_dev_path(parent, path);
+ if (!child)
+ child = __alloc_dev(parent, path);
+ spin_unlock(&dev_lock);
+ return child;
+}
+
+/**
* Round a number up to an alignment.
*
* @param val The starting value.
diff --git a/src/devices/device_util.c b/src/devices/device_util.c
index 5225938e19..ecc2c13659 100644
--- a/src/devices/device_util.c
+++ b/src/devices/device_util.c
@@ -48,22 +48,6 @@ device_t find_dev_path(struct bus *parent, struct device_path *path)
}
/**
- * See if a device structure already exists and if not allocate it.
- *
- * @param parent The bus to find the device on.
- * @param path The relative path from the bus to the appropriate device.
- * @return Pointer to a device structure for the device on bus at path.
- */
-device_t alloc_find_dev(struct bus *parent, struct device_path *path)
-{
- device_t child;
- child = find_dev_path(parent, path);
- if (!child)
- child = alloc_dev(parent, path);
- return child;
-}
-
-/**
* Given a PCI bus and a devfn number, find the device structure.
*
* @param bus The bus number.