scsi: ch: remove ch_mutex()
ch_mutex() was introduced with a mechanical conversion, but as we now have correct locking we can remove it altogether. Link: https://lore.kernel.org/r/20200213153207.123357-4-hare@suse.de Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
1c7ce4bcfb
commit
30f6d494cc
@ -44,7 +44,6 @@ MODULE_LICENSE("GPL");
|
|||||||
MODULE_ALIAS_CHARDEV_MAJOR(SCSI_CHANGER_MAJOR);
|
MODULE_ALIAS_CHARDEV_MAJOR(SCSI_CHANGER_MAJOR);
|
||||||
MODULE_ALIAS_SCSI_DEVICE(TYPE_MEDIUM_CHANGER);
|
MODULE_ALIAS_SCSI_DEVICE(TYPE_MEDIUM_CHANGER);
|
||||||
|
|
||||||
static DEFINE_MUTEX(ch_mutex);
|
|
||||||
static int init = 1;
|
static int init = 1;
|
||||||
module_param(init, int, 0444);
|
module_param(init, int, 0444);
|
||||||
MODULE_PARM_DESC(init, \
|
MODULE_PARM_DESC(init, \
|
||||||
@ -591,26 +590,22 @@ ch_open(struct inode *inode, struct file *file)
|
|||||||
scsi_changer *ch;
|
scsi_changer *ch;
|
||||||
int minor = iminor(inode);
|
int minor = iminor(inode);
|
||||||
|
|
||||||
mutex_lock(&ch_mutex);
|
|
||||||
spin_lock(&ch_index_lock);
|
spin_lock(&ch_index_lock);
|
||||||
ch = idr_find(&ch_index_idr, minor);
|
ch = idr_find(&ch_index_idr, minor);
|
||||||
|
|
||||||
if (ch == NULL || !kref_get_unless_zero(&ch->ref)) {
|
if (ch == NULL || !kref_get_unless_zero(&ch->ref)) {
|
||||||
spin_unlock(&ch_index_lock);
|
spin_unlock(&ch_index_lock);
|
||||||
mutex_unlock(&ch_mutex);
|
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
spin_unlock(&ch_index_lock);
|
spin_unlock(&ch_index_lock);
|
||||||
if (scsi_device_get(ch->device)) {
|
if (scsi_device_get(ch->device)) {
|
||||||
kref_put(&ch->ref, ch_destroy);
|
kref_put(&ch->ref, ch_destroy);
|
||||||
mutex_unlock(&ch_mutex);
|
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
/* Synchronize with ch_probe() */
|
/* Synchronize with ch_probe() */
|
||||||
mutex_lock(&ch->lock);
|
mutex_lock(&ch->lock);
|
||||||
file->private_data = ch;
|
file->private_data = ch;
|
||||||
mutex_unlock(&ch->lock);
|
mutex_unlock(&ch->lock);
|
||||||
mutex_unlock(&ch_mutex);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user