Commit d47b3bd7 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Martin K. Petersen

scsi: am53c974: use the generic DMA API

Remove usage of the legacy PCI DMA API.  To make this easier we also
store a struct device instead of pci_dev in the dev field of struct
esp.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Tested-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 5adaf1e8
...@@ -96,9 +96,7 @@ static void pci_esp_dma_drain(struct esp *esp); ...@@ -96,9 +96,7 @@ static void pci_esp_dma_drain(struct esp *esp);
static inline struct pci_esp_priv *pci_esp_get_priv(struct esp *esp) static inline struct pci_esp_priv *pci_esp_get_priv(struct esp *esp)
{ {
struct pci_dev *pdev = esp->dev; return dev_get_drvdata(esp->dev);
return pci_get_drvdata(pdev);
} }
static void pci_esp_write8(struct esp *esp, u8 val, unsigned long reg) static void pci_esp_write8(struct esp *esp, u8 val, unsigned long reg)
...@@ -119,25 +117,25 @@ static void pci_esp_write32(struct esp *esp, u32 val, unsigned long reg) ...@@ -119,25 +117,25 @@ static void pci_esp_write32(struct esp *esp, u32 val, unsigned long reg)
static dma_addr_t pci_esp_map_single(struct esp *esp, void *buf, static dma_addr_t pci_esp_map_single(struct esp *esp, void *buf,
size_t sz, int dir) size_t sz, int dir)
{ {
return pci_map_single(esp->dev, buf, sz, dir); return dma_map_single(esp->dev, buf, sz, dir);
} }
static int pci_esp_map_sg(struct esp *esp, struct scatterlist *sg, static int pci_esp_map_sg(struct esp *esp, struct scatterlist *sg,
int num_sg, int dir) int num_sg, int dir)
{ {
return pci_map_sg(esp->dev, sg, num_sg, dir); return dma_map_sg(esp->dev, sg, num_sg, dir);
} }
static void pci_esp_unmap_single(struct esp *esp, dma_addr_t addr, static void pci_esp_unmap_single(struct esp *esp, dma_addr_t addr,
size_t sz, int dir) size_t sz, int dir)
{ {
pci_unmap_single(esp->dev, addr, sz, dir); dma_unmap_single(esp->dev, addr, sz, dir);
} }
static void pci_esp_unmap_sg(struct esp *esp, struct scatterlist *sg, static void pci_esp_unmap_sg(struct esp *esp, struct scatterlist *sg,
int num_sg, int dir) int num_sg, int dir)
{ {
pci_unmap_sg(esp->dev, sg, num_sg, dir); dma_unmap_sg(esp->dev, sg, num_sg, dir);
} }
static int pci_esp_irq_pending(struct esp *esp) static int pci_esp_irq_pending(struct esp *esp)
...@@ -375,18 +373,18 @@ static void dc390_read_eeprom(struct pci_dev *pdev, u16 *ptr) ...@@ -375,18 +373,18 @@ static void dc390_read_eeprom(struct pci_dev *pdev, u16 *ptr)
static void dc390_check_eeprom(struct esp *esp) static void dc390_check_eeprom(struct esp *esp)
{ {
struct pci_dev *pdev = to_pci_dev(esp->dev);
u8 EEbuf[128]; u8 EEbuf[128];
u16 *ptr = (u16 *)EEbuf, wval = 0; u16 *ptr = (u16 *)EEbuf, wval = 0;
int i; int i;
dc390_read_eeprom((struct pci_dev *)esp->dev, ptr); dc390_read_eeprom(pdev, ptr);
for (i = 0; i < DC390_EEPROM_LEN; i++, ptr++) for (i = 0; i < DC390_EEPROM_LEN; i++, ptr++)
wval += *ptr; wval += *ptr;
/* no Tekram EEprom found */ /* no Tekram EEprom found */
if (wval != 0x1234) { if (wval != 0x1234) {
struct pci_dev *pdev = esp->dev;
dev_printk(KERN_INFO, &pdev->dev, dev_printk(KERN_INFO, &pdev->dev,
"No valid Tekram EEprom found\n"); "No valid Tekram EEprom found\n");
return; return;
...@@ -411,7 +409,7 @@ static int pci_esp_probe_one(struct pci_dev *pdev, ...@@ -411,7 +409,7 @@ static int pci_esp_probe_one(struct pci_dev *pdev,
return -ENODEV; return -ENODEV;
} }
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
dev_printk(KERN_INFO, &pdev->dev, dev_printk(KERN_INFO, &pdev->dev,
"failed to set 32bit DMA mask\n"); "failed to set 32bit DMA mask\n");
goto fail_disable_device; goto fail_disable_device;
...@@ -435,7 +433,7 @@ static int pci_esp_probe_one(struct pci_dev *pdev, ...@@ -435,7 +433,7 @@ static int pci_esp_probe_one(struct pci_dev *pdev,
esp = shost_priv(shost); esp = shost_priv(shost);
esp->host = shost; esp->host = shost;
esp->dev = pdev; esp->dev = &pdev->dev;
esp->ops = &pci_esp_ops; esp->ops = &pci_esp_ops;
/* /*
* The am53c974 HBA has a design flaw of generating * The am53c974 HBA has a design flaw of generating
...@@ -467,8 +465,8 @@ static int pci_esp_probe_one(struct pci_dev *pdev, ...@@ -467,8 +465,8 @@ static int pci_esp_probe_one(struct pci_dev *pdev,
pci_set_master(pdev); pci_set_master(pdev);
esp->command_block = pci_alloc_consistent(pdev, 16, esp->command_block = dma_alloc_coherent(&pdev->dev, 16,
&esp->command_block_dma); &esp->command_block_dma, GFP_KERNEL);
if (!esp->command_block) { if (!esp->command_block) {
dev_printk(KERN_ERR, &pdev->dev, dev_printk(KERN_ERR, &pdev->dev,
"failed to allocate command block\n"); "failed to allocate command block\n");
...@@ -508,7 +506,7 @@ static int pci_esp_probe_one(struct pci_dev *pdev, ...@@ -508,7 +506,7 @@ static int pci_esp_probe_one(struct pci_dev *pdev,
free_irq(pdev->irq, esp); free_irq(pdev->irq, esp);
fail_unmap_command_block: fail_unmap_command_block:
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
pci_free_consistent(pdev, 16, esp->command_block, dma_free_coherent(&pdev->dev, 16, esp->command_block,
esp->command_block_dma); esp->command_block_dma);
fail_unmap_regs: fail_unmap_regs:
pci_iounmap(pdev, esp->regs); pci_iounmap(pdev, esp->regs);
...@@ -532,7 +530,7 @@ static void pci_esp_remove_one(struct pci_dev *pdev) ...@@ -532,7 +530,7 @@ static void pci_esp_remove_one(struct pci_dev *pdev)
scsi_esp_unregister(esp); scsi_esp_unregister(esp);
free_irq(pdev->irq, esp); free_irq(pdev->irq, esp);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
pci_free_consistent(pdev, 16, esp->command_block, dma_free_coherent(&pdev->dev, 16, esp->command_block,
esp->command_block_dma); esp->command_block_dma);
pci_iounmap(pdev, esp->regs); pci_iounmap(pdev, esp->regs);
pci_release_regions(pdev); pci_release_regions(pdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment