From: Jiyoung Yun Date: Thu, 5 Feb 2015 12:00:39 +0000 (+0900) Subject: libdevice-node: Add HARDWARE_MODULE_STRUCTURE define X-Git-Tag: submit/tizen/20150213.103227^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9298d6349a42a62be2b48d108bf8ea7bed1ac4bb;p=platform%2Fcore%2Fsystem%2Flibdevice-node.git libdevice-node: Add HARDWARE_MODULE_STRUCTURE define Change-Id: I3ab9e9455eeba8a6d2cd5ca3a65b2cc069d7b894 Signed-off-by: Jiyoung Yun --- diff --git a/hw/common.c b/hw/common.c index 3e2dc7a..66e1705 100644 --- a/hw/common.c +++ b/hw/common.c @@ -31,8 +31,15 @@ #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; diff --git a/hw/common.h b/hw/common.h index e14e705..b333532 100644 --- a/hw/common.h +++ b/hw/common.h @@ -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