kent: change param order of kent_init

This commit is contained in:
anna 2021-02-17 15:01:15 +01:00
parent b8c4593fc5
commit b7abbf1cf7
Signed by: fef
GPG key ID: EC22E476DC2D3D84
4 changed files with 19 additions and 6 deletions

View file

@ -44,11 +44,11 @@ extern struct kent *kent_root;
/**
* Initialize a kent and increment its refcounter by one.
*
* @param parent: The parent kent.
* @param kent: The kent.
* @param parent: The parent kent.
* @returns A nonzero value on failure
*/
int kent_init(struct kent *parent, struct kent *kent);
int kent_init(struct kent *kent, struct kent *parent);
/**
* Increment the reference counter.

View file

@ -12,6 +12,16 @@
struct kent *devices_kent = NULL;
static void device_destroy(struct kent *kent)
{
struct device *dev = to_device(kent);
free(dev);
}
struct kent_ops devices_kent_ops = {
.destroy = &device_destroy,
};
/** Initialize the devices subsystem. */
int devices_init(void)
{
@ -22,7 +32,10 @@ int devices_init(void)
if (devices_kent == NULL)
return -ENOMEM;
return kent_init(NULL, devices_kent);
/* we don't need that because the root device kent lives forever */
devices_kent->operations = NULL;
return kent_init(devices_kent, NULL);
}
int device_init(struct device *dev, struct device *parent)
@ -30,7 +43,7 @@ int device_init(struct device *dev, struct device *parent)
if (devices_kent == NULL)
return -ENOENT;
return kent_init(devices_kent, &dev->kent);
return kent_init(&dev->kent, devices_kent);
}
/*

View file

@ -29,7 +29,7 @@ struct dmabuf *dmabuf_create(struct device *dev, size_t len)
buf->kent.operations = &dma_kent_ops;
err = kent_init(&dev->kent, &buf->kent);
err = kent_init(&buf->kent, &dev->kent);
if (err != 0) {
free(buf);
return NULL;

View file

@ -10,7 +10,7 @@
struct kent *kent_root;
int kent_init(struct kent *parent, struct kent *kent)
int kent_init(struct kent *kent, struct kent *parent)
{
int ret = 0;