hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/drivers/scsi/3w-xxxx.c
....@@ -834,15 +834,17 @@
834834
835835 dprintk(KERN_NOTICE "3w-xxxx: tw_allocate_memory()\n");
836836
837
- cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle);
837
+ cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev,
838
+ size * TW_Q_LENGTH, &dma_handle, GFP_KERNEL);
838839 if (cpu_addr == NULL) {
839
- printk(KERN_WARNING "3w-xxxx: pci_alloc_consistent() failed.\n");
840
+ printk(KERN_WARNING "3w-xxxx: dma_alloc_coherent() failed.\n");
840841 return 1;
841842 }
842843
843844 if ((unsigned long)cpu_addr % (tw_dev->tw_pci_dev->device == TW_DEVICE_ID ? TW_ALIGNMENT_6000 : TW_ALIGNMENT_7000)) {
844845 printk(KERN_WARNING "3w-xxxx: Couldn't allocate correctly aligned memory.\n");
845
- pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, cpu_addr, dma_handle);
846
+ dma_free_coherent(&tw_dev->tw_pci_dev->dev, size * TW_Q_LENGTH,
847
+ cpu_addr, dma_handle);
846848 return 1;
847849 }
848850
....@@ -1047,9 +1049,7 @@
10471049 static const struct file_operations tw_fops = {
10481050 .owner = THIS_MODULE,
10491051 .unlocked_ioctl = tw_chrdev_ioctl,
1050
-#ifdef CONFIG_COMPAT
1051
- .compat_ioctl = tw_chrdev_ioctl,
1052
-#endif
1052
+ .compat_ioctl = compat_ptr_ioctl,
10531053 .open = tw_chrdev_open,
10541054 .release = NULL,
10551055 .llseek = noop_llseek,
....@@ -1062,10 +1062,16 @@
10621062
10631063 /* Free command packet and generic buffer memory */
10641064 if (tw_dev->command_packet_virtual_address[0])
1065
- pci_free_consistent(tw_dev->tw_pci_dev, sizeof(TW_Command)*TW_Q_LENGTH, tw_dev->command_packet_virtual_address[0], tw_dev->command_packet_physical_address[0]);
1065
+ dma_free_coherent(&tw_dev->tw_pci_dev->dev,
1066
+ sizeof(TW_Command) * TW_Q_LENGTH,
1067
+ tw_dev->command_packet_virtual_address[0],
1068
+ tw_dev->command_packet_physical_address[0]);
10661069
10671070 if (tw_dev->alignment_virtual_address[0])
1068
- pci_free_consistent(tw_dev->tw_pci_dev, sizeof(TW_Sector)*TW_Q_LENGTH, tw_dev->alignment_virtual_address[0], tw_dev->alignment_physical_address[0]);
1071
+ dma_free_coherent(&tw_dev->tw_pci_dev->dev,
1072
+ sizeof(TW_Sector) * TW_Q_LENGTH,
1073
+ tw_dev->alignment_virtual_address[0],
1074
+ tw_dev->alignment_physical_address[0]);
10691075 } /* End tw_free_device_extension() */
10701076
10711077 /* This function will send an initconnection command to controller */
....@@ -1166,7 +1172,7 @@
11661172 command_que_value = tw_dev->command_packet_physical_address[request_id];
11671173 if (command_que_value == 0) {
11681174 printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Bad command packet physical address.\n");
1169
- return 1;
1175
+ return 1;
11701176 }
11711177
11721178 /* Send command packet to the board */
....@@ -2239,7 +2245,6 @@
22392245 .sg_tablesize = TW_MAX_SGL_LENGTH,
22402246 .max_sectors = TW_MAX_SECTORS,
22412247 .cmd_per_lun = TW_MAX_CMDS_PER_LUN,
2242
- .use_clustering = ENABLE_CLUSTERING,
22432248 .shost_attrs = tw_host_attrs,
22442249 .emulated = 1,
22452250 .no_write_same = 1,
....@@ -2260,7 +2265,7 @@
22602265
22612266 pci_set_master(pdev);
22622267
2263
- retval = pci_set_dma_mask(pdev, TW_DMA_MASK);
2268
+ retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
22642269 if (retval) {
22652270 printk(KERN_WARNING "3w-xxxx: Failed to set dma mask.");
22662271 goto out_disable_device;
....@@ -2303,8 +2308,10 @@
23032308 TW_DISABLE_INTERRUPTS(tw_dev);
23042309
23052310 /* Initialize the card */
2306
- if (tw_reset_sequence(tw_dev))
2311
+ if (tw_reset_sequence(tw_dev)) {
2312
+ retval = -EINVAL;
23072313 goto out_release_mem_region;
2314
+ }
23082315
23092316 /* Set host specific parameters */
23102317 host->max_id = TW_MAX_UNITS;