"device_type" : "disk",
"device_name" : "vda",
"device_config_path" : "/hal/etc/pass/pass-dummy.json"
+ }, {
+ "device_type" : "battery",
+ "device_name" : "battery",
+ "device_config_path" : "/hal/etc/pass/pass-dummy.json"
}
]
}
struct pass_resource_bus *bus = NULL;
struct pass_resource_gpu *gpu = NULL;
struct pass_resource_memory *memory = NULL;
+ struct pass_resource_battery *battery = NULL;
int ret;
/* Allocate memory */
goto err_gpu;
}
+ battery = calloc(1, sizeof(struct pass_resource_battery));
+ if (!battery) {
+ ret = -ENOMEM;
+ goto err_memory;
+ }
+
/* Initialize each h/w resource */
cpu->dvfs = cpufreq_dvfs_ops;
cpu->hotplug = cpu_hotplus_ops;
gpu->dvfs = gpu_dvfs_ops;
gpu->tmu = tmu_ops;
+ battery->tmu = tmu_ops;
+
memory->get_fault_around_bytes = memory_get_fault_around_bytes;
memory->set_fault_around_bytes = memory_set_fault_around_bytes;
power_funcs->bus = bus;
power_funcs->gpu = gpu;
power_funcs->memory = memory;
+ power_funcs->battery = battery;
*data = (void *)power_funcs;
return 0;
+err_memory:
+ free(memory);
err_gpu:
- if (gpu)
- free(gpu);
+ free(gpu);
err_bus:
- if (bus)
- free(bus);
+ free(bus);
err_cpu:
- if (cpu)
- free(cpu);
+ free(cpu);
err_funcs:
free(power_funcs);
funcs = (hal_backend_power_funcs *)data;
- if (funcs->cpu)
- free(funcs->cpu);
- if (funcs->bus)
- free(funcs->bus);
- if (funcs->gpu)
- free(funcs->gpu);
- if (funcs->memory)
- free(funcs->memory);
+ free(funcs->cpu);
+ free(funcs->bus);
+ free(funcs->gpu);
+ free(funcs->memory);
+ free(funcs->battery);
free(funcs);