obj: object header is no longer allocated automatically

This commit is contained in:
2023-05-06 19:48:14 +01:00
parent 79c30e5393
commit f52ca2f1e2
13 changed files with 97 additions and 66 deletions

View File

@@ -2,6 +2,8 @@
#include <socks/object.h>
#include <socks/device.h>
#define DEVICE_CAST(p) OBJECT_C_CAST(struct device, dev_base, &device_type, p)
static struct device *root_device = NULL;
static struct object_type device_type = {
.ob_name = "device",
@@ -20,10 +22,10 @@ kern_status_t device_init(void)
kern_status_t set_root_device(struct device *dev)
{
if (root_device) {
object_deref(object_header(root_device));
object_deref(&root_device->dev_base);
}
object_ref(object_header(dev));
object_ref(&dev->dev_base);
root_device = dev;
return KERN_OK;
@@ -35,6 +37,6 @@ struct device *device_alloc(void)
if (!dev_object) {
return NULL;
}
return object_data(dev_object);
return DEVICE_CAST(dev_object);
}