| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /****************************************************************************** |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * Portions of this file are derived from the ipw3945 project, as well |
|---|
| 6 | 7 | * as portions of the ieee80211 subsystem header files. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 9 | | - * under the terms of version 2 of the GNU General Public License as |
|---|
| 10 | | - * published by the Free Software Foundation. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 13 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 14 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 15 | | - * more details. |
|---|
| 16 | | - * |
|---|
| 17 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 18 | | - * this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
|---|
| 20 | | - * |
|---|
| 21 | | - * The full GNU General Public License is included in this distribution in the |
|---|
| 22 | | - * file called LICENSE. |
|---|
| 23 | 8 | * |
|---|
| 24 | 9 | * Contact Information: |
|---|
| 25 | 10 | * Intel Linux Wireless <ilw@linux.intel.com> |
|---|
| .. | .. |
|---|
| 33 | 18 | #include <linux/module.h> |
|---|
| 34 | 19 | #include <linux/init.h> |
|---|
| 35 | 20 | #include <linux/pci.h> |
|---|
| 36 | | -#include <linux/pci-aspm.h> |
|---|
| 37 | 21 | #include <linux/slab.h> |
|---|
| 38 | 22 | #include <linux/dma-mapping.h> |
|---|
| 39 | 23 | #include <linux/delay.h> |
|---|
| .. | .. |
|---|
| 244 | 228 | static int |
|---|
| 245 | 229 | il3945_remove_static_key(struct il_priv *il) |
|---|
| 246 | 230 | { |
|---|
| 247 | | - int ret = -EOPNOTSUPP; |
|---|
| 248 | | - |
|---|
| 249 | | - return ret; |
|---|
| 231 | + return -EOPNOTSUPP; |
|---|
| 250 | 232 | } |
|---|
| 251 | 233 | |
|---|
| 252 | 234 | static int |
|---|
| .. | .. |
|---|
| 383 | 365 | |
|---|
| 384 | 366 | case WLAN_CIPHER_SUITE_WEP104: |
|---|
| 385 | 367 | tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; |
|---|
| 386 | | - /* fall through */ |
|---|
| 368 | + fallthrough; |
|---|
| 387 | 369 | case WLAN_CIPHER_SUITE_WEP40: |
|---|
| 388 | 370 | tx_cmd->sec_ctl |= |
|---|
| 389 | 371 | TX_CMD_SEC_WEP | (info->control.hw_key-> |
|---|
| .. | .. |
|---|
| 825 | 807 | wake_up(&il->wait_command_queue); |
|---|
| 826 | 808 | } |
|---|
| 827 | 809 | |
|---|
| 828 | | -/** |
|---|
| 810 | +/* |
|---|
| 829 | 811 | * il3945_setup_handlers - Initialize Rx handler callbacks |
|---|
| 830 | 812 | * |
|---|
| 831 | 813 | * Setup the RX handlers for each of the reply types sent from the uCode |
|---|
| .. | .. |
|---|
| 925 | 907 | * |
|---|
| 926 | 908 | */ |
|---|
| 927 | 909 | |
|---|
| 928 | | -/** |
|---|
| 910 | +/* |
|---|
| 929 | 911 | * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr |
|---|
| 930 | 912 | */ |
|---|
| 931 | 913 | static inline __le32 |
|---|
| .. | .. |
|---|
| 934 | 916 | return cpu_to_le32((u32) dma_addr); |
|---|
| 935 | 917 | } |
|---|
| 936 | 918 | |
|---|
| 937 | | -/** |
|---|
| 919 | +/* |
|---|
| 938 | 920 | * il3945_rx_queue_restock - refill RX queue from pre-allocated pool |
|---|
| 939 | 921 | * |
|---|
| 940 | 922 | * If there are slots in the RX queue that need to be restocked, |
|---|
| .. | .. |
|---|
| 984 | 966 | } |
|---|
| 985 | 967 | } |
|---|
| 986 | 968 | |
|---|
| 987 | | -/** |
|---|
| 969 | +/* |
|---|
| 988 | 970 | * il3945_rx_replenish - Move all used packet from rx_used to rx_free |
|---|
| 989 | 971 | * |
|---|
| 990 | 972 | * When moving to rx_free an SKB is allocated for the slot. |
|---|
| .. | .. |
|---|
| 1185 | 1167 | return (int)ratio2dB[sig_ratio]; |
|---|
| 1186 | 1168 | } |
|---|
| 1187 | 1169 | |
|---|
| 1188 | | -/** |
|---|
| 1170 | +/* |
|---|
| 1189 | 1171 | * il3945_rx_handle - Main entry function for receiving responses from uCode |
|---|
| 1190 | 1172 | * |
|---|
| 1191 | 1173 | * Uses the il->handlers callback function array to invoke |
|---|
| .. | .. |
|---|
| 1392 | 1374 | } |
|---|
| 1393 | 1375 | |
|---|
| 1394 | 1376 | static void |
|---|
| 1395 | | -il3945_irq_tasklet(unsigned long data) |
|---|
| 1377 | +il3945_irq_tasklet(struct tasklet_struct *t) |
|---|
| 1396 | 1378 | { |
|---|
| 1397 | | - struct il_priv *il = (struct il_priv *)data; |
|---|
| 1379 | + struct il_priv *il = from_tasklet(il, t, irq_tasklet); |
|---|
| 1398 | 1380 | u32 inta, handled = 0; |
|---|
| 1399 | 1381 | u32 inta_fh; |
|---|
| 1400 | 1382 | unsigned long flags; |
|---|
| .. | .. |
|---|
| 1672 | 1654 | il_free_fw_desc(il->pci_dev, &il->ucode_boot); |
|---|
| 1673 | 1655 | } |
|---|
| 1674 | 1656 | |
|---|
| 1675 | | -/** |
|---|
| 1657 | +/* |
|---|
| 1676 | 1658 | * il3945_verify_inst_full - verify runtime uCode image in card vs. host, |
|---|
| 1677 | 1659 | * looking at all data. |
|---|
| 1678 | 1660 | */ |
|---|
| .. | .. |
|---|
| 1711 | 1693 | return rc; |
|---|
| 1712 | 1694 | } |
|---|
| 1713 | 1695 | |
|---|
| 1714 | | -/** |
|---|
| 1696 | +/* |
|---|
| 1715 | 1697 | * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host, |
|---|
| 1716 | 1698 | * using sample data 100 bytes apart. If these sample points are good, |
|---|
| 1717 | 1699 | * it's a pretty good bet that everything between them is good, too. |
|---|
| .. | .. |
|---|
| 1748 | 1730 | return rc; |
|---|
| 1749 | 1731 | } |
|---|
| 1750 | 1732 | |
|---|
| 1751 | | -/** |
|---|
| 1733 | +/* |
|---|
| 1752 | 1734 | * il3945_verify_ucode - determine which instruction image is in SRAM, |
|---|
| 1753 | 1735 | * and verify its contents |
|---|
| 1754 | 1736 | */ |
|---|
| .. | .. |
|---|
| 1829 | 1811 | IL3945_UCODE_GET(init_data_size); |
|---|
| 1830 | 1812 | IL3945_UCODE_GET(boot_size); |
|---|
| 1831 | 1813 | |
|---|
| 1832 | | -/** |
|---|
| 1814 | +/* |
|---|
| 1833 | 1815 | * il3945_read_ucode - Read uCode images from disk file. |
|---|
| 1834 | 1816 | * |
|---|
| 1835 | 1817 | * Copy into buffers for card to fetch via bus-mastering |
|---|
| .. | .. |
|---|
| 2065 | 2047 | return ret; |
|---|
| 2066 | 2048 | } |
|---|
| 2067 | 2049 | |
|---|
| 2068 | | -/** |
|---|
| 2050 | +/* |
|---|
| 2069 | 2051 | * il3945_set_ucode_ptrs - Set uCode address location |
|---|
| 2070 | 2052 | * |
|---|
| 2071 | 2053 | * Tell initialization uCode where to find runtime uCode. |
|---|
| .. | .. |
|---|
| 2099 | 2081 | return 0; |
|---|
| 2100 | 2082 | } |
|---|
| 2101 | 2083 | |
|---|
| 2102 | | -/** |
|---|
| 2084 | +/* |
|---|
| 2103 | 2085 | * il3945_init_alive_start - Called after N_ALIVE notification received |
|---|
| 2104 | 2086 | * |
|---|
| 2105 | 2087 | * Called after N_ALIVE notification received from "initialize" uCode. |
|---|
| .. | .. |
|---|
| 2143 | 2125 | queue_work(il->workqueue, &il->restart); |
|---|
| 2144 | 2126 | } |
|---|
| 2145 | 2127 | |
|---|
| 2146 | | -/** |
|---|
| 2128 | +/* |
|---|
| 2147 | 2129 | * il3945_alive_start - called after N_ALIVE notification received |
|---|
| 2148 | 2130 | * from protocol/runtime uCode (initialization uCode's |
|---|
| 2149 | 2131 | * Alive gets handled by il3945_init_alive_start()). |
|---|
| .. | .. |
|---|
| 2318 | 2300 | il3945_hw_txq_ctx_free(il); |
|---|
| 2319 | 2301 | exit: |
|---|
| 2320 | 2302 | memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); |
|---|
| 2321 | | - |
|---|
| 2322 | | - if (il->beacon_skb) |
|---|
| 2323 | | - dev_kfree_skb(il->beacon_skb); |
|---|
| 2303 | + dev_kfree_skb(il->beacon_skb); |
|---|
| 2324 | 2304 | il->beacon_skb = NULL; |
|---|
| 2325 | 2305 | |
|---|
| 2326 | 2306 | /* clear out any free frames */ |
|---|
| .. | .. |
|---|
| 3400 | 3380 | * |
|---|
| 3401 | 3381 | *****************************************************************************/ |
|---|
| 3402 | 3382 | |
|---|
| 3403 | | -static void |
|---|
| 3383 | +static int |
|---|
| 3404 | 3384 | il3945_setup_deferred_work(struct il_priv *il) |
|---|
| 3405 | 3385 | { |
|---|
| 3406 | 3386 | il->workqueue = create_singlethread_workqueue(DRV_NAME); |
|---|
| 3387 | + if (!il->workqueue) |
|---|
| 3388 | + return -ENOMEM; |
|---|
| 3407 | 3389 | |
|---|
| 3408 | 3390 | init_waitqueue_head(&il->wait_command_queue); |
|---|
| 3409 | 3391 | |
|---|
| .. | .. |
|---|
| 3419 | 3401 | |
|---|
| 3420 | 3402 | timer_setup(&il->watchdog, il_bg_watchdog, 0); |
|---|
| 3421 | 3403 | |
|---|
| 3422 | | - tasklet_init(&il->irq_tasklet, |
|---|
| 3423 | | - il3945_irq_tasklet, |
|---|
| 3424 | | - (unsigned long)il); |
|---|
| 3404 | + tasklet_setup(&il->irq_tasklet, il3945_irq_tasklet); |
|---|
| 3405 | + |
|---|
| 3406 | + return 0; |
|---|
| 3425 | 3407 | } |
|---|
| 3426 | 3408 | |
|---|
| 3427 | 3409 | static void |
|---|
| .. | .. |
|---|
| 3743 | 3725 | } |
|---|
| 3744 | 3726 | |
|---|
| 3745 | 3727 | il_set_rxon_channel(il, &il->bands[NL80211_BAND_2GHZ].channels[5]); |
|---|
| 3746 | | - il3945_setup_deferred_work(il); |
|---|
| 3728 | + err = il3945_setup_deferred_work(il); |
|---|
| 3729 | + if (err) |
|---|
| 3730 | + goto out_remove_sysfs; |
|---|
| 3731 | + |
|---|
| 3747 | 3732 | il3945_setup_handlers(il); |
|---|
| 3748 | 3733 | il_power_initialize(il); |
|---|
| 3749 | 3734 | |
|---|
| .. | .. |
|---|
| 3755 | 3740 | |
|---|
| 3756 | 3741 | err = il3945_setup_mac(il); |
|---|
| 3757 | 3742 | if (err) |
|---|
| 3758 | | - goto out_remove_sysfs; |
|---|
| 3743 | + goto out_destroy_workqueue; |
|---|
| 3759 | 3744 | |
|---|
| 3760 | | - err = il_dbgfs_register(il, DRV_NAME); |
|---|
| 3761 | | - if (err) |
|---|
| 3762 | | - IL_ERR("failed to create debugfs files. Ignoring error: %d\n", |
|---|
| 3763 | | - err); |
|---|
| 3745 | + il_dbgfs_register(il, DRV_NAME); |
|---|
| 3764 | 3746 | |
|---|
| 3765 | 3747 | /* Start monitoring the killswitch */ |
|---|
| 3766 | 3748 | queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, 2 * HZ); |
|---|
| 3767 | 3749 | |
|---|
| 3768 | 3750 | return 0; |
|---|
| 3769 | 3751 | |
|---|
| 3770 | | -out_remove_sysfs: |
|---|
| 3752 | +out_destroy_workqueue: |
|---|
| 3771 | 3753 | destroy_workqueue(il->workqueue); |
|---|
| 3772 | 3754 | il->workqueue = NULL; |
|---|
| 3755 | +out_remove_sysfs: |
|---|
| 3773 | 3756 | sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); |
|---|
| 3774 | 3757 | out_release_irq: |
|---|
| 3775 | 3758 | free_irq(il->pci_dev->irq, il); |
|---|
| .. | .. |
|---|
| 3866 | 3849 | il_free_channel_map(il); |
|---|
| 3867 | 3850 | il_free_geos(il); |
|---|
| 3868 | 3851 | kfree(il->scan_cmd); |
|---|
| 3869 | | - if (il->beacon_skb) |
|---|
| 3870 | | - dev_kfree_skb(il->beacon_skb); |
|---|
| 3871 | | - |
|---|
| 3852 | + dev_kfree_skb(il->beacon_skb); |
|---|
| 3872 | 3853 | ieee80211_free_hw(il->hw); |
|---|
| 3873 | 3854 | } |
|---|
| 3874 | 3855 | |
|---|