forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/s390/char/tape_char.c
....@@ -290,7 +290,7 @@
290290 rc = tape_open(device);
291291 if (rc == 0) {
292292 filp->private_data = device;
293
- nonseekable_open(inode, filp);
293
+ stream_open(inode, filp);
294294 } else
295295 tape_put_device(device);
296296
....@@ -341,14 +341,14 @@
341341 */
342342 static int
343343 __tapechar_ioctl(struct tape_device *device,
344
- unsigned int no, unsigned long data)
344
+ unsigned int no, void __user *data)
345345 {
346346 int rc;
347347
348348 if (no == MTIOCTOP) {
349349 struct mtop op;
350350
351
- if (copy_from_user(&op, (char __user *) data, sizeof(op)) != 0)
351
+ if (copy_from_user(&op, data, sizeof(op)) != 0)
352352 return -EFAULT;
353353 if (op.mt_count < 0)
354354 return -EINVAL;
....@@ -392,9 +392,7 @@
392392 if (rc < 0)
393393 return rc;
394394 pos.mt_blkno = rc;
395
- if (copy_to_user((char __user *) data, &pos, sizeof(pos)) != 0)
396
- return -EFAULT;
397
- return 0;
395
+ return put_user_mtpos(data, &pos);
398396 }
399397 if (no == MTIOCGET) {
400398 /* MTIOCGET: query the tape drive status. */
....@@ -424,15 +422,12 @@
424422 get.mt_blkno = rc;
425423 }
426424
427
- if (copy_to_user((char __user *) data, &get, sizeof(get)) != 0)
428
- return -EFAULT;
429
-
430
- return 0;
425
+ return put_user_mtget(data, &get);
431426 }
432427 /* Try the discipline ioctl function. */
433428 if (device->discipline->ioctl_fn == NULL)
434429 return -EINVAL;
435
- return device->discipline->ioctl_fn(device, no, data);
430
+ return device->discipline->ioctl_fn(device, no, (unsigned long)data);
436431 }
437432
438433 static long
....@@ -445,7 +440,7 @@
445440
446441 device = (struct tape_device *) filp->private_data;
447442 mutex_lock(&device->mutex);
448
- rc = __tapechar_ioctl(device, no, data);
443
+ rc = __tapechar_ioctl(device, no, (void __user *)data);
449444 mutex_unlock(&device->mutex);
450445 return rc;
451446 }
....@@ -455,23 +450,17 @@
455450 tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
456451 {
457452 struct tape_device *device = filp->private_data;
458
- int rval = -ENOIOCTLCMD;
459
- unsigned long argp;
453
+ long rc;
460454
461
- /* The 'arg' argument of any ioctl function may only be used for
462
- * pointers because of the compat pointer conversion.
463
- * Consider this when adding new ioctls.
464
- */
465
- argp = (unsigned long) compat_ptr(data);
466
- if (device->discipline->ioctl_fn) {
467
- mutex_lock(&device->mutex);
468
- rval = device->discipline->ioctl_fn(device, no, argp);
469
- mutex_unlock(&device->mutex);
470
- if (rval == -EINVAL)
471
- rval = -ENOIOCTLCMD;
472
- }
455
+ if (no == MTIOCPOS32)
456
+ no = MTIOCPOS;
457
+ else if (no == MTIOCGET32)
458
+ no = MTIOCGET;
473459
474
- return rval;
460
+ mutex_lock(&device->mutex);
461
+ rc = __tapechar_ioctl(device, no, compat_ptr(data));
462
+ mutex_unlock(&device->mutex);
463
+ return rc;
475464 }
476465 #endif /* CONFIG_COMPAT */
477466