Skip to content

Commit be1fd70

Browse files
Alan-CoxJens Axboe
authored andcommitted
paride: push ioctl down into driver
Leaves us with lock_kernel for two methods. Also remove a bogus printk with no printk level and return -ENOTTY not -EINVAL for correctness. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (Jens: added smp_lock.h include to pt.c, otherwise it wont compile because of missing {un}lock_kernel() definition) Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent 823ed72 commit be1fd70

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

  • drivers/block/paride

‎drivers/block/paride/pt.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ static int (*drives[4])[6] = {&drive0, &drive1, &drive2, &drive3};
146146
#include <linux/mtio.h>
147147
#include <linux/device.h>
148148
#include <linux/sched.h> /* current, TASK_*, schedule_timeout() */
149+
#include <linux/smp_lock.h>
149150

150151
#include <asm/uaccess.h>
151152

@@ -189,8 +190,7 @@ module_param_array(drive3, int, NULL, 0);
189190
#define ATAPI_LOG_SENSE 0x4d
190191

191192
static int pt_open(struct inode *inode, struct file *file);
192-
static int pt_ioctl(struct inode *inode, struct file *file,
193-
unsigned int cmd, unsigned long arg);
193+
static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
194194
static int pt_release(struct inode *inode, struct file *file);
195195
static ssize_t pt_read(struct file *filp, char __user *buf,
196196
size_t count, loff_t * ppos);
@@ -236,7 +236,7 @@ static const struct file_operations pt_fops = {
236236
.owner = THIS_MODULE,
237237
.read = pt_read,
238238
.write = pt_write,
239-
.ioctl = pt_ioctl,
239+
.unlocked_ioctl = pt_ioctl,
240240
.open = pt_open,
241241
.release = pt_release,
242242
};
@@ -685,8 +685,7 @@ static int pt_open(struct inode *inode, struct file *file)
685685
return err;
686686
}
687687

688-
static int pt_ioctl(struct inode *inode, struct file *file,
689-
unsigned int cmd, unsigned long arg)
688+
static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
690689
{
691690
struct pt_unit *tape = file->private_data;
692691
struct mtop __user *p = (void __user *)arg;
@@ -700,23 +699,26 @@ static int pt_ioctl(struct inode *inode, struct file *file,
700699
switch (mtop.mt_op) {
701700

702701
case MTREW:
702+
lock_kernel();
703703
pt_rewind(tape);
704+
unlock_kernel();
704705
return 0;
705706

706707
case MTWEOF:
708+
lock_kernel();
707709
pt_write_fm(tape);
710+
unlock_kernel();
708711
return 0;
709712

710713
default:
711-
printk("%s: Unimplemented mt_op %d\n", tape->name,
714+
/* FIXME: rate limit ?? */
715+
printk(KERN_DEBUG "%s: Unimplemented mt_op %d\n", tape->name,
712716
mtop.mt_op);
713717
return -EINVAL;
714718
}
715719

716720
default:
717-
printk("%s: Unimplemented ioctl 0x%x\n", tape->name, cmd);
718-
return -EINVAL;
719-
721+
return -ENOTTY;
720722
}
721723
}
722724

0 commit comments

Comments
 (0)