.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /*============================================================================= |
---|
2 | 3 | * |
---|
3 | 4 | * A PCMCIA client driver for the Raylink wireless LAN card. |
---|
4 | 5 | * The starting point for this module was the skeleton.c in the |
---|
5 | 6 | * PCMCIA 2.9.12 package written by David Hinds, dahinds@users.sourceforge.net |
---|
6 | 7 | * |
---|
7 | | - * |
---|
8 | 8 | * 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/>. |
---|
21 | 9 | * |
---|
22 | 10 | * Changes: |
---|
23 | 11 | * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 08/08/2000 |
---|
.. | .. |
---|
282 | 270 | { |
---|
283 | 271 | ray_dev_t *local; |
---|
284 | 272 | struct net_device *dev; |
---|
| 273 | + int ret; |
---|
285 | 274 | |
---|
286 | 275 | dev_dbg(&p_dev->dev, "ray_attach()\n"); |
---|
287 | 276 | |
---|
288 | 277 | /* Allocate space for private device-specific data */ |
---|
289 | 278 | dev = alloc_etherdev(sizeof(ray_dev_t)); |
---|
290 | 279 | if (!dev) |
---|
291 | | - goto fail_alloc_dev; |
---|
| 280 | + return -ENOMEM; |
---|
292 | 281 | |
---|
293 | 282 | local = netdev_priv(dev); |
---|
294 | 283 | local->finder = p_dev; |
---|
.. | .. |
---|
325 | 314 | timer_setup(&local->timer, NULL, 0); |
---|
326 | 315 | |
---|
327 | 316 | this_device = p_dev; |
---|
328 | | - return ray_config(p_dev); |
---|
| 317 | + ret = ray_config(p_dev); |
---|
| 318 | + if (ret) |
---|
| 319 | + goto err_free_dev; |
---|
329 | 320 | |
---|
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 | +} |
---|
333 | 327 | |
---|
334 | 328 | static void ray_detach(struct pcmcia_device *link) |
---|
335 | 329 | { |
---|
.. | .. |
---|
394 | 388 | goto failed; |
---|
395 | 389 | local->sram = ioremap(link->resource[2]->start, |
---|
396 | 390 | resource_size(link->resource[2])); |
---|
| 391 | + if (!local->sram) |
---|
| 392 | + goto failed; |
---|
397 | 393 | |
---|
398 | 394 | /*** Set up 16k window for shared memory (receive buffer) ***************/ |
---|
399 | 395 | link->resource[3]->flags |= |
---|
.. | .. |
---|
408 | 404 | goto failed; |
---|
409 | 405 | local->rmem = ioremap(link->resource[3]->start, |
---|
410 | 406 | resource_size(link->resource[3])); |
---|
| 407 | + if (!local->rmem) |
---|
| 408 | + goto failed; |
---|
411 | 409 | |
---|
412 | 410 | /*** Set up window for attribute memory ***********************************/ |
---|
413 | 411 | link->resource[4]->flags |= |
---|
.. | .. |
---|
422 | 420 | goto failed; |
---|
423 | 421 | local->amem = ioremap(link->resource[4]->start, |
---|
424 | 422 | resource_size(link->resource[4])); |
---|
| 423 | + if (!local->amem) |
---|
| 424 | + goto failed; |
---|
425 | 425 | |
---|
426 | 426 | dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram); |
---|
427 | 427 | dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem); |
---|
.. | .. |
---|
889 | 889 | switch (ccsindex = get_free_tx_ccs(local)) { |
---|
890 | 890 | case ECCSBUSY: |
---|
891 | 891 | pr_debug("ray_hw_xmit tx_ccs table busy\n"); |
---|
| 892 | + /* fall through */ |
---|
892 | 893 | case ECCSFULL: |
---|
893 | 894 | pr_debug("ray_hw_xmit No free tx ccs\n"); |
---|
| 895 | + /* fall through */ |
---|
894 | 896 | case ECARDGONE: |
---|
895 | 897 | netif_stop_queue(dev); |
---|
896 | 898 | return XMIT_NO_CCS; |
---|
.. | .. |
---|
957 | 959 | if (proto == htons(ETH_P_AARP) || proto == htons(ETH_P_IPX)) { |
---|
958 | 960 | /* This is the selective translation table, only 2 entries */ |
---|
959 | 961 | writeb(0xf8, |
---|
960 | | - &((struct snaphdr_t __iomem *)ptx->var)->org[3]); |
---|
| 962 | + &((struct snaphdr_t __iomem *)ptx->var)->org[2]); |
---|
961 | 963 | } |
---|
962 | 964 | /* Copy body of ethernet packet without ethernet header */ |
---|
963 | 965 | memcpy_toio((void __iomem *)&ptx->var + |
---|
.. | .. |
---|
1645 | 1647 | /*===========================================================================*/ |
---|
1646 | 1648 | static int parse_addr(char *in_str, UCHAR *out) |
---|
1647 | 1649 | { |
---|
| 1650 | + int i, k; |
---|
1648 | 1651 | int len; |
---|
1649 | | - int i, j, k; |
---|
1650 | | - int status; |
---|
1651 | 1652 | |
---|
1652 | 1653 | if (in_str == NULL) |
---|
1653 | 1654 | return 0; |
---|
1654 | | - if ((len = strlen(in_str)) < 2) |
---|
| 1655 | + len = strnlen(in_str, ADDRLEN * 2 + 1) - 1; |
---|
| 1656 | + if (len < 1) |
---|
1655 | 1657 | return 0; |
---|
1656 | 1658 | memset(out, 0, ADDRLEN); |
---|
1657 | 1659 | |
---|
1658 | | - status = 1; |
---|
1659 | | - j = len - 1; |
---|
1660 | | - if (j > 12) |
---|
1661 | | - j = 12; |
---|
1662 | 1660 | i = 5; |
---|
1663 | 1661 | |
---|
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) |
---|
1666 | 1664 | out[i] = k; |
---|
1667 | 1665 | else |
---|
1668 | 1666 | return 0; |
---|
1669 | 1667 | |
---|
1670 | | - if (j == 0) |
---|
| 1668 | + if (len == 0) |
---|
1671 | 1669 | break; |
---|
1672 | | - if ((k = hex_to_bin(in_str[j--])) != -1) |
---|
| 1670 | + if ((k = hex_to_bin(in_str[len--])) != -1) |
---|
1673 | 1671 | out[i] += k << 4; |
---|
1674 | 1672 | else |
---|
1675 | 1673 | return 0; |
---|
1676 | 1674 | if (!i--) |
---|
1677 | 1675 | break; |
---|
1678 | 1676 | } |
---|
1679 | | - return status; |
---|
| 1677 | + return 1; |
---|
1680 | 1678 | } |
---|
1681 | 1679 | |
---|
1682 | 1680 | /*===========================================================================*/ |
---|
.. | .. |
---|
2209 | 2207 | untranslate(local, skb, total_len); |
---|
2210 | 2208 | } |
---|
2211 | 2209 | } else { /* sniffer mode, so just pass whole packet */ |
---|
2212 | | - }; |
---|
| 2210 | + } |
---|
2213 | 2211 | |
---|
2214 | 2212 | /************************/ |
---|
2215 | 2213 | /* Now pick up the rest of the fragments if any */ |
---|
.. | .. |
---|
2727 | 2725 | return count; |
---|
2728 | 2726 | } |
---|
2729 | 2727 | |
---|
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, |
---|
2734 | 2731 | }; |
---|
2735 | 2732 | |
---|
2736 | 2733 | static ssize_t int_proc_write(struct file *file, const char __user *buffer, |
---|
.. | .. |
---|
2761 | 2758 | return count; |
---|
2762 | 2759 | } |
---|
2763 | 2760 | |
---|
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, |
---|
2768 | 2764 | }; |
---|
2769 | 2765 | #endif |
---|
2770 | 2766 | |
---|
.. | .. |
---|
2793 | 2789 | rc = pcmcia_register_driver(&ray_driver); |
---|
2794 | 2790 | pr_debug("raylink init_module register_pcmcia_driver returns 0x%x\n", |
---|
2795 | 2791 | rc); |
---|
| 2792 | + if (rc) |
---|
| 2793 | + return rc; |
---|
2796 | 2794 | |
---|
2797 | 2795 | #ifdef CONFIG_PROC_FS |
---|
2798 | 2796 | proc_mkdir("driver/ray_cs", NULL); |
---|
2799 | 2797 | |
---|
2800 | 2798 | 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, |
---|
2803 | 2801 | &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, |
---|
2805 | 2803 | &translate); |
---|
2806 | 2804 | #endif |
---|
2807 | | - if (translate != 0) |
---|
2808 | | - translate = 1; |
---|
| 2805 | + translate = !!translate; |
---|
2809 | 2806 | return 0; |
---|
2810 | 2807 | } /* init_ray_cs */ |
---|
2811 | 2808 | |
---|
.. | .. |
---|
2816 | 2813 | pr_debug("ray_cs: cleanup_module\n"); |
---|
2817 | 2814 | |
---|
2818 | 2815 | #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); |
---|
2824 | 2817 | #endif |
---|
2825 | 2818 | |
---|
2826 | 2819 | pcmcia_unregister_driver(&ray_driver); |
---|