[PATCH] libertas: move reset_device() code main.c to if_usb.c
The reset_device() logic is only needed for USB devices, not for CF devices. Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
committed by
John W. Linville
parent
fb3dddf22c
commit
3874d0fefd
@@ -73,7 +73,6 @@ extern 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);
|
||||||
|
|
||||||
int reset_device(wlan_private *priv);
|
|
||||||
/* main.c */
|
/* main.c */
|
||||||
extern struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band,
|
extern struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band,
|
||||||
int *cfp_no);
|
int *cfp_no);
|
||||||
|
@@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
static const char usbdriver_name[] = "usb8xxx";
|
static const char usbdriver_name[] = "usb8xxx";
|
||||||
|
|
||||||
|
#define MAX_DEVS 5
|
||||||
|
static struct net_device *libertas_devs[MAX_DEVS];
|
||||||
|
static int libertas_found = 0;
|
||||||
|
|
||||||
static struct usb_device_id if_usb_table[] = {
|
static struct usb_device_id if_usb_table[] = {
|
||||||
/* Enter the device signature inside */
|
/* Enter the device signature inside */
|
||||||
{ USB_DEVICE(0x1286, 0x2001) },
|
{ USB_DEVICE(0x1286, 0x2001) },
|
||||||
@@ -28,6 +32,7 @@ MODULE_DEVICE_TABLE(usb, if_usb_table);
|
|||||||
|
|
||||||
static void if_usb_receive(struct urb *urb);
|
static void if_usb_receive(struct urb *urb);
|
||||||
static void if_usb_receive_fwload(struct urb *urb);
|
static void if_usb_receive_fwload(struct urb *urb);
|
||||||
|
static int reset_device(wlan_private *priv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief call back function to handle the status of the URB
|
* @brief call back function to handle the status of the URB
|
||||||
@@ -189,6 +194,12 @@ static int if_usb_probe(struct usb_interface *intf,
|
|||||||
*/
|
*/
|
||||||
if (!(priv = wlan_add_card(usb_cardp)))
|
if (!(priv = wlan_add_card(usb_cardp)))
|
||||||
goto dealloc;
|
goto dealloc;
|
||||||
|
|
||||||
|
if (libertas_found < MAX_DEVS) {
|
||||||
|
libertas_devs[libertas_found] = priv->wlan_dev.netdev;
|
||||||
|
libertas_found++;
|
||||||
|
}
|
||||||
|
|
||||||
if (wlan_add_mesh(priv))
|
if (wlan_add_mesh(priv))
|
||||||
goto dealloc;
|
goto dealloc;
|
||||||
|
|
||||||
@@ -220,6 +231,7 @@ static void if_usb_disconnect(struct usb_interface *intf)
|
|||||||
struct usb_card_rec *cardp = usb_get_intfdata(intf);
|
struct usb_card_rec *cardp = usb_get_intfdata(intf);
|
||||||
wlan_private *priv = (wlan_private *) cardp->priv;
|
wlan_private *priv = (wlan_private *) cardp->priv;
|
||||||
wlan_adapter *adapter = NULL;
|
wlan_adapter *adapter = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
adapter = priv->adapter;
|
adapter = priv->adapter;
|
||||||
|
|
||||||
@@ -228,6 +240,14 @@ static void if_usb_disconnect(struct usb_interface *intf)
|
|||||||
*/
|
*/
|
||||||
adapter->surpriseremoved = 1;
|
adapter->surpriseremoved = 1;
|
||||||
|
|
||||||
|
for (i = 0; i<libertas_found; i++) {
|
||||||
|
if (libertas_devs[i]==priv->wlan_dev.netdev) {
|
||||||
|
libertas_devs[i] = libertas_devs[--libertas_found];
|
||||||
|
libertas_devs[libertas_found] = NULL ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* 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);
|
wlan_remove_mesh(priv);
|
||||||
@@ -330,12 +350,17 @@ static int libertas_do_reset(wlan_private *priv)
|
|||||||
int ret;
|
int ret;
|
||||||
struct usb_card_rec *cardp = priv->wlan_dev.card;
|
struct usb_card_rec *cardp = priv->wlan_dev.card;
|
||||||
|
|
||||||
|
lbs_deb_enter(LBS_DEB_USB);
|
||||||
|
|
||||||
ret = usb_reset_device(cardp->udev);
|
ret = usb_reset_device(cardp->udev);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
msleep(10);
|
msleep(10);
|
||||||
reset_device(priv);
|
reset_device(priv);
|
||||||
msleep(10);
|
msleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,14 +743,16 @@ int libertas_sbi_read_event_cause(wlan_private * priv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reset_device(wlan_private *priv)
|
static int reset_device(wlan_private *priv)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
lbs_deb_enter(LBS_DEB_USB);
|
||||||
ret = libertas_prepare_and_send_command(priv, cmd_802_11_reset,
|
ret = libertas_prepare_and_send_command(priv, cmd_802_11_reset,
|
||||||
cmd_act_halt, 0, 0, NULL);
|
cmd_act_halt, 0, 0, NULL);
|
||||||
msleep_interruptible(10);
|
msleep_interruptible(10);
|
||||||
|
|
||||||
|
lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -935,7 +962,13 @@ int libertas_sbi_register(void)
|
|||||||
*/
|
*/
|
||||||
void libertas_sbi_unregister(void)
|
void libertas_sbi_unregister(void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i<libertas_found; i++) {
|
||||||
|
wlan_private *priv = libertas_devs[i]->priv;
|
||||||
|
reset_device(priv);
|
||||||
|
}
|
||||||
|
|
||||||
/* API unregisters the driver from USB subsystem */
|
/* API unregisters the driver from USB subsystem */
|
||||||
usb_deregister(&if_usb_driver);
|
usb_deregister(&if_usb_driver);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
@@ -169,10 +169,6 @@ u8 libertas_adhoc_rates_g[G_SUPPORTED_RATES] =
|
|||||||
*/
|
*/
|
||||||
u8 libertas_adhoc_rates_b[4] = { 0x82, 0x84, 0x8b, 0x96 };
|
u8 libertas_adhoc_rates_b[4] = { 0x82, 0x84, 0x8b, 0x96 };
|
||||||
|
|
||||||
#define MAX_DEVS 5
|
|
||||||
static struct net_device *libertas_devs[MAX_DEVS];
|
|
||||||
static int libertas_found = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the table to keep region code
|
* the table to keep region code
|
||||||
*/
|
*/
|
||||||
@@ -851,11 +847,6 @@ wlan_private *wlan_add_card(void *card)
|
|||||||
|
|
||||||
libertas_debugfs_init_one(priv, dev);
|
libertas_debugfs_init_one(priv, dev);
|
||||||
|
|
||||||
if (libertas_found == MAX_DEVS)
|
|
||||||
goto err_init_fw;
|
|
||||||
libertas_devs[libertas_found] = dev;
|
|
||||||
libertas_found++;
|
|
||||||
|
|
||||||
lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv);
|
lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv);
|
||||||
return priv;
|
return priv;
|
||||||
|
|
||||||
@@ -960,7 +951,6 @@ int wlan_remove_card(wlan_private *priv)
|
|||||||
wlan_adapter *adapter;
|
wlan_adapter *adapter;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
union iwreq_data wrqu;
|
union iwreq_data wrqu;
|
||||||
int i;
|
|
||||||
|
|
||||||
lbs_deb_enter(LBS_DEB_NET);
|
lbs_deb_enter(LBS_DEB_NET);
|
||||||
|
|
||||||
@@ -1003,14 +993,6 @@ int wlan_remove_card(wlan_private *priv)
|
|||||||
lbs_deb_net("free adapter\n");
|
lbs_deb_net("free adapter\n");
|
||||||
libertas_free_adapter(priv);
|
libertas_free_adapter(priv);
|
||||||
|
|
||||||
for (i = 0; i<libertas_found; i++) {
|
|
||||||
if (libertas_devs[i]==priv->wlan_dev.netdev) {
|
|
||||||
libertas_devs[i] = libertas_devs[--libertas_found];
|
|
||||||
libertas_devs[libertas_found] = NULL ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lbs_deb_net("unregister finish\n");
|
lbs_deb_net("unregister finish\n");
|
||||||
|
|
||||||
priv->wlan_dev.netdev = NULL;
|
priv->wlan_dev.netdev = NULL;
|
||||||
@@ -1161,15 +1143,8 @@ static int wlan_init_module(void)
|
|||||||
|
|
||||||
static void wlan_cleanup_module(void)
|
static void wlan_cleanup_module(void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
lbs_deb_enter(LBS_DEB_MAIN);
|
lbs_deb_enter(LBS_DEB_MAIN);
|
||||||
|
|
||||||
for (i = 0; i<libertas_found; i++) {
|
|
||||||
wlan_private *priv = libertas_devs[i]->priv;
|
|
||||||
reset_device(priv);
|
|
||||||
}
|
|
||||||
|
|
||||||
libertas_sbi_unregister();
|
libertas_sbi_unregister();
|
||||||
libertas_debugfs_remove();
|
libertas_debugfs_remove();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user