aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/devices/xmm626/xmm626_sec_modem.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/samsung-ipc/devices/xmm626/xmm626_sec_modem.c b/samsung-ipc/devices/xmm626/xmm626_sec_modem.c
index ffe46a5..33b115d 100644
--- a/samsung-ipc/devices/xmm626/xmm626_sec_modem.c
+++ b/samsung-ipc/devices/xmm626/xmm626_sec_modem.c
@@ -436,11 +436,16 @@ int xmm626_sec_modem_close(int fd)
int xmm626_sec_modem_read(int fd, void *buffer, size_t length)
{
+ int status;
int rc;
if (fd < 0 || buffer == NULL || length <= 0)
return -1;
+ status = ioctl(fd, IOCTL_MODEM_STATUS, 0);
+ if (status != STATE_ONLINE && status != STATE_BOOTING)
+ return -1;
+
rc = read(fd, buffer, length);
return rc;
@@ -448,11 +453,16 @@ int xmm626_sec_modem_read(int fd, void *buffer, size_t length)
int xmm626_sec_modem_write(int fd, const void *buffer, size_t length)
{
+ int status;
int rc;
if (fd < 0 || buffer == NULL || length <= 0)
return -1;
+ status = ioctl(fd, IOCTL_MODEM_STATUS, 0);
+ if (status != STATE_ONLINE && status != STATE_BOOTING)
+ return -1;
+
rc = write(fd, buffer, length);
return rc;
@@ -460,9 +470,9 @@ int xmm626_sec_modem_write(int fd, const void *buffer, size_t length)
int xmm626_sec_modem_poll(int fd, struct timeval *timeout)
{
+ int status;
fd_set fds;
int rc;
- int status;
if (fd < 0)
return -1;
@@ -474,7 +484,7 @@ int xmm626_sec_modem_poll(int fd, struct timeval *timeout)
if (FD_ISSET(fd, &fds)) {
status = ioctl(fd, IOCTL_MODEM_STATUS, 0);
if (status != STATE_ONLINE && status != STATE_BOOTING)
- return 0;
+ return -1;
}
return rc;