diff options
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r-- | drivers/ide/ide-floppy.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index d33717c8afd4..57cd21c5b2c1 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -279,6 +279,7 @@ typedef struct ide_floppy_obj { | |||
279 | ide_driver_t *driver; | 279 | ide_driver_t *driver; |
280 | struct gendisk *disk; | 280 | struct gendisk *disk; |
281 | struct kref kref; | 281 | struct kref kref; |
282 | unsigned int openers; /* protected by BKL for now */ | ||
282 | 283 | ||
283 | /* Current packet command */ | 284 | /* Current packet command */ |
284 | idefloppy_pc_t *pc; | 285 | idefloppy_pc_t *pc; |
@@ -866,7 +867,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
866 | if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { | 867 | if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { |
867 | printk(KERN_ERR "ide-floppy: The floppy wants to issue " | 868 | printk(KERN_ERR "ide-floppy: The floppy wants to issue " |
868 | "more interrupts in DMA mode\n"); | 869 | "more interrupts in DMA mode\n"); |
869 | (void)__ide_dma_off(drive); | 870 | ide_dma_off(drive); |
870 | return ide_do_reset(drive); | 871 | return ide_do_reset(drive); |
871 | } | 872 | } |
872 | 873 | ||
@@ -1096,9 +1097,9 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p | |||
1096 | pc->current_position = pc->buffer; | 1097 | pc->current_position = pc->buffer; |
1097 | bcount.all = min(pc->request_transfer, 63 * 1024); | 1098 | bcount.all = min(pc->request_transfer, 63 * 1024); |
1098 | 1099 | ||
1099 | if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) { | 1100 | if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) |
1100 | (void)__ide_dma_off(drive); | 1101 | ide_dma_off(drive); |
1101 | } | 1102 | |
1102 | feature.all = 0; | 1103 | feature.all = 0; |
1103 | 1104 | ||
1104 | if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) | 1105 | if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) |
@@ -1433,7 +1434,8 @@ static int idefloppy_get_capacity (ide_drive_t *drive) | |||
1433 | 1434 | ||
1434 | drive->bios_cyl = 0; | 1435 | drive->bios_cyl = 0; |
1435 | drive->bios_head = drive->bios_sect = 0; | 1436 | drive->bios_head = drive->bios_sect = 0; |
1436 | floppy->blocks = floppy->bs_factor = 0; | 1437 | floppy->blocks = 0; |
1438 | floppy->bs_factor = 1; | ||
1437 | set_capacity(floppy->disk, 0); | 1439 | set_capacity(floppy->disk, 0); |
1438 | 1440 | ||
1439 | idefloppy_create_read_capacity_cmd(&pc); | 1441 | idefloppy_create_read_capacity_cmd(&pc); |
@@ -1949,9 +1951,9 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1949 | 1951 | ||
1950 | drive = floppy->drive; | 1952 | drive = floppy->drive; |
1951 | 1953 | ||
1952 | drive->usage++; | 1954 | floppy->openers++; |
1953 | 1955 | ||
1954 | if (drive->usage == 1) { | 1956 | if (floppy->openers == 1) { |
1955 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | 1957 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); |
1956 | /* Just in case */ | 1958 | /* Just in case */ |
1957 | 1959 | ||
@@ -1969,13 +1971,11 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1969 | ** capacity of the drive or begin the format - Sam | 1971 | ** capacity of the drive or begin the format - Sam |
1970 | */ | 1972 | */ |
1971 | ) { | 1973 | ) { |
1972 | drive->usage--; | ||
1973 | ret = -EIO; | 1974 | ret = -EIO; |
1974 | goto out_put_floppy; | 1975 | goto out_put_floppy; |
1975 | } | 1976 | } |
1976 | 1977 | ||
1977 | if (floppy->wp && (filp->f_mode & 2)) { | 1978 | if (floppy->wp && (filp->f_mode & 2)) { |
1978 | drive->usage--; | ||
1979 | ret = -EROFS; | 1979 | ret = -EROFS; |
1980 | goto out_put_floppy; | 1980 | goto out_put_floppy; |
1981 | } | 1981 | } |
@@ -1987,13 +1987,13 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1987 | } | 1987 | } |
1988 | check_disk_change(inode->i_bdev); | 1988 | check_disk_change(inode->i_bdev); |
1989 | } else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) { | 1989 | } else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) { |
1990 | drive->usage--; | ||
1991 | ret = -EBUSY; | 1990 | ret = -EBUSY; |
1992 | goto out_put_floppy; | 1991 | goto out_put_floppy; |
1993 | } | 1992 | } |
1994 | return 0; | 1993 | return 0; |
1995 | 1994 | ||
1996 | out_put_floppy: | 1995 | out_put_floppy: |
1996 | floppy->openers--; | ||
1997 | ide_floppy_put(floppy); | 1997 | ide_floppy_put(floppy); |
1998 | return ret; | 1998 | return ret; |
1999 | } | 1999 | } |
@@ -2007,7 +2007,7 @@ static int idefloppy_release(struct inode *inode, struct file *filp) | |||
2007 | 2007 | ||
2008 | debug_log(KERN_INFO "Reached idefloppy_release\n"); | 2008 | debug_log(KERN_INFO "Reached idefloppy_release\n"); |
2009 | 2009 | ||
2010 | if (drive->usage == 1) { | 2010 | if (floppy->openers == 1) { |
2011 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 2011 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
2012 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { | 2012 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { |
2013 | idefloppy_create_prevent_cmd(&pc, 0); | 2013 | idefloppy_create_prevent_cmd(&pc, 0); |
@@ -2016,7 +2016,8 @@ static int idefloppy_release(struct inode *inode, struct file *filp) | |||
2016 | 2016 | ||
2017 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | 2017 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); |
2018 | } | 2018 | } |
2019 | drive->usage--; | 2019 | |
2020 | floppy->openers--; | ||
2020 | 2021 | ||
2021 | ide_floppy_put(floppy); | 2022 | ide_floppy_put(floppy); |
2022 | 2023 | ||
@@ -2050,7 +2051,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
2050 | prevent = 0; | 2051 | prevent = 0; |
2051 | /* fall through */ | 2052 | /* fall through */ |
2052 | case CDROM_LOCKDOOR: | 2053 | case CDROM_LOCKDOOR: |
2053 | if (drive->usage > 1) | 2054 | if (floppy->openers > 1) |
2054 | return -EBUSY; | 2055 | return -EBUSY; |
2055 | 2056 | ||
2056 | /* The IOMEGA Clik! Drive doesn't support this command - no room for an eject mechanism */ | 2057 | /* The IOMEGA Clik! Drive doesn't support this command - no room for an eject mechanism */ |
@@ -2072,7 +2073,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
2072 | if (!(file->f_mode & 2)) | 2073 | if (!(file->f_mode & 2)) |
2073 | return -EPERM; | 2074 | return -EPERM; |
2074 | 2075 | ||
2075 | if (drive->usage > 1) { | 2076 | if (floppy->openers > 1) { |
2076 | /* Don't format if someone is using the disk */ | 2077 | /* Don't format if someone is using the disk */ |
2077 | 2078 | ||
2078 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, | 2079 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, |