hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/tty/n_r3964.c
....@@ -129,11 +129,15 @@
129129 static int r3964_open(struct tty_struct *tty);
130130 static void r3964_close(struct tty_struct *tty);
131131 static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
132
- unsigned char __user * buf, size_t nr);
132
+ void *cookie, unsigned char *buf, size_t nr);
133133 static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
134134 const unsigned char *buf, size_t nr);
135135 static int r3964_ioctl(struct tty_struct *tty, struct file *file,
136136 unsigned int cmd, unsigned long arg);
137
+#ifdef CONFIG_COMPAT
138
+static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file,
139
+ unsigned int cmd, unsigned long arg);
140
+#endif
137141 static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old);
138142 static __poll_t r3964_poll(struct tty_struct *tty, struct file *file,
139143 struct poll_table_struct *wait);
....@@ -149,6 +153,9 @@
149153 .read = r3964_read,
150154 .write = r3964_write,
151155 .ioctl = r3964_ioctl,
156
+#ifdef CONFIG_COMPAT
157
+ .compat_ioctl = r3964_compat_ioctl,
158
+#endif
152159 .set_termios = r3964_set_termios,
153160 .poll = r3964_poll,
154161 .receive_buf = r3964_receive_buf,
....@@ -598,7 +605,6 @@
598605 }
599606 break;
600607 case R3964_WAIT_FOR_RX_REPEAT:
601
- /* FALLTHROUGH */
602608 case R3964_IDLE:
603609 if (c == STX) {
604610 /* Prevent rx_queue from overflow: */
....@@ -1052,7 +1058,8 @@
10521058 }
10531059
10541060 static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
1055
- unsigned char __user * buf, size_t nr)
1061
+ unsigned char *kbuf, size_t nr,
1062
+ void **cookie, unsigned long offset)
10561063 {
10571064 struct r3964_info *pInfo = tty->disc_data;
10581065 struct r3964_client_info *pClient;
....@@ -1103,10 +1110,7 @@
11031110 kfree(pMsg);
11041111 TRACE_M("r3964_read - msg kfree %p", pMsg);
11051112
1106
- if (copy_to_user(buf, &theMsg, ret)) {
1107
- ret = -EFAULT;
1108
- goto unlock;
1109
- }
1113
+ memcpy(kbuf, &theMsg, ret);
11101114
11111115 TRACE_PS("read - return %d", ret);
11121116 goto unlock;
....@@ -1210,6 +1214,21 @@
12101214 }
12111215 }
12121216
1217
+#ifdef CONFIG_COMPAT
1218
+static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file,
1219
+ unsigned int cmd, unsigned long arg)
1220
+{
1221
+ switch (cmd) {
1222
+ case R3964_ENABLE_SIGNALS:
1223
+ case R3964_SETPRIORITY:
1224
+ case R3964_USE_BCC:
1225
+ return r3964_ioctl(tty, file, cmd, arg);
1226
+ default:
1227
+ return -ENOIOCTLCMD;
1228
+ }
1229
+}
1230
+#endif
1231
+
12131232 static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old)
12141233 {
12151234 TRACE_L("set_termios");