aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samsung-ipc/device/maguro/maguro_loader.c2
-rw-r--r--samsung-ipc/device/xmm6260/xmm6260_ipc.c13
-rw-r--r--samsung-ipc/wakelock.c27
3 files changed, 28 insertions, 14 deletions
diff --git a/samsung-ipc/device/maguro/maguro_loader.c b/samsung-ipc/device/maguro/maguro_loader.c
index cd1e1ac..0ee71a0 100644
--- a/samsung-ipc/device/maguro/maguro_loader.c
+++ b/samsung-ipc/device/maguro/maguro_loader.c
@@ -819,6 +819,8 @@ int maguro_modem_bootstrap(struct ipc_client *client)
ipc_client_log(client, "Modem is online!");
ret = 0;
+ usleep(500 * 1000);
+
fail:
if (io_data.radio_data != MAP_FAILED) {
munmap(io_data.radio_data, RADIO_MAP_SIZE);
diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.c b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
index 9e595e9..205c73b 100644
--- a/samsung-ipc/device/xmm6260/xmm6260_ipc.c
+++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
@@ -100,12 +100,15 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
int num_read = 0;
int left = 0;
+ if (!client || !response)
+ return -1;
+
wake_lock(FMT_LOCK_NAME);
num_read = client->handlers->read(buf, IPC_MAX_XFER,
client->handlers->read_data);
- if (num_read < 0) {
+ if (num_read <= 0) {
ipc_client_log(client, "read failed to read ipc length: %d", num_read);
response->data = 0;
response->length = 0;
@@ -128,9 +131,11 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
response->index = ipc.index;
response->type = ipc.type;
response->length = ipc.length - sizeof(ipc);
-
- response->data = (unsigned char*)malloc(response->length);
- memcpy(response->data, buf + sizeof(ipc), response->length);
+
+ if (response->length > 0) {
+ response->data = (unsigned char*)malloc(response->length);
+ memcpy(response->data, buf + sizeof(ipc), response->length);
+ }
ipc_client_log_recv(client, response, __func__);
diff --git a/samsung-ipc/wakelock.c b/samsung-ipc/wakelock.c
index ea28048..1daaec9 100644
--- a/samsung-ipc/wakelock.c
+++ b/samsung-ipc/wakelock.c
@@ -22,17 +22,22 @@
#include <fcntl.h>
#include <wakelock.h>
+static int wake_lock_fd = -1;
+static int wake_unlock_fd = -1;
+
int wake_lock(char *lock_name) {
int rc;
assert(lock_name != NULL);
- int fd = open("/sys/power/wake_lock", O_RDWR);
- if (fd < 0) {
- return fd;
+ if (wake_lock_fd < 0) {
+ wake_lock_fd = open("/sys/power/wake_lock", O_RDWR);
+ }
+
+ if (wake_lock_fd < 0) {
+ return wake_lock_fd;
}
- rc = write(fd, lock_name, strlen(lock_name));
- close(fd);
+ rc = write(wake_lock_fd, lock_name, strlen(lock_name));
return rc;
}
@@ -41,13 +46,15 @@ int wake_unlock(char *lock_name) {
int rc;
assert(lock_name != NULL);
- int fd = open("/sys/power/wake_unlock", O_RDWR);
- if (fd < 0) {
- return fd;
+ if (wake_unlock_fd < 0) {
+ wake_unlock_fd = open("/sys/power/wake_unlock", O_RDWR);
+ }
+
+ if (wake_unlock_fd < 0) {
+ return wake_lock_fd;
}
- rc = write(fd, lock_name, strlen(lock_name));
- close(fd);
+ rc = write(wake_unlock_fd, lock_name, strlen(lock_name));
return rc;
}