aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-floppy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r--drivers/ide/ide-floppy.c56
1 files changed, 24 insertions, 32 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 650981758f15..8b3f204f7d73 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -77,7 +77,8 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc)
77 (rq && blk_pc_request(rq))) 77 (rq && blk_pc_request(rq)))
78 uptodate = 1; /* FIXME */ 78 uptodate = 1; /* FIXME */
79 else if (pc->c[0] == GPCMD_REQUEST_SENSE) { 79 else if (pc->c[0] == GPCMD_REQUEST_SENSE) {
80 u8 *buf = pc->buf; 80
81 u8 *buf = bio_data(rq->bio);
81 82
82 if (!pc->error) { 83 if (!pc->error) {
83 floppy->sense_key = buf[2] & 0x0F; 84 floppy->sense_key = buf[2] & 0x0F;
@@ -209,8 +210,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
209 pc->rq = rq; 210 pc->rq = rq;
210 if (rq->cmd_flags & REQ_RW) 211 if (rq->cmd_flags & REQ_RW)
211 pc->flags |= PC_FLAG_WRITING; 212 pc->flags |= PC_FLAG_WRITING;
212 pc->buf = NULL; 213
213 pc->req_xfer = pc->buf_size = blocks * floppy->block_size;
214 pc->flags |= PC_FLAG_DMA_OK; 214 pc->flags |= PC_FLAG_DMA_OK;
215} 215}
216 216
@@ -225,9 +225,6 @@ static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy,
225 if (rq_data_dir(rq) == WRITE) 225 if (rq_data_dir(rq) == WRITE)
226 pc->flags |= PC_FLAG_WRITING; 226 pc->flags |= PC_FLAG_WRITING;
227 } 227 }
228 /* pio will be performed by ide_pio_bytes() which handles sg fine */
229 pc->buf = NULL;
230 pc->req_xfer = pc->buf_size = blk_rq_bytes(rq);
231} 228}
232 229
233static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, 230static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
@@ -272,10 +269,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
272 } else if (blk_pc_request(rq)) { 269 } else if (blk_pc_request(rq)) {
273 pc = &floppy->queued_pc; 270 pc = &floppy->queued_pc;
274 idefloppy_blockpc_cmd(floppy, pc, rq); 271 idefloppy_blockpc_cmd(floppy, pc, rq);
275 } else { 272 } else
276 blk_dump_rq_flags(rq, PFX "unsupported command in queue"); 273 BUG();
277 goto out_end;
278 }
279 274
280 ide_prep_sense(drive, rq); 275 ide_prep_sense(drive, rq);
281 276
@@ -286,8 +281,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
286 281
287 cmd.rq = rq; 282 cmd.rq = rq;
288 283
289 if (blk_fs_request(rq) || pc->req_xfer) { 284 if (blk_fs_request(rq) || blk_rq_bytes(rq)) {
290 ide_init_sg_cmd(&cmd, pc->req_xfer); 285 ide_init_sg_cmd(&cmd, blk_rq_bytes(rq));
291 ide_map_sg(drive, &cmd); 286 ide_map_sg(drive, &cmd);
292 } 287 }
293 288
@@ -311,33 +306,33 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive,
311{ 306{
312 struct ide_disk_obj *floppy = drive->driver_data; 307 struct ide_disk_obj *floppy = drive->driver_data;
313 struct gendisk *disk = floppy->disk; 308 struct gendisk *disk = floppy->disk;
314 u8 *page; 309 u8 *page, buf[40];
315 int capacity, lba_capacity; 310 int capacity, lba_capacity;
316 u16 transfer_rate, sector_size, cyls, rpm; 311 u16 transfer_rate, sector_size, cyls, rpm;
317 u8 heads, sectors; 312 u8 heads, sectors;
318 313
319 ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); 314 ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE);
320 315
321 if (ide_queue_pc_tail(drive, disk, pc)) { 316 if (ide_queue_pc_tail(drive, disk, pc, buf, pc->req_xfer)) {
322 printk(KERN_ERR PFX "Can't get flexible disk page params\n"); 317 printk(KERN_ERR PFX "Can't get flexible disk page params\n");
323 return 1; 318 return 1;
324 } 319 }
325 320
326 if (pc->buf[3] & 0x80) 321 if (buf[3] & 0x80)
327 drive->dev_flags |= IDE_DFLAG_WP; 322 drive->dev_flags |= IDE_DFLAG_WP;
328 else 323 else
329 drive->dev_flags &= ~IDE_DFLAG_WP; 324 drive->dev_flags &= ~IDE_DFLAG_WP;
330 325
331 set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP)); 326 set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP));
332 327
333 page = &pc->buf[8]; 328 page = &buf[8];
334 329
335 transfer_rate = be16_to_cpup((__be16 *)&pc->buf[8 + 2]); 330 transfer_rate = be16_to_cpup((__be16 *)&buf[8 + 2]);
336 sector_size = be16_to_cpup((__be16 *)&pc->buf[8 + 6]); 331 sector_size = be16_to_cpup((__be16 *)&buf[8 + 6]);
337 cyls = be16_to_cpup((__be16 *)&pc->buf[8 + 8]); 332 cyls = be16_to_cpup((__be16 *)&buf[8 + 8]);
338 rpm = be16_to_cpup((__be16 *)&pc->buf[8 + 28]); 333 rpm = be16_to_cpup((__be16 *)&buf[8 + 28]);
339 heads = pc->buf[8 + 4]; 334 heads = buf[8 + 4];
340 sectors = pc->buf[8 + 5]; 335 sectors = buf[8 + 5];
341 336
342 capacity = cyls * heads * sectors * sector_size; 337 capacity = cyls * heads * sectors * sector_size;
343 338
@@ -387,22 +382,19 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
387 drive->capacity64 = 0; 382 drive->capacity64 = 0;
388 383
389 ide_floppy_create_read_capacity_cmd(&pc); 384 ide_floppy_create_read_capacity_cmd(&pc);
390 pc.buf = &pc_buf[0]; 385 if (ide_queue_pc_tail(drive, disk, &pc, pc_buf, pc.req_xfer)) {
391 pc.buf_size = sizeof(pc_buf);
392
393 if (ide_queue_pc_tail(drive, disk, &pc)) {
394 printk(KERN_ERR PFX "Can't get floppy parameters\n"); 386 printk(KERN_ERR PFX "Can't get floppy parameters\n");
395 return 1; 387 return 1;
396 } 388 }
397 header_len = pc.buf[3]; 389 header_len = pc_buf[3];
398 cap_desc = &pc.buf[4]; 390 cap_desc = &pc_buf[4];
399 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ 391 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */
400 392
401 for (i = 0; i < desc_cnt; i++) { 393 for (i = 0; i < desc_cnt; i++) {
402 unsigned int desc_start = 4 + i*8; 394 unsigned int desc_start = 4 + i*8;
403 395
404 blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); 396 blocks = be32_to_cpup((__be32 *)&pc_buf[desc_start]);
405 length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); 397 length = be16_to_cpup((__be16 *)&pc_buf[desc_start + 6]);
406 398
407 ide_debug_log(IDE_DBG_PROBE, "Descriptor %d: %dkB, %d blocks, " 399 ide_debug_log(IDE_DBG_PROBE, "Descriptor %d: %dkB, %d blocks, "
408 "%d sector size", 400 "%d sector size",
@@ -415,7 +407,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
415 * the code below is valid only for the 1st descriptor, ie i=0 407 * the code below is valid only for the 1st descriptor, ie i=0
416 */ 408 */
417 409
418 switch (pc.buf[desc_start + 4] & 0x03) { 410 switch (pc_buf[desc_start + 4] & 0x03) {
419 /* Clik! drive returns this instead of CAPACITY_CURRENT */ 411 /* Clik! drive returns this instead of CAPACITY_CURRENT */
420 case CAPACITY_UNFORMATTED: 412 case CAPACITY_UNFORMATTED:
421 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) 413 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE))
@@ -464,7 +456,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
464 break; 456 break;
465 } 457 }
466 ide_debug_log(IDE_DBG_PROBE, "Descriptor 0 Code: %d", 458 ide_debug_log(IDE_DBG_PROBE, "Descriptor 0 Code: %d",
467 pc.buf[desc_start + 4] & 0x03); 459 pc_buf[desc_start + 4] & 0x03);
468 } 460 }
469 461
470 /* Clik! disk does not support get_flexible_disk_page */ 462 /* Clik! disk does not support get_flexible_disk_page */