[Replicant] [PATCH] libsamsung-ipc: improve board drivers print (issue #2150)

belgin belginstirbu at hotmail.com
Sat Nov 21 12:26:36 UTC 2020


---
 samsung-ipc/devices/galaxys2/galaxys2.c | 76 ++++++++++++++++++++-----
 samsung-ipc/devices/i9300/i9300.c       | 45 ++++++++++++---
 samsung-ipc/devices/n5100/n5100.c       | 41 ++++++++++---
 samsung-ipc/devices/n7100/n7100.c       | 39 ++++++++++---
 4 files changed, 161 insertions(+), 40 deletions(-)

diff --git a/samsung-ipc/devices/galaxys2/galaxys2.c b/samsung-ipc/devices/galaxys2/galaxys2.c
index 8b96893..a16982b 100644
--- a/samsung-ipc/devices/galaxys2/galaxys2.c
+++ b/samsung-ipc/devices/galaxys2/galaxys2.c
@@ -74,25 +74,55 @@ int galaxys2_boot(struct ipc_client *client)
     ipc_client_log(client, "Opened modem link device");
 
     rc = xmm626_sec_modem_power(modem_boot_fd, 0);
-    rc |= xmm626_sec_modem_link_control_enable(modem_link_fd, 0);
-    rc |= xmm626_sec_modem_hci_power(0);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 0);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering off the modem failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 0);
+    if (rc < 0) {
+        ipc_client_log(client, "Disabling the modem link failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_hci_power(0);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering off the HCI bus failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 0);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem off failed");
+        ipc_client_log(client, "Deactivating the modem link failed");
         goto error;
     }
+
     ipc_client_log(client, "Turned the modem off");
 
     rc = xmm626_sec_modem_power(modem_boot_fd, 1);
-    rc |= xmm626_sec_modem_link_control_enable(modem_link_fd, 1);
-    rc |= xmm626_sec_modem_hci_power(1);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 1);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering on the modem failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 1);
+    if (rc < 0) {
+        ipc_client_log(client, "Enabling the modem link failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_hci_power(1);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering on the HCI bus failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 1);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem on failed");
+        ipc_client_log(client, "Activating the modem link failed");
         goto error;
     }
+
     ipc_client_log(client, "Turned the modem on");
 
     rc = xmm626_sec_modem_link_connected_wait(modem_link_fd);
@@ -174,11 +204,20 @@ int galaxys2_boot(struct ipc_client *client)
     }
 
     rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 0);
-    rc |= xmm626_sec_modem_hci_power(0);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 0);
+    if (rc < 0) {
+        ipc_client_log(client, "Disabling the modem link failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_hci_power(0);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering off the HCI bus failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 0);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem off failed");
+        ipc_client_log(client, "Deactivating the modem link failed");
         goto error;
     }
 
@@ -190,11 +229,20 @@ int galaxys2_boot(struct ipc_client *client)
     ipc_client_log(client, "Waited for host wake");
 
     rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 1);
-    rc |= xmm626_sec_modem_hci_power(1);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 1);
+    if (rc < 0) {
+        ipc_client_log(client, "Enabling the modem link failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_hci_power(1);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering on the HCI bus failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 1);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem on failed");
+        ipc_client_log(client, "Activating the modem link failed");
         goto error;
     }
 
diff --git a/samsung-ipc/devices/i9300/i9300.c b/samsung-ipc/devices/i9300/i9300.c
index c0d3cb1..06ed9c0 100644
--- a/samsung-ipc/devices/i9300/i9300.c
+++ b/samsung-ipc/devices/i9300/i9300.c
@@ -75,18 +75,26 @@ int i9300_boot(struct ipc_client *client)
 
     rc = xmm626_sec_modem_hci_power(0);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem off failed");
+        ipc_client_log(client, "Powering off the HCI bus failed");
         goto error;
     }
+
     ipc_client_log(client, "Turned the modem off");
 
     rc = xmm626_sec_modem_power(modem_boot_fd, 1);
-    rc |= xmm626_sec_modem_hci_power(1);
 
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem on failed");
+        ipc_client_log(client, "Powering on the modem failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_hci_power(1);
+
+    if (rc < 0) {
+        ipc_client_log(client, "Powering on the HCI bus failed");
         goto error;
     }
+
     ipc_client_log(client, "Turned the modem on");
 
     rc = xmm626_sec_modem_link_connected_wait(modem_link_fd);
@@ -167,12 +175,22 @@ int i9300_boot(struct ipc_client *client)
         ipc_client_log(client, "Waiting for host wake failed");
     }
 
+
     rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 0);
-    rc |= xmm626_sec_modem_hci_power(0);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 0);
+    if (rc < 0) {
+        ipc_client_log(client, "Disabling the modem link failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_hci_power(0);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem off failed");
+        ipc_client_log(client, "Powering off the HCI bus failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 0);
+    if (rc < 0) {
+        ipc_client_log(client, "Deactivating the modem link failed");
         goto error;
     }
 
@@ -184,11 +202,20 @@ int i9300_boot(struct ipc_client *client)
     ipc_client_log(client, "Waited for host wake");
 
     rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 1);
-    rc |= xmm626_sec_modem_hci_power(1);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 1);
+    if (rc < 0) {
+        ipc_client_log(client, "Enabling the modem link failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_hci_power(1);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering on the HCI bus failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 1);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem on failed");
+        ipc_client_log(client, "Activating the modem link failed");
         goto error;
     }
 
diff --git a/samsung-ipc/devices/n5100/n5100.c b/samsung-ipc/devices/n5100/n5100.c
index 78d1f1f..b7414c8 100644
--- a/samsung-ipc/devices/n5100/n5100.c
+++ b/samsung-ipc/devices/n5100/n5100.c
@@ -76,18 +76,23 @@ int n5100_boot(struct ipc_client *client)
 
     rc = xmm626_sec_modem_hci_power(0);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem off failed");
+        ipc_client_log(client, "Powering off the modem failed");
         goto error;
     }
     ipc_client_log(client, "Turned the modem off");
 
     rc = xmm626_sec_modem_power(modem_boot_fd, 1);
-    rc |= xmm626_sec_modem_hci_power(1);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering on the modem failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_hci_power(1);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem on failed");
+        ipc_client_log(client, "Powering on the HCI bus failed");
         goto error;
     }
+
     ipc_client_log(client, "Turned the modem on");
 
     rc = xmm626_sec_modem_link_connected_wait(modem_link_fd);
@@ -169,11 +174,20 @@ int n5100_boot(struct ipc_client *client)
     }
 
     rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 0);
-    rc |= xmm626_sec_modem_hci_power(0);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 0);
+    if (rc < 0) {
+        ipc_client_log(client, "Disabling the modem link failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_hci_power(0);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem off failed");
+        ipc_client_log(client, "Powering off the HCI bus failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 0);
+    if (rc < 0) {
+        ipc_client_log(client, "Deactivating the modem link failed");
         goto error;
     }
 
@@ -185,11 +199,20 @@ int n5100_boot(struct ipc_client *client)
     ipc_client_log(client, "Waited for host wake");
 
     rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 1);
-    rc |= xmm626_sec_modem_hci_power(1);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 1);
+    if (rc < 0) {
+        ipc_client_log(client, "Enabling the modem link failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_hci_power(1);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering on the HCI bus failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 1);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem on failed");
+        ipc_client_log(client, "Activating the modem link failed");
         goto error;
     }
 
diff --git a/samsung-ipc/devices/n7100/n7100.c b/samsung-ipc/devices/n7100/n7100.c
index eb2005b..c4426fd 100644
--- a/samsung-ipc/devices/n7100/n7100.c
+++ b/samsung-ipc/devices/n7100/n7100.c
@@ -81,12 +81,17 @@ int n7100_boot(struct ipc_client *client)
     ipc_client_log(client, "Turned the modem off");
 
     rc = xmm626_sec_modem_power(modem_boot_fd, 1);
-    rc |= xmm626_sec_modem_hci_power(1);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering on the modem failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_hci_power(1);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem on failed");
+        ipc_client_log(client, "Powering on the HCI bus failed");
         goto error;
     }
+
     ipc_client_log(client, "Turned the modem on");
 
     rc = xmm626_sec_modem_link_connected_wait(modem_link_fd);
@@ -168,11 +173,20 @@ int n7100_boot(struct ipc_client *client)
     }
 
     rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 0);
-    rc |= xmm626_sec_modem_hci_power(0);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 0);
+    if (rc < 0) {
+        ipc_client_log(client, "Disabling the modem link failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_hci_power(0);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem off failed");
+        ipc_client_log(client, "Powering off the HCI bus failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 0);
+    if (rc < 0) {
+        ipc_client_log(client, "Deactivating the modem link failed");
         goto error;
     }
 
@@ -184,11 +198,20 @@ int n7100_boot(struct ipc_client *client)
     ipc_client_log(client, "Waited for host wake");
 
     rc = xmm626_sec_modem_link_control_enable(modem_link_fd, 1);
-    rc |= xmm626_sec_modem_hci_power(1);
-    rc |= xmm626_sec_modem_link_control_active(modem_link_fd, 1);
+    if (rc < 0) {
+        ipc_client_log(client, "Enabling the modem link failed");
+        goto error;
+    }
+
+    rc = xmm626_sec_modem_hci_power(1);
+    if (rc < 0) {
+        ipc_client_log(client, "Powering on the HCI bus failed");
+        goto error;
+    }
 
+    rc = xmm626_sec_modem_link_control_active(modem_link_fd, 1);
     if (rc < 0) {
-        ipc_client_log(client, "Turning the modem on failed");
+        ipc_client_log(client, "Activating the modem link failed");
         goto error;
     }
 
-- 
2.17.1



More information about the Replicant mailing list