* [v2,2/2] USB: serial: ark3116: Move TIOCGSERIAL ioctl case to function.
@ 2018-01-09 11:57 Johan Hovold
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2018-01-09 11:57 UTC (permalink / raw)
To: Mikhail Zaytsev; +Cc: Johan Hovold, Greg Kroah-Hartman, linux-usb, linux-kernel
On Sat, Jan 06, 2018 at 08:15:22PM +0300, Mikhail Zaytsev wrote:
> The patch moves TIOCGSERIAL ioctl case to get_serial_info function.
>
> Signed-off-by: Mikhail Zaytsev <flashed@mail.ru>
> 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;
I prefer keeping this pointer here to avoid adding casts to every helper
function call, so I added it back before applying.
>
> switch (cmd) {
> case TIOCGSERIAL:
> + return ark3116_get_serial_info(port,
> + (struct serial_struct __user *)arg);
Thanks,
Johan
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread* [v2,2/2] USB: serial: ark3116: Move TIOCGSERIAL ioctl case to function.
@ 2018-01-06 17:15 Mikhail Zaytsev
0 siblings, 0 replies; 2+ messages in thread
From: Mikhail Zaytsev @ 2018-01-06 17:15 UTC (permalink / raw)
To: Johan Hovold; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel
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;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-09 11:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-09 11:57 [v2,2/2] USB: serial: ark3116: Move TIOCGSERIAL ioctl case to function Johan Hovold
-- strict thread matches above, loose matches on Subject: below --
2018-01-06 17:15 Mikhail Zaytsev
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).