From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932224AbcELI5i (ORCPT ); Thu, 12 May 2016 04:57:38 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35997 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932164AbcELIue (ORCPT ); Thu, 12 May 2016 04:50:34 -0400 From: Mathieu OTHACEHE To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu OTHACEHE Subject: [PATCH 22/36] usb: serial: ti_usb_3410_5052: Change ti_get/set_serial_info function arguments Date: Thu, 12 May 2016 10:48:54 +0200 Message-Id: <1463042948-12205-23-git-send-email-m.othacehe@gmail.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1463042948-12205-1-git-send-email-m.othacehe@gmail.com> References: <1463042948-12205-1-git-send-email-m.othacehe@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is sufficient to pass usb_serial_port structure to ti_get_serial_info and ti_set_serial_info. Also move functions above ioctl to avoid function prototyping and use unsigned int instead of unsigned for cwait variable. Signed-off-by: Mathieu OTHACEHE --- drivers/usb/serial/ti_usb_3410_5052.c | 122 ++++++++++++++++------------------ 1 file changed, 57 insertions(+), 65 deletions(-) diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 3d36ae7..2a993a2 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -306,10 +306,6 @@ static void ti_interrupt_callback(struct urb *urb); static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); static int ti_get_lsr(struct ti_port *tport, u8 *lsr); -static int ti_get_serial_info(struct ti_port *tport, - struct serial_struct __user *ret_arg); -static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, - struct serial_struct __user *new_arg); static void ti_handle_new_msr(struct usb_serial_port *port, u8 msr); static int ti_download_firmware(struct usb_serial *serial); @@ -847,19 +843,71 @@ static bool ti_tx_empty(struct usb_serial_port *port) return true; } +static int ti_get_serial_info(struct usb_serial_port *port, + struct serial_struct __user *ret_arg) +{ + struct ti_device *tdev = usb_get_serial_data(port->serial); + struct serial_struct ret_serial; + unsigned int cwait; + int baud_base; + + if (!ret_arg) + return -EFAULT; + + cwait = port->port.closing_wait; + if (cwait != ASYNC_CLOSING_WAIT_NONE) + cwait = jiffies_to_msecs(cwait) / 10; + + memset(&ret_serial, 0, sizeof(ret_serial)); + + if (tdev->td_is_3410) + baud_base = TI_3410_BAUD_BASE; + else + baud_base = TI_5052_BAUD_BASE; + + ret_serial.type = PORT_16550A; + ret_serial.line = port->minor; + ret_serial.port = port->port_number; + ret_serial.xmit_fifo_size = port->bulk_out_size; + ret_serial.baud_base = baud_base; + ret_serial.closing_wait = cwait; + + if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg))) + return -EFAULT; + + return 0; +} + +static int ti_set_serial_info(struct usb_serial_port *port, + struct serial_struct __user *new_arg) +{ + struct serial_struct new_serial; + unsigned int cwait; + + if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) + return -EFAULT; + + cwait = new_serial.closing_wait; + if (cwait != ASYNC_CLOSING_WAIT_NONE) + cwait = msecs_to_jiffies(10 * new_serial.closing_wait); + + port->port.closing_wait = cwait; + + return 0; +} + static int ti_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { struct usb_serial_port *port = tty->driver_data; - struct ti_port *tport = usb_get_serial_port_data(port); switch (cmd) { case TIOCGSERIAL: - return ti_get_serial_info(tport, - (struct serial_struct __user *)arg); + return ti_get_serial_info(port, + (struct serial_struct __user *)arg); case TIOCSSERIAL: - return ti_set_serial_info(tty, tport, - (struct serial_struct __user *)arg); + return ti_set_serial_info(port, + (struct serial_struct __user *)arg); } return -ENOIOCTLCMD; } @@ -1189,62 +1237,6 @@ free_data: return status; } - -static int ti_get_serial_info(struct ti_port *tport, - struct serial_struct __user *ret_arg) -{ - struct usb_serial_port *port = tport->tp_port; - struct serial_struct ret_serial; - unsigned cwait; - int baud_base; - - if (!ret_arg) - return -EFAULT; - - cwait = port->port.closing_wait; - if (cwait != ASYNC_CLOSING_WAIT_NONE) - cwait = jiffies_to_msecs(cwait) / 10; - - memset(&ret_serial, 0, sizeof(ret_serial)); - - if (tport->tp_tdev->td_is_3410) - baud_base = TI_3410_BAUD_BASE; - else - baud_base = TI_5052_BAUD_BASE; - - ret_serial.type = PORT_16550A; - ret_serial.line = port->minor; - ret_serial.port = port->port_number; - ret_serial.xmit_fifo_size = port->bulk_out_size; - ret_serial.baud_base = baud_base; - ret_serial.closing_wait = cwait; - - if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg))) - return -EFAULT; - - return 0; -} - - -static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, - struct serial_struct __user *new_arg) -{ - struct serial_struct new_serial; - unsigned cwait; - - if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) - return -EFAULT; - - cwait = new_serial.closing_wait; - if (cwait != ASYNC_CLOSING_WAIT_NONE) - cwait = msecs_to_jiffies(10 * new_serial.closing_wait); - - tport->tp_port->port.closing_wait = cwait; - - return 0; -} - - static void ti_handle_new_msr(struct usb_serial_port *port, u8 msr) { struct ti_port *tport = usb_get_serial_port_data(port); -- 2.8.2