diff options
Diffstat (limited to 'samsung-ipc/devices/xmm626')
-rw-r--r-- | samsung-ipc/devices/xmm626/xmm626_sec_modem.c | 43 | ||||
-rw-r--r-- | samsung-ipc/devices/xmm626/xmm626_sec_modem.h | 3 |
2 files changed, 39 insertions, 7 deletions
diff --git a/samsung-ipc/devices/xmm626/xmm626_sec_modem.c b/samsung-ipc/devices/xmm626/xmm626_sec_modem.c index 33b115d..dfdebdf 100644 --- a/samsung-ipc/devices/xmm626/xmm626_sec_modem.c +++ b/samsung-ipc/devices/xmm626/xmm626_sec_modem.c @@ -468,25 +468,56 @@ int xmm626_sec_modem_write(int fd, const void *buffer, size_t length) return rc; } -int xmm626_sec_modem_poll(int fd, struct timeval *timeout) +int xmm626_sec_modem_poll(int fd, struct ipc_poll_fds *fds, + struct timeval *timeout) { int status; - fd_set fds; + fd_set set; + int fd_max; + unsigned int i; + unsigned int count; int rc; if (fd < 0) return -1; - FD_ZERO(&fds); - FD_SET(fd, &fds); + FD_ZERO(&set); + FD_SET(fd, &set); - rc = select(fd + 1, &fds, NULL, NULL, timeout); - if (FD_ISSET(fd, &fds)) { + fd_max = fd; + + if (fds != NULL && fds->fds != NULL && fds->count > 0) { + for (i = 0; i < fds->count; i++) { + if (fds->fds[i] >= 0) { + FD_SET(fds->fds[i], &set); + + if (fds->fds[i] > fd_max) + fd_max = fds->fds[i]; + } + } + } + + rc = select(fd_max + 1, &set, NULL, NULL, timeout); + + if (FD_ISSET(fd, &set)) { status = ioctl(fd, IOCTL_MODEM_STATUS, 0); if (status != STATE_ONLINE && status != STATE_BOOTING) return -1; } + if (fds != NULL && fds->fds != NULL && fds->count > 0) { + count = fds->count; + + for (i = 0; i < fds->count; i++) { + if (!FD_ISSET(fds->fds[i], &set)) { + fds->fds[i] = -1; + count--; + } + } + + fds->count = count; + } + return rc; } diff --git a/samsung-ipc/devices/xmm626/xmm626_sec_modem.h b/samsung-ipc/devices/xmm626/xmm626_sec_modem.h index 728320e..9599a84 100644 --- a/samsung-ipc/devices/xmm626/xmm626_sec_modem.h +++ b/samsung-ipc/devices/xmm626/xmm626_sec_modem.h @@ -53,7 +53,8 @@ int xmm626_sec_modem_open(int type); int xmm626_sec_modem_close(int fd); 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 xmm626_sec_modem_poll(int fd, struct timeval *timeout); +int xmm626_sec_modem_poll(int fd, struct ipc_poll_fds *fds, + struct timeval *timeout); char *xmm626_sec_modem_gprs_get_iface(unsigned int cid); int xmm626_sec_modem_gprs_get_capabilities(struct ipc_client_gprs_capabilities *capabilities); |