diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2022-08-05 04:47:39 +0900 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2022-08-05 09:28:51 +0900 |
commit | 4539efcd6b86ba885c7993bda14d745411269b0e (patch) | |
tree | 499ce8f0ed9722cb82f7220a3174233798fb5cf9 | |
parent | e314ca7d6fe3320382f2c2629de1fb7e50275179 (diff) | |
download | power-emulator-4539efcd6b86ba885c7993bda14d745411269b0e.tar.gz power-emulator-4539efcd6b86ba885c7993bda14d745411269b0e.tar.bz2 power-emulator-4539efcd6b86ba885c7993bda14d745411269b0e.zip |
power-emulator: Add battery hal informationsubmit/tizen/20220805.011213accepted/tizen/unified/20220805.131739
Change-Id: If31c5d2254adcd4800e72ea404e5ec00b410fdd6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
-rw-r--r-- | scripts/pass.json | 4 | ||||
-rw-r--r-- | src/hal-backend-power.c | 34 |
2 files changed, 24 insertions, 14 deletions
diff --git a/scripts/pass.json b/scripts/pass.json index 6178d54..557f286 100644 --- a/scripts/pass.json +++ b/scripts/pass.json @@ -21,6 +21,10 @@ "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" } ] } diff --git a/src/hal-backend-power.c b/src/hal-backend-power.c index 2a9bd7f..ce7606f 100644 --- a/src/hal-backend-power.c +++ b/src/hal-backend-power.c @@ -470,6 +470,7 @@ static int power_init(void **data) 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 */ @@ -501,6 +502,12 @@ static int power_init(void **data) 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; @@ -512,6 +519,8 @@ static int power_init(void **data) 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; @@ -520,20 +529,20 @@ static int power_init(void **data) 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); @@ -549,14 +558,11 @@ static int power_exit(void *data) 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); |