.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /****************************************************************************** |
---|
2 | 3 | |
---|
3 | 4 | Copyright(c) 2003 - 2006 Intel Corporation. All rights reserved. |
---|
.. | .. |
---|
8 | 9 | By Gerald Combs <gerald@ethereal.com> |
---|
9 | 10 | Copyright 1998 Gerald Combs |
---|
10 | 11 | |
---|
11 | | - This program is free software; you can redistribute it and/or modify it |
---|
12 | | - under the terms of version 2 of the GNU General Public License as |
---|
13 | | - published by the Free Software Foundation. |
---|
14 | | - |
---|
15 | | - This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | | - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
17 | | - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
18 | | - more details. |
---|
19 | | - |
---|
20 | | - You should have received a copy of the GNU General Public License along with |
---|
21 | | - this program; if not, write to the Free Software Foundation, Inc., 59 |
---|
22 | | - Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
23 | | - |
---|
24 | | - The full GNU General Public License is included in this distribution in the |
---|
25 | | - file called LICENSE. |
---|
26 | 12 | |
---|
27 | 13 | Contact Information: |
---|
28 | 14 | Intel Linux Wireless <ilw@linux.intel.com> |
---|
.. | .. |
---|
237 | 223 | int out, i, j, l; |
---|
238 | 224 | char c; |
---|
239 | 225 | |
---|
240 | | - out = snprintf(buf, count, "%08X", ofs); |
---|
| 226 | + out = scnprintf(buf, count, "%08X", ofs); |
---|
241 | 227 | |
---|
242 | 228 | for (l = 0, i = 0; i < 2; i++) { |
---|
243 | | - out += snprintf(buf + out, count - out, " "); |
---|
| 229 | + out += scnprintf(buf + out, count - out, " "); |
---|
244 | 230 | for (j = 0; j < 8 && l < len; j++, l++) |
---|
245 | | - out += snprintf(buf + out, count - out, "%02X ", |
---|
| 231 | + out += scnprintf(buf + out, count - out, "%02X ", |
---|
246 | 232 | data[(i * 8 + j)]); |
---|
247 | 233 | for (; j < 8; j++) |
---|
248 | | - out += snprintf(buf + out, count - out, " "); |
---|
| 234 | + out += scnprintf(buf + out, count - out, " "); |
---|
249 | 235 | } |
---|
250 | 236 | |
---|
251 | | - out += snprintf(buf + out, count - out, " "); |
---|
| 237 | + out += scnprintf(buf + out, count - out, " "); |
---|
252 | 238 | for (l = 0, i = 0; i < 2; i++) { |
---|
253 | | - out += snprintf(buf + out, count - out, " "); |
---|
| 239 | + out += scnprintf(buf + out, count - out, " "); |
---|
254 | 240 | for (j = 0; j < 8 && l < len; j++, l++) { |
---|
255 | 241 | c = data[(i * 8 + j)]; |
---|
256 | 242 | if (!isascii(c) || !isprint(c)) |
---|
257 | 243 | c = '.'; |
---|
258 | 244 | |
---|
259 | | - out += snprintf(buf + out, count - out, "%c", c); |
---|
| 245 | + out += scnprintf(buf + out, count - out, "%c", c); |
---|
260 | 246 | } |
---|
261 | 247 | |
---|
262 | 248 | for (; j < 8; j++) |
---|
263 | | - out += snprintf(buf + out, count - out, " "); |
---|
| 249 | + out += scnprintf(buf + out, count - out, " "); |
---|
264 | 250 | } |
---|
265 | 251 | |
---|
266 | 252 | return out; |
---|
.. | .. |
---|
1293 | 1279 | log_len = log_size / sizeof(*log); |
---|
1294 | 1280 | ipw_capture_event_log(priv, log_len, log); |
---|
1295 | 1281 | |
---|
1296 | | - len += snprintf(buf + len, PAGE_SIZE - len, "%08X", log_len); |
---|
| 1282 | + len += scnprintf(buf + len, PAGE_SIZE - len, "%08X", log_len); |
---|
1297 | 1283 | for (i = 0; i < log_len; i++) |
---|
1298 | | - len += snprintf(buf + len, PAGE_SIZE - len, |
---|
| 1284 | + len += scnprintf(buf + len, PAGE_SIZE - len, |
---|
1299 | 1285 | "\n%08X%08X%08X", |
---|
1300 | 1286 | log[i].time, log[i].event, log[i].data); |
---|
1301 | | - len += snprintf(buf + len, PAGE_SIZE - len, "\n"); |
---|
| 1287 | + len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); |
---|
1302 | 1288 | kfree(log); |
---|
1303 | 1289 | return len; |
---|
1304 | 1290 | } |
---|
.. | .. |
---|
1312 | 1298 | u32 len = 0, i; |
---|
1313 | 1299 | if (!priv->error) |
---|
1314 | 1300 | return 0; |
---|
1315 | | - len += snprintf(buf + len, PAGE_SIZE - len, |
---|
| 1301 | + len += scnprintf(buf + len, PAGE_SIZE - len, |
---|
1316 | 1302 | "%08lX%08X%08X%08X", |
---|
1317 | 1303 | priv->error->jiffies, |
---|
1318 | 1304 | priv->error->status, |
---|
1319 | 1305 | priv->error->config, priv->error->elem_len); |
---|
1320 | 1306 | for (i = 0; i < priv->error->elem_len; i++) |
---|
1321 | | - len += snprintf(buf + len, PAGE_SIZE - len, |
---|
| 1307 | + len += scnprintf(buf + len, PAGE_SIZE - len, |
---|
1322 | 1308 | "\n%08X%08X%08X%08X%08X%08X%08X", |
---|
1323 | 1309 | priv->error->elem[i].time, |
---|
1324 | 1310 | priv->error->elem[i].desc, |
---|
.. | .. |
---|
1328 | 1314 | priv->error->elem[i].link2, |
---|
1329 | 1315 | priv->error->elem[i].data); |
---|
1330 | 1316 | |
---|
1331 | | - len += snprintf(buf + len, PAGE_SIZE - len, |
---|
| 1317 | + len += scnprintf(buf + len, PAGE_SIZE - len, |
---|
1332 | 1318 | "\n%08X", priv->error->log_len); |
---|
1333 | 1319 | for (i = 0; i < priv->error->log_len; i++) |
---|
1334 | | - len += snprintf(buf + len, PAGE_SIZE - len, |
---|
| 1320 | + len += scnprintf(buf + len, PAGE_SIZE - len, |
---|
1335 | 1321 | "\n%08X%08X%08X", |
---|
1336 | 1322 | priv->error->log[i].time, |
---|
1337 | 1323 | priv->error->log[i].event, |
---|
1338 | 1324 | priv->error->log[i].data); |
---|
1339 | | - len += snprintf(buf + len, PAGE_SIZE - len, "\n"); |
---|
| 1325 | + len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); |
---|
1340 | 1326 | return len; |
---|
1341 | 1327 | } |
---|
1342 | 1328 | |
---|
.. | .. |
---|
1364 | 1350 | (i != priv->cmdlog_pos) && (len < PAGE_SIZE); |
---|
1365 | 1351 | i = (i + 1) % priv->cmdlog_len) { |
---|
1366 | 1352 | len += |
---|
1367 | | - snprintf(buf + len, PAGE_SIZE - len, |
---|
| 1353 | + scnprintf(buf + len, PAGE_SIZE - len, |
---|
1368 | 1354 | "\n%08lX%08X%08X%08X\n", priv->cmdlog[i].jiffies, |
---|
1369 | 1355 | priv->cmdlog[i].retcode, priv->cmdlog[i].cmd.cmd, |
---|
1370 | 1356 | priv->cmdlog[i].cmd.len); |
---|
.. | .. |
---|
1372 | 1358 | snprintk_buf(buf + len, PAGE_SIZE - len, |
---|
1373 | 1359 | (u8 *) priv->cmdlog[i].cmd.param, |
---|
1374 | 1360 | priv->cmdlog[i].cmd.len); |
---|
1375 | | - len += snprintf(buf + len, PAGE_SIZE - len, "\n"); |
---|
| 1361 | + len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); |
---|
1376 | 1362 | } |
---|
1377 | | - len += snprintf(buf + len, PAGE_SIZE - len, "\n"); |
---|
| 1363 | + len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); |
---|
1378 | 1364 | return len; |
---|
1379 | 1365 | } |
---|
1380 | 1366 | |
---|
.. | .. |
---|
1959 | 1945 | wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); |
---|
1960 | 1946 | } |
---|
1961 | 1947 | |
---|
1962 | | -static void ipw_irq_tasklet(unsigned long data) |
---|
| 1948 | +static void ipw_irq_tasklet(struct tasklet_struct *t) |
---|
1963 | 1949 | { |
---|
1964 | | - struct ipw_priv *priv = (struct ipw_priv *)data; |
---|
| 1950 | + struct ipw_priv *priv = from_tasklet(priv, t, irq_tasklet); |
---|
1965 | 1951 | u32 inta, inta_mask, handled = 0; |
---|
1966 | 1952 | unsigned long flags; |
---|
1967 | | - int rc = 0; |
---|
1968 | 1953 | |
---|
1969 | 1954 | spin_lock_irqsave(&priv->irq_lock, flags); |
---|
1970 | 1955 | |
---|
.. | .. |
---|
1994 | 1979 | |
---|
1995 | 1980 | if (inta & IPW_INTA_BIT_TX_CMD_QUEUE) { |
---|
1996 | 1981 | IPW_DEBUG_HC("Command completed.\n"); |
---|
1997 | | - rc = ipw_queue_tx_reclaim(priv, &priv->txq_cmd, -1); |
---|
| 1982 | + ipw_queue_tx_reclaim(priv, &priv->txq_cmd, -1); |
---|
1998 | 1983 | priv->status &= ~STATUS_HCMD_ACTIVE; |
---|
1999 | 1984 | wake_up_interruptible(&priv->wait_command_queue); |
---|
2000 | 1985 | handled |= IPW_INTA_BIT_TX_CMD_QUEUE; |
---|
.. | .. |
---|
2002 | 1987 | |
---|
2003 | 1988 | if (inta & IPW_INTA_BIT_TX_QUEUE_1) { |
---|
2004 | 1989 | IPW_DEBUG_TX("TX_QUEUE_1\n"); |
---|
2005 | | - rc = ipw_queue_tx_reclaim(priv, &priv->txq[0], 0); |
---|
| 1990 | + ipw_queue_tx_reclaim(priv, &priv->txq[0], 0); |
---|
2006 | 1991 | handled |= IPW_INTA_BIT_TX_QUEUE_1; |
---|
2007 | 1992 | } |
---|
2008 | 1993 | |
---|
2009 | 1994 | if (inta & IPW_INTA_BIT_TX_QUEUE_2) { |
---|
2010 | 1995 | IPW_DEBUG_TX("TX_QUEUE_2\n"); |
---|
2011 | | - rc = ipw_queue_tx_reclaim(priv, &priv->txq[1], 1); |
---|
| 1996 | + ipw_queue_tx_reclaim(priv, &priv->txq[1], 1); |
---|
2012 | 1997 | handled |= IPW_INTA_BIT_TX_QUEUE_2; |
---|
2013 | 1998 | } |
---|
2014 | 1999 | |
---|
2015 | 2000 | if (inta & IPW_INTA_BIT_TX_QUEUE_3) { |
---|
2016 | 2001 | IPW_DEBUG_TX("TX_QUEUE_3\n"); |
---|
2017 | | - rc = ipw_queue_tx_reclaim(priv, &priv->txq[2], 2); |
---|
| 2002 | + ipw_queue_tx_reclaim(priv, &priv->txq[2], 2); |
---|
2018 | 2003 | handled |= IPW_INTA_BIT_TX_QUEUE_3; |
---|
2019 | 2004 | } |
---|
2020 | 2005 | |
---|
2021 | 2006 | if (inta & IPW_INTA_BIT_TX_QUEUE_4) { |
---|
2022 | 2007 | IPW_DEBUG_TX("TX_QUEUE_4\n"); |
---|
2023 | | - rc = ipw_queue_tx_reclaim(priv, &priv->txq[3], 3); |
---|
| 2008 | + ipw_queue_tx_reclaim(priv, &priv->txq[3], 3); |
---|
2024 | 2009 | handled |= IPW_INTA_BIT_TX_QUEUE_4; |
---|
2025 | 2010 | } |
---|
2026 | 2011 | |
---|
.. | .. |
---|
2736 | 2721 | /* Do not load eeprom data on fatal error or suspend */ |
---|
2737 | 2722 | ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 0); |
---|
2738 | 2723 | } else { |
---|
2739 | | - IPW_DEBUG_INFO("Enabling FW initializationg of SRAM\n"); |
---|
| 2724 | + IPW_DEBUG_INFO("Enabling FW initialization of SRAM\n"); |
---|
2740 | 2725 | |
---|
2741 | 2726 | /* Load eeprom data on fatal error or suspend */ |
---|
2742 | 2727 | ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 1); |
---|
.. | .. |
---|
3013 | 2998 | spin_unlock_irqrestore(&priv->ieee->lock, flags); |
---|
3014 | 2999 | } |
---|
3015 | 3000 | |
---|
3016 | | -/** |
---|
| 3001 | +/* |
---|
3017 | 3002 | * Check that card is still alive. |
---|
3018 | 3003 | * Reads debug register from domain0. |
---|
3019 | 3004 | * If card is present, pre-defined value should |
---|
.. | .. |
---|
3128 | 3113 | mdelay(1); |
---|
3129 | 3114 | |
---|
3130 | 3115 | /* write ucode */ |
---|
3131 | | - /** |
---|
| 3116 | + /* |
---|
3132 | 3117 | * @bug |
---|
3133 | 3118 | * Do NOT set indirect address register once and then |
---|
3134 | 3119 | * store data to indirect data register in the loop. |
---|
.. | .. |
---|
3400 | 3385 | __le32 boot_size; |
---|
3401 | 3386 | __le32 ucode_size; |
---|
3402 | 3387 | __le32 fw_size; |
---|
3403 | | - u8 data[0]; |
---|
| 3388 | + u8 data[]; |
---|
3404 | 3389 | }; |
---|
3405 | 3390 | |
---|
3406 | 3391 | static int ipw_get_fw(struct ipw_priv *priv, |
---|
.. | .. |
---|
3456 | 3441 | /* In the reset function, these buffers may have been allocated |
---|
3457 | 3442 | * to an SKB, so we need to unmap and free potential storage */ |
---|
3458 | 3443 | if (rxq->pool[i].skb != NULL) { |
---|
3459 | | - pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr, |
---|
3460 | | - IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); |
---|
3461 | | - dev_kfree_skb(rxq->pool[i].skb); |
---|
| 3444 | + dma_unmap_single(&priv->pci_dev->dev, |
---|
| 3445 | + rxq->pool[i].dma_addr, |
---|
| 3446 | + IPW_RX_BUF_SIZE, DMA_FROM_DEVICE); |
---|
| 3447 | + dev_kfree_skb_irq(rxq->pool[i].skb); |
---|
3462 | 3448 | rxq->pool[i].skb = NULL; |
---|
3463 | 3449 | } |
---|
3464 | 3450 | list_add_tail(&rxq->pool[i].list, &rxq->rx_used); |
---|
.. | .. |
---|
3680 | 3666 | return rc; |
---|
3681 | 3667 | } |
---|
3682 | 3668 | |
---|
3683 | | -/** |
---|
| 3669 | +/* |
---|
3684 | 3670 | * DMA services |
---|
3685 | 3671 | * |
---|
3686 | 3672 | * Theory of operation |
---|
.. | .. |
---|
3703 | 3689 | * we only utilize the first data transmit queue (queue1). |
---|
3704 | 3690 | */ |
---|
3705 | 3691 | |
---|
3706 | | -/** |
---|
| 3692 | +/* |
---|
3707 | 3693 | * Driver allocates buffers of this size for Rx |
---|
3708 | 3694 | */ |
---|
3709 | 3695 | |
---|
3710 | | -/** |
---|
| 3696 | +/* |
---|
3711 | 3697 | * ipw_rx_queue_space - Return number of free slots available in queue. |
---|
3712 | 3698 | */ |
---|
3713 | 3699 | static int ipw_rx_queue_space(const struct ipw_rx_queue *q) |
---|
.. | .. |
---|
3738 | 3724 | return (++index == n_bd) ? 0 : index; |
---|
3739 | 3725 | } |
---|
3740 | 3726 | |
---|
3741 | | -/** |
---|
| 3727 | +/* |
---|
3742 | 3728 | * Initialize common DMA queue structure |
---|
3743 | 3729 | * |
---|
3744 | 3730 | * @param q queue to init |
---|
.. | .. |
---|
3784 | 3770 | struct pci_dev *dev = priv->pci_dev; |
---|
3785 | 3771 | |
---|
3786 | 3772 | q->txb = kmalloc_array(count, sizeof(q->txb[0]), GFP_KERNEL); |
---|
3787 | | - if (!q->txb) { |
---|
3788 | | - IPW_ERROR("vmalloc for auxiliary BD structures failed\n"); |
---|
| 3773 | + if (!q->txb) |
---|
3789 | 3774 | return -ENOMEM; |
---|
3790 | | - } |
---|
3791 | 3775 | |
---|
3792 | 3776 | q->bd = |
---|
3793 | | - pci_alloc_consistent(dev, sizeof(q->bd[0]) * count, &q->q.dma_addr); |
---|
| 3777 | + dma_alloc_coherent(&dev->dev, sizeof(q->bd[0]) * count, |
---|
| 3778 | + &q->q.dma_addr, GFP_KERNEL); |
---|
3794 | 3779 | if (!q->bd) { |
---|
3795 | 3780 | IPW_ERROR("pci_alloc_consistent(%zd) failed\n", |
---|
3796 | 3781 | sizeof(q->bd[0]) * count); |
---|
.. | .. |
---|
3803 | 3788 | return 0; |
---|
3804 | 3789 | } |
---|
3805 | 3790 | |
---|
3806 | | -/** |
---|
| 3791 | +/* |
---|
3807 | 3792 | * Free one TFD, those at index [txq->q.last_used]. |
---|
3808 | 3793 | * Do NOT advance any indexes |
---|
3809 | 3794 | * |
---|
.. | .. |
---|
3826 | 3811 | if (le32_to_cpu(bd->u.data.num_chunks) > NUM_TFD_CHUNKS) { |
---|
3827 | 3812 | IPW_ERROR("Too many chunks: %i\n", |
---|
3828 | 3813 | le32_to_cpu(bd->u.data.num_chunks)); |
---|
3829 | | - /** @todo issue fatal error, it is quite serious situation */ |
---|
| 3814 | + /* @todo issue fatal error, it is quite serious situation */ |
---|
3830 | 3815 | return; |
---|
3831 | 3816 | } |
---|
3832 | 3817 | |
---|
3833 | 3818 | /* unmap chunks if any */ |
---|
3834 | 3819 | for (i = 0; i < le32_to_cpu(bd->u.data.num_chunks); i++) { |
---|
3835 | | - pci_unmap_single(dev, le32_to_cpu(bd->u.data.chunk_ptr[i]), |
---|
| 3820 | + dma_unmap_single(&dev->dev, |
---|
| 3821 | + le32_to_cpu(bd->u.data.chunk_ptr[i]), |
---|
3836 | 3822 | le16_to_cpu(bd->u.data.chunk_len[i]), |
---|
3837 | | - PCI_DMA_TODEVICE); |
---|
| 3823 | + DMA_TO_DEVICE); |
---|
3838 | 3824 | if (txq->txb[txq->q.last_used]) { |
---|
3839 | 3825 | libipw_txb_free(txq->txb[txq->q.last_used]); |
---|
3840 | 3826 | txq->txb[txq->q.last_used] = NULL; |
---|
.. | .. |
---|
3842 | 3828 | } |
---|
3843 | 3829 | } |
---|
3844 | 3830 | |
---|
3845 | | -/** |
---|
| 3831 | +/* |
---|
3846 | 3832 | * Deallocate DMA queue. |
---|
3847 | 3833 | * |
---|
3848 | 3834 | * Empty queue by removing and destroying all BD's. |
---|
.. | .. |
---|
3866 | 3852 | } |
---|
3867 | 3853 | |
---|
3868 | 3854 | /* free buffers belonging to queue itself */ |
---|
3869 | | - pci_free_consistent(dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd, |
---|
3870 | | - q->dma_addr); |
---|
| 3855 | + dma_free_coherent(&dev->dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd, |
---|
| 3856 | + q->dma_addr); |
---|
3871 | 3857 | kfree(txq->txb); |
---|
3872 | 3858 | |
---|
3873 | 3859 | /* 0 fill whole structure */ |
---|
3874 | 3860 | memset(txq, 0, sizeof(*txq)); |
---|
3875 | 3861 | } |
---|
3876 | 3862 | |
---|
3877 | | -/** |
---|
| 3863 | +/* |
---|
3878 | 3864 | * Destroy all DMA queues and structures |
---|
3879 | 3865 | * |
---|
3880 | 3866 | * @param priv |
---|
.. | .. |
---|
4479 | 4465 | } |
---|
4480 | 4466 | } |
---|
4481 | 4467 | |
---|
4482 | | -/** |
---|
| 4468 | +/* |
---|
4483 | 4469 | * Handle host notification packet. |
---|
4484 | 4470 | * Called from interrupt routine |
---|
4485 | 4471 | */ |
---|
.. | .. |
---|
4939 | 4925 | } |
---|
4940 | 4926 | } |
---|
4941 | 4927 | |
---|
4942 | | -/** |
---|
| 4928 | +/* |
---|
4943 | 4929 | * Destroys all DMA structures and initialise them again |
---|
4944 | 4930 | * |
---|
4945 | 4931 | * @param priv |
---|
.. | .. |
---|
4948 | 4934 | static int ipw_queue_reset(struct ipw_priv *priv) |
---|
4949 | 4935 | { |
---|
4950 | 4936 | int rc = 0; |
---|
4951 | | - /** @todo customize queue sizes */ |
---|
| 4937 | + /* @todo customize queue sizes */ |
---|
4952 | 4938 | int nTx = 64, nTxCmd = 8; |
---|
4953 | 4939 | ipw_tx_queue_free(priv); |
---|
4954 | 4940 | /* Tx CMD queue */ |
---|
.. | .. |
---|
5004 | 4990 | return rc; |
---|
5005 | 4991 | } |
---|
5006 | 4992 | |
---|
5007 | | -/** |
---|
| 4993 | +/* |
---|
5008 | 4994 | * Reclaim Tx queue entries no more used by NIC. |
---|
5009 | 4995 | * |
---|
5010 | 4996 | * When FW advances 'R' index, all entries between old and |
---|
.. | .. |
---|
5212 | 5198 | list_del(element); |
---|
5213 | 5199 | |
---|
5214 | 5200 | rxb->dma_addr = |
---|
5215 | | - pci_map_single(priv->pci_dev, rxb->skb->data, |
---|
5216 | | - IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); |
---|
| 5201 | + dma_map_single(&priv->pci_dev->dev, rxb->skb->data, |
---|
| 5202 | + IPW_RX_BUF_SIZE, DMA_FROM_DEVICE); |
---|
5217 | 5203 | |
---|
5218 | 5204 | list_add_tail(&rxb->list, &rxq->rx_free); |
---|
5219 | 5205 | rxq->free_count++; |
---|
.. | .. |
---|
5246 | 5232 | |
---|
5247 | 5233 | for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { |
---|
5248 | 5234 | if (rxq->pool[i].skb != NULL) { |
---|
5249 | | - pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr, |
---|
5250 | | - IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); |
---|
| 5235 | + dma_unmap_single(&priv->pci_dev->dev, |
---|
| 5236 | + rxq->pool[i].dma_addr, |
---|
| 5237 | + IPW_RX_BUF_SIZE, DMA_FROM_DEVICE); |
---|
5251 | 5238 | dev_kfree_skb(rxq->pool[i].skb); |
---|
5252 | 5239 | } |
---|
5253 | 5240 | } |
---|
.. | .. |
---|
5653 | 5640 | } |
---|
5654 | 5641 | |
---|
5655 | 5642 | mutex_lock(&priv->mutex); |
---|
5656 | | - if ((priv->ieee->iw_mode == IW_MODE_ADHOC)) { |
---|
| 5643 | + if (priv->ieee->iw_mode == IW_MODE_ADHOC) { |
---|
5657 | 5644 | IPW_DEBUG_MERGE("remove network %*pE\n", |
---|
5658 | 5645 | priv->essid_len, priv->essid); |
---|
5659 | 5646 | ipw_remove_current_network(priv); |
---|
.. | .. |
---|
6803 | 6790 | { |
---|
6804 | 6791 | struct ipw_priv *priv = libipw_priv(dev); |
---|
6805 | 6792 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
---|
6806 | | - __le16 reason; |
---|
6807 | | - |
---|
6808 | | - reason = cpu_to_le16(mlme->reason_code); |
---|
6809 | 6793 | |
---|
6810 | 6794 | switch (mlme->cmd) { |
---|
6811 | 6795 | case IW_MLME_DEAUTH: |
---|
.. | .. |
---|
7059 | 7043 | * off the network from the associated setting, adjust the QoS |
---|
7060 | 7044 | * setting |
---|
7061 | 7045 | */ |
---|
7062 | | -static int ipw_qos_association_resp(struct ipw_priv *priv, |
---|
| 7046 | +static void ipw_qos_association_resp(struct ipw_priv *priv, |
---|
7063 | 7047 | struct libipw_network *network) |
---|
7064 | 7048 | { |
---|
7065 | | - int ret = 0; |
---|
7066 | 7049 | unsigned long flags; |
---|
7067 | 7050 | u32 size = sizeof(struct libipw_qos_parameters); |
---|
7068 | 7051 | int set_qos_param = 0; |
---|
7069 | 7052 | |
---|
7070 | 7053 | if ((priv == NULL) || (network == NULL) || |
---|
7071 | 7054 | (priv->assoc_network == NULL)) |
---|
7072 | | - return ret; |
---|
| 7055 | + return; |
---|
7073 | 7056 | |
---|
7074 | 7057 | if (!(priv->status & STATUS_ASSOCIATED)) |
---|
7075 | | - return ret; |
---|
| 7058 | + return; |
---|
7076 | 7059 | |
---|
7077 | 7060 | if ((priv->ieee->iw_mode != IW_MODE_INFRA)) |
---|
7078 | | - return ret; |
---|
| 7061 | + return; |
---|
7079 | 7062 | |
---|
7080 | 7063 | spin_lock_irqsave(&priv->ieee->lock, flags); |
---|
7081 | 7064 | if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { |
---|
.. | .. |
---|
7105 | 7088 | |
---|
7106 | 7089 | if (set_qos_param == 1) |
---|
7107 | 7090 | schedule_work(&priv->qos_activate); |
---|
7108 | | - |
---|
7109 | | - return ret; |
---|
7110 | 7091 | } |
---|
7111 | 7092 | |
---|
7112 | 7093 | static u32 ipw_qos_get_burst_duration(struct ipw_priv *priv) |
---|
.. | .. |
---|
8266 | 8247 | struct ipw_rx_mem_buffer *rxb; |
---|
8267 | 8248 | struct ipw_rx_packet *pkt; |
---|
8268 | 8249 | struct libipw_hdr_4addr *header; |
---|
8269 | | - u32 r, w, i; |
---|
| 8250 | + u32 r, i; |
---|
8270 | 8251 | u8 network_packet; |
---|
8271 | 8252 | u8 fill_rx = 0; |
---|
8272 | 8253 | |
---|
8273 | 8254 | r = ipw_read32(priv, IPW_RX_READ_INDEX); |
---|
8274 | | - w = ipw_read32(priv, IPW_RX_WRITE_INDEX); |
---|
| 8255 | + ipw_read32(priv, IPW_RX_WRITE_INDEX); |
---|
8275 | 8256 | i = priv->rxq->read; |
---|
8276 | 8257 | |
---|
8277 | 8258 | if (ipw_rx_queue_space (priv->rxq) > (RX_QUEUE_SIZE / 2)) |
---|
.. | .. |
---|
8285 | 8266 | } |
---|
8286 | 8267 | priv->rxq->queue[i] = NULL; |
---|
8287 | 8268 | |
---|
8288 | | - pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr, |
---|
8289 | | - IPW_RX_BUF_SIZE, |
---|
8290 | | - PCI_DMA_FROMDEVICE); |
---|
| 8269 | + dma_sync_single_for_cpu(&priv->pci_dev->dev, rxb->dma_addr, |
---|
| 8270 | + IPW_RX_BUF_SIZE, DMA_FROM_DEVICE); |
---|
8291 | 8271 | |
---|
8292 | 8272 | pkt = (struct ipw_rx_packet *)rxb->skb->data; |
---|
8293 | 8273 | IPW_DEBUG_RX("Packet: type=%02X seq=%02X bits=%02X\n", |
---|
.. | .. |
---|
8439 | 8419 | rxb->skb = NULL; |
---|
8440 | 8420 | } |
---|
8441 | 8421 | |
---|
8442 | | - pci_unmap_single(priv->pci_dev, rxb->dma_addr, |
---|
8443 | | - IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); |
---|
| 8422 | + dma_unmap_single(&priv->pci_dev->dev, rxb->dma_addr, |
---|
| 8423 | + IPW_RX_BUF_SIZE, DMA_FROM_DEVICE); |
---|
8444 | 8424 | list_add_tail(&rxb->list, &priv->rxq->rx_used); |
---|
8445 | 8425 | |
---|
8446 | 8426 | i = (i + 1) % RX_QUEUE_SIZE; |
---|
.. | .. |
---|
8465 | 8445 | #define DEFAULT_SHORT_RETRY_LIMIT 7U |
---|
8466 | 8446 | #define DEFAULT_LONG_RETRY_LIMIT 4U |
---|
8467 | 8447 | |
---|
8468 | | -/** |
---|
| 8448 | +/* |
---|
8469 | 8449 | * ipw_sw_reset |
---|
8470 | 8450 | * @option: options to control different reset behaviour |
---|
8471 | 8451 | * 0 = reset everything except the 'disable' module_param |
---|
.. | .. |
---|
9625 | 9605 | int level = IPW_POWER_LEVEL(priv->power_mode); |
---|
9626 | 9606 | char *p = extra; |
---|
9627 | 9607 | |
---|
9628 | | - p += snprintf(p, MAX_WX_STRING, "Power save level: %d ", level); |
---|
| 9608 | + p += scnprintf(p, MAX_WX_STRING, "Power save level: %d ", level); |
---|
9629 | 9609 | |
---|
9630 | 9610 | switch (level) { |
---|
9631 | 9611 | case IPW_POWER_AC: |
---|
9632 | | - p += snprintf(p, MAX_WX_STRING - (p - extra), "(AC)"); |
---|
| 9612 | + p += scnprintf(p, MAX_WX_STRING - (p - extra), "(AC)"); |
---|
9633 | 9613 | break; |
---|
9634 | 9614 | case IPW_POWER_BATTERY: |
---|
9635 | | - p += snprintf(p, MAX_WX_STRING - (p - extra), "(BATTERY)"); |
---|
| 9615 | + p += scnprintf(p, MAX_WX_STRING - (p - extra), "(BATTERY)"); |
---|
9636 | 9616 | break; |
---|
9637 | 9617 | default: |
---|
9638 | | - p += snprintf(p, MAX_WX_STRING - (p - extra), |
---|
| 9618 | + p += scnprintf(p, MAX_WX_STRING - (p - extra), |
---|
9639 | 9619 | "(Timeout %dms, Period %dms)", |
---|
9640 | 9620 | timeout_duration[level - 1] / 1000, |
---|
9641 | 9621 | period_duration[level - 1] / 1000); |
---|
9642 | 9622 | } |
---|
9643 | 9623 | |
---|
9644 | 9624 | if (!(priv->power_mode & IPW_POWER_ENABLED)) |
---|
9645 | | - p += snprintf(p, MAX_WX_STRING - (p - extra), " OFF"); |
---|
| 9625 | + p += scnprintf(p, MAX_WX_STRING - (p - extra), " OFF"); |
---|
9646 | 9626 | |
---|
9647 | 9627 | wrqu->data.length = p - extra + 1; |
---|
9648 | 9628 | |
---|
.. | .. |
---|
10239 | 10219 | txb->fragments[i]->len - hdr_len); |
---|
10240 | 10220 | |
---|
10241 | 10221 | tfd->u.data.chunk_ptr[i] = |
---|
10242 | | - cpu_to_le32(pci_map_single |
---|
10243 | | - (priv->pci_dev, |
---|
10244 | | - txb->fragments[i]->data + hdr_len, |
---|
10245 | | - txb->fragments[i]->len - hdr_len, |
---|
10246 | | - PCI_DMA_TODEVICE)); |
---|
| 10222 | + cpu_to_le32(dma_map_single(&priv->pci_dev->dev, |
---|
| 10223 | + txb->fragments[i]->data + hdr_len, |
---|
| 10224 | + txb->fragments[i]->len - hdr_len, |
---|
| 10225 | + DMA_TO_DEVICE)); |
---|
10247 | 10226 | tfd->u.data.chunk_len[i] = |
---|
10248 | 10227 | cpu_to_le16(txb->fragments[i]->len - hdr_len); |
---|
10249 | 10228 | } |
---|
.. | .. |
---|
10273 | 10252 | dev_kfree_skb_any(txb->fragments[i]); |
---|
10274 | 10253 | txb->fragments[i] = skb; |
---|
10275 | 10254 | tfd->u.data.chunk_ptr[i] = |
---|
10276 | | - cpu_to_le32(pci_map_single |
---|
10277 | | - (priv->pci_dev, skb->data, |
---|
10278 | | - remaining_bytes, |
---|
10279 | | - PCI_DMA_TODEVICE)); |
---|
| 10255 | + cpu_to_le32(dma_map_single(&priv->pci_dev->dev, |
---|
| 10256 | + skb->data, |
---|
| 10257 | + remaining_bytes, |
---|
| 10258 | + DMA_TO_DEVICE)); |
---|
10280 | 10259 | |
---|
10281 | 10260 | le32_add_cpu(&tfd->u.data.num_chunks, 1); |
---|
10282 | 10261 | } |
---|
.. | .. |
---|
10660 | 10639 | mutex_unlock(&priv->mutex); |
---|
10661 | 10640 | } |
---|
10662 | 10641 | |
---|
10663 | | -static int ipw_setup_deferred_work(struct ipw_priv *priv) |
---|
| 10642 | +static void ipw_setup_deferred_work(struct ipw_priv *priv) |
---|
10664 | 10643 | { |
---|
10665 | | - int ret = 0; |
---|
10666 | | - |
---|
10667 | 10644 | init_waitqueue_head(&priv->wait_command_queue); |
---|
10668 | 10645 | init_waitqueue_head(&priv->wait_state); |
---|
10669 | 10646 | |
---|
.. | .. |
---|
10695 | 10672 | INIT_WORK(&priv->qos_activate, ipw_bg_qos_activate); |
---|
10696 | 10673 | #endif /* CONFIG_IPW2200_QOS */ |
---|
10697 | 10674 | |
---|
10698 | | - tasklet_init(&priv->irq_tasklet, |
---|
10699 | | - ipw_irq_tasklet, (unsigned long)priv); |
---|
10700 | | - |
---|
10701 | | - return ret; |
---|
| 10675 | + tasklet_setup(&priv->irq_tasklet, ipw_irq_tasklet); |
---|
10702 | 10676 | } |
---|
10703 | 10677 | |
---|
10704 | 10678 | static void shim__set_security(struct net_device *dev, |
---|
.. | .. |
---|
10723 | 10697 | } |
---|
10724 | 10698 | |
---|
10725 | 10699 | if (sec->flags & SEC_ACTIVE_KEY) { |
---|
10726 | | - if (sec->active_key <= 3) { |
---|
10727 | | - priv->ieee->sec.active_key = sec->active_key; |
---|
10728 | | - priv->ieee->sec.flags |= SEC_ACTIVE_KEY; |
---|
10729 | | - } else |
---|
10730 | | - priv->ieee->sec.flags &= ~SEC_ACTIVE_KEY; |
---|
| 10700 | + priv->ieee->sec.active_key = sec->active_key; |
---|
| 10701 | + priv->ieee->sec.flags |= SEC_ACTIVE_KEY; |
---|
10731 | 10702 | priv->status |= STATUS_SECURITY_UPDATED; |
---|
10732 | 10703 | } else |
---|
10733 | 10704 | priv->ieee->sec.flags &= ~SEC_ACTIVE_KEY; |
---|
.. | .. |
---|
11429 | 11400 | set_wiphy_dev(wdev->wiphy, &priv->pci_dev->dev); |
---|
11430 | 11401 | |
---|
11431 | 11402 | /* With that information in place, we can now register the wiphy... */ |
---|
11432 | | - if (wiphy_register(wdev->wiphy)) |
---|
11433 | | - rc = -EIO; |
---|
| 11403 | + rc = wiphy_register(wdev->wiphy); |
---|
| 11404 | + if (rc) |
---|
| 11405 | + goto out; |
---|
| 11406 | + |
---|
| 11407 | + return 0; |
---|
11434 | 11408 | out: |
---|
| 11409 | + kfree(priv->ieee->a_band.channels); |
---|
| 11410 | + kfree(priv->ieee->bg_band.channels); |
---|
11435 | 11411 | return rc; |
---|
11436 | 11412 | } |
---|
11437 | 11413 | |
---|
.. | .. |
---|
11649 | 11625 | |
---|
11650 | 11626 | pci_set_master(pdev); |
---|
11651 | 11627 | |
---|
11652 | | - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
---|
| 11628 | + err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); |
---|
11653 | 11629 | if (!err) |
---|
11654 | | - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
---|
| 11630 | + err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); |
---|
11655 | 11631 | if (err) { |
---|
11656 | 11632 | printk(KERN_WARNING DRV_NAME ": No suitable DMA available.\n"); |
---|
11657 | 11633 | goto out_pci_disable_device; |
---|
.. | .. |
---|
11682 | 11658 | IPW_DEBUG_INFO("pci_resource_len = 0x%08x\n", length); |
---|
11683 | 11659 | IPW_DEBUG_INFO("pci_resource_base = %p\n", base); |
---|
11684 | 11660 | |
---|
11685 | | - err = ipw_setup_deferred_work(priv); |
---|
11686 | | - if (err) { |
---|
11687 | | - IPW_ERROR("Unable to setup deferred work\n"); |
---|
11688 | | - goto out_iounmap; |
---|
11689 | | - } |
---|
| 11661 | + ipw_setup_deferred_work(priv); |
---|
11690 | 11662 | |
---|
11691 | 11663 | ipw_sw_reset(priv, 1); |
---|
11692 | 11664 | |
---|
.. | .. |
---|
11871 | 11843 | free_firmware(); |
---|
11872 | 11844 | } |
---|
11873 | 11845 | |
---|
11874 | | -#ifdef CONFIG_PM |
---|
11875 | | -static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state) |
---|
| 11846 | +static int __maybe_unused ipw_pci_suspend(struct device *dev_d) |
---|
11876 | 11847 | { |
---|
11877 | | - struct ipw_priv *priv = pci_get_drvdata(pdev); |
---|
| 11848 | + struct ipw_priv *priv = dev_get_drvdata(dev_d); |
---|
11878 | 11849 | struct net_device *dev = priv->net_dev; |
---|
11879 | 11850 | |
---|
11880 | 11851 | printk(KERN_INFO "%s: Going into suspend...\n", dev->name); |
---|
.. | .. |
---|
11885 | 11856 | /* Remove the PRESENT state of the device */ |
---|
11886 | 11857 | netif_device_detach(dev); |
---|
11887 | 11858 | |
---|
11888 | | - pci_save_state(pdev); |
---|
11889 | | - pci_disable_device(pdev); |
---|
11890 | | - pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
---|
11891 | | - |
---|
11892 | 11859 | priv->suspend_at = ktime_get_boottime_seconds(); |
---|
11893 | 11860 | |
---|
11894 | 11861 | return 0; |
---|
11895 | 11862 | } |
---|
11896 | 11863 | |
---|
11897 | | -static int ipw_pci_resume(struct pci_dev *pdev) |
---|
| 11864 | +static int __maybe_unused ipw_pci_resume(struct device *dev_d) |
---|
11898 | 11865 | { |
---|
| 11866 | + struct pci_dev *pdev = to_pci_dev(dev_d); |
---|
11899 | 11867 | struct ipw_priv *priv = pci_get_drvdata(pdev); |
---|
11900 | 11868 | struct net_device *dev = priv->net_dev; |
---|
11901 | | - int err; |
---|
11902 | 11869 | u32 val; |
---|
11903 | 11870 | |
---|
11904 | 11871 | printk(KERN_INFO "%s: Coming out of suspend...\n", dev->name); |
---|
11905 | | - |
---|
11906 | | - pci_set_power_state(pdev, PCI_D0); |
---|
11907 | | - err = pci_enable_device(pdev); |
---|
11908 | | - if (err) { |
---|
11909 | | - printk(KERN_ERR "%s: pci_enable_device failed on resume\n", |
---|
11910 | | - dev->name); |
---|
11911 | | - return err; |
---|
11912 | | - } |
---|
11913 | | - pci_restore_state(pdev); |
---|
11914 | 11872 | |
---|
11915 | 11873 | /* |
---|
11916 | 11874 | * Suspend/Resume resets the PCI configuration space, so we have to |
---|
.. | .. |
---|
11933 | 11891 | |
---|
11934 | 11892 | return 0; |
---|
11935 | 11893 | } |
---|
11936 | | -#endif |
---|
11937 | 11894 | |
---|
11938 | 11895 | static void ipw_pci_shutdown(struct pci_dev *pdev) |
---|
11939 | 11896 | { |
---|
.. | .. |
---|
11945 | 11902 | pci_disable_device(pdev); |
---|
11946 | 11903 | } |
---|
11947 | 11904 | |
---|
| 11905 | +static SIMPLE_DEV_PM_OPS(ipw_pci_pm_ops, ipw_pci_suspend, ipw_pci_resume); |
---|
| 11906 | + |
---|
11948 | 11907 | /* driver initialization stuff */ |
---|
11949 | 11908 | static struct pci_driver ipw_driver = { |
---|
11950 | 11909 | .name = DRV_NAME, |
---|
11951 | 11910 | .id_table = card_ids, |
---|
11952 | 11911 | .probe = ipw_pci_probe, |
---|
11953 | 11912 | .remove = ipw_pci_remove, |
---|
11954 | | -#ifdef CONFIG_PM |
---|
11955 | | - .suspend = ipw_pci_suspend, |
---|
11956 | | - .resume = ipw_pci_resume, |
---|
11957 | | -#endif |
---|
| 11913 | + .driver.pm = &ipw_pci_pm_ops, |
---|
11958 | 11914 | .shutdown = ipw_pci_shutdown, |
---|
11959 | 11915 | }; |
---|
11960 | 11916 | |
---|