aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-floppy.c90
1 files changed, 36 insertions, 54 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index e9d11faec9bd..5d84fa5f3dc6 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -120,33 +120,6 @@ typedef struct idefloppy_packet_command_s {
120#define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */ 120#define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */
121 121
122/* 122/*
123 * Flexible disk page.
124 */
125typedef struct {
126#if defined(__LITTLE_ENDIAN_BITFIELD)
127 unsigned page_code :6; /* Page code - Should be 0x5 */
128 unsigned reserved1_6 :1; /* Reserved */
129 unsigned ps :1; /* The device is capable of saving the page */
130#elif defined(__BIG_ENDIAN_BITFIELD)
131 unsigned ps :1; /* The device is capable of saving the page */
132 unsigned reserved1_6 :1; /* Reserved */
133 unsigned page_code :6; /* Page code - Should be 0x5 */
134#else
135#error "Bitfield endianness not defined! Check your byteorder.h"
136#endif
137 u8 page_length; /* Page Length - Should be 0x1e */
138 u16 transfer_rate; /* In kilobits per second */
139 u8 heads, sectors; /* Number of heads, Number of sectors per track */
140 u16 sector_size; /* Byes per sector */
141 u16 cyls; /* Number of cylinders */
142 u8 reserved10[10];
143 u8 motor_delay; /* Motor off delay */
144 u8 reserved21[7];
145 u16 rpm; /* Rotations per minute */
146 u8 reserved30[2];
147} idefloppy_flexible_disk_page_t;
148
149/*
150 * Format capacity 123 * Format capacity
151 */ 124 */
152typedef struct { 125typedef struct {
@@ -214,7 +187,7 @@ typedef struct ide_floppy_obj {
214 /* Last format capacity */ 187 /* Last format capacity */
215 idefloppy_capacity_descriptor_t capacity; 188 idefloppy_capacity_descriptor_t capacity;
216 /* Copy of the flexible disk page */ 189 /* Copy of the flexible disk page */
217 idefloppy_flexible_disk_page_t flexible_disk_page; 190 u8 flexible_disk_page[32];
218 /* Write protect */ 191 /* Write protect */
219 int wp; 192 int wp;
220 /* Supports format progress report */ 193 /* Supports format progress report */
@@ -1095,48 +1068,57 @@ static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc)
1095} 1068}
1096 1069
1097/* 1070/*
1098 * Look at the flexible disk page parameters. We will ignore the CHS 1071 * Look at the flexible disk page parameters. We ignore the CHS capacity
1099 * capacity parameters and use the LBA parameters instead. 1072 * parameters and use the LBA parameters instead.
1100 */ 1073 */
1101static int idefloppy_get_flexible_disk_page (ide_drive_t *drive) 1074static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
1102{ 1075{
1103 idefloppy_floppy_t *floppy = drive->driver_data; 1076 idefloppy_floppy_t *floppy = drive->driver_data;
1104 idefloppy_pc_t pc; 1077 idefloppy_pc_t pc;
1105 idefloppy_flexible_disk_page_t *page; 1078 u8 *page;
1106 int capacity, lba_capacity; 1079 int capacity, lba_capacity;
1080 u16 transfer_rate, sector_size, cyls, rpm;
1081 u8 heads, sectors;
1107 1082
1108 idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE, MODE_SENSE_CURRENT); 1083 idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE,
1109 if (idefloppy_queue_pc_tail(drive,&pc)) { 1084 MODE_SENSE_CURRENT);
1110 printk(KERN_ERR "ide-floppy: Can't get flexible disk " 1085
1111 "page parameters\n"); 1086 if (idefloppy_queue_pc_tail(drive, &pc)) {
1087 printk(KERN_ERR "ide-floppy: Can't get flexible disk page"
1088 " parameters\n");
1112 return 1; 1089 return 1;
1113 } 1090 }
1114 floppy->wp = !!(pc.buffer[3] & 0x80); 1091 floppy->wp = !!(pc.buffer[3] & 0x80);
1115 set_disk_ro(floppy->disk, floppy->wp); 1092 set_disk_ro(floppy->disk, floppy->wp);
1116 page = (idefloppy_flexible_disk_page_t *) &pc.buffer[8]; 1093 page = &pc.buffer[8];
1117 1094
1118 page->transfer_rate = be16_to_cpu(page->transfer_rate); 1095 transfer_rate = be16_to_cpu(*(u16 *)&pc.buffer[8 + 2]);
1119 page->sector_size = be16_to_cpu(page->sector_size); 1096 sector_size = be16_to_cpu(*(u16 *)&pc.buffer[8 + 6]);
1120 page->cyls = be16_to_cpu(page->cyls); 1097 cyls = be16_to_cpu(*(u16 *)&pc.buffer[8 + 8]);
1121 page->rpm = be16_to_cpu(page->rpm); 1098 rpm = be16_to_cpu(*(u16 *)&pc.buffer[8 + 28]);
1122 capacity = page->cyls * page->heads * page->sectors * page->sector_size; 1099 heads = pc.buffer[8 + 4];
1123 if (memcmp (page, &floppy->flexible_disk_page, sizeof (idefloppy_flexible_disk_page_t))) 1100 sectors = pc.buffer[8 + 5];
1101
1102 capacity = cyls * heads * sectors * sector_size;
1103
1104 if (memcmp(page, &floppy->flexible_disk_page, 32))
1124 printk(KERN_INFO "%s: %dkB, %d/%d/%d CHS, %d kBps, " 1105 printk(KERN_INFO "%s: %dkB, %d/%d/%d CHS, %d kBps, "
1125 "%d sector size, %d rpm\n", 1106 "%d sector size, %d rpm\n",
1126 drive->name, capacity / 1024, page->cyls, 1107 drive->name, capacity / 1024, cyls, heads,
1127 page->heads, page->sectors, 1108 sectors, transfer_rate / 8, sector_size, rpm);
1128 page->transfer_rate / 8, page->sector_size, page->rpm); 1109
1129 1110 memcpy(&floppy->flexible_disk_page, page, 32);
1130 floppy->flexible_disk_page = *page; 1111 drive->bios_cyl = cyls;
1131 drive->bios_cyl = page->cyls; 1112 drive->bios_head = heads;
1132 drive->bios_head = page->heads; 1113 drive->bios_sect = sectors;
1133 drive->bios_sect = page->sectors;
1134 lba_capacity = floppy->blocks * floppy->block_size; 1114 lba_capacity = floppy->blocks * floppy->block_size;
1115
1135 if (capacity < lba_capacity) { 1116 if (capacity < lba_capacity) {
1136 printk(KERN_NOTICE "%s: The disk reports a capacity of %d " 1117 printk(KERN_NOTICE "%s: The disk reports a capacity of %d "
1137 "bytes, but the drive only handles %d\n", 1118 "bytes, but the drive only handles %d\n",
1138 drive->name, lba_capacity, capacity); 1119 drive->name, lba_capacity, capacity);
1139 floppy->blocks = floppy->block_size ? capacity / floppy->block_size : 0; 1120 floppy->blocks = floppy->block_size ?
1121 capacity / floppy->block_size : 0;
1140 } 1122 }
1141 return 0; 1123 return 0;
1142} 1124}
@@ -1243,7 +1225,7 @@ static int idefloppy_get_capacity (ide_drive_t *drive)
1243 1225
1244 /* Clik! disk does not support get_flexible_disk_page */ 1226 /* Clik! disk does not support get_flexible_disk_page */
1245 if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { 1227 if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
1246 (void) idefloppy_get_flexible_disk_page(drive); 1228 (void) ide_floppy_get_flexible_disk_page(drive);
1247 } 1229 }
1248 1230
1249 set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); 1231 set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor);