From: Mikhail Zaytsev <flashed@mail.ru>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [v2,2/2] USB: serial: ark3116: Move TIOCGSERIAL ioctl case to function.
Date: Sat, 6 Jan 2018 20:15:22 +0300 [thread overview]
Message-ID: <20180106201522.7a542d44@debian> (raw)
The patch moves TIOCGSERIAL ioctl case to get_serial_info function.
Signed-off-by: Mikhail Zaytsev <flashed@mail.ru>
---
drivers/usb/serial/ark3116.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 2e957c76f..7683c76a1 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -397,27 +397,33 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
return result;
}
+static int ark3116_get_serial_info(struct usb_serial_port *port,
+ struct serial_struct __user *retinfo)
+{
+ struct serial_struct tmp;
+
+ memset(&tmp, 0, sizeof(tmp));
+
+ tmp.type = PORT_16654;
+ tmp.line = port->minor;
+ tmp.port = port->port_number;
+ tmp.baud_base = 460800;
+
+ if (copy_to_user(retinfo, &tmp, sizeof(tmp)))
+ return -EFAULT;
+
+ return 0;
+}
+
static int ark3116_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{
struct usb_serial_port *port = tty->driver_data;
- struct serial_struct serstruct;
- void __user *user_arg = (void __user *)arg;
switch (cmd) {
case TIOCGSERIAL:
- /* XXX: Some of these values are probably wrong. */
- memset(&serstruct, 0, sizeof(serstruct));
- serstruct.type = PORT_16654;
- serstruct.line = port->minor;
- serstruct.port = port->port_number;
- serstruct.custom_divisor = 0;
- serstruct.baud_base = 460800;
-
- if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
- return -EFAULT;
-
- return 0;
+ return ark3116_get_serial_info(port,
+ (struct serial_struct __user *)arg);
default:
break;
}
WARNING: multiple messages have this Message-ID (diff)
From: Mikhail Zaytsev <flashed@mail.ru>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/2] USB: serial: ark3116: Move TIOCGSERIAL ioctl case to function.
Date: Sat, 6 Jan 2018 20:15:22 +0300 [thread overview]
Message-ID: <20180106201522.7a542d44@debian> (raw)
In-Reply-To: <20180106200809.41cdd723@debian>
The patch moves TIOCGSERIAL ioctl case to get_serial_info function.
Signed-off-by: Mikhail Zaytsev <flashed@mail.ru>
---
drivers/usb/serial/ark3116.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 2e957c76f..7683c76a1 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -397,27 +397,33 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
return result;
}
+static int ark3116_get_serial_info(struct usb_serial_port *port,
+ struct serial_struct __user *retinfo)
+{
+ struct serial_struct tmp;
+
+ memset(&tmp, 0, sizeof(tmp));
+
+ tmp.type = PORT_16654;
+ tmp.line = port->minor;
+ tmp.port = port->port_number;
+ tmp.baud_base = 460800;
+
+ if (copy_to_user(retinfo, &tmp, sizeof(tmp)))
+ return -EFAULT;
+
+ return 0;
+}
+
static int ark3116_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{
struct usb_serial_port *port = tty->driver_data;
- struct serial_struct serstruct;
- void __user *user_arg = (void __user *)arg;
switch (cmd) {
case TIOCGSERIAL:
- /* XXX: Some of these values are probably wrong. */
- memset(&serstruct, 0, sizeof(serstruct));
- serstruct.type = PORT_16654;
- serstruct.line = port->minor;
- serstruct.port = port->port_number;
- serstruct.custom_divisor = 0;
- serstruct.baud_base = 460800;
-
- if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
- return -EFAULT;
-
- return 0;
+ return ark3116_get_serial_info(port,
+ (struct serial_struct __user *)arg);
default:
break;
}
--
2.11.0
next reply other threads:[~2018-01-06 17:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-06 17:15 Mikhail Zaytsev [this message]
2018-01-06 17:15 ` [PATCH v2 2/2] USB: serial: ark3116: Move TIOCGSERIAL ioctl case to function Mikhail Zaytsev
-- strict thread matches above, loose matches on Subject: below --
2018-01-09 11:57 [v2,2/2] " Johan Hovold
2018-01-09 11:57 ` [PATCH v2 2/2] " Johan Hovold
2018-01-09 11:55 [v2,1/2] USB: serial: ark3116: Remove unused TIOCSSERIAL ioctl case Johan Hovold
2018-01-09 11:55 ` [PATCH v2 1/2] " Johan Hovold
2018-01-08 21:45 [v2,1/2] " Mikhail Zaytsev
2018-01-08 21:45 ` [PATCH v2 1/2] " Mikhail Zaytsev
2018-01-08 15:28 [v2,1/2] " Johan Hovold
2018-01-08 15:28 ` [PATCH v2 1/2] " Johan Hovold
2018-01-08 10:33 [v2,1/2] " Oliver Neukum
2018-01-08 10:33 ` [PATCH v2 1/2] " Oliver Neukum
2018-01-06 17:14 [v2,1/2] " Mikhail Zaytsev
2018-01-06 17:14 ` [PATCH v2 1/2] " Mikhail Zaytsev
2018-01-06 17:08 [PATCH v2 0/2] USB: serial: ark3116: ioctl changes Mikhail Zaytsev
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=20180106201522.7a542d44@debian \
--to=flashed@mail.ru \
--cc=gregkh@linuxfoundation.org \
--cc=johan@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.