diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 16:25:21 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 16:25:21 -0400 |
commit | d54452fbf84500eff77a55a2061f4669441d2cc3 (patch) | |
tree | 3bc697e9360a915703aed4e579ff85bd43e014d9 /drivers/ide | |
parent | b8e73fba60414e161d8fd2429b6fb268e34502e2 (diff) |
ide: factor out setting PCI bus-mastering from ide_hwif_setup_dma()
Factor out setting PCI bus-mastering from ide_hwif_setup_dma()
to ide_pci_set_master() helper.
While at it:
* don't read PCI Command register if not necessary
* use PCI device name instead of hwif->name
* cleanup ide_hwif_setup_dma() a bit
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/setup-pci.c | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index f8fc9727da07..bf28970b0278 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -132,6 +132,29 @@ static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_ | |||
132 | out: | 132 | out: |
133 | return dma_base; | 133 | return dma_base; |
134 | } | 134 | } |
135 | |||
136 | /* | ||
137 | * Set up BM-DMA capability (PnP BIOS should have done this) | ||
138 | */ | ||
139 | static int ide_pci_set_master(struct pci_dev *dev, const char *name) | ||
140 | { | ||
141 | u16 pcicmd; | ||
142 | |||
143 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | ||
144 | |||
145 | if ((pcicmd & PCI_COMMAND_MASTER) == 0) { | ||
146 | pci_set_master(dev); | ||
147 | |||
148 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || | ||
149 | (pcicmd & PCI_COMMAND_MASTER) == 0) { | ||
150 | printk(KERN_ERR "%s: error updating PCICMD on %s\n", | ||
151 | name, pci_name(dev)); | ||
152 | return -EIO; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | return 0; | ||
157 | } | ||
135 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 158 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
136 | 159 | ||
137 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) | 160 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) |
@@ -340,36 +363,26 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
340 | void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | 363 | void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) |
341 | { | 364 | { |
342 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 365 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
343 | u16 pcicmd; | ||
344 | |||
345 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | ||
346 | 366 | ||
347 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || | 367 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || |
348 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && | 368 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
349 | (dev->class & 0x80))) { | 369 | (dev->class & 0x80))) { |
350 | unsigned long dma_base = ide_get_or_set_dma_base(d, hwif); | 370 | unsigned long dma_base = ide_get_or_set_dma_base(d, hwif); |
351 | if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { | 371 | |
352 | /* | 372 | if (dma_base == 0 || ide_pci_set_master(dev, d->name) < 0) |
353 | * Set up BM-DMA capability | 373 | goto out_disabled; |
354 | * (PnP BIOS should have done this) | 374 | |
355 | */ | 375 | if (d->init_dma) |
356 | pci_set_master(dev); | 376 | d->init_dma(hwif, dma_base); |
357 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || !(pcicmd & PCI_COMMAND_MASTER)) { | 377 | |
358 | printk(KERN_ERR "%s: %s error updating PCICMD\n", | 378 | ide_setup_dma(hwif, dma_base); |
359 | hwif->name, d->name); | ||
360 | dma_base = 0; | ||
361 | } | ||
362 | } | ||
363 | if (dma_base) { | ||
364 | if (d->init_dma) | ||
365 | d->init_dma(hwif, dma_base); | ||
366 | |||
367 | ide_setup_dma(hwif, dma_base); | ||
368 | } else { | ||
369 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled " | ||
370 | "(BIOS)\n", hwif->name, d->name); | ||
371 | } | ||
372 | } | 379 | } |
380 | |||
381 | return; | ||
382 | |||
383 | out_disabled: | ||
384 | printk(KERN_INFO "%s: Bus-Master DMA disabled (BIOS) on %s\n", | ||
385 | d->name, pci_name(dev)); | ||
373 | } | 386 | } |
374 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 387 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
375 | 388 | ||