Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 79162
b: refs/heads/master
c: 6e66f03
h: refs/heads/master
v: v3
  • Loading branch information
Dan Williams authored and David S. Miller committed Jan 28, 2008
1 parent ddbb706 commit 981bcdd
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 82 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a8bdcd71fd33e4a919f9f0cb32207c644b70853f
refs/heads/master: 6e66f03ff78b23d845920739373b1561c546b13f
76 changes: 67 additions & 9 deletions trunk/drivers/net/wireless/libertas/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "dev.h"
#include "join.h"
#include "wext.h"
#include "cmd.h"

static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode);
struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
Expand All @@ -36,18 +37,78 @@ static u8 is_command_allowed_in_ps(u16 cmd)
return 0;
}

static int lbs_cmd_hw_spec(struct lbs_private *priv, struct cmd_ds_command *cmd)
/**
* @brief Updates the hardware details like MAC address and regulatory region
*
* @param priv A pointer to struct lbs_private structure
*
* @return 0 on success, error on failure
*/
int lbs_update_hw_spec(struct lbs_private *priv)
{
struct cmd_ds_get_hw_spec *hwspec = &cmd->params.hwspec;
struct cmd_ds_get_hw_spec cmd;
int ret = -1;
u32 i;
DECLARE_MAC_BUF(mac);

lbs_deb_enter(LBS_DEB_CMD);

cmd->command = cpu_to_le16(CMD_GET_HW_SPEC);
cmd->size = cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN);
memcpy(hwspec->permanentaddr, priv->current_addr, ETH_ALEN);
memset(&cmd, 0, sizeof(cmd));
cmd.hdr.size = cpu_to_le16(sizeof(cmd));
memcpy(cmd.permanentaddr, priv->current_addr, ETH_ALEN);
ret = lbs_cmd_with_response(priv, CMD_GET_HW_SPEC, cmd);
if (ret)
goto out;

priv->fwcapinfo = le32_to_cpu(cmd.fwcapinfo);
memcpy(priv->fwreleasenumber, cmd.fwreleasenumber, 4);

lbs_deb_cmd("GET_HW_SPEC: firmware release %u.%u.%up%u\n",
priv->fwreleasenumber[2], priv->fwreleasenumber[1],
priv->fwreleasenumber[0], priv->fwreleasenumber[3]);
lbs_deb_cmd("GET_HW_SPEC: MAC addr %s\n",
print_mac(mac, cmd.permanentaddr));
lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
cmd.hwifversion, cmd.version);

/* Clamp region code to 8-bit since FW spec indicates that it should
* only ever be 8-bit, even though the field size is 16-bit. Some firmware
* returns non-zero high 8 bits here.
*/
priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF;

for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
/* use the region code to search for the index */
if (priv->regioncode == lbs_region_code_to_index[i])
break;
}

/* if it's unidentified region code, use the default (USA) */
if (i >= MRVDRV_MAX_REGION_CODE) {
priv->regioncode = 0x10;
lbs_pr_info("unidentified region code; using the default (USA)\n");
}

if (priv->current_addr[0] == 0xff)
memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN);

memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN);
if (priv->mesh_dev)
memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN);

if (lbs_set_regiontable(priv, priv->regioncode, 0)) {
ret = -1;
goto out;
}

if (lbs_set_universaltable(priv, 0)) {
ret = -1;
goto out;
}

out:
lbs_deb_leave(LBS_DEB_CMD);
return 0;
return ret;
}

static int lbs_cmd_802_11_ps_mode(struct lbs_private *priv,
Expand Down Expand Up @@ -1223,9 +1284,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
cmdptr->result = 0;

switch (cmd_no) {
case CMD_GET_HW_SPEC:
ret = lbs_cmd_hw_spec(priv, cmdptr);
break;
case CMD_802_11_PS_MODE:
ret = lbs_cmd_802_11_ps_mode(priv, cmdptr, cmd_action);
break;
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/net/wireless/libertas/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command,
int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
struct cmd_header *resp);

int lbs_update_hw_spec(struct lbs_private *priv);

#endif /* _LBS_CMD_H */
67 changes: 0 additions & 67 deletions trunk/drivers/net/wireless/libertas/cmdresp.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,69 +145,6 @@ static int lbs_ret_reg_access(struct lbs_private *priv,
return ret;
}

static int lbs_ret_get_hw_spec(struct lbs_private *priv,
struct cmd_ds_command *resp)
{
u32 i;
struct cmd_ds_get_hw_spec *hwspec = &resp->params.hwspec;
int ret = 0;
DECLARE_MAC_BUF(mac);

lbs_deb_enter(LBS_DEB_CMD);

priv->fwcapinfo = le32_to_cpu(hwspec->fwcapinfo);

memcpy(priv->fwreleasenumber, hwspec->fwreleasenumber, 4);

lbs_deb_cmd("GET_HW_SPEC: firmware release %u.%u.%up%u\n",
priv->fwreleasenumber[2], priv->fwreleasenumber[1],
priv->fwreleasenumber[0], priv->fwreleasenumber[3]);
lbs_deb_cmd("GET_HW_SPEC: MAC addr %s\n",
print_mac(mac, hwspec->permanentaddr));
lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
hwspec->hwifversion, hwspec->version);

/* Clamp region code to 8-bit since FW spec indicates that it should
* only ever be 8-bit, even though the field size is 16-bit. Some firmware
* returns non-zero high 8 bits here.
*/
priv->regioncode = le16_to_cpu(hwspec->regioncode) & 0xFF;

for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
/* use the region code to search for the index */
if (priv->regioncode == lbs_region_code_to_index[i]) {
break;
}
}

/* if it's unidentified region code, use the default (USA) */
if (i >= MRVDRV_MAX_REGION_CODE) {
priv->regioncode = 0x10;
lbs_pr_info("unidentified region code; using the default (USA)\n");
}

if (priv->current_addr[0] == 0xff)
memmove(priv->current_addr, hwspec->permanentaddr, ETH_ALEN);

memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN);
if (priv->mesh_dev)
memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN);

if (lbs_set_regiontable(priv, priv->regioncode, 0)) {
ret = -1;
goto done;
}

if (lbs_set_universaltable(priv, 0)) {
ret = -1;
goto done;
}

done:
lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret);
return ret;
}

static int lbs_ret_802_11_sleep_params(struct lbs_private *priv,
struct cmd_ds_command *resp)
{
Expand Down Expand Up @@ -569,10 +506,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
ret = lbs_ret_reg_access(priv, respcmd, resp);
break;

case CMD_RET(CMD_GET_HW_SPEC):
ret = lbs_ret_get_hw_spec(priv, resp);
break;

case CMD_RET(CMD_802_11_SCAN):
ret = lbs_ret_80211_scan(priv, resp);
break;
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/net/wireless/libertas/hostcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ struct cmd_ds_gen {
* This structure defines the response for the GET_HW_SPEC command
*/
struct cmd_ds_get_hw_spec {
struct cmd_header hdr;

/* HW Interface version number */
__le16 hwifversion;
/* HW version number */
Expand Down Expand Up @@ -637,7 +639,6 @@ struct cmd_ds_command {

/* command Body */
union {
struct cmd_ds_get_hw_spec hwspec;
struct cmd_ds_802_11_ps_mode psmode;
struct cmd_ds_802_11_scan scan;
struct cmd_ds_802_11_scan_rsp scanresp;
Expand Down
6 changes: 2 additions & 4 deletions trunk/drivers/net/wireless/libertas/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "debugfs.h"
#include "assoc.h"
#include "join.h"
#include "cmd.h"

#define DRIVER_RELEASE_VERSION "323.p0"
const char lbs_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
Expand Down Expand Up @@ -843,10 +844,7 @@ static int lbs_setup_firmware(struct lbs_private *priv)
* Read MAC address from HW
*/
memset(priv->current_addr, 0xff, ETH_ALEN);

ret = lbs_prepare_and_send_command(priv, CMD_GET_HW_SPEC,
0, CMD_OPTION_WAITFORRSP, 0, NULL);

ret = lbs_update_hw_spec(priv);
if (ret) {
ret = -1;
goto done;
Expand Down

0 comments on commit 981bcdd

Please sign in to comment.