device-battery: Fix incorrect module naming 26/309326/5
authorYunhee Seo <yuni.seo@samsung.com>
Mon, 8 Apr 2024 06:02:41 +0000 (15:02 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Mon, 15 Apr 2024 08:05:52 +0000 (17:05 +0900)
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>
haltest/battery.cpp
include/hal-battery-interface.h [deleted file]
include/hal-battery.h [deleted file]
include/hal-device-battery-interface.h [new file with mode: 0644]
include/hal-device-battery.h [new file with mode: 0644]
src/battery.c

index 5c433955e72c7fe6ae19171c3046451c4d3128ba..8baed63044a6af84564c2cb62b26d073d8a84c42 100644 (file)
@@ -1,7 +1,7 @@
 #include <system_info.h>
 
 #include "haltest.h"
-#include "hal-battery.h"
+#include "hal-device-battery.h"
 
 class BATTERY : public testing::Test {
        protected:
diff --git a/include/hal-battery-interface.h b/include/hal-battery-interface.h
deleted file mode 100644 (file)
index 00d06b5..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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__ */
diff --git a/include/hal-battery.h b/include/hal-battery.h
deleted file mode 100644 (file)
index 5dee8fd..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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__
diff --git a/include/hal-device-battery-interface.h b/include/hal-device-battery-interface.h
new file mode 100644 (file)
index 0000000..6ac77e1
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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__ */
diff --git a/include/hal-device-battery.h b/include/hal-device-battery.h
new file mode 100644 (file)
index 0000000..c84947f
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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__
index aa280622c3ae21639c6581706191050428226626..7556872043f47112c5d4ea37751491af3946312a 100644 (file)
 
 #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;
@@ -39,11 +39,11 @@ int hal_device_battery_get_backend(void)
 
 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;
 }
@@ -52,32 +52,32 @@ int hal_device_battery_register_changed_event(BatteryUpdated updated_cb, void *d
 {
        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;
 }
 
@@ -85,14 +85,14 @@ int hal_device_battery_get_current_state(BatteryUpdated updated_cb, void *data)
 {
        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);
 }