diff options
author | Matthias Kaehlcke <matthias.kaehlcke@gmail.com> | 2007-07-09 17:17:56 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-07-09 17:17:56 -0400 |
commit | f9383c4269d264c3cf563bd2de365891f6592ebd (patch) | |
tree | 7f1f3525c51237dc5806d17dd2c68c19d47a493b /drivers/ide/ide-proc.c | |
parent | 1b9da32a2855afa3c5f27690e03a33dc97410c42 (diff) |
ide: use mutex instead of ide_setting_sem semaphore in IDE driver
The IDE driver uses a semaphore as mutex.
Use the mutex API instead of the (binary) semaphore.
Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
--
Diffstat (limited to 'drivers/ide/ide-proc.c')
-rw-r--r-- | drivers/ide/ide-proc.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index ea94c9aa1220..fc1d8ae6a803 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -156,7 +156,7 @@ static int __ide_add_setting(ide_drive_t *drive, const char *name, int rw, int d | |||
156 | { | 156 | { |
157 | ide_settings_t **p = (ide_settings_t **) &drive->settings, *setting = NULL; | 157 | ide_settings_t **p = (ide_settings_t **) &drive->settings, *setting = NULL; |
158 | 158 | ||
159 | down(&ide_setting_sem); | 159 | mutex_lock(&ide_setting_mtx); |
160 | while ((*p) && strcmp((*p)->name, name) < 0) | 160 | while ((*p) && strcmp((*p)->name, name) < 0) |
161 | p = &((*p)->next); | 161 | p = &((*p)->next); |
162 | if ((setting = kzalloc(sizeof(*setting), GFP_KERNEL)) == NULL) | 162 | if ((setting = kzalloc(sizeof(*setting), GFP_KERNEL)) == NULL) |
@@ -177,10 +177,10 @@ static int __ide_add_setting(ide_drive_t *drive, const char *name, int rw, int d | |||
177 | if (auto_remove) | 177 | if (auto_remove) |
178 | setting->auto_remove = 1; | 178 | setting->auto_remove = 1; |
179 | *p = setting; | 179 | *p = setting; |
180 | up(&ide_setting_sem); | 180 | mutex_unlock(&ide_setting_mtx); |
181 | return 0; | 181 | return 0; |
182 | abort: | 182 | abort: |
183 | up(&ide_setting_sem); | 183 | mutex_unlock(&ide_setting_mtx); |
184 | kfree(setting); | 184 | kfree(setting); |
185 | return -1; | 185 | return -1; |
186 | } | 186 | } |
@@ -224,7 +224,7 @@ static void __ide_remove_setting (ide_drive_t *drive, char *name) | |||
224 | * | 224 | * |
225 | * Automatically remove all the driver specific settings for this | 225 | * Automatically remove all the driver specific settings for this |
226 | * drive. This function may not be called from IRQ context. The | 226 | * drive. This function may not be called from IRQ context. The |
227 | * caller must hold ide_setting_sem. | 227 | * caller must hold ide_setting_mtx. |
228 | */ | 228 | */ |
229 | 229 | ||
230 | static void auto_remove_settings (ide_drive_t *drive) | 230 | static void auto_remove_settings (ide_drive_t *drive) |
@@ -269,7 +269,7 @@ static ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name) | |||
269 | * @setting: drive setting | 269 | * @setting: drive setting |
270 | * | 270 | * |
271 | * Read a drive setting and return the value. The caller | 271 | * Read a drive setting and return the value. The caller |
272 | * must hold the ide_setting_sem when making this call. | 272 | * must hold the ide_setting_mtx when making this call. |
273 | * | 273 | * |
274 | * BUGS: the data return and error are the same return value | 274 | * BUGS: the data return and error are the same return value |
275 | * so an error -EINVAL and true return of the same value cannot | 275 | * so an error -EINVAL and true return of the same value cannot |
@@ -306,7 +306,7 @@ static int ide_read_setting(ide_drive_t *drive, ide_settings_t *setting) | |||
306 | * @val: value | 306 | * @val: value |
307 | * | 307 | * |
308 | * Write a drive setting if it is possible. The caller | 308 | * Write a drive setting if it is possible. The caller |
309 | * must hold the ide_setting_sem when making this call. | 309 | * must hold the ide_setting_mtx when making this call. |
310 | * | 310 | * |
311 | * BUGS: the data return and error are the same return value | 311 | * BUGS: the data return and error are the same return value |
312 | * so an error -EINVAL and true return of the same value cannot | 312 | * so an error -EINVAL and true return of the same value cannot |
@@ -367,7 +367,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg) | |||
367 | * @drive: drive being configured | 367 | * @drive: drive being configured |
368 | * | 368 | * |
369 | * Add the generic parts of the system settings to the /proc files. | 369 | * Add the generic parts of the system settings to the /proc files. |
370 | * The caller must not be holding the ide_setting_sem. | 370 | * The caller must not be holding the ide_setting_mtx. |
371 | */ | 371 | */ |
372 | 372 | ||
373 | void ide_add_generic_settings (ide_drive_t *drive) | 373 | void ide_add_generic_settings (ide_drive_t *drive) |
@@ -408,7 +408,7 @@ static int proc_ide_read_settings | |||
408 | 408 | ||
409 | proc_ide_settings_warn(); | 409 | proc_ide_settings_warn(); |
410 | 410 | ||
411 | down(&ide_setting_sem); | 411 | mutex_lock(&ide_setting_mtx); |
412 | out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); | 412 | out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); |
413 | out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); | 413 | out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); |
414 | while(setting) { | 414 | while(setting) { |
@@ -428,7 +428,7 @@ static int proc_ide_read_settings | |||
428 | setting = setting->next; | 428 | setting = setting->next; |
429 | } | 429 | } |
430 | len = out - page; | 430 | len = out - page; |
431 | up(&ide_setting_sem); | 431 | mutex_unlock(&ide_setting_mtx); |
432 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 432 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); |
433 | } | 433 | } |
434 | 434 | ||
@@ -508,16 +508,16 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer, | |||
508 | ++p; | 508 | ++p; |
509 | } | 509 | } |
510 | 510 | ||
511 | down(&ide_setting_sem); | 511 | mutex_lock(&ide_setting_mtx); |
512 | setting = ide_find_setting_by_name(drive, name); | 512 | setting = ide_find_setting_by_name(drive, name); |
513 | if (!setting) | 513 | if (!setting) |
514 | { | 514 | { |
515 | up(&ide_setting_sem); | 515 | mutex_unlock(&ide_setting_mtx); |
516 | goto parse_error; | 516 | goto parse_error; |
517 | } | 517 | } |
518 | if (for_real) | 518 | if (for_real) |
519 | ide_write_setting(drive, setting, val * setting->div_factor / setting->mul_factor); | 519 | ide_write_setting(drive, setting, val * setting->div_factor / setting->mul_factor); |
520 | up(&ide_setting_sem); | 520 | mutex_unlock(&ide_setting_mtx); |
521 | } | 521 | } |
522 | } while (!for_real++); | 522 | } while (!for_real++); |
523 | free_page((unsigned long)buf); | 523 | free_page((unsigned long)buf); |
@@ -705,7 +705,7 @@ EXPORT_SYMBOL(ide_proc_register_driver); | |||
705 | * Clean up the driver specific /proc files and IDE settings | 705 | * Clean up the driver specific /proc files and IDE settings |
706 | * for a given drive. | 706 | * for a given drive. |
707 | * | 707 | * |
708 | * Takes ide_setting_sem and ide_lock. | 708 | * Takes ide_setting_mtx and ide_lock. |
709 | * Caller must hold none of the locks. | 709 | * Caller must hold none of the locks. |
710 | */ | 710 | */ |
711 | 711 | ||
@@ -715,10 +715,10 @@ void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) | |||
715 | 715 | ||
716 | ide_remove_proc_entries(drive->proc, driver->proc); | 716 | ide_remove_proc_entries(drive->proc, driver->proc); |
717 | 717 | ||
718 | down(&ide_setting_sem); | 718 | mutex_lock(&ide_setting_mtx); |
719 | spin_lock_irqsave(&ide_lock, flags); | 719 | spin_lock_irqsave(&ide_lock, flags); |
720 | /* | 720 | /* |
721 | * ide_setting_sem protects the settings list | 721 | * ide_setting_mtx protects the settings list |
722 | * ide_lock protects the use of settings | 722 | * ide_lock protects the use of settings |
723 | * | 723 | * |
724 | * so we need to hold both, ide_settings_sem because we want to | 724 | * so we need to hold both, ide_settings_sem because we want to |
@@ -726,11 +726,11 @@ void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) | |||
726 | * a setting out that is being used. | 726 | * a setting out that is being used. |
727 | * | 727 | * |
728 | * OTOH both ide_{read,write}_setting are only ever used under | 728 | * OTOH both ide_{read,write}_setting are only ever used under |
729 | * ide_setting_sem. | 729 | * ide_setting_mtx. |
730 | */ | 730 | */ |
731 | auto_remove_settings(drive); | 731 | auto_remove_settings(drive); |
732 | spin_unlock_irqrestore(&ide_lock, flags); | 732 | spin_unlock_irqrestore(&ide_lock, flags); |
733 | up(&ide_setting_sem); | 733 | mutex_unlock(&ide_setting_mtx); |
734 | } | 734 | } |
735 | 735 | ||
736 | EXPORT_SYMBOL(ide_proc_unregister_driver); | 736 | EXPORT_SYMBOL(ide_proc_unregister_driver); |