diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:33 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:33 -0400 |
commit | 170dc5b085e688639aa2b7acd1b907e2e1c7a48a (patch) | |
tree | 0e7260a9483b036b2a59509d313324714001a71a /drivers/ide | |
parent | aa7687738af3332470e02ac1060f6c046d83c9a3 (diff) |
ide: cleanup generic_ide_ioctl()
* Fix intendation for the main 'switch ()'.
* 'switch ()' -> 'if ()' for HDIO_DRIVE_TASKFILE case.
* Move HDIO_SET_NICE case under HDIO_GET_NICE one.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide.c | 97 |
1 files changed, 45 insertions, 52 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 4910924abeb7..19181493e722 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -565,8 +565,9 @@ static const struct ide_ioctl_devset ide_ioctl_settings[] = { | |||
565 | { 0 } | 565 | { 0 } |
566 | }; | 566 | }; |
567 | 567 | ||
568 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, | 568 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, |
569 | unsigned int cmd, unsigned long arg) | 569 | struct block_device *bdev, |
570 | unsigned int cmd, unsigned long arg) | ||
570 | { | 571 | { |
571 | int err; | 572 | int err; |
572 | 573 | ||
@@ -575,57 +576,49 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device | |||
575 | return err; | 576 | return err; |
576 | 577 | ||
577 | switch (cmd) { | 578 | switch (cmd) { |
578 | case HDIO_OBSOLETE_IDENTITY: | 579 | case HDIO_OBSOLETE_IDENTITY: |
579 | case HDIO_GET_IDENTITY: | 580 | case HDIO_GET_IDENTITY: |
580 | if (bdev != bdev->bd_contains) | 581 | if (bdev != bdev->bd_contains) |
581 | return -EINVAL; | ||
582 | return ide_get_identity_ioctl(drive, cmd, arg); | ||
583 | case HDIO_GET_NICE: | ||
584 | return ide_get_nice_ioctl(drive, arg); | ||
585 | #ifdef CONFIG_IDE_TASK_IOCTL | ||
586 | case HDIO_DRIVE_TASKFILE: | ||
587 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
588 | return -EACCES; | ||
589 | switch(drive->media) { | ||
590 | case ide_disk: | ||
591 | return ide_taskfile_ioctl(drive, cmd, arg); | ||
592 | default: | ||
593 | return -ENOMSG; | ||
594 | } | ||
595 | #endif /* CONFIG_IDE_TASK_IOCTL */ | ||
596 | |||
597 | case HDIO_DRIVE_CMD: | ||
598 | if (!capable(CAP_SYS_RAWIO)) | ||
599 | return -EACCES; | ||
600 | return ide_cmd_ioctl(drive, cmd, arg); | ||
601 | |||
602 | case HDIO_DRIVE_TASK: | ||
603 | if (!capable(CAP_SYS_RAWIO)) | ||
604 | return -EACCES; | ||
605 | return ide_task_ioctl(drive, cmd, arg); | ||
606 | case HDIO_SET_NICE: | ||
607 | if (!capable(CAP_SYS_ADMIN)) | ||
608 | return -EACCES; | ||
609 | return ide_set_nice_ioctl(drive, arg); | ||
610 | case HDIO_DRIVE_RESET: | ||
611 | if (!capable(CAP_SYS_ADMIN)) | ||
612 | return -EACCES; | ||
613 | |||
614 | return generic_drive_reset(drive); | ||
615 | |||
616 | case HDIO_GET_BUSSTATE: | ||
617 | if (!capable(CAP_SYS_ADMIN)) | ||
618 | return -EACCES; | ||
619 | if (put_user(BUSSTATE_ON, (long __user *)arg)) | ||
620 | return -EFAULT; | ||
621 | return 0; | ||
622 | |||
623 | case HDIO_SET_BUSSTATE: | ||
624 | if (!capable(CAP_SYS_ADMIN)) | ||
625 | return -EACCES; | ||
626 | return -EOPNOTSUPP; | ||
627 | default: | ||
628 | return -EINVAL; | 582 | return -EINVAL; |
583 | return ide_get_identity_ioctl(drive, cmd, arg); | ||
584 | case HDIO_GET_NICE: | ||
585 | return ide_get_nice_ioctl(drive, arg); | ||
586 | case HDIO_SET_NICE: | ||
587 | if (!capable(CAP_SYS_ADMIN)) | ||
588 | return -EACCES; | ||
589 | return ide_set_nice_ioctl(drive, arg); | ||
590 | #ifdef CONFIG_IDE_TASK_IOCTL | ||
591 | case HDIO_DRIVE_TASKFILE: | ||
592 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
593 | return -EACCES; | ||
594 | if (drive->media == ide_disk) | ||
595 | return ide_taskfile_ioctl(drive, cmd, arg); | ||
596 | return -ENOMSG; | ||
597 | #endif | ||
598 | case HDIO_DRIVE_CMD: | ||
599 | if (!capable(CAP_SYS_RAWIO)) | ||
600 | return -EACCES; | ||
601 | return ide_cmd_ioctl(drive, cmd, arg); | ||
602 | case HDIO_DRIVE_TASK: | ||
603 | if (!capable(CAP_SYS_RAWIO)) | ||
604 | return -EACCES; | ||
605 | return ide_task_ioctl(drive, cmd, arg); | ||
606 | case HDIO_DRIVE_RESET: | ||
607 | if (!capable(CAP_SYS_ADMIN)) | ||
608 | return -EACCES; | ||
609 | return generic_drive_reset(drive); | ||
610 | case HDIO_GET_BUSSTATE: | ||
611 | if (!capable(CAP_SYS_ADMIN)) | ||
612 | return -EACCES; | ||
613 | if (put_user(BUSSTATE_ON, (long __user *)arg)) | ||
614 | return -EFAULT; | ||
615 | return 0; | ||
616 | case HDIO_SET_BUSSTATE: | ||
617 | if (!capable(CAP_SYS_ADMIN)) | ||
618 | return -EACCES; | ||
619 | return -EOPNOTSUPP; | ||
620 | default: | ||
621 | return -EINVAL; | ||
629 | } | 622 | } |
630 | } | 623 | } |
631 | EXPORT_SYMBOL(generic_ide_ioctl); | 624 | EXPORT_SYMBOL(generic_ide_ioctl); |