aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-tape.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 055f52e1ea0e..51ea59e3f6ad 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -240,18 +240,27 @@ static struct class *idetape_sysfs_class;
240 240
241static void ide_tape_release(struct device *); 241static void ide_tape_release(struct device *);
242 242
243static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) 243static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES];
244
245static struct ide_tape_obj *ide_tape_get(struct gendisk *disk, bool cdev,
246 unsigned int i)
244{ 247{
245 struct ide_tape_obj *tape = NULL; 248 struct ide_tape_obj *tape = NULL;
246 249
247 mutex_lock(&idetape_ref_mutex); 250 mutex_lock(&idetape_ref_mutex);
248 tape = ide_drv_g(disk, ide_tape_obj); 251
252 if (cdev)
253 tape = idetape_devs[i];
254 else
255 tape = ide_drv_g(disk, ide_tape_obj);
256
249 if (tape) { 257 if (tape) {
250 if (ide_device_get(tape->drive)) 258 if (ide_device_get(tape->drive))
251 tape = NULL; 259 tape = NULL;
252 else 260 else
253 get_device(&tape->dev); 261 get_device(&tape->dev);
254 } 262 }
263
255 mutex_unlock(&idetape_ref_mutex); 264 mutex_unlock(&idetape_ref_mutex);
256 return tape; 265 return tape;
257} 266}
@@ -267,24 +276,6 @@ static void ide_tape_put(struct ide_tape_obj *tape)
267} 276}
268 277
269/* 278/*
270 * The variables below are used for the character device interface. Additional
271 * state variables are defined in our ide_drive_t structure.
272 */
273static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES];
274
275static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
276{
277 struct ide_tape_obj *tape = NULL;
278
279 mutex_lock(&idetape_ref_mutex);
280 tape = idetape_devs[i];
281 if (tape)
282 get_device(&tape->dev);
283 mutex_unlock(&idetape_ref_mutex);
284 return tape;
285}
286
287/*
288 * called on each failed packet command retry to analyze the request sense. We 279 * called on each failed packet command retry to analyze the request sense. We
289 * currently do not utilize this information. 280 * currently do not utilize this information.
290 */ 281 */
@@ -1495,7 +1486,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
1495 return -ENXIO; 1486 return -ENXIO;
1496 1487
1497 lock_kernel(); 1488 lock_kernel();
1498 tape = ide_tape_chrdev_get(i); 1489 tape = ide_tape_get(NULL, true, i);
1499 if (!tape) { 1490 if (!tape) {
1500 unlock_kernel(); 1491 unlock_kernel();
1501 return -ENXIO; 1492 return -ENXIO;
@@ -1916,7 +1907,7 @@ static const struct file_operations idetape_fops = {
1916 1907
1917static int idetape_open(struct block_device *bdev, fmode_t mode) 1908static int idetape_open(struct block_device *bdev, fmode_t mode)
1918{ 1909{
1919 struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk); 1910 struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk, false, 0);
1920 1911
1921 if (!tape) 1912 if (!tape)
1922 return -ENXIO; 1913 return -ENXIO;