amiserial.c (adc8d746caa67fff4b53ba3e5163a6cbacc3b523) | amiserial.c (89c8d91e31f267703e365593f6bfebb9f6d2ad01) |
---|---|
1/* 2 * Serial driver for the amiga builtin port. 3 * 4 * This code was created by taking serial.c version 4.30 from kernel 5 * release 2.3.22, replacing all hardware related stuff with the 6 * corresponding amiga hardware actions, and removing all irrelevant 7 * code. As a consequence, it uses many of the constants and names 8 * associated with the registers and bits of 16550 compatible UARTS - --- 1019 unchanged lines hidden (view full) --- 1028static int get_serial_info(struct tty_struct *tty, struct serial_state *state, 1029 struct serial_struct __user * retinfo) 1030{ 1031 struct serial_struct tmp; 1032 1033 if (!retinfo) 1034 return -EFAULT; 1035 memset(&tmp, 0, sizeof(tmp)); | 1/* 2 * Serial driver for the amiga builtin port. 3 * 4 * This code was created by taking serial.c version 4.30 from kernel 5 * release 2.3.22, replacing all hardware related stuff with the 6 * corresponding amiga hardware actions, and removing all irrelevant 7 * code. As a consequence, it uses many of the constants and names 8 * associated with the registers and bits of 16550 compatible UARTS - --- 1019 unchanged lines hidden (view full) --- 1028static int get_serial_info(struct tty_struct *tty, struct serial_state *state, 1029 struct serial_struct __user * retinfo) 1030{ 1031 struct serial_struct tmp; 1032 1033 if (!retinfo) 1034 return -EFAULT; 1035 memset(&tmp, 0, sizeof(tmp)); |
1036 tty_lock(); | 1036 tty_lock(tty); |
1037 tmp.line = tty->index; 1038 tmp.port = state->port; 1039 tmp.flags = state->tport.flags; 1040 tmp.xmit_fifo_size = state->xmit_fifo_size; 1041 tmp.baud_base = state->baud_base; 1042 tmp.close_delay = state->tport.close_delay; 1043 tmp.closing_wait = state->tport.closing_wait; 1044 tmp.custom_divisor = state->custom_divisor; | 1037 tmp.line = tty->index; 1038 tmp.port = state->port; 1039 tmp.flags = state->tport.flags; 1040 tmp.xmit_fifo_size = state->xmit_fifo_size; 1041 tmp.baud_base = state->baud_base; 1042 tmp.close_delay = state->tport.close_delay; 1043 tmp.closing_wait = state->tport.closing_wait; 1044 tmp.custom_divisor = state->custom_divisor; |
1045 tty_unlock(); | 1045 tty_unlock(tty); |
1046 if (copy_to_user(retinfo,&tmp,sizeof(*retinfo))) 1047 return -EFAULT; 1048 return 0; 1049} 1050 1051static int set_serial_info(struct tty_struct *tty, struct serial_state *state, 1052 struct serial_struct __user * new_info) 1053{ 1054 struct tty_port *port = &state->tport; 1055 struct serial_struct new_serial; 1056 bool change_spd; 1057 int retval = 0; 1058 1059 if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) 1060 return -EFAULT; 1061 | 1046 if (copy_to_user(retinfo,&tmp,sizeof(*retinfo))) 1047 return -EFAULT; 1048 return 0; 1049} 1050 1051static int set_serial_info(struct tty_struct *tty, struct serial_state *state, 1052 struct serial_struct __user * new_info) 1053{ 1054 struct tty_port *port = &state->tport; 1055 struct serial_struct new_serial; 1056 bool change_spd; 1057 int retval = 0; 1058 1059 if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) 1060 return -EFAULT; 1061 |
1062 tty_lock(); | 1062 tty_lock(tty); |
1063 change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) || 1064 new_serial.custom_divisor != state->custom_divisor; 1065 if (new_serial.irq || new_serial.port != state->port || 1066 new_serial.xmit_fifo_size != state->xmit_fifo_size) { | 1063 change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) || 1064 new_serial.custom_divisor != state->custom_divisor; 1065 if (new_serial.irq || new_serial.port != state->port || 1066 new_serial.xmit_fifo_size != state->xmit_fifo_size) { |
1067 tty_unlock(); | 1067 tty_unlock(tty); |
1068 return -EINVAL; 1069 } 1070 1071 if (!serial_isroot()) { 1072 if ((new_serial.baud_base != state->baud_base) || 1073 (new_serial.close_delay != port->close_delay) || 1074 (new_serial.xmit_fifo_size != state->xmit_fifo_size) || 1075 ((new_serial.flags & ~ASYNC_USR_MASK) != 1076 (port->flags & ~ASYNC_USR_MASK))) { | 1068 return -EINVAL; 1069 } 1070 1071 if (!serial_isroot()) { 1072 if ((new_serial.baud_base != state->baud_base) || 1073 (new_serial.close_delay != port->close_delay) || 1074 (new_serial.xmit_fifo_size != state->xmit_fifo_size) || 1075 ((new_serial.flags & ~ASYNC_USR_MASK) != 1076 (port->flags & ~ASYNC_USR_MASK))) { |
1077 tty_unlock(); | 1077 tty_unlock(tty); |
1078 return -EPERM; 1079 } 1080 port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1081 (new_serial.flags & ASYNC_USR_MASK)); 1082 state->custom_divisor = new_serial.custom_divisor; 1083 goto check_and_exit; 1084 } 1085 1086 if (new_serial.baud_base < 9600) { | 1078 return -EPERM; 1079 } 1080 port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1081 (new_serial.flags & ASYNC_USR_MASK)); 1082 state->custom_divisor = new_serial.custom_divisor; 1083 goto check_and_exit; 1084 } 1085 1086 if (new_serial.baud_base < 9600) { |
1087 tty_unlock(); | 1087 tty_unlock(tty); |
1088 return -EINVAL; 1089 } 1090 1091 /* 1092 * OK, past this point, all the error checking has been done. 1093 * At this point, we start making changes..... 1094 */ 1095 --- 15 unchanged lines hidden (view full) --- 1111 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 1112 tty->alt_speed = 230400; 1113 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 1114 tty->alt_speed = 460800; 1115 change_speed(tty, state, NULL); 1116 } 1117 } else 1118 retval = startup(tty, state); | 1088 return -EINVAL; 1089 } 1090 1091 /* 1092 * OK, past this point, all the error checking has been done. 1093 * At this point, we start making changes..... 1094 */ 1095 --- 15 unchanged lines hidden (view full) --- 1111 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 1112 tty->alt_speed = 230400; 1113 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 1114 tty->alt_speed = 460800; 1115 change_speed(tty, state, NULL); 1116 } 1117 } else 1118 retval = startup(tty, state); |
1119 tty_unlock(); | 1119 tty_unlock(tty); |
1120 return retval; 1121} 1122 1123 1124/* 1125 * get_lsr_info - get line status register info 1126 * 1127 * Purpose: Let user call ioctl() to get info when the UART physically --- 756 unchanged lines hidden --- | 1120 return retval; 1121} 1122 1123 1124/* 1125 * get_lsr_info - get line status register info 1126 * 1127 * Purpose: Let user call ioctl() to get info when the UART physically --- 756 unchanged lines hidden --- |