aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-floppy.c24
-rw-r--r--include/linux/ide.h18
2 files changed, 25 insertions, 17 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index de611c57b280..78d92835a3c1 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -110,10 +110,6 @@ typedef struct ide_floppy_obj {
110 u8 cap_desc[8]; 110 u8 cap_desc[8];
111 /* Copy of the flexible disk page */ 111 /* Copy of the flexible disk page */
112 u8 flexible_disk_page[32]; 112 u8 flexible_disk_page[32];
113 /* Write protect */
114 int wp;
115 /* Supports format progress report */
116 int srfp;
117} idefloppy_floppy_t; 113} idefloppy_floppy_t;
118 114
119#define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ 115#define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */
@@ -574,8 +570,14 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
574 " parameters\n"); 570 " parameters\n");
575 return 1; 571 return 1;
576 } 572 }
577 floppy->wp = !!(pc.buf[3] & 0x80); 573
578 set_disk_ro(disk, floppy->wp); 574 if (pc.buf[3] & 0x80)
575 drive->atapi_flags |= IDE_AFLAG_WP;
576 else
577 drive->atapi_flags &= ~IDE_AFLAG_WP;
578
579 set_disk_ro(disk, !!(drive->atapi_flags & IDE_AFLAG_WP));
580
579 page = &pc.buf[8]; 581 page = &pc.buf[8];
580 582
581 transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]); 583 transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]);
@@ -614,7 +616,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive)
614 idefloppy_floppy_t *floppy = drive->driver_data; 616 idefloppy_floppy_t *floppy = drive->driver_data;
615 struct ide_atapi_pc pc; 617 struct ide_atapi_pc pc;
616 618
617 floppy->srfp = 0; 619 drive->atapi_flags &= ~IDE_AFLAG_SRFP;
618 620
619 idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE); 621 idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE);
620 pc.flags |= PC_FLAG_SUPPRESS_ERROR; 622 pc.flags |= PC_FLAG_SUPPRESS_ERROR;
@@ -622,7 +624,9 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive)
622 if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 624 if (ide_queue_pc_tail(drive, floppy->disk, &pc))
623 return 1; 625 return 1;
624 626
625 floppy->srfp = pc.buf[8 + 2] & 0x40; 627 if (pc.buf[8 + 2] & 0x40)
628 drive->atapi_flags |= IDE_AFLAG_SRFP;
629
626 return 0; 630 return 0;
627} 631}
628 632
@@ -820,7 +824,7 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
820 struct ide_atapi_pc pc; 824 struct ide_atapi_pc pc;
821 int progress_indication = 0x10000; 825 int progress_indication = 0x10000;
822 826
823 if (floppy->srfp) { 827 if (drive->atapi_flags & IDE_AFLAG_SRFP) {
824 idefloppy_create_request_sense_cmd(&pc); 828 idefloppy_create_request_sense_cmd(&pc);
825 if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 829 if (ide_queue_pc_tail(drive, floppy->disk, &pc))
826 return -EIO; 830 return -EIO;
@@ -1044,7 +1048,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
1044 goto out_put_floppy; 1048 goto out_put_floppy;
1045 } 1049 }
1046 1050
1047 if (floppy->wp && (filp->f_mode & 2)) { 1051 if ((drive->atapi_flags & IDE_AFLAG_WP) && (filp->f_mode & 2)) {
1048 ret = -EROFS; 1052 ret = -EROFS;
1049 goto out_put_floppy; 1053 goto out_put_floppy;
1050 } 1054 }
diff --git a/include/linux/ide.h b/include/linux/ide.h
index b5be2368c96e..cc41a885688a 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -356,21 +356,25 @@ enum {
356 IDE_AFLAG_CLIK_DRIVE = (1 << 19), 356 IDE_AFLAG_CLIK_DRIVE = (1 << 19),
357 /* Requires BH algorithm for packets */ 357 /* Requires BH algorithm for packets */
358 IDE_AFLAG_ZIP_DRIVE = (1 << 20), 358 IDE_AFLAG_ZIP_DRIVE = (1 << 20),
359 /* Write protect */
360 IDE_AFLAG_WP = (1 << 21),
361 /* Supports format progress report */
362 IDE_AFLAG_SRFP = (1 << 22),
359 363
360 /* ide-tape */ 364 /* ide-tape */
361 IDE_AFLAG_IGNORE_DSC = (1 << 21), 365 IDE_AFLAG_IGNORE_DSC = (1 << 23),
362 /* 0 When the tape position is unknown */ 366 /* 0 When the tape position is unknown */
363 IDE_AFLAG_ADDRESS_VALID = (1 << 22), 367 IDE_AFLAG_ADDRESS_VALID = (1 << 24),
364 /* Device already opened */ 368 /* Device already opened */
365 IDE_AFLAG_BUSY = (1 << 23), 369 IDE_AFLAG_BUSY = (1 << 25),
366 /* Attempt to auto-detect the current user block size */ 370 /* Attempt to auto-detect the current user block size */
367 IDE_AFLAG_DETECT_BS = (1 << 24), 371 IDE_AFLAG_DETECT_BS = (1 << 26),
368 /* Currently on a filemark */ 372 /* Currently on a filemark */
369 IDE_AFLAG_FILEMARK = (1 << 25), 373 IDE_AFLAG_FILEMARK = (1 << 27),
370 /* 0 = no tape is loaded, so we don't rewind after ejecting */ 374 /* 0 = no tape is loaded, so we don't rewind after ejecting */
371 IDE_AFLAG_MEDIUM_PRESENT = (1 << 26), 375 IDE_AFLAG_MEDIUM_PRESENT = (1 << 28),
372 376
373 IDE_AFLAG_NO_AUTOCLOSE = (1 << 27), 377 IDE_AFLAG_NO_AUTOCLOSE = (1 << 29),
374}; 378};
375 379
376struct ide_drive_s { 380struct ide_drive_s {