summaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 22:39:33 +0200
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 22:39:33 +0200
commitaa7687738af3332470e02ac1060f6c046d83c9a3 (patch)
tree2eb2cd89de0b8dcad12534e28a9178d0325ae491 /drivers/ide/ide-disk.c
parent9232c14bff36d65de254f34386c00b732c5b6099 (diff)
downloadop-kernel-dev-aa7687738af3332470e02ac1060f6c046d83c9a3.zip
op-kernel-dev-aa7687738af3332470e02ac1060f6c046d83c9a3.tar.gz
ide: add ide_setting_ioctl() helper
* Add struct ide_ioctl_devset representing ioctl device setting. * Add ide_setting_ioctl() helper for matching given ioctl and its parameters against table of ioctl device settings. * Convert ide_setting_ioctl() and idedisk_ioctl() to use ide_setting_ioctl(). * Un-export ide_setting_mtx. While at it: * {get,set}_lba_addressing() -> {get,set}_addressing() There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r--drivers/ide/ide-disk.c59
1 files changed, 18 insertions, 41 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 43025c9..1190634 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -676,7 +676,7 @@ static int set_acoustic(ide_drive_t *drive, int arg)
return 0;
}
-ide_devset_get(lba_addressing, addressing);
+ide_devset_get(addressing, addressing);
/*
* drive->addressing:
@@ -684,7 +684,7 @@ ide_devset_get(lba_addressing, addressing);
* 1: 48-bit
* 2: 48-bit capable doing 28-bit
*/
-static int set_lba_addressing(ide_drive_t *drive, int arg)
+static int set_addressing(ide_drive_t *drive, int arg)
{
if (arg < 0 || arg > 2)
return -EINVAL;
@@ -704,7 +704,7 @@ static int set_lba_addressing(ide_drive_t *drive, int arg)
#ifdef CONFIG_IDE_PROC_FS
ide_devset_rw_nolock(acoustic, 0, 254, acoustic);
-ide_devset_rw_nolock(address, 0, 2, lba_addressing);
+ide_devset_rw_nolock(address, 0, 2, addressing);
ide_devset_rw_nolock(multcount, 0, 16, multcount);
ide_devset_rw_nolock(nowerr, 0, 1, nowerr);
ide_devset_rw_nolock(wcache, 0, 1, wcache);
@@ -753,7 +753,7 @@ static void idedisk_setup(ide_drive_t *drive)
drive->doorlocking = 1;
}
- (void)set_lba_addressing(drive, 1);
+ (void)set_addressing(drive, 1);
if (drive->addressing == 1) {
int max_s = 2048;
@@ -1000,51 +1000,28 @@ static int idedisk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
return 0;
}
+static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = {
+{ HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, get_addressing, set_addressing },
+{ HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, get_multcount, set_multcount },
+{ HDIO_GET_NOWERR, HDIO_SET_NOWERR, get_nowerr, set_nowerr },
+{ HDIO_GET_WCACHE, HDIO_SET_WCACHE, get_wcache, set_wcache },
+{ HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, get_acoustic, set_acoustic },
+{ 0 }
+};
+
static int idedisk_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
- unsigned long flags;
struct block_device *bdev = inode->i_bdev;
struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk);
ide_drive_t *drive = idkp->drive;
- int err, (*getfunc)(ide_drive_t *), (*setfunc)(ide_drive_t *, int);
-
- switch (cmd) {
- case HDIO_GET_ADDRESS: getfunc = get_lba_addressing; goto read_val;
- case HDIO_GET_MULTCOUNT: getfunc = get_multcount; goto read_val;
- case HDIO_GET_NOWERR: getfunc = get_nowerr; goto read_val;
- case HDIO_GET_WCACHE: getfunc = get_wcache; goto read_val;
- case HDIO_GET_ACOUSTIC: getfunc = get_acoustic; goto read_val;
- case HDIO_SET_ADDRESS: setfunc = set_lba_addressing; goto set_val;
- case HDIO_SET_MULTCOUNT: setfunc = set_multcount; goto set_val;
- case HDIO_SET_NOWERR: setfunc = set_nowerr; goto set_val;
- case HDIO_SET_WCACHE: setfunc = set_wcache; goto set_val;
- case HDIO_SET_ACOUSTIC: setfunc = set_acoustic; goto set_val;
- }
+ int err;
- return generic_ide_ioctl(drive, file, bdev, cmd, arg);
+ err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings);
+ if (err != -EOPNOTSUPP)
+ return err;
-read_val:
- mutex_lock(&ide_setting_mtx);
- spin_lock_irqsave(&ide_lock, flags);
- err = getfunc(drive);
- spin_unlock_irqrestore(&ide_lock, flags);
- mutex_unlock(&ide_setting_mtx);
- return err >= 0 ? put_user(err, (long __user *)arg) : err;
-
-set_val:
- if (bdev != bdev->bd_contains)
- err = -EINVAL;
- else {
- if (!capable(CAP_SYS_ADMIN))
- err = -EACCES;
- else {
- mutex_lock(&ide_setting_mtx);
- err = setfunc(drive, arg);
- mutex_unlock(&ide_setting_mtx);
- }
- }
- return err;
+ return generic_ide_ioctl(drive, file, bdev, cmd, arg);
}
static int idedisk_media_changed(struct gendisk *disk)
OpenPOWER on IntegriCloud