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 | |
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')
-rw-r--r-- | samsung-ipc/ipc.c | 51 | ||||
-rw-r--r-- | samsung-ipc/ipc_devices.c | 6 | ||||
-rw-r--r-- | samsung-ipc/ipc_devices.h | 1 |
3 files changed, 46 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; } diff --git a/samsung-ipc/ipc_devices.c b/samsung-ipc/ipc_devices.c index 559b34e..c104fdf 100644 --- a/samsung-ipc/ipc_devices.c +++ b/samsung-ipc/ipc_devices.c @@ -28,6 +28,7 @@ struct ipc_device_desc ipc_devices[] = { { .name = "crespo", .board_name = "herring", + .kernel_version = NULL, .fmt_ops = &crespo_fmt_ops, .rfs_ops = &crespo_rfs_ops, .handlers = &crespo_default_handlers, @@ -37,6 +38,7 @@ struct ipc_device_desc ipc_devices[] = { { .name = "aries", .board_name = "aries", + .kernel_version = NULL, .fmt_ops = &aries_fmt_ops, .rfs_ops = &aries_rfs_ops, .handlers = &aries_default_handlers, @@ -46,6 +48,7 @@ struct ipc_device_desc ipc_devices[] = { { .name = "aries", .board_name = "gt-p1000", + .kernel_version = NULL, .fmt_ops = &aries_fmt_ops, .rfs_ops = &aries_rfs_ops, .handlers = &aries_default_handlers, @@ -55,6 +58,7 @@ struct ipc_device_desc ipc_devices[] = { { .name = "galaxys2", .board_name = "i9100", + .kernel_version = NULL, .fmt_ops = &galaxys2_fmt_ops, .rfs_ops = &galaxys2_rfs_ops, .handlers = &galaxys2_default_handlers, @@ -64,6 +68,7 @@ struct ipc_device_desc ipc_devices[] = { { .name = "galaxys2", .board_name = "smdk4210", + .kernel_version = NULL, .fmt_ops = &galaxys2_fmt_ops, .rfs_ops = &galaxys2_rfs_ops, .handlers = &galaxys2_default_handlers, @@ -73,6 +78,7 @@ struct ipc_device_desc ipc_devices[] = { { .name = "maguro", .board_name = "tuna", + .kernel_version = NULL, .fmt_ops = &maguro_fmt_ops, .rfs_ops = &maguro_rfs_ops, .handlers = &maguro_default_handlers, diff --git a/samsung-ipc/ipc_devices.h b/samsung-ipc/ipc_devices.h index 2e028e2..a408997 100644 --- a/samsung-ipc/ipc_devices.h +++ b/samsung-ipc/ipc_devices.h @@ -26,6 +26,7 @@ struct ipc_device_desc { char *name; char *board_name; + char *kernel_version; struct ipc_ops *fmt_ops; struct ipc_ops *rfs_ops; |