diff options
-rw-r--r-- | drivers/char/synclink_gt.c | 107 | ||||
-rw-r--r-- | include/linux/Kbuild | 2 | ||||
-rw-r--r-- | include/linux/synclink.h | 24 |
3 files changed, 132 insertions, 1 deletions
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 2a7736b5f2f7..02b49bc00028 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c | |||
@@ -1171,6 +1171,112 @@ static int ioctl(struct tty_struct *tty, struct file *file, | |||
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | /* | 1173 | /* |
1174 | * support for 32 bit ioctl calls on 64 bit systems | ||
1175 | */ | ||
1176 | #ifdef CONFIG_COMPAT | ||
1177 | static long get_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *user_params) | ||
1178 | { | ||
1179 | struct MGSL_PARAMS32 tmp_params; | ||
1180 | |||
1181 | DBGINFO(("%s get_params32\n", info->device_name)); | ||
1182 | tmp_params.mode = (compat_ulong_t)info->params.mode; | ||
1183 | tmp_params.loopback = info->params.loopback; | ||
1184 | tmp_params.flags = info->params.flags; | ||
1185 | tmp_params.encoding = info->params.encoding; | ||
1186 | tmp_params.clock_speed = (compat_ulong_t)info->params.clock_speed; | ||
1187 | tmp_params.addr_filter = info->params.addr_filter; | ||
1188 | tmp_params.crc_type = info->params.crc_type; | ||
1189 | tmp_params.preamble_length = info->params.preamble_length; | ||
1190 | tmp_params.preamble = info->params.preamble; | ||
1191 | tmp_params.data_rate = (compat_ulong_t)info->params.data_rate; | ||
1192 | tmp_params.data_bits = info->params.data_bits; | ||
1193 | tmp_params.stop_bits = info->params.stop_bits; | ||
1194 | tmp_params.parity = info->params.parity; | ||
1195 | if (copy_to_user(user_params, &tmp_params, sizeof(struct MGSL_PARAMS32))) | ||
1196 | return -EFAULT; | ||
1197 | return 0; | ||
1198 | } | ||
1199 | |||
1200 | static long set_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *new_params) | ||
1201 | { | ||
1202 | struct MGSL_PARAMS32 tmp_params; | ||
1203 | |||
1204 | DBGINFO(("%s set_params32\n", info->device_name)); | ||
1205 | if (copy_from_user(&tmp_params, new_params, sizeof(struct MGSL_PARAMS32))) | ||
1206 | return -EFAULT; | ||
1207 | |||
1208 | spin_lock(&info->lock); | ||
1209 | info->params.mode = tmp_params.mode; | ||
1210 | info->params.loopback = tmp_params.loopback; | ||
1211 | info->params.flags = tmp_params.flags; | ||
1212 | info->params.encoding = tmp_params.encoding; | ||
1213 | info->params.clock_speed = tmp_params.clock_speed; | ||
1214 | info->params.addr_filter = tmp_params.addr_filter; | ||
1215 | info->params.crc_type = tmp_params.crc_type; | ||
1216 | info->params.preamble_length = tmp_params.preamble_length; | ||
1217 | info->params.preamble = tmp_params.preamble; | ||
1218 | info->params.data_rate = tmp_params.data_rate; | ||
1219 | info->params.data_bits = tmp_params.data_bits; | ||
1220 | info->params.stop_bits = tmp_params.stop_bits; | ||
1221 | info->params.parity = tmp_params.parity; | ||
1222 | spin_unlock(&info->lock); | ||
1223 | |||
1224 | change_params(info); | ||
1225 | |||
1226 | return 0; | ||
1227 | } | ||
1228 | |||
1229 | static long slgt_compat_ioctl(struct tty_struct *tty, struct file *file, | ||
1230 | unsigned int cmd, unsigned long arg) | ||
1231 | { | ||
1232 | struct slgt_info *info = tty->driver_data; | ||
1233 | int rc = -ENOIOCTLCMD; | ||
1234 | |||
1235 | if (sanity_check(info, tty->name, "compat_ioctl")) | ||
1236 | return -ENODEV; | ||
1237 | DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd)); | ||
1238 | |||
1239 | switch (cmd) { | ||
1240 | |||
1241 | case MGSL_IOCSPARAMS32: | ||
1242 | rc = set_params32(info, compat_ptr(arg)); | ||
1243 | break; | ||
1244 | |||
1245 | case MGSL_IOCGPARAMS32: | ||
1246 | rc = get_params32(info, compat_ptr(arg)); | ||
1247 | break; | ||
1248 | |||
1249 | case MGSL_IOCGPARAMS: | ||
1250 | case MGSL_IOCSPARAMS: | ||
1251 | case MGSL_IOCGTXIDLE: | ||
1252 | case MGSL_IOCGSTATS: | ||
1253 | case MGSL_IOCWAITEVENT: | ||
1254 | case MGSL_IOCGIF: | ||
1255 | case MGSL_IOCSGPIO: | ||
1256 | case MGSL_IOCGGPIO: | ||
1257 | case MGSL_IOCWAITGPIO: | ||
1258 | case TIOCGICOUNT: | ||
1259 | rc = ioctl(tty, file, cmd, (unsigned long)(compat_ptr(arg))); | ||
1260 | break; | ||
1261 | |||
1262 | case MGSL_IOCSTXIDLE: | ||
1263 | case MGSL_IOCTXENABLE: | ||
1264 | case MGSL_IOCRXENABLE: | ||
1265 | case MGSL_IOCTXABORT: | ||
1266 | case TIOCMIWAIT: | ||
1267 | case MGSL_IOCSIF: | ||
1268 | rc = ioctl(tty, file, cmd, arg); | ||
1269 | break; | ||
1270 | } | ||
1271 | |||
1272 | DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc)); | ||
1273 | return rc; | ||
1274 | } | ||
1275 | #else | ||
1276 | #define slgt_compat_ioctl NULL | ||
1277 | #endif /* ifdef CONFIG_COMPAT */ | ||
1278 | |||
1279 | /* | ||
1174 | * proc fs support | 1280 | * proc fs support |
1175 | */ | 1281 | */ |
1176 | static inline int line_info(char *buf, struct slgt_info *info) | 1282 | static inline int line_info(char *buf, struct slgt_info *info) |
@@ -3446,6 +3552,7 @@ static const struct tty_operations ops = { | |||
3446 | .chars_in_buffer = chars_in_buffer, | 3552 | .chars_in_buffer = chars_in_buffer, |
3447 | .flush_buffer = flush_buffer, | 3553 | .flush_buffer = flush_buffer, |
3448 | .ioctl = ioctl, | 3554 | .ioctl = ioctl, |
3555 | .compat_ioctl = slgt_compat_ioctl, | ||
3449 | .throttle = throttle, | 3556 | .throttle = throttle, |
3450 | .unthrottle = unthrottle, | 3557 | .unthrottle = unthrottle, |
3451 | .send_xchar = send_xchar, | 3558 | .send_xchar = send_xchar, |
diff --git a/include/linux/Kbuild b/include/linux/Kbuild index 94cc04a143f2..645b3b528150 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild | |||
@@ -140,7 +140,6 @@ header-y += snmp.h | |||
140 | header-y += sockios.h | 140 | header-y += sockios.h |
141 | header-y += som.h | 141 | header-y += som.h |
142 | header-y += sound.h | 142 | header-y += sound.h |
143 | header-y += synclink.h | ||
144 | header-y += taskstats.h | 143 | header-y += taskstats.h |
145 | header-y += telephony.h | 144 | header-y += telephony.h |
146 | header-y += termios.h | 145 | header-y += termios.h |
@@ -320,6 +319,7 @@ unifdef-y += sonypi.h | |||
320 | unifdef-y += soundcard.h | 319 | unifdef-y += soundcard.h |
321 | unifdef-y += stat.h | 320 | unifdef-y += stat.h |
322 | unifdef-y += stddef.h | 321 | unifdef-y += stddef.h |
322 | unifdef-y += synclink.h | ||
323 | unifdef-y += sysctl.h | 323 | unifdef-y += sysctl.h |
324 | unifdef-y += tcp.h | 324 | unifdef-y += tcp.h |
325 | unifdef-y += time.h | 325 | unifdef-y += time.h |
diff --git a/include/linux/synclink.h b/include/linux/synclink.h index c8b042667af1..5562fbf72095 100644 --- a/include/linux/synclink.h +++ b/include/linux/synclink.h | |||
@@ -291,4 +291,28 @@ struct gpio_desc { | |||
291 | #define MGSL_IOCGGPIO _IOR(MGSL_MAGIC_IOC,17,struct gpio_desc) | 291 | #define MGSL_IOCGGPIO _IOR(MGSL_MAGIC_IOC,17,struct gpio_desc) |
292 | #define MGSL_IOCWAITGPIO _IOWR(MGSL_MAGIC_IOC,18,struct gpio_desc) | 292 | #define MGSL_IOCWAITGPIO _IOWR(MGSL_MAGIC_IOC,18,struct gpio_desc) |
293 | 293 | ||
294 | #ifdef __KERNEL__ | ||
295 | /* provide 32 bit ioctl compatibility on 64 bit systems */ | ||
296 | #ifdef CONFIG_COMPAT | ||
297 | #include <linux/compat.h> | ||
298 | struct MGSL_PARAMS32 { | ||
299 | compat_ulong_t mode; | ||
300 | unsigned char loopback; | ||
301 | unsigned short flags; | ||
302 | unsigned char encoding; | ||
303 | compat_ulong_t clock_speed; | ||
304 | unsigned char addr_filter; | ||
305 | unsigned short crc_type; | ||
306 | unsigned char preamble_length; | ||
307 | unsigned char preamble; | ||
308 | compat_ulong_t data_rate; | ||
309 | unsigned char data_bits; | ||
310 | unsigned char stop_bits; | ||
311 | unsigned char parity; | ||
312 | }; | ||
313 | #define MGSL_IOCSPARAMS32 _IOW(MGSL_MAGIC_IOC,0,struct MGSL_PARAMS32) | ||
314 | #define MGSL_IOCGPARAMS32 _IOR(MGSL_MAGIC_IOC,1,struct MGSL_PARAMS32) | ||
315 | #endif | ||
316 | #endif | ||
317 | |||
294 | #endif /* _SYNCLINK_H_ */ | 318 | #endif /* _SYNCLINK_H_ */ |