[Replicant] [libsamsung-ipc][PATCHv2] devices: aries: cosmetic cleanups

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Thu Feb 6 05:32:01 UTC 2020


- Whitespaces were unified to use 4 spaces as stated by the
  last line that has vim settings.
- The line length was limited to 80 characters with the exception
  of the aries_gprs_get_capabilities function where it didn't make
  sense to try to split it as the result would look counter intuitive.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 samsung-ipc/devices/aries/aries.c | 91 ++++++++++++++++++++-----------
 1 file changed, 59 insertions(+), 32 deletions(-)

diff --git a/samsung-ipc/devices/aries/aries.c b/samsung-ipc/devices/aries/aries.c
index e41a4e2..7b39688 100644
--- a/samsung-ipc/devices/aries/aries.c
+++ b/samsung-ipc/devices/aries/aries.c
@@ -57,12 +57,16 @@ int aries_boot(struct ipc_client *client)
     int rc;
     int i;
 
-    if (client == NULL || client->handlers == NULL || client->handlers->power_on == NULL || client->handlers->power_off == NULL)
-        return -1;
+    if (client == NULL || client->handlers == NULL ||
+        client->handlers->power_on == NULL ||
+        client->handlers->power_off == NULL) {
+      return -1;
+    }
 
     ipc_client_log(client, "Starting aries modem boot");
 
-    modem_image_data = file_data_read(client, ARIES_MODEM_IMAGE_DEVICE, ARIES_MODEM_IMAGE_SIZE, 0x1000, 0);
+    modem_image_data = file_data_read(client, ARIES_MODEM_IMAGE_DEVICE,
+                                      ARIES_MODEM_IMAGE_SIZE, 0x1000, 0);
     if (modem_image_data == NULL) {
         ipc_client_log(client, "Reading modem image data failed");
         goto error;
@@ -148,7 +152,8 @@ int aries_boot(struct ipc_client *client)
     } while (onedram_init != ARIES_ONEDRAM_INIT);
     ipc_client_log(client, "Read onedram init (0x%x)", onedram_init);
 
