hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/net/wireless/ray_cs.c
....@@ -1,23 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*=============================================================================
23 *
34 * A PCMCIA client driver for the Raylink wireless LAN card.
45 * The starting point for this module was the skeleton.c in the
56 * PCMCIA 2.9.12 package written by David Hinds, dahinds@users.sourceforge.net
67 *
7
- *
88 * Copyright (c) 1998 Corey Thomas (corey@world.std.com)
9
- *
10
- * This driver is free software; you can redistribute it and/or modify
11
- * it under the terms of version 2 only of the GNU General Public License as
12
- * published by the Free Software Foundation.
13
- *
14
- * It is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
219 *
2210 * Changes:
2311 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 08/08/2000
....@@ -282,13 +270,14 @@
282270 {
283271 ray_dev_t *local;
284272 struct net_device *dev;
273
+ int ret;
285274
286275 dev_dbg(&p_dev->dev, "ray_attach()\n");
287276
288277 /* Allocate space for private device-specific data */
289278 dev = alloc_etherdev(sizeof(ray_dev_t));
290279 if (!dev)
291
- goto fail_alloc_dev;
280
+ return -ENOMEM;
292281
293282 local = netdev_priv(dev);
294283 local->finder = p_dev;
....@@ -325,11 +314,16 @@
325314 timer_setup(&local->timer, NULL, 0);
326315
327316 this_device = p_dev;
328
- return ray_config(p_dev);
317
+ ret = ray_config(p_dev);
318
+ if (ret)
319
+ goto err_free_dev;
329320
330
-fail_alloc_dev:
331
- return -ENOMEM;
332
-} /* ray_attach */
321
+ return 0;
322
+
323
+err_free_dev:
324
+ free_netdev(dev);
325
+ return ret;
326
+}
333327
334328 static void ray_detach(struct pcmcia_device *link)
335329 {
....@@ -394,6 +388,8 @@
394388 goto failed;
395389 local->sram = ioremap(link->resource[2]->start,
396390 resource_size(link->resource[2]));
391
+ if (!local->sram)
392
+ goto failed;
397393
398394 /*** Set up 16k window for shared memory (receive buffer) ***************/
399395 link->resource[3]->flags |=
....@@ -408,6 +404,8 @@
408404 goto failed;
409405 local->rmem = ioremap(link->resource[3]->start,
410406 resource_size(link->resource[3]));
407
+ if (!local->rmem)
408
+ goto failed;
411409
412410 /*** Set up window for attribute memory ***********************************/
413411 link->resource[4]->flags |=
....@@ -422,6 +420,8 @@
422420 goto failed;
423421 local->amem = ioremap(link->resource[4]->start,
424422 resource_size(link->resource[4]));
423
+ if (!local->amem)
424
+ goto failed;
425425
426426 dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram);
427427 dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem);
....@@ -889,8 +889,10 @@
889889 switch (ccsindex = get_free_tx_ccs(local)) {
890890 case ECCSBUSY:
891891 pr_debug("ray_hw_xmit tx_ccs table busy\n");
892
+ /* fall through */
892893 case ECCSFULL:
893894 pr_debug("ray_hw_xmit No free tx ccs\n");
895
+ /* fall through */
894896 case ECARDGONE:
895897 netif_stop_queue(dev);
896898 return XMIT_NO_CCS;
....@@ -957,7 +959,7 @@
957959 if (proto == htons(ETH_P_AARP) || proto == htons(ETH_P_IPX)) {
958960 /* This is the selective translation table, only 2 entries */
959961 writeb(0xf8,
960
- &((struct snaphdr_t __iomem *)ptx->var)->org[3]);
962
+ &((struct snaphdr_t __iomem *)ptx->var)->org[2]);
961963 }
962964 /* Copy body of ethernet packet without ethernet header */
963965 memcpy_toio((void __iomem *)&ptx->var +
....@@ -1645,38 +1647,34 @@
16451647 /*===========================================================================*/
16461648 static int parse_addr(char *in_str, UCHAR *out)
16471649 {
1650
+ int i, k;
16481651 int len;
1649
- int i, j, k;
1650
- int status;
16511652
16521653 if (in_str == NULL)
16531654 return 0;
1654
- if ((len = strlen(in_str)) < 2)
1655
+ len = strnlen(in_str, ADDRLEN * 2 + 1) - 1;
1656
+ if (len < 1)
16551657 return 0;
16561658 memset(out, 0, ADDRLEN);
16571659
1658
- status = 1;
1659
- j = len - 1;
1660
- if (j > 12)
1661
- j = 12;
16621660 i = 5;
16631661
1664
- while (j > 0) {
1665
- if ((k = hex_to_bin(in_str[j--])) != -1)
1662
+ while (len > 0) {
1663
+ if ((k = hex_to_bin(in_str[len--])) != -1)
16661664 out[i] = k;
16671665 else
16681666 return 0;
16691667
1670
- if (j == 0)
1668
+ if (len == 0)
16711669 break;
1672
- if ((k = hex_to_bin(in_str[j--])) != -1)
1670
+ if ((k = hex_to_bin(in_str[len--])) != -1)
16731671 out[i] += k << 4;
16741672 else
16751673 return 0;
16761674 if (!i--)
16771675 break;
16781676 }
1679
- return status;
1677
+ return 1;
16801678 }
16811679
16821680 /*===========================================================================*/
....@@ -2209,7 +2207,7 @@
22092207 untranslate(local, skb, total_len);
22102208 }
22112209 } else { /* sniffer mode, so just pass whole packet */
2212
- };
2210
+ }
22132211
22142212 /************************/
22152213 /* Now pick up the rest of the fragments if any */
....@@ -2727,10 +2725,9 @@
27272725 return count;
27282726 }
27292727
2730
-static const struct file_operations ray_cs_essid_proc_fops = {
2731
- .owner = THIS_MODULE,
2732
- .write = ray_cs_essid_proc_write,
2733
- .llseek = noop_llseek,
2728
+static const struct proc_ops ray_cs_essid_proc_ops = {
2729
+ .proc_write = ray_cs_essid_proc_write,
2730
+ .proc_lseek = noop_llseek,
27342731 };
27352732
27362733 static ssize_t int_proc_write(struct file *file, const char __user *buffer,
....@@ -2761,10 +2758,9 @@
27612758 return count;
27622759 }
27632760
2764
-static const struct file_operations int_proc_fops = {
2765
- .owner = THIS_MODULE,
2766
- .write = int_proc_write,
2767
- .llseek = noop_llseek,
2761
+static const struct proc_ops int_proc_ops = {
2762
+ .proc_write = int_proc_write,
2763
+ .proc_lseek = noop_llseek,
27682764 };
27692765 #endif
27702766
....@@ -2793,19 +2789,20 @@
27932789 rc = pcmcia_register_driver(&ray_driver);
27942790 pr_debug("raylink init_module register_pcmcia_driver returns 0x%x\n",
27952791 rc);
2792
+ if (rc)
2793
+ return rc;
27962794
27972795 #ifdef CONFIG_PROC_FS
27982796 proc_mkdir("driver/ray_cs", NULL);
27992797
28002798 proc_create_single("driver/ray_cs/ray_cs", 0, NULL, ray_cs_proc_show);
2801
- proc_create("driver/ray_cs/essid", 0200, NULL, &ray_cs_essid_proc_fops);
2802
- proc_create_data("driver/ray_cs/net_type", 0200, NULL, &int_proc_fops,
2799
+ proc_create("driver/ray_cs/essid", 0200, NULL, &ray_cs_essid_proc_ops);
2800
+ proc_create_data("driver/ray_cs/net_type", 0200, NULL, &int_proc_ops,
28032801 &net_type);
2804
- proc_create_data("driver/ray_cs/translate", 0200, NULL, &int_proc_fops,
2802
+ proc_create_data("driver/ray_cs/translate", 0200, NULL, &int_proc_ops,
28052803 &translate);
28062804 #endif
2807
- if (translate != 0)
2808
- translate = 1;
2805
+ translate = !!translate;
28092806 return 0;
28102807 } /* init_ray_cs */
28112808
....@@ -2816,11 +2813,7 @@
28162813 pr_debug("ray_cs: cleanup_module\n");
28172814
28182815 #ifdef CONFIG_PROC_FS
2819
- remove_proc_entry("driver/ray_cs/ray_cs", NULL);
2820
- remove_proc_entry("driver/ray_cs/essid", NULL);
2821
- remove_proc_entry("driver/ray_cs/net_type", NULL);
2822
- remove_proc_entry("driver/ray_cs/translate", NULL);
2823
- remove_proc_entry("driver/ray_cs", NULL);
2816
+ remove_proc_subtree("driver/ray_cs", NULL);
28242817 #endif
28252818
28262819 pcmcia_unregister_driver(&ray_driver);