aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorPaul Fulghum <paulkf@microgate.com>2007-05-11 01:22:43 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-11 11:29:34 -0400
commit2acdb1694494eb6f17b44b2b3065879af32d0d46 (patch)
treec9d53e5082ac8e2e80aa228c95102661e0822978 /drivers/char
parent4c64c30a5c96bb798cbd6097d4996205b5359fa2 (diff)
synclink_gt: add compat_ioctl
Add support for 32 bit ioctl on 64 bit systems for synclink_gt Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Paul Fulghum <paulkf@microgate.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/synclink_gt.c107
1 files changed, 107 insertions, 0 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
1177static 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
1200static 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
1229static 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 */
1176static inline int line_info(char *buf, struct slgt_info *info) 1282static 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,