-    onedram_address = mmap(NULL, ARIES_ONEDRAM_MEMORY_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, onedram_fd, 0);
+    onedram_address = mmap(NULL, ARIES_ONEDRAM_MEMORY_SIZE,
+                           PROT_READ|PROT_WRITE, MAP_SHARED, onedram_fd, 0);
     if (onedram_address == NULL || onedram_address == (void *) 0xffffffff) {
             ipc_client_log(client, "Mapping onedram to memory failed");
             goto error;
@@ -157,7 +162,8 @@ int aries_boot(struct ipc_client *client)
 
     pp = (unsigned char *) onedram_address;
 
-    rc = xmm616_firmware_send(client, -1, (void *) pp, (void *) p, ARIES_MODEM_IMAGE_SIZE - ARIES_PSI_SIZE);
+    rc = xmm616_firmware_send(client, -1, (void *) pp, (void *) p,
+                              ARIES_MODEM_IMAGE_SIZE - ARIES_PSI_SIZE);
     if (rc < 0) {
         ipc_client_log(client, "Sending XMM616 firmware failed");
         goto error;
@@ -247,8 +253,10 @@ int aries_fmt_send(struct ipc_client *client, struct ipc_message *message)
     unsigned char *p;
     int rc;
 
-    if (client == NULL || client->handlers == NULL || client->handlers->write == NULL || message == NULL)
-        return -1;
+    if (client == NULL || client->handlers == NULL ||
+        client->handlers->write == NULL || message == NULL) {
+      return -1;
+    }
 
     ipc_fmt_header_setup(&header, message);
 
@@ -267,9 +275,11 @@ int aries_fmt_send(struct ipc_client *client, struct ipc_message *message)
     p = (unsigned char *) buffer;
 
     while (count < length) {
-        chunk = length - count < ARIES_BUFFER_LENGTH ? length - count : ARIES_BUFFER_LENGTH;
+        chunk = (length - count) < ARIES_BUFFER_LENGTH ?
+          length - count : ARIES_BUFFER_LENGTH;
 
-        rc = client->handlers->write(client->handlers->transport_data, p, chunk);
+        rc = client->handlers->write(client->handlers->transport_data, p,
+                                     chunk);
         if (rc < 0) {
             ipc_client_log(client, "Writing FMT data failed");
             goto error;
@@ -302,13 +312,16 @@ int aries_fmt_recv(struct ipc_client *client, struct ipc_message *message)
     unsigned char *p;
     int rc;
 
-    if (client == NULL || client->handlers == NULL || client->handlers->read == NULL || message == NULL)
-        return -1;
+    if (client == NULL || client->handlers == NULL ||
+        client->handlers->read == NULL || message == NULL) {
+      return -1;
+    }
 
     length = ARIES_BUFFER_LENGTH;
     buffer = calloc(1, length);
 
-    rc = client->handlers->read(client->handlers->transport_data, buffer, length);
+    rc = client->handlers->read(client->handlers->transport_data, buffer,
+                                length);
     if (rc < (int) sizeof(struct ipc_fmt_header)) {
         ipc_client_log(client, "Reading FMT header failed");
         goto error;
@@ -333,7 +346,8 @@ int aries_fmt_recv(struct ipc_client *client, struct ipc_message *message)
     p = (unsigned char *) message->data + count;
 
     while (count < length) {
-        chunk = length - count < ARIES_BUFFER_LENGTH ? length - count : ARIES_BUFFER_LENGTH;
+        chunk = (length - count) < ARIES_BUFFER_LENGTH ?
+          length - count : ARIES_BUFFER_LENGTH;
 
         rc = client->handlers->read(client->handlers->transport_data, p, chunk);
         if (rc < 0) {
@@ -370,8 +384,10 @@ int aries_rfs_send(struct ipc_client *client, struct ipc_message *message)
     unsigned char *p;
     int rc;
 
-    if (client == NULL || client->handlers == NULL || client->handlers->write == NULL || message == NULL)
-        return -1;
+    if (client == NULL || client->handlers == NULL ||
+        client->handlers->write == NULL || message == NULL) {
+      return -1;
+    }
 
     ipc_rfs_header_setup(&header, message);
 
@@ -389,9 +405,11 @@ int aries_rfs_send(struct ipc_client *client, struct ipc_message *message)
     p = (unsigned char *) buffer;
 
     while (count < length) {
-        chunk = length - count < ARIES_BUFFER_LENGTH ? length - count : ARIES_BUFFER_LENGTH;
+        chunk = (length - count) < ARIES_BUFFER_LENGTH ?
+          length - count : ARIES_BUFFER_LENGTH;
 
-        rc = client->handlers->write(client->handlers->transport_data, p, chunk);
+        rc = client->handlers->write(client->handlers->transport_data,
+                                     p, chunk);
         if (rc < 0) {
             ipc_client_log(client, "Writing RFS data failed");
             goto error;
@@ -424,13 +442,16 @@ int aries_rfs_recv(struct ipc_client *client, struct ipc_message *message)
     unsigned char *p;
     int rc;
 
-    if (client == NULL || client->handlers == NULL || client->handlers->read == NULL || message == NULL)
-        return -1;
+    if (client == NULL || client->handlers == NULL ||
+        client->handlers->read == NULL || message == NULL) {
+      return -1;
+    }
 
     length = ARIES_BUFFER_LENGTH;
     buffer = calloc(1, length);
 
-    rc = client->handlers->read(client->handlers->transport_data, buffer, length);
+    rc = client->handlers->read(client->handlers->transport_data, buffer,
+                                length);
     if (rc < (int) sizeof(struct ipc_rfs_header)) {
         ipc_client_log(client, "Reading RFS header failed");
         goto error;
@@ -459,7 +480,8 @@ int aries_rfs_recv(struct ipc_client *client, struct ipc_message *message)
     p = (unsigned char *) message->data + count;
 
     while (count < length) {
-        chunk = length - count < ARIES_BUFFER_LENGTH ? length - count : ARIES_BUFFER_LENGTH;
+        chunk = (length - count) < ARIES_BUFFER_LENGTH ?
+          length - count : ARIES_BUFFER_LENGTH;
 
         rc = client->handlers->read(client->handlers->transport_data, p, chunk);
         if (rc < 0) {
@@ -547,7 +569,8 @@ int aries_open(void *data, int type)
     if (type == IPC_CLIENT_TYPE_RFS)
     {
         socket_rfs_magic = ARIES_SOCKET_RFS_MAGIC;
-        rc = setsockopt(fd, SOL_SOCKET, SO_IPC_RFS, &socket_rfs_magic, sizeof(socket_rfs_magic));
+        rc = setsockopt(fd, SOL_SOCKET, SO_IPC_RFS, &socket_rfs_magic,
+                        sizeof(socket_rfs_magic));
         if (rc < 0)
             return -1;
     }
@@ -597,7 +620,8 @@ int aries_read(void *data, void *buffer, size_t length)
 
     spn_size = sizeof(struct sockaddr_pn);
 
-    rc = recvfrom(fd, buffer, length, 0, (struct sockaddr *) &transport_data->spn, &spn_size);
+    rc = recvfrom(fd, buffer, length, 0,
+                  (struct sockaddr *) &transport_data->spn, &spn_size);
 
     return rc;
 }
@@ -620,7 +644,8 @@ int aries_write(void *data, const void *buffer, size_t length)
 
     spn_size = sizeof(struct sockaddr_pn);
 
-    rc = sendto(fd, buffer, length, 0, (const struct sockaddr *) &transport_data->spn, spn_size);
+    rc = sendto(fd, buffer, length, 0,
+                (const struct sockaddr *) &transport_data->spn, spn_size);
 
     return rc;
 }
@@ -692,7 +717,8 @@ int aries_power_on(__attribute__((unused)) void *data)
     if (value == 1)
         return 0;
 
-    rc = sysfs_string_write(ARIES_MODEMCTL_CONTROL_SYSFS, (char *) &buffer, strlen(buffer));
+    rc = sysfs_string_write(ARIES_MODEMCTL_CONTROL_SYSFS, (char *) &buffer,
+                            strlen(buffer));
     if (rc < 0)
         return -1;
 
@@ -713,7 +739,8 @@ int aries_power_off(__attribute__((unused)) void *data)
     if (value == 0)
         return 0;
 
-    rc = sysfs_string_write(ARIES_MODEMCTL_CONTROL_SYSFS, (char *) &buffer, strlen(buffer));
+    rc = sysfs_string_write(ARIES_MODEMCTL_CONTROL_SYSFS, (char *) &buffer,
+                            strlen(buffer));
     if (rc < 0)
         return -1;
 
@@ -721,8 +748,8 @@ int aries_power_off(__attribute__((unused)) void *data)
 }
 
 int aries_data_create(void **transport_data,
-		      __attribute__((unused)) void **power_data,
-		      __attribute__((unused)) void **gprs_data)
+                      __attribute__((unused)) void **power_data,
+                      __attribute__((unused)) void **gprs_data)
 {
     if (transport_data == NULL)
         return -1;
@@ -733,8 +760,8 @@ int aries_data_create(void **transport_data,
 }
 
 int aries_data_destroy(void *transport_data,
-		       __attribute__((unused)) void *power_data,
-		       __attribute__((unused)) void *gprs_data)
+                       __attribute__((unused)) void *power_data,
+                       __attribute__((unused)) void *gprs_data)
 {
     if (transport_data == NULL)
         return -1;
@@ -745,7 +772,7 @@ int aries_data_destroy(void *transport_data,
 }
 
 int aries_gprs_activate(__attribute__((unused)) void *data,
-			unsigned int cid)
+                        unsigned int cid)
 {
     int rc;
 
@@ -757,7 +784,7 @@ int aries_gprs_activate(__attribute__((unused)) void *data,
 }
 
 int aries_gprs_deactivate(__attribute__((unused)) void *data,
-			  unsigned int cid)
+                          unsigned int cid)
 {
     int rc;
 
-- 
2.25.0



More information about the Replicant mailing list