Fix incorrect module name from "battery" to "device-battery".
struct
- hal_backend_battery_funcs -> struct hal_backend_device_battery_funcs
file
- hal-battery.h -> hal-device-battery.h
- hal-battery-interface.h -> hal-device-battery-interface.h
According to HAL API Prototype rule,
hal module funcs structure naming is same as below
- hal_backend_[module]_funcs.
Also, hal module header files naming is same as below.
- hal-[module].h
- hal-[module]-interface.h
However, the hal module name was being used incorrectly.
Actual hal module name is not "battery" but "device-battery".
Change-Id: I8e4b648b497b8aded8de390c45736434912aadf3
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
#include <system_info.h>
#include "haltest.h"
-#include "hal-battery.h"
+#include "hal-device-battery.h"
class BATTERY : public testing::Test {
protected:
+++ /dev/null
-/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef __HAL_BATTERY_INTERFACE_H__
-#define __HAL_BATTERY_INTERFACE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * The id of this device
- */
-#define BATTERY_HARDWARE_DEVICE_ID "battery"
-
-#define POWER_SOURCE_NONE "none"
-#define POWER_SOURCE_AC "ac"
-#define POWER_SOURCE_USB "usb"
-#define POWER_SOURCE_WIRELESS "wireless"
-
-struct battery_info {
- char *name;
- char *status;
- char *health;
- char *power_source;
-
- int online;
- int present;
- int capacity;
-
- int current_now;
- int current_average;
- int voltage_now;
- int voltage_average;
- int temperature;
-};
-
-typedef void (*BatteryUpdated)(struct battery_info *info, void *data);
-
-typedef struct _hal_backend_battery_funcs {
- /* Register battery event */
- int (*register_changed_event)(BatteryUpdated updated_cb, void *data);
- void (*unregister_changed_event)(BatteryUpdated updated_cb);
-
- /* Get current states */
- int (*get_current_state)(BatteryUpdated updated_cb, void *data);
-} hal_backend_battery_funcs;
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __HAL_BATTERY_INTERFACE_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef __HAL_BATTERY_H__
-#define __HAL_BATTERY_H__
-
-#include "hal-battery-interface.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int hal_device_battery_get_backend(void);
-int hal_device_battery_put_backend(void);
-int hal_device_battery_register_changed_event(BatteryUpdated updated_cb, void *data);
-int hal_device_battery_unregister_changed_event(BatteryUpdated updated_cb);
-int hal_device_battery_get_current_state(BatteryUpdated updated_cb, void *data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __HAL_BATTERY_H__
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __HAL_DEVICE_BATTERY_INTERFACE_H__
+#define __HAL_DEVICE_BATTERY_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * The id of this device
+ */
+#define BATTERY_HARDWARE_DEVICE_ID "battery"
+
+#define POWER_SOURCE_NONE "none"
+#define POWER_SOURCE_AC "ac"
+#define POWER_SOURCE_USB "usb"
+#define POWER_SOURCE_WIRELESS "wireless"
+
+struct battery_info {
+ char *name;
+ char *status;
+ char *health;
+ char *power_source;
+
+ int online;
+ int present;
+ int capacity;
+
+ int current_now;
+ int current_average;
+ int voltage_now;
+ int voltage_average;
+ int temperature;
+};
+
+typedef void (*BatteryUpdated)(struct battery_info *info, void *data);
+
+typedef struct _hal_backend_device_battery_funcs {
+ /* Register battery event */
+ int (*register_changed_event)(BatteryUpdated updated_cb, void *data);
+ void (*unregister_changed_event)(BatteryUpdated updated_cb);
+
+ /* Get current states */
+ int (*get_current_state)(BatteryUpdated updated_cb, void *data);
+} hal_backend_device_battery_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_DEVICE_BATTERY_INTERFACE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __HAL_DEVICE_BATTERY_H__
+#define __HAL_DEVICE_BATTERY_H__
+
+#include "hal-device-battery-interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int hal_device_battery_get_backend(void);
+int hal_device_battery_put_backend(void);
+int hal_device_battery_register_changed_event(BatteryUpdated updated_cb, void *data);
+int hal_device_battery_unregister_changed_event(BatteryUpdated updated_cb);
+int hal_device_battery_get_current_state(BatteryUpdated updated_cb, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __HAL_DEVICE_BATTERY_H__
#include <hal/hal-common.h>
-#include "hal-battery-interface.h"
+#include "hal-device-battery-interface.h"
#include "common.h"
-static hal_backend_battery_funcs *hal_battery_funcs = NULL;
+static hal_backend_device_battery_funcs *hal_device_battery_funcs = NULL;
int hal_device_battery_get_backend(void)
{
int ret;
- if (hal_battery_funcs)
+ if (hal_device_battery_funcs)
return 0;
- ret = hal_common_get_backend(HAL_MODULE_DEVICE_BATTERY, (void **)&hal_battery_funcs);
+ ret = hal_common_get_backend(HAL_MODULE_DEVICE_BATTERY, (void **)&hal_device_battery_funcs);
if (ret < 0) {
_E("Failed to get battery backend");
return -EINVAL;
int hal_device_battery_put_backend(void)
{
- if (!hal_battery_funcs)
+ if (!hal_device_battery_funcs)
return 0;
- hal_common_put_backend(HAL_MODULE_DEVICE_BATTERY, (void *)hal_battery_funcs);
- hal_battery_funcs = NULL;
+ hal_common_put_backend(HAL_MODULE_DEVICE_BATTERY, (void *)hal_device_battery_funcs);
+ hal_device_battery_funcs = NULL;
return 0;
}
{
int ret;
- if (!hal_battery_funcs) {
+ if (!hal_device_battery_funcs) {
if ((ret = hal_device_battery_get_backend()) < 0)
return ret;
}
- if (!hal_battery_funcs ||
- !hal_battery_funcs->register_changed_event)
+ if (!hal_device_battery_funcs ||
+ !hal_device_battery_funcs->register_changed_event)
return -ENODEV;
- return hal_battery_funcs->register_changed_event(updated_cb, data);
+ return hal_device_battery_funcs->register_changed_event(updated_cb, data);
}
int hal_device_battery_unregister_changed_event(BatteryUpdated updated_cb)
{
int ret;
- if (!hal_battery_funcs) {
+ if (!hal_device_battery_funcs) {
if ((ret = hal_device_battery_get_backend()) < 0)
return ret;
}
- if (!hal_battery_funcs ||
- !hal_battery_funcs->unregister_changed_event)
+ if (!hal_device_battery_funcs ||
+ !hal_device_battery_funcs->unregister_changed_event)
return -ENODEV;
- hal_battery_funcs->unregister_changed_event(updated_cb);
+ hal_device_battery_funcs->unregister_changed_event(updated_cb);
return 0;
}
{
int ret;
- if (!hal_battery_funcs) {
+ if (!hal_device_battery_funcs) {
if ((ret = hal_device_battery_get_backend()) < 0)
return ret;
}
- if (!hal_battery_funcs ||
- !hal_battery_funcs->get_current_state)
+ if (!hal_device_battery_funcs ||
+ !hal_device_battery_funcs->get_current_state)
return -ENODEV;
- return hal_battery_funcs->get_current_state(updated_cb, data);
+ return hal_device_battery_funcs->get_current_state(updated_cb, data);
}