summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunhee Seo <yuni.seo@samsung.com>2024-04-16 16:25:46 +0900
committerYunhee Seo <yuni.seo@samsung.com>2024-04-16 17:05:50 +0900
commitbb9ce529c06f0c2a499d4b2751c1dc8365cb5d70 (patch)
treeb7d71c630b290b8c56fc0c6c60e2139bc369b8d8
parentc6a298bb12b9f972adb1e64fcad782593b42929c (diff)
downloaddevice-emulator-bb9ce529c06f0c2a499d4b2751c1dc8365cb5d70.tar.gz
device-emulator-bb9ce529c06f0c2a499d4b2751c1dc8365cb5d70.tar.bz2
device-emulator-bb9ce529c06f0c2a499d4b2751c1dc8365cb5d70.zip
battery: Apply HAL ABI versioning
To support OS upgrade feature, hal-backend and hal-api module needs HAL ABI versioning. So, major/minor version is added to hal_backend structure. While applying HAL ABI versioning, hal_backend_[module]_funcs is allocated from hal-api-[module] side. Thus, allocation is moved to hal-api-device-battery side. Change-Id: I30ac0eafdecab58ce88d97cc5013a11997113fe8 Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
-rw-r--r--hw/battery/battery.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/hw/battery/battery.c b/hw/battery/battery.c
index c5a9b10..5d74236 100644
--- a/hw/battery/battery.c
+++ b/hw/battery/battery.c
@@ -43,7 +43,7 @@
#define FILE_BATTERY_CHARGE_NOW "/sys/class/power_supply/battery/charge_now"
static struct signal_data {
- BatteryUpdated updated_cb;
+ hal_device_battery_updated_cb updated_cb;
void *data;
} sdata = { 0, };
@@ -56,13 +56,13 @@ static int get_power_source(int online, char **src)
switch (online) {
case 2:
- *src = POWER_SOURCE_AC;
+ *src = HAL_DEVICE_BATTERY_POWER_SOURCE_AC;
break;
case 4:
- *src = POWER_SOURCE_USB;
+ *src = HAL_DEVICE_BATTERY_POWER_SOURCE_USB;
break;
default:
- *src = POWER_SOURCE_NONE;
+ *src = HAL_DEVICE_BATTERY_POWER_SOURCE_NONE;
break;
}
@@ -77,7 +77,7 @@ static void signal_delivered(GDBusConnection *conn,
GVariant *parameters,
gpointer user_data)
{
- struct battery_info info;
+ hal_device_battery_info_s info;
int num, ret;
char *sig, *capacity, *status, *health, *online, *present;
char *val;
@@ -95,7 +95,7 @@ static void signal_delivered(GDBusConnection *conn,
g_variant_get(parameters, "(sisssss)", &sig, &num,
&capacity, &status, &health, &online, &present);
- info.name = BATTERY_HARDWARE_DEVICE_ID;
+ info.name = HAL_DEVICE_BATTERY_HARDWARE_DEVICE_ID;
info.status = status;
info.health = health;
info.online = atoi(online);
@@ -132,7 +132,7 @@ out:
}
static int battery_register_changed_event(
- BatteryUpdated updated_cb, void *data)
+ hal_device_battery_updated_cb updated_cb, void *data)
{
if (sdata.updated_cb) {
_E("update callback is already registered");
@@ -154,7 +154,7 @@ static int battery_register_changed_event(
}
static void battery_unregister_changed_event(
- BatteryUpdated updated_cb)
+ hal_device_battery_updated_cb updated_cb)
{
if (signal_id > 0) {
gdbus_signal_unsubscribe(NULL, signal_id);
@@ -165,10 +165,10 @@ static void battery_unregister_changed_event(
}
static int battery_get_current_state(
- BatteryUpdated updated_cb, void *data)
+ hal_device_battery_updated_cb updated_cb, void *data)
{
int ret;
- struct battery_info info;
+ hal_device_battery_info_s info;
char *status;
char *val;
char capacity_str[8];
@@ -180,7 +180,7 @@ static int battery_get_current_state(
if (!updated_cb)
return -EINVAL;
- info.name = BATTERY_HARDWARE_DEVICE_ID;
+ info.name = HAL_DEVICE_BATTERY_HARDWARE_DEVICE_ID;
ret = sys_get_str(FILE_BATTERY_CAPACITY, capacity_str, sizeof(capacity_str));
if (ret < 0) {
@@ -265,9 +265,14 @@ static int battery_init(void **data)
{
hal_backend_device_battery_funcs *device_battery_funcs;
- device_battery_funcs = calloc(1, sizeof(hal_backend_device_battery_funcs));
+ if (!data) {
+ _E("Invalid parameter");
+ return -EINVAL;
+ }
+
+ device_battery_funcs = *(hal_backend_device_battery_funcs **) data;
if (!device_battery_funcs)
- return -ENOMEM;
+ return -EINVAL;
device_battery_funcs->register_changed_event = battery_register_changed_event;
device_battery_funcs->unregister_changed_event = battery_unregister_changed_event;