.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * AMD am53c974 driver. |
---|
3 | 4 | * Copyright (c) 2014 Hannes Reinecke, SUSE Linux GmbH |
---|
.. | .. |
---|
96 | 97 | |
---|
97 | 98 | static inline struct pci_esp_priv *pci_esp_get_priv(struct esp *esp) |
---|
98 | 99 | { |
---|
99 | | - struct pci_dev *pdev = esp->dev; |
---|
100 | | - |
---|
101 | | - return pci_get_drvdata(pdev); |
---|
| 100 | + return dev_get_drvdata(esp->dev); |
---|
102 | 101 | } |
---|
103 | 102 | |
---|
104 | 103 | static void pci_esp_write8(struct esp *esp, u8 val, unsigned long reg) |
---|
.. | .. |
---|
114 | 113 | static void pci_esp_write32(struct esp *esp, u32 val, unsigned long reg) |
---|
115 | 114 | { |
---|
116 | 115 | return iowrite32(val, esp->regs + (reg * 4UL)); |
---|
117 | | -} |
---|
118 | | - |
---|
119 | | -static dma_addr_t pci_esp_map_single(struct esp *esp, void *buf, |
---|
120 | | - size_t sz, int dir) |
---|
121 | | -{ |
---|
122 | | - return pci_map_single(esp->dev, buf, sz, dir); |
---|
123 | | -} |
---|
124 | | - |
---|
125 | | -static int pci_esp_map_sg(struct esp *esp, struct scatterlist *sg, |
---|
126 | | - int num_sg, int dir) |
---|
127 | | -{ |
---|
128 | | - return pci_map_sg(esp->dev, sg, num_sg, dir); |
---|
129 | | -} |
---|
130 | | - |
---|
131 | | -static void pci_esp_unmap_single(struct esp *esp, dma_addr_t addr, |
---|
132 | | - size_t sz, int dir) |
---|
133 | | -{ |
---|
134 | | - pci_unmap_single(esp->dev, addr, sz, dir); |
---|
135 | | -} |
---|
136 | | - |
---|
137 | | -static void pci_esp_unmap_sg(struct esp *esp, struct scatterlist *sg, |
---|
138 | | - int num_sg, int dir) |
---|
139 | | -{ |
---|
140 | | - pci_unmap_sg(esp->dev, sg, num_sg, dir); |
---|
141 | 116 | } |
---|
142 | 117 | |
---|
143 | 118 | static int pci_esp_irq_pending(struct esp *esp) |
---|
.. | .. |
---|
295 | 270 | static const struct esp_driver_ops pci_esp_ops = { |
---|
296 | 271 | .esp_write8 = pci_esp_write8, |
---|
297 | 272 | .esp_read8 = pci_esp_read8, |
---|
298 | | - .map_single = pci_esp_map_single, |
---|
299 | | - .map_sg = pci_esp_map_sg, |
---|
300 | | - .unmap_single = pci_esp_unmap_single, |
---|
301 | | - .unmap_sg = pci_esp_unmap_sg, |
---|
302 | 273 | .irq_pending = pci_esp_irq_pending, |
---|
303 | 274 | .reset_dma = pci_esp_reset_dma, |
---|
304 | 275 | .dma_drain = pci_esp_dma_drain, |
---|
.. | .. |
---|
375 | 346 | |
---|
376 | 347 | static void dc390_check_eeprom(struct esp *esp) |
---|
377 | 348 | { |
---|
| 349 | + struct pci_dev *pdev = to_pci_dev(esp->dev); |
---|
378 | 350 | u8 EEbuf[128]; |
---|
379 | 351 | u16 *ptr = (u16 *)EEbuf, wval = 0; |
---|
380 | 352 | int i; |
---|
381 | 353 | |
---|
382 | | - dc390_read_eeprom((struct pci_dev *)esp->dev, ptr); |
---|
| 354 | + dc390_read_eeprom(pdev, ptr); |
---|
383 | 355 | |
---|
384 | 356 | for (i = 0; i < DC390_EEPROM_LEN; i++, ptr++) |
---|
385 | 357 | wval += *ptr; |
---|
386 | 358 | |
---|
387 | 359 | /* no Tekram EEprom found */ |
---|
388 | 360 | if (wval != 0x1234) { |
---|
389 | | - struct pci_dev *pdev = esp->dev; |
---|
390 | 361 | dev_printk(KERN_INFO, &pdev->dev, |
---|
391 | 362 | "No valid Tekram EEprom found\n"); |
---|
392 | 363 | return; |
---|
.. | .. |
---|
411 | 382 | return -ENODEV; |
---|
412 | 383 | } |
---|
413 | 384 | |
---|
414 | | - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { |
---|
| 385 | + if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { |
---|
415 | 386 | dev_printk(KERN_INFO, &pdev->dev, |
---|
416 | 387 | "failed to set 32bit DMA mask\n"); |
---|
417 | 388 | goto fail_disable_device; |
---|
.. | .. |
---|
435 | 406 | |
---|
436 | 407 | esp = shost_priv(shost); |
---|
437 | 408 | esp->host = shost; |
---|
438 | | - esp->dev = pdev; |
---|
| 409 | + esp->dev = &pdev->dev; |
---|
439 | 410 | esp->ops = &pci_esp_ops; |
---|
440 | 411 | /* |
---|
441 | 412 | * The am53c974 HBA has a design flaw of generating |
---|
.. | .. |
---|
467 | 438 | |
---|
468 | 439 | pci_set_master(pdev); |
---|
469 | 440 | |
---|
470 | | - esp->command_block = pci_alloc_consistent(pdev, 16, |
---|
471 | | - &esp->command_block_dma); |
---|
| 441 | + esp->command_block = dma_alloc_coherent(&pdev->dev, 16, |
---|
| 442 | + &esp->command_block_dma, GFP_KERNEL); |
---|
472 | 443 | if (!esp->command_block) { |
---|
473 | 444 | dev_printk(KERN_ERR, &pdev->dev, |
---|
474 | 445 | "failed to allocate command block\n"); |
---|
.. | .. |
---|
498 | 469 | /* Assume 40MHz clock */ |
---|
499 | 470 | esp->cfreq = 40000000; |
---|
500 | 471 | |
---|
501 | | - err = scsi_esp_register(esp, &pdev->dev); |
---|
| 472 | + err = scsi_esp_register(esp); |
---|
502 | 473 | if (err) |
---|
503 | 474 | goto fail_free_irq; |
---|
504 | 475 | |
---|
.. | .. |
---|
508 | 479 | free_irq(pdev->irq, esp); |
---|
509 | 480 | fail_unmap_command_block: |
---|
510 | 481 | pci_set_drvdata(pdev, NULL); |
---|
511 | | - pci_free_consistent(pdev, 16, esp->command_block, |
---|
512 | | - esp->command_block_dma); |
---|
| 482 | + dma_free_coherent(&pdev->dev, 16, esp->command_block, |
---|
| 483 | + esp->command_block_dma); |
---|
513 | 484 | fail_unmap_regs: |
---|
514 | 485 | pci_iounmap(pdev, esp->regs); |
---|
515 | 486 | fail_release_regions: |
---|
.. | .. |
---|
532 | 503 | scsi_esp_unregister(esp); |
---|
533 | 504 | free_irq(pdev->irq, esp); |
---|
534 | 505 | pci_set_drvdata(pdev, NULL); |
---|
535 | | - pci_free_consistent(pdev, 16, esp->command_block, |
---|
536 | | - esp->command_block_dma); |
---|
| 506 | + dma_free_coherent(&pdev->dev, 16, esp->command_block, |
---|
| 507 | + esp->command_block_dma); |
---|
537 | 508 | pci_iounmap(pdev, esp->regs); |
---|
538 | 509 | pci_release_regions(pdev); |
---|
539 | 510 | pci_disable_device(pdev); |
---|