From: Tal Shorer <tal.shorer@gmail.com>
To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, gregkh@linuxfoundation.org,
balbi@kernel.org, corbet@lwn.net
Cc: Tal Shorer <tal.shorer@gmail.com>
Subject: [PATCH v2 6/8] usb: gadget: f_acm: add an ioctl to get the current line coding
Date: Tue, 13 Jun 2017 09:52:12 +0300 [thread overview]
Message-ID: <1497336734-19368-7-git-send-email-tal.shorer@gmail.com> (raw)
In-Reply-To: <1497336734-19368-1-git-send-email-tal.shorer@gmail.com>
The user can issue USB_F_GET_LINE_CODING to get the current line coding
as set by the host (or the default if unset yet).
Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
---
Documentation/ioctl/ioctl-number.txt | 1 +
drivers/usb/gadget/function/f_acm.c | 19 +++++++++++++++++++
include/uapi/linux/usb/f_acm.h | 12 ++++++++++++
3 files changed, 32 insertions(+)
create mode 100644 include/uapi/linux/usb/f_acm.h
diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt
index 1e9fcb4..3d70680 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -329,6 +329,7 @@ Code Seq#(hex) Include File Comments
0xCA 80-8F uapi/scsi/cxlflash_ioctl.h
0xCB 00-1F CBM serial IEC bus in development:
<mailto:michael.klein@puffin.lb.shuttle.de>
+0xCD 10-1F linux/usb/f_acm.h
0xCD 01 linux/reiserfs_fs.h
0xCF 02 fs/cifs/ioctl.c
0xDB 00-0F drivers/char/mwave/mwavepub.h
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
index 188d314..5feea7c 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/device.h>
#include <linux/err.h>
+#include <uapi/linux/usb/f_acm.h>
#include "u_serial.h"
@@ -611,6 +612,23 @@ static int acm_send_break(struct gserial *port, int duration)
return acm_notify_serial_state(acm);
}
+static int acm_ioctl(struct gserial *port, unsigned int cmd, unsigned long arg)
+{
+ struct f_acm *acm = port_to_acm(port);
+ int ret = -ENOIOCTLCMD;
+
+ switch (cmd) {
+ case USB_F_ACM_GET_LINE_CODING:
+ if (copy_to_user((__user void *)arg, &acm->port_line_coding,
+ sizeof(acm->port_line_coding)))
+ ret = -EFAULT;
+ else
+ ret = 0;
+ break;
+ }
+ return ret;
+}
+
/*-------------------------------------------------------------------------*/
/* ACM function driver setup/binding */
@@ -749,6 +767,7 @@ static struct usb_function *acm_alloc_func(struct usb_function_instance *fi)
acm->port.connect = acm_connect;
acm->port.disconnect = acm_disconnect;
acm->port.send_break = acm_send_break;
+ acm->port.ioctl = acm_ioctl;
acm->port.func.name = "acm";
acm->port.func.strings = acm_strings;
diff --git a/include/uapi/linux/usb/f_acm.h b/include/uapi/linux/usb/f_acm.h
new file mode 100644
index 0000000..51f96f0
--- /dev/null
+++ b/include/uapi/linux/usb/f_acm.h
@@ -0,0 +1,12 @@
+/* f_acm.h -- Header file for USB CDC-ACM gadget function */
+
+#ifndef __UAPI_LINUX_USB_F_ACM_H
+#define __UAPI_LINUX_USB_F_ACM_H
+
+#include <linux/usb/cdc.h>
+#include <linux/ioctl.h>
+
+/* The 0xCD code is also used by reiserfs. we use 0x10-0x1F range */
+#define USB_F_ACM_GET_LINE_CODING _IOR(0xCD, 0x10, struct usb_cdc_line_coding)
+
+#endif /* __UAPI_LINUX_USB_F_ACM_H */
--
2.7.4
next prev parent reply other threads:[~2017-06-13 6:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 6:52 [PATCH v2 0/8] Allow f_acm gadgets to notify the user about SetLineCoding requests Tal Shorer
2017-06-13 6:52 ` [PATCH v2 1/8] tty: add a poll() callback in struct tty_operations Tal Shorer
2017-06-14 1:15 ` Alan Cox
2017-06-14 8:20 ` Tal Shorer
2017-06-14 8:27 ` Tal Shorer
2017-06-14 13:33 ` Alan Cox
2017-06-15 14:44 ` Tal Shorer
2017-06-13 6:52 ` [PATCH v2 2/8] usb: gadget: u_serial: propagate poll() to the next layer Tal Shorer
2017-06-13 6:52 ` [PATCH v2 3/8] usb: gadget: f_acm: validate set_line_coding requests Tal Shorer
2017-06-13 6:52 ` [PATCH v2 4/8] usb: gadget: u_serial: propagate ioctl() to the next layer Tal Shorer
2017-06-13 6:52 ` [PATCH v2 5/8] usb: gadget: f_acm: initialize port_line_coding when creating an instance Tal Shorer
2017-06-13 6:52 ` Tal Shorer [this message]
2017-06-13 9:19 ` [PATCH v2 6/8] usb: gadget: f_acm: add an ioctl to get the current line coding Greg KH
2017-06-13 9:24 ` Tal Shorer
2017-06-13 6:52 ` [PATCH v2 7/8] usb: gadget: f_acm: notify the user on SetLineCoding Tal Shorer
2017-06-13 6:52 ` [PATCH v2 8/8] usb: gadget: u_serial: remove port_line_config from struct gserial Tal Shorer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1497336734-19368-7-git-send-email-tal.shorer@gmail.com \
--to=tal.shorer@gmail.com \
--cc=balbi@kernel.org \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).