[Replicant] [libsamsung-ipc][PATCH 1/4] Add IPC_CLIENT_TYPE_DUMMY

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Thu Jan 23 17:02:52 UTC 2020


The libsamsung-ipc logging system depends on having a valid ipc_client
struct which is created by ipc_client_create.

This enable libsamsung-ipc to be reused accross software stacks that use
different logging systems.

For instance the libsamsung-ipc can be used by libsamsung-ril which
integrates libsamsung-ipc logging to the Android logging system.

However this has several side effects:
- Standalone tools like nv_data-md5 that may not necessarily run
  on a device with a compatible modem and driver end up not
  printing many of the information it should be printing.
- As ipc_client_create tries to autodetect hardware and software
  configurations, and that logging is only available after it
  succeed, the early intialisation prints are not forwarded to
  the logging system.
  This can be an issue on Android as users and developers expect
  the logging to go to 'logcat' and getting the early logs require
  more extesive modification of the system.

This enables to create a dummy ipc_client with working logging.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 include/samsung-ipc.h |  1 +
 samsung-ipc/ipc.c     | 26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/samsung-ipc.h b/include/samsung-ipc.h
index 9d638ec..d495ba2 100644
--- a/include/samsung-ipc.h
+++ b/include/samsung-ipc.h
@@ -30,6 +30,7 @@
 
 #define IPC_CLIENT_TYPE_FMT                                     0x00
 #define IPC_CLIENT_TYPE_RFS                                     0x01
+#define IPC_CLIENT_TYPE_DUMMY                                   0x02
 
 /*
  * Structures
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index f7e0379..5387611 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -153,7 +153,18 @@ complete:
     return index;
 }
 
-struct ipc_client *ipc_client_create(int type)
+
+static struct ipc_client *ipc_dummy_client_create(void)
+{
+    struct ipc_client *client = NULL;
+
+    client = (struct ipc_client *) calloc(1, sizeof(struct ipc_client));
+    client->type = IPC_CLIENT_TYPE_DUMMY;
+
+    return client;
+}
+
+static struct ipc_client *ipc_transport_client_create(int type)
 {
     struct ipc_client *client = NULL;
     unsigned int device_index;
@@ -205,6 +216,19 @@ complete:
     return client;
 }
 
+struct ipc_client *ipc_client_create(int type)
+{
+    switch (type) {
+        case IPC_CLIENT_TYPE_RFS:
+        case IPC_CLIENT_TYPE_FMT:
+            return ipc_transport_client_create(type);
+        case IPC_CLIENT_TYPE_DUMMY:
+            return ipc_dummy_client_create();
+        default:
+             return NULL;
+    }
+}
+
 int ipc_client_destroy(struct ipc_client *client)
 {
     if (client == NULL)
-- 
2.24.1



More information about the Replicant mailing list