From: Ruchi Kandoi Date: Fri, 4 Nov 2016 16:56:58 +0000 (-0700) Subject: exynos: libmemtrack: Add open method for memtrack X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=660f356d29f57b9568ac25b3922ed316a04868f6;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_exynos.git exynos: libmemtrack: Add open method for memtrack Open method is used to dl-open the HAL for hidl. Test: HIDL successfully loads the HAL Bug: 31180823 Signed-off-by: Ruchi Kandoi Change-Id: I2452e2d749b9ab7b4f5722b1ce79ae64032d12ee --- diff --git a/libmemtrack/memtrack_exynos.c b/libmemtrack/memtrack_exynos.c index 77fa96e..1c3b796 100644 --- a/libmemtrack/memtrack_exynos.c +++ b/libmemtrack/memtrack_exynos.c @@ -15,6 +15,9 @@ */ #include +#include +#include +#include #include @@ -40,8 +43,38 @@ int exynos_memtrack_get_memory(const struct memtrack_module __unused *module, return -EINVAL; } +static int memtrack_open(__attribute__((unused)) const hw_module_t* module, const char* name, + hw_device_t** device) +{ + ALOGD("%s: enter; name=%s", __FUNCTION__, name); + int retval = 0; /* 0 is ok; -1 is error */ + + if (strcmp(name, "memtrack") == 0) { + struct memtrack_module *dev = (struct memtrack_module *)calloc(1, + sizeof(struct memtrack_module)); + + if (dev) { + /* Common hw_device_t fields */ + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.module_api_version = MEMTRACK_MODULE_API_VERSION_0_1; + dev->common.hal_api_version = HARDWARE_HAL_API_VERSION; + + dev->init = exynos_memtrack_init; + dev->getMemory = exynos_memtrack_get_memory; + + *device = (hw_device_t*)dev; + } else + retval = -ENOMEM; + } else { + retval = -EINVAL; + } + + ALOGD("%s: exit %d", __FUNCTION__, retval); + return retval; +} + static struct hw_module_methods_t memtrack_module_methods = { - .open = NULL, + .open = memtrack_open, }; struct memtrack_module HAL_MODULE_INFO_SYM = {