diff options
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-tape.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 58fc920d5c32..6a0e62542167 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -221,6 +221,8 @@ typedef struct ide_tape_obj { | |||
221 | 221 | ||
222 | static DEFINE_MUTEX(idetape_ref_mutex); | 222 | static DEFINE_MUTEX(idetape_ref_mutex); |
223 | 223 | ||
224 | static DEFINE_MUTEX(idetape_chrdev_mutex); | ||
225 | |||
224 | static struct class *idetape_sysfs_class; | 226 | static struct class *idetape_sysfs_class; |
225 | 227 | ||
226 | static void ide_tape_release(struct device *); | 228 | static void ide_tape_release(struct device *); |
@@ -1457,10 +1459,11 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1457 | if (i >= MAX_HWIFS * MAX_DRIVES) | 1459 | if (i >= MAX_HWIFS * MAX_DRIVES) |
1458 | return -ENXIO; | 1460 | return -ENXIO; |
1459 | 1461 | ||
1460 | lock_kernel(); | 1462 | mutex_lock(&idetape_chrdev_mutex); |
1463 | |||
1461 | tape = ide_tape_get(NULL, true, i); | 1464 | tape = ide_tape_get(NULL, true, i); |
1462 | if (!tape) { | 1465 | if (!tape) { |
1463 | unlock_kernel(); | 1466 | mutex_unlock(&idetape_chrdev_mutex); |
1464 | return -ENXIO; | 1467 | return -ENXIO; |
1465 | } | 1468 | } |
1466 | 1469 | ||
@@ -1519,12 +1522,15 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1519 | tape->door_locked = DOOR_LOCKED; | 1522 | tape->door_locked = DOOR_LOCKED; |
1520 | } | 1523 | } |
1521 | } | 1524 | } |
1522 | unlock_kernel(); | 1525 | mutex_unlock(&idetape_chrdev_mutex); |
1526 | |||
1523 | return 0; | 1527 | return 0; |
1524 | 1528 | ||
1525 | out_put_tape: | 1529 | out_put_tape: |
1526 | ide_tape_put(tape); | 1530 | ide_tape_put(tape); |
1527 | unlock_kernel(); | 1531 | |
1532 | mutex_unlock(&idetape_chrdev_mutex); | ||
1533 | |||
1528 | return retval; | 1534 | return retval; |
1529 | } | 1535 | } |
1530 | 1536 | ||
@@ -1551,7 +1557,8 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
1551 | ide_drive_t *drive = tape->drive; | 1557 | ide_drive_t *drive = tape->drive; |
1552 | unsigned int minor = iminor(inode); | 1558 | unsigned int minor = iminor(inode); |
1553 | 1559 | ||
1554 | lock_kernel(); | 1560 | mutex_lock(&idetape_chrdev_mutex); |
1561 | |||
1555 | tape = drive->driver_data; | 1562 | tape = drive->driver_data; |
1556 | 1563 | ||
1557 | ide_debug_log(IDE_DBG_FUNC, "enter"); | 1564 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
@@ -1575,7 +1582,9 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
1575 | } | 1582 | } |
1576 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); | 1583 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); |
1577 | ide_tape_put(tape); | 1584 | ide_tape_put(tape); |
1578 | unlock_kernel(); | 1585 | |
1586 | mutex_unlock(&idetape_chrdev_mutex); | ||
1587 | |||
1579 | return 0; | 1588 | return 0; |
1580 | } | 1589 | } |
1581 | 1590 | ||