From ffda67f121bc99de57031344d75ee1445bc9dd6f Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Wed, 6 Aug 2014 12:37:31 +0200 Subject: xmm626: Check modem status on read and write Signed-off-by: Paul Kocialkowski --- samsung-ipc/devices/xmm626/xmm626_sec_modem.c | 14 ++++++++++++-- 1 file 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; -- cgit v1.1