aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-25 16:17:06 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-25 16:17:06 -0500
commit650d841d9e053a618dd8ce753422f91b493cf2f6 (patch)
tree70f81acbf856e4a4d8126bdf6d60144b374cc1a9 /drivers/ide/ide-disk.c
parentcd2a2d969761c26542095c01324201ca0b3ee896 (diff)
ide: add struct ide_taskfile (take 2)
* Don't set write-only ide_task_t.hobRegister[6] and ide_task_t.hobRegister[7] in idedisk_set_max_address_ext(). * Add struct ide_taskfile and use it in ide_task_t instead of tfRegister[] and hobRegister[]. * Remove no longer needed IDE_CONTROL_OFFSET_HOB define. * Add #ifndef/#endif __KERNEL__ around definitions of {task,hob}_struct_t. While at it: * Use ATA_LBA define for LBA bit (0x40) as suggested by Tejun Heo. v2: * Add missing newlines. (Noticed by Sergei) * Use ~ATA_LBA instead of 0xBF. (Noticed by Sergei) * Use unnamed unions for error/feature and status/command. (Suggested by Sergei). There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: Tejun Heo <htejun@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r--drivers/ide/ide-disk.c120
1 files changed, 57 insertions, 63 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 322c4691836..a4c4d435056 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -310,23 +310,22 @@ static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive, struct request *rq, s
310static unsigned long idedisk_read_native_max_address(ide_drive_t *drive) 310static unsigned long idedisk_read_native_max_address(ide_drive_t *drive)
311{ 311{
312 ide_task_t args; 312 ide_task_t args;
313 struct ide_taskfile *tf = &args.tf;
313 unsigned long addr = 0; 314 unsigned long addr = 0;
314 315
315 /* Create IDE/ATA command request structure */ 316 /* Create IDE/ATA command request structure */
316 memset(&args, 0, sizeof(ide_task_t)); 317 memset(&args, 0, sizeof(ide_task_t));
317 args.tfRegister[IDE_SELECT_OFFSET] = 0x40; 318 tf->device = ATA_LBA;
318 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_READ_NATIVE_MAX; 319 tf->command = WIN_READ_NATIVE_MAX;
319 args.command_type = IDE_DRIVE_TASK_NO_DATA; 320 args.command_type = IDE_DRIVE_TASK_NO_DATA;
320 args.handler = &task_no_data_intr; 321 args.handler = &task_no_data_intr;
321 /* submit command request */ 322 /* submit command request */
322 ide_raw_taskfile(drive, &args, NULL); 323 ide_raw_taskfile(drive, &args, NULL);
323 324
324 /* if OK, compute maximum address value */ 325 /* if OK, compute maximum address value */
325 if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { 326 if ((tf->status & 0x01) == 0) {
326 addr = ((args.tfRegister[IDE_SELECT_OFFSET] & 0x0f) << 24) 327 addr = ((tf->device & 0xf) << 24) |
327 | ((args.tfRegister[ IDE_HCYL_OFFSET] ) << 16) 328 (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
328 | ((args.tfRegister[ IDE_LCYL_OFFSET] ) << 8)
329 | ((args.tfRegister[IDE_SECTOR_OFFSET] ));
330 addr++; /* since the return value is (maxlba - 1), we add 1 */ 329 addr++; /* since the return value is (maxlba - 1), we add 1 */
331 } 330 }
332 return addr; 331 return addr;
@@ -335,26 +334,24 @@ static unsigned long idedisk_read_native_max_address(ide_drive_t *drive)
335static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive) 334static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive)
336{ 335{
337 ide_task_t args; 336 ide_task_t args;
337 struct ide_taskfile *tf = &args.tf;
338 unsigned long long addr = 0; 338 unsigned long long addr = 0;
339 339
340 /* Create IDE/ATA command request structure */ 340 /* Create IDE/ATA command request structure */
341 memset(&args, 0, sizeof(ide_task_t)); 341 memset(&args, 0, sizeof(ide_task_t));
342 342 tf->device = ATA_LBA;
343 args.tfRegister[IDE_SELECT_OFFSET] = 0x40; 343 tf->command = WIN_READ_NATIVE_MAX_EXT;
344 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_READ_NATIVE_MAX_EXT;
345 args.command_type = IDE_DRIVE_TASK_NO_DATA; 344 args.command_type = IDE_DRIVE_TASK_NO_DATA;
346 args.handler = &task_no_data_intr; 345 args.handler = &task_no_data_intr;
347 /* submit command request */ 346 /* submit command request */
348 ide_raw_taskfile(drive, &args, NULL); 347 ide_raw_taskfile(drive, &args, NULL);
349 348
350 /* if OK, compute maximum address value */ 349 /* if OK, compute maximum address value */
351 if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { 350 if ((tf->status & 0x01) == 0) {
352 u32 high = (args.hobRegister[IDE_HCYL_OFFSET] << 16) | 351 u32 high, low;
353 (args.hobRegister[IDE_LCYL_OFFSET] << 8) | 352
354 args.hobRegister[IDE_SECTOR_OFFSET]; 353 high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | tf->hob_lbal;
355 u32 low = ((args.tfRegister[IDE_HCYL_OFFSET])<<16) | 354 low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
356 ((args.tfRegister[IDE_LCYL_OFFSET])<<8) |
357 (args.tfRegister[IDE_SECTOR_OFFSET]);
358 addr = ((__u64)high << 24) | low; 355 addr = ((__u64)high << 24) | low;
359 addr++; /* since the return value is (maxlba - 1), we add 1 */ 356 addr++; /* since the return value is (maxlba - 1), we add 1 */
360 } 357 }
@@ -368,26 +365,25 @@ static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive
368static unsigned long idedisk_set_max_address(ide_drive_t *drive, unsigned long addr_req) 365static unsigned long idedisk_set_max_address(ide_drive_t *drive, unsigned long addr_req)
369{ 366{
370 ide_task_t args; 367 ide_task_t args;
368 struct ide_taskfile *tf = &args.tf;
371 unsigned long addr_set = 0; 369 unsigned long addr_set = 0;
372 370
373 addr_req--; 371 addr_req--;
374 /* Create IDE/ATA command request structure */ 372 /* Create IDE/ATA command request structure */
375 memset(&args, 0, sizeof(ide_task_t)); 373 memset(&args, 0, sizeof(ide_task_t));
376 args.tfRegister[IDE_SECTOR_OFFSET] = ((addr_req >> 0) & 0xff); 374 tf->lbal = (addr_req >> 0) & 0xff;
377 args.tfRegister[IDE_LCYL_OFFSET] = ((addr_req >> 8) & 0xff); 375 tf->lbam = (addr_req >> 8) & 0xff;
378 args.tfRegister[IDE_HCYL_OFFSET] = ((addr_req >> 16) & 0xff); 376 tf->lbah = (addr_req >> 16) & 0xff;
379 args.tfRegister[IDE_SELECT_OFFSET] = ((addr_req >> 24) & 0x0f) | 0x40; 377 tf->device = ((addr_req >> 24) & 0x0f) | ATA_LBA;
380 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SET_MAX; 378 tf->command = WIN_SET_MAX;
381 args.command_type = IDE_DRIVE_TASK_NO_DATA; 379 args.command_type = IDE_DRIVE_TASK_NO_DATA;
382 args.handler = &task_no_data_intr; 380 args.handler = &task_no_data_intr;
383 /* submit command request */ 381 /* submit command request */
384 ide_raw_taskfile(drive, &args, NULL); 382 ide_raw_taskfile(drive, &args, NULL);
385 /* if OK, read new maximum address value */ 383 /* if OK, read new maximum address value */
386 if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { 384 if ((tf->status & 0x01) == 0) {
387 addr_set = ((args.tfRegister[IDE_SELECT_OFFSET] & 0x0f) << 24) 385 addr_set = ((tf->device & 0xf) << 24) |
388 | ((args.tfRegister[ IDE_HCYL_OFFSET] ) << 16) 386 (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
389 | ((args.tfRegister[ IDE_LCYL_OFFSET] ) << 8)
390 | ((args.tfRegister[IDE_SECTOR_OFFSET] ));
391 addr_set++; 387 addr_set++;
392 } 388 }
393 return addr_set; 389 return addr_set;
@@ -396,33 +392,30 @@ static unsigned long idedisk_set_max_address(ide_drive_t *drive, unsigned long a
396static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsigned long long addr_req) 392static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsigned long long addr_req)
397{ 393{
398 ide_task_t args; 394 ide_task_t args;
395 struct ide_taskfile *tf = &args.tf;
399 unsigned long long addr_set = 0; 396 unsigned long long addr_set = 0;
400 397
401 addr_req--; 398 addr_req--;
402 /* Create IDE/ATA command request structure */ 399 /* Create IDE/ATA command request structure */
403 memset(&args, 0, sizeof(ide_task_t)); 400 memset(&args, 0, sizeof(ide_task_t));
404 args.tfRegister[IDE_SECTOR_OFFSET] = ((addr_req >> 0) & 0xff); 401 tf->lbal = (addr_req >> 0) & 0xff;
405 args.tfRegister[IDE_LCYL_OFFSET] = ((addr_req >>= 8) & 0xff); 402 tf->lbam = (addr_req >>= 8) & 0xff;
406 args.tfRegister[IDE_HCYL_OFFSET] = ((addr_req >>= 8) & 0xff); 403 tf->lbah = (addr_req >>= 8) & 0xff;
407 args.tfRegister[IDE_SELECT_OFFSET] = 0x40; 404 tf->device = ATA_LBA;
408 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SET_MAX_EXT; 405 tf->command = WIN_SET_MAX_EXT;
409 args.hobRegister[IDE_SECTOR_OFFSET] = (addr_req >>= 8) & 0xff; 406 tf->hob_lbal = (addr_req >>= 8) & 0xff;
410 args.hobRegister[IDE_LCYL_OFFSET] = (addr_req >>= 8) & 0xff; 407 tf->hob_lbam = (addr_req >>= 8) & 0xff;
411 args.hobRegister[IDE_HCYL_OFFSET] = (addr_req >>= 8) & 0xff; 408 tf->hob_lbah = (addr_req >>= 8) & 0xff;
412 args.hobRegister[IDE_SELECT_OFFSET] = 0x40;
413 args.hobRegister[IDE_CONTROL_OFFSET_HOB]= (drive->ctl|0x80);
414 args.command_type = IDE_DRIVE_TASK_NO_DATA; 409 args.command_type = IDE_DRIVE_TASK_NO_DATA;
415 args.handler = &task_no_data_intr; 410 args.handler = &task_no_data_intr;
416 /* submit command request */ 411 /* submit command request */
417 ide_raw_taskfile(drive, &args, NULL); 412 ide_raw_taskfile(drive, &args, NULL);
418 /* if OK, compute maximum address value */ 413 /* if OK, compute maximum address value */
419 if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { 414 if ((tf->status & 0x01) == 0) {
420 u32 high = (args.hobRegister[IDE_HCYL_OFFSET] << 16) | 415 u32 high, low;
421 (args.hobRegister[IDE_LCYL_OFFSET] << 8) | 416
422 args.hobRegister[IDE_SECTOR_OFFSET]; 417 high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | tf->hob_lbal;
423 u32 low = ((args.tfRegister[IDE_HCYL_OFFSET])<<16) | 418 low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
424 ((args.tfRegister[IDE_LCYL_OFFSET])<<8) |
425 (args.tfRegister[IDE_SECTOR_OFFSET]);
426 addr_set = ((__u64)high << 24) | low; 419 addr_set = ((__u64)high << 24) | low;
427 addr_set++; 420 addr_set++;
428 } 421 }
@@ -556,12 +549,13 @@ static sector_t idedisk_capacity (ide_drive_t *drive)
556static int smart_enable(ide_drive_t *drive) 549static int smart_enable(ide_drive_t *drive)
557{ 550{
558 ide_task_t args; 551 ide_task_t args;
552 struct ide_taskfile *tf = &args.tf;
559 553
560 memset(&args, 0, sizeof(ide_task_t)); 554 memset(&args, 0, sizeof(ide_task_t));
561 args.tfRegister[IDE_FEATURE_OFFSET] = SMART_ENABLE; 555 tf->feature = SMART_ENABLE;
562 args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS; 556 tf->lbam = SMART_LCYL_PASS;
563 args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS; 557 tf->lbah = SMART_HCYL_PASS;
564 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SMART; 558 tf->command = WIN_SMART;
565 args.command_type = IDE_DRIVE_TASK_NO_DATA; 559 args.command_type = IDE_DRIVE_TASK_NO_DATA;
566 args.handler = &task_no_data_intr; 560 args.handler = &task_no_data_intr;
567 return ide_raw_taskfile(drive, &args, NULL); 561 return ide_raw_taskfile(drive, &args, NULL);
@@ -570,13 +564,14 @@ static int smart_enable(ide_drive_t *drive)
570static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) 564static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
571{ 565{
572 ide_task_t args; 566 ide_task_t args;
567 struct ide_taskfile *tf = &args.tf;
573 568
574 memset(&args, 0, sizeof(ide_task_t)); 569 memset(&args, 0, sizeof(ide_task_t));
575 args.tfRegister[IDE_FEATURE_OFFSET] = sub_cmd; 570 tf->feature = sub_cmd;
576 args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01; 571 tf->nsect = 0x01;
577 args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS; 572 tf->lbam = SMART_LCYL_PASS;
578 args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS; 573 tf->lbah = SMART_HCYL_PASS;
579 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SMART; 574 tf->command = WIN_SMART;
580 args.command_type = IDE_DRIVE_TASK_IN; 575 args.command_type = IDE_DRIVE_TASK_IN;
581 args.data_phase = TASKFILE_IN; 576 args.data_phase = TASKFILE_IN;
582 args.handler = &task_in_intr; 577 args.handler = &task_in_intr;
@@ -753,9 +748,9 @@ static int write_cache(ide_drive_t *drive, int arg)
753 748
754 if (ide_id_has_flush_cache(drive->id)) { 749 if (ide_id_has_flush_cache(drive->id)) {
755 memset(&args, 0, sizeof(ide_task_t)); 750 memset(&args, 0, sizeof(ide_task_t));
756 args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? 751 args.tf.feature = arg ?
757 SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; 752 SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE;
758 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES; 753 args.tf.command = WIN_SETFEATURES;
759 args.command_type = IDE_DRIVE_TASK_NO_DATA; 754 args.command_type = IDE_DRIVE_TASK_NO_DATA;
760 args.handler = &task_no_data_intr; 755 args.handler = &task_no_data_intr;
761 err = ide_raw_taskfile(drive, &args, NULL); 756 err = ide_raw_taskfile(drive, &args, NULL);
@@ -774,9 +769,9 @@ static int do_idedisk_flushcache (ide_drive_t *drive)
774 769
775 memset(&args, 0, sizeof(ide_task_t)); 770 memset(&args, 0, sizeof(ide_task_t));
776 if (ide_id_has_flush_cache_ext(drive->id)) 771 if (ide_id_has_flush_cache_ext(drive->id))
777 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_FLUSH_CACHE_EXT; 772 args.tf.command = WIN_FLUSH_CACHE_EXT;
778 else 773 else
779 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_FLUSH_CACHE; 774 args.tf.command = WIN_FLUSH_CACHE;
780 args.command_type = IDE_DRIVE_TASK_NO_DATA; 775 args.command_type = IDE_DRIVE_TASK_NO_DATA;
781 args.handler = &task_no_data_intr; 776 args.handler = &task_no_data_intr;
782 return ide_raw_taskfile(drive, &args, NULL); 777 return ide_raw_taskfile(drive, &args, NULL);
@@ -790,10 +785,9 @@ static int set_acoustic (ide_drive_t *drive, int arg)
790 return -EINVAL; 785 return -EINVAL;
791 786
792 memset(&args, 0, sizeof(ide_task_t)); 787 memset(&args, 0, sizeof(ide_task_t));
793 args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? SETFEATURES_EN_AAM : 788 args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM;
794 SETFEATURES_DIS_AAM; 789 args.tf.nsect = arg;
795 args.tfRegister[IDE_NSECTOR_OFFSET] = arg; 790 args.tf.command = WIN_SETFEATURES;
796 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
797 args.command_type = IDE_DRIVE_TASK_NO_DATA; 791 args.command_type = IDE_DRIVE_TASK_NO_DATA;
798 args.handler = &task_no_data_intr; 792 args.handler = &task_no_data_intr;
799 ide_raw_taskfile(drive, &args, NULL); 793 ide_raw_taskfile(drive, &args, NULL);
@@ -1057,7 +1051,7 @@ static int idedisk_open(struct inode *inode, struct file *filp)
1057 if (drive->removable && idkp->openers == 1) { 1051 if (drive->removable && idkp->openers == 1) {
1058 ide_task_t args; 1052 ide_task_t args;
1059 memset(&args, 0, sizeof(ide_task_t)); 1053 memset(&args, 0, sizeof(ide_task_t));
1060 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORLOCK; 1054 args.tf.command = WIN_DOORLOCK;
1061 args.command_type = IDE_DRIVE_TASK_NO_DATA; 1055 args.command_type = IDE_DRIVE_TASK_NO_DATA;
1062 args.handler = &task_no_data_intr; 1056 args.handler = &task_no_data_intr;
1063 check_disk_change(inode->i_bdev); 1057 check_disk_change(inode->i_bdev);
@@ -1084,7 +1078,7 @@ static int idedisk_release(struct inode *inode, struct file *filp)
1084 if (drive->removable && idkp->openers == 1) { 1078 if (drive->removable && idkp->openers == 1) {
1085 ide_task_t args; 1079 ide_task_t args;
1086 memset(&args, 0, sizeof(ide_task_t)); 1080 memset(&args, 0, sizeof(ide_task_t));
1087 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORUNLOCK; 1081 args.tf.command = WIN_DOORUNLOCK;
1088 args.command_type = IDE_DRIVE_TASK_NO_DATA; 1082 args.command_type = IDE_DRIVE_TASK_NO_DATA;
1089 args.handler = &task_no_data_intr; 1083 args.handler = &task_no_data_intr;
1090 if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL)) 1084 if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL))