Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: 3w-9xxx: fully convert to the generic DMA API

The driver is currently using an odd mix of legacy PCI DMA API and
generic DMA API calls, switch it over to the generic API entirely.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Adam Radford <aradford@gmail.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Christoph Hellwig and committed by
Martin K. Petersen
b000bced 3a21986f

+24 -26
+24 -26
drivers/scsi/3w-9xxx.c
··· 518 518 unsigned long *cpu_addr; 519 519 int retval = 1; 520 520 521 - cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle); 521 + cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, 522 + size * TW_Q_LENGTH, &dma_handle, GFP_KERNEL); 522 523 if (!cpu_addr) { 523 524 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed"); 524 525 goto out; ··· 527 526 528 527 if ((unsigned long)cpu_addr % (TW_ALIGNMENT_9000)) { 529 528 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x6, "Failed to allocate correctly aligned memory"); 530 - pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, cpu_addr, dma_handle); 529 + dma_free_coherent(&tw_dev->tw_pci_dev->dev, size * TW_Q_LENGTH, 530 + cpu_addr, dma_handle); 531 531 goto out; 532 532 } 533 533 ··· 1029 1027 static void twa_free_device_extension(TW_Device_Extension *tw_dev) 1030 1028 { 1031 1029 if (tw_dev->command_packet_virt[0]) 1032 - pci_free_consistent(tw_dev->tw_pci_dev, 1033 - sizeof(TW_Command_Full)*TW_Q_LENGTH, 1034 - tw_dev->command_packet_virt[0], 1035 - tw_dev->command_packet_phys[0]); 1030 + dma_free_coherent(&tw_dev->tw_pci_dev->dev, 1031 + sizeof(TW_Command_Full) * TW_Q_LENGTH, 1032 + tw_dev->command_packet_virt[0], 1033 + tw_dev->command_packet_phys[0]); 1036 1034 1037 1035 if (tw_dev->generic_buffer_virt[0]) 1038 - pci_free_consistent(tw_dev->tw_pci_dev, 1039 - TW_SECTOR_SIZE*TW_Q_LENGTH, 1040 - tw_dev->generic_buffer_virt[0], 1041 - tw_dev->generic_buffer_phys[0]); 1036 + dma_free_coherent(&tw_dev->tw_pci_dev->dev, 1037 + TW_SECTOR_SIZE * TW_Q_LENGTH, 1038 + tw_dev->generic_buffer_virt[0], 1039 + tw_dev->generic_buffer_phys[0]); 1042 1040 1043 1041 kfree(tw_dev->event_queue[0]); 1044 1042 } /* End twa_free_device_extension() */ ··· 2017 2015 pci_set_master(pdev); 2018 2016 pci_try_set_mwi(pdev); 2019 2017 2020 - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) 2021 - || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) 2022 - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) 2023 - || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { 2024 - TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask"); 2025 - retval = -ENODEV; 2026 - goto out_disable_device; 2027 - } 2018 + if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) || 2019 + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) { 2020 + TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask"); 2021 + retval = -ENODEV; 2022 + goto out_disable_device; 2023 + } 2028 2024 2029 2025 host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension)); 2030 2026 if (!host) { ··· 2237 2237 pci_set_master(pdev); 2238 2238 pci_try_set_mwi(pdev); 2239 2239 2240 - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) 2241 - || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) 2242 - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) 2243 - || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { 2244 - TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume"); 2245 - retval = -ENODEV; 2246 - goto out_disable_device; 2247 - } 2240 + if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) || 2241 + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) { 2242 + TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume"); 2243 + retval = -ENODEV; 2244 + goto out_disable_device; 2245 + } 2248 2246 2249 2247 /* Initialize the card */ 2250 2248 if (twa_reset_sequence(tw_dev, 0)) {