aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas
diff options
context:
space:
mode:
authorVasily Khoruzhick <anarsoul@gmail.com>2011-01-21 15:44:49 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-02-03 16:38:26 -0500
commit75abde4d193fe300a2c1d3ee7f632eb777aa48b2 (patch)
treed6c8b835de0e28d43094d7c15c3c625436c6b628 /drivers/net/wireless/libertas
parent16f775befc1ccf67e6b223c4d9bb17ac3502ab2c (diff)
libertas: Prepare stuff for if_spi.c pm support
To support suspend/resume in if_spi we need two things: - re-setup fw in lbs_resume(), because if_spi powercycles card; - don't touch hwaddr on second lbs_update_hw_spec() call for same reason; Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas')
-rw-r--r--drivers/net/wireless/libertas/cmd.c10
-rw-r--r--drivers/net/wireless/libertas/dev.h2
-rw-r--r--drivers/net/wireless/libertas/main.c77
3 files changed, 49 insertions, 40 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 78c4da150a74..7e8a658b7670 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -145,9 +145,13 @@ int lbs_update_hw_spec(struct lbs_private *priv)
145 if (priv->current_addr[0] == 0xff) 145 if (priv->current_addr[0] == 0xff)
146 memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN); 146 memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN);
147 147
148 memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN); 148 if (!priv->copied_hwaddr) {
149 if (priv->mesh_dev) 149 memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN);
150 memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN); 150 if (priv->mesh_dev)
151 memcpy(priv->mesh_dev->dev_addr,
152 priv->current_addr, ETH_ALEN);
153 priv->copied_hwaddr = 1;
154 }
151 155
152out: 156out:
153 lbs_deb_leave(LBS_DEB_CMD); 157 lbs_deb_leave(LBS_DEB_CMD);
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 18dd9a02c459..bc461eb39660 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -90,6 +90,7 @@ struct lbs_private {
90 void *card; 90 void *card;
91 u8 fw_ready; 91 u8 fw_ready;
92 u8 surpriseremoved; 92 u8 surpriseremoved;
93 u8 setup_fw_on_resume;
93 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb); 94 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
94 void (*reset_card) (struct lbs_private *priv); 95 void (*reset_card) (struct lbs_private *priv);
95 int (*enter_deep_sleep) (struct lbs_private *priv); 96 int (*enter_deep_sleep) (struct lbs_private *priv);
@@ -101,6 +102,7 @@ struct lbs_private {
101 u32 fwcapinfo; 102 u32 fwcapinfo;
102 u16 regioncode; 103 u16 regioncode;
103 u8 current_addr[ETH_ALEN]; 104 u8 current_addr[ETH_ALEN];
105 u8 copied_hwaddr;
104 106
105 /* Command download */ 107 /* Command download */
106 u8 dnld_sent; 108 u8 dnld_sent;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 6836a6dd9853..ca8149cd5bd9 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -539,6 +539,43 @@ static int lbs_thread(void *data)
539 return 0; 539 return 0;
540} 540}
541 541
542/**
543 * @brief This function gets the HW spec from the firmware and sets
544 * some basic parameters.
545 *
546 * @param priv A pointer to struct lbs_private structure
547 * @return 0 or -1
548 */
549static int lbs_setup_firmware(struct lbs_private *priv)
550{
551 int ret = -1;
552 s16 curlevel = 0, minlevel = 0, maxlevel = 0;
553
554 lbs_deb_enter(LBS_DEB_FW);
555
556 /* Read MAC address from firmware */
557 memset(priv->current_addr, 0xff, ETH_ALEN);
558 ret = lbs_update_hw_spec(priv);
559 if (ret)
560 goto done;
561
562 /* Read power levels if available */
563 ret = lbs_get_tx_power(priv, &curlevel, &minlevel, &maxlevel);
564 if (ret == 0) {
565 priv->txpower_cur = curlevel;
566 priv->txpower_min = minlevel;
567 priv->txpower_max = maxlevel;
568 }
569
570 /* Send cmd to FW to enable 11D function */
571 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_11D_ENABLE, 1);
572
573 lbs_set_mac_control(priv);
574done:
575 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
576 return ret;
577}
578
542int lbs_suspend(struct lbs_private *priv) 579int lbs_suspend(struct lbs_private *priv)
543{ 580{
544 int ret; 581 int ret;
@@ -584,47 +621,13 @@ int lbs_resume(struct lbs_private *priv)
584 lbs_pr_err("deep sleep activation failed: %d\n", ret); 621 lbs_pr_err("deep sleep activation failed: %d\n", ret);
585 } 622 }
586 623
587 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret); 624 if (priv->setup_fw_on_resume)
588 return ret; 625 ret = lbs_setup_firmware(priv);
589}
590EXPORT_SYMBOL_GPL(lbs_resume);
591
592/**
593 * @brief This function gets the HW spec from the firmware and sets
594 * some basic parameters.
595 *
596 * @param priv A pointer to struct lbs_private structure
597 * @return 0 or -1
598 */
599static int lbs_setup_firmware(struct lbs_private *priv)
600{
601 int ret = -1;
602 s16 curlevel = 0, minlevel = 0, maxlevel = 0;
603
604 lbs_deb_enter(LBS_DEB_FW);
605
606 /* Read MAC address from firmware */
607 memset(priv->current_addr, 0xff, ETH_ALEN);
608 ret = lbs_update_hw_spec(priv);
609 if (ret)
610 goto done;
611
612 /* Read power levels if available */
613 ret = lbs_get_tx_power(priv, &curlevel, &minlevel, &maxlevel);
614 if (ret == 0) {
615 priv->txpower_cur = curlevel;
616 priv->txpower_min = minlevel;
617 priv->txpower_max = maxlevel;
618 }
619 626
620 /* Send cmd to FW to enable 11D function */
621 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_11D_ENABLE, 1);
622
623 lbs_set_mac_control(priv);
624done:
625 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret); 627 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
626 return ret; 628 return ret;
627} 629}
630EXPORT_SYMBOL_GPL(lbs_resume);
628 631
629/** 632/**
630 * This function handles the timeout of command sending. 633 * This function handles the timeout of command sending.