libdevice-node: Add HARDWARE_MODULE_STRUCTURE define 92/34992/1 accepted/tizen/common/20150213.145211 accepted/tizen/mobile/20150215.073624 accepted/tizen/tv/20150215.072632 accepted/tizen/wearable/20150215.072952 submit/tizen/20150213.103227
authorJiyoung Yun <jy910.yun@samsung.com>
Thu, 5 Feb 2015 12:00:39 +0000 (21:00 +0900)
committerJiyoung Yun <jy910.yun@samsung.com>
Thu, 5 Feb 2015 12:00:39 +0000 (21:00 +0900)
Change-Id: I3ab9e9455eeba8a6d2cd5ca3a65b2cc069d7b894
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
hw/common.c
hw/common.h

index 3e2dc7a445c131ccdc914c6992f13ea4ebe2f6a2..66e17052abe162b09bcee9987024a6336a1b4faf 100644 (file)
 #define EXPORT __attribute__ ((visibility("default")))
 #endif
 
+#ifndef LIBPATH
+#error LIBPATH is not defined.
+#endif
+
 #define MODULE_PATH                    LIBPATH"/hw"
 
+#define STRINGIZE2(s)  #s
+#define STRINGIZE(s)   STRINGIZE2(s)
+
 EXPORT
 int hw_get_info(const char *id, const struct hw_info **info)
 {
@@ -40,7 +47,7 @@ int hw_get_info(const char *id, const struct hw_info **info)
        void *handle;
        struct hw_info *it;
 
-       if (!*info || !id)
+       if (!info || !id)
                return -EINVAL;
 
        /* Find matched module path */
@@ -58,7 +65,7 @@ int hw_get_info(const char *id, const struct hw_info **info)
        }
 
        /* Get the address of struct hw_common */
-       it = dlsym(handle, HARDWARE_INFO_SYM_AS_STR);
+       it = dlsym(handle, STRINGIZE(HARDWARE_INFO_SYM));
        if (!it) {
                _E("fail to find symbol : %s", dlerror());
                goto error;
index e14e70587c6046bc78c3f946fc0cb5ba80522700..b333532750542af0ff8d21888baa78639ad213b3 100644 (file)
@@ -68,11 +68,18 @@ struct hw_common {
  */
 #define HARDWARE_INFO_SYM              TizenHwInfo
 
+int hw_get_info(const char *id, const struct hw_info **info);
+
 /**
- * Name of the hardware info symbolic as a string
+ * Structure define of hardware info module
+ * All hardware module should be use below define
+ * to make a specific structure for Tizen HAL.
+ * hw_get_info function will load a hw_info structure
+ * by using TizenHwInfo name at runtime.
+ * TizenHwInfo means Tizen Hardware Info.
  */
-#define HARDWARE_INFO_SYM_AS_STR       "TizenHwInfo"
-
-int hw_get_info(const char *id, const struct hw_info **info);
+#define HARDWARE_MODULE_STRUCTURE      \
+       __attribute__ ((visibility("default"))) \
+       struct hw_info HARDWARE_INFO_SYM
 
 #endif