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

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

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

Al Viro 6fbf9582 b129cbc9

+37 -40
+37 -40
drivers/tty/cyclades.c
··· 2257 2257 } 2258 2258 } /* set_line_char */ 2259 2259 2260 - static int cy_get_serial_info(struct cyclades_port *info, 2261 - struct serial_struct __user *retinfo) 2260 + static int cy_get_serial_info(struct tty_struct *tty, 2261 + struct serial_struct *ss) 2262 2262 { 2263 + struct cyclades_port *info = tty->driver_data; 2263 2264 struct cyclades_card *cinfo = info->card; 2264 - struct serial_struct tmp = { 2265 - .type = info->type, 2266 - .line = info->line, 2267 - .port = (info->card - cy_card) * 0x100 + info->line - 2268 - cinfo->first_line, 2269 - .irq = cinfo->irq, 2270 - .flags = info->port.flags, 2271 - .close_delay = info->port.close_delay, 2272 - .closing_wait = info->port.closing_wait, 2273 - .baud_base = info->baud, 2274 - .custom_divisor = info->custom_divisor, 2275 - }; 2276 - return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; 2265 + 2266 + if (serial_paranoia_check(info, tty->name, "cy_ioctl")) 2267 + return -ENODEV; 2268 + ss->type = info->type; 2269 + ss->line = info->line; 2270 + ss->port = (info->card - cy_card) * 0x100 + info->line - 2271 + cinfo->first_line; 2272 + ss->irq = cinfo->irq; 2273 + ss->flags = info->port.flags; 2274 + ss->close_delay = info->port.close_delay; 2275 + ss->closing_wait = info->port.closing_wait; 2276 + ss->baud_base = info->baud; 2277 + ss->custom_divisor = info->custom_divisor; 2278 + return 0; 2277 2279 } 2278 2280 2279 - static int 2280 - cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty, 2281 - struct serial_struct __user *new_info) 2281 + static int cy_set_serial_info(struct tty_struct *tty, 2282 + struct serial_struct *ss) 2282 2283 { 2283 - struct serial_struct new_serial; 2284 + struct cyclades_port *info = tty->driver_data; 2284 2285 int old_flags; 2285 2286 int ret; 2286 2287 2287 - if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2288 - return -EFAULT; 2288 + if (serial_paranoia_check(info, tty->name, "cy_ioctl")) 2289 + return -ENODEV; 2289 2290 2290 2291 mutex_lock(&info->port.mutex); 2291 2292 2292 2293 old_flags = info->port.flags; 2293 2294 2294 2295 if (!capable(CAP_SYS_ADMIN)) { 2295 - if (new_serial.close_delay != info->port.close_delay || 2296 - new_serial.baud_base != info->baud || 2297 - (new_serial.flags & ASYNC_FLAGS & 2296 + if (ss->close_delay != info->port.close_delay || 2297 + ss->baud_base != info->baud || 2298 + (ss->flags & ASYNC_FLAGS & 2298 2299 ~ASYNC_USR_MASK) != 2299 2300 (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)) 2300 2301 { ··· 2303 2302 return -EPERM; 2304 2303 } 2305 2304 info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) | 2306 - (new_serial.flags & ASYNC_USR_MASK); 2307 - info->baud = new_serial.baud_base; 2308 - info->custom_divisor = new_serial.custom_divisor; 2305 + (ss->flags & ASYNC_USR_MASK); 2306 + info->baud = ss->baud_base; 2307 + info->custom_divisor = ss->custom_divisor; 2309 2308 goto check_and_exit; 2310 2309 } 2311 2310 ··· 2314 2313 * At this point, we start making changes..... 2315 2314 */ 2316 2315 2317 - info->baud = new_serial.baud_base; 2318 - info->custom_divisor = new_serial.custom_divisor; 2316 + info->baud = ss->baud_base; 2317 + info->custom_divisor = ss->custom_divisor; 2319 2318 info->port.flags = (info->port.flags & ~ASYNC_FLAGS) | 2320 - (new_serial.flags & ASYNC_FLAGS); 2321 - info->port.close_delay = new_serial.close_delay * HZ / 100; 2322 - info->port.closing_wait = new_serial.closing_wait * HZ / 100; 2319 + (ss->flags & ASYNC_FLAGS); 2320 + info->port.close_delay = ss->close_delay * HZ / 100; 2321 + info->port.closing_wait = ss->closing_wait * HZ / 100; 2323 2322 2324 2323 check_and_exit: 2325 2324 if (tty_port_initialized(&info->port)) { 2326 - if ((new_serial.flags ^ old_flags) & ASYNC_SPD_MASK) { 2325 + if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) { 2327 2326 /* warn about deprecation unless clearing */ 2328 - if (new_serial.flags & ASYNC_SPD_MASK) 2327 + if (ss->flags & ASYNC_SPD_MASK) 2329 2328 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n"); 2330 2329 } 2331 2330 cy_set_line_char(info, tty); ··· 2698 2697 break; 2699 2698 case CYGETWAIT: 2700 2699 ret_val = info->port.closing_wait / (HZ / 100); 2701 - break; 2702 - case TIOCGSERIAL: 2703 - ret_val = cy_get_serial_info(info, argp); 2704 - break; 2705 - case TIOCSSERIAL: 2706 - ret_val = cy_set_serial_info(info, tty, argp); 2707 2700 break; 2708 2701 case TIOCSERGETLSR: /* Get line status register */ 2709 2702 ret_val = get_lsr_info(info, argp); ··· 4006 4011 .tiocmget = cy_tiocmget, 4007 4012 .tiocmset = cy_tiocmset, 4008 4013 .get_icount = cy_get_icount, 4014 + .set_serial = cy_set_serial_info, 4015 + .get_serial = cy_get_serial_info, 4009 4016 .proc_show = cyclades_proc_show, 4010 4017 }; 4011 4018