Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fwserial: switch to ->[sg]et_serial()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro b98e5a67 617a2811

+28 -38
+28 -38
drivers/staging/fwserial/fwserial.c
··· 1209 1209 check_msr_delta(port, mask, &prev)); 1210 1210 } 1211 1211 1212 - static int get_serial_info(struct fwtty_port *port, 1213 - struct serial_struct __user *info) 1212 + static int get_serial_info(struct tty_struct *tty, 1213 + struct serial_struct *ss) 1214 1214 { 1215 - struct serial_struct tmp; 1216 - 1217 - memset(&tmp, 0, sizeof(tmp)); 1218 - 1219 - tmp.type = PORT_UNKNOWN; 1220 - tmp.line = port->port.tty->index; 1221 - tmp.flags = port->port.flags; 1222 - tmp.xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN; 1223 - tmp.baud_base = 400000000; 1224 - tmp.close_delay = port->port.close_delay; 1225 - 1226 - return (copy_to_user(info, &tmp, sizeof(*info))) ? -EFAULT : 0; 1215 + struct fwtty_port *port = tty->driver_data; 1216 + mutex_lock(&port->port.mutex); 1217 + ss->type = PORT_UNKNOWN; 1218 + ss->line = port->port.tty->index; 1219 + ss->flags = port->port.flags; 1220 + ss->xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN; 1221 + ss->baud_base = 400000000; 1222 + ss->close_delay = port->port.close_delay; 1223 + mutex_unlock(&port->port.mutex); 1224 + return 0; 1227 1225 } 1228 1226 1229 - static int set_serial_info(struct fwtty_port *port, 1230 - struct serial_struct __user *info) 1227 + static int set_serial_info(struct tty_struct *tty, 1228 + struct serial_struct *ss) 1231 1229 { 1232 - struct serial_struct tmp; 1230 + struct fwtty_port *port = tty->driver_data; 1233 1231 1234 - if (copy_from_user(&tmp, info, sizeof(tmp))) 1235 - return -EFAULT; 1236 - 1237 - if (tmp.irq != 0 || tmp.port != 0 || tmp.custom_divisor != 0 || 1238 - tmp.baud_base != 400000000) 1232 + if (ss->irq != 0 || ss->port != 0 || ss->custom_divisor != 0 || 1233 + ss->baud_base != 400000000) 1239 1234 return -EPERM; 1240 1235 1236 + mutex_lock(&port->port.mutex); 1241 1237 if (!capable(CAP_SYS_ADMIN)) { 1242 - if (((tmp.flags & ~ASYNC_USR_MASK) != 1243 - (port->port.flags & ~ASYNC_USR_MASK))) 1238 + if (((ss->flags & ~ASYNC_USR_MASK) != 1239 + (port->port.flags & ~ASYNC_USR_MASK))) { 1240 + mutex_unlock(&port->port.mutex); 1244 1241 return -EPERM; 1245 - } else { 1246 - port->port.close_delay = tmp.close_delay * HZ / 100; 1242 + } 1247 1243 } 1244 + port->port.close_delay = ss->close_delay * HZ / 100; 1245 + mutex_unlock(&port->port.mutex); 1248 1246 1249 1247 return 0; 1250 1248 } ··· 1254 1256 int err; 1255 1257 1256 1258 switch (cmd) { 1257 - case TIOCGSERIAL: 1258 - mutex_lock(&port->port.mutex); 1259 - err = get_serial_info(port, (void __user *)arg); 1260 - mutex_unlock(&port->port.mutex); 1261 - break; 1262 - 1263 - case TIOCSSERIAL: 1264 - mutex_lock(&port->port.mutex); 1265 - err = set_serial_info(port, (void __user *)arg); 1266 - mutex_unlock(&port->port.mutex); 1267 - break; 1268 - 1269 1259 case TIOCMIWAIT: 1270 1260 err = wait_msr_change(port, arg); 1271 1261 break; ··· 1543 1557 .tiocmget = fwtty_tiocmget, 1544 1558 .tiocmset = fwtty_tiocmset, 1545 1559 .get_icount = fwtty_get_icount, 1560 + .set_serial = set_serial_info, 1561 + .get_serial = get_serial_info, 1546 1562 .proc_show = fwtty_proc_show, 1547 1563 }; 1548 1564 ··· 1566 1578 .tiocmget = fwtty_tiocmget, 1567 1579 .tiocmset = fwtty_tiocmset, 1568 1580 .get_icount = fwtty_get_icount, 1581 + .set_serial = set_serial_info, 1582 + .get_serial = get_serial_info, 1569 1583 }; 1570 1584 1571 1585 static inline int mgmt_pkt_expected_len(__be16 code)