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.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 650981758f15..800c83a9db83 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,
@@ -286,8 +283,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
286 283
287 cmd.rq = rq; 284 cmd.rq = rq;
288 285
289 if (blk_fs_request(rq) || pc->req_xfer) { 286 if (blk_fs_request(rq) || blk_rq_bytes(rq)) {
290 ide_init_sg_cmd(&cmd, pc->req_xfer); 287 ide_init_sg_cmd(&cmd, blk_rq_bytes(rq));
291 ide_map_sg(drive, &cmd); 288 ide_map_sg(drive, &cmd);
292 } 289 }
293 290
@@ -311,33 +308,33 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive,
311{ 308{
312 struct ide_disk_obj *floppy = drive->driver_data; 309 struct ide_disk_obj *floppy = drive->driver_data;
313 struct gendisk *disk = floppy->disk; 310 struct gendisk *disk = floppy->disk;
314 u8 *page; 311 u8 *page, buf[40];
315 int capacity, lba_capacity; 312 int capacity, lba_capacity;
316 u16 transfer_rate, sector_size, cyls, rpm; 313 u16 transfer_rate, sector_size, cyls, rpm;
317 u8 heads, sectors; 314 u8 heads, sectors;
318 315
319 ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); 316 ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE);
320 317
321 if (ide_queue_pc_tail(drive, disk, pc)) { 318 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"); 319 printk(KERN_ERR PFX "Can't get flexible disk page params\n");
323 return 1; 320 return 1;
324 } 321 }
325 322
326 if (pc->buf[3] & 0x80) 323 if (buf[3] & 0x80)
327 drive->dev_flags |= IDE_DFLAG_WP; 324 drive->dev_flags |= IDE_DFLAG_WP;
328 else 325 else
329 drive->dev_flags &= ~IDE_DFLAG_WP; 326 drive->dev_flags &= ~IDE_DFLAG_WP;
330 327
331 set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP)); 328 set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP));
332 329
333 page = &pc->buf[8]; 330 page = &buf[8];
334 331
335 transfer_rate = be16_to_cpup((__be16 *)&pc->buf[8 + 2]); 332 transfer_rate = be16_to_cpup((__be16 *)&buf[8 + 2]);
336 sector_size = be16_to_cpup((__be16 *)&pc->buf[8 + 6]); 333 sector_size = be16_to_cpup((__be16 *)&buf[8 + 6]);
337 cyls = be16_to_cpup((__be16 *)&pc->buf[8 + 8]); 334 cyls = be16_to_cpup((__be16 *)&buf[8 + 8]);
338 rpm = be16_to_cpup((__be16 *)&pc->buf[8 + 28]); 335 rpm = be16_to_cpup((__be16 *)&buf[8 + 28]);
339 heads = pc->buf[8 + 4]; 336 heads = buf[8 + 4];
340 sectors = pc->buf[8 + 5]; 337 sectors = buf[8 + 5];
341 338
342 capacity = cyls * heads * sectors * sector_size; 339 capacity = cyls * heads * sectors * sector_size;
343 340
@@ -387,22 +384,19 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
387 drive->capacity64 = 0; 384 drive->capacity64 = 0;
388 385
389 ide_floppy_create_read_capacity_cmd(&pc); 386 ide_floppy_create_read_capacity_cmd(&pc);
390 pc.buf = &pc_buf[0]; 387 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"); 388 printk(KERN_ERR PFX "Can't get floppy parameters\n");
395 return 1; 389 return 1;
396 } 390 }
397 header_len = pc.buf[3]; 391 header_len = pc_buf[3];
398 cap_desc = &pc.buf[4]; 392 cap_desc = &pc_buf[4];
399 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ 393 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */
400 394
401 for (i = 0; i < desc_cnt; i++) { 395 for (i = 0; i < desc_cnt; i++) {
402 unsigned int desc_start = 4 + i*8; 396 unsigned int desc_start = 4 + i*8;
403 397
404 blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); 398 blocks = be32_to_cpup((__be32 *)&pc_buf[desc_start]);
405 length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); 399 length = be16_to_cpup((__be16 *)&pc_buf[desc_start + 6]);
406 400
407 ide_debug_log(IDE_DBG_PROBE, "Descriptor %d: %dkB, %d blocks, " 401 ide_debug_log(IDE_DBG_PROBE, "Descriptor %d: %dkB, %d blocks, "
408 "%d sector size", 402 "%d sector size",
@@ -415,7 +409,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 409 * the code below is valid only for the 1st descriptor, ie i=0
416 */ 410 */
417 411
418 switch (pc.buf[desc_start + 4] & 0x03) { 412 switch (pc_buf[desc_start + 4] & 0x03) {
419 /* Clik! drive returns this instead of CAPACITY_CURRENT */ 413 /* Clik! drive returns this instead of CAPACITY_CURRENT */
420 case CAPACITY_UNFORMATTED: 414 case CAPACITY_UNFORMATTED:
421 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) 415 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE))
@@ -464,7 +458,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
464 break; 458 break;
465 } 459 }
466 ide_debug_log(IDE_DBG_PROBE, "Descriptor 0 Code: %d", 460 ide_debug_log(IDE_DBG_PROBE, "Descriptor 0 Code: %d",
467 pc.buf[desc_start + 4] & 0x03); 461 pc_buf[desc_start + 4] & 0x03);
468 } 462 }
469 463
470 /* Clik! disk does not support get_flexible_disk_page */ 464 /* Clik! disk does not support get_flexible_disk_page */