int index;
};
-struct resource {
- int id;
- char *name;
- const struct resource_driver *driver;
- int type;
- void *priv;
-
- int num_attrs;
- const struct resource_attribute *attrs;
- struct resource_attribute_value *attrs_value;
- int num_ctrls;
- const struct resource_control *ctrls;
- u_int64_t attr_interest;
- u_int64_t attr_supported;
-
- int64_t ts_start;
- int64_t ts_end;
-};
-
#define RESOURCE_DRIVER_REGISTER(resource_driver) \
static void __CONSTRUCTOR__ module_init(void) \
{ \
int unset_resource_attr_interest(struct resource *resource, u_int64_t interest_mask);
bool is_resource_attr_interested(const struct resource *resource, u_int64_t interest_mask);
+const char *get_resource_name(struct resource *resource);
+void *get_resource_privdata(struct resource *resource);
+int get_resource_id(struct resource *resource);
+int get_resource_type(struct resource *resource);
+int get_resource_ts(struct resource *resource, int64_t *ts_start, int64_t *ts_end);
+
+int set_resource_privdata(struct resource *resource, void *priv);
+
inline __attribute__((always_inline)) int64_t get_time_now(void)
{
struct timeval tv;
#define RESOURCE_ATTR_INDEX(id) BIT64_INDEX(id)
#define RESOURCE_CTRL_INDEX(id) BIT64_INDEX(id)
+struct resource {
+ int id;
+ char *name;
+ const struct resource_driver *driver;
+ int type;
+ void *priv;
+
+ int num_attrs;
+ const struct resource_attribute *attrs;
+ struct resource_attribute_value *attrs_value;
+ int num_ctrls;
+ const struct resource_control *ctrls;
+ u_int64_t attr_interest;
+ u_int64_t attr_supported;
+
+ int64_t ts_start;
+ int64_t ts_end;
+};
+
static int g_resource_id;
static GList *g_resource_driver_head;
static GList *g_resource_device_head;
return true;
}
+
+const char *get_resource_name(struct resource *resource)
+{
+ return resource ? resource->name : NULL;
+}
+
+void *get_resource_privdata(struct resource *resource)
+{
+ return resource ? resource->priv : NULL;
+}
+
+int get_resource_id(struct resource *resource)
+{
+ return resource ? resource->id : -EINVAL;
+}
+
+int get_resource_type(struct resource *resource)
+{
+ return resource ? resource->type : -EINVAL;
+}
+
+int get_resource_ts(struct resource *resource, int64_t *ts_start, int64_t *ts_end)
+{
+ if (!resource)
+ return -EINVAL;
+
+ *ts_start = resource->ts_start;
+ *ts_end = resource->ts_end;
+
+ return 0;
+}
+
+int set_resource_privdata(struct resource *resource, void *priv)
+{
+ if (!resource)
+ return -EINVAL;
+
+ resource->priv = priv;
+
+ return 0;
+}