aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-12-11 12:42:16 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:06:42 -0500
commit6e66f03ff78b23d845920739373b1561c546b13f (patch)
treec190caf119aedbcc07d6020226dfd4637ef44970 /drivers/net
parenta8bdcd71fd33e4a919f9f0cb32207c644b70853f (diff)
libertas: convert GET_HW_SPEC to a direct command
Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/libertas/cmd.c76
-rw-r--r--drivers/net/wireless/libertas/cmd.h2
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c67
-rw-r--r--drivers/net/wireless/libertas/hostcmd.h3
-rw-r--r--drivers/net/wireless/libertas/main.c6
5 files changed, 73 insertions, 81 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index c4b32a05de10..bb940cce3a73 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -11,6 +11,7 @@
11#include "dev.h" 11#include "dev.h"
12#include "join.h" 12#include "join.h"
13#include "wext.h" 13#include "wext.h"
14#include "cmd.h"
14 15
15static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode); 16static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode);
16struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv); 17struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
@@ -36,18 +37,78 @@ static u8 is_command_allowed_in_ps(u16 cmd)
36 return 0; 37 return 0;
37} 38}
38 39
39static int lbs_cmd_hw_spec(struct lbs_private *priv, struct cmd_ds_command *cmd) 40/**
41 * @brief Updates the hardware details like MAC address and regulatory region
42 *
43 * @param priv A pointer to struct lbs_private structure
44 *
45 * @return 0 on success, error on failure
46 */
47int lbs_update_hw_spec(struct lbs_private *priv)
40{ 48{
41 struct cmd_ds_get_hw_spec *hwspec = &cmd->params.hwspec; 49 struct cmd_ds_get_hw_spec cmd;
50 int ret = -1;
51 u32 i;
52 DECLARE_MAC_BUF(mac);
42 53
43 lbs_deb_enter(LBS_DEB_CMD); 54 lbs_deb_enter(LBS_DEB_CMD);
44 55
45 cmd->command = cpu_to_le16(CMD_GET_HW_SPEC); 56 memset(&cmd, 0, sizeof(cmd));
46 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN); 57 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
47 memcpy(hwspec->permanentaddr, priv->current_addr, ETH_ALEN); 58 memcpy(cmd.permanentaddr, priv->current_addr, ETH_ALEN);
59 ret = lbs_cmd_with_response(priv, CMD_GET_HW_SPEC, cmd);
60 if (ret)
61 goto out;
62
63 priv->fwcapinfo = le32_to_cpu(cmd.fwcapinfo);
64 memcpy(priv->fwreleasenumber, cmd.fwreleasenumber, 4);
65
66 lbs_deb_cmd("GET_HW_SPEC: firmware release %u.%u.%up%u\n",
67 priv->fwreleasenumber[2], priv->fwreleasenumber[1],
68 priv->fwreleasenumber[0], priv->fwreleasenumber[3]);
69 lbs_deb_cmd("GET_HW_SPEC: MAC addr %s\n",
70 print_mac(mac, cmd.permanentaddr));
71 lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
72 cmd.hwifversion, cmd.version);
73
74 /* Clamp region code to 8-bit since FW spec indicates that it should
75 * only ever be 8-bit, even though the field size is 16-bit. Some firmware
76 * returns non-zero high 8 bits here.
77 */
78 priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF;
79
80 for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
81 /* use the region code to search for the index */
82 if (priv->regioncode == lbs_region_code_to_index[i])
83 break;
84 }
48 85
86 /* if it's unidentified region code, use the default (USA) */
87 if (i >= MRVDRV_MAX_REGION_CODE) {
88 priv->regioncode = 0x10;
89 lbs_pr_info("unidentified region code; using the default (USA)\n");
90 }
91
92 if (priv->current_addr[0] == 0xff)
93 memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN);
94
95 memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN);
96 if (priv->mesh_dev)
97 memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN);
98
99 if (lbs_set_regiontable(priv, priv->regioncode, 0)) {
100 ret = -1;
101 goto out;
102 }
103
104 if (lbs_set_universaltable(priv, 0)) {
105 ret = -1;
106 goto out;
107 }
108
109out:
49 lbs_deb_leave(LBS_DEB_CMD); 110 lbs_deb_leave(LBS_DEB_CMD);
50 return 0; 111 return ret;
51} 112}
52 113
53static int lbs_cmd_802_11_ps_mode(struct lbs_private *priv, 114static int lbs_cmd_802_11_ps_mode(struct lbs_private *priv,
@@ -1223,9 +1284,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1223 cmdptr->result = 0; 1284 cmdptr->result = 0;
1224 1285
1225 switch (cmd_no) { 1286 switch (cmd_no) {
1226 case CMD_GET_HW_SPEC:
1227 ret = lbs_cmd_hw_spec(priv, cmdptr);
1228 break;
1229 case CMD_802_11_PS_MODE: 1287 case CMD_802_11_PS_MODE:
1230 ret = lbs_cmd_802_11_ps_mode(priv, cmdptr, cmd_action); 1288 ret = lbs_cmd_802_11_ps_mode(priv, cmdptr, cmd_action);
1231 break; 1289 break;
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h
index 72857a1a2482..b8e5d21329a3 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -22,4 +22,6 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command,
22int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, 22int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
23 struct cmd_header *resp); 23 struct cmd_header *resp);
24 24
25int lbs_update_hw_spec(struct lbs_private *priv);
26
25#endif /* _LBS_CMD_H */ 27#endif /* _LBS_CMD_H */
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index 91136697f697..671e323764c8 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -145,69 +145,6 @@ static int lbs_ret_reg_access(struct lbs_private *priv,
145 return ret; 145 return ret;
146} 146}
147 147
148static int lbs_ret_get_hw_spec(struct lbs_private *priv,
149 struct cmd_ds_command *resp)
150{
151 u32 i;
152 struct cmd_ds_get_hw_spec *hwspec = &resp->params.hwspec;
153 int ret = 0;
154 DECLARE_MAC_BUF(mac);
155
156 lbs_deb_enter(LBS_DEB_CMD);
157
158 priv->fwcapinfo = le32_to_cpu(hwspec->fwcapinfo);
159
160 memcpy(priv->fwreleasenumber, hwspec->fwreleasenumber, 4);
161
162 lbs_deb_cmd("GET_HW_SPEC: firmware release %u.%u.%up%u\n",
163 priv->fwreleasenumber[2], priv->fwreleasenumber[1],
164 priv->fwreleasenumber[0], priv->fwreleasenumber[3]);
165 lbs_deb_cmd("GET_HW_SPEC: MAC addr %s\n",
166 print_mac(mac, hwspec->permanentaddr));
167 lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
168 hwspec->hwifversion, hwspec->version);
169
170 /* Clamp region code to 8-bit since FW spec indicates that it should
171 * only ever be 8-bit, even though the field size is 16-bit. Some firmware
172 * returns non-zero high 8 bits here.
173 */
174 priv->regioncode = le16_to_cpu(hwspec->regioncode) & 0xFF;
175
176 for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
177 /* use the region code to search for the index */
178 if (priv->regioncode == lbs_region_code_to_index[i]) {
179 break;
180 }
181 }
182
183 /* if it's unidentified region code, use the default (USA) */
184 if (i >= MRVDRV_MAX_REGION_CODE) {
185 priv->regioncode = 0x10;
186 lbs_pr_info("unidentified region code; using the default (USA)\n");
187 }
188
189 if (priv->current_addr[0] == 0xff)
190 memmove(priv->current_addr, hwspec->permanentaddr, ETH_ALEN);
191
192 memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN);
193 if (priv->mesh_dev)
194 memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN);
195
196 if (lbs_set_regiontable(priv, priv->regioncode, 0)) {
197 ret = -1;
198 goto done;
199 }
200
201 if (lbs_set_universaltable(priv, 0)) {
202 ret = -1;
203 goto done;
204 }
205
206done:
207 lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret);
208 return ret;
209}
210
211static int lbs_ret_802_11_sleep_params(struct lbs_private *priv, 148static int lbs_ret_802_11_sleep_params(struct lbs_private *priv,
212 struct cmd_ds_command *resp) 149 struct cmd_ds_command *resp)
213{ 150{
@@ -569,10 +506,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
569 ret = lbs_ret_reg_access(priv, respcmd, resp); 506 ret = lbs_ret_reg_access(priv, respcmd, resp);
570 break; 507 break;
571 508
572 case CMD_RET(CMD_GET_HW_SPEC):
573 ret = lbs_ret_get_hw_spec(priv, resp);
574 break;
575
576 case CMD_RET(CMD_802_11_SCAN): 509 case CMD_RET(CMD_802_11_SCAN):
577 ret = lbs_ret_80211_scan(priv, resp); 510 ret = lbs_ret_80211_scan(priv, resp);
578 break; 511 break;
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h
index 93ac46a05c54..a87c2174bbf3 100644
--- a/drivers/net/wireless/libertas/hostcmd.h
+++ b/drivers/net/wireless/libertas/hostcmd.h
@@ -119,6 +119,8 @@ struct cmd_ds_gen {
119 * This structure defines the response for the GET_HW_SPEC command 119 * This structure defines the response for the GET_HW_SPEC command
120 */ 120 */
121struct cmd_ds_get_hw_spec { 121struct cmd_ds_get_hw_spec {
122 struct cmd_header hdr;
123
122 /* HW Interface version number */ 124 /* HW Interface version number */
123 __le16 hwifversion; 125 __le16 hwifversion;
124 /* HW version number */ 126 /* HW version number */
@@ -637,7 +639,6 @@ struct cmd_ds_command {
637 639
638 /* command Body */ 640 /* command Body */
639 union { 641 union {
640 struct cmd_ds_get_hw_spec hwspec;
641 struct cmd_ds_802_11_ps_mode psmode; 642 struct cmd_ds_802_11_ps_mode psmode;
642 struct cmd_ds_802_11_scan scan; 643 struct cmd_ds_802_11_scan scan;
643 struct cmd_ds_802_11_scan_rsp scanresp; 644 struct cmd_ds_802_11_scan_rsp scanresp;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 9a231099212f..9f6c119c2d1b 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -22,6 +22,7 @@
22#include "debugfs.h" 22#include "debugfs.h"
23#include "assoc.h" 23#include "assoc.h"
24#include "join.h" 24#include "join.h"
25#include "cmd.h"
25 26
26#define DRIVER_RELEASE_VERSION "323.p0" 27#define DRIVER_RELEASE_VERSION "323.p0"
27const char lbs_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION 28const char lbs_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
@@ -843,10 +844,7 @@ static int lbs_setup_firmware(struct lbs_private *priv)
843 * Read MAC address from HW 844 * Read MAC address from HW
844 */ 845 */
845 memset(priv->current_addr, 0xff, ETH_ALEN); 846 memset(priv->current_addr, 0xff, ETH_ALEN);
846 847 ret = lbs_update_hw_spec(priv);
847 ret = lbs_prepare_and_send_command(priv, CMD_GET_HW_SPEC,
848 0, CMD_OPTION_WAITFORRSP, 0, NULL);
849
850 if (ret) { 848 if (ret) {
851 ret = -1; 849 ret = -1;
852 goto done; 850 goto done;