haptic: add check backend function 66/251366/2
authorYunmi Ha <yunmi.ha@samsung.com>
Wed, 13 Jan 2021 05:53:30 +0000 (14:53 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Wed, 13 Jan 2021 06:29:33 +0000 (15:29 +0900)
Change-Id: I5d463473d2a95d477fb54c6e40340f7641c8b52e
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
hal-api-device.pc.in
include/hal-haptic.h
packaging/hal-api-device.spec
src/haptic.c

index 30f2af2..739fabd 100644 (file)
@@ -3,7 +3,7 @@
 
 prefix=@PREFIX@
 exec_prefix=/usr
-libdir=@LIB_INSTALL_DIR@
+libdir=@LIB_INSTALL_DIR@/hal
 includedir=/usr/include
 
 Name: @PC_NAME@
index dfbeb54..942fca2 100644 (file)
@@ -26,6 +26,7 @@ extern "C" {
 
 int hal_device_haptic_get_backend(void);
 int hal_device_haptic_put_backend(void);
+int hal_device_haptic_check_backend(void);
 
 int hal_device_haptic_get_device_count(int *count);
 int hal_device_haptic_open_device(int *handle);
index c46950c..ceecfaa 100644 (file)
@@ -42,7 +42,7 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %files
 %manifest %{name}.manifest
 %license LICENSE.Apache-2.0
-%{_libdir}/hal/libhal-api-device.so.*
+%{_libdir}/hal/libhal-api-device.so*
 
 %files devel
 %manifest %{name}.manifest
index 72ffbbf..cb8d9ae 100644 (file)
@@ -37,13 +37,21 @@ int hal_device_haptic_get_backend(void)
                return -ENODEV;
        }
 
+       if (!g_haptic_funcs)
+               return -ENODEV;
+
+       if (!g_haptic_funcs->is_valid || !(g_haptic_funcs->is_valid())) {
+               hal_device_haptic_put_backend();
+               return -ENODEV;
+       }
+
        return 0;
 }
 
 int hal_device_haptic_put_backend(void)
 {
        if (!g_haptic_funcs)
-               return 0;
+               return -ENODEV;
 
        hal_common_put_backend(HAL_MODULE_DEVICE_HAPTIC, (void *)g_haptic_funcs);
        g_haptic_funcs = NULL;
@@ -51,6 +59,14 @@ int hal_device_haptic_put_backend(void)
        return 0;
 }
 
+int hal_device_haptic_check_backend(void)
+{
+       if (!g_haptic_funcs)
+               return -ENODEV;
+
+       return 0;
+}
+
 int hal_device_haptic_get_device_count(int *count)
 {
        if (!g_haptic_funcs || !g_haptic_funcs->get_device_count)