Commit f3da61af authored by Alexander Viro's avatar Alexander Viro Committed by James Bottomley

[PATCH] ide-taskfile ioctls prototype cleanup

	* ide_..._ioctl() never use two of five arguments - inode and file.
Arguments removed.
parent 5ddfdaad
...@@ -1404,7 +1404,7 @@ ide_startstop_t flagged_task_out_intr(ide_drive_t *); ...@@ -1404,7 +1404,7 @@ ide_startstop_t flagged_task_out_intr(ide_drive_t *);
ide_startstop_t flagged_pre_task_mulout_intr(ide_drive_t *, struct request *); ide_startstop_t flagged_pre_task_mulout_intr(ide_drive_t *, struct request *);
ide_startstop_t flagged_task_mulout_intr(ide_drive_t *); ide_startstop_t flagged_task_mulout_intr(ide_drive_t *);
int ide_taskfile_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
{ {
ide_task_request_t *req_task; ide_task_request_t *req_task;
ide_task_t args; ide_task_t args;
...@@ -1626,7 +1626,7 @@ EXPORT_SYMBOL(ide_wait_cmd); ...@@ -1626,7 +1626,7 @@ EXPORT_SYMBOL(ide_wait_cmd);
/* /*
* FIXME : this needs to map into at taskfile. <andre@linux-ide.org> * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
*/ */
int ide_cmd_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
{ {
#if 1 #if 1
int err = 0; int err = 0;
...@@ -1764,7 +1764,7 @@ EXPORT_SYMBOL(ide_wait_cmd_task); ...@@ -1764,7 +1764,7 @@ EXPORT_SYMBOL(ide_wait_cmd_task);
/* /*
* FIXME : this needs to map into at taskfile. <andre@linux-ide.org> * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
*/ */
int ide_task_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
{ {
int err = 0; int err = 0;
u8 args[7], *argbuf = args; u8 args[7], *argbuf = args;
...@@ -2185,7 +2185,7 @@ ide_startstop_t flagged_task_mulout_intr (ide_drive_t *drive) ...@@ -2185,7 +2185,7 @@ ide_startstop_t flagged_task_mulout_intr (ide_drive_t *drive)
#ifdef CONFIG_PKT_TASK_IOCTL #ifdef CONFIG_PKT_TASK_IOCTL
int pkt_taskfile_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) int pkt_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
{ {
#if 0 #if 0
switch(req_task->data_phase) { switch(req_task->data_phase) {
......
...@@ -2400,10 +2400,10 @@ int ata_attach(ide_drive_t *drive) ...@@ -2400,10 +2400,10 @@ int ata_attach(ide_drive_t *drive)
EXPORT_SYMBOL(ata_attach); EXPORT_SYMBOL(ata_attach);
static int ide_ioctl (struct inode *inode, struct file *file, int generic_ide_ioctl(struct block_device *bdev, unsigned int cmd,
unsigned int cmd, unsigned long arg) unsigned long arg)
{ {
ide_drive_t *drive = inode->i_bdev->bd_disk->private_data; ide_drive_t *drive = bdev->bd_disk->private_data;
ide_settings_t *setting; ide_settings_t *setting;
int err = 0; int err = 0;
...@@ -2412,7 +2412,7 @@ static int ide_ioctl (struct inode *inode, struct file *file, ...@@ -2412,7 +2412,7 @@ static int ide_ioctl (struct inode *inode, struct file *file,
err = ide_read_setting(drive, setting); err = ide_read_setting(drive, setting);
return err >= 0 ? put_user(err, (long *) arg) : err; return err >= 0 ? put_user(err, (long *) arg) : err;
} else { } else {
if (inode->i_bdev != inode->i_bdev->bd_contains) if (bdev != bdev->bd_contains)
return -EINVAL; return -EINVAL;
return ide_write_setting(drive, setting, arg); return ide_write_setting(drive, setting, arg);
} }
...@@ -2427,7 +2427,7 @@ static int ide_ioctl (struct inode *inode, struct file *file, ...@@ -2427,7 +2427,7 @@ static int ide_ioctl (struct inode *inode, struct file *file,
if (put_user(drive->bios_head, (u8 *) &loc->heads)) return -EFAULT; if (put_user(drive->bios_head, (u8 *) &loc->heads)) return -EFAULT;
if (put_user(drive->bios_sect, (u8 *) &loc->sectors)) return -EFAULT; if (put_user(drive->bios_sect, (u8 *) &loc->sectors)) return -EFAULT;
if (put_user(bios_cyl, (u16 *) &loc->cylinders)) return -EFAULT; if (put_user(bios_cyl, (u16 *) &loc->cylinders)) return -EFAULT;
if (put_user((unsigned)get_start_sect(inode->i_bdev), if (put_user((unsigned)get_start_sect(bdev),
(unsigned long *) &loc->start)) return -EFAULT; (unsigned long *) &loc->start)) return -EFAULT;
return 0; return 0;
} }
...@@ -2439,14 +2439,14 @@ static int ide_ioctl (struct inode *inode, struct file *file, ...@@ -2439,14 +2439,14 @@ static int ide_ioctl (struct inode *inode, struct file *file,
if (put_user(drive->head, (u8 *) &loc->heads)) return -EFAULT; if (put_user(drive->head, (u8 *) &loc->heads)) return -EFAULT;
if (put_user(drive->sect, (u8 *) &loc->sectors)) return -EFAULT; if (put_user(drive->sect, (u8 *) &loc->sectors)) return -EFAULT;
if (put_user(drive->cyl, (unsigned int *) &loc->cylinders)) return -EFAULT; if (put_user(drive->cyl, (unsigned int *) &loc->cylinders)) return -EFAULT;
if (put_user((unsigned)get_start_sect(inode->i_bdev), if (put_user((unsigned)get_start_sect(bdev),
(unsigned long *) &loc->start)) return -EFAULT; (unsigned long *) &loc->start)) return -EFAULT;
return 0; return 0;
} }
case HDIO_OBSOLETE_IDENTITY: case HDIO_OBSOLETE_IDENTITY:
case HDIO_GET_IDENTITY: case HDIO_GET_IDENTITY:
if (inode->i_bdev != inode->i_bdev->bd_contains) if (bdev != bdev->bd_contains)
return -EINVAL; return -EINVAL;
if (drive->id == NULL) if (drive->id == NULL)
return -ENOMSG; return -ENOMSG;
...@@ -2468,12 +2468,12 @@ static int ide_ioctl (struct inode *inode, struct file *file, ...@@ -2468,12 +2468,12 @@ static int ide_ioctl (struct inode *inode, struct file *file,
return -EACCES; return -EACCES;
switch(drive->media) { switch(drive->media) {
case ide_disk: case ide_disk:
return ide_taskfile_ioctl(drive, inode, file, cmd, arg); return ide_taskfile_ioctl(drive, cmd, arg);
#ifdef CONFIG_PKT_TASK_IOCTL #ifdef CONFIG_PKT_TASK_IOCTL
case ide_cdrom: case ide_cdrom:
case ide_tape: case ide_tape:
case ide_floppy: case ide_floppy:
return pkt_taskfile_ioctl(drive, inode, file, cmd, arg); return pkt_taskfile_ioctl(drive, cmd, arg);
#endif /* CONFIG_PKT_TASK_IOCTL */ #endif /* CONFIG_PKT_TASK_IOCTL */
default: default:
return -ENOMSG; return -ENOMSG;
...@@ -2483,12 +2483,12 @@ static int ide_ioctl (struct inode *inode, struct file *file, ...@@ -2483,12 +2483,12 @@ static int ide_ioctl (struct inode *inode, struct file *file,
case HDIO_DRIVE_CMD: case HDIO_DRIVE_CMD:
if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
return -EACCES; return -EACCES;
return ide_cmd_ioctl(drive, inode, file, cmd, arg); return ide_cmd_ioctl(drive, cmd, arg);
case HDIO_DRIVE_TASK: case HDIO_DRIVE_TASK:
if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
return -EACCES; return -EACCES;
return ide_task_ioctl(drive, inode, file, cmd, arg); return ide_task_ioctl(drive, cmd, arg);
case HDIO_SCAN_HWIF: case HDIO_SCAN_HWIF:
{ {
...@@ -2545,15 +2545,14 @@ static int ide_ioctl (struct inode *inode, struct file *file, ...@@ -2545,15 +2545,14 @@ static int ide_ioctl (struct inode *inode, struct file *file,
* } * }
* HWIF(drive)->multiproc(drive); * HWIF(drive)->multiproc(drive);
*/ */
return file->f_op->ioctl(inode, file, return ioctl_by_bdev(bdev, BLKRRPART, 0);
BLKRRPART, 0);
} }
return 0; return 0;
} }
case CDROMEJECT: case CDROMEJECT:
case CDROMCLOSETRAY: case CDROMCLOSETRAY:
return scsi_cmd_ioctl(inode->i_bdev, cmd, arg); return scsi_cmd_ioctl(bdev, cmd, arg);
case HDIO_GET_BUSSTATE: case HDIO_GET_BUSSTATE:
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
...@@ -2570,12 +2569,24 @@ static int ide_ioctl (struct inode *inode, struct file *file, ...@@ -2570,12 +2569,24 @@ static int ide_ioctl (struct inode *inode, struct file *file,
return 0; return 0;
default: default:
if (drive->driver != NULL) return -EINVAL;
return DRIVER(drive)->ioctl(drive, inode, file, cmd, arg);
return -EPERM;
} }
} }
EXPORT_SYMBOL(generic_ide_ioctl);
static int ide_ioctl (struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct block_device *bdev = inode->i_bdev;
ide_drive_t *drive = bdev->bd_disk->private_data;
int err = generic_ide_ioctl(bdev, cmd, arg);
if (err == -EINVAL && drive->driver)
err = DRIVER(drive)->ioctl(drive, inode, file, cmd, arg);
return err;
}
static int ide_check_media_change(struct gendisk *disk) static int ide_check_media_change(struct gendisk *disk)
{ {
ide_drive_t *drive = disk->private_data; ide_drive_t *drive = disk->private_data;
......
...@@ -1207,6 +1207,8 @@ typedef struct ide_driver_s { ...@@ -1207,6 +1207,8 @@ typedef struct ide_driver_s {
#define DRIVER(drive) ((drive)->driver) #define DRIVER(drive) ((drive)->driver)
extern int generic_ide_ioctl(struct block_device *, unsigned, unsigned long);
/* /*
* IDE modules. * IDE modules.
*/ */
...@@ -1483,9 +1485,9 @@ extern ide_post_handler_t * ide_post_handler_parser(struct hd_drive_task_hdr *, ...@@ -1483,9 +1485,9 @@ extern ide_post_handler_t * ide_post_handler_parser(struct hd_drive_task_hdr *,
/* Expects args is a full set of TF registers and parses the command type */ /* Expects args is a full set of TF registers and parses the command type */
extern int ide_cmd_type_parser(ide_task_t *); extern int ide_cmd_type_parser(ide_task_t *);
int ide_taskfile_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long); int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
int ide_cmd_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long); int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
int ide_task_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long); int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
#if 0 #if 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment