aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc/devices/xmm626/xmm626_sec_modem.c
diff options
context:
space:
mode:
Diffstat (limited to 'samsung-ipc/devices/xmm626/xmm626_sec_modem.c')
-rw-r--r--samsung-ipc/devices/xmm626/xmm626_sec_modem.c43
1 files changed, 37 insertions, 6 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;
}