forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/wl3501_cs.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * WL3501 Wireless LAN PCMCIA Card Driver for Linux
34 * Written originally for Linux 2.0.30 by Fox Chen, mhchen@golf.ccl.itri.org.tw
....@@ -133,8 +134,8 @@
133134
134135 /**
135136 * iw_valid_channel - validate channel in regulatory domain
136
- * @reg_comain - regulatory domain
137
- * @channel - channel to validate
137
+ * @reg_domain: regulatory domain
138
+ * @channel: channel to validate
138139 *
139140 * Returns 0 if invalid in the specified regulatory domain, non-zero if valid.
140141 */
....@@ -153,7 +154,7 @@
153154
154155 /**
155156 * iw_default_channel - get default channel for a regulatory domain
156
- * @reg_comain - regulatory domain
157
+ * @reg_domain: regulatory domain
157158 *
158159 * Returns the default channel for a regulatory domain
159160 */
....@@ -236,6 +237,7 @@
236237
237238 /**
238239 * wl3501_set_to_wla - Move 'size' bytes from PC to card
240
+ * @this: Card
239241 * @dest: Card addressing space
240242 * @src: PC addressing space
241243 * @size: Bytes to move
....@@ -258,6 +260,7 @@
258260
259261 /**
260262 * wl3501_get_from_wla - Move 'size' bytes from card to PC
263
+ * @this: Card
261264 * @src: Card addressing space
262265 * @dest: PC addressing space
263266 * @size: Bytes to move
....@@ -454,12 +457,10 @@
454457
455458 /**
456459 * wl3501_send_pkt - Send a packet.
457
- * @this - card
458
- *
459
- * Send a packet.
460
- *
461
- * data = Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr,
460
+ * @this: Card
461
+ * @data: Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr,
462462 * data[6] - data[11] is Src MAC Addr)
463
+ * @len: Packet length
463464 * Ref: IEEE 802.11
464465 */
465466 static int wl3501_send_pkt(struct wl3501_card *this, u8 *data, u16 len)
....@@ -722,7 +723,7 @@
722723
723724 /**
724725 * wl3501_block_interrupt - Mask interrupt from SUTRO
725
- * @this - card
726
+ * @this: Card
726727 *
727728 * Mask interrupt from SUTRO. (i.e. SUTRO cannot interrupt the HOST)
728729 * Return: 1 if interrupt is originally enabled
....@@ -739,7 +740,7 @@
739740
740741 /**
741742 * wl3501_unblock_interrupt - Enable interrupt from SUTRO
742
- * @this - card
743
+ * @this: Card
743744 *
744745 * Enable interrupt from SUTRO. (i.e. SUTRO can interrupt the HOST)
745746 * Return: 1 if interrupt is originally enabled
....@@ -1113,8 +1114,8 @@
11131114
11141115 /**
11151116 * wl3501_interrupt - Hardware interrupt from card.
1116
- * @irq - Interrupt number
1117
- * @dev_id - net_device
1117
+ * @irq: Interrupt number
1118
+ * @dev_id: net_device
11181119 *
11191120 * We must acknowledge the interrupt as soon as possible, and block the
11201121 * interrupt from the same card immediately to prevent re-entry.
....@@ -1229,7 +1230,6 @@
12291230 static int wl3501_close(struct net_device *dev)
12301231 {
12311232 struct wl3501_card *this = netdev_priv(dev);
1232
- int rc = -ENODEV;
12331233 unsigned long flags;
12341234 struct pcmcia_device *link;
12351235 link = this->p_dev;
....@@ -1244,15 +1244,14 @@
12441244 /* Mask interrupts from the SUTRO */
12451245 wl3501_block_interrupt(this);
12461246
1247
- rc = 0;
12481247 printk(KERN_INFO "%s: WL3501 closed\n", dev->name);
12491248 spin_unlock_irqrestore(&this->lock, flags);
1250
- return rc;
1249
+ return 0;
12511250 }
12521251
12531252 /**
12541253 * wl3501_reset - Reset the SUTRO.
1255
- * @dev - network device
1254
+ * @dev: network device
12561255 *
12571256 * It is almost the same as wl3501_open(). In fact, we may just wl3501_close()
12581257 * and wl3501_open() again, but I wouldn't like to free_irq() when the driver
....@@ -1290,7 +1289,7 @@
12901289 return rc;
12911290 }
12921291
1293
-static void wl3501_tx_timeout(struct net_device *dev)
1292
+static void wl3501_tx_timeout(struct net_device *dev, unsigned int txqueue)
12941293 {
12951294 struct net_device_stats *stats = &dev->stats;
12961295 int rc;
....@@ -1329,7 +1328,7 @@
13291328 } else {
13301329 ++dev->stats.tx_packets;
13311330 dev->stats.tx_bytes += skb->len;
1332
- kfree_skb(skb);
1331
+ dev_kfree_skb_irq(skb);
13331332
13341333 if (this->tx_buffer_cnt < 2)
13351334 netif_stop_queue(dev);
....@@ -1415,7 +1414,7 @@
14151414
14161415 /**
14171416 * wl3501_detach - deletes a driver "instance"
1418
- * @link - FILL_IN
1417
+ * @link: FILL_IN
14191418 *
14201419 * This deletes a driver "instance". The device is de-registered with Card
14211420 * Services. If it has been released, all local data structures are freed.
....@@ -1436,9 +1435,7 @@
14361435 wl3501_release(link);
14371436
14381437 unregister_netdev(dev);
1439
-
1440
- if (link->priv)
1441
- free_netdev(link->priv);
1438
+ free_netdev(dev);
14421439 }
14431440
14441441 static int wl3501_get_name(struct net_device *dev, struct iw_request_info *info,
....@@ -1865,6 +1862,7 @@
18651862 {
18661863 struct net_device *dev;
18671864 struct wl3501_card *this;
1865
+ int ret;
18681866
18691867 /* The io structure describes IO port mapping */
18701868 p_dev->resource[0]->end = 16;
....@@ -1876,8 +1874,7 @@
18761874
18771875 dev = alloc_etherdev(sizeof(struct wl3501_card));
18781876 if (!dev)
1879
- goto out_link;
1880
-
1877
+ return -ENOMEM;
18811878
18821879 dev->netdev_ops = &wl3501_netdev_ops;
18831880 dev->watchdog_timeo = 5 * HZ;
....@@ -1890,9 +1887,15 @@
18901887 netif_stop_queue(dev);
18911888 p_dev->priv = dev;
18921889
1893
- return wl3501_config(p_dev);
1894
-out_link:
1895
- return -ENOMEM;
1890
+ ret = wl3501_config(p_dev);
1891
+ if (ret)
1892
+ goto out_free_etherdev;
1893
+
1894
+ return 0;
1895
+
1896
+out_free_etherdev:
1897
+ free_netdev(dev);
1898
+ return ret;
18961899 }
18971900
18981901 static int wl3501_config(struct pcmcia_device *link)
....@@ -1948,8 +1951,7 @@
19481951 goto failed;
19491952 }
19501953
1951
- for (i = 0; i < 6; i++)
1952
- dev->dev_addr[i] = ((char *)&this->mac_addr)[i];
1954
+ eth_hw_addr_set(dev, this->mac_addr);
19531955
19541956 /* print probe information */
19551957 printk(KERN_INFO "%s: wl3501 @ 0x%3.3x, IRQ %d, "