aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-08-06 12:37:31 +0200
committerPaul Kocialkowski <contact@paulk.fr>2014-08-06 12:37:31 +0200
commitffda67f121bc99de57031344d75ee1445bc9dd6f (patch)
tree48f570cf7e1fc11a0380241419794e02d2c33d69 /samsung-ipc
parent6f0dca4789a86efba377b34a7c780c68cf74671b (diff)
downloadexternal_libsamsung-ipc-ffda67f121bc99de57031344d75ee1445bc9dd6f.zip
external_libsamsung-ipc-ffda67f121bc99de57031344d75ee1445bc9dd6f.tar.gz
external_libsamsung-ipc-ffda67f121bc99de57031344d75ee1445bc9dd6f.tar.bz2
xmm626: Check modem status on read and write
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
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;