Skip to content

Commit fc6cc97

Browse files
author
Al Viro
committed
whiteheat: switch to ->get_serial()
... and fix the return value - on success it used to have ioctl(2) fill the user-supplied struct serial_struct and return -ENOTTY. Reviewed-by: Johan Hovold <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 57e5723 commit fc6cc97

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

drivers/usb/serial/whiteheat.c

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ static int whiteheat_port_remove(struct usb_serial_port *port);
8383
static int whiteheat_open(struct tty_struct *tty,
8484
struct usb_serial_port *port);
8585
static void whiteheat_close(struct usb_serial_port *port);
86-
static int whiteheat_ioctl(struct tty_struct *tty,
87-
unsigned int cmd, unsigned long arg);
86+
static int whiteheat_get_serial(struct tty_struct *tty,
87+
struct serial_struct *ss);
8888
static void whiteheat_set_termios(struct tty_struct *tty,
8989
struct usb_serial_port *port, struct ktermios *old);
9090
static int whiteheat_tiocmget(struct tty_struct *tty);
@@ -120,7 +120,7 @@ static struct usb_serial_driver whiteheat_device = {
120120
.port_remove = whiteheat_port_remove,
121121
.open = whiteheat_open,
122122
.close = whiteheat_close,
123-
.ioctl = whiteheat_ioctl,
123+
.get_serial = whiteheat_get_serial,
124124
.set_termios = whiteheat_set_termios,
125125
.break_ctl = whiteheat_break_ctl,
126126
.tiocmget = whiteheat_tiocmget,
@@ -442,33 +442,21 @@ static int whiteheat_tiocmset(struct tty_struct *tty,
442442
}
443443

444444

445-
static int whiteheat_ioctl(struct tty_struct *tty,
446-
unsigned int cmd, unsigned long arg)
445+
static int whiteheat_get_serial(struct tty_struct *tty,
446+
struct serial_struct *ss)
447447
{
448448
struct usb_serial_port *port = tty->driver_data;
449-
struct serial_struct serstruct;
450-
void __user *user_arg = (void __user *)arg;
451-
452-
switch (cmd) {
453-
case TIOCGSERIAL:
454-
memset(&serstruct, 0, sizeof(serstruct));
455-
serstruct.type = PORT_16654;
456-
serstruct.line = port->minor;
457-
serstruct.port = port->port_number;
458-
serstruct.xmit_fifo_size = kfifo_size(&port->write_fifo);
459-
serstruct.custom_divisor = 0;
460-
serstruct.baud_base = 460800;
461-
serstruct.close_delay = CLOSING_DELAY;
462-
serstruct.closing_wait = CLOSING_DELAY;
463-
464-
if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
465-
return -EFAULT;
466-
break;
467-
default:
468-
break;
469-
}
470449

471-
return -ENOIOCTLCMD;
450+
ss->type = PORT_16654;
451+
ss->line = port->minor;
452+
ss->port = port->port_number;
453+
ss->xmit_fifo_size = kfifo_size(&port->write_fifo);
454+
ss->custom_divisor = 0;
455+
ss->baud_base = 460800;
456+
ss->close_delay = CLOSING_DELAY;
457+
ss->closing_wait = CLOSING_DELAY;
458+
459+
return 0;
472460
}
473461

474462

0 commit comments

Comments
 (0)