| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | |
|---|
| 2 | 3 | /* |
|---|
| 3 | 4 | * Linux device driver for PCI based Prism54 |
|---|
| .. | .. |
|---|
| 7 | 8 | * |
|---|
| 8 | 9 | * Based on the islsm (softmac prism54) driver, which is: |
|---|
| 9 | 10 | * Copyright 2004-2006 Jean-Baptiste Note <jean-baptiste.note@m4x.org>, et al. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 12 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 13 | | - * published by the Free Software Foundation. |
|---|
| 14 | 11 | */ |
|---|
| 15 | 12 | |
|---|
| 16 | 13 | #include <linux/pci.h> |
|---|
| .. | .. |
|---|
| 156 | 153 | if (!skb) |
|---|
| 157 | 154 | break; |
|---|
| 158 | 155 | |
|---|
| 159 | | - mapping = pci_map_single(priv->pdev, |
|---|
| 156 | + mapping = dma_map_single(&priv->pdev->dev, |
|---|
| 160 | 157 | skb_tail_pointer(skb), |
|---|
| 161 | 158 | priv->common.rx_mtu + 32, |
|---|
| 162 | | - PCI_DMA_FROMDEVICE); |
|---|
| 159 | + DMA_FROM_DEVICE); |
|---|
| 163 | 160 | |
|---|
| 164 | | - if (pci_dma_mapping_error(priv->pdev, mapping)) { |
|---|
| 161 | + if (dma_mapping_error(&priv->pdev->dev, mapping)) { |
|---|
| 165 | 162 | dev_kfree_skb_any(skb); |
|---|
| 166 | 163 | dev_err(&priv->pdev->dev, |
|---|
| 167 | 164 | "RX DMA Mapping error\n"); |
|---|
| .. | .. |
|---|
| 218 | 215 | len = priv->common.rx_mtu; |
|---|
| 219 | 216 | } |
|---|
| 220 | 217 | dma_addr = le32_to_cpu(desc->host_addr); |
|---|
| 221 | | - pci_dma_sync_single_for_cpu(priv->pdev, dma_addr, |
|---|
| 222 | | - priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE); |
|---|
| 218 | + dma_sync_single_for_cpu(&priv->pdev->dev, dma_addr, |
|---|
| 219 | + priv->common.rx_mtu + 32, |
|---|
| 220 | + DMA_FROM_DEVICE); |
|---|
| 223 | 221 | skb_put(skb, len); |
|---|
| 224 | 222 | |
|---|
| 225 | 223 | if (p54_rx(dev, skb)) { |
|---|
| 226 | | - pci_unmap_single(priv->pdev, dma_addr, |
|---|
| 227 | | - priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE); |
|---|
| 224 | + dma_unmap_single(&priv->pdev->dev, dma_addr, |
|---|
| 225 | + priv->common.rx_mtu + 32, |
|---|
| 226 | + DMA_FROM_DEVICE); |
|---|
| 228 | 227 | rx_buf[i] = NULL; |
|---|
| 229 | 228 | desc->host_addr = cpu_to_le32(0); |
|---|
| 230 | 229 | } else { |
|---|
| 231 | 230 | skb_trim(skb, 0); |
|---|
| 232 | | - pci_dma_sync_single_for_device(priv->pdev, dma_addr, |
|---|
| 233 | | - priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE); |
|---|
| 231 | + dma_sync_single_for_device(&priv->pdev->dev, dma_addr, |
|---|
| 232 | + priv->common.rx_mtu + 32, |
|---|
| 233 | + DMA_FROM_DEVICE); |
|---|
| 234 | 234 | desc->len = cpu_to_le16(priv->common.rx_mtu + 32); |
|---|
| 235 | 235 | } |
|---|
| 236 | 236 | |
|---|
| .. | .. |
|---|
| 261 | 261 | skb = tx_buf[i]; |
|---|
| 262 | 262 | tx_buf[i] = NULL; |
|---|
| 263 | 263 | |
|---|
| 264 | | - pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr), |
|---|
| 265 | | - le16_to_cpu(desc->len), PCI_DMA_TODEVICE); |
|---|
| 264 | + dma_unmap_single(&priv->pdev->dev, |
|---|
| 265 | + le32_to_cpu(desc->host_addr), |
|---|
| 266 | + le16_to_cpu(desc->len), DMA_TO_DEVICE); |
|---|
| 266 | 267 | |
|---|
| 267 | 268 | desc->host_addr = 0; |
|---|
| 268 | 269 | desc->device_addr = 0; |
|---|
| .. | .. |
|---|
| 277 | 278 | } |
|---|
| 278 | 279 | } |
|---|
| 279 | 280 | |
|---|
| 280 | | -static void p54p_tasklet(unsigned long dev_id) |
|---|
| 281 | +static void p54p_tasklet(struct tasklet_struct *t) |
|---|
| 281 | 282 | { |
|---|
| 282 | | - struct ieee80211_hw *dev = (struct ieee80211_hw *)dev_id; |
|---|
| 283 | | - struct p54p_priv *priv = dev->priv; |
|---|
| 283 | + struct p54p_priv *priv = from_tasklet(priv, t, tasklet); |
|---|
| 284 | + struct ieee80211_hw *dev = pci_get_drvdata(priv->pdev); |
|---|
| 284 | 285 | struct p54p_ring_control *ring_control = priv->ring_control; |
|---|
| 285 | 286 | |
|---|
| 286 | 287 | p54p_check_tx_ring(dev, &priv->tx_idx_mgmt, 3, ring_control->tx_mgmt, |
|---|
| .. | .. |
|---|
| 339 | 340 | i = idx % ARRAY_SIZE(ring_control->tx_data); |
|---|
| 340 | 341 | device_addr = ((struct p54_hdr *)skb->data)->req_id; |
|---|
| 341 | 342 | |
|---|
| 342 | | - mapping = pci_map_single(priv->pdev, skb->data, skb->len, |
|---|
| 343 | | - PCI_DMA_TODEVICE); |
|---|
| 344 | | - if (pci_dma_mapping_error(priv->pdev, mapping)) { |
|---|
| 343 | + mapping = dma_map_single(&priv->pdev->dev, skb->data, skb->len, |
|---|
| 344 | + DMA_TO_DEVICE); |
|---|
| 345 | + if (dma_mapping_error(&priv->pdev->dev, mapping)) { |
|---|
| 345 | 346 | spin_unlock_irqrestore(&priv->lock, flags); |
|---|
| 346 | 347 | p54_free_skb(dev, skb); |
|---|
| 347 | 348 | dev_err(&priv->pdev->dev, "TX DMA mapping error\n"); |
|---|
| .. | .. |
|---|
| 383 | 384 | for (i = 0; i < ARRAY_SIZE(priv->rx_buf_data); i++) { |
|---|
| 384 | 385 | desc = &ring_control->rx_data[i]; |
|---|
| 385 | 386 | if (desc->host_addr) |
|---|
| 386 | | - pci_unmap_single(priv->pdev, |
|---|
| 387 | + dma_unmap_single(&priv->pdev->dev, |
|---|
| 387 | 388 | le32_to_cpu(desc->host_addr), |
|---|
| 388 | 389 | priv->common.rx_mtu + 32, |
|---|
| 389 | | - PCI_DMA_FROMDEVICE); |
|---|
| 390 | + DMA_FROM_DEVICE); |
|---|
| 390 | 391 | kfree_skb(priv->rx_buf_data[i]); |
|---|
| 391 | 392 | priv->rx_buf_data[i] = NULL; |
|---|
| 392 | 393 | } |
|---|
| .. | .. |
|---|
| 394 | 395 | for (i = 0; i < ARRAY_SIZE(priv->rx_buf_mgmt); i++) { |
|---|
| 395 | 396 | desc = &ring_control->rx_mgmt[i]; |
|---|
| 396 | 397 | if (desc->host_addr) |
|---|
| 397 | | - pci_unmap_single(priv->pdev, |
|---|
| 398 | + dma_unmap_single(&priv->pdev->dev, |
|---|
| 398 | 399 | le32_to_cpu(desc->host_addr), |
|---|
| 399 | 400 | priv->common.rx_mtu + 32, |
|---|
| 400 | | - PCI_DMA_FROMDEVICE); |
|---|
| 401 | + DMA_FROM_DEVICE); |
|---|
| 401 | 402 | kfree_skb(priv->rx_buf_mgmt[i]); |
|---|
| 402 | 403 | priv->rx_buf_mgmt[i] = NULL; |
|---|
| 403 | 404 | } |
|---|
| .. | .. |
|---|
| 405 | 406 | for (i = 0; i < ARRAY_SIZE(priv->tx_buf_data); i++) { |
|---|
| 406 | 407 | desc = &ring_control->tx_data[i]; |
|---|
| 407 | 408 | if (desc->host_addr) |
|---|
| 408 | | - pci_unmap_single(priv->pdev, |
|---|
| 409 | + dma_unmap_single(&priv->pdev->dev, |
|---|
| 409 | 410 | le32_to_cpu(desc->host_addr), |
|---|
| 410 | 411 | le16_to_cpu(desc->len), |
|---|
| 411 | | - PCI_DMA_TODEVICE); |
|---|
| 412 | + DMA_TO_DEVICE); |
|---|
| 412 | 413 | |
|---|
| 413 | 414 | p54_free_skb(dev, priv->tx_buf_data[i]); |
|---|
| 414 | 415 | priv->tx_buf_data[i] = NULL; |
|---|
| .. | .. |
|---|
| 417 | 418 | for (i = 0; i < ARRAY_SIZE(priv->tx_buf_mgmt); i++) { |
|---|
| 418 | 419 | desc = &ring_control->tx_mgmt[i]; |
|---|
| 419 | 420 | if (desc->host_addr) |
|---|
| 420 | | - pci_unmap_single(priv->pdev, |
|---|
| 421 | + dma_unmap_single(&priv->pdev->dev, |
|---|
| 421 | 422 | le32_to_cpu(desc->host_addr), |
|---|
| 422 | 423 | le16_to_cpu(desc->len), |
|---|
| 423 | | - PCI_DMA_TODEVICE); |
|---|
| 424 | + DMA_TO_DEVICE); |
|---|
| 424 | 425 | |
|---|
| 425 | 426 | p54_free_skb(dev, priv->tx_buf_mgmt[i]); |
|---|
| 426 | 427 | priv->tx_buf_mgmt[i] = NULL; |
|---|
| .. | .. |
|---|
| 573 | 574 | goto err_disable_dev; |
|---|
| 574 | 575 | } |
|---|
| 575 | 576 | |
|---|
| 576 | | - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
|---|
| 577 | + err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); |
|---|
| 577 | 578 | if (!err) |
|---|
| 578 | | - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
|---|
| 579 | + err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); |
|---|
| 579 | 580 | if (err) { |
|---|
| 580 | 581 | dev_err(&pdev->dev, "No suitable DMA available\n"); |
|---|
| 581 | 582 | goto err_free_reg; |
|---|
| .. | .. |
|---|
| 608 | 609 | goto err_free_dev; |
|---|
| 609 | 610 | } |
|---|
| 610 | 611 | |
|---|
| 611 | | - priv->ring_control = pci_alloc_consistent(pdev, sizeof(*priv->ring_control), |
|---|
| 612 | | - &priv->ring_control_dma); |
|---|
| 612 | + priv->ring_control = dma_alloc_coherent(&pdev->dev, |
|---|
| 613 | + sizeof(*priv->ring_control), |
|---|
| 614 | + &priv->ring_control_dma, GFP_KERNEL); |
|---|
| 613 | 615 | if (!priv->ring_control) { |
|---|
| 614 | 616 | dev_err(&pdev->dev, "Cannot allocate rings\n"); |
|---|
| 615 | 617 | err = -ENOMEM; |
|---|
| .. | .. |
|---|
| 620 | 622 | priv->common.tx = p54p_tx; |
|---|
| 621 | 623 | |
|---|
| 622 | 624 | spin_lock_init(&priv->lock); |
|---|
| 623 | | - tasklet_init(&priv->tasklet, p54p_tasklet, (unsigned long)dev); |
|---|
| 625 | + tasklet_setup(&priv->tasklet, p54p_tasklet); |
|---|
| 624 | 626 | |
|---|
| 625 | 627 | err = request_firmware_nowait(THIS_MODULE, 1, "isl3886pci", |
|---|
| 626 | 628 | &priv->pdev->dev, GFP_KERNEL, |
|---|
| .. | .. |
|---|
| 628 | 630 | if (!err) |
|---|
| 629 | 631 | return 0; |
|---|
| 630 | 632 | |
|---|
| 631 | | - pci_free_consistent(pdev, sizeof(*priv->ring_control), |
|---|
| 632 | | - priv->ring_control, priv->ring_control_dma); |
|---|
| 633 | + dma_free_coherent(&pdev->dev, sizeof(*priv->ring_control), |
|---|
| 634 | + priv->ring_control, priv->ring_control_dma); |
|---|
| 633 | 635 | |
|---|
| 634 | 636 | err_iounmap: |
|---|
| 635 | 637 | iounmap(priv->map); |
|---|
| .. | .. |
|---|
| 658 | 660 | wait_for_completion(&priv->fw_loaded); |
|---|
| 659 | 661 | p54_unregister_common(dev); |
|---|
| 660 | 662 | release_firmware(priv->firmware); |
|---|
| 661 | | - pci_free_consistent(pdev, sizeof(*priv->ring_control), |
|---|
| 662 | | - priv->ring_control, priv->ring_control_dma); |
|---|
| 663 | + dma_free_coherent(&pdev->dev, sizeof(*priv->ring_control), |
|---|
| 664 | + priv->ring_control, priv->ring_control_dma); |
|---|
| 663 | 665 | iounmap(priv->map); |
|---|
| 664 | 666 | pci_release_regions(pdev); |
|---|
| 665 | 667 | pci_disable_device(pdev); |
|---|