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: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 3e0e29f7
...@@ -19,7 +19,6 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev, ...@@ -19,7 +19,6 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev,
const struct ide_ioctl_devset *s) const struct ide_ioctl_devset *s)
{ {
const struct ide_devset *ds; const struct ide_devset *ds;
unsigned long flags;
int err = -EOPNOTSUPP; int err = -EOPNOTSUPP;
for (; (ds = s->setting); s++) { for (; (ds = s->setting); s++) {
...@@ -33,9 +32,7 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev, ...@@ -33,9 +32,7 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev,
read_val: read_val:
mutex_lock(&ide_setting_mtx); mutex_lock(&ide_setting_mtx);
spin_lock_irqsave(&ide_lock, flags);
err = ds->get(drive); err = ds->get(drive);
spin_unlock_irqrestore(&ide_lock, flags);
mutex_unlock(&ide_setting_mtx); mutex_unlock(&ide_setting_mtx);
return err >= 0 ? put_user(err, (long __user *)arg) : err; return err >= 0 ? put_user(err, (long __user *)arg) : err;
......
...@@ -155,13 +155,8 @@ static int ide_read_setting(ide_drive_t *drive, ...@@ -155,13 +155,8 @@ static int ide_read_setting(ide_drive_t *drive,
const struct ide_devset *ds = setting->setting; const struct ide_devset *ds = setting->setting;
int val = -EINVAL; int val = -EINVAL;
if (ds->get) { if (ds->get)
unsigned long flags;
spin_lock_irqsave(&ide_lock, flags);
val = ds->get(drive); val = ds->get(drive);
spin_unlock_irqrestore(&ide_lock, flags);
}
return val; return val;
} }
...@@ -583,31 +578,19 @@ EXPORT_SYMBOL(ide_proc_register_driver); ...@@ -583,31 +578,19 @@ EXPORT_SYMBOL(ide_proc_register_driver);
* Clean up the driver specific /proc files and IDE settings * Clean up the driver specific /proc files and IDE settings
* for a given drive. * for a given drive.
* *
* Takes ide_setting_mtx and ide_lock. * Takes ide_setting_mtx.
* Caller must hold none of the locks.
*/ */
void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver)
{ {
unsigned long flags;
ide_remove_proc_entries(drive->proc, driver->proc_entries(drive)); ide_remove_proc_entries(drive->proc, driver->proc_entries(drive));
mutex_lock(&ide_setting_mtx); mutex_lock(&ide_setting_mtx);
spin_lock_irqsave(&ide_lock, flags);
/* /*
* ide_setting_mtx protects the settings list * ide_setting_mtx protects both the settings list and the use
* ide_lock protects the use of settings * of settings (we cannot take a setting out that is being used).
*
* so we need to hold both, ide_settings_sem because we want to
* modify the settings list, and ide_lock because we cannot take
* a setting out that is being used.
*
* OTOH both ide_{read,write}_setting are only ever used under
* ide_setting_mtx.
*/ */
drive->settings = NULL; drive->settings = NULL;
spin_unlock_irqrestore(&ide_lock, flags);
mutex_unlock(&ide_setting_mtx); mutex_unlock(&ide_setting_mtx);
} }
EXPORT_SYMBOL(ide_proc_unregister_driver); EXPORT_SYMBOL(ide_proc_unregister_driver);
......
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