aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:45 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:45 -0400
commit06b89518fa69fb7243dc98c31f9a9cfa61bfe788 (patch)
treec343692a440f551da2a09d22cf644df9e093b426 /drivers/ide/ide-disk.c
parentf87904898e91923a91b925078ac933f05076c7fd (diff)
ide-disk: move /proc handling to ide-disk_proc.c (take 3)
While at it: - idedisk_capacity() -> ide_disk_capacity() - idedisk_proc[] -> ide_disk_proc[] - idedisk_settings[] -> ide_disk_settings[] v2/3: Build fix for CONFIG_IDE_PROC_FS=n from Elias Oltmanns. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r--drivers/ide/ide-disk.c142
1 files changed, 7 insertions, 135 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 995d448109eb..3853bde8eedc 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -405,115 +405,11 @@ static void init_idedisk_capacity(ide_drive_t *drive)
405 } 405 }
406} 406}
407 407
408static sector_t idedisk_capacity(ide_drive_t *drive) 408sector_t ide_disk_capacity(ide_drive_t *drive)
409{ 409{
410 return drive->capacity64; 410 return drive->capacity64;
411} 411}
412 412
413#ifdef CONFIG_IDE_PROC_FS
414static int smart_enable(ide_drive_t *drive)
415{
416 ide_task_t args;
417 struct ide_taskfile *tf = &args.tf;
418
419 memset(&args, 0, sizeof(ide_task_t));
420 tf->feature = ATA_SMART_ENABLE;
421 tf->lbam = ATA_SMART_LBAM_PASS;
422 tf->lbah = ATA_SMART_LBAH_PASS;
423 tf->command = ATA_CMD_SMART;
424 args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
425 return ide_no_data_taskfile(drive, &args);
426}
427
428static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
429{
430 ide_task_t args;
431 struct ide_taskfile *tf = &args.tf;
432
433 memset(&args, 0, sizeof(ide_task_t));
434 tf->feature = sub_cmd;
435 tf->nsect = 0x01;
436 tf->lbam = ATA_SMART_LBAM_PASS;
437 tf->lbah = ATA_SMART_LBAH_PASS;
438 tf->command = ATA_CMD_SMART;
439 args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
440 args.data_phase = TASKFILE_IN;
441 (void) smart_enable(drive);
442 return ide_raw_taskfile(drive, &args, buf, 1);
443}
444
445static int proc_idedisk_read_cache
446 (char *page, char **start, off_t off, int count, int *eof, void *data)
447{
448 ide_drive_t *drive = (ide_drive_t *) data;
449 char *out = page;
450 int len;
451
452 if (drive->dev_flags & IDE_DFLAG_ID_READ)
453 len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2);
454 else
455 len = sprintf(out, "(none)\n");
456
457 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
458}
459
460static int proc_idedisk_read_capacity
461 (char *page, char **start, off_t off, int count, int *eof, void *data)
462{
463 ide_drive_t*drive = (ide_drive_t *)data;
464 int len;
465
466 len = sprintf(page, "%llu\n", (long long)idedisk_capacity(drive));
467
468 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
469}
470
471static int proc_idedisk_read_smart(char *page, char **start, off_t off,
472 int count, int *eof, void *data, u8 sub_cmd)
473{
474 ide_drive_t *drive = (ide_drive_t *)data;
475 int len = 0, i = 0;
476
477 if (get_smart_data(drive, page, sub_cmd) == 0) {
478 unsigned short *val = (unsigned short *) page;
479 char *out = (char *)val + SECTOR_SIZE;
480
481 page = out;
482 do {
483 out += sprintf(out, "%04x%c", le16_to_cpu(*val),
484 (++i & 7) ? ' ' : '\n');
485 val += 1;
486 } while (i < SECTOR_SIZE / 2);
487 len = out - page;
488 }
489
490 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
491}
492
493static int proc_idedisk_read_sv
494 (char *page, char **start, off_t off, int count, int *eof, void *data)
495{
496 return proc_idedisk_read_smart(page, start, off, count, eof, data,
497 ATA_SMART_READ_VALUES);
498}
499
500static int proc_idedisk_read_st
501 (char *page, char **start, off_t off, int count, int *eof, void *data)
502{
503 return proc_idedisk_read_smart(page, start, off, count, eof, data,
504 ATA_SMART_READ_THRESHOLDS);
505}
506
507static ide_proc_entry_t idedisk_proc[] = {
508 { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL },
509 { "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL },
510 { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL },
511 { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_sv, NULL },
512 { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_st, NULL },
513 { NULL, 0, NULL, NULL }
514};
515#endif /* CONFIG_IDE_PROC_FS */
516
517static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) 413static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
518{ 414{
519 ide_drive_t *drive = q->queuedata; 415 ide_drive_t *drive = q->queuedata;
@@ -612,7 +508,7 @@ static void update_ordered(ide_drive_t *drive)
612 * time we have trimmed the drive capacity if LBA48 is 508 * time we have trimmed the drive capacity if LBA48 is
613 * not available so we don't need to recheck that. 509 * not available so we don't need to recheck that.
614 */ 510 */
615 capacity = idedisk_capacity(drive); 511 capacity = ide_disk_capacity(drive);
616 barrier = ata_id_flush_enabled(id) && 512 barrier = ata_id_flush_enabled(id) &&
617 (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 && 513 (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 &&
618 ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 || 514 ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 ||
@@ -720,30 +616,6 @@ ide_ext_devset_rw(wcache, wcache);
720 616
721ide_ext_devset_rw_sync(nowerr, nowerr); 617ide_ext_devset_rw_sync(nowerr, nowerr);
722 618
723#ifdef CONFIG_IDE_PROC_FS
724ide_devset_rw_field(bios_cyl, bios_cyl);
725ide_devset_rw_field(bios_head, bios_head);
726ide_devset_rw_field(bios_sect, bios_sect);
727ide_devset_rw_field(failures, failures);
728ide_devset_rw_field(lun, lun);
729ide_devset_rw_field(max_failures, max_failures);
730
731static const struct ide_proc_devset idedisk_settings[] = {
732 IDE_PROC_DEVSET(acoustic, 0, 254),
733 IDE_PROC_DEVSET(address, 0, 2),
734 IDE_PROC_DEVSET(bios_cyl, 0, 65535),
735 IDE_PROC_DEVSET(bios_head, 0, 255),
736 IDE_PROC_DEVSET(bios_sect, 0, 63),
737 IDE_PROC_DEVSET(failures, 0, 65535),
738 IDE_PROC_DEVSET(lun, 0, 7),
739 IDE_PROC_DEVSET(max_failures, 0, 65535),
740 IDE_PROC_DEVSET(multcount, 0, 16),
741 IDE_PROC_DEVSET(nowerr, 0, 1),
742 IDE_PROC_DEVSET(wcache, 0, 1),
743 { 0 },
744};
745#endif
746
747static void idedisk_setup(ide_drive_t *drive) 619static void idedisk_setup(ide_drive_t *drive)
748{ 620{
749 struct ide_disk_obj *idkp = drive->driver_data; 621 struct ide_disk_obj *idkp = drive->driver_data;
@@ -806,7 +678,7 @@ static void idedisk_setup(ide_drive_t *drive)
806 * if possible, give fdisk access to more of the drive, 678 * if possible, give fdisk access to more of the drive,
807 * by correcting bios_cyls: 679 * by correcting bios_cyls:
808 */ 680 */
809 capacity = idedisk_capacity(drive); 681 capacity = ide_disk_capacity(drive);
810 682
811 if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) { 683 if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) {
812 if (ata_id_lba48_enabled(drive->id)) { 684 if (ata_id_lba48_enabled(drive->id)) {
@@ -939,8 +811,8 @@ static ide_driver_t idedisk_driver = {
939 .end_request = ide_end_request, 811 .end_request = ide_end_request,
940 .error = __ide_error, 812 .error = __ide_error,
941#ifdef CONFIG_IDE_PROC_FS 813#ifdef CONFIG_IDE_PROC_FS
942 .proc = idedisk_proc, 814 .proc = ide_disk_proc,
943 .settings = idedisk_settings, 815 .settings = ide_disk_settings,
944#endif 816#endif
945}; 817};
946 818
@@ -1034,7 +906,7 @@ static int idedisk_media_changed(struct gendisk *disk)
1034static int idedisk_revalidate_disk(struct gendisk *disk) 906static int idedisk_revalidate_disk(struct gendisk *disk)
1035{ 907{
1036 struct ide_disk_obj *idkp = ide_disk_g(disk); 908 struct ide_disk_obj *idkp = ide_disk_g(disk);
1037 set_capacity(disk, idedisk_capacity(idkp->drive)); 909 set_capacity(disk, ide_disk_capacity(idkp->drive));
1038 return 0; 910 return 0;
1039} 911}
1040 912
@@ -1096,7 +968,7 @@ static int ide_disk_probe(ide_drive_t *drive)
1096 g->flags |= GENHD_FL_EXT_DEVT; 968 g->flags |= GENHD_FL_EXT_DEVT;
1097 if (drive->dev_flags & IDE_DFLAG_REMOVABLE) 969 if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
1098 g->flags = GENHD_FL_REMOVABLE; 970 g->flags = GENHD_FL_REMOVABLE;
1099 set_capacity(g, idedisk_capacity(drive)); 971 set_capacity(g, ide_disk_capacity(drive));
1100 g->fops = &idedisk_ops; 972 g->fops = &idedisk_ops;
1101 add_disk(g); 973 add_disk(g);
1102 return 0; 974 return 0;