Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147925
b: refs/heads/master
c: 9d01e4c
h: refs/heads/master
i:
  147923: 7e660f2
v: v3
  • Loading branch information
Borislav Petkov authored and Bartlomiej Zolnierkiewicz committed Jun 8, 2009
1 parent f3c19a6 commit 5377195
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 734affdcae20af4fec95e46a64fb29f063a15c19
refs/heads/master: 9d01e4cd7eb4a70b04cf5a5b4f79c99e8e3e3edc
35 changes: 13 additions & 22 deletions trunk/drivers/ide/ide-tape.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,27 @@ static struct class *idetape_sysfs_class;

static void ide_tape_release(struct device *);

static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES];

static struct ide_tape_obj *ide_tape_get(struct gendisk *disk, bool cdev,
unsigned int i)
{
struct ide_tape_obj *tape = NULL;

mutex_lock(&idetape_ref_mutex);
tape = ide_drv_g(disk, ide_tape_obj);

if (cdev)
tape = idetape_devs[i];
else
tape = ide_drv_g(disk, ide_tape_obj);

if (tape) {
if (ide_device_get(tape->drive))
tape = NULL;
else
get_device(&tape->dev);
}

mutex_unlock(&idetape_ref_mutex);
return tape;
}
Expand All @@ -266,24 +275,6 @@ static void ide_tape_put(struct ide_tape_obj *tape)
mutex_unlock(&idetape_ref_mutex);
}

/*
* The variables below are used for the character device interface. Additional
* state variables are defined in our ide_drive_t structure.
*/
static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES];

static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
{
struct ide_tape_obj *tape = NULL;

mutex_lock(&idetape_ref_mutex);
tape = idetape_devs[i];
if (tape)
get_device(&tape->dev);
mutex_unlock(&idetape_ref_mutex);
return tape;
}

/*
* called on each failed packet command retry to analyze the request sense. We
* currently do not utilize this information.
Expand Down Expand Up @@ -1495,7 +1486,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
return -ENXIO;

lock_kernel();
tape = ide_tape_chrdev_get(i);
tape = ide_tape_get(NULL, true, i);
if (!tape) {
unlock_kernel();
return -ENXIO;
Expand Down Expand Up @@ -1916,7 +1907,7 @@ static const struct file_operations idetape_fops = {

static int idetape_open(struct block_device *bdev, fmode_t mode)
{
struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk);
struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk, false, 0);

if (!tape)
return -ENXIO;
Expand Down

0 comments on commit 5377195

Please sign in to comment.