hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/wireless/intel/iwlegacy/3945-mac.c
....@@ -1,25 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /******************************************************************************
23 *
34 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
45 *
56 * Portions of this file are derived from the ipw3945 project, as well
67 * 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.
238 *
249 * Contact Information:
2510 * Intel Linux Wireless <ilw@linux.intel.com>
....@@ -33,7 +18,6 @@
3318 #include <linux/module.h>
3419 #include <linux/init.h>
3520 #include <linux/pci.h>
36
-#include <linux/pci-aspm.h>
3721 #include <linux/slab.h>
3822 #include <linux/dma-mapping.h>
3923 #include <linux/delay.h>
....@@ -244,9 +228,7 @@
244228 static int
245229 il3945_remove_static_key(struct il_priv *il)
246230 {
247
- int ret = -EOPNOTSUPP;
248
-
249
- return ret;
231
+ return -EOPNOTSUPP;
250232 }
251233
252234 static int
....@@ -383,7 +365,7 @@
383365
384366 case WLAN_CIPHER_SUITE_WEP104:
385367 tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
386
- /* fall through */
368
+ fallthrough;
387369 case WLAN_CIPHER_SUITE_WEP40:
388370 tx_cmd->sec_ctl |=
389371 TX_CMD_SEC_WEP | (info->control.hw_key->
....@@ -825,7 +807,7 @@
825807 wake_up(&il->wait_command_queue);
826808 }
827809
828
-/**
810
+/*
829811 * il3945_setup_handlers - Initialize Rx handler callbacks
830812 *
831813 * Setup the RX handlers for each of the reply types sent from the uCode
....@@ -925,7 +907,7 @@
925907 *
926908 */
927909
928
-/**
910
+/*
929911 * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr
930912 */
931913 static inline __le32
....@@ -934,7 +916,7 @@
934916 return cpu_to_le32((u32) dma_addr);
935917 }
936918
937
-/**
919
+/*
938920 * il3945_rx_queue_restock - refill RX queue from pre-allocated pool
939921 *
940922 * If there are slots in the RX queue that need to be restocked,
....@@ -984,7 +966,7 @@
984966 }
985967 }
986968
987
-/**
969
+/*
988970 * il3945_rx_replenish - Move all used packet from rx_used to rx_free
989971 *
990972 * When moving to rx_free an SKB is allocated for the slot.
....@@ -1185,7 +1167,7 @@
11851167 return (int)ratio2dB[sig_ratio];
11861168 }
11871169
1188
-/**
1170
+/*
11891171 * il3945_rx_handle - Main entry function for receiving responses from uCode
11901172 *
11911173 * Uses the il->handlers callback function array to invoke
....@@ -1392,9 +1374,9 @@
13921374 }
13931375
13941376 static void
1395
-il3945_irq_tasklet(unsigned long data)
1377
+il3945_irq_tasklet(struct tasklet_struct *t)
13961378 {
1397
- struct il_priv *il = (struct il_priv *)data;
1379
+ struct il_priv *il = from_tasklet(il, t, irq_tasklet);
13981380 u32 inta, handled = 0;
13991381 u32 inta_fh;
14001382 unsigned long flags;
....@@ -1672,7 +1654,7 @@
16721654 il_free_fw_desc(il->pci_dev, &il->ucode_boot);
16731655 }
16741656
1675
-/**
1657
+/*
16761658 * il3945_verify_inst_full - verify runtime uCode image in card vs. host,
16771659 * looking at all data.
16781660 */
....@@ -1711,7 +1693,7 @@
17111693 return rc;
17121694 }
17131695
1714
-/**
1696
+/*
17151697 * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host,
17161698 * using sample data 100 bytes apart. If these sample points are good,
17171699 * it's a pretty good bet that everything between them is good, too.
....@@ -1748,7 +1730,7 @@
17481730 return rc;
17491731 }
17501732
1751
-/**
1733
+/*
17521734 * il3945_verify_ucode - determine which instruction image is in SRAM,
17531735 * and verify its contents
17541736 */
....@@ -1829,7 +1811,7 @@
18291811 IL3945_UCODE_GET(init_data_size);
18301812 IL3945_UCODE_GET(boot_size);
18311813
1832
-/**
1814
+/*
18331815 * il3945_read_ucode - Read uCode images from disk file.
18341816 *
18351817 * Copy into buffers for card to fetch via bus-mastering
....@@ -2065,7 +2047,7 @@
20652047 return ret;
20662048 }
20672049
2068
-/**
2050
+/*
20692051 * il3945_set_ucode_ptrs - Set uCode address location
20702052 *
20712053 * Tell initialization uCode where to find runtime uCode.
....@@ -2099,7 +2081,7 @@
20992081 return 0;
21002082 }
21012083
2102
-/**
2084
+/*
21032085 * il3945_init_alive_start - Called after N_ALIVE notification received
21042086 *
21052087 * Called after N_ALIVE notification received from "initialize" uCode.
....@@ -2143,7 +2125,7 @@
21432125 queue_work(il->workqueue, &il->restart);
21442126 }
21452127
2146
-/**
2128
+/*
21472129 * il3945_alive_start - called after N_ALIVE notification received
21482130 * from protocol/runtime uCode (initialization uCode's
21492131 * Alive gets handled by il3945_init_alive_start()).
....@@ -2318,9 +2300,7 @@
23182300 il3945_hw_txq_ctx_free(il);
23192301 exit:
23202302 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);
23242304 il->beacon_skb = NULL;
23252305
23262306 /* clear out any free frames */
....@@ -3400,10 +3380,12 @@
34003380 *
34013381 *****************************************************************************/
34023382
3403
-static void
3383
+static int
34043384 il3945_setup_deferred_work(struct il_priv *il)
34053385 {
34063386 il->workqueue = create_singlethread_workqueue(DRV_NAME);
3387
+ if (!il->workqueue)
3388
+ return -ENOMEM;
34073389
34083390 init_waitqueue_head(&il->wait_command_queue);
34093391
....@@ -3419,9 +3401,9 @@
34193401
34203402 timer_setup(&il->watchdog, il_bg_watchdog, 0);
34213403
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;
34253407 }
34263408
34273409 static void
....@@ -3743,7 +3725,10 @@
37433725 }
37443726
37453727 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
+
37473732 il3945_setup_handlers(il);
37483733 il_power_initialize(il);
37493734
....@@ -3755,21 +3740,19 @@
37553740
37563741 err = il3945_setup_mac(il);
37573742 if (err)
3758
- goto out_remove_sysfs;
3743
+ goto out_destroy_workqueue;
37593744
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);
37643746
37653747 /* Start monitoring the killswitch */
37663748 queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, 2 * HZ);
37673749
37683750 return 0;
37693751
3770
-out_remove_sysfs:
3752
+out_destroy_workqueue:
37713753 destroy_workqueue(il->workqueue);
37723754 il->workqueue = NULL;
3755
+out_remove_sysfs:
37733756 sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group);
37743757 out_release_irq:
37753758 free_irq(il->pci_dev->irq, il);
....@@ -3866,9 +3849,7 @@
38663849 il_free_channel_map(il);
38673850 il_free_geos(il);
38683851 kfree(il->scan_cmd);
3869
- if (il->beacon_skb)
3870
- dev_kfree_skb(il->beacon_skb);
3871
-
3852
+ dev_kfree_skb(il->beacon_skb);
38723853 ieee80211_free_hw(il->hw);
38733854 }
38743855