resource: Add the new device ops create/delete 80/279980/2
authorDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 18 Aug 2022 11:23:56 +0000 (20:23 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Mon, 22 Aug 2022 23:37:48 +0000 (08:37 +0900)
To separate initialization and instance creation on resource driver,
the new ops create/delete are introduced. Now, each operation is
used as below:
 - init: Setup the common contexts for resource (called once)
 - exit: Clear the init-ed contexts (called once)
 - create: Create resource instance with an individual context
 - delete: Free own context and remove resource instance

Change-Id: I4987f26afd6de7e7ec0b1d8ed6a724acbf55e374
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
include/util/resource.h
src/util/resource.c

index 596f414..d47db5a 100644 (file)
@@ -92,8 +92,10 @@ struct resource_control {
 };
 
 struct resource_driver_ops {
-       int (*init)(struct resource *res);
-       void (*exit)(struct resource *res);
+       int (*init)(void);
+       void (*exit)(void);
+       int (*create)(struct resource *res);
+       void (*delete)(struct resource *res);
        /*
         * If prepare_update is specified, it will be called
         * at every update_resource_attrs().
index fa68256..02e5ff9 100644 (file)
@@ -184,8 +184,8 @@ void delete_resource(struct resource *resource)
        if (!resource)
                return;
 
-       if (resource->driver && resource->driver->ops.exit)
-               resource->driver->ops.exit(resource);
+       if (resource->driver && resource->driver->ops.delete)
+               resource->driver->ops.delete(resource);
 
        unset_resource_attr_interest(resource, RESOURCE_ATTR_MASK);
 
@@ -257,8 +257,8 @@ struct resource *create_resource(int resource_type)
        resource->ctrls = driver->ctrls;
        resource->num_ctrls = driver->num_ctrls;
 
-       if (driver->ops.init) {
-               ret = driver->ops.init(resource);
+       if (driver->ops.create) {
+               ret = driver->ops.create(resource);
                if (ret < 0) {
                        _E("failed to initialize resource driver, res:type(%s)id(%d)\n",
                                                resource->name, resource->id);