Commit 6e5fa7b8 authored by Borislav Petkov's avatar Borislav Petkov Committed by Bartlomiej Zolnierkiewicz

ide-floppy: remove atomic test_*bit macros

..and replace them with flag enums.

Bart:
- fix idefloppy_media_changed() return value
Signed-off-by: default avatarBorislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 757ced89
...@@ -104,15 +104,19 @@ typedef struct idefloppy_packet_command_s { ...@@ -104,15 +104,19 @@ typedef struct idefloppy_packet_command_s {
unsigned long flags; /* Status/Action bit flags: long for set_bit */ unsigned long flags; /* Status/Action bit flags: long for set_bit */
} idefloppy_pc_t; } idefloppy_pc_t;
/* /* Packet command flag bits. */
* Packet command flag bits. enum {
*/ /* 1 when we prefer to use DMA if possible */
#define PC_DMA_RECOMMENDED 2 /* 1 when we prefer to use DMA if possible */ PC_FLAG_DMA_RECOMMENDED = (1 << 0),
#define PC_DMA_IN_PROGRESS 3 /* 1 while DMA in progress */ /* 1 while DMA in progress */
#define PC_DMA_ERROR 4 /* 1 when encountered problem during DMA */ PC_FLAG_DMA_IN_PROGRESS = (1 << 1),
#define PC_WRITING 5 /* Data direction */ /* 1 when encountered problem during DMA */
PC_FLAG_DMA_ERROR = (1 << 2),
#define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */ /* Data direction */
PC_FLAG_WRITING = (1 << 3),
/* Suppress error reporting */
PC_FLAG_SUPPRESS_ERROR = (1 << 4),
};
/* format capacities descriptor codes */ /* format capacities descriptor codes */
#define CAPACITY_INVALID 0x00 #define CAPACITY_INVALID 0x00
...@@ -171,14 +175,19 @@ typedef struct ide_floppy_obj { ...@@ -171,14 +175,19 @@ typedef struct ide_floppy_obj {
#define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */
/* /* Floppy flag bits values. */
* Floppy flag bits values. enum {
*/ /* DRQ interrupt device */
#define IDEFLOPPY_DRQ_INTERRUPT 0 /* DRQ interrupt device */ IDEFLOPPY_FLAG_DRQ_INTERRUPT = (1 << 0),
#define IDEFLOPPY_MEDIA_CHANGED 1 /* Media may have changed */ /* Media may have changed */
#define IDEFLOPPY_FORMAT_IN_PROGRESS 3 /* Format in progress */ IDEFLOPPY_FLAG_MEDIA_CHANGED = (1 << 1),
#define IDEFLOPPY_CLIK_DRIVE 4 /* Avoid commands not supported in Clik drive */ /* Format in progress */
#define IDEFLOPPY_ZIP_DRIVE 5 /* Requires BH algorithm for packets */ IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS = (1 << 2),
/* Avoid commands not supported in Clik drive */
IDEFLOPPY_FLAG_CLIK_DRIVE = (1 << 3),
/* Requires BH algorithm for packets */
IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4),
};
/* /*
* Defines for the mode sense command * Defines for the mode sense command
...@@ -503,12 +512,12 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) ...@@ -503,12 +512,12 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
debug_log("Reached %s interrupt handler\n", __func__); debug_log("Reached %s interrupt handler\n", __func__);
if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
dma_error = hwif->ide_dma_end(drive); dma_error = hwif->ide_dma_end(drive);
if (dma_error) { if (dma_error) {
printk(KERN_ERR "%s: DMA %s error\n", drive->name, printk(KERN_ERR "%s: DMA %s error\n", drive->name,
rq_data_dir(rq) ? "write" : "read"); rq_data_dir(rq) ? "write" : "read");
set_bit(PC_DMA_ERROR, &pc->flags); pc->flags |= PC_FLAG_DMA_ERROR;
} else { } else {
pc->actually_transferred = pc->request_transfer; pc->actually_transferred = pc->request_transfer;
idefloppy_update_buffers(drive, pc); idefloppy_update_buffers(drive, pc);
...@@ -522,11 +531,11 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) ...@@ -522,11 +531,11 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ if ((stat & DRQ_STAT) == 0) { /* No more interrupts */
debug_log("Packet command completed, %d bytes transferred\n", debug_log("Packet command completed, %d bytes transferred\n",
pc->actually_transferred); pc->actually_transferred);
clear_bit(PC_DMA_IN_PROGRESS, &pc->flags); pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
local_irq_enable_in_hardirq(); local_irq_enable_in_hardirq();
if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
/* Error detected */ /* Error detected */
debug_log("%s: I/O error\n", drive->name); debug_log("%s: I/O error\n", drive->name);
rq->errors++; rq->errors++;
...@@ -548,7 +557,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) ...@@ -548,7 +557,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
return ide_stopped; return ide_stopped;
} }
if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
printk(KERN_ERR "ide-floppy: The floppy wants to issue " printk(KERN_ERR "ide-floppy: The floppy wants to issue "
"more interrupts in DMA mode\n"); "more interrupts in DMA mode\n");
ide_dma_off(drive); ide_dma_off(drive);
...@@ -565,7 +575,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) ...@@ -565,7 +575,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__);
return ide_do_reset(drive); return ide_do_reset(drive);
} }
if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
/* Hopefully, we will never get here */ /* Hopefully, we will never get here */
printk(KERN_ERR "ide-floppy: We wanted to %s, ", printk(KERN_ERR "ide-floppy: We wanted to %s, ",
(ireason & IO) ? "Write" : "Read"); (ireason & IO) ? "Write" : "Read");
...@@ -573,7 +583,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) ...@@ -573,7 +583,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
(ireason & IO) ? "Read" : "Write"); (ireason & IO) ? "Read" : "Write");
return ide_do_reset(drive); return ide_do_reset(drive);
} }
if (!test_bit(PC_WRITING, &pc->flags)) { if (!(pc->flags & PC_FLAG_WRITING)) {
/* Reading - Check that we have enough space */ /* Reading - Check that we have enough space */
temp = pc->actually_transferred + bcount; temp = pc->actually_transferred + bcount;
if (temp > pc->request_transfer) { if (temp > pc->request_transfer) {
...@@ -593,7 +603,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) ...@@ -593,7 +603,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
" expected - allowing transfer\n"); " expected - allowing transfer\n");
} }
} }
if (test_bit(PC_WRITING, &pc->flags)) if (pc->flags & PC_FLAG_WRITING)
xferfunc = hwif->atapi_output_bytes; xferfunc = hwif->atapi_output_bytes;
else else
xferfunc = hwif->atapi_input_bytes; xferfunc = hwif->atapi_input_bytes;
...@@ -602,7 +612,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) ...@@ -602,7 +612,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
xferfunc(drive, pc->current_position, bcount); xferfunc(drive, pc->current_position, bcount);
else else
ide_floppy_io_buffers(drive, pc, bcount, ide_floppy_io_buffers(drive, pc, bcount,
test_bit(PC_WRITING, &pc->flags)); !!(pc->flags & PC_FLAG_WRITING));
/* Update the current position */ /* Update the current position */
pc->actually_transferred += bcount; pc->actually_transferred += bcount;
...@@ -733,7 +743,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p ...@@ -733,7 +743,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
floppy->pc = pc; floppy->pc = pc;
if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) {
if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR))
ide_floppy_report_error(floppy, pc); ide_floppy_report_error(floppy, pc);
/* Giving up */ /* Giving up */
pc->error = IDEFLOPPY_ERROR_GENERAL; pc->error = IDEFLOPPY_ERROR_GENERAL;
...@@ -751,24 +761,25 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p ...@@ -751,24 +761,25 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
pc->current_position = pc->buffer; pc->current_position = pc->buffer;
bcount = min(pc->request_transfer, 63 * 1024); bcount = min(pc->request_transfer, 63 * 1024);
if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) if (pc->flags & PC_FLAG_DMA_ERROR) {
pc->flags &= ~PC_FLAG_DMA_ERROR;
ide_dma_off(drive); ide_dma_off(drive);
}
dma = 0; dma = 0;
if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma)
dma = !hwif->dma_setup(drive); dma = !hwif->dma_setup(drive);
ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK |
IDE_TFLAG_OUT_DEVICE, bcount, dma); IDE_TFLAG_OUT_DEVICE, bcount, dma);
if (dma) { /* Begin DMA, if necessary */ if (dma) { /* Begin DMA, if necessary */
set_bit(PC_DMA_IN_PROGRESS, &pc->flags); pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
hwif->dma_start(drive); hwif->dma_start(drive);
} }
/* Can we transfer the packet when we get the interrupt or wait? */ /* Can we transfer the packet when we get the interrupt or wait? */
if (test_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags)) { if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) {
/* wait */ /* wait */
pkt_xfer_routine = &idefloppy_transfer_pc1; pkt_xfer_routine = &idefloppy_transfer_pc1;
} else { } else {
...@@ -776,7 +787,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p ...@@ -776,7 +787,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
pkt_xfer_routine = &idefloppy_transfer_pc; pkt_xfer_routine = &idefloppy_transfer_pc;
} }
if (test_bit (IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags)) { if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) {
/* Issue the packet command */ /* Issue the packet command */
ide_execute_command(drive, WIN_PACKETCMD, ide_execute_command(drive, WIN_PACKETCMD,
pkt_xfer_routine, pkt_xfer_routine,
...@@ -834,7 +845,7 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, ...@@ -834,7 +845,7 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l,
put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4]));
put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8]));
pc->buffer_size=12; pc->buffer_size=12;
set_bit(PC_WRITING, &pc->flags); pc->flags |= PC_FLAG_WRITING;
} }
/* /*
...@@ -897,10 +908,10 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, ...@@ -897,10 +908,10 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
pc->rq = rq; pc->rq = rq;
pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
if (rq->cmd_flags & REQ_RW) if (rq->cmd_flags & REQ_RW)
set_bit(PC_WRITING, &pc->flags); pc->flags |= PC_FLAG_WRITING;
pc->buffer = NULL; pc->buffer = NULL;
pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; pc->request_transfer = pc->buffer_size = blocks * floppy->block_size;
set_bit(PC_DMA_RECOMMENDED, &pc->flags); pc->flags |= PC_FLAG_DMA_RECOMMENDED;
} }
static void static void
...@@ -912,11 +923,10 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req ...@@ -912,11 +923,10 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req
pc->rq = rq; pc->rq = rq;
pc->b_count = rq->data_len; pc->b_count = rq->data_len;
if (rq->data_len && rq_data_dir(rq) == WRITE) if (rq->data_len && rq_data_dir(rq) == WRITE)
set_bit(PC_WRITING, &pc->flags); pc->flags |= PC_FLAG_WRITING;
pc->buffer = rq->data; pc->buffer = rq->data;
if (rq->bio) if (rq->bio)
set_bit(PC_DMA_RECOMMENDED, &pc->flags); pc->flags |= PC_FLAG_DMA_RECOMMENDED;
/* /*
* possibly problematic, doesn't look like ide-floppy correctly * possibly problematic, doesn't look like ide-floppy correctly
* handled scattered requests if dma fails... * handled scattered requests if dma fails...
...@@ -1057,7 +1067,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) ...@@ -1057,7 +1067,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive)
idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE,
MODE_SENSE_CURRENT); MODE_SENSE_CURRENT);
set_bit(PC_SUPPRESS_ERROR, &pc.flags); pc.flags |= PC_FLAG_SUPPRESS_ERROR;
if (idefloppy_queue_pc_tail(drive, &pc)) if (idefloppy_queue_pc_tail(drive, &pc))
return 1; return 1;
...@@ -1110,7 +1120,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) ...@@ -1110,7 +1120,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
switch (pc.buffer[desc_start + 4] & 0x03) { switch (pc.buffer[desc_start + 4] & 0x03) {
/* Clik! drive returns this instead of CAPACITY_CURRENT */ /* Clik! drive returns this instead of CAPACITY_CURRENT */
case CAPACITY_UNFORMATTED: case CAPACITY_UNFORMATTED:
if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE))
/* /*
* If it is not a clik drive, break out * If it is not a clik drive, break out
* (maintains previous driver behaviour) * (maintains previous driver behaviour)
...@@ -1156,7 +1166,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) ...@@ -1156,7 +1166,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
} }
/* Clik! disk does not support get_flexible_disk_page */ /* Clik! disk does not support get_flexible_disk_page */
if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE))
(void) ide_floppy_get_flexible_disk_page(drive); (void) ide_floppy_get_flexible_disk_page(drive);
set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor);
...@@ -1356,7 +1366,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) ...@@ -1356,7 +1366,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
*((u16 *) &gcw) = drive->id->config; *((u16 *) &gcw) = drive->id->config;
floppy->pc = floppy->pc_stack; floppy->pc = floppy->pc_stack;
if (gcw.drq_type == 1) if (gcw.drq_type == 1)
set_bit(IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags); floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT;
/* /*
* We used to check revisions here. At this point however * We used to check revisions here. At this point however
* I'm giving up. Just assume they are all broken, its easier. * I'm giving up. Just assume they are all broken, its easier.
...@@ -1369,7 +1379,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) ...@@ -1369,7 +1379,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
*/ */
if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) {
set_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags); floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE;
/* This value will be visible in the /proc/ide/hdx/settings */ /* This value will be visible in the /proc/ide/hdx/settings */
floppy->ticks = IDEFLOPPY_TICKS_DELAY; floppy->ticks = IDEFLOPPY_TICKS_DELAY;
blk_queue_max_sectors(drive->queue, 64); blk_queue_max_sectors(drive->queue, 64);
...@@ -1382,7 +1392,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) ...@@ -1382,7 +1392,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
*/ */
if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) {
blk_queue_max_sectors(drive->queue, 64); blk_queue_max_sectors(drive->queue, 64);
set_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags); floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE;
} }
...@@ -1472,7 +1482,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) ...@@ -1472,7 +1482,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
floppy->openers++; floppy->openers++;
if (floppy->openers == 1) { if (floppy->openers == 1) {
clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
/* Just in case */ /* Just in case */
idefloppy_create_test_unit_ready_cmd(&pc); idefloppy_create_test_unit_ready_cmd(&pc);
...@@ -1497,14 +1507,14 @@ static int idefloppy_open(struct inode *inode, struct file *filp) ...@@ -1497,14 +1507,14 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
ret = -EROFS; ret = -EROFS;
goto out_put_floppy; goto out_put_floppy;
} }
set_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); floppy->flags |= IDEFLOPPY_FLAG_MEDIA_CHANGED;
/* IOMEGA Clik! drives do not support lock/unlock commands */ /* IOMEGA Clik! drives do not support lock/unlock commands */
if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) {
idefloppy_create_prevent_cmd(&pc, 1); idefloppy_create_prevent_cmd(&pc, 1);
(void) idefloppy_queue_pc_tail(drive, &pc); (void) idefloppy_queue_pc_tail(drive, &pc);
} }
check_disk_change(inode->i_bdev); check_disk_change(inode->i_bdev);
} else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) { } else if (floppy->flags & IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS) {
ret = -EBUSY; ret = -EBUSY;
goto out_put_floppy; goto out_put_floppy;
} }
...@@ -1527,12 +1537,12 @@ static int idefloppy_release(struct inode *inode, struct file *filp) ...@@ -1527,12 +1537,12 @@ static int idefloppy_release(struct inode *inode, struct file *filp)
if (floppy->openers == 1) { if (floppy->openers == 1) {
/* IOMEGA Clik! drives do not support lock/unlock commands */ /* IOMEGA Clik! drives do not support lock/unlock commands */
if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) {
idefloppy_create_prevent_cmd(&pc, 0); idefloppy_create_prevent_cmd(&pc, 0);
(void) idefloppy_queue_pc_tail(drive, &pc); (void) idefloppy_queue_pc_tail(drive, &pc);
} }
clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
} }
floppy->openers--; floppy->openers--;
...@@ -1561,7 +1571,7 @@ static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, ...@@ -1561,7 +1571,7 @@ static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc,
/* The IOMEGA Clik! Drive doesn't support this command - /* The IOMEGA Clik! Drive doesn't support this command -
* no room for an eject mechanism */ * no room for an eject mechanism */
if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) {
int prevent = arg ? 1 : 0; int prevent = arg ? 1 : 0;
if (cmd == CDROMEJECT) if (cmd == CDROMEJECT)
...@@ -1587,11 +1597,11 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, ...@@ -1587,11 +1597,11 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy,
if (floppy->openers > 1) { if (floppy->openers > 1) {
/* Don't format if someone is using the disk */ /* Don't format if someone is using the disk */
clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
return -EBUSY; return -EBUSY;
} }
set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); floppy->flags |= IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
/* /*
* Send ATAPI_FORMAT_UNIT to the drive. * Send ATAPI_FORMAT_UNIT to the drive.
...@@ -1623,7 +1633,7 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, ...@@ -1623,7 +1633,7 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy,
out: out:
if (err) if (err)
clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
return err; return err;
} }
...@@ -1676,13 +1686,16 @@ static int idefloppy_media_changed(struct gendisk *disk) ...@@ -1676,13 +1686,16 @@ static int idefloppy_media_changed(struct gendisk *disk)
{ {
struct ide_floppy_obj *floppy = ide_floppy_g(disk); struct ide_floppy_obj *floppy = ide_floppy_g(disk);
ide_drive_t *drive = floppy->drive; ide_drive_t *drive = floppy->drive;
int ret;
/* do not scan partitions twice if this is a removable device */ /* do not scan partitions twice if this is a removable device */
if (drive->attach) { if (drive->attach) {
drive->attach = 0; drive->attach = 0;
return 0; return 0;
} }
return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); ret = !!(floppy->flags & IDEFLOPPY_FLAG_MEDIA_CHANGED);
floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED;
return ret;
} }
static int idefloppy_revalidate_disk(struct gendisk *disk) static int idefloppy_revalidate_disk(struct gendisk *disk)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment