mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 2/2] USB: serial: ark3116.c: Move TIOCGSERIAL ioctl case to function.
Date: Wed, 13 Dec 2017 16:45:06 +0300	[thread overview]
Message-ID: <20171213164506.79ef2eaa@zaytsev.tver.pg> (raw)
In-Reply-To: <20171213112445.GB3831@localhost>

The patch moves TIOCGSERIAL ioctl case to get_serial_info function.

Signed-off-by: Mikhail Zaytsev <flashed@mail.ru>
---
 drivers/usb/serial/ark3116.c | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 2e957c76f..2ce8fe10e 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -36,6 +36,7 @@
 #define DRIVER_DESC "USB ARK3116 serial/IrDA driver"
 #define DRIVER_DEV_DESC "ARK3116 RS232/IrDA"
 #define DRIVER_NAME "ark3116"
+#define ARK3116_BAUDRATE 460800
 
 /* usb timeout of 1 second */
 #define ARK_TIMEOUT 1000
@@ -397,27 +398,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,
+			unsigned long arg)
+{
+	struct serial_struct ser;
+
+	memset(&ser, 0, sizeof(ser));
+
+	ser.type = PORT_16654;
+	ser.line = port->minor;
+	ser.port = port->port_number;
+	ser.custom_divisor = 0;
+	ser.baud_base = ARK3116_BAUDRATE;
+
+	if (copy_to_user((void __user *)arg, &ser, sizeof(ser)))
+		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, arg);
 	default:
 		break;
 	}
-- 
2.11.0

  parent reply	other threads:[~2017-12-13 13:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13  9:30 [PATCH] USB: serial: ark3116.c: Remove unused TIOCSSERIAL case from ioctl Mikhail Zaytsev
2017-12-13 10:17 ` Oliver Neukum
2017-12-13 11:31   ` Mikhail Zaytsev
2017-12-13 11:40     ` Oliver Neukum
2017-12-13 12:30       ` Mikhail Zaytsev
2017-12-13 14:39         ` Oliver Neukum
2017-12-13 16:43           ` Mikhail Zaytsev
2017-12-13 11:24 ` Johan Hovold
2017-12-13 13:44   ` [PATCH 0/2] USB: serial: ark3116.c: ioctl changes Mikhail Zaytsev
2017-12-13 13:44   ` [PATCH 1/2] USB: serial: ark3116.c: Remove unused TIOCSSERIAL ioctl case Mikhail Zaytsev
2018-01-02 14:50     ` Johan Hovold
2017-12-13 13:45   ` Mikhail Zaytsev [this message]
2018-01-02 15:00     ` [PATCH 2/2] USB: serial: ark3116.c: Move TIOCGSERIAL ioctl case to function Johan Hovold

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=20171213164506.79ef2eaa@zaytsev.tver.pg \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®