Commit 084708b6 authored by Holger Schurig's avatar Holger Schurig Committed by John W. Linville

[PATCH] libertas: split module into two (libertas.ko and usb8xxx.ko)

* add CONFIG_LIBERTAS to Kconfig
* remove global variable libertas_fw_name, the USB module might want to
    use a different default FW name than the CF module, so libertas_fw_name
    is now local to if_usb.c
* exported some symbols as GPL
Signed-off-by: default avatarHolger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent ed457037
...@@ -266,16 +266,22 @@ config IPW2200_DEBUG ...@@ -266,16 +266,22 @@ config IPW2200_DEBUG
If you are not sure, say N here. If you are not sure, say N here.
config LIBERTAS_USB config LIBERTAS
tristate "Marvell Libertas 8388 802.11a/b/g cards" tristate "Marvell 8xxx Libertas WLAN driver support"
depends on USB && WLAN_80211 depends on WLAN_80211
select FW_LOADER select FW_LOADER
---help---
A library for Marvell Libertas 8xxx devices.
config LIBERTAS_USB
tristate "Marvell Libertas 8388 USB 802.11b/g cards"
depends on LIBERTAS && USB
---help--- ---help---
A driver for Marvell Libertas 8388 USB devices. A driver for Marvell Libertas 8388 USB devices.
config LIBERTAS_USB_DEBUG config LIBERTAS_DEBUG
bool "Enable full debugging output in the Libertas USB module." bool "Enable full debugging output in the Libertas module."
depends on LIBERTAS_USB depends on LIBERTAS
---help--- ---help---
Debugging support. Debugging support.
......
usb8xxx-objs := main.o fw.o wext.o \ libertas-objs := main.o fw.o wext.o \
rx.o tx.o cmd.o \ rx.o tx.o cmd.o \
cmdresp.o scan.o \ cmdresp.o scan.o \
join.o 11d.o \ join.o 11d.o \
...@@ -8,5 +8,5 @@ usb8xxx-objs := main.o fw.o wext.o \ ...@@ -8,5 +8,5 @@ usb8xxx-objs := main.o fw.o wext.o \
usb8xxx-objs += if_bootcmd.o usb8xxx-objs += if_bootcmd.o
usb8xxx-objs += if_usb.o usb8xxx-objs += if_usb.o
obj-$(CONFIG_LIBERTAS) += libertas.o
obj-$(CONFIG_LIBERTAS_USB) += usb8xxx.o obj-$(CONFIG_LIBERTAS_USB) += usb8xxx.o
...@@ -1459,6 +1459,7 @@ int libertas_prepare_and_send_command(wlan_private * priv, ...@@ -1459,6 +1459,7 @@ int libertas_prepare_and_send_command(wlan_private * priv,
lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(libertas_prepare_and_send_command);
/** /**
* @brief This function allocates the command buffer and link * @brief This function allocates the command buffer and link
......
...@@ -74,20 +74,16 @@ void libertas_mac_event_disconnected(wlan_private * priv); ...@@ -74,20 +74,16 @@ void libertas_mac_event_disconnected(wlan_private * priv);
void libertas_send_iwevcustom_event(wlan_private * priv, s8 * str); void libertas_send_iwevcustom_event(wlan_private * priv, s8 * str);
/* fw.c */ /* fw.c */
int libertas_init_fw(wlan_private * priv); int libertas_init_fw(wlan_private * priv, char *fw_name);
/* main.c */ /* main.c */
struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band, struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band,
int *cfp_no); int *cfp_no);
wlan_private *wlan_add_card(void *card); wlan_private *libertas_add_card(void *card);
int libertas_activate_card(wlan_private *priv); int libertas_activate_card(wlan_private *priv, char *fw_name);
int wlan_remove_card(wlan_private *priv); int libertas_remove_card(wlan_private *priv);
int wlan_add_mesh(wlan_private *priv); int libertas_add_mesh(wlan_private *priv);
void wlan_remove_mesh(wlan_private *priv); void libertas_remove_mesh(wlan_private *priv);
/* preliminary here */
int if_usb_register(void);
void if_usb_unregister(void);
#endif /* _WLAN_DECL_H_ */ #endif /* _WLAN_DECL_H_ */
/** /**
* This file contains the initialization for FW and HW * This file contains the initialization for FW and HW
*/ */
#include <linux/moduleparam.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include "host.h" #include "host.h"
...@@ -11,9 +10,6 @@ ...@@ -11,9 +10,6 @@
#include "wext.h" #include "wext.h"
#include "if_usb.h" #include "if_usb.h"
char *libertas_fw_name = NULL;
module_param_named(fw_name, libertas_fw_name, charp, 0644);
/** /**
* @brief This function checks the validity of Boot2/FW image. * @brief This function checks the validity of Boot2/FW image.
* *
...@@ -67,18 +63,18 @@ static int check_fwfile_format(u8 *data, u32 totlen) ...@@ -67,18 +63,18 @@ static int check_fwfile_format(u8 *data, u32 totlen)
* @param priv A pointer to wlan_private structure * @param priv A pointer to wlan_private structure
* @return 0 or -1 * @return 0 or -1
*/ */
static int wlan_setup_station_hw(wlan_private * priv) static int wlan_setup_station_hw(wlan_private * priv, char *fw_name)
{ {
int ret = -1; int ret = -1;
wlan_adapter *adapter = priv->adapter; wlan_adapter *adapter = priv->adapter;
lbs_deb_enter(LBS_DEB_FW); lbs_deb_enter(LBS_DEB_FW);
if ((ret = request_firmware(&priv->firmware, libertas_fw_name, if ((ret = request_firmware(&priv->firmware, fw_name,
priv->hotplug_device)) < 0) { priv->hotplug_device)) < 0) {
lbs_pr_err("request_firmware() failed with %#x\n", lbs_pr_err("request_firmware() failed with %#x\n",
ret); ret);
lbs_pr_err("firmware %s not found\n", libertas_fw_name); lbs_pr_err("firmware %s not found\n", fw_name);
goto done; goto done;
} }
...@@ -247,7 +243,7 @@ static void wlan_init_adapter(wlan_private * priv) ...@@ -247,7 +243,7 @@ static void wlan_init_adapter(wlan_private * priv)
static void command_timer_fn(unsigned long data); static void command_timer_fn(unsigned long data);
int libertas_init_fw(wlan_private * priv) int libertas_init_fw(wlan_private * priv, char *fw_name)
{ {
int ret = -1; int ret = -1;
wlan_adapter *adapter = priv->adapter; wlan_adapter *adapter = priv->adapter;
...@@ -266,7 +262,7 @@ int libertas_init_fw(wlan_private * priv) ...@@ -266,7 +262,7 @@ int libertas_init_fw(wlan_private * priv)
(unsigned long)priv); (unsigned long)priv);
/* download fimrware etc. */ /* download fimrware etc. */
if ((ret = wlan_setup_station_hw(priv)) != 0) { if ((ret = wlan_setup_station_hw(priv, fw_name)) != 0) {
del_timer_sync(&adapter->command_timer); del_timer_sync(&adapter->command_timer);
goto done; goto done;
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* This file contains functions used in USB interface module. * This file contains functions used in USB interface module.
*/ */
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/moduleparam.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/usb.h> #include <linux/usb.h>
...@@ -15,6 +16,11 @@ ...@@ -15,6 +16,11 @@
#define MESSAGE_HEADER_LEN 4 #define MESSAGE_HEADER_LEN 4
static const char usbdriver_name[] = "usb8xxx"; static const char usbdriver_name[] = "usb8xxx";
static u8 *default_fw_name = "usb8388.bin";
char *libertas_fw_name = NULL;
module_param_named(fw_name, libertas_fw_name, charp, 0644);
#define MAX_DEVS 5 #define MAX_DEVS 5
static struct net_device *libertas_devs[MAX_DEVS]; static struct net_device *libertas_devs[MAX_DEVS];
...@@ -195,14 +201,14 @@ static int if_usb_probe(struct usb_interface *intf, ...@@ -195,14 +201,14 @@ static int if_usb_probe(struct usb_interface *intf,
} }
/* At this point wlan_add_card() will be called. Don't worry /* At this point libertas_add_card() will be called. Don't worry
* about keeping pwlanpriv around since it will be set on our * about keeping pwlanpriv around since it will be set on our
* usb device data in -> add() -> hw_register_dev() -> if_usb_register_dev. * usb device data in -> add() -> hw_register_dev() -> if_usb_register_dev.
*/ */
if (!(priv = wlan_add_card(usb_cardp))) if (!(priv = libertas_add_card(usb_cardp)))
goto dealloc; goto dealloc;
if (wlan_add_mesh(priv)) if (libertas_add_mesh(priv))
goto err_add_mesh; goto err_add_mesh;
priv->hw_register_dev = if_usb_register_dev; priv->hw_register_dev = if_usb_register_dev;
...@@ -212,7 +218,7 @@ static int if_usb_probe(struct usb_interface *intf, ...@@ -212,7 +218,7 @@ static int if_usb_probe(struct usb_interface *intf,
priv->hw_get_int_status = if_usb_get_int_status; priv->hw_get_int_status = if_usb_get_int_status;
priv->hw_read_event_cause = if_usb_read_event_cause; priv->hw_read_event_cause = if_usb_read_event_cause;
if (libertas_activate_card(priv)) if (libertas_activate_card(priv, libertas_fw_name))
goto err_activate_card; goto err_activate_card;
if (libertas_found < MAX_DEVS) { if (libertas_found < MAX_DEVS) {
...@@ -273,8 +279,8 @@ static void if_usb_disconnect(struct usb_interface *intf) ...@@ -273,8 +279,8 @@ static void if_usb_disconnect(struct usb_interface *intf)
/* card is removed and we can call wlan_remove_card */ /* card is removed and we can call wlan_remove_card */
lbs_deb_usbd(&cardp->udev->dev, "call remove card\n"); lbs_deb_usbd(&cardp->udev->dev, "call remove card\n");
wlan_remove_mesh(priv); libertas_remove_mesh(priv);
wlan_remove_card(priv); libertas_remove_card(priv);
/* Unlink and free urb */ /* Unlink and free urb */
if_usb_free(cardp); if_usb_free(cardp);
...@@ -964,33 +970,28 @@ static struct usb_driver if_usb_driver = { ...@@ -964,33 +970,28 @@ static struct usb_driver if_usb_driver = {
.resume = if_usb_resume, .resume = if_usb_resume,
}; };
/** static int if_usb_init_module(void)
* @brief This function registers driver.
* @param add pointer to add_card callback function
* @param remove pointer to remove card callback function
* @param arg pointer to call back function parameter
* @return dummy success variable
*/
int if_usb_register(void)
{ {
/* int ret = 0;
* API registers the Marvell USB driver
* to the USB system
*/
usb_register(&if_usb_driver);
/* Return success to wlan layer */ lbs_deb_enter(LBS_DEB_MAIN);
return 0;
if (libertas_fw_name == NULL) {
libertas_fw_name = default_fw_name;
}
ret = usb_register(&if_usb_driver);
lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
return ret;
} }
/** static void if_usb_exit_module(void)
* @brief This function removes usb driver.
* @return N/A
*/
void if_usb_unregister(void)
{ {
int i; int i;
lbs_deb_enter(LBS_DEB_MAIN);
for (i = 0; i<libertas_found; i++) { for (i = 0; i<libertas_found; i++) {
wlan_private *priv = libertas_devs[i]->priv; wlan_private *priv = libertas_devs[i]->priv;
reset_device(priv); reset_device(priv);
...@@ -998,4 +999,13 @@ void if_usb_unregister(void) ...@@ -998,4 +999,13 @@ void if_usb_unregister(void)
/* API unregisters the driver from USB subsystem */ /* API unregisters the driver from USB subsystem */
usb_deregister(&if_usb_driver); usb_deregister(&if_usb_driver);
lbs_deb_leave(LBS_DEB_MAIN);
} }
module_init(if_usb_init_module);
module_exit(if_usb_exit_module);
MODULE_DESCRIPTION("8388 USB WLAN Driver");
MODULE_AUTHOR("Marvell International Ltd.");
MODULE_LICENSE("GPL");
...@@ -32,7 +32,7 @@ const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION ...@@ -32,7 +32,7 @@ const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
/* Module parameters */ /* Module parameters */
unsigned int libertas_debug = 0; unsigned int libertas_debug = 0;
module_param(libertas_debug, int, 0644); module_param(libertas_debug, int, 0644);
EXPORT_SYMBOL_GPL(libertas_debug);
#define WLAN_TX_PWR_DEFAULT 20 /*100mW */ #define WLAN_TX_PWR_DEFAULT 20 /*100mW */
...@@ -173,8 +173,6 @@ u8 libertas_adhoc_rates_b[4] = { 0x82, 0x84, 0x8b, 0x96 }; ...@@ -173,8 +173,6 @@ u8 libertas_adhoc_rates_b[4] = { 0x82, 0x84, 0x8b, 0x96 };
u16 libertas_region_code_to_index[MRVDRV_MAX_REGION_CODE] = u16 libertas_region_code_to_index[MRVDRV_MAX_REGION_CODE] =
{ 0x10, 0x20, 0x30, 0x31, 0x32, 0x40 }; { 0x10, 0x20, 0x30, 0x31, 0x32, 0x40 };
static u8 *default_fw_name = "usb8388.bin";
/** /**
* Attributes exported through sysfs * Attributes exported through sysfs
*/ */
...@@ -766,7 +764,7 @@ static int wlan_service_main_thread(void *data) ...@@ -766,7 +764,7 @@ static int wlan_service_main_thread(void *data)
* @param card A pointer to card * @param card A pointer to card
* @return A pointer to wlan_private structure * @return A pointer to wlan_private structure
*/ */
wlan_private *wlan_add_card(void *card) wlan_private *libertas_add_card(void *card)
{ {
struct net_device *dev = NULL; struct net_device *dev = NULL;
wlan_private *priv = NULL; wlan_private *priv = NULL;
...@@ -826,8 +824,9 @@ wlan_private *wlan_add_card(void *card) ...@@ -826,8 +824,9 @@ wlan_private *wlan_add_card(void *card)
lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv); lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv);
return priv; return priv;
} }
EXPORT_SYMBOL_GPL(libertas_add_card);
int libertas_activate_card(wlan_private *priv) int libertas_activate_card(wlan_private *priv, char *fw_name)
{ {
struct net_device *dev = priv->wlan_dev.netdev; struct net_device *dev = priv->wlan_dev.netdev;
int ret = -1; int ret = -1;
...@@ -854,7 +853,7 @@ int libertas_activate_card(wlan_private *priv) ...@@ -854,7 +853,7 @@ int libertas_activate_card(wlan_private *priv)
} }
/* init FW and HW */ /* init FW and HW */
if (libertas_init_fw(priv)) { if (fw_name && libertas_init_fw(priv, fw_name)) {
lbs_pr_err("firmware init failed\n"); lbs_pr_err("firmware init failed\n");
goto err_registerdev; goto err_registerdev;
} }
...@@ -884,6 +883,8 @@ int libertas_activate_card(wlan_private *priv) ...@@ -884,6 +883,8 @@ int libertas_activate_card(wlan_private *priv)
lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(libertas_activate_card);
/** /**
* @brief This function adds mshX interface * @brief This function adds mshX interface
...@@ -891,7 +892,7 @@ int libertas_activate_card(wlan_private *priv) ...@@ -891,7 +892,7 @@ int libertas_activate_card(wlan_private *priv)
* @param priv A pointer to the wlan_private structure * @param priv A pointer to the wlan_private structure
* @return 0 if successful, -X otherwise * @return 0 if successful, -X otherwise
*/ */
int wlan_add_mesh(wlan_private *priv) int libertas_add_mesh(wlan_private *priv)
{ {
struct net_device *mesh_dev = NULL; struct net_device *mesh_dev = NULL;
int ret = 0; int ret = 0;
...@@ -949,6 +950,7 @@ int wlan_add_mesh(wlan_private *priv) ...@@ -949,6 +950,7 @@ int wlan_add_mesh(wlan_private *priv)
lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(libertas_add_mesh);
static void wake_pending_cmdnodes(wlan_private *priv) static void wake_pending_cmdnodes(wlan_private *priv)
{ {
...@@ -966,7 +968,7 @@ static void wake_pending_cmdnodes(wlan_private *priv) ...@@ -966,7 +968,7 @@ static void wake_pending_cmdnodes(wlan_private *priv)
} }
int wlan_remove_card(wlan_private *priv) int libertas_remove_card(wlan_private *priv)
{ {
wlan_adapter *adapter; wlan_adapter *adapter;
struct net_device *dev; struct net_device *dev;
...@@ -1022,8 +1024,10 @@ int wlan_remove_card(wlan_private *priv) ...@@ -1022,8 +1024,10 @@ int wlan_remove_card(wlan_private *priv)
lbs_deb_leave(LBS_DEB_NET); lbs_deb_leave(LBS_DEB_NET);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(libertas_remove_card);
void wlan_remove_mesh(wlan_private *priv)
void libertas_remove_mesh(wlan_private *priv)
{ {
struct net_device *mesh_dev; struct net_device *mesh_dev;
...@@ -1046,6 +1050,7 @@ void wlan_remove_mesh(wlan_private *priv) ...@@ -1046,6 +1050,7 @@ void wlan_remove_mesh(wlan_private *priv)
out: out:
lbs_deb_leave(LBS_DEB_NET); lbs_deb_leave(LBS_DEB_NET);
} }
EXPORT_SYMBOL_GPL(libertas_remove_mesh);
/** /**
* @brief This function finds the CFP in * @brief This function finds the CFP in
...@@ -1141,41 +1146,28 @@ void libertas_interrupt(struct net_device *dev) ...@@ -1141,41 +1146,28 @@ void libertas_interrupt(struct net_device *dev)
lbs_deb_leave(LBS_DEB_THREAD); lbs_deb_leave(LBS_DEB_THREAD);
} }
EXPORT_SYMBOL_GPL(libertas_interrupt);
static int wlan_init_module(void) static int libertas_init_module(void)
{ {
int ret = 0;
lbs_deb_enter(LBS_DEB_MAIN); lbs_deb_enter(LBS_DEB_MAIN);
if (libertas_fw_name == NULL) {
libertas_fw_name = default_fw_name;
}
libertas_debugfs_init(); libertas_debugfs_init();
lbs_deb_leave(LBS_DEB_MAIN);
if (if_usb_register()) { return 0;
ret = -1;
libertas_debugfs_remove();
}
lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
return ret;
} }
static void wlan_cleanup_module(void) static void libertas_exit_module(void)
{ {
lbs_deb_enter(LBS_DEB_MAIN); lbs_deb_enter(LBS_DEB_MAIN);
if_usb_unregister();
libertas_debugfs_remove(); libertas_debugfs_remove();
lbs_deb_leave(LBS_DEB_MAIN); lbs_deb_leave(LBS_DEB_MAIN);
} }
module_init(wlan_init_module); module_init(libertas_init_module);
module_exit(wlan_cleanup_module); module_exit(libertas_exit_module);
MODULE_DESCRIPTION("M-WLAN Driver"); MODULE_DESCRIPTION("Libertas WLAN Driver Library");
MODULE_AUTHOR("Marvell International Ltd."); MODULE_AUTHOR("Marvell International Ltd.");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -277,6 +277,7 @@ int libertas_process_rxed_packet(wlan_private * priv, struct sk_buff *skb) ...@@ -277,6 +277,7 @@ int libertas_process_rxed_packet(wlan_private * priv, struct sk_buff *skb)
lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret); lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(libertas_process_rxed_packet);
/** /**
* @brief This function converts Tx/Rx rates from the Marvell WLAN format * @brief This function converts Tx/Rx rates from the Marvell WLAN format
......
...@@ -287,3 +287,4 @@ void libertas_send_tx_feedback(wlan_private * priv) ...@@ -287,3 +287,4 @@ void libertas_send_tx_feedback(wlan_private * priv)
netif_wake_queue(priv->mesh_dev); netif_wake_queue(priv->mesh_dev);
} }
} }
EXPORT_SYMBOL_GPL(libertas_send_tx_feedback);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment