diff options
Diffstat (limited to 'drivers/staging/rtl8192u/r8192U_core.c')
-rw-r--r-- | drivers/staging/rtl8192u/r8192U_core.c | 276 |
1 files changed, 75 insertions, 201 deletions
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 726d7ad9408b..0a60ef20107c 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -56,7 +56,6 @@ double __extendsfdf2(float a) #include "r8192U_dm.h" #include <linux/usb.h> #include <linux/slab.h> -#include <linux/proc_fs.h> #include <linux/seq_file.h> /* FIXME: check if 2.6.7 is ok */ @@ -453,179 +452,6 @@ static void rtl8192_restart(struct work_struct *work); static void watch_dog_timer_callback(struct timer_list *t); /**************************************************************************** - * -----------------------------PROCFS STUFF------------------------- - ****************************************************************************/ - -static struct proc_dir_entry *rtl8192_proc; - -static int __maybe_unused proc_get_stats_ap(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - struct ieee80211_device *ieee = priv->ieee80211; - struct ieee80211_network *target; - - list_for_each_entry(target, &ieee->network_list, list) { - const char *wpa = "non_WPA"; - - if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) - wpa = "WPA"; - - seq_printf(m, "%s %s\n", target->ssid, wpa); - } - - return 0; -} - -static int __maybe_unused proc_get_registers(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - int i, n, max = 0xff; - u8 byte_rd; - - seq_puts(m, "\n####################page 0##################\n "); - - for (n = 0; n <= max;) { - seq_printf(m, "\nD: %2x > ", n); - - for (i = 0; i < 16 && n <= max; i++, n++) { - read_nic_byte(dev, 0x000 | n, &byte_rd); - seq_printf(m, "%2x ", byte_rd); - } - } - - seq_puts(m, "\n####################page 1##################\n "); - for (n = 0; n <= max;) { - seq_printf(m, "\nD: %2x > ", n); - - for (i = 0; i < 16 && n <= max; i++, n++) { - read_nic_byte(dev, 0x100 | n, &byte_rd); - seq_printf(m, "%2x ", byte_rd); - } - } - - seq_puts(m, "\n####################page 3##################\n "); - for (n = 0; n <= max;) { - seq_printf(m, "\nD: %2x > ", n); - - for (i = 0; i < 16 && n <= max; i++, n++) { - read_nic_byte(dev, 0x300 | n, &byte_rd); - seq_printf(m, "%2x ", byte_rd); - } - } - - seq_putc(m, '\n'); - return 0; -} - -static int __maybe_unused proc_get_stats_tx(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - - seq_printf(m, - "TX VI priority ok int: %lu\n" - "TX VI priority error int: %lu\n" - "TX VO priority ok int: %lu\n" - "TX VO priority error int: %lu\n" - "TX BE priority ok int: %lu\n" - "TX BE priority error int: %lu\n" - "TX BK priority ok int: %lu\n" - "TX BK priority error int: %lu\n" - "TX MANAGE priority ok int: %lu\n" - "TX MANAGE priority error int: %lu\n" - "TX BEACON priority ok int: %lu\n" - "TX BEACON priority error int: %lu\n" - "TX queue resume: %lu\n" - "TX queue stopped?: %d\n" - "TX fifo overflow: %lu\n" - "TX VI queue: %d\n" - "TX VO queue: %d\n" - "TX BE queue: %d\n" - "TX BK queue: %d\n" - "TX VI dropped: %lu\n" - "TX VO dropped: %lu\n" - "TX BE dropped: %lu\n" - "TX BK dropped: %lu\n" - "TX total data packets %lu\n", - priv->stats.txviokint, - priv->stats.txvierr, - priv->stats.txvookint, - priv->stats.txvoerr, - priv->stats.txbeokint, - priv->stats.txbeerr, - priv->stats.txbkokint, - priv->stats.txbkerr, - priv->stats.txmanageokint, - priv->stats.txmanageerr, - priv->stats.txbeaconokint, - priv->stats.txbeaconerr, - priv->stats.txresumed, - netif_queue_stopped(dev), - priv->stats.txoverflow, - atomic_read(&(priv->tx_pending[VI_PRIORITY])), - atomic_read(&(priv->tx_pending[VO_PRIORITY])), - atomic_read(&(priv->tx_pending[BE_PRIORITY])), - atomic_read(&(priv->tx_pending[BK_PRIORITY])), - priv->stats.txvidrop, - priv->stats.txvodrop, - priv->stats.txbedrop, - priv->stats.txbkdrop, - priv->stats.txdatapkt - ); - - return 0; -} - -static int __maybe_unused proc_get_stats_rx(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - - seq_printf(m, - "RX packets: %lu\n" - "RX urb status error: %lu\n" - "RX invalid urb error: %lu\n", - priv->stats.rxoktotal, - priv->stats.rxstaterr, - priv->stats.rxurberr); - - return 0; -} - -static void rtl8192_proc_module_init(void) -{ - RT_TRACE(COMP_INIT, "Initializing proc filesystem"); - rtl8192_proc = proc_mkdir(RTL819XU_MODULE_NAME, init_net.proc_net); -} - -static void rtl8192_proc_init_one(struct net_device *dev) -{ - struct proc_dir_entry *dir; - - if (!rtl8192_proc) - return; - - dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev); - if (!dir) - return; - - proc_create_single("stats-rx", S_IFREG | 0444, dir, - proc_get_stats_rx); - proc_create_single("stats-tx", S_IFREG | 0444, dir, - proc_get_stats_tx); - proc_create_single("stats-ap", S_IFREG | 0444, dir, - proc_get_stats_ap); - proc_create_single("registers", S_IFREG | 0444, dir, - proc_get_registers); -} - -static void rtl8192_proc_remove_one(struct net_device *dev) -{ - remove_proc_subtree(dev->name, rtl8192_proc); -} - -/**************************************************************************** * -----------------------------MISC STUFF------------------------- *****************************************************************************/ @@ -2531,13 +2357,13 @@ static short rtl8192_init(struct net_device *dev) #ifdef PIPE12 { int i = 0; - u8 queuetopipe[] = {3, 2, 1, 0, 4, 8, 7, 6, 5}; + static const u8 queuetopipe[] = {3, 2, 1, 0, 4, 8, 7, 6, 5}; memcpy(priv->txqueue_to_outpipemap, queuetopipe, 9); } #else { - u8 queuetopipe[] = {3, 2, 1, 0, 4, 4, 0, 4, 4}; + static const u8 queuetopipe[] = {3, 2, 1, 0, 4, 4, 0, 4, 4}; memcpy(priv->txqueue_to_outpipemap, queuetopipe, 9); } @@ -2666,14 +2492,7 @@ static bool rtl8192_adapter_start(struct net_device *dev) /* config CPUReset Register */ /* Firmware Reset or not? */ read_nic_dword(dev, CPU_GEN, &dwRegRead); - if (priv->pFirmware->firmware_status == FW_STATUS_0_INIT) - dwRegRead |= CPU_GEN_SYSTEM_RESET; /* do nothing here? */ - else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) - dwRegRead |= CPU_GEN_FIRMWARE_RESET; - else - RT_TRACE(COMP_ERR, - "ERROR in %s(): undefined firmware state(%d)\n", - __func__, priv->pFirmware->firmware_status); + dwRegRead |= CPU_GEN_SYSTEM_RESET; /* do nothing here? */ write_nic_dword(dev, CPU_GEN, dwRegRead); /* config BB. */ @@ -4737,7 +4556,7 @@ static int rtl8192_usb_probe(struct usb_interface *intf, goto fail2; RT_TRACE(COMP_INIT, "dev name=======> %s\n", dev->name); - rtl8192_proc_init_one(dev); + rtl8192_debugfs_init_one(dev); RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; @@ -4771,10 +4590,11 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf) struct net_device *dev = usb_get_intfdata(intf); struct r8192_priv *priv = ieee80211_priv(dev); - unregister_netdev(dev); RT_TRACE(COMP_DOWN, "=============>wlan driver to be removed\n"); - rtl8192_proc_remove_one(dev); + rtl8192_debugfs_exit_one(dev); + + unregister_netdev(dev); rtl8192_down(dev); kfree(priv->pFirmware); @@ -4786,53 +4606,107 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf) RT_TRACE(COMP_DOWN, "wlan driver removed\n"); } +static int rtl8192_usb_netdev_event(struct notifier_block *nb, unsigned long event, + void *data) +{ + struct net_device *netdev = netdev_notifier_info_to_dev(data); + + if (netdev->netdev_ops != &rtl8192_netdev_ops) + goto out; + + switch (event) { + case NETDEV_CHANGENAME: + rtl8192_debugfs_rename_one(netdev); + break; + default: + break; + } + +out: + return NOTIFY_DONE; +} + +static struct notifier_block rtl8192_usb_netdev_notifier = { + .notifier_call = rtl8192_usb_netdev_event, +}; + static int __init rtl8192_usb_module_init(void) { int ret; -#ifdef CONFIG_IEEE80211_DEBUG + pr_info("\nLinux kernel driver for RTL8192 based WLAN cards\n"); + pr_info("Copyright (c) 2007-2008, Realsil Wlan\n"); + RT_TRACE(COMP_INIT, "Initializing module"); + RT_TRACE(COMP_INIT, "Wireless extensions version %d", WIRELESS_EXT); + + ret = register_netdevice_notifier(&rtl8192_usb_netdev_notifier); + if (ret) { + pr_err("register_netdevice_notifier failed %d\n", ret); + return ret; + } + + rtl8192_debugfs_init(); ret = ieee80211_debug_init(); if (ret) { pr_err("ieee80211_debug_init() failed %d\n", ret); - return ret; + goto debugfs_exit; } -#endif + ret = ieee80211_crypto_init(); if (ret) { pr_err("ieee80211_crypto_init() failed %d\n", ret); - return ret; + goto debug_exit; } ret = ieee80211_crypto_tkip_init(); if (ret) { pr_err("ieee80211_crypto_tkip_init() failed %d\n", ret); - return ret; + goto crypto_exit; } ret = ieee80211_crypto_ccmp_init(); if (ret) { pr_err("ieee80211_crypto_ccmp_init() failed %d\n", ret); - return ret; + goto crypto_tkip_exit; } ret = ieee80211_crypto_wep_init(); if (ret) { pr_err("ieee80211_crypto_wep_init() failed %d\n", ret); - return ret; + goto crypto_ccmp_exit; } - pr_info("\nLinux kernel driver for RTL8192 based WLAN cards\n"); - pr_info("Copyright (c) 2007-2008, Realsil Wlan\n"); - RT_TRACE(COMP_INIT, "Initializing module"); - RT_TRACE(COMP_INIT, "Wireless extensions version %d", WIRELESS_EXT); - rtl8192_proc_module_init(); - return usb_register(&rtl8192_usb_driver); + ret = usb_register(&rtl8192_usb_driver); + if (ret) + goto crypto_wep_exit; + return ret; + +crypto_wep_exit: + ieee80211_crypto_wep_exit(); +crypto_ccmp_exit: + ieee80211_crypto_ccmp_exit(); +crypto_tkip_exit: + ieee80211_crypto_tkip_exit(); +crypto_exit: + ieee80211_crypto_deinit(); +debug_exit: + ieee80211_debug_exit(); +debugfs_exit: + rtl8192_debugfs_exit(); + unregister_netdevice_notifier(&rtl8192_usb_netdev_notifier); + return ret; } static void __exit rtl8192_usb_module_exit(void) { usb_deregister(&rtl8192_usb_driver); - + ieee80211_crypto_wep_exit(); + ieee80211_crypto_ccmp_exit(); + ieee80211_crypto_tkip_exit(); + ieee80211_crypto_deinit(); + ieee80211_debug_exit(); + rtl8192_debugfs_exit(); + unregister_netdevice_notifier(&rtl8192_usb_netdev_notifier); RT_TRACE(COMP_DOWN, "Exiting"); } |