aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-16 14:33:42 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-16 14:33:42 -0400
commitb48c89a9699f451e4e236fa7313461281c00e69b (patch)
tree54a9daa2444e1550a566b9413be7884536ed9a7b /drivers/ide
parente6d95bd14928926d6658b5e4ace905e8b83ed27a (diff)
cmd640: add ->init_dev method
Convert the driver to use ->init_dev method instead of open-coding devices init in cmd640x_init(). While at it: - fix printk()-s to use KERN_INFO level instead of the default KERN_ERR - use DRV_NAME define in printk()-s - set proper ->pio_mask also for CONFIG_BLK_DEV_CMD640_ENHANCED=n There should be no functional changes caused by this patch (except fixing printk()-s levels). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/pci/cmd640.c72
1 files changed, 30 insertions, 42 deletions
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index ab7d7274d8b1..1ad1e23e3105 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -611,11 +611,40 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio)
611 611
612 display_clocks(index); 612 display_clocks(index);
613} 613}
614#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
615
616static void cmd640_init_dev(ide_drive_t *drive)
617{
618 unsigned int i = drive->hwif->channel * 2 + drive->select.b.unit;
619
620#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
621 /*
622 * Reset timing to the slowest speed and turn off prefetch.
623 * This way, the drive identify code has a better chance.
624 */
625 setup_counts[i] = 4; /* max possible */
626 active_counts[i] = 16; /* max possible */
627 recovery_counts[i] = 16; /* max possible */
628 program_drive_counts(drive, i);
629 set_prefetch_mode(drive, i, 0);
630 printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch cleared\n", i);
631#else
632 /*
633 * Set the drive unmask flags to match the prefetch setting.
634 */
635 check_prefetch(drive, i);
636 printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch(%s) preserved\n",
637 i, drive->no_io_32bit ? "off" : "on");
638#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
639}
640
614 641
615static const struct ide_port_ops cmd640_port_ops = { 642static const struct ide_port_ops cmd640_port_ops = {
643 .init_dev = cmd640_init_dev,
644#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
616 .set_pio_mode = cmd640_set_pio_mode, 645 .set_pio_mode = cmd640_set_pio_mode,
646#endif
617}; 647};
618#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
619 648
620static int pci_conf1(void) 649static int pci_conf1(void)
621{ 650{
@@ -658,10 +687,8 @@ static const struct ide_port_info cmd640_port_info __initdata = {
658 IDE_HFLAG_NO_DMA | 687 IDE_HFLAG_NO_DMA |
659 IDE_HFLAG_ABUSE_PREFETCH | 688 IDE_HFLAG_ABUSE_PREFETCH |
660 IDE_HFLAG_ABUSE_FAST_DEVSEL, 689 IDE_HFLAG_ABUSE_FAST_DEVSEL,
661#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
662 .port_ops = &cmd640_port_ops, 690 .port_ops = &cmd640_port_ops,
663 .pio_mask = ATA_PIO5, 691 .pio_mask = ATA_PIO5,
664#endif
665}; 692};
666 693
667static int cmd640x_init_one(unsigned long base, unsigned long ctl) 694static int cmd640x_init_one(unsigned long base, unsigned long ctl)
@@ -689,7 +716,6 @@ static int __init cmd640x_init(void)
689{ 716{
690 int second_port_cmd640 = 0, rc; 717 int second_port_cmd640 = 0, rc;
691 const char *bus_type, *port2; 718 const char *bus_type, *port2;
692 unsigned int index;
693 u8 b, cfr; 719 u8 b, cfr;
694 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 720 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
695 hw_regs_t hw[2]; 721 hw_regs_t hw[2];
@@ -813,44 +839,6 @@ static int __init cmd640x_init(void)
813 printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", 839 printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n",
814 second_port_cmd640 ? "" : "not ", port2); 840 second_port_cmd640 ? "" : "not ", port2);
815 841
816 /*
817 * Establish initial timings/prefetch for all drives.
818 * Do not unnecessarily disturb any prior BIOS setup of these.
819 */
820 for (index = 0; index < (2 + (second_port_cmd640 << 1)); index++) {
821 ide_drive_t *drive;
822
823 if (index > 1) {
824 if (cmd_hwif1 == NULL)
825 continue;
826 drive = &cmd_hwif1->drives[index & 1];
827 } else {
828 if (cmd_hwif0 == NULL)
829 continue;
830 drive = &cmd_hwif0->drives[index & 1];
831 }
832
833#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
834 /*
835 * Reset timing to the slowest speed and turn off prefetch.
836 * This way, the drive identify code has a better chance.
837 */
838 setup_counts [index] = 4; /* max possible */
839 active_counts [index] = 16; /* max possible */
840 recovery_counts [index] = 16; /* max possible */
841 program_drive_counts(drive, index);
842 set_prefetch_mode(drive, index, 0);
843 printk("cmd640: drive%d timings/prefetch cleared\n", index);
844#else
845 /*
846 * Set the drive unmask flags to match the prefetch setting
847 */
848 check_prefetch(drive, index);
849 printk("cmd640: drive%d timings/prefetch(%s) preserved\n",
850 index, drive->no_io_32bit ? "off" : "on");
851#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
852 }
853
854#ifdef CMD640_DUMP_REGS 842#ifdef CMD640_DUMP_REGS
855 cmd640_dump_regs(); 843 cmd640_dump_regs();
856#endif 844#endif