hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/drivers/tty/amiserial.c
....@@ -22,17 +22,7 @@
2222 *
2323 */
2424
25
-/*
26
- * Serial driver configuration section. Here are the various options:
27
- *
28
- * SERIAL_PARANOIA_CHECK
29
- * Check the magic number for the async_structure where
30
- * ever possible.
31
- */
32
-
3325 #include <linux/delay.h>
34
-
35
-#undef SERIAL_PARANOIA_CHECK
3626
3727 /* Set of debugging defines */
3828
....@@ -132,28 +122,6 @@
132122
133123 #define serial_isroot() (capable(CAP_SYS_ADMIN))
134124
135
-
136
-static inline int serial_paranoia_check(struct serial_state *info,
137
- char *name, const char *routine)
138
-{
139
-#ifdef SERIAL_PARANOIA_CHECK
140
- static const char *badmagic =
141
- "Warning: bad magic number for serial struct (%s) in %s\n";
142
- static const char *badinfo =
143
- "Warning: null async_struct for (%s) in %s\n";
144
-
145
- if (!info) {
146
- printk(badinfo, name, routine);
147
- return 1;
148
- }
149
- if (info->magic != SERIAL_MAGIC) {
150
- printk(badmagic, name, routine);
151
- return 1;
152
- }
153
-#endif
154
- return 0;
155
-}
156
-
157125 /* some serial hardware definitions */
158126 #define SDR_OVRUN (1<<15)
159127 #define SDR_RBF (1<<14)
....@@ -189,9 +157,6 @@
189157 struct serial_state *info = tty->driver_data;
190158 unsigned long flags;
191159
192
- if (serial_paranoia_check(info, tty->name, "rs_stop"))
193
- return;
194
-
195160 local_irq_save(flags);
196161 if (info->IER & UART_IER_THRI) {
197162 info->IER &= ~UART_IER_THRI;
....@@ -208,9 +173,6 @@
208173 {
209174 struct serial_state *info = tty->driver_data;
210175 unsigned long flags;
211
-
212
- if (serial_paranoia_check(info, tty->name, "rs_start"))
213
- return;
214176
215177 local_irq_save(flags);
216178 if (info->xmit.head != info->xmit.tail
....@@ -783,9 +745,6 @@
783745
784746 info = tty->driver_data;
785747
786
- if (serial_paranoia_check(info, tty->name, "rs_put_char"))
787
- return 0;
788
-
789748 if (!info->xmit.buf)
790749 return 0;
791750
....@@ -808,9 +767,6 @@
808767 struct serial_state *info = tty->driver_data;
809768 unsigned long flags;
810769
811
- if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
812
- return;
813
-
814770 if (info->xmit.head == info->xmit.tail
815771 || tty->stopped
816772 || tty->hw_stopped
....@@ -832,9 +788,6 @@
832788 int c, ret = 0;
833789 struct serial_state *info = tty->driver_data;
834790 unsigned long flags;
835
-
836
- if (serial_paranoia_check(info, tty->name, "rs_write"))
837
- return 0;
838791
839792 if (!info->xmit.buf)
840793 return 0;
....@@ -878,8 +831,6 @@
878831 {
879832 struct serial_state *info = tty->driver_data;
880833
881
- if (serial_paranoia_check(info, tty->name, "rs_write_room"))
882
- return 0;
883834 return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
884835 }
885836
....@@ -887,8 +838,6 @@
887838 {
888839 struct serial_state *info = tty->driver_data;
889840
890
- if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
891
- return 0;
892841 return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
893842 }
894843
....@@ -897,8 +846,6 @@
897846 struct serial_state *info = tty->driver_data;
898847 unsigned long flags;
899848
900
- if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
901
- return;
902849 local_irq_save(flags);
903850 info->xmit.head = info->xmit.tail = 0;
904851 local_irq_restore(flags);
....@@ -913,9 +860,6 @@
913860 {
914861 struct serial_state *info = tty->driver_data;
915862 unsigned long flags;
916
-
917
- if (serial_paranoia_check(info, tty->name, "rs_send_xchar"))
918
- return;
919863
920864 info->x_char = ch;
921865 if (ch) {
....@@ -952,9 +896,6 @@
952896 printk("throttle %s ....\n", tty_name(tty));
953897 #endif
954898
955
- if (serial_paranoia_check(info, tty->name, "rs_throttle"))
956
- return;
957
-
958899 if (I_IXOFF(tty))
959900 rs_send_xchar(tty, STOP_CHAR(tty));
960901
....@@ -973,9 +914,6 @@
973914 #ifdef SERIAL_DEBUG_THROTTLE
974915 printk("unthrottle %s ....\n", tty_name(tty));
975916 #endif
976
-
977
- if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
978
- return;
979917
980918 if (I_IXOFF(tty)) {
981919 if (info->x_char)
....@@ -996,63 +934,56 @@
996934 * ------------------------------------------------------------
997935 */
998936
999
-static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
1000
- struct serial_struct __user * retinfo)
937
+static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
1001938 {
1002
- struct serial_struct tmp;
1003
-
1004
- memset(&tmp, 0, sizeof(tmp));
939
+ struct serial_state *state = tty->driver_data;
940
+
1005941 tty_lock(tty);
1006
- tmp.line = tty->index;
1007
- tmp.port = state->port;
1008
- tmp.flags = state->tport.flags;
1009
- tmp.xmit_fifo_size = state->xmit_fifo_size;
1010
- tmp.baud_base = state->baud_base;
1011
- tmp.close_delay = state->tport.close_delay;
1012
- tmp.closing_wait = state->tport.closing_wait;
1013
- tmp.custom_divisor = state->custom_divisor;
942
+ ss->line = tty->index;
943
+ ss->port = state->port;
944
+ ss->flags = state->tport.flags;
945
+ ss->xmit_fifo_size = state->xmit_fifo_size;
946
+ ss->baud_base = state->baud_base;
947
+ ss->close_delay = state->tport.close_delay;
948
+ ss->closing_wait = state->tport.closing_wait;
949
+ ss->custom_divisor = state->custom_divisor;
1014950 tty_unlock(tty);
1015
- if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
1016
- return -EFAULT;
1017951 return 0;
1018952 }
1019953
1020
-static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
1021
- struct serial_struct __user * new_info)
954
+static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
1022955 {
956
+ struct serial_state *state = tty->driver_data;
1023957 struct tty_port *port = &state->tport;
1024
- struct serial_struct new_serial;
1025958 bool change_spd;
1026959 int retval = 0;
1027960
1028
- if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
1029
- return -EFAULT;
1030
-
1031961 tty_lock(tty);
1032
- change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
1033
- new_serial.custom_divisor != state->custom_divisor;
1034
- if (new_serial.irq || new_serial.port != state->port ||
1035
- new_serial.xmit_fifo_size != state->xmit_fifo_size) {
962
+ change_spd = ((ss->flags ^ port->flags) & ASYNC_SPD_MASK) ||
963
+ ss->custom_divisor != state->custom_divisor;
964
+ if (ss->irq || ss->port != state->port ||
965
+ ss->xmit_fifo_size != state->xmit_fifo_size) {
1036966 tty_unlock(tty);
1037967 return -EINVAL;
1038968 }
1039969
1040970 if (!serial_isroot()) {
1041
- if ((new_serial.baud_base != state->baud_base) ||
1042
- (new_serial.close_delay != port->close_delay) ||
1043
- (new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
1044
- ((new_serial.flags & ~ASYNC_USR_MASK) !=
971
+ if ((ss->baud_base != state->baud_base) ||
972
+ (ss->close_delay != port->close_delay) ||
973
+ (ss->closing_wait != port->closing_wait) ||
974
+ (ss->xmit_fifo_size != state->xmit_fifo_size) ||
975
+ ((ss->flags & ~ASYNC_USR_MASK) !=
1045976 (port->flags & ~ASYNC_USR_MASK))) {
1046977 tty_unlock(tty);
1047978 return -EPERM;
1048979 }
1049980 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1050
- (new_serial.flags & ASYNC_USR_MASK));
1051
- state->custom_divisor = new_serial.custom_divisor;
981
+ (ss->flags & ASYNC_USR_MASK));
982
+ state->custom_divisor = ss->custom_divisor;
1052983 goto check_and_exit;
1053984 }
1054985
1055
- if (new_serial.baud_base < 9600) {
986
+ if (ss->baud_base < 9600) {
1056987 tty_unlock(tty);
1057988 return -EINVAL;
1058989 }
....@@ -1062,19 +993,19 @@
1062993 * At this point, we start making changes.....
1063994 */
1064995
1065
- state->baud_base = new_serial.baud_base;
996
+ state->baud_base = ss->baud_base;
1066997 port->flags = ((port->flags & ~ASYNC_FLAGS) |
1067
- (new_serial.flags & ASYNC_FLAGS));
1068
- state->custom_divisor = new_serial.custom_divisor;
1069
- port->close_delay = new_serial.close_delay * HZ/100;
1070
- port->closing_wait = new_serial.closing_wait * HZ/100;
998
+ (ss->flags & ASYNC_FLAGS));
999
+ state->custom_divisor = ss->custom_divisor;
1000
+ port->close_delay = ss->close_delay * HZ/100;
1001
+ port->closing_wait = ss->closing_wait * HZ/100;
10711002 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
10721003
10731004 check_and_exit:
10741005 if (tty_port_initialized(port)) {
10751006 if (change_spd) {
10761007 /* warn about deprecation unless clearing */
1077
- if (new_serial.flags & ASYNC_SPD_MASK)
1008
+ if (ss->flags & ASYNC_SPD_MASK)
10781009 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n");
10791010 change_speed(tty, state, NULL);
10801011 }
....@@ -1083,7 +1014,6 @@
10831014 tty_unlock(tty);
10841015 return retval;
10851016 }
1086
-
10871017
10881018 /*
10891019 * get_lsr_info - get line status register info
....@@ -1118,8 +1048,6 @@
11181048 unsigned char control, status;
11191049 unsigned long flags;
11201050
1121
- if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
1122
- return -ENODEV;
11231051 if (tty_io_error(tty))
11241052 return -EIO;
11251053
....@@ -1140,8 +1068,6 @@
11401068 struct serial_state *info = tty->driver_data;
11411069 unsigned long flags;
11421070
1143
- if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
1144
- return -ENODEV;
11451071 if (tty_io_error(tty))
11461072 return -EIO;
11471073
....@@ -1164,11 +1090,7 @@
11641090 */
11651091 static int rs_break(struct tty_struct *tty, int break_state)
11661092 {
1167
- struct serial_state *info = tty->driver_data;
11681093 unsigned long flags;
1169
-
1170
- if (serial_paranoia_check(info, tty->name, "rs_break"))
1171
- return -EINVAL;
11721094
11731095 local_irq_save(flags);
11741096 if (break_state == -1)
....@@ -1221,32 +1143,18 @@
12211143 DEFINE_WAIT(wait);
12221144 int ret;
12231145
1224
- if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
1225
- return -ENODEV;
1226
-
1227
- if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
1228
- (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
1146
+ if ((cmd != TIOCSERCONFIG) &&
12291147 (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
12301148 if (tty_io_error(tty))
12311149 return -EIO;
12321150 }
12331151
12341152 switch (cmd) {
1235
- case TIOCGSERIAL:
1236
- return get_serial_info(tty, info, argp);
1237
- case TIOCSSERIAL:
1238
- return set_serial_info(tty, info, argp);
12391153 case TIOCSERCONFIG:
12401154 return 0;
12411155
12421156 case TIOCSERGETLSR: /* Get line status register */
12431157 return get_lsr_info(info, argp);
1244
-
1245
- case TIOCSERGSTRUCT:
1246
- if (copy_to_user(argp,
1247
- info, sizeof(struct serial_state)))
1248
- return -EFAULT;
1249
- return 0;
12501158
12511159 /*
12521160 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
....@@ -1287,12 +1195,6 @@
12871195 }
12881196 finish_wait(&info->tport.delta_msr_wait, &wait);
12891197 return ret;
1290
-
1291
- case TIOCSERGWILD:
1292
- case TIOCSERSWILD:
1293
- /* "setserial -W" is called in Debian boot */
1294
- printk ("TIOCSER?WILD ioctl obsolete, ignored.\n");
1295
- return 0;
12961198
12971199 default:
12981200 return -ENOIOCTLCMD;
....@@ -1359,9 +1261,6 @@
13591261 struct serial_state *state = tty->driver_data;
13601262 struct tty_port *port = &state->tport;
13611263
1362
- if (serial_paranoia_check(state, tty->name, "rs_close"))
1363
- return;
1364
-
13651264 if (tty_port_close_start(port, tty, filp) == 0)
13661265 return;
13671266
....@@ -1404,9 +1303,6 @@
14041303 struct serial_state *info = tty->driver_data;
14051304 unsigned long orig_jiffies, char_time;
14061305 int lsr;
1407
-
1408
- if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
1409
- return;
14101306
14111307 if (info->xmit_fifo_size == 0)
14121308 return; /* Just in case.... */
....@@ -1466,9 +1362,6 @@
14661362 {
14671363 struct serial_state *info = tty->driver_data;
14681364
1469
- if (serial_paranoia_check(info, tty->name, "rs_hangup"))
1470
- return;
1471
-
14721365 rs_flush_buffer(tty);
14731366 shutdown(tty, info);
14741367 info->tport.count = 0;
....@@ -1493,8 +1386,6 @@
14931386 port->tty = tty;
14941387 tty->driver_data = info;
14951388 tty->port = port;
1496
- if (serial_paranoia_check(info, tty->name, "rs_open"))
1497
- return -ENODEV;
14981389
14991390 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
15001391
....@@ -1607,6 +1498,8 @@
16071498 .tiocmget = rs_tiocmget,
16081499 .tiocmset = rs_tiocmset,
16091500 .get_icount = rs_get_icount,
1501
+ .set_serial = set_serial_info,
1502
+ .get_serial = get_serial_info,
16101503 .proc_show = rs_proc_show,
16111504 };
16121505