[PATCH] cdc-wdm: add a dummy implementation of ioctls TCGETS and TCSETS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a dummy implementation of the TCGETS and TCSETS ioctls
to cdc-wdm.  This is necessary for userspace applications like "chat".

cdc-wdm devices are similar to cdc-acm devices, except for the lack of a
bulk data interface.  This makes them useful in dialling applications
and chatscripts.  However, some of these userspace applications assume
they are talking to a TTY device and fail with cdc-wdm devices:

 nemi:/tmp# chat -t 5 -v -s "" "AT" "OK" > /dev/cdc-wdm0 < /dev/cdc-wdm0
 Can't get terminal parameters: Inappropriate ioctl for device

This is a workaround for the problem.


Signed-off-by: Bjørn Mork <bjorn@xxxxxxx>
---

Note: I have not understood why cdc-wdm isn't a fullblown TTY driver,
like cdc-acm is.  Could anyone care to explain?

The correct fix for the described problem may be changing cdc-wdm to use
the TTY layer, but I guess that means renaming the devices and possibly
other very userspace visible changes?  Let me know if this is desired,
and I'll try to provide a patch.


diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 3771d6e..ce5bac2 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/tty.h>
 #include <linux/module.h>
 #include <linux/smp_lock.h>
 #include <linux/mutex.h>
@@ -555,10 +556,27 @@ static int wdm_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
+static long wdm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct wdm_device *desc = file->private_data;
+
+	if (!desc)
+		return -ENODEV;
+
+	switch (cmd) {
+	case TCGETS:
+	case TCSETS:
+		return 0;
+	default:
+		return -ENOTTY;
+	}
+}
+
 static const struct file_operations wdm_fops = {
 	.owner =	THIS_MODULE,
 	.read =		wdm_read,
 	.write =	wdm_write,
+	.unlocked_ioctl = wdm_ioctl,
 	.open =		wdm_open,
 	.flush =	wdm_flush,
 	.release =	wdm_release,

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux