diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-19 18:32:37 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-19 18:32:37 -0400 |
commit | a02bfd3ce9342453441202028df44dc58f90e225 (patch) | |
tree | 23ba048ae3ad526b7990c76d82f5d28a90daf5a5 /drivers/ide | |
parent | 52c8136137bc98103249fa195aaacaf84a970d51 (diff) |
ide: PCI BMDMA initialization fixes (take 2)
* Set hwif->dma_base only if allocation of extra ports succeeds.
While at it:
* Move setting of hwif->dma_{base,master} from ide_{mapped_mmio,iomio}_dma()
to ide_setup_dma().
* Rename 'dma_base' argument to 'base' in ide_setup_dma() (to make the code
obey 80-columns limit and increase its readability).
* Remove stale ide_setup_dma() comment.
v2:
* Change to allocate hwif->dmatable_cpu before reserving I/O ports missed
teardown code (spotted by Sergei). On the second thought this change is
actually unnecessary so revert it in v2.
* Make ide_release_dma_engine() void and remove needless comment.
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-dma.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 80b4f17f3941..428f7a8a00b6 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -901,10 +901,7 @@ void ide_dma_timeout (ide_drive_t *drive) | |||
901 | 901 | ||
902 | EXPORT_SYMBOL(ide_dma_timeout); | 902 | EXPORT_SYMBOL(ide_dma_timeout); |
903 | 903 | ||
904 | /* | 904 | static void ide_release_dma_engine(ide_hwif_t *hwif) |
905 | * Needed for allowing full modular support of ide-driver | ||
906 | */ | ||
907 | static int ide_release_dma_engine(ide_hwif_t *hwif) | ||
908 | { | 905 | { |
909 | if (hwif->dmatable_cpu) { | 906 | if (hwif->dmatable_cpu) { |
910 | pci_free_consistent(hwif->pci_dev, | 907 | pci_free_consistent(hwif->pci_dev, |
@@ -913,7 +910,6 @@ static int ide_release_dma_engine(ide_hwif_t *hwif) | |||
913 | hwif->dmatable_dma); | 910 | hwif->dmatable_dma); |
914 | hwif->dmatable_cpu = NULL; | 911 | hwif->dmatable_cpu = NULL; |
915 | } | 912 | } |
916 | return 1; | ||
917 | } | 913 | } |
918 | 914 | ||
919 | static int ide_release_iomio_dma(ide_hwif_t *hwif) | 915 | static int ide_release_iomio_dma(ide_hwif_t *hwif) |
@@ -956,12 +952,6 @@ static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base, unsigned in | |||
956 | { | 952 | { |
957 | printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); | 953 | printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); |
958 | 954 | ||
959 | hwif->dma_base = base; | ||
960 | |||
961 | if(hwif->mate) | ||
962 | hwif->dma_master = (hwif->channel) ? hwif->mate->dma_base : base; | ||
963 | else | ||
964 | hwif->dma_master = base; | ||
965 | return 0; | 955 | return 0; |
966 | } | 956 | } |
967 | 957 | ||
@@ -975,8 +965,6 @@ static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int port | |||
975 | return 1; | 965 | return 1; |
976 | } | 966 | } |
977 | 967 | ||
978 | hwif->dma_base = base; | ||
979 | |||
980 | if (hwif->cds->extra) { | 968 | if (hwif->cds->extra) { |
981 | hwif->extra_base = base + (hwif->channel ? 8 : 16); | 969 | hwif->extra_base = base + (hwif->channel ? 8 : 16); |
982 | 970 | ||
@@ -991,10 +979,6 @@ static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int port | |||
991 | } | 979 | } |
992 | } | 980 | } |
993 | 981 | ||
994 | if(hwif->mate) | ||
995 | hwif->dma_master = (hwif->channel) ? hwif->mate->dma_base:base; | ||
996 | else | ||
997 | hwif->dma_master = base; | ||
998 | return 0; | 982 | return 0; |
999 | } | 983 | } |
1000 | 984 | ||
@@ -1006,12 +990,9 @@ static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base, unsigned int por | |||
1006 | return ide_iomio_dma(hwif, base, ports); | 990 | return ide_iomio_dma(hwif, base, ports); |
1007 | } | 991 | } |
1008 | 992 | ||
1009 | /* | 993 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) |
1010 | * This can be called for a dynamically installed interface. Don't __init it | ||
1011 | */ | ||
1012 | void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_ports) | ||
1013 | { | 994 | { |
1014 | if (ide_dma_iobase(hwif, dma_base, num_ports)) | 995 | if (ide_dma_iobase(hwif, base, num_ports)) |
1015 | return; | 996 | return; |
1016 | 997 | ||
1017 | if (ide_allocate_dma_engine(hwif)) { | 998 | if (ide_allocate_dma_engine(hwif)) { |
@@ -1019,6 +1000,13 @@ void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_p | |||
1019 | return; | 1000 | return; |
1020 | } | 1001 | } |
1021 | 1002 | ||
1003 | hwif->dma_base = base; | ||
1004 | |||
1005 | if (hwif->mate) | ||
1006 | hwif->dma_master = hwif->channel ? hwif->mate->dma_base : base; | ||
1007 | else | ||
1008 | hwif->dma_master = base; | ||
1009 | |||
1022 | if (!(hwif->dma_command)) | 1010 | if (!(hwif->dma_command)) |
1023 | hwif->dma_command = hwif->dma_base; | 1011 | hwif->dma_command = hwif->dma_base; |
1024 | if (!(hwif->dma_vendor1)) | 1012 | if (!(hwif->dma_vendor1)) |