Monitoring clients will want this feature on devices which do not echo back the command for us. Make it a per-device-id configurable item and disabled by default, as it represents a behavioural change This is preparing for supporting devices using other protocols than AT commands. Such devices will typically not echo back the received command. Signed-off-by: Bjørn Mork <bjorn@xxxxxxx> --- This won't affect existing users. I was wondering how to enable echo in a sane way. I did not want to that the tty route using an ioctl... Although that is probably the only possible way if configuring this is required per client? For now it is a static device specific attribute. The assumption is that QMI devices will have this on to enable monitoring complete transactions from a read-only process, while AT based devices have it turned off as they echo back commands themselves drivers/usb/class/cdc-wdm.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index bd0cb5f..e0c17ff 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -31,6 +31,9 @@ #define DRIVER_AUTHOR "Oliver Neukum" #define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device Management" +/* attribute flags for device list */ +#define WDM_ATTR_ECHO 0x0001 /* device wants command echo */ + static const struct usb_device_id wdm_ids[] = { { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | @@ -89,6 +92,8 @@ struct wdm_device { loff_t pos; /* virtual "file position" mapped into ubuf */ loff_t valid; /* maintain boundary for packetized protocols! */ + + unsigned long attr; /* device specific attributes */ }; static struct usb_driver wdm_driver; @@ -371,6 +376,16 @@ static ssize_t wdm_write } else { dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d", desc->orq->wIndex); + /* + * echo command if device attribute says so. + * Note: we don't update the file pointer on write, so + * this we will read this back ourselves as well + */ + if (desc->attr & WDM_ATTR_ECHO) { + spin_lock_irq(&desc->iuspin); + wdm_copy_to_ubuf(desc, buf, count); + spin_unlock_irq(&desc->iuspin); + } } out: usb_autopm_put_interface(desc->intf); @@ -648,6 +663,10 @@ next_desc: desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL); if (!desc) goto out; + + /* save device specific attributes */ + desc->attr = id->driver_info; + mutex_init(&desc->wlock); spin_lock_init(&desc->iuspin); init_waitqueue_head(&desc->wait); -- 1.7.8.3 -- 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