diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2012-10-01 19:34:45 +0200 |
---|---|---|
committer | Simon Busch <morphis@gravedo.de> | 2012-10-13 17:06:19 +0200 |
commit | 896c02cd4cf1486a9984dd4ee61c8dac7aa95858 (patch) | |
tree | 630ae2dc03342dcbe5712e42778a1d4b28fad0a3 /samsung-ipc/ipc.c | |
parent | 9c23156c6d42384f0a8477b04a20419d606a2e2e (diff) | |
download | hardware_replicant_libsamsung-ipc-896c02cd4cf1486a9984dd4ee61c8dac7aa95858.tar.gz hardware_replicant_libsamsung-ipc-896c02cd4cf1486a9984dd4ee61c8dac7aa95858.tar.bz2 hardware_replicant_libsamsung-ipc-896c02cd4cf1486a9984dd4ee61c8dac7aa95858.zip |
Kernel version in IPC device desc, with detection code
Change-Id: Ica8dd604ddaff527436e9ba909ab7d22eda9a875
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc/ipc.c')
-rw-r--r-- | samsung-ipc/ipc.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c index d6b4b92..14d52c3 100644 --- a/samsung-ipc/ipc.c +++ b/samsung-ipc/ipc.c @@ -35,6 +35,7 @@ #include <sys/stat.h> #include <sys/types.h> #include <asm/types.h> +#include <sys/utsname.h> #include <radio.h> @@ -63,18 +64,13 @@ void ipc_client_log(struct ipc_client *client, const char *message, ...) int ipc_device_detect(void) { + char *device = NULL; + char *kernel_version = NULL; int index = -1; int i; #ifdef IPC_DEVICE_EXPLICIT - for (i=0 ; i < ipc_devices_count ; i++) - { - if (strcmp(IPC_DEVICE_EXPLICIT, ipc_devices[i].name) == 0) - { - index = i; - break; - } - } + device = strdup(IPC_DEVICE_EXPLICIT); #else char buf[4096]; @@ -100,18 +96,49 @@ int ipc_device_detect(void) str[i] = tmp; } - for (i=0 ; i < ipc_devices_count ; i++) + device = strdup(pch); + } + pch = strtok(NULL, "\n"); + } +#endif + +#ifdef IPC_KERNEL_VERSION_EXPLICIT + kernel_version = strdup(IPC_KERNEL_VERSION_EXPLICIT); +#else + struct utsname utsname; + memset(&utsname, 0, sizeof(utsname)); + + uname(&utsname); + + kernel_version = strdup(utsname.release); +#endif + + for (i=0 ; i < ipc_devices_count ; i++) + { + if (strcmp(device, ipc_devices[i].name) == 0) + { + if (ipc_devices[i].kernel_version != NULL) { - if (strstr(pch, ipc_devices[i].board_name) != NULL) + if (strncmp(kernel_version, ipc_devices[i].kernel_version, strlen(ipc_devices[i].kernel_version)) == 0) { index = i; break; + } else { + // Kernel version didn't match but it may still work + index = i; } + } else { + index = i; + break; } } - pch = strtok(NULL, "\n"); } -#endif + + if (device != NULL) + free(device); + + if (kernel_version != NULL) + free(kernel_version); return index; } |