summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2016-05-11 13:24:02 +0200
committerJohn Crispin <john@phrozen.org>2016-05-11 11:19:10 +0200
commitd4dfed2f548bdd6f503dd7965ff9996754bb69b3 (patch)
tree6c3058a2d8fdab0c48e2a13b14987a1148a6eae4
parent6584f5e624401e4ede6af9e66e78d14ca0649a5c (diff)
get buffer size from driver
Signed-off-by: Bjørn Mork <bjorn@mork.no>
-rw-r--r--mbim-dev.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/mbim-dev.c b/mbim-dev.c
index 34bb2c2..dd1110d 100644
--- a/mbim-dev.c
+++ b/mbim-dev.c
@@ -12,6 +12,8 @@
* GNU General Public License for more details.
*/
+#include <linux/usb/cdc-wdm.h>
+#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -132,13 +134,20 @@ mbim_recv(struct uloop_fd *u, unsigned int events)
void
mbim_open(const char *path)
{
+ __u16 max;
+ int rc;
+
mbim_fd.cb = mbim_recv;
mbim_fd.fd = open(path, O_RDWR);
if (mbim_fd.fd < 1) {
perror("open failed: ");
exit(-1);
}
- mbim_bufsize = MBIM_BUFFER_SIZE;
+ rc = ioctl(mbim_fd.fd, IOCTL_WDM_MAX_COMMAND, &max);
+ if (!rc)
+ mbim_bufsize = max;
+ else
+ mbim_bufsize = 512;
mbim_buffer = malloc(mbim_bufsize);
uloop_fd_add(&mbim_fd, ULOOP_READ);
}