diff options
author | Borislav Petkov <bbpetkov@yahoo.de> | 2008-02-02 13:56:37 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-02 13:56:37 -0500 |
commit | 6e5fa7b88c376b9d33228888f2ccd71fc79b2a17 (patch) | |
tree | e9428cfedba6a3af7a5a38933582d2e245c56be3 /drivers | |
parent | 757ced8983a0b8d1bb353128605cec0f7a6f633e (diff) |
ide-floppy: remove atomic test_*bit macros
..and replace them with flag enums.
Bart:
- fix idefloppy_media_changed() return value
Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ide-floppy.c | 125 |
1 files changed, 69 insertions, 56 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 01701ca95204..ac66622a3570 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -104,15 +104,19 @@ typedef struct idefloppy_packet_command_s { | |||
104 | unsigned long flags; /* Status/Action bit flags: long for set_bit */ | 104 | unsigned long flags; /* Status/Action bit flags: long for set_bit */ |
105 | } idefloppy_pc_t; | 105 | } idefloppy_pc_t; |
106 | 106 | ||
107 | /* | 107 | /* Packet command flag bits. */ |
108 | * Packet command flag bits. | 108 | enum { |
109 | */ | 109 | /* 1 when we prefer to use DMA if possible */ |
110 | #define PC_DMA_RECOMMENDED 2 /* 1 when we prefer to use DMA if possible */ | 110 | PC_FLAG_DMA_RECOMMENDED = (1 << 0), |
111 | #define PC_DMA_IN_PROGRESS 3 /* 1 while DMA in progress */ | 111 | /* 1 while DMA in progress */ |
112 | #define PC_DMA_ERROR 4 /* 1 when encountered problem during DMA */ | 112 | PC_FLAG_DMA_IN_PROGRESS = (1 << 1), |
113 | #define PC_WRITING 5 /* Data direction */ | 113 | /* 1 when encountered problem during DMA */ |
114 | 114 | PC_FLAG_DMA_ERROR = (1 << 2), | |
115 | #define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */ | 115 | /* Data direction */ |
116 | PC_FLAG_WRITING = (1 << 3), | ||
117 | /* Suppress error reporting */ | ||
118 | PC_FLAG_SUPPRESS_ERROR = (1 << 4), | ||
119 | }; | ||
116 | 120 | ||
117 | /* format capacities descriptor codes */ | 121 | /* format capacities descriptor codes */ |
118 | #define CAPACITY_INVALID 0x00 | 122 | #define CAPACITY_INVALID 0x00 |
@@ -171,14 +175,19 @@ typedef struct ide_floppy_obj { | |||
171 | 175 | ||
172 | #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ | 176 | #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ |
173 | 177 | ||
174 | /* | 178 | /* Floppy flag bits values. */ |
175 | * Floppy flag bits values. | 179 | enum { |
176 | */ | 180 | /* DRQ interrupt device */ |
177 | #define IDEFLOPPY_DRQ_INTERRUPT 0 /* DRQ interrupt device */ | 181 | IDEFLOPPY_FLAG_DRQ_INTERRUPT = (1 << 0), |
178 | #define IDEFLOPPY_MEDIA_CHANGED 1 /* Media may have changed */ | 182 | /* Media may have changed */ |
179 | #define IDEFLOPPY_FORMAT_IN_PROGRESS 3 /* Format in progress */ | 183 | IDEFLOPPY_FLAG_MEDIA_CHANGED = (1 << 1), |
180 | #define IDEFLOPPY_CLIK_DRIVE 4 /* Avoid commands not supported in Clik drive */ | 184 | /* Format in progress */ |
181 | #define IDEFLOPPY_ZIP_DRIVE 5 /* Requires BH algorithm for packets */ | 185 | IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS = (1 << 2), |
186 | /* Avoid commands not supported in Clik drive */ | ||
187 | IDEFLOPPY_FLAG_CLIK_DRIVE = (1 << 3), | ||
188 | /* Requires BH algorithm for packets */ | ||
189 | IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), | ||
190 | }; | ||
182 | 191 | ||
183 | /* | 192 | /* |
184 | * Defines for the mode sense command | 193 | * Defines for the mode sense command |
@@ -503,12 +512,12 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
503 | 512 | ||
504 | debug_log("Reached %s interrupt handler\n", __func__); | 513 | debug_log("Reached %s interrupt handler\n", __func__); |
505 | 514 | ||
506 | if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { | 515 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
507 | dma_error = hwif->ide_dma_end(drive); | 516 | dma_error = hwif->ide_dma_end(drive); |
508 | if (dma_error) { | 517 | if (dma_error) { |
509 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, | 518 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, |
510 | rq_data_dir(rq) ? "write" : "read"); | 519 | rq_data_dir(rq) ? "write" : "read"); |
511 | set_bit(PC_DMA_ERROR, &pc->flags); | 520 | pc->flags |= PC_FLAG_DMA_ERROR; |
512 | } else { | 521 | } else { |
513 | pc->actually_transferred = pc->request_transfer; | 522 | pc->actually_transferred = pc->request_transfer; |
514 | idefloppy_update_buffers(drive, pc); | 523 | idefloppy_update_buffers(drive, pc); |
@@ -522,11 +531,11 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
522 | if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ | 531 | if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ |
523 | debug_log("Packet command completed, %d bytes transferred\n", | 532 | debug_log("Packet command completed, %d bytes transferred\n", |
524 | pc->actually_transferred); | 533 | pc->actually_transferred); |
525 | clear_bit(PC_DMA_IN_PROGRESS, &pc->flags); | 534 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; |
526 | 535 | ||
527 | local_irq_enable_in_hardirq(); | 536 | local_irq_enable_in_hardirq(); |
528 | 537 | ||
529 | if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { | 538 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { |
530 | /* Error detected */ | 539 | /* Error detected */ |
531 | debug_log("%s: I/O error\n", drive->name); | 540 | debug_log("%s: I/O error\n", drive->name); |
532 | rq->errors++; | 541 | rq->errors++; |
@@ -548,7 +557,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
548 | return ide_stopped; | 557 | return ide_stopped; |
549 | } | 558 | } |
550 | 559 | ||
551 | if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { | 560 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
561 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
552 | printk(KERN_ERR "ide-floppy: The floppy wants to issue " | 562 | printk(KERN_ERR "ide-floppy: The floppy wants to issue " |
553 | "more interrupts in DMA mode\n"); | 563 | "more interrupts in DMA mode\n"); |
554 | ide_dma_off(drive); | 564 | ide_dma_off(drive); |
@@ -565,7 +575,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
565 | printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); | 575 | printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); |
566 | return ide_do_reset(drive); | 576 | return ide_do_reset(drive); |
567 | } | 577 | } |
568 | if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { | 578 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { |
569 | /* Hopefully, we will never get here */ | 579 | /* Hopefully, we will never get here */ |
570 | printk(KERN_ERR "ide-floppy: We wanted to %s, ", | 580 | printk(KERN_ERR "ide-floppy: We wanted to %s, ", |
571 | (ireason & IO) ? "Write" : "Read"); | 581 | (ireason & IO) ? "Write" : "Read"); |
@@ -573,7 +583,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
573 | (ireason & IO) ? "Read" : "Write"); | 583 | (ireason & IO) ? "Read" : "Write"); |
574 | return ide_do_reset(drive); | 584 | return ide_do_reset(drive); |
575 | } | 585 | } |
576 | if (!test_bit(PC_WRITING, &pc->flags)) { | 586 | if (!(pc->flags & PC_FLAG_WRITING)) { |
577 | /* Reading - Check that we have enough space */ | 587 | /* Reading - Check that we have enough space */ |
578 | temp = pc->actually_transferred + bcount; | 588 | temp = pc->actually_transferred + bcount; |
579 | if (temp > pc->request_transfer) { | 589 | if (temp > pc->request_transfer) { |
@@ -593,7 +603,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
593 | " expected - allowing transfer\n"); | 603 | " expected - allowing transfer\n"); |
594 | } | 604 | } |
595 | } | 605 | } |
596 | if (test_bit(PC_WRITING, &pc->flags)) | 606 | if (pc->flags & PC_FLAG_WRITING) |
597 | xferfunc = hwif->atapi_output_bytes; | 607 | xferfunc = hwif->atapi_output_bytes; |
598 | else | 608 | else |
599 | xferfunc = hwif->atapi_input_bytes; | 609 | xferfunc = hwif->atapi_input_bytes; |
@@ -602,7 +612,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
602 | xferfunc(drive, pc->current_position, bcount); | 612 | xferfunc(drive, pc->current_position, bcount); |
603 | else | 613 | else |
604 | ide_floppy_io_buffers(drive, pc, bcount, | 614 | ide_floppy_io_buffers(drive, pc, bcount, |
605 | test_bit(PC_WRITING, &pc->flags)); | 615 | !!(pc->flags & PC_FLAG_WRITING)); |
606 | 616 | ||
607 | /* Update the current position */ | 617 | /* Update the current position */ |
608 | pc->actually_transferred += bcount; | 618 | pc->actually_transferred += bcount; |
@@ -733,7 +743,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p | |||
733 | floppy->pc = pc; | 743 | floppy->pc = pc; |
734 | 744 | ||
735 | if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { | 745 | if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { |
736 | if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) | 746 | if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR)) |
737 | ide_floppy_report_error(floppy, pc); | 747 | ide_floppy_report_error(floppy, pc); |
738 | /* Giving up */ | 748 | /* Giving up */ |
739 | pc->error = IDEFLOPPY_ERROR_GENERAL; | 749 | 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 | pc->current_position = pc->buffer; | 761 | pc->current_position = pc->buffer; |
752 | bcount = min(pc->request_transfer, 63 * 1024); | 762 | bcount = min(pc->request_transfer, 63 * 1024); |
753 | 763 | ||
754 | if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) | 764 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
765 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
755 | ide_dma_off(drive); | 766 | ide_dma_off(drive); |
756 | 767 | } | |
757 | dma = 0; | 768 | dma = 0; |
758 | 769 | ||
759 | if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) | 770 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) |
760 | dma = !hwif->dma_setup(drive); | 771 | dma = !hwif->dma_setup(drive); |
761 | 772 | ||
762 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | 773 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | |
763 | IDE_TFLAG_OUT_DEVICE, bcount, dma); | 774 | IDE_TFLAG_OUT_DEVICE, bcount, dma); |
764 | 775 | ||
765 | if (dma) { /* Begin DMA, if necessary */ | 776 | if (dma) { /* Begin DMA, if necessary */ |
766 | set_bit(PC_DMA_IN_PROGRESS, &pc->flags); | 777 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; |
767 | hwif->dma_start(drive); | 778 | hwif->dma_start(drive); |
768 | } | 779 | } |
769 | 780 | ||
770 | /* Can we transfer the packet when we get the interrupt or wait? */ | 781 | /* Can we transfer the packet when we get the interrupt or wait? */ |
771 | if (test_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags)) { | 782 | if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) { |
772 | /* wait */ | 783 | /* wait */ |
773 | pkt_xfer_routine = &idefloppy_transfer_pc1; | 784 | pkt_xfer_routine = &idefloppy_transfer_pc1; |
774 | } else { | 785 | } else { |
@@ -776,7 +787,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p | |||
776 | pkt_xfer_routine = &idefloppy_transfer_pc; | 787 | pkt_xfer_routine = &idefloppy_transfer_pc; |
777 | } | 788 | } |
778 | 789 | ||
779 | if (test_bit (IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags)) { | 790 | if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) { |
780 | /* Issue the packet command */ | 791 | /* Issue the packet command */ |
781 | ide_execute_command(drive, WIN_PACKETCMD, | 792 | ide_execute_command(drive, WIN_PACKETCMD, |
782 | pkt_xfer_routine, | 793 | pkt_xfer_routine, |
@@ -834,7 +845,7 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, | |||
834 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); | 845 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); |
835 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); | 846 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); |
836 | pc->buffer_size=12; | 847 | pc->buffer_size=12; |
837 | set_bit(PC_WRITING, &pc->flags); | 848 | pc->flags |= PC_FLAG_WRITING; |
838 | } | 849 | } |
839 | 850 | ||
840 | /* | 851 | /* |
@@ -897,10 +908,10 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | |||
897 | pc->rq = rq; | 908 | pc->rq = rq; |
898 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; | 909 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; |
899 | if (rq->cmd_flags & REQ_RW) | 910 | if (rq->cmd_flags & REQ_RW) |
900 | set_bit(PC_WRITING, &pc->flags); | 911 | pc->flags |= PC_FLAG_WRITING; |
901 | pc->buffer = NULL; | 912 | pc->buffer = NULL; |
902 | pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; | 913 | pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; |
903 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); | 914 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
904 | } | 915 | } |
905 | 916 | ||
906 | static void | 917 | static void |
@@ -912,11 +923,10 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req | |||
912 | pc->rq = rq; | 923 | pc->rq = rq; |
913 | pc->b_count = rq->data_len; | 924 | pc->b_count = rq->data_len; |
914 | if (rq->data_len && rq_data_dir(rq) == WRITE) | 925 | if (rq->data_len && rq_data_dir(rq) == WRITE) |
915 | set_bit(PC_WRITING, &pc->flags); | 926 | pc->flags |= PC_FLAG_WRITING; |
916 | pc->buffer = rq->data; | 927 | pc->buffer = rq->data; |
917 | if (rq->bio) | 928 | if (rq->bio) |
918 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); | 929 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
919 | |||
920 | /* | 930 | /* |
921 | * possibly problematic, doesn't look like ide-floppy correctly | 931 | * possibly problematic, doesn't look like ide-floppy correctly |
922 | * handled scattered requests if dma fails... | 932 | * handled scattered requests if dma fails... |
@@ -1057,7 +1067,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) | |||
1057 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, | 1067 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, |
1058 | MODE_SENSE_CURRENT); | 1068 | MODE_SENSE_CURRENT); |
1059 | 1069 | ||
1060 | set_bit(PC_SUPPRESS_ERROR, &pc.flags); | 1070 | pc.flags |= PC_FLAG_SUPPRESS_ERROR; |
1061 | if (idefloppy_queue_pc_tail(drive, &pc)) | 1071 | if (idefloppy_queue_pc_tail(drive, &pc)) |
1062 | return 1; | 1072 | return 1; |
1063 | 1073 | ||
@@ -1110,7 +1120,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
1110 | switch (pc.buffer[desc_start + 4] & 0x03) { | 1120 | switch (pc.buffer[desc_start + 4] & 0x03) { |
1111 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ | 1121 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ |
1112 | case CAPACITY_UNFORMATTED: | 1122 | case CAPACITY_UNFORMATTED: |
1113 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) | 1123 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) |
1114 | /* | 1124 | /* |
1115 | * If it is not a clik drive, break out | 1125 | * If it is not a clik drive, break out |
1116 | * (maintains previous driver behaviour) | 1126 | * (maintains previous driver behaviour) |
@@ -1156,7 +1166,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
1156 | } | 1166 | } |
1157 | 1167 | ||
1158 | /* Clik! disk does not support get_flexible_disk_page */ | 1168 | /* Clik! disk does not support get_flexible_disk_page */ |
1159 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) | 1169 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) |
1160 | (void) ide_floppy_get_flexible_disk_page(drive); | 1170 | (void) ide_floppy_get_flexible_disk_page(drive); |
1161 | 1171 | ||
1162 | set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); | 1172 | 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 | *((u16 *) &gcw) = drive->id->config; | 1366 | *((u16 *) &gcw) = drive->id->config; |
1357 | floppy->pc = floppy->pc_stack; | 1367 | floppy->pc = floppy->pc_stack; |
1358 | if (gcw.drq_type == 1) | 1368 | if (gcw.drq_type == 1) |
1359 | set_bit(IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags); | 1369 | floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; |
1360 | /* | 1370 | /* |
1361 | * We used to check revisions here. At this point however | 1371 | * We used to check revisions here. At this point however |
1362 | * I'm giving up. Just assume they are all broken, its easier. | 1372 | * 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 | */ | 1379 | */ |
1370 | 1380 | ||
1371 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { | 1381 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { |
1372 | set_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags); | 1382 | floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; |
1373 | /* This value will be visible in the /proc/ide/hdx/settings */ | 1383 | /* This value will be visible in the /proc/ide/hdx/settings */ |
1374 | floppy->ticks = IDEFLOPPY_TICKS_DELAY; | 1384 | floppy->ticks = IDEFLOPPY_TICKS_DELAY; |
1375 | blk_queue_max_sectors(drive->queue, 64); | 1385 | blk_queue_max_sectors(drive->queue, 64); |
@@ -1382,7 +1392,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) | |||
1382 | */ | 1392 | */ |
1383 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { | 1393 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { |
1384 | blk_queue_max_sectors(drive->queue, 64); | 1394 | blk_queue_max_sectors(drive->queue, 64); |
1385 | set_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags); | 1395 | floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; |
1386 | } | 1396 | } |
1387 | 1397 | ||
1388 | 1398 | ||
@@ -1472,7 +1482,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1472 | floppy->openers++; | 1482 | floppy->openers++; |
1473 | 1483 | ||
1474 | if (floppy->openers == 1) { | 1484 | if (floppy->openers == 1) { |
1475 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | 1485 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; |
1476 | /* Just in case */ | 1486 | /* Just in case */ |
1477 | 1487 | ||
1478 | idefloppy_create_test_unit_ready_cmd(&pc); | 1488 | idefloppy_create_test_unit_ready_cmd(&pc); |
@@ -1497,14 +1507,14 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1497 | ret = -EROFS; | 1507 | ret = -EROFS; |
1498 | goto out_put_floppy; | 1508 | goto out_put_floppy; |
1499 | } | 1509 | } |
1500 | set_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); | 1510 | floppy->flags |= IDEFLOPPY_FLAG_MEDIA_CHANGED; |
1501 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 1511 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
1502 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { | 1512 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { |
1503 | idefloppy_create_prevent_cmd(&pc, 1); | 1513 | idefloppy_create_prevent_cmd(&pc, 1); |
1504 | (void) idefloppy_queue_pc_tail(drive, &pc); | 1514 | (void) idefloppy_queue_pc_tail(drive, &pc); |
1505 | } | 1515 | } |
1506 | check_disk_change(inode->i_bdev); | 1516 | check_disk_change(inode->i_bdev); |
1507 | } else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) { | 1517 | } else if (floppy->flags & IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS) { |
1508 | ret = -EBUSY; | 1518 | ret = -EBUSY; |
1509 | goto out_put_floppy; | 1519 | goto out_put_floppy; |
1510 | } | 1520 | } |
@@ -1527,12 +1537,12 @@ static int idefloppy_release(struct inode *inode, struct file *filp) | |||
1527 | 1537 | ||
1528 | if (floppy->openers == 1) { | 1538 | if (floppy->openers == 1) { |
1529 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 1539 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
1530 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { | 1540 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { |
1531 | idefloppy_create_prevent_cmd(&pc, 0); | 1541 | idefloppy_create_prevent_cmd(&pc, 0); |
1532 | (void) idefloppy_queue_pc_tail(drive, &pc); | 1542 | (void) idefloppy_queue_pc_tail(drive, &pc); |
1533 | } | 1543 | } |
1534 | 1544 | ||
1535 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | 1545 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; |
1536 | } | 1546 | } |
1537 | 1547 | ||
1538 | floppy->openers--; | 1548 | floppy->openers--; |
@@ -1561,7 +1571,7 @@ static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, | |||
1561 | 1571 | ||
1562 | /* The IOMEGA Clik! Drive doesn't support this command - | 1572 | /* The IOMEGA Clik! Drive doesn't support this command - |
1563 | * no room for an eject mechanism */ | 1573 | * no room for an eject mechanism */ |
1564 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { | 1574 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { |
1565 | int prevent = arg ? 1 : 0; | 1575 | int prevent = arg ? 1 : 0; |
1566 | 1576 | ||
1567 | if (cmd == CDROMEJECT) | 1577 | if (cmd == CDROMEJECT) |
@@ -1587,11 +1597,11 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, | |||
1587 | 1597 | ||
1588 | if (floppy->openers > 1) { | 1598 | if (floppy->openers > 1) { |
1589 | /* Don't format if someone is using the disk */ | 1599 | /* Don't format if someone is using the disk */ |
1590 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | 1600 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; |
1591 | return -EBUSY; | 1601 | return -EBUSY; |
1592 | } | 1602 | } |
1593 | 1603 | ||
1594 | set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | 1604 | floppy->flags |= IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; |
1595 | 1605 | ||
1596 | /* | 1606 | /* |
1597 | * Send ATAPI_FORMAT_UNIT to the drive. | 1607 | * Send ATAPI_FORMAT_UNIT to the drive. |
@@ -1623,7 +1633,7 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, | |||
1623 | 1633 | ||
1624 | out: | 1634 | out: |
1625 | if (err) | 1635 | if (err) |
1626 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | 1636 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; |
1627 | return err; | 1637 | return err; |
1628 | } | 1638 | } |
1629 | 1639 | ||
@@ -1676,13 +1686,16 @@ static int idefloppy_media_changed(struct gendisk *disk) | |||
1676 | { | 1686 | { |
1677 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); | 1687 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); |
1678 | ide_drive_t *drive = floppy->drive; | 1688 | ide_drive_t *drive = floppy->drive; |
1689 | int ret; | ||
1679 | 1690 | ||
1680 | /* do not scan partitions twice if this is a removable device */ | 1691 | /* do not scan partitions twice if this is a removable device */ |
1681 | if (drive->attach) { | 1692 | if (drive->attach) { |
1682 | drive->attach = 0; | 1693 | drive->attach = 0; |
1683 | return 0; | 1694 | return 0; |
1684 | } | 1695 | } |
1685 | return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); | 1696 | ret = !!(floppy->flags & IDEFLOPPY_FLAG_MEDIA_CHANGED); |
1697 | floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; | ||
1698 | return ret; | ||
1686 | } | 1699 | } |
1687 | 1700 | ||
1688 | static int idefloppy_revalidate_disk(struct gendisk *disk) | 1701 | static int idefloppy_revalidate_disk(struct gendisk *disk) |