aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-12-29 14:27:29 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-12-29 14:27:29 -0500
commit1f473e9c92ea458e60494561a2065a358b7239bb (patch)
treedc80484535ac987d49179c45f30f1fabadc8855a /drivers
parent3e0e29f7373ec96a1bd972790649524af7353f42 (diff)
ide: IDE settings don't need an ide_lock held
IDE settings are protected by ide_setting_mtx mutex so there is no need to hold ide_lock in ide_setting_ioctl(), ide_read_setting() and ide_proc_unregister_driver(). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ide-ioctls.c3
-rw-r--r--drivers/ide/ide-proc.c25
2 files changed, 4 insertions, 24 deletions
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index fcde16bb53a7..f9034765aa18 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
@@ -19,7 +19,6 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev,
19 const struct ide_ioctl_devset *s) 19 const struct ide_ioctl_devset *s)
20{ 20{
21 const struct ide_devset *ds; 21 const struct ide_devset *ds;
22 unsigned long flags;
23 int err = -EOPNOTSUPP; 22 int err = -EOPNOTSUPP;
24 23
25 for (; (ds = s->setting); s++) { 24 for (; (ds = s->setting); s++) {
@@ -33,9 +32,7 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev,
33 32
34read_val: 33read_val:
35 mutex_lock(&ide_setting_mtx); 34 mutex_lock(&ide_setting_mtx);
36 spin_lock_irqsave(&ide_lock, flags);
37 err = ds->get(drive); 35 err = ds->get(drive);
38 spin_unlock_irqrestore(&ide_lock, flags);
39 mutex_unlock(&ide_setting_mtx); 36 mutex_unlock(&ide_setting_mtx);
40 return err >= 0 ? put_user(err, (long __user *)arg) : err; 37 return err >= 0 ? put_user(err, (long __user *)arg) : err;
41 38
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index f3cddd1b2f8f..dd899e1f3841 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -155,13 +155,8 @@ static int ide_read_setting(ide_drive_t *drive,
155 const struct ide_devset *ds = setting->setting; 155 const struct ide_devset *ds = setting->setting;
156 int val = -EINVAL; 156 int val = -EINVAL;
157 157
158 if (ds->get) { 158 if (ds->get)
159 unsigned long flags;
160
161 spin_lock_irqsave(&ide_lock, flags);
162 val = ds->get(drive); 159 val = ds->get(drive);
163 spin_unlock_irqrestore(&ide_lock, flags);
164 }
165 160
166 return val; 161 return val;
167} 162}
@@ -583,31 +578,19 @@ EXPORT_SYMBOL(ide_proc_register_driver);
583 * Clean up the driver specific /proc files and IDE settings 578 * Clean up the driver specific /proc files and IDE settings
584 * for a given drive. 579 * for a given drive.
585 * 580 *
586 * Takes ide_setting_mtx and ide_lock. 581 * Takes ide_setting_mtx.
587 * Caller must hold none of the locks.
588 */ 582 */
589 583
590void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) 584void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver)
591{ 585{
592 unsigned long flags;
593
594 ide_remove_proc_entries(drive->proc, driver->proc_entries(drive)); 586 ide_remove_proc_entries(drive->proc, driver->proc_entries(drive));
595 587
596 mutex_lock(&ide_setting_mtx); 588 mutex_lock(&ide_setting_mtx);
597 spin_lock_irqsave(&ide_lock, flags);
598 /* 589 /*
599 * ide_setting_mtx protects the settings list 590 * ide_setting_mtx protects both the settings list and the use
600 * ide_lock protects the use of settings 591 * of settings (we cannot take a setting out that is being used).
601 *
602 * so we need to hold both, ide_settings_sem because we want to
603 * modify the settings list, and ide_lock because we cannot take
604 * a setting out that is being used.
605 *
606 * OTOH both ide_{read,write}_setting are only ever used under
607 * ide_setting_mtx.
608 */ 592 */
609 drive->settings = NULL; 593 drive->settings = NULL;
610 spin_unlock_irqrestore(&ide_lock, flags);
611 mutex_unlock(&ide_setting_mtx); 594 mutex_unlock(&ide_setting_mtx);
612} 595}
613EXPORT_SYMBOL(ide_proc_unregister_driver); 596EXPORT_SYMBOL(ide_proc_unregister_driver